diff options
author | dvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-12-15 18:47:43 +0000 |
---|---|---|
committer | dvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-12-15 18:47:43 +0000 |
commit | 595eaacd59e8adaf8801afd4995643c6d53871b5 (patch) | |
tree | f23fd1fb005dd83d72b413e070868e386f162ce0 /channels | |
parent | 15a10f400d5feba8d59b7457e0df19fe6dd39657 (diff) |
reverses minor sip registration regression
reverses the changes caused by issue #15539. The
issue reported was expected behavior.
(issue #15539)
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.2@235134 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r-- | channels/chan_sip.c | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 73ee8fa2c..989738620 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -11543,6 +11543,7 @@ static int transmit_register(struct sip_registry *r, int sipmethod, const char * 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 @@ static int transmit_register(struct sip_registry *r, int sipmethod, const char * 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(); |