#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 */
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 */
return res;
}
-#define DEFAULT_MAX_FORWARDS 70
/*--- sip_transfer: Transfer SIP call */
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 */
} 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;
}
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);
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);
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);
}
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 */
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");
snprintf(referto, sizeof(referto), "<sip:%s>", 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));
+ /* 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;
- }
+ 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
}
}
- /* 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 <sip:%s@%s%s%s>", 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 <sip:%s@%s%s%s>", 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);