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

Author: Richard Good <[email protected]>
Committer: Richard Good <[email protected]>
Date:   Fri Mar  7 11:07:11 2014 +0200

lib/ims/ims_getters: Changed cscf_get_called_party_id to 
cscf_get_public_identity_from_called_party_id
        Changed function to get identity from called part id header instead of 
full header
        Fixes clients that attach extra info (e.g. phone-context)
        Changed references to this method in ims_charging and 
ims_registrar_pcscf

---

 lib/ims/ims_getters.c                        |   20 ++++++++++++++++++--
 lib/ims/ims_getters.h                        |    4 ++--
 modules/ims_charging/ims_ro.c                |    2 +-
 modules/ims_charging/mod.c                   |    2 +-
 modules/ims_registrar_pcscf/service_routes.c |    2 +-
 5 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/lib/ims/ims_getters.c b/lib/ims/ims_getters.c
index aa37c7d..eb266e8 100644
--- a/lib/ims/ims_getters.c
+++ b/lib/ims/ims_getters.c
@@ -1494,15 +1494,19 @@ int cscf_get_cseq(struct sip_msg *msg,struct hdr_field 
**hr)
 
 static str s_called_party_id={"P-Called-Party-ID",17};
 /**
- * Looks for the P-Called-Party-ID header and extracts its content.
+ * Looks for the P-Called-Party-ID header and extracts the public identity 
from it
  * @param msg - the sip message
  * @param hr - ptr to return the found hdr_field 
  * @returns the P-Called_Party-ID
  */
-str cscf_get_called_party_id(struct sip_msg *msg,struct hdr_field **hr)
+str cscf_get_public_identity_from_called_party_id(struct sip_msg *msg,struct 
hdr_field **hr)
 {
        str id={0,0};
        struct hdr_field *h;
+       int after_semi_colon=0;
+       int len=0;
+       int i=0;
+       
        if (hr) *hr=0;
        if (!msg) return id;
        if (parse_headers(msg, HDR_EOH_F, 0)<0) {
@@ -1522,6 +1526,18 @@ str cscf_get_called_party_id(struct sip_msg *msg,struct 
hdr_field **hr)
                        while(id.len && (id.s[id.len-1]==' ' || 
id.s[id.len-1]=='\t' || id.s[id.len-1]=='>')){
                                id.len--;
                        }       
+                       //get only text in front of ';' there might not even be 
a semi-colon
+                       //this caters for extra information after the public 
identity - e.g. phone-context
+                       len= id.len;
+                       for(i=0; i<len;i++) {
+                           if(id.s[i]==';'){
+                               //found semi-colon
+                               after_semi_colon = 1;
+                           }
+                           if(after_semi_colon){
+                               id.len--;
+                           }
+                       }
                        if (hr) *hr = h;
                        return id;
                }
diff --git a/lib/ims/ims_getters.h b/lib/ims/ims_getters.h
index 2217ddc..aeeb591 100644
--- a/lib/ims/ims_getters.h
+++ b/lib/ims/ims_getters.h
@@ -420,12 +420,12 @@ int cscf_add_header_rpl(struct sip_msg *msg, str *hdr);
 int cscf_get_cseq(struct sip_msg *msg,struct hdr_field **hr);
 
 /**
- * Looks for the P-Called-Party-ID header and extracts its content.
+ * Looks for the P-Called-Party-ID header and extracts the public identity 
from it
  * @param msg - the sip message
  * @param hr - ptr to return the found hdr_field 
  * @returns the P-Called_Party-ID
  */
-str cscf_get_called_party_id(struct sip_msg *msg,struct hdr_field **hr);
+str cscf_get_public_identity_from_called_party_id(struct sip_msg *msg,struct 
hdr_field **hr);
 
 #endif
 
diff --git a/modules/ims_charging/ims_ro.c b/modules/ims_charging/ims_ro.c
index ae13389..f71dc98 100644
--- a/modules/ims_charging/ims_ro.c
+++ b/modules/ims_charging/ims_ro.c
@@ -954,7 +954,7 @@ int Ro_Send_CCR(struct sip_msg *msg, struct dlg_cell *dlg, 
int dir, str* charge_
     
     
     //getting called asserted identity
-    if ((called_asserted_identity = cscf_get_called_party_id(msg, &h)).len == 
0) {
+    if ((called_asserted_identity = 
cscf_get_public_identity_from_called_party_id(msg, &h)).len == 0) {
            LM_DBG("No P-Called-Identity hdr found. Using request URI for 
called_asserted_identity");
            called_asserted_identity = 
cscf_get_public_identity_from_requri(msg);
            free_called_asserted_identity = 1;
diff --git a/modules/ims_charging/mod.c b/modules/ims_charging/mod.c
index 4fb423f..bbc2708 100644
--- a/modules/ims_charging/mod.c
+++ b/modules/ims_charging/mod.c
@@ -362,7 +362,7 @@ static int w_ro_ccr(struct sip_msg *msg, str* route_name, 
str* direction, str* c
                
        } else if (dir == RO_TERM_DIRECTION){
                //get callee IMPU from called part id - if not present then 
skip this
-               if ((identity = cscf_get_called_party_id(msg, &h)).len == 0) {
+               if ((identity = 
cscf_get_public_identity_from_called_party_id(msg, &h)).len == 0) {
                        LM_WARN("No P-Called-Identity hdr found - will not get 
callbacks if this IMPU is removed to terminate call");
                        goto send_ccr;
                }
diff --git a/modules/ims_registrar_pcscf/service_routes.c 
b/modules/ims_registrar_pcscf/service_routes.c
index 6360aab..cafed54 100644
--- a/modules/ims_registrar_pcscf/service_routes.c
+++ b/modules/ims_registrar_pcscf/service_routes.c
@@ -481,7 +481,7 @@ int assert_called_identity(struct sip_msg* _m, udomain_t* 
_d) {
                goto error;
        }
        
-       called_party_id = cscf_get_called_party_id(req, &h);
+       called_party_id = cscf_get_public_identity_from_called_party_id(req, 
&h);
        
                
        if (!called_party_id.len){


_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to