Module: kamailio
Branch: master
Commit: b96a31409a3671f5f89617901886d9b5ffc61c73
URL:
https://github.com/kamailio/kamailio/commit/b96a31409a3671f5f89617901886d9b…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2018-04-10T13:29:01+02:00
pv: new config variable $sas
- return source address in socket format (proto:address:port)
---
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/b96a31409a3671f5f89617901886d9b…
Patch:
https://github.com/kamailio/kamailio/commit/b96a31409a3671f5f89617901886d9b…
---
diff --git a/src/modules/pv/pv.c b/src/modules/pv/pv.c
index 5743dd6d4d..258be56399 100644
--- a/src/modules/pv/pv.c
+++ b/src/modules/pv/pv.c
@@ -400,6 +400,9 @@ static pv_export_t mod_pvs[] = {
{{"RAut", (sizeof("RAut")-1)}, /* */
PVT_OTHER, pv_get_rcvadv_uri_full, 0,
0, 0, 0, 0},
+ {{"sas", (sizeof("sas")-1)}, /* */
+ PVT_OTHER, pv_get_srcaddr_socket, 0,
+ 0, 0, 0, 0},
{{"sf", (sizeof("sf")-1)}, /* */
PVT_OTHER, pv_get_sflags, pv_set_sflags,
0, 0, 0, 0},
diff --git a/src/modules/pv/pv_core.c b/src/modules/pv/pv_core.c
index b087f5ad1b..098d5435c2 100644
--- a/src/modules/pv/pv_core.c
+++ b/src/modules/pv/pv_core.c
@@ -726,6 +726,31 @@ int pv_get_srcaddr_uri_helper(struct sip_msg *msg, pv_param_t
*param,
return pv_get_strval(msg, param, res, &sr);
}
+int pv_get_srcaddr_socket(struct sip_msg *msg, pv_param_t *param,
+ pv_value_t *res)
+{
+ str ssock;
+ str sr;
+
+ if(msg==NULL)
+ return -1;
+
+ if(get_src_address_socket(msg, &ssock)<0)
+ return pv_get_null(msg, param, res);
+
+ if (ssock.len + 1 >= pv_get_buffer_size()) {
+ LM_ERR("local buffer size exceeded\n");
+ return pv_get_null(msg, param, res);
+ }
+
+ sr.s = pv_get_buffer();
+ strncpy(sr.s, ssock.s, ssock.len);
+ sr.len = ssock.len;
+ sr.s[sr.len] = '\0';
+
+ return pv_get_strval(msg, param, res, &sr);
+}
+
int pv_get_srcaddr_uri(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 898b3a8513..148e87f269 100644
--- a/src/modules/pv/pv_core.h
+++ b/src/modules/pv/pv_core.h
@@ -142,6 +142,9 @@ int pv_get_srcaddr_uri(struct sip_msg *msg, pv_param_t *param,
int pv_get_srcaddr_uri_full(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res);
+int pv_get_srcaddr_socket(struct sip_msg *msg, pv_param_t *param,
+ pv_value_t *res);
+
int pv_get_rcvip(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res);