Module: kamailio
Branch: master
Commit: 01afb3bb1a06c929ffd5bd1f0aaee03df28764a0
URL:
https://github.com/kamailio/kamailio/commit/01afb3bb1a06c929ffd5bd1f0aaee03…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2017-06-22T08:45:36+02:00
pv: $siz - return source ip, with enclosing square brackets for ipv6
---
Modified: src/modules/pv/pv.c
Modified: src/modules/pv/pv_core.c
Modified: src/modules/pv/pv_core.h
---
Diff:
https://github.com/kamailio/kamailio/commit/01afb3bb1a06c929ffd5bd1f0aaee03…
Patch:
https://github.com/kamailio/kamailio/commit/01afb3bb1a06c929ffd5bd1f0aaee03…
---
diff --git a/src/modules/pv/pv.c b/src/modules/pv/pv.c
index e9dc36c4d5..483faa2d19 100644
--- a/src/modules/pv/pv.c
+++ b/src/modules/pv/pv.c
@@ -396,6 +396,9 @@ static pv_export_t mod_pvs[] = {
{{"si", (sizeof("si")-1)}, /* */
PVT_OTHER, pv_get_srcip, 0,
0, 0, 0, 0},
+ {{"siz", (sizeof("siz")-1)}, /* */
+ PVT_OTHER, pv_get_srcipz, 0,
+ 0, 0, 0, 0},
{ {"sid", (sizeof("sid")-1)}, /* server id */
PVT_OTHER, pv_get_server_id, 0,
0, 0, 0, 0},
diff --git a/src/modules/pv/pv_core.c b/src/modules/pv/pv_core.c
index c39f105852..acd9105cb2 100644
--- a/src/modules/pv/pv_core.c
+++ b/src/modules/pv/pv_core.c
@@ -665,6 +665,18 @@ int pv_get_srcip(struct sip_msg *msg, pv_param_t *param,
return pv_get_strval(msg, param, res, &s);
}
+int pv_get_srcipz(struct sip_msg *msg, pv_param_t *param,
+ pv_value_t *res)
+{
+ str s;
+ if(msg==NULL)
+ return -1;
+
+ s.s = ip_addr2strz(&msg->rcv.src_ip);
+ s.len = strlen(s.s);
+ return pv_get_strval(msg, param, res, &s);
+}
+
int pv_get_srcport(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res)
{
diff --git a/src/modules/pv/pv_core.h b/src/modules/pv/pv_core.h
index 3a112a1e31..905fc89db5 100644
--- a/src/modules/pv/pv_core.h
+++ b/src/modules/pv/pv_core.h
@@ -127,6 +127,9 @@ int pv_get_callid(struct sip_msg *msg, pv_param_t *param,
int pv_get_srcip(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res);
+int pv_get_srcipz(struct sip_msg *msg, pv_param_t *param,
+ pv_value_t *res);
+
int pv_get_srcport(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res);