Jelajahi Sumber

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

Richard Good 11 tahun lalu
induk
melakukan
bbcb7da488

+ 18 - 2
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;
 		}

+ 2 - 2
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
 

+ 1 - 1
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;

+ 1 - 1
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;
 		}

+ 1 - 1
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){