From: Olle Johansson Date: Tue, 1 Jul 2008 14:59:31 +0000 (+0000) Subject: Use domain part of SIP uri in register= configuration as fromdomain. X-Git-Tag: 1.4.22-rc1~160 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d3ba59fdc789fe5d9d59c5d4d696e7ba19f923b1;p=thirdparty%2Fasterisk.git Use domain part of SIP uri in register= configuration as fromdomain. Reported by: one47 Patches: sip-reg-fromdom2.dpatch uploaded by one47 (license 23) (closes issue #12474) git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@126902 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/channels/chan_sip.c b/channels/chan_sip.c index cc235abf0d..3451ffbe5c 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -7579,6 +7579,7 @@ static int transmit_register(struct sip_registry *r, int sipmethod, const char * char tmp[80]; char addr[80]; struct sip_pvt *p; + char *fromdomain; /* 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))) { @@ -7673,12 +7674,19 @@ static int transmit_register(struct sip_registry *r, int sipmethod, const char * ast_log(LOG_DEBUG, "Scheduled a registration timeout for %s id #%d \n", r->hostname, r->timeout); } - if (strchr(r->username, '@')) { + if ((fromdomain = strchr(r->username, '@'))) { + /* We have a domain in the username for registration */ snprintf(from, sizeof(from), ";tag=%s", r->username, p->tag); if (!ast_strlen_zero(p->theirtag)) snprintf(to, sizeof(to), ";tag=%s", r->username, p->theirtag); else snprintf(to, sizeof(to), "", r->username); + + /* If the registration username contains '@', then the domain should be used as + the equivalent of "fromdomain" for the registration */ + if (ast_strlen_zero(p->fromdomain)) { + ast_string_field_set(p, fromdomain, ++fromdomain); + } } else { snprintf(from, sizeof(from), ";tag=%s", r->username, p->tohost, p->tag); if (!ast_strlen_zero(p->theirtag))