[asterisk-commits] oej: trunk r49984 - in /trunk: ./ channels/chan_sip.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Jan 8 06:34:57 MST 2007


Author: oej
Date: Mon Jan  8 07:34:56 2007
New Revision: 49984

URL: http://svn.digium.com/view/asterisk?view=rev&rev=49984
Log:
Merged revisions 49983 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r49983 | oej | 2007-01-08 14:28:18 +0100 (Mon, 08 Jan 2007) | 3 lines

Issue #8524, support multiple via header values (tardieu)
	Thanks!

........

Modified:
    trunk/   (props changed)
    trunk/channels/chan_sip.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?view=diff&rev=49984&r1=49983&r2=49984
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Mon Jan  8 07:34:56 2007
@@ -5430,21 +5430,25 @@
 			break;
 
 		if (!copied) {	/* Only check for empty rport in topmost via header */
-			char *rport;
+			char leftmost[256], *others, *rport;
+
+			/* Only work on leftmost value */
+			ast_copy_string(leftmost, oh, sizeof(leftmost));
+			others = strchr(leftmost, ',');
+			if (others)
+			    *others++ = '\0';
 
 			/* Find ;rport;  (empty request) */
-			rport = strstr(oh, ";rport");
+			rport = strstr(leftmost, ";rport");
 			if (rport && *(rport+6) == '=') 
 				rport = NULL;		/* We already have a parameter to rport */
 
 			/* Check rport if NAT=yes or NAT=rfc3581 (which is the default setting)  */
 			if (rport && ((ast_test_flag(&p->flags[0], SIP_NAT) == SIP_NAT_ALWAYS) || (ast_test_flag(&p->flags[0], SIP_NAT) == SIP_NAT_RFC3581))) {
 				/* We need to add received port - rport */
-				char tmp[256], *end;
-
-				ast_copy_string(tmp, oh, sizeof(tmp));
-
-				rport = strstr(tmp, ";rport");
+				char *end;
+
+				rport = strstr(leftmost, ";rport");
 
 				if (rport) {
 					end = strchr(rport + 1, ';');
@@ -5455,13 +5459,15 @@
 				}
 
 				/* Add rport to first VIA header if requested */
-				snprintf(new, sizeof(new), "%s;received=%s;rport=%d",
-					tmp, ast_inet_ntoa(p->recv.sin_addr),
-					ntohs(p->recv.sin_port));
+				snprintf(new, sizeof(new), "%s;received=%s;rport=%d%s%s",
+					leftmost, ast_inet_ntoa(p->recv.sin_addr),
+					ntohs(p->recv.sin_port),
+					others ? "," : "", others ? others : "");
 			} else {
 				/* We should *always* add a received to the topmost via */
-				snprintf(new, sizeof(new), "%s;received=%s",
-					oh, ast_inet_ntoa(p->recv.sin_addr));
+				snprintf(new, sizeof(new), "%s;received=%s%s%s",
+					leftmost, ast_inet_ntoa(p->recv.sin_addr),
+					others ? "," : "", others ? others : "");
 			}
 			oh = new;	/* the header to copy */
 		}  /* else add the following via headers untouched */
@@ -8896,6 +8902,11 @@
 	struct ast_hostent ahp;
 
 	ast_copy_string(via, get_header(req, "Via"), sizeof(via));
+
+	/* Work on the leftmost value of the topmost Via header */
+	c = strchr(via, ',');
+	if (c)
+		*c = '\0';
 
 	/* Check for rport */
 	c = strstr(via, ";rport");



More information about the asterisk-commits mailing list