diff options
author | rizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-05-11 09:38:53 +0000 |
---|---|---|
committer | rizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-05-11 09:38:53 +0000 |
commit | 23875cea7917001e9fe79c4fdbb6ba6b9b04dc9a (patch) | |
tree | abb181f59e79359e42c7a0423cc2315ba5115d8f | |
parent | c346de75180b22ab4025522eef3c59ace7c0cdd9 (diff) |
simplify init_req()
As the rest of the chan_sip.c changes i am committing, this is
Approved by: oej
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@26804 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r-- | channels/chan_sip.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 90f8af722..3994615d1 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -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 */ |