Module: kamailio
Branch: master
Commit: 5e06b6bcaf0047e5bb22105e03331268cee8486f
URL: 
https://github.com/kamailio/kamailio/commit/5e06b6bcaf0047e5bb22105e03331268cee8486f

Author: Daniel-Constantin Mierla <mico...@gmail.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date: 2021-06-09T13:33:06+02:00

pv: support Record/-Route headers for $hflc(...)

---

Modified: src/modules/pv/pv_core.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/5e06b6bcaf0047e5bb22105e03331268cee8486f.diff
Patch: 
https://github.com/kamailio/kamailio/commit/5e06b6bcaf0047e5bb22105e03331268cee8486f.patch

---

diff --git a/src/modules/pv/pv_core.c b/src/modules/pv/pv_core.c
index 6e70010816..7c5743151d 100644
--- a/src/modules/pv/pv_core.c
+++ b/src/modules/pv/pv_core.c
@@ -2428,6 +2428,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;
        hdr_field_t *hf = NULL;
        int n = 0;
 
@@ -2471,6 +2472,33 @@ 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_RECORDROUTE_T || tv.ri==HDR_ROUTE_T)) 
{
+               if(tv.ri==HDR_RECORDROUTE_T) {
+                       hf=msg->record_route;
+               } else {
+                       hf=msg->route;
+               }
+               if(hf==NULL) {
+                       LM_DBG("no %s header\n", 
(tv.ri==HDR_ROUTE_T)?"route":"record-route");
+                       return pv_get_sintval(msg, param, res, 0);
+               }
+
+               /* count Record-Route/Route header bodies */
+               for(; hf!=NULL; hf=hf->next) {
+                       if(hf->type==tv.ri) {
+                               if(parse_rr(hf) == -1) {
+                                       LM_ERR("failed parsing %s header\n",
+                                                       
(tv.ri==HDR_ROUTE_T)?"route":"record-route");
+                                       return pv_get_sintval(msg, param, res, 
0);
+                               }
+                               for(rrb=(rr_t*)hf->parsed; rrb!=NULL; 
rrb=rrb->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) {


_______________________________________________
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to