[asterisk-commits] dvossel: branch 1.6.2 r235134 - /branches/1.6.2/channels/chan_sip.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Dec 15 12:47:45 CST 2009


Author: dvossel
Date: Tue Dec 15 12:47:43 2009
New Revision: 235134

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=235134
Log:
reverses minor sip registration regression

reverses the changes caused by issue #15539. The
issue reported was expected behavior.

(issue #15539)

Modified:
    branches/1.6.2/channels/chan_sip.c

Modified: branches/1.6.2/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.2/channels/chan_sip.c?view=diff&rev=235134&r1=235133&r2=235134
==============================================================================
--- branches/1.6.2/channels/chan_sip.c (original)
+++ branches/1.6.2/channels/chan_sip.c Tue Dec 15 12:47:43 2009
@@ -11543,6 +11543,7 @@
 	struct sip_peer *peer = NULL;
 	int res;
 	char *fromdomain;
+	char *domainport = NULL;
 
 	/* exit if we are already in process with this registrar ?*/
 	if (r == NULL || ((auth == NULL) && (r->regstate == REG_STATE_REGSENT || r->regstate == REG_STATE_AUTHSENT))) {
@@ -11701,14 +11702,33 @@
 		else
 			snprintf(to, sizeof(to), "<sip:%s@%s>", r->username, p->tohost);
 	}
-
-	/* Host is what we are registered to, regardless if a domain exists in the username */
-	if (r->portno && r->portno != STANDARD_SIP_PORT) {
-		snprintf(addr, sizeof(addr), "sip:%s:%d", r->hostname, r->portno);
+	
+	/* Fromdomain is what we are registering to, regardless of actual
+	   host name from SRV */
+	if (!ast_strlen_zero(p->fromdomain)) {
+		domainport = strrchr(p->fromdomain, ':');
+		if (domainport) {
+			*domainport++ = '\0'; /* trim off domainport from p->fromdomain */
+			if (ast_strlen_zero(domainport))
+				domainport = NULL;
+		}		
+		if (domainport) {			
+			if (atoi(domainport) != STANDARD_SIP_PORT)
+				snprintf(addr, sizeof(addr), "sip:%s:%s", p->fromdomain, domainport);
+			else
+				snprintf(addr, sizeof(addr), "sip:%s", p->fromdomain);
+		} else {
+			if (r->portno && r->portno != STANDARD_SIP_PORT)
+				snprintf(addr, sizeof(addr), "sip:%s:%d", p->fromdomain, r->portno);
+			else
+				snprintf(addr, sizeof(addr), "sip:%s", p->fromdomain);
+		}
 	} else {
-		snprintf(addr, sizeof(addr), "sip:%s", r->hostname);
-	}
-
+		if (r->portno && r->portno != STANDARD_SIP_PORT)
+			snprintf(addr, sizeof(addr), "sip:%s:%d", r->hostname, r->portno);
+		else
+			snprintf(addr, sizeof(addr), "sip:%s", r->hostname);
+	}
 	ast_string_field_set(p, uri, addr);
 
 	p->branch ^= ast_random();




More information about the asterisk-commits mailing list