Module: sems Branch: master Commit: 675a77ee6aef75cf27ee91d60f0c89c3dc40f64a URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=675a77ee6aef75cf27ee91d60f0c89c3dc40f64a
Author: Stefan Sayer <[email protected]> Committer: Stefan Sayer <[email protected]> Date: Thu Jul 7 21:29:35 2011 +0200 sbc: SST configurable for A (caller) leg separately --- apps/sbc/SBC.cpp | 24 +++++++++++++--------- apps/sbc/SBCCallProfile.cpp | 31 +++++++++++++++++++++++++++++- apps/sbc/SBCCallProfile.h | 4 +++ apps/sbc/etc/sst_b2b.sbcprofile.conf | 7 ++++++ apps/sbc/etc/transparent.sbcprofile.conf | 8 +++++++ core/AmConfigReader.cpp | 4 +++ core/AmConfigReader.h | 1 + doc/Readme.sbc.txt | 10 +++++++- 8 files changed, 76 insertions(+), 13 deletions(-) diff --git a/apps/sbc/SBC.cpp b/apps/sbc/SBC.cpp index 9438930..887a0e2 100644 --- a/apps/sbc/SBC.cpp +++ b/apps/sbc/SBC.cpp @@ -225,15 +225,19 @@ AmSession* SBCFactory::onInvite(const AmSipRequest& req, const string& app_name, return NULL; } - AmConfigReader& sst_cfg = call_profile.use_global_sst_config ? - cfg : call_profile.cfg; // override with profile config + AmConfigReader* sst_cfg = &call_profile.cfg; + if (call_profile.use_aleg_sst_config) { + sst_cfg = &call_profile.aleg_sst_cfg; // override with aleg sst config (aleg_*) + } else if (call_profile.use_global_sst_config) { + sst_cfg = &cfg; // global config + } - if (call_profile.sst_enabled) { - DBG("Enabling SIP Session Timers\n"); + if (call_profile.sst_aleg_enabled) { + DBG("Enabling SIP Session Timers (A leg)\n"); try { - if (!session_timer_fact->onInvite(req, sst_cfg)) { + if (!session_timer_fact->onInvite(req, *sst_cfg)) { profiles_mut.unlock(); - return NULL; + throw AmSession::Exception(500, SIP_REPLY_SERVER_INTERNAL_ERROR); } } catch (const AmSession::Exception& e) { profiles_mut.unlock(); @@ -259,7 +263,7 @@ AmSession* SBCFactory::onInvite(const AmSipRequest& req, const string& app_name, } } - if (call_profile.sst_enabled) { + if (call_profile.sst_aleg_enabled) { AmSessionEventHandler* h = session_timer_fact->getHandler(b2b_dlg); if(!h) { profiles_mut.unlock(); @@ -268,7 +272,7 @@ AmSession* SBCFactory::onInvite(const AmSipRequest& req, const string& app_name, throw AmSession::Exception(500, SIP_REPLY_SERVER_INTERNAL_ERROR); } - if (h->configure(sst_cfg)){ + if (h->configure(*sst_cfg)){ ERROR("Could not configure the session timer: disabling session timers.\n"); delete h; } else { @@ -621,7 +625,7 @@ void SBCDialog::onInvite(const AmSipRequest& req) b2b_mode = B2BMode_SDPFilter; } - if (call_profile.sst_enabled) { + if (call_profile.sst_aleg_enabled) { removeHeader(invite_req.hdrs,SIP_HDR_SESSION_EXPIRES); removeHeader(invite_req.hdrs,SIP_HDR_MIN_SE); } @@ -1071,7 +1075,7 @@ void SBCDialog::createCalleeSession() throw AmSession::Exception(500, SIP_REPLY_SERVER_INTERNAL_ERROR); } AmConfigReader& sst_cfg = call_profile.use_global_sst_config ? - SBCFactory::cfg: call_profile.cfg; // override with profile config + SBCFactory::cfg : call_profile.cfg; // override with profile config if(h->configure(sst_cfg)){ ERROR("Could not configure the session timer: disabling session timers.\n"); diff --git a/apps/sbc/SBCCallProfile.cpp b/apps/sbc/SBCCallProfile.cpp index a96193a..c937dec 100644 --- a/apps/sbc/SBCCallProfile.cpp +++ b/apps/sbc/SBCCallProfile.cpp @@ -110,7 +110,30 @@ bool SBCCallProfile::readFromConfiguration(const string& name, } sst_enabled = cfg.getParameter("enable_session_timer", "no") == "yes"; + if (cfg.hasParameter("enable_aleg_session_timer")) { + sst_aleg_enabled = cfg.getParameter("enable_aleg_session_timer", "no") == "yes"; + } else { + sst_aleg_enabled = sst_enabled; + } use_global_sst_config = !cfg.hasParameter("session_expires"); + use_aleg_sst_config = cfg.hasParameter("aleg_session_expires"); + + if (sst_aleg_enabled) { + aleg_sst_cfg.setParameter("enable_session_timer", "yes"); + // create aleg_sst_cfg with values from aleg_* +#define CP_SST_CFGVAR(cfgkey) \ + if (cfg.hasParameter("aleg_" cfgkey)) { \ + aleg_sst_cfg.setParameter(cfgkey, \ + cfg.getParameter("aleg_" cfgkey)); \ + } + CP_SST_CFGVAR("session_expires"); + CP_SST_CFGVAR("minimum_timer"); + CP_SST_CFGVAR("maximum_timer"); + CP_SST_CFGVAR("session_refresh_method"); + CP_SST_CFGVAR("accept_501_reply"); +#undef CP_SST_CFGVAR + } + auth_enabled = cfg.getParameter("enable_auth", "no") == "yes"; auth_credentials.user = cfg.getParameter("auth_user"); @@ -234,7 +257,9 @@ bool SBCCallProfile::readFromConfiguration(const string& name, } } - INFO("SBC: SST %sabled\n", sst_enabled?"en":"dis"); + INFO("SBC: SST on A leg %sabled\n", sst_aleg_enabled?"en":"dis"); + INFO("SBC: SST on B leg %sabled\n", sst_enabled?"en":"dis"); + INFO("SBC: SIP auth %sabled\n", auth_enabled?"en":"dis"); INFO("SBC: SIP auth for A leg %sabled\n", auth_aleg_enabled?"en":"dis"); INFO("SBC: call timer %sabled\n", call_timer_enabled?"en":"dis"); @@ -283,7 +308,9 @@ bool SBCCallProfile::operator==(const SBCCallProfile& rhs) const { messagefilter_list == rhs.messagefilter_list && sdpfilter_enabled == rhs.sdpfilter_enabled && sst_enabled == rhs.sst_enabled && + sst_aleg_enabled == rhs.sst_aleg_enabled && use_global_sst_config == rhs.use_global_sst_config && + use_aleg_sst_config == rhs.use_aleg_sst_config && auth_enabled == rhs.auth_enabled && auth_aleg_enabled == rhs.auth_aleg_enabled && call_timer_enabled == rhs.call_timer_enabled && @@ -353,7 +380,9 @@ string SBCCallProfile::print() const { res += "sdpfilter: " + string(FilterType2String(sdpfilter)) + "\n"; res += "sdpfilter_list: " + stringset_print(sdpfilter_list) + "\n"; res += "sst_enabled: " + string(sst_enabled?"true":"false") + "\n"; + res += "sst_aleg_enabled: " + string(sst_aleg_enabled?"true":"false") + "\n"; res += "use_global_sst_config:" + string(use_global_sst_config?"true":"false") + "\n"; + res += "use_aleg_sst_config:" + string(use_aleg_sst_config?"true":"false") + "\n"; res += "auth_enabled: " + string(auth_enabled?"true":"false") + "\n"; res += "auth_user: " + auth_credentials.user+"\n"; res += "auth_pwd: " + auth_credentials.pwd+"\n"; diff --git a/apps/sbc/SBCCallProfile.h b/apps/sbc/SBCCallProfile.h index 333d95b..9c65c27 100644 --- a/apps/sbc/SBCCallProfile.h +++ b/apps/sbc/SBCCallProfile.h @@ -70,7 +70,11 @@ struct SBCCallProfile { set<string> sdpfilter_list; bool sst_enabled; + bool sst_aleg_enabled; bool use_global_sst_config; + bool use_aleg_sst_config; + AmConfigReader aleg_sst_cfg; + bool auth_enabled; UACAuthCred auth_credentials; diff --git a/apps/sbc/etc/sst_b2b.sbcprofile.conf b/apps/sbc/etc/sst_b2b.sbcprofile.conf index 119997d..1805595 100644 --- a/apps/sbc/etc/sst_b2b.sbcprofile.conf +++ b/apps/sbc/etc/sst_b2b.sbcprofile.conf @@ -51,6 +51,13 @@ enable_session_timer=yes #session_refresh_method=UPDATE_FALLBACK_INVITE #accept_501_reply=yes +#separate SST configuration for A (caller) leg: +#enable_aleg_session_timer=yes +#aleg_session_expires=120 +#aleg_minimum_timer=90 +#aleg_maximum_timer=900 +#aleg_session_refresh_method=UPDATE_FALLBACK_INVITE +#aleg_accept_501_reply=yes # #This application can be routed through for achieving diff --git a/apps/sbc/etc/transparent.sbcprofile.conf b/apps/sbc/etc/transparent.sbcprofile.conf index 42ceed0..7ec1916 100644 --- a/apps/sbc/etc/transparent.sbcprofile.conf +++ b/apps/sbc/etc/transparent.sbcprofile.conf @@ -74,6 +74,14 @@ #session_refresh_method=UPDATE_FALLBACK_INVITE #accept_501_reply=yes +##separate SST configuration for A (caller) leg, optional: +#enable_aleg_session_timer=yes +#aleg_session_expires=120 +#aleg_minimum_timer=90 +#aleg_maximum_timer=900 +#aleg_session_refresh_method=UPDATE_FALLBACK_INVITE +#aleg_accept_501_reply=yes + ## refuse call # refuse all calls with <code> <reason> #refuse_with="404 Not Found" diff --git a/core/AmConfigReader.cpp b/core/AmConfigReader.cpp index 9f8826a..6132776 100644 --- a/core/AmConfigReader.cpp +++ b/core/AmConfigReader.cpp @@ -208,6 +208,10 @@ bool AmConfigReader::getMD5(const string& path, string& md5hash, bool lowercase) return true; } +void AmConfigReader::setParameter(const string& param, const string& val) { + keys[param] = val; +} + bool AmConfigReader::hasParameter(const string& param) { return (keys.find(param) != keys.end()); diff --git a/core/AmConfigReader.h b/core/AmConfigReader.h index b29db6c..1521788 100644 --- a/core/AmConfigReader.h +++ b/core/AmConfigReader.h @@ -50,6 +50,7 @@ class AmConfigReader int loadFile(const string& path); /** get md5 hash of file contents */ bool getMD5(const string& path, string& md5hash, bool lowercase = true); + void setParameter(const string& param, const string& val); bool hasParameter(const string& param); const string& getParameter(const string& param, const string& defval = ""); unsigned int getParameterInt(const string& param, unsigned int defval = 0); diff --git a/doc/Readme.sbc.txt b/doc/Readme.sbc.txt index a3a4a4c..cdd9da5 100644 --- a/doc/Readme.sbc.txt +++ b/doc/Readme.sbc.txt @@ -344,8 +344,8 @@ Reliable 1xx (PRACK) Reliable 1xx (PRACK) extension (3262) is supported in a transparent mode, i.e. the RSeq header is relayed and RAck CSeq is translated properly. -Session Timer configuration ---------------------------- +SIP Session Timer configuration +------------------------------- If SIP Session Timers are enabled for a profile, the session timers values (session_refresh, minimum_timer etc) can be configured either in sbc.conf or in the profile configuration. The profile SST configuration is used if @@ -354,6 +354,12 @@ session_expires is set in the profile configuration file. Note that for performance reasons the whole SST configuration is in this case used from the profile configuration (it is not overwritten value-by-value). +SIP Session Timers may be configured for each leg individually. SST may be dis- +abled on the A (caller) leg by setting enable_aleg_session_timer=no. If +enable_session_timer=yes and enable_aleg_session_timer not set, SST is enabled for +both legs. Likewise, if aleg_session_expires is not set, the SST configuration of +the B leg is used (session_expires, minimum_timer etc). + Prepaid ------- Prepaid accounting can be enabled with the enable_prepaid option. The credit _______________________________________________ Semsdev mailing list [email protected] http://lists.iptel.org/mailman/listinfo/semsdev
