Module: kamailio
Branch: master
Commit: 2aae3ee39ea56e349879e25234a75aa79ff4284d
URL:
https://github.com/kamailio/kamailio/commit/2aae3ee39ea56e349879e25234a75aa…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2021-12-17T08:34:46+01:00
pv: added $Ras - return local received address in socket format
---
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/2aae3ee39ea56e349879e25234a75aa…
Patch:
https://github.com/kamailio/kamailio/commit/2aae3ee39ea56e349879e25234a75aa…
---
diff --git a/src/modules/pv/pv.c b/src/modules/pv/pv.c
index 9de6bc49af..c34ce5dd31 100644
--- a/src/modules/pv/pv.c
+++ b/src/modules/pv/pv.c
@@ -406,6 +406,9 @@ static pv_export_t mod_pvs[] = {
{{"rz", (sizeof("rz")-1)}, /* */
PVT_OTHER, pv_get_ruri_attr, 0,
0, 0, pv_init_iname, 5},
+ {{"Ras", (sizeof("Ras")-1)}, /* */
+ PVT_OTHER, pv_get_rcvaddr_socket, 0,
+ 0, 0, 0, 0},
{{"Ri", (sizeof("Ri")-1)}, /* */
PVT_OTHER, pv_get_rcvip, 0,
0, 0, 0, 0},
diff --git a/src/modules/pv/pv_core.c b/src/modules/pv/pv_core.c
index de5d5b41c8..afccbd4c7f 100644
--- a/src/modules/pv/pv_core.c
+++ b/src/modules/pv/pv_core.c
@@ -932,6 +932,18 @@ int pv_get_rcvaddr_uri_full(struct sip_msg *msg, pv_param_t *param,
return pv_get_rcvaddr_uri_helper(msg, param, 1, res);
}
+int pv_get_rcvaddr_socket(struct sip_msg *msg, pv_param_t *param,
+ pv_value_t *res)
+{
+ if(msg==NULL)
+ return -1;
+
+ if(msg->rcv.bind_address==NULL || msg->rcv.bind_address->sock_str.s==NULL) {
+ return pv_get_null(msg, param, res);
+ }
+ return pv_get_strval(msg, param, res, &msg->rcv.bind_address->sock_str);
+}
+
int pv_get_rcv_advertised_ip(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 5e0f6860b5..ffb7d734ba 100644
--- a/src/modules/pv/pv_core.h
+++ b/src/modules/pv/pv_core.h
@@ -166,6 +166,9 @@ int pv_get_rcvaddr_uri(struct sip_msg *msg, pv_param_t *param,
int pv_get_rcvaddr_uri_full(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res);
+int pv_get_rcvaddr_socket(struct sip_msg *msg, pv_param_t *param,
+ pv_value_t *res);
+
int pv_get_rcvsname(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res);