Module: kamailio Branch: master Commit: ffecc676c4c5d947c9a3163570be1aaaf0e5e8d9 URL: https://github.com/kamailio/kamailio/commit/ffecc676c4c5d947c9a3163570be1aaa...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2021-06-11T09:17:36+02:00
pv: support for Contact header in $hflc()
---
Modified: src/modules/pv/pv_core.c
---
Diff: https://github.com/kamailio/kamailio/commit/ffecc676c4c5d947c9a3163570be1aaa... Patch: https://github.com/kamailio/kamailio/commit/ffecc676c4c5d947c9a3163570be1aaa...
---
diff --git a/src/modules/pv/pv_core.c b/src/modules/pv/pv_core.c index 7c5743151d..04d7ef7013 100644 --- a/src/modules/pv/pv_core.c +++ b/src/modules/pv/pv_core.c @@ -2429,6 +2429,7 @@ int pv_get_hflc(sip_msg_t *msg, pv_param_t *param, pv_value_t *res) pv_value_t tv = {0}; via_body_t *vb = NULL; rr_t *rrb = NULL; + contact_t *cb = NULL; hdr_field_t *hf = NULL; int n = 0;
@@ -2499,6 +2500,28 @@ int pv_get_hflc(sip_msg_t *msg, pv_param_t *param, pv_value_t *res) return pv_get_sintval(msg, param, res, n); }
+ if((tv.flags == 0) && (tv.ri==HDR_CONTACT_T)) { + if(msg->contact==NULL) { + LM_DBG("no Contact header\n"); + return pv_get_sintval(msg, param, res, 0); + } + if(parse_contact_headers(msg) < 0) { + LM_DBG("failed to parse Contact headers\n"); + return pv_get_sintval(msg, param, res, 0); + } + + /* count Contact header bodies */ + for(hf=msg->contact; hf!=NULL; hf=hf->next) { + if(hf->type==HDR_CONTACT_T) { + for(cb=(((contact_body_t*)hf->parsed)->contacts); + cb!=NULL; cb=cb->next) { + n++; + } + } + } + return pv_get_sintval(msg, param, res, n); + } + for (hf=msg->headers; hf; hf=hf->next) { if(tv.flags == 0) { if (tv.ri==hf->type) {