Module: sems
Branch: master
Commit: e1b0a856bf6fce91892b7b696338e1a07056ab1c
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=e1b0a856bf6fce91892b7b696338e1a07056ab1c

Author: Stefan Sayer <[email protected]>
Committer: Stefan Sayer <[email protected]>
Date:   Fri Oct  7 18:11:22 2011 +0200

sbc: sdp_anonymize option to anonymize u,o,s lines in SDP

based on a patch by Carsten Bock

---

 apps/sbc/SBC.cpp                         |    4 ++--
 apps/sbc/SBCCallProfile.cpp              |    6 ++++--
 apps/sbc/SBCCallProfile.h                |    1 +
 apps/sbc/SDPFilter.cpp                   |   12 +++++++++++-
 apps/sbc/SDPFilter.h                     |    2 +-
 apps/sbc/etc/codecfilter.sbcprofile.conf |   28 +++-------------------------
 apps/sbc/etc/transparent.sbcprofile.conf |    1 +
 doc/Readme.sbc.txt                       |    2 ++
 8 files changed, 25 insertions(+), 31 deletions(-)

diff --git a/apps/sbc/SBC.cpp b/apps/sbc/SBC.cpp
index b718fc6..9ef4610 100644
--- a/apps/sbc/SBC.cpp
+++ b/apps/sbc/SBC.cpp
@@ -963,7 +963,7 @@ int SBCDialog::relayEvent(AmEvent* ev) {
 int SBCDialog::filterBody(AmSdp& sdp, bool is_a2b) {
   if (call_profile.sdpfilter_enabled) {
     // normalize SDP
-    normalizeSDP(sdp);
+    normalizeSDP(sdp, call_profile.anonymize_sdp);
     // filter SDP
     if (call_profile.sdpfilter != Transparent) {
       filterSDP(sdp, call_profile.sdpfilter, call_profile.sdpfilter_list);
@@ -1591,7 +1591,7 @@ void SBCCalleeSession::onSendRequest(const string& 
method, const string& content
 int SBCCalleeSession::filterBody(AmSdp& sdp, bool is_a2b) {
   if (call_profile.sdpfilter_enabled) {
     // normalize SDP
-    normalizeSDP(sdp);
+    normalizeSDP(sdp, call_profile.anonymize_sdp);
     // filter SDP
     if (call_profile.sdpfilter != Transparent) {
       filterSDP(sdp, call_profile.sdpfilter, call_profile.sdpfilter_list);
diff --git a/apps/sbc/SBCCallProfile.cpp b/apps/sbc/SBCCallProfile.cpp
index 50d7e1c..29e536a 100644
--- a/apps/sbc/SBCCallProfile.cpp
+++ b/apps/sbc/SBCCallProfile.cpp
@@ -110,8 +110,10 @@ bool SBCCallProfile::readFromConfiguration(const string& 
name,
       std::transform(c.begin(), c.end(), c.begin(), ::tolower);
       sdpfilter_list.insert(c);
     }
+    anonymize_sdp = cfg.getParameter("sdp_anonymize", "no") == "yes";
   }
 
+
   sst_enabled = cfg.getParameter("enable_session_timer");
   if (cfg.hasParameter("enable_aleg_session_timer")) {
     sst_aleg_enabled = cfg.getParameter("enable_aleg_session_timer");
@@ -296,9 +298,9 @@ bool SBCCallProfile::readFromConfiguration(const string& 
name,
         FilterType2String(headerfilter), headerfilter_list.size());
     INFO("SBC:      message filter is %s, %zd items in list\n",
         FilterType2String(messagefilter), messagefilter_list.size());
-    INFO("SBC:      SDP filter is %sabled, %s, %zd items in list\n",
+    INFO("SBC:      SDP filter is %sabled, %s, %zd items in list, 
%sanonymizing SDP\n",
         sdpfilter_enabled?"en":"dis", FilterType2String(sdpfilter),
-        sdpfilter_list.size());
+        sdpfilter_list.size(), anonymize_sdp?"":"not ");
 
     INFO("SBC:      RTP relay %sabled\n", rtprelay_enabled?"en":"dis");
     if (rtprelay_enabled) {
diff --git a/apps/sbc/SBCCallProfile.h b/apps/sbc/SBCCallProfile.h
index 01479de..703e267 100644
--- a/apps/sbc/SBCCallProfile.h
+++ b/apps/sbc/SBCCallProfile.h
@@ -84,6 +84,7 @@ struct SBCCallProfile
   bool sdpfilter_enabled;
   FilterType sdpfilter;
   set<string> sdpfilter_list;
+  bool anonymize_sdp;
 
   string sst_enabled;
   string sst_aleg_enabled;
diff --git a/apps/sbc/SDPFilter.cpp b/apps/sbc/SDPFilter.cpp
index 7370b66..573573f 100644
--- a/apps/sbc/SDPFilter.cpp
+++ b/apps/sbc/SDPFilter.cpp
@@ -101,7 +101,7 @@ void fix_incomplete_silencesupp(SdpMedia& m) {
   }
 }
 
-int normalizeSDP(AmSdp& sdp) {
+int normalizeSDP(AmSdp& sdp, bool anonymize_sdp) {
   for (std::vector<SdpMedia>::iterator m_it=
         sdp.media.begin(); m_it != sdp.media.end(); m_it++) {
     if (m_it->type != MT_AUDIO && m_it->type != MT_VIDEO)
@@ -114,5 +114,15 @@ int normalizeSDP(AmSdp& sdp) {
     // (only media level - RFC3108 4.)
     fix_incomplete_silencesupp(*m_it);
   }
+
+  if (anonymize_sdp) {
+    // Clear s-Line in SDP:
+    sdp.sessionName.clear();
+    // Clear u-Line in SDP:
+    sdp.uri.clear();
+    // Clear origin user
+    sdp.origin.user = "-";
+  }
+
   return 0;
 }
diff --git a/apps/sbc/SDPFilter.h b/apps/sbc/SDPFilter.h
index 8485646..dfd2fd5 100644
--- a/apps/sbc/SDPFilter.h
+++ b/apps/sbc/SDPFilter.h
@@ -38,6 +38,6 @@ using std::string;
 int filterSDP(AmSdp& sdp, FilterType sdpfilter, const std::set<string>& 
sdpfilter_list);
 
 /** normalize SDP, fixing some common issues */
-int normalizeSDP(AmSdp& sdp);
+int normalizeSDP(AmSdp& sdp, bool anonymize_sdp);
 
 #endif
diff --git a/apps/sbc/etc/codecfilter.sbcprofile.conf 
b/apps/sbc/etc/codecfilter.sbcprofile.conf
index 2f5878b..d480d51 100644
--- a/apps/sbc/etc/codecfilter.sbcprofile.conf
+++ b/apps/sbc/etc/codecfilter.sbcprofile.conf
@@ -29,28 +29,6 @@
 sdp_filter=whitelist
 sdpfilter_list=g729,g723,ilbc,speex,gsm,amr
 
-## authentication:
-#enable_auth=yes
-#auth_user=$P(u)
-#auth_pwd=$P(p)
-
-## call timer
-#enable_call_timer=yes
-#call_timer=60
-# or, e.g.: call_timer=$P(t)
-
-## prepaid
-#enable_prepaid=yes
-#prepaid_accmodule=cc_acc
-#prepaid_uuid=$H(P-Caller-Uuid)
-#prepaid_acc_dest=$H(P-Acc-Dest)
-
-## session timer:
-#enable_session_timer=yes
-# if session_expires is not configured here,
-# the values from sbc.conf are used, or the
-# default values
-#session_expires=120
-#minimum_timer=90
-#session_refresh_method=UPDATE_FALLBACK_INVITE
-#accept_501_reply=yes
+# anonymize SDP or not (u, s, o lines)
+#
+#sdp_anonymize=yes
diff --git a/apps/sbc/etc/transparent.sbcprofile.conf 
b/apps/sbc/etc/transparent.sbcprofile.conf
index 1b9ed90..bd014e1 100644
--- a/apps/sbc/etc/transparent.sbcprofile.conf
+++ b/apps/sbc/etc/transparent.sbcprofile.conf
@@ -40,6 +40,7 @@
 #message_list=
 #sdp_filter=whitelist
 #sdpfilter_list=g729,g723,ilbc,speex,gsm,amr
+#sdp_anonymize=yes
 
 ## append extra headers
 #append_headers="P-Source-IP: $si\r\nP-Source-Port: $sp\r\n"
diff --git a/doc/Readme.sbc.txt b/doc/Readme.sbc.txt
index 0037bae..9fcd375 100644
--- a/doc/Readme.sbc.txt
+++ b/doc/Readme.sbc.txt
@@ -283,6 +283,8 @@ set to transparent, the SDP is parsed and reconstructed 
(SDP sanity check).
 Codecs may be filtered out by their payload names in whitelist or blacklist
 modes. The payload names in the list are case-insensitive (PCMU==pcmu).
 
+The s, u and o-lines of the SDP can be anonymized with the setting 
sdp_anonymize=yes.
+
 RTP relay
 ---------
 RTP can be bridged through the SBC. Where without rtprelay, A call would go 
only

_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev

Reply via email to