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: http://svn.digium.com/svn/asterisk/trunk@12456 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
parent
aeefcdabca
commit
2d5bc7ca0c
|
@ -9502,6 +9502,8 @@ static void parse_moved_contact(struct sip_pvt *p, struct sip_request *req)
|
||||||
{
|
{
|
||||||
char tmp[256];
|
char tmp[256];
|
||||||
char *s, *e;
|
char *s, *e;
|
||||||
|
char *domain;
|
||||||
|
|
||||||
ast_copy_string(tmp, get_header(req, "Contact"), sizeof(tmp));
|
ast_copy_string(tmp, get_header(req, "Contact"), sizeof(tmp));
|
||||||
s = get_in_brackets(tmp);
|
s = get_in_brackets(tmp);
|
||||||
e = strchr(s, ';');
|
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);
|
ast_string_field_build(p->owner, call_forward, "SIP/%s", s);
|
||||||
} else {
|
} else {
|
||||||
e = strchr(tmp, '@');
|
e = strchr(tmp, '@');
|
||||||
if (e)
|
if (e) {
|
||||||
*e = '\0';
|
*e = '\0';
|
||||||
|
e++;
|
||||||
|
domain = e;
|
||||||
|
} else {
|
||||||
|
/* No username part */
|
||||||
|
domain = tmp;
|
||||||
|
}
|
||||||
e = strchr(tmp, '/');
|
e = strchr(tmp, '/');
|
||||||
if (e)
|
if (e)
|
||||||
*e = '\0';
|
*e = '\0';
|
||||||
if (!strncasecmp(s, "sip:", 4))
|
if (!strncasecmp(s, "sip:", 4))
|
||||||
s += 4;
|
s += 4;
|
||||||
ast_log(LOG_DEBUG, "Found 302 Redirect to extension '%s'\n", s);
|
if (option_debug > 1)
|
||||||
if (p->owner)
|
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);
|
ast_string_field_set(p->owner, call_forward, s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in New Issue