summaryrefslogtreecommitdiff
path: root/channels
diff options
context:
space:
mode:
authorKevin P. Fleming <kpfleming@digium.com>2005-06-09 22:41:18 +0000
committerKevin P. Fleming <kpfleming@digium.com>2005-06-09 22:41:18 +0000
commitf3efc756adf372a435bfac43114a1c5034b787d4 (patch)
tree7cb857baf65234abd2e3f474cdf5173d49ec023e /channels
parent4d102efb7a9092b63264bead5725f152e8260a52 (diff)
allow transfer-to number for SIP transfers to contain an '@' (and enforce the max-forwards restriction for these transfers) (bug #4048)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5894 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels')
-rwxr-xr-xchannels/chan_sip.c39
1 files changed, 26 insertions, 13 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 7832542e7..3fbf3d9dd 100755
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -2251,6 +2251,8 @@ static int sip_senddigit(struct ast_channel *ast, char digit)
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 @@ static int transmit_refer(struct sip_pvt *p, const char *dest)
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 @@ static int transmit_refer(struct sip_pvt *p, const char *dest)
} 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 @@ static int transmit_refer(struct sip_pvt *p, const char *dest)
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));
-
- 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);
+ 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);
+ } else {
+ return -1;
+ }
}
/*--- transmit_info_with_digit: Send SIP INFO dtmf message, see Cisco documentation on cisco.co
@@ -11187,8 +11202,6 @@ static int sip_getheader(struct ast_channel *chan, void *data)
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 */