]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Issue #9229 - No port in request URI on register to non default SIP ports (neelakantan)
authorOlle Johansson <oej@edvina.net>
Tue, 13 Mar 2007 11:45:52 +0000 (11:45 +0000)
committerOlle Johansson <oej@edvina.net>
Tue, 13 Mar 2007 11:45:52 +0000 (11:45 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@58847 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index d2ae1047243aff3dd68a285acd386653b7fcb7a9..8946bab589cd3eb6200665ea1b856e0d18c9ceb6 100644 (file)
@@ -5643,10 +5643,17 @@ static int transmit_register(struct sip_registry *r, int sipmethod, char *auth,
        
        /* Fromdomain is what we are registering to, regardless of actual
           host name from SRV */
-       if (!ast_strlen_zero(p->fromdomain))
-               snprintf(addr, sizeof(addr), "sip:%s", p->fromdomain);
-       else
-               snprintf(addr, sizeof(addr), "sip:%s", r->hostname);
+       if (!ast_strlen_zero(p->fromdomain)) {
+               if (r->portno && r->portno != DEFAULT_SIP_PORT)
+                       snprintf(addr, sizeof(addr), "sip:%s:%d", p->fromdomain, r->portno);
+               else
+                       snprintf(addr, sizeof(addr), "sip:%s", p->fromdomain);
+       } else {
+               if (r->portno && r->portno != DEFAULT_SIP_PORT)
+                       snprintf(addr, sizeof(addr), "sip:%s:%d", r->hostname, r->portno);
+               else
+                       snprintf(addr, sizeof(addr), "sip:%s", r->hostname);
+       }
        ast_copy_string(p->uri, addr, sizeof(p->uri));
 
        p->branch ^= thread_safe_rand();