diff --git a/apps/sbc/SBCCallLeg.cpp b/apps/sbc/SBCCallLeg.cpp index 8b1200a0c..4df92fd00 100644 --- a/apps/sbc/SBCCallLeg.cpp +++ b/apps/sbc/SBCCallLeg.cpp @@ -279,6 +279,8 @@ void SBCCallLeg::applyAProfile() if(!call_profile.dlg_contact_params.empty()) dlg->setContactParams(call_profile.dlg_contact_params); + + dlg->setContact(call_profile.aleg_contact); } int SBCCallLeg::applySSTCfg(AmConfigReader& sst_cfg, diff --git a/apps/sbc/SBCCallProfile.cpp b/apps/sbc/SBCCallProfile.cpp index 28995a585..02e505651 100644 --- a/apps/sbc/SBCCallProfile.cpp +++ b/apps/sbc/SBCCallProfile.cpp @@ -389,7 +389,8 @@ bool SBCCallProfile::readFromConfiguration(const string& name, contact.hiding_prefix = cfg.getParameter("contact_hiding_prefix"); contact.hiding_vars = cfg.getParameter("contact_hiding_vars"); - if (!bleg_contact.readConfig(cfg)) return false; + if (!aleg_contact.readConfig(cfg,"aleg_")) return false; + if (!bleg_contact.readConfig(cfg,"bleg_")) return false; if (!codec_prefs.readConfig(cfg)) return false; if (!transcoder.readConfig(cfg)) return false; hold_settings.readConfig(cfg); @@ -583,7 +584,9 @@ bool SBCCallProfile::readFromConfiguration(const string& name, codec_prefs.infoPrint(); transcoder.infoPrint(); - bleg_contact.infoPrint(); + + INFO("SBC: A leg contact: %s\n", aleg_contact.print().c_str()); + INFO("SBC: B leg contact: %s\n", bleg_contact.print().c_str()); return true; } @@ -788,6 +791,7 @@ bool SBCCallProfile::evaluate(ParamReplacerCtx& ctx, REPLACE_NONEMPTY_STR(outbound_proxy); REPLACE_NONEMPTY_STR(next_hop); + if (!aleg_contact.evaluate(ctx,req)) return false; if (!bleg_contact.evaluate(ctx,req)) return false; if (!transcoder.evaluate(ctx,req)) return false; @@ -1781,16 +1785,16 @@ bool SBCCallProfile::HoldSettings::evaluate(ParamReplacerCtx& ctx, const AmSipRe return true; } -bool SBCCallProfile::BLegContact::readConfig(AmConfigReader &cfg) +bool SBCCallProfile::LegContact::readConfig(AmConfigReader &cfg, const string &prefix) { - uri_host = cfg.getParameter("bleg_contact_host"); - uri_port = cfg.getParameter("bleg_contact_port"); - uri_user = cfg.getParameter("bleg_contact_user"); - uri_param = cfg.getParameter("bleg_contact_uri_params"); - display_name = cfg.getParameter("bleg_contact_displayname"); + uri_host = cfg.getParameter(prefix+"contact_host"); + uri_port = cfg.getParameter(prefix+"contact_port"); + uri_user = cfg.getParameter(prefix+"contact_user"); + uri_param = cfg.getParameter(prefix+"contact_uri_params"); + display_name = cfg.getParameter(prefix+"contact_displayname"); int pos = 0; - string params = cfg.getParameter("bleg_contact_params"); + string params = cfg.getParameter(prefix+"contact_params"); if(params.empty()) return true; if(!parse_params(params,pos)) { ERROR("bleg_contact_params parsing failed"); @@ -1799,7 +1803,7 @@ bool SBCCallProfile::BLegContact::readConfig(AmConfigReader &cfg) return true; } -bool SBCCallProfile::BLegContact::evaluate(ParamReplacerCtx& ctx, const AmSipRequest& req) +bool SBCCallProfile::LegContact::evaluate(ParamReplacerCtx& ctx, const AmSipRequest& req) { REPLACE_NONEMPTY_STR(uri_host); REPLACE_NONEMPTY_STR(uri_port); @@ -1815,7 +1819,3 @@ bool SBCCallProfile::BLegContact::evaluate(ParamReplacerCtx& ctx, const AmSipReq return true; } -void SBCCallProfile::BLegContact::infoPrint() const -{ - INFO("SBC: B leg contact: %s\n", print().c_str()); -} diff --git a/apps/sbc/SBCCallProfile.h b/apps/sbc/SBCCallProfile.h index 435c9dd7c..33cf10b8b 100644 --- a/apps/sbc/SBCCallProfile.h +++ b/apps/sbc/SBCCallProfile.h @@ -125,14 +125,13 @@ struct SBCCallProfile Contact contact; - class BLegContact + class LegContact : public AmUriParser { public: - bool readConfig(AmConfigReader &cfg); + bool readConfig(AmConfigReader &cfg, const string &prefix); bool evaluate(ParamReplacerCtx& ctx, const AmSipRequest& req); - void infoPrint() const; - } bleg_contact; + } aleg_contact, bleg_contact; string callid; diff --git a/apps/sbc/SBCSimpleRelay.cpp b/apps/sbc/SBCSimpleRelay.cpp index 5b42709ab..2141b4cf6 100644 --- a/apps/sbc/SBCSimpleRelay.cpp +++ b/apps/sbc/SBCSimpleRelay.cpp @@ -484,6 +484,7 @@ int SimpleRelayDialog::initUAS(const AmSipRequest& req, fix_replaces_ref = cp.fix_replaces_ref=="yes"; setContactParams(cp.dlg_contact_params); + setContact(cp.aleg_contact); return 0; } diff --git a/doc/Readme.sbc.txt b/doc/Readme.sbc.txt index a201dc62e..604b5e928 100644 --- a/doc/Readme.sbc.txt +++ b/doc/Readme.sbc.txt @@ -588,18 +588,20 @@ Examples: Contact header rewriting ------------------------ +SBC can add/alter Contact header parts for both legs. -SBC can add/alter Contact header parts -for the the outgoing initial INVITE by using the following options: +available variables: - - bleg_contact_host - - bleg_contact_port - - bleg_contact_user - - bleg_contact_displayname - - bleg_contact_params - - bleg_contact_uri_params + - {leg}_contact_host + - {leg}_contact_port + - {leg}_contact_user + - {leg}_contact_displayname + - {leg}_contact_params + - {leg}_contact_uri_params -note: bleg_contact_params and bleg_contact_uri_params +where {leg} is 'aleg' or 'bleg' + +note: *_contact_params and *_contact_uri_params are strings with semicolon-separated params list. not specified or empty after placeholders substitution parts will be left untouched.