[SR-Users] Fwd: [sr-dev] git:master:c32a5f64: sipcapture: added $hep(src_ip) variable

David Villasmil david.villasmil.work at gmail.com
Thu Feb 9 21:26:01 CET 2017


Hello guys,

i just installed kamailio from

deb     http://deb.kamailio.org/kamailio50-nightly jessie  main
deb-src http://deb.kamailio.org/kamailio50-nightly jessie  main

And i'm trying to use the newly exposed $hep(src_ip) by:

if ( ds_is_from_list("10", "2", "sip:$hep(src_ip)" ) )

but i'm getting:

ERROR: sipcapture [sipcapture.c:2763]: pv_parse_hep_name(): REQUEST, PRE,
src_ip
ERROR: sipcapture [sipcapture.c:2793]: pv_parse_hep_name(): unknown hep
name src_ip
ERROR: <core> [core/pvapi.c:877]: pv_parse_spec2(): pvar "hep" has an
invalid name param [src_ip]
ERROR: <core> [core/pvapi.c:1032]: pv_parse_spec2(): wrong char [)/41] in
[$hep(src_ip)] at [11 (5)]
ERROR: <core> [core/sr_module.c:1251]: fix_param(): bad PVE format:
"sip:$hep(src_ip)"
ERROR: <core> [core/mod_fix.c:539]: fixup_spve_null(): Cannot convert
function parameter 1 to spve

Any ideas?

Thanks

Regards,

David Villasmil
email: david.villasmil.work at gmail.com
phone: +34669448337

---------- Forwarded message ----------
From: Daniel-Constantin Mierla <miconda at gmail.com>
Date: Fri, Dec 9, 2016 at 10:17 AM
Subject: [sr-dev] git:master:c32a5f64: sipcapture: added $hep(src_ip)
variable
To: sr-dev at lists.sip-router.org


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2016-12-09T10:16:31+01:00

sipcapture: added $hep(src_ip) variable

- reworked patch from GH #879

---

Modified: src/modules/sipcapture/sipcapture.c

---

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

---

diff --git a/src/modules/sipcapture/sipcapture.c b/src/modules/sipcapture/
sipcapture.c
index 117db74..b5bbe7b 100644
--- a/src/modules/sipcapture/sipcapture.c
+++ b/src/modules/sipcapture/sipcapture.c
@@ -2835,6 +2835,11 @@ static int pv_parse_hep_name (pv_spec_p sp, str *in)
                        else goto error;
                }
                break;
+               case 6:
+               {
+                       if(!strncmp(in->s, "src_ip", 6))
sp->pvp.pvn.u.isname.name.n = 2;
+                       else goto error;
+               }
                case 7:
                {
                        if(!strncmp(in->s, "version", 7))
sp->pvp.pvn.u.isname.name.n = 0;
@@ -2857,17 +2862,24 @@ static int pv_parse_hep_name (pv_spec_p sp, str *in)

 static int pv_get_hep(struct sip_msg *msg, pv_param_t *param, pv_value_t
*res)
 {
+       static char sc_buf_ip[IP_ADDR_MAX_STR_SIZE+12];
+       int sc_buf_ip_len;
+
        if(param==NULL) return -1;

        switch(param->pvn.u.isname.name.n)
        {
                case 0:
-                       return pv_get_uintval(msg, param, res,
hep_version(msg));
-               case 1:
-                       return pv_get_uintval(msg, param, res,
hep_version(msg));
+                       return pv_get_uintval(msg, param, res,
hep_version(msg));
+               case 1:
+                       return pv_get_uintval(msg, param, res,
hep_version(msg));
+               case 2:
+                               sc_buf_ip_len=ip_addr2sbuf(&msg->rcv.src_ip,
sc_buf_ip,
+                                               sizeof(sc_buf_ip)-1);
+                               sc_buf_ip[sc_buf_ip_len]=0;
+                               return pv_get_strlval(msg, param, res,
sc_buf_ip, sc_buf_ip_len);
                default:
                        return  hepv3_get_chunk(msg, msg->buf, msg->len,
param->pvn.u.isname.name.n, param, res);
        }
        return 0;
 }
-


_______________________________________________
sr-dev mailing list
sr-dev at lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

ᐧ
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20170209/33ffbd28/attachment.html>


More information about the sr-users mailing list