diff options
author | Olle Johansson <oej@edvina.net> | 2006-03-08 08:36:40 +0000 |
---|---|---|
committer | Olle Johansson <oej@edvina.net> | 2006-03-08 08:36:40 +0000 |
commit | 06abc680dd5198de59b4e6bd953cc919c711c085 (patch) | |
tree | c9207e0759c90f72a8a8ae2fa0965e473549a7e9 /channels | |
parent | 09ea61fc7393e0d0de214ac511a30ef4b18f7fe0 (diff) |
Set SIPDOMAIN on 302 redirects.
This way you can catch 302 redirects in the dial plan and see if
the redirect is to a local extension or a remote URI.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@12456 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels')
-rw-r--r-- | channels/chan_sip.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 2c76212a3..57d7c7db0 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -9502,6 +9502,8 @@ static void parse_moved_contact(struct sip_pvt *p, struct sip_request *req) { char tmp[256]; char *s, *e; + char *domain; + ast_copy_string(tmp, get_header(req, "Contact"), sizeof(tmp)); s = get_in_brackets(tmp); e = strchr(s, ';'); @@ -9518,16 +9520,25 @@ static void parse_moved_contact(struct sip_pvt *p, struct sip_request *req) ast_string_field_build(p->owner, call_forward, "SIP/%s", s); } else { e = strchr(tmp, '@'); - if (e) + if (e) { *e = '\0'; + e++; + domain = e; + } else { + /* No username part */ + domain = tmp; + } e = strchr(tmp, '/'); if (e) *e = '\0'; if (!strncasecmp(s, "sip:", 4)) s += 4; - ast_log(LOG_DEBUG, "Found 302 Redirect to extension '%s'\n", s); - if (p->owner) + if (option_debug > 1) + ast_log(LOG_DEBUG, "Received 302 Redirect to extension '%s' (domain %s)\n", s, domain); + if (p->owner) { + pbx_builtin_setvar_helper(p->owner, "SIPDOMAIN", domain); ast_string_field_set(p->owner, call_forward, s); + } } } |