Index: channels/chan_sip.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v retrieving revision 1.894 diff -u -r1.894 chan_sip.c --- channels/chan_sip.c 17 Oct 2005 22:26:33 -0000 1.894 +++ channels/chan_sip.c 19 Oct 2005 18:15:34 -0000 @@ -95,6 +95,7 @@ #define DEFAULT_DEFAULT_EXPIRY 120 #define DEFAULT_MAX_EXPIRY 3600 #define DEFAULT_REGISTRATION_TIMEOUT 20 +#define DEFAULT_MAX_FORWARDS "70" /* guard limit must be larger than guard secs */ /* guard min must be < 1000, and should be >= 250 */ @@ -658,7 +659,6 @@ struct sip_request initreq; /* Initial request */ int maxtime; /* Max time for first response */ - int maxforwards; /* keep the max-forwards info */ int initid; /* Auto-congest ID if appropriate */ int autokillid; /* Auto-kill ID */ time_t lastrtprx; /* Last RTP received */ @@ -2574,7 +2574,6 @@ return res; } -#define DEFAULT_MAX_FORWARDS 70 /*--- sip_transfer: Transfer SIP call */ @@ -3960,6 +3959,7 @@ copy_header(resp, req, "CSeq"); add_header(resp, "User-Agent", default_useragent); add_header(resp, "Allow", ALLOWED_METHODS); + add_header(resp, "Max-Forwards", DEFAULT_MAX_FORWARDS); if (msg[0] == '2' && (p->method == SIP_SUBSCRIBE || p->method == SIP_REGISTER)) { /* For registration responses, we also need expiry and contact info */ @@ -3975,11 +3975,6 @@ } else if (p->our_contact[0]) { add_header(resp, "Contact", p->our_contact); } - if (p->maxforwards) { - char tmp[256]; - snprintf(tmp, sizeof(tmp), "%d", p->maxforwards); - add_header(resp, "Max-Forwards", tmp); - } return 0; } @@ -4076,6 +4071,7 @@ add_header(req, "CSeq", tmp); add_header(req, "User-Agent", default_useragent); + add_header(req, "Max-Forwards", DEFAULT_MAX_FORWARDS); if (p->rpid) add_header(req, "Remote-Party-ID", p->rpid); @@ -4774,7 +4770,7 @@ ast_build_string(&invite, &invite_max, "%s", urioptions); } - /* If custom URI options have been provided, append them */ + /* If custom URI options have been provided, append them */ if (p->options && p->options->uri_options) ast_build_string(&invite, &invite_max, ";%s", p->options->uri_options); @@ -4807,6 +4803,7 @@ add_header(req, "Call-ID", p->callid); add_header(req, "CSeq", tmp); add_header(req, "User-Agent", default_useragent); + add_header(req, "Max-Forwards", DEFAULT_MAX_FORWARDS); if (p->rpid) add_header(req, "Remote-Party-ID", p->rpid); } @@ -5411,6 +5408,7 @@ add_header(&req, "Call-ID", p->callid); add_header(&req, "CSeq", tmp); add_header(&req, "User-Agent", default_useragent); + add_header(&req, "Max-Forwards", DEFAULT_MAX_FORWARDS); if (auth) /* Add auth header */ @@ -5471,7 +5469,6 @@ 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"); @@ -5497,26 +5494,16 @@ snprintf(referto, sizeof(referto), "", dest); } - 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; - } + /* 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); } /*--- transmit_info_with_digit: Send SIP INFO dtmf message, see Cisco documentation on cisco.co @@ -12831,21 +12818,9 @@ } } - /* make sure the forwarding won't be forever */ - ast_copy_string(tmp, get_header(&p->initreq, "Max-Forwards"), sizeof(tmp)); - if (strlen(tmp) && atoi(tmp)) { - /* we found Max-Forwards in the original SIP request */ - p->maxforwards = atoi(tmp) - 1; - } else { - /* just send our 302 Moved Temporarily */ - p->maxforwards = DEFAULT_MAX_FORWARDS - 1; - } - if (p->maxforwards > -1) { - snprintf(p->our_contact, sizeof(p->our_contact), "Transfer ", extension, host, port ? ":" : "", port ? port : ""); - transmit_response_reliable(p, "302 Moved Temporarily", &p->initreq, 1); - } else { - transmit_response(p, "483 Too Many Hops", &p->initreq); - } + snprintf(p->our_contact, sizeof(p->our_contact), "Transfer ", extension, host, port ? ":" : "", port ? port : ""); + transmit_response_reliable(p, "302 Moved Temporarily", &p->initreq, 1); + /* this is all that we want to send to that SIP device */ ast_set_flag(p, SIP_ALREADYGONE);