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

Author: Raphael Coeffic <[email protected]>
Committer: Raphael Coeffic <[email protected]>
Date:   Fri Apr 13 22:51:18 2012 +0200

sbc: added support for R-URI host modification

added RURI_host call profile variable.

---

 apps/sbc/SBC.cpp            |    9 +++++++++
 apps/sbc/SBCCallProfile.cpp |    7 ++++++-
 apps/sbc/SBCCallProfile.h   |    1 +
 core/AmUriParser.cpp        |   26 ++++++++++++++++++++++++++
 core/AmUriParser.h          |    3 +++
 5 files changed, 45 insertions(+), 1 deletions(-)

diff --git a/apps/sbc/SBC.cpp b/apps/sbc/SBC.cpp
index 4e45075..6617ade 100644
--- a/apps/sbc/SBC.cpp
+++ b/apps/sbc/SBC.cpp
@@ -769,6 +769,15 @@ void SBCDialog::onInvite(const AmSipRequest& req)
   }
 
   ruri = call_profile.ruri.empty() ? req.r_uri : call_profile.ruri;
+  if(!call_profile.ruri_host.empty()){
+    ruri_parser.uri = ruri;
+    if(!ruri_parser.parse_uri()) {
+      WARN("Error parsing R-URI '%s'\n", ruri.c_str());
+    }
+    else {
+      ruri = ruri_parser.uri_str();
+    }
+  }
   from = call_profile.from.empty() ? req.from : call_profile.from;
   to = call_profile.to.empty() ? req.to : call_profile.to;
   callid = call_profile.callid;
diff --git a/apps/sbc/SBCCallProfile.cpp b/apps/sbc/SBCCallProfile.cpp
index 8d79ea5..2096948 100644
--- a/apps/sbc/SBCCallProfile.cpp
+++ b/apps/sbc/SBCCallProfile.cpp
@@ -45,6 +45,7 @@ bool SBCCallProfile::readFromConfiguration(const string& name,
   profile_file = profile_file_name;
 
   ruri = cfg.getParameter("RURI");
+  ruri_host = cfg.getParameter("RURI_host");
   from = cfg.getParameter("From");
   to = cfg.getParameter("To");
   contact = cfg.getParameter("Contact");
@@ -292,7 +293,8 @@ bool SBCCallProfile::readFromConfiguration(const string& 
name,
   if (!refuse_with.empty()) {
     INFO("SBC:      refusing calls with '%s'\n", refuse_with.c_str());
   } else {
-    INFO("SBC:      RURI = '%s'\n", ruri.c_str());
+    INFO("SBC:      RURI      = '%s'\n", ruri.c_str());
+    INFO("SBC:      RURI-host = '%s'\n", ruri_host.c_str());
     INFO("SBC:      From = '%s'\n", from.c_str());
     INFO("SBC:      To   = '%s'\n", to.c_str());
     if (!contact.empty()) {
@@ -431,6 +433,7 @@ static bool payloadDescsEqual(const vector<PayloadDesc> &a, 
const vector<Payload
 bool SBCCallProfile::operator==(const SBCCallProfile& rhs) const {
   bool res =
     ruri == rhs.ruri &&
+    ruri_host == rhs.ruri_host &&
     from == rhs.from &&
     to == rhs.to &&
     contact == rhs.contact &&
@@ -485,6 +488,7 @@ string SBCCallProfile::print() const {
   string res = 
     "SBC call profile dump: ~~~~~~~~~~~~~~~~~\n";
   res += "ruri:                 " + ruri + "\n";
+  res += "ruri_host:            " + ruri_host + "\n";
   res += "from:                 " + from + "\n";
   res += "to:                   " + to + "\n";
   res += "contact:              " + contact + "\n";
@@ -620,6 +624,7 @@ bool SBCCallProfile::evaluate(const AmSipRequest& req,
 
 
   REPLACE_NONEMPTY_STR(ruri);
+  REPLACE_NONEMPTY_STR(ruri_host);
   REPLACE_NONEMPTY_STR(from);
   REPLACE_NONEMPTY_STR(to);
   REPLACE_NONEMPTY_STR(contact);
diff --git a/apps/sbc/SBCCallProfile.h b/apps/sbc/SBCCallProfile.h
index 8d369ce..d6b50e3 100644
--- a/apps/sbc/SBCCallProfile.h
+++ b/apps/sbc/SBCCallProfile.h
@@ -82,6 +82,7 @@ struct SBCCallProfile
   string profile_file;
 
   string ruri;       /* updated if set */
+  string ruri_host;  /* updated if set */
   string from;       /* updated if set */
   string to;         /* updated if set */
   string contact;
diff --git a/core/AmUriParser.cpp b/core/AmUriParser.cpp
index 8946462..56a8827 100644
--- a/core/AmUriParser.cpp
+++ b/core/AmUriParser.cpp
@@ -459,3 +459,29 @@ void AmUriParser::dump() {
   }
   DBG("-------------------- \n");
 }
+
+string AmUriParser::uri_str()
+{
+  string res = uri_host;
+
+  if(!uri_user.empty()) {
+    res = uri_user + "@" + res;
+  }
+
+  if(!uri_port.empty()) {
+    res += ":" + uri_port;
+  }
+
+  if(!uri_param.empty()) {
+    res += ";" + uri_param;
+  }
+
+  res = "sip:" + res;
+
+  return res;
+}
+
+string AmUriParser::nameaddr_str()
+{
+  return "\"" + display_name + "\" <" + uri_str() + ">";
+}
diff --git a/core/AmUriParser.h b/core/AmUriParser.h
index 107e0a3..f49a768 100644
--- a/core/AmUriParser.h
+++ b/core/AmUriParser.h
@@ -51,6 +51,9 @@ struct AmUriParser {
   bool parse_uri();
   bool parse_params(const string& line, int& pos);
   void dump();
+  string uri_str();
+  string nameaddr_str();
+  
   AmUriParser() { }
 };
 

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

Reply via email to