]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
simplify init_req()
authorLuigi Rizzo <rizzo@icir.org>
Thu, 11 May 2006 09:38:53 +0000 (09:38 +0000)
committerLuigi Rizzo <rizzo@icir.org>
Thu, 11 May 2006 09:38:53 +0000 (09:38 +0000)
As the rest of the chan_sip.c changes i am committing, this is

Approved by: oej

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@26804 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index 90f8af7222d02fc93e47bd2242d1b631b276c3a8..3994615d1ba94b8fa73be5fb57e30e7aa02b47a7 100644 (file)
@@ -4396,16 +4396,13 @@ static int init_resp(struct sip_request *resp, const char *msg)
 /*! \brief Initialize SIP request */
 static int init_req(struct sip_request *req, int sipmethod, const char *recip)
 {
-       /* Initialize a response */
-       if (req->headers || req->len) {
-               ast_log(LOG_WARNING, "Request already initialized?!?\n");
-               return -1;
-       }
-       req->header[req->headers] = req->data + req->len;
-       snprintf(req->header[req->headers], sizeof(req->data) - req->len, "%s %s SIP/2.0\r\n", sip_methods[sipmethod].text, recip);
-       req->len += strlen(req->header[req->headers]);
+       /* Initialize a request */
+       memset(req, 0, sizeof(*req));
+        req->method = sipmethod;
+       req->header[0] = req->data;
+       snprintf(req->header[0], sizeof(req->data), "%s %s SIP/2.0\r\n", sip_methods[sipmethod].text, recip);
+       req->len = strlen(req->header[0]);
        req->headers++;
-       req->method = sipmethod;
        return 0;
 }
 
@@ -5286,7 +5283,6 @@ static void initreqprep(struct sip_request *req, struct sip_pvt *p, int sipmetho
                snprintf(to, sizeof(to), "<%s>", p->uri);
        }
        
-       memset(req, 0, sizeof(struct sip_request));
        init_req(req, sipmethod, p->uri);
        snprintf(tmp, sizeof(tmp), "%d %s", ++p->ocseq, sip_methods[sipmethod].text);
 
@@ -5874,7 +5870,6 @@ static int transmit_register(struct sip_registry *r, int sipmethod, char *auth,
 
        p->branch ^= ast_random();
 
-       memset(&req, 0, sizeof(req));
        init_req(&req, sipmethod, addr);
 
        /* Add to CSEQ */