sbc: next_hop_for_replies option

making use of next hop for replies configurable
sayer/1.4-spce2.6
Stefan Sayer 16 years ago
parent ed118aba69
commit 660f23aa83

@ -961,6 +961,7 @@ void SBCDialog::createCalleeSession()
callee_dlg.next_hop_ip = call_profile.next_hop_ip;
callee_dlg.next_hop_port = call_profile.next_hop_port.empty() ?
5060 : call_profile.next_hop_port_i;
callee_dlg.next_hop_for_replies = call_profile.next_hop_for_replies;
}
other_id = AmSession::getNewId();

@ -52,6 +52,7 @@ bool SBCCallProfile::readFromConfiguration(const string& name,
next_hop_ip = cfg.getParameter("next_hop_ip");
next_hop_port = cfg.getParameter("next_hop_port");
next_hop_for_replies = cfg.getParameter("next_hop_for_replies") == "yes";
string hf_type = cfg.getParameter("header_filter", "transparent");
if (hf_type=="transparent")
@ -194,6 +195,10 @@ bool SBCCallProfile::readFromConfiguration(const string& name,
if (!next_hop_ip.empty()) {
INFO("SBC: next hop = %s%s\n", next_hop_ip.c_str(),
next_hop_port.empty()? "" : (":"+next_hop_port).c_str());
if (next_hop_for_replies) {
INFO("SBC: next hop used for replies\n");
}
}
INFO("SBC: header filter is %s, %zd items in list\n",
@ -244,6 +249,7 @@ bool SBCCallProfile::operator==(const SBCCallProfile& rhs) const {
next_hop_ip == rhs.next_hop_ip &&
next_hop_port == rhs.next_hop_port &&
next_hop_port_i == rhs.next_hop_port_i &&
next_hop_for_replies == rhs.next_hop_for_replies &&
headerfilter == rhs.headerfilter &&
headerfilter_list == rhs.headerfilter_list &&
messagefilter == rhs.messagefilter &&
@ -301,6 +307,7 @@ string SBCCallProfile::print() const {
res += "next_hop_ip: " + next_hop_ip + "\n";
res += "next_hop_port: " + next_hop_port + "\n";
res += "next_hop_port_i: " + int2str(next_hop_port_i) + "\n";
res += "next_hop_for_replies: " + string(next_hop_for_replies?"true":"false") + "\n";
res += "headerfilter: " + string(FilterType2String(headerfilter)) + "\n";
res += "headerfilter_list: " + stringset_print(headerfilter_list) + "\n";
res += "messagefilter: " + string(FilterType2String(messagefilter)) + "\n";

@ -56,6 +56,7 @@ struct SBCCallProfile {
string next_hop_ip;
string next_hop_port;
unsigned short next_hop_port_i;
bool next_hop_for_replies;
FilterType headerfilter;
set<string> headerfilter_list;

@ -18,6 +18,8 @@
# destination IP[:port] for outgoing requests
#next_hop_ip=192.168.5.106
#next_hop_port=5060
# use next_hop for replies, too?
#next_hop_for_replies=yes
## filters:
#header_filter=blacklist

@ -692,13 +692,15 @@ void AmSession::onSipRequest(const AmSipRequest& req)
ERROR("%s\n",s.c_str());
setStopped();
AmSipDialog::reply_error(req, 500, SIP_REPLY_SERVER_INTERNAL_ERROR, "",
dlg.next_hop_ip, dlg.next_hop_port);
dlg.next_hop_for_replies ? dlg.next_hop_ip : "",
dlg.next_hop_for_replies ? dlg.next_hop_port : 0);
}
catch(const AmSession::Exception& e) {
ERROR("%i %s\n",e.code,e.reason.c_str());
setStopped();
AmSipDialog::reply_error(req,e.code, e.reason, e.hdrs,
dlg.next_hop_ip, dlg.next_hop_port);
dlg.next_hop_for_replies ? dlg.next_hop_ip : "",
dlg.next_hop_for_replies ? dlg.next_hop_port : 0);
}
if(detached.get() && !getStopped()){

@ -46,7 +46,7 @@ AmSipDialog::AmSipDialog(AmSipDialogEventHandler* h)
force_outbound_proxy(AmConfig::ForceOutboundProxy),
reliable_1xx(AmConfig::rel100),
rseq(0), rseq_1st(0), rseq_confirmed(false),
next_hop_port(0)
next_hop_port(0), next_hop_for_replies(false)
{
}
@ -94,7 +94,8 @@ void AmSipDialog::updateStatus(const AmSipRequest& req)
INFO("remote cseq lower than previous ones - refusing request\n");
// see 12.2.2
reply_error(req, 500, SIP_REPLY_SERVER_INTERNAL_ERROR, "",
next_hop_ip, next_hop_port);
next_hop_for_replies ? next_hop_ip : "",
next_hop_for_replies ? next_hop_port : 0);
return;
}
@ -102,7 +103,8 @@ void AmSipDialog::updateStatus(const AmSipRequest& req)
if (pending_invites) {
reply_error(req,500, SIP_REPLY_SERVER_INTERNAL_ERROR,
"Retry-After: " + int2str(get_random() % 10) + CRLF,
next_hop_ip, next_hop_port);
next_hop_for_replies ? next_hop_ip : "",
next_hop_for_replies ? next_hop_port : 0);
return;
}
@ -177,7 +179,8 @@ int AmSipDialog::rel100OnRequestIn(const AmSipRequest& req)
if (key_in_list(getHeader(req.hdrs,SIP_HDR_REQUIRE),SIP_EXT_100REL))
reply_error(req, 420, SIP_REPLY_BAD_EXTENSION,
SIP_HDR_COLSP(SIP_HDR_UNSUPPORTED) SIP_EXT_100REL CRLF,
next_hop_ip, next_hop_port);
next_hop_for_replies ? next_hop_ip : "",
next_hop_for_replies ? next_hop_port : 0);
break;
default:
@ -572,7 +575,8 @@ int AmSipDialog::reply(const AmSipRequest& req,
if(updateStatusReply(req,code))
return -1;
int ret = SipCtrlInterface::send(reply, next_hop_ip, next_hop_port);
int ret = SipCtrlInterface::send(reply, next_hop_for_replies ? next_hop_ip : "",
next_hop_for_replies ? next_hop_port : 0);
if(ret){
ERROR("Could not send reply: code=%i; reason='%s'; method=%s; call-id=%s; cseq=%i\n",
reply.code,reply.reason.c_str(),req.method.c_str(),req.callid.c_str(),req.cseq);

@ -178,6 +178,7 @@ class AmSipDialog
string next_hop_ip;
unsigned short next_hop_port;
bool next_hop_for_replies;
/** enable the reliability of provisional replies? */
enum provisional_100rel { // could be a char

@ -251,7 +251,9 @@ the outbound proxy route also for in-dialog requests.
The next hop (destination IP[:port] of outgoing requests) can be set with
the next_hop_ip and next_hop_port options. next_hop_port defaults to 5060
if not set or empty.
if not set or empty. Usually, replies are sent back to where the request came
from (honoring rport), but if next_hop should be used nevertheless,
next_hop_for_replies profile option can be set to "yes".
Filters
-------

Loading…
Cancel
Save