Handle registration setups better when username contains an @
authorMark Spencer <markster@digium.com>
Sun, 15 Jun 2003 22:53:05 +0000 (22:53 +0000)
committerMark Spencer <markster@digium.com>
Sun, 15 Jun 2003 22:53:05 +0000 (22:53 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1093 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index 77f301b..87f179f 100755 (executable)
@@ -2613,8 +2613,13 @@ static int transmit_register(struct sip_registry *r, char *cmd, char *auth)
                ast_log(LOG_DEBUG, "Scheduled a timeout # %d\n", r->timeout);
        }
 
-       snprintf(from, sizeof(from), "<sip:%s@%s>;tag=as%08x", r->username, r->hostname, p->tag);
-       snprintf(to, sizeof(to),     "<sip:%s@%s>", r->username, r->hostname);
+       if (strchr(r->username, '@')) {
+               snprintf(from, sizeof(from), "<sip:%s>;tag=as%08x", r->username, p->tag);
+               snprintf(to, sizeof(to),     "<sip:%s>", r->username);
+       } else {
+               snprintf(from, sizeof(from), "<sip:%s@%s>;tag=as%08x", r->username, r->hostname, p->tag);
+               snprintf(to, sizeof(to),     "<sip:%s@%s>", r->username, r->hostname);
+       }
        
        snprintf(addr, sizeof(addr), "sip:%s", r->hostname);
        strncpy(p->uri, addr, sizeof(p->uri) - 1);