Module: sip-router Branch: master Commit: 12d0feed38cd036cbc0e7c9f0c0c540d0e9eca4a URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=12d0feed...
Author: Richard Good richard.good@smilecoms.com Committer: Richard Good richard.good@smilecoms.com Date: Tue Feb 11 08:48:34 2014 +0200
lib/ims: added function to get Called-Party_ID AVP from message
---
lib/ims/ims_getters.c | 38 ++++++++++++++++++++++++++++++++++++++ lib/ims/ims_getters.h | 8 ++++++++ 2 files changed, 46 insertions(+), 0 deletions(-)
diff --git a/lib/ims/ims_getters.c b/lib/ims/ims_getters.c index a41cd31..fb8598c 100644 --- a/lib/ims/ims_getters.c +++ b/lib/ims/ims_getters.c @@ -1473,3 +1473,41 @@ int cscf_get_cseq(struct sip_msg *msg,struct hdr_field **hr) return nr; }
+static str s_called_party_id={"P-Called-Party-ID",17}; +/** + * Looks for the P-Called-Party-ID header and extracts its content. + * @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 id={0,0}; + struct hdr_field *h; + if (hr) *hr=0; + if (!msg) return id; + if (parse_headers(msg, HDR_EOH_F, 0)<0) { + return id; + } + h = msg->headers; + while(h) + { + if (h->name.len == s_called_party_id.len && + strncasecmp(h->name.s,s_called_party_id.s,s_called_party_id.len)==0) + { + id = h->body; + while(id.len && (id.s[0]==' ' || id.s[0]=='\t' || id.s[0]=='<')){ + id.s = id.s+1; + id.len --; + } + while(id.len && (id.s[id.len-1]==' ' || id.s[id.len-1]=='\t' || id.s[id.len-1]=='>')){ + id.len--; + } + if (hr) *hr = h; + return id; + } + h = h->next; + } + return id; +} + diff --git a/lib/ims/ims_getters.h b/lib/ims/ims_getters.h index e78310f..0b01ffc 100644 --- a/lib/ims/ims_getters.h +++ b/lib/ims/ims_getters.h @@ -418,5 +418,13 @@ 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. + * @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); + #endif