[Asterisk-cvs] asterisk/channels chan_sip.c,1.758,1.759

kpfleming at lists.digium.com kpfleming at lists.digium.com
Thu Jun 9 18:39:12 CDT 2005


Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv32274/channels

Modified Files:
	chan_sip.c 
Log Message:
allow transfer-to number for SIP transfers to contain an '@' (and enforce the max-forwards restriction for these transfers) (bug #4048)


Index: chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.758
retrieving revision 1.759
diff -u -d -r1.758 -r1.759
--- chan_sip.c	9 Jun 2005 21:11:30 -0000	1.758
+++ chan_sip.c	9 Jun 2005 22:41:18 -0000	1.759
@@ -2251,6 +2251,8 @@
 	return res;
 }
 
+#define DEFAULT_MAX_FORWARDS   70
+
 
 /*--- sip_transfer: Transfer SIP call */
 static int sip_transfer(struct ast_channel *ast, const char *dest)
@@ -4826,6 +4828,7 @@
 	char from[256];
 	char *of, *c;
 	char referto[256];
+       char tmp[80];
 
 	if (ast_test_flag(p, SIP_OUTGOING)) 
 		of = get_header(&p->initreq, "To");
@@ -4839,7 +4842,9 @@
 	} else
 		of += 4;
 	/* Get just the username part */
-	if ((c = strchr(of, '@'))) {
+       if ((c = strchr(dest, '@'))) {
+               c = NULL;
+       } else if ((c = strchr(of, '@'))) {
 		*c = '\0';
 		c++;
 	}
@@ -4849,16 +4854,26 @@
 		snprintf(referto, sizeof(referto), "<sip:%s>", dest);
 	}
 
-	/* save in case we get 407 challenge */
-	ast_copy_string(p->refer_to, referto, sizeof(p->refer_to)); 
-	ast_copy_string(p->referred_by, p->our_contact, sizeof(p->referred_by)); 
+       ast_copy_string(tmp, get_header(&p->initreq, "Max-Forwards"), sizeof(tmp));
+       if (strlen(tmp) && atoi(tmp)) {
+               p->maxforwards = atoi(tmp) - 1;
+       } else {
+               p->maxforwards = DEFAULT_MAX_FORWARDS - 1;
+       }
+       if (p->maxforwards > -1) {
+               /* save in case we get 407 challenge */
+               ast_copy_string(p->refer_to, referto, sizeof(p->refer_to));
+               ast_copy_string(p->referred_by, p->our_contact, sizeof(p->referred_by));
 
-	reqprep(&req, p, SIP_REFER, 0, 1);
-	add_header(&req, "Refer-To", referto);
-	if (!ast_strlen_zero(p->our_contact))
-		add_header(&req, "Referred-By", p->our_contact);
-	add_blank_header(&req);
-	return send_request(p, &req, 1, p->ocseq);
+               reqprep(&req, p, SIP_REFER, 0, 1);
+               add_header(&req, "Refer-To", referto);
+               if (!ast_strlen_zero(p->our_contact))
+                       add_header(&req, "Referred-By", p->our_contact);
+               add_blank_header(&req);
+               return send_request(p, &req, 1, p->ocseq);
+       } else {
+               return -1;
+       }
 }
 
 /*--- transmit_info_with_digit: Send SIP INFO dtmf message, see Cisco documentation on cisco.co
@@ -11187,8 +11202,6 @@
 	return 0;
 }
 
-#define DEFAULT_MAX_FORWARDS	70
-
 /*--- sip_sipredirect: Transfer call before connect with a 302 redirect ---*/
 /* Called by the transfer() dialplan application through the sip_transfer() */
 /* pbx interface function if the call is in ringing state */




More information about the svn-commits mailing list