[asterisk-commits] trunk r12456 - /trunk/channels/chan_sip.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed Mar 8 01:36:43 MST 2006


Author: oej
Date: Wed Mar  8 02:36:40 2006
New Revision: 12456

URL: http://svn.digium.com/view/asterisk?rev=12456&view=rev
Log:
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.

Modified:
    trunk/channels/chan_sip.c

Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?rev=12456&r1=12455&r2=12456&view=diff
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Wed Mar  8 02:36:40 2006
@@ -9502,6 +9502,8 @@
 {
 	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 @@
 			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);
+		}
 	}
 }
 



More information about the asterisk-commits mailing list