[svn-commits] branch group/sip-threading r26807 - in /team/group/sip-threading: ./ channels/

svn-commits at lists.digium.com svn-commits at lists.digium.com
Thu May 11 02:49:11 MST 2006


Author: file
Date: Thu May 11 04:49:11 2006
New Revision: 26807

URL: http://svn.digium.com/view/asterisk?rev=26807&view=rev
Log:
Merged revisions 26801-26802,26804 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
r26801 | rizzo | 2006-05-11 04:32:51 -0500 (Thu, 11 May 2006) | 3 lines

staticize a variable.


........
r26802 | rizzo | 2006-05-11 04:36:10 -0500 (Thu, 11 May 2006) | 3 lines

cleanup init_resp with proper variable names and arguments.


........
r26804 | rizzo | 2006-05-11 04:38:53 -0500 (Thu, 11 May 2006) | 6 lines

simplify init_req()
As the rest of the chan_sip.c changes i am committing, this is

Approved by: oej


........

Modified:
    team/group/sip-threading/   (props changed)
    team/group/sip-threading/channels/chan_sip.c

Propchange: team/group/sip-threading/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Thu May 11 04:49:11 2006
@@ -1,1 +1,1 @@
-/trunk:1-26800
+/trunk:1-26806

Modified: team/group/sip-threading/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/group/sip-threading/channels/chan_sip.c?rev=26807&r1=26806&r2=26807&view=diff
==============================================================================
--- team/group/sip-threading/channels/chan_sip.c (original)
+++ team/group/sip-threading/channels/chan_sip.c Thu May 11 04:49:11 2006
@@ -1042,7 +1042,7 @@
 static int ourport;
 static struct sockaddr_in debugaddr;
 
-struct ast_config *notify_types;		/*!< The list of manual NOTIFY types we know how to send */
+static struct ast_config *notify_types;		/*!< The list of manual NOTIFY types we know how to send */
 
 /*---------------------------- Forward declarations of functions in chan_sip.c */
 /*! \note Sorted up from start to build_rpid.... Will continue categorization in order to
@@ -1207,7 +1207,7 @@
 static void initialize_initreq(struct sip_pvt *p, struct sip_request *req);
 static int init_req(struct sip_request *req, int sipmethod, const char *recip);
 static int reqprep(struct sip_request *req, struct sip_pvt *p, int sipmethod, int seqno, int newbranch);
-static int init_resp(struct sip_request *req, const char *resp, struct sip_request *orig);
+static int init_resp(struct sip_request *resp, const char *msg);
 static int respprep(struct sip_request *resp, struct sip_pvt *p, const char *msg, struct sip_request *req);
 static const struct sockaddr_in *sip_real_dst(const struct sip_pvt *p);
 static void build_via(struct sip_pvt *p);
@@ -4489,37 +4489,31 @@
 }
 
 /*! \brief Initialize SIP response, based on SIP request */
-static int init_resp(struct sip_request *req, const char *resp, struct sip_request *orig)
+static int init_resp(struct sip_request *resp, const char *msg)
 {
 	/* Initialize a response */
-	if (req->headers || req->len) {
-		ast_log(LOG_WARNING, "Request already initialized?!?\n");
-		return -1;
-	}
-	req->method = SIP_RESPONSE;
-	req->header[req->headers] = req->data + req->len;
-	snprintf(req->header[req->headers], sizeof(req->data) - req->len, "SIP/2.0 %s\r\n", resp);
-	req->len += strlen(req->header[req->headers]);
+	memset(resp, 0, sizeof(*resp));
+	resp->method = SIP_RESPONSE;
+	resp->header[0] = resp->data;
+	snprintf(resp->header[0], sizeof(resp->data), "SIP/2.0 %s\r\n", msg);
+	resp->len = strlen(resp->header[0]);
+	resp->headers++;
+	return 0;
+}
+
+/*! \brief Initialize SIP request */
+static int init_req(struct sip_request *req, int sipmethod, const char *recip)
+{
+	/* 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++;
 	return 0;
 }
 
-/*! \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]);
-	req->headers++;
-	req->method = sipmethod;
-	return 0;
-}
-
 
 /*! \brief Prepare SIP response packet */
 static int respprep(struct sip_request *resp, struct sip_pvt *p, const char *msg, struct sip_request *req)
@@ -4527,8 +4521,7 @@
 	char newto[256];
 	const char *ot;
 
-	memset(resp, 0, sizeof(*resp));
-	init_resp(resp, msg, req);
+	init_resp(resp, msg);
 	copy_via_headers(p, resp, req, "Via");
 	if (msg[0] == '2')
 		copy_all_header(resp, req, "Record-Route");
@@ -5398,7 +5391,6 @@
 		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);
 
@@ -5986,7 +5978,6 @@
 
 	p->branch ^= ast_random();
 
-	memset(&req, 0, sizeof(req));
 	init_req(&req, sipmethod, addr);
 
 	/* Add to CSEQ */



More information about the svn-commits mailing list