[asterisk-scf-commits] asterisk-scf/integration/sip.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Sat Oct 16 12:44:45 CDT 2010


branch "master" has been updated
       via  08e8e938ea5d7a3ebff21f1b685149896ff700dc (commit)
      from  5ffae4e79a205ce7f024518a6f1b8dbf6657cb30 (commit)

Summary of changes:
 src/PJSipSessionModule.cpp |   36 +++++++++++++++++++++++++++++++-----
 1 files changed, 31 insertions(+), 5 deletions(-)


- Log -----------------------------------------------------------------
commit 08e8e938ea5d7a3ebff21f1b685149896ff700dc
Author: Joshua Colp <jcolp at digium.com>
Date:   Sat Oct 16 10:42:57 2010 -0700

    Add support for getting the Replaces header from yet another place in the URI and getting the to/from tags.

diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index 4b8137d..5d55afe 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -434,20 +434,46 @@ void PJSipSessionModule::handleRefer(pjsip_inv_session *inv, pjsip_rx_data *rdat
    pj_str_t replaces = pj_str((char*)"Replaces");
    pjsip_param *replaces_param = pjsip_param_find(&target_sip_uri->other_param, &replaces);
 
+   if (!replaces_param)
+   {
+      replaces_param = pjsip_param_find(&target_sip_uri->header_param, &replaces);
+   }
+
    if (replaces_param)
    {
       pj_str_t to_tag = pj_str((char*)"To-tag");
       pj_str_t from_tag = pj_str((char*)"From-tag");
       pjsip_param *to_tag_param = pjsip_param_find(&target_sip_uri->other_param, &to_tag);
       pjsip_param *from_tag_param = pjsip_param_find(&target_sip_uri->other_param, &from_tag);
+      pjsip_dialog *other_dlg = NULL;
 
-      if (!to_tag_param || !from_tag_param)
+      if (to_tag_param && from_tag_param)
       {
-	 pjsip_dlg_respond(inv->dlg, rdata, 400, NULL, NULL, NULL);
-	 return;
+	 other_dlg = pjsip_ua_find_dialog(&replaces_param->value, &to_tag_param->value, &from_tag_param->value, PJ_TRUE);
       }
+      else
+      {
+	 // It is possible for the to and from tag value to be present within the Replaces parameter value, so try to parse it out
+	 std::string replaces_value_tmp = std::string(pj_strbuf(&replaces_param->value), pj_strlen(&replaces_param->value));
+	 size_t from_tag_pos = replaces_value_tmp.find(";from-tag=");
+	 size_t to_tag_pos = replaces_value_tmp.find(";to-tag=");
 
-      pjsip_dialog *other_dlg = pjsip_ua_find_dialog(&replaces_param->value, &to_tag_param->value, &from_tag_param->value, PJ_TRUE);
+	 if (from_tag_pos == std::string::npos || to_tag_pos == std::string::npos)
+	 {
+	    pjsip_dlg_respond(inv->dlg, rdata, 400, NULL, NULL, NULL);
+	    return;
+	 }
+
+	 std::string to_tag_value = replaces_value_tmp.substr(to_tag_pos + 8, from_tag_pos - to_tag_pos - 8);
+	 std::string from_tag_value = replaces_value_tmp.substr(from_tag_pos + 10);
+	 std::string replaces_value = replaces_value_tmp.substr(9, to_tag_pos - 9);
+
+	 pj_str_t to_tag_str = pj_str((char*)to_tag_value.c_str());
+	 pj_str_t from_tag_str = pj_str((char*)from_tag_value.c_str());
+	 pj_str_t replaces_tag_str = pj_str((char*)replaces_value.c_str());
+
+	 other_dlg = pjsip_ua_find_dialog(&replaces_tag_str, &to_tag_str, &from_tag_str, PJ_TRUE);
+      }
 
       if (!other_dlg)
       {

-----------------------------------------------------------------------


-- 
asterisk-scf/integration/sip.git



More information about the asterisk-scf-commits mailing list