Module: sems Branch: kubartv/cc_rest DELETED Commit: 62e85fc6039310c26af0c05aafd886f023b8167d URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=62e85fc6039310c26af0c05aafd886f023b8167d
Author: Václav Kubart <[email protected]> Committer: Václav Kubart <[email protected]> Date: Sun Feb 5 08:51:36 2012 +0100 added header filter support --- apps/sbc/call_control/rest/Readme.cc_rest.txt | 1 + apps/sbc/call_control/rest/RestModule.cpp | 30 ++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletions(-) diff --git a/apps/sbc/call_control/rest/Readme.cc_rest.txt b/apps/sbc/call_control/rest/Readme.cc_rest.txt index 8efe11f..16aedaf 100644 --- a/apps/sbc/call_control/rest/Readme.cc_rest.txt +++ b/apps/sbc/call_control/rest/Readme.cc_rest.txt @@ -18,6 +18,7 @@ Following parameters are supported now: next_hop_ip, next_hop_port, next_hop_for_replies, append_headers, + header_filter, header_list sst_enabled diff --git a/apps/sbc/call_control/rest/RestModule.cpp b/apps/sbc/call_control/rest/RestModule.cpp index 6de853f..06a28f2 100644 --- a/apps/sbc/call_control/rest/RestModule.cpp +++ b/apps/sbc/call_control/rest/RestModule.cpp @@ -33,6 +33,7 @@ #include "ampi/SBCCallControlAPI.h" #include <string.h> +#include <algorithm> #include <curl/curl.h> using namespace std; @@ -194,6 +195,27 @@ static RestParams::Format getFormat(const AmArg &values, RestParams::Format _def return _default; } +static void setHeaderFilter(SBCCallProfile* call_profile, + const string &type, const string &list) +{ + if (type=="transparent") + call_profile->headerfilter = Transparent; + else if (type=="whitelist") + call_profile->headerfilter = Whitelist; + else if (type=="blacklist") + call_profile->headerfilter = Blacklist; + else { + ERROR("invalid header_filter mode '%s'\n", type.c_str()); + throw string("invalid header filter"); + } + + vector<string> v = explode(list, ","); + for (vector<string>::iterator i = v.begin(); i != v.end(); ++i) { + transform(i->begin(), i->end(), i->begin(), ::tolower); + call_profile->headerfilter_list.insert(*i); + } +} + void RestModule::start(const string& cc_name, const string& ltag, SBCCallProfile* call_profile, int start_ts_sec, int start_ts_usec, @@ -228,7 +250,13 @@ void RestModule::start(const string& cc_name, const string& ltag, params.getIfSet("next_hop_port", call_profile->next_hop_port); params.getIfSet("next_hop_for_replies", call_profile->next_hop_for_replies); - // TODO: headerfilter, messagefilter + string hf_type, hf_list; + params.getIfSet("header_filter", hf_type); + params.getIfSet("header_list", hf_list); + if ( (!hf_type.empty()) || (!hf_list.empty())) setHeaderFilter(call_profile, hf_type, hf_list); + + //messagefilter + // sdpfilter, anonymize_sdp params.getIfSet("sst_enabled", call_profile->sst_enabled); _______________________________________________ Semsdev mailing list [email protected] http://lists.iptel.org/mailman/listinfo/semsdev
