Module: sems Branch: sayer/dsm/next_hop_for_replies Commit: 660f23aa83ba40ae16f447b9cac7ff5599cb11ff URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=660f23aa83ba40ae16f447b9cac7ff5599cb11ff
Author: Stefan Sayer <[email protected]> Committer: Stefan Sayer <[email protected]> Date: Thu Jan 20 13:42:15 2011 +0100 sbc: next_hop_for_replies option making use of next hop for replies configurable --- apps/sbc/SBC.cpp | 1 + apps/sbc/SBCCallProfile.cpp | 7 +++++++ apps/sbc/SBCCallProfile.h | 1 + apps/sbc/etc/transparent.sbcprofile.conf | 2 ++ core/AmSession.cpp | 6 ++++-- core/AmSipDialog.cpp | 14 +++++++++----- core/AmSipDialog.h | 1 + doc/Readme.sbc.txt | 4 +++- 8 files changed, 28 insertions(+), 8 deletions(-) diff --git a/apps/sbc/SBC.cpp b/apps/sbc/SBC.cpp index 2bbd624..de21edc 100644 --- a/apps/sbc/SBC.cpp +++ b/apps/sbc/SBC.cpp @@ -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(); diff --git a/apps/sbc/SBCCallProfile.cpp b/apps/sbc/SBCCallProfile.cpp index 440a6ad..6032cd3 100644 --- a/apps/sbc/SBCCallProfile.cpp +++ b/apps/sbc/SBCCallProfile.cpp @@ -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"; diff --git a/apps/sbc/SBCCallProfile.h b/apps/sbc/SBCCallProfile.h index d9511c4..6ad4d47 100644 --- a/apps/sbc/SBCCallProfile.h +++ b/apps/sbc/SBCCallProfile.h @@ -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; diff --git a/apps/sbc/etc/transparent.sbcprofile.conf b/apps/sbc/etc/transparent.sbcprofile.conf index ded34e9..b0e9121 100644 --- a/apps/sbc/etc/transparent.sbcprofile.conf +++ b/apps/sbc/etc/transparent.sbcprofile.conf @@ -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 diff --git a/core/AmSession.cpp b/core/AmSession.cpp index 1cb1173..28b8e3e 100644 --- a/core/AmSession.cpp +++ b/core/AmSession.cpp @@ -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()){ diff --git a/core/AmSipDialog.cpp b/core/AmSipDialog.cpp index f96acd9..4f0e9e2 100644 --- a/core/AmSipDialog.cpp +++ b/core/AmSipDialog.cpp @@ -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); diff --git a/core/AmSipDialog.h b/core/AmSipDialog.h index 894fcd5..dfa05c9 100644 --- a/core/AmSipDialog.h +++ b/core/AmSipDialog.h @@ -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 diff --git a/doc/Readme.sbc.txt b/doc/Readme.sbc.txt index 9a626d8..1941bb9 100644 --- a/doc/Readme.sbc.txt +++ b/doc/Readme.sbc.txt @@ -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 ------- _______________________________________________ Semsdev mailing list [email protected] http://lists.iptel.org/mailman/listinfo/semsdev
