[asterisk-commits] trunk r26915 - /trunk/channels/chan_sip.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu May 11 07:35:07 MST 2006


Author: rizzo
Date: Thu May 11 09:35:06 2006
New Revision: 26915

URL: http://svn.digium.com/view/asterisk?rev=26915&view=rev
Log:
remove almost all useless instances of add_blank_header() but one,
for which i need to investigate a bit more (but i am almost 100%
sure that one is also useless).
I do the commit in two steps so it is easier to track the problem.


Modified:
    trunk/channels/chan_sip.c

Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?rev=26915&r1=26914&r2=26915&view=diff
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Thu May 11 09:35:06 2006
@@ -1796,11 +1796,22 @@
 	parse_request(dst);
 }
 
+/* add a blank line if no body */
+static void add_blank(struct sip_request *req)
+{
+	if (!req->lines) {
+		/* Add extra empty return. add_header() reserves 4 bytes so cannot be truncated */
+		snprintf(req->data + req->len, sizeof(req->data) - req->len, "\r\n");
+		req->len += strlen(req->data + req->len);
+	}
+}
+
 /*! \brief Transmit response on SIP request*/
 static int send_response(struct sip_pvt *p, struct sip_request *req, enum xmittype reliable, int seqno)
 {
 	int res;
 
+	add_blank(req);
 	if (sip_debug_test_pvt(p)) {
 		char iabuf[INET_ADDRSTRLEN];
 		if (ast_test_flag(&p->flags[0], SIP_NAT_ROUTE))
@@ -1827,6 +1838,7 @@
 {
 	int res;
 
+	add_blank(req);
 	if (sip_debug_test_pvt(p)) {
 		char iabuf[INET_ADDRSTRLEN];
 		if (ast_test_flag(&p->flags[0], SIP_NAT_ROUTE))
@@ -4578,7 +4590,6 @@
 		snprintf(buf, sizeof(buf), "%d", p->owner->hangupcause);
 		add_header(&resp, "X-Asterisk-HangupCauseCode", buf);
 	}
-	add_blank_header(&resp);
 	return send_response(p, &resp, reliable, seqno);
 }
 
@@ -4625,7 +4636,6 @@
 	respprep(&resp, p, msg, req);
 	append_date(&resp);
 	add_header_contentLength(&resp, 0);
-	add_blank_header(&resp);
 	return send_response(p, &resp, XMIT_UNRELIABLE, 0);
 }
 
@@ -4636,7 +4646,6 @@
 	respprep(&resp, p, msg, req);
 	add_header(&resp, "Accept", "application/sdp");
 	add_header_contentLength(&resp, 0);
-	add_blank_header(&resp);
 	return send_response(p, &resp, reliable, 0);
 }
 
@@ -4657,7 +4666,6 @@
 	respprep(&resp, p, msg, req);
 	add_header(&resp, header, tmp);
 	add_header_contentLength(&resp, 0);
-	add_blank_header(&resp);
 	return send_response(p, &resp, reliable, seqno);
 }
 
@@ -5395,7 +5403,6 @@
 		add_sdp(&req, p);
 	} else {
 		add_header_contentLength(&req, 0);
-		add_blank_header(&req);
 	}
 
 	if (!p->initreq.headers)
@@ -5915,7 +5922,6 @@
 	add_header(&req, "Contact", p->our_contact);
 	add_header(&req, "Event", "registration");
 	add_header_contentLength(&req, 0);
-	add_blank_header(&req);
 
 	initialize_initreq(p, &req);
 	if (sip_debug_test_pvt(p))
@@ -6000,7 +6006,6 @@
 	add_header(&req, "Supported", SUPPORTED_EXTENSIONS);
 	if (!ast_strlen_zero(p->our_contact))
 		add_header(&req, "Referred-By", p->our_contact);
-	add_blank_header(&req);
 
 	return send_request(p, &req, 1, p->ocseq);
 	/* We should propably wait for a NOTIFY here until we ack the transfer */
@@ -6038,7 +6043,6 @@
 	struct sip_request resp;
 	reqprep(&resp, p, sipmethod, seqno, newbranch);
 	add_header_contentLength(&resp, 0);
-	add_blank_header(&resp);
 	return send_request(p, &resp, reliable, seqno ? seqno : p->ocseq);
 }
 
@@ -6073,7 +6077,6 @@
 	}
 
 	add_header_contentLength(&resp, 0);
-	add_blank_header(&resp);
 	return send_request(p, &resp, reliable, seqno ? seqno : p->ocseq);	
 }
 



More information about the asterisk-commits mailing list