Module: sems Branch: master Commit: c3bb47724697578b0fc73589a21b5fc9997bb9ea URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=c3bb47724697578b0fc73589a21b5fc9997bb9ea
Author: Raphael Coeffic <[email protected]> Committer: Raphael Coeffic <[email protected]> Date: Wed Sep 12 23:05:53 2012 +0200 sbc: add next_hop_1st_req flag this new flag allows to decide whether or not next_hop should be used only for the first request within a dialog (=true), or for each and every request. --- apps/sbc/SBC.cpp | 1 + apps/sbc/SBCCallProfile.cpp | 6 +++++- apps/sbc/SBCCallProfile.h | 1 + core/AmConfig.cpp | 2 ++ core/AmConfig.h | 2 ++ core/AmSipDialog.cpp | 9 +++++++-- core/AmSipDialog.h | 1 + 7 files changed, 19 insertions(+), 3 deletions(-) diff --git a/apps/sbc/SBC.cpp b/apps/sbc/SBC.cpp index b7f013b..52b0eb4 100644 --- a/apps/sbc/SBC.cpp +++ b/apps/sbc/SBC.cpp @@ -1814,6 +1814,7 @@ void SBCDialog::createCalleeSession() if (!call_profile.next_hop.empty()) { callee_dlg.next_hop = call_profile.next_hop; + callee_dlg.next_hop_1st_req = call_profile.next_hop_1st_req; } if(outbound_interface >= 0) diff --git a/apps/sbc/SBCCallProfile.cpp b/apps/sbc/SBCCallProfile.cpp index 17fbe36..3fb38c2 100644 --- a/apps/sbc/SBCCallProfile.cpp +++ b/apps/sbc/SBCCallProfile.cpp @@ -130,6 +130,7 @@ bool SBCCallProfile::readFromConfiguration(const string& name, next_hop = cfg.getParameter("next_hop"); next_hop_for_replies = cfg.getParameter("next_hop_for_replies"); + next_hop_1st_req = cfg.getParameter("next_hop_1st_req") == "yes"; if (cfg.hasParameter("header_filter")) { string hf_type = cfg.getParameter("header_filter"); @@ -377,7 +378,8 @@ bool SBCCallProfile::readFromConfiguration(const string& name, INFO("SBC: force outbound proxy: %s\n", force_outbound_proxy?"yes":"no"); INFO("SBC: outbound proxy = '%s'\n", outbound_proxy.c_str()); if (!next_hop.empty()) { - INFO("SBC: next hop = %s\n", next_hop.c_str()); + INFO("SBC: next hop = %s (%s)\n", next_hop.c_str(), + next_hop_1st_req ? "1st req" : "all reqs"); if (!next_hop_for_replies.empty()) { INFO("SBC: next hop used for replies: '%s'\n", next_hop_for_replies.c_str()); @@ -509,6 +511,7 @@ bool SBCCallProfile::operator==(const SBCCallProfile& rhs) const { force_outbound_proxy == rhs.force_outbound_proxy && next_hop == rhs.next_hop && next_hop_for_replies == rhs.next_hop_for_replies && + next_hop_1st_req == rhs.next_hop_1st_req && headerfilter == rhs.headerfilter && headerfilter_list == rhs.headerfilter_list && messagefilter == rhs.messagefilter && @@ -574,6 +577,7 @@ string SBCCallProfile::print() const { res += "sdpfilter_list: " + stringset_print(sdpfilter_list) + "\n"; res += "sdpalinesfilter: " + string(FilterType2String(sdpalinesfilter)) + "\n"; res += "sdpalinesfilter_list: " + stringset_print(sdpalinesfilter_list) + "\n"; + res += "next_hop_1st_req: " + string(next_hop_1st_req ? "true":"false") + "\n"; res += "sst_enabled: " + sst_enabled + "\n"; res += "sst_aleg_enabled: " + sst_aleg_enabled + "\n"; res += "auth_enabled: " + string(auth_enabled?"true":"false") + "\n"; diff --git a/apps/sbc/SBCCallProfile.h b/apps/sbc/SBCCallProfile.h index 7cb2657..5e904a0 100644 --- a/apps/sbc/SBCCallProfile.h +++ b/apps/sbc/SBCCallProfile.h @@ -94,6 +94,7 @@ struct SBCCallProfile string next_hop; string next_hop_for_replies; + bool next_hop_1st_req; FilterType headerfilter; set<string> headerfilter_list; diff --git a/core/AmConfig.cpp b/core/AmConfig.cpp index 7b29ae9..94d4ac4 100644 --- a/core/AmConfig.cpp +++ b/core/AmConfig.cpp @@ -80,6 +80,7 @@ int AmConfig::SIPServerThreads = NUM_SIP_SERVERS; string AmConfig::OutboundProxy = ""; bool AmConfig::ForceOutboundProxy = false; string AmConfig::NextHop = ""; +bool AmConfig::NextHop1stReq = false; bool AmConfig::ProxyStickyAuth = false; bool AmConfig::IgnoreNotifyLowerCSeq = false; bool AmConfig::DisableDNSSRV = false; @@ -325,6 +326,7 @@ int AmConfig::readConfiguration() if(cfg.hasParameter("next_hop")) { NextHop = cfg.getParameter("next_hop"); + NextHop1stReq = (cfg.getParameter("next_hop_1st_req") == "yes"); } if(cfg.hasParameter("proxy_sticky_auth")) { diff --git a/core/AmConfig.h b/core/AmConfig.h index 864b939..9f9db9d 100644 --- a/core/AmConfig.h +++ b/core/AmConfig.h @@ -143,6 +143,8 @@ struct AmConfig static bool ForceOutboundProxy; /** force next hop IP[:port] */ static string NextHop; + /** use next hop only on 1st request within a dialog */ + static bool NextHop1stReq; /** update ruri-host to previously resolved IP:port on SIP auth */ static bool ProxyStickyAuth; /** Ignore Low CSeq on NOTIFY - for RFC 3265 instead of 5057 */ diff --git a/core/AmSipDialog.cpp b/core/AmSipDialog.cpp index 17c9731..8f6abf5 100644 --- a/core/AmSipDialog.cpp +++ b/core/AmSipDialog.cpp @@ -92,6 +92,7 @@ AmSipDialog::AmSipDialog(AmSipDialogEventHandler* h) outbound_proxy(AmConfig::OutboundProxy), force_outbound_proxy(AmConfig::ForceOutboundProxy), next_hop(AmConfig::NextHop), + next_hop_1st_req(AmConfig::NextHop1stReq), outbound_interface(-1), sdp_local(), sdp_remote() { @@ -1132,7 +1133,9 @@ int AmSipDialog::sendRequest(const string& method, hdl->onSendRequest(req,flags); onTxRequest(req); - int res = SipCtrlInterface::send(req, next_hop, outbound_interface); + int res = SipCtrlInterface::send(req, + remote_tag.empty() ? next_hop : "", + outbound_interface); if(res) { ERROR("Could not send request: method=%s; call-id=%s; cseq=%i\n", req.method.c_str(),req.callid.c_str(),req.cseq); @@ -1215,7 +1218,9 @@ int AmSipDialog::send_200_ack(unsigned int inv_cseq, hdl->onSendRequest(req,flags); //onTxRequest(req); // not needed right now in the ACK case - int res = SipCtrlInterface::send(req, next_hop, outbound_interface); + int res = SipCtrlInterface::send(req, + remote_tag.empty() ? next_hop : "", + outbound_interface); if (res) return res; diff --git a/core/AmSipDialog.h b/core/AmSipDialog.h index 99e1941..27f8601 100644 --- a/core/AmSipDialog.h +++ b/core/AmSipDialog.h @@ -151,6 +151,7 @@ private: bool force_outbound_proxy; string next_hop; + bool next_hop_1st_req; int outbound_interface; _______________________________________________ Semsdev mailing list [email protected] http://lists.iptel.org/mailman/listinfo/semsdev
