Module: kamailio
Branch: master
Commit: 5a825ddf6bd97f7a309ba7b663496c04a6895899
URL:
https://github.com/kamailio/kamailio/commit/5a825ddf6bd97f7a309ba7b663496c0…
Author: lazedo <luis.azedo(a)factorlusitano.com>
Committer: lazedo <luis.azedo(a)factorlusitano.com>
Date: 2017-06-20T15:24:09+01:00
pv: add received ip/port pvars for advertised ip/port
adds $RAi , $RAp
if advertise is not set, defaults to reveived ip/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/5a825ddf6bd97f7a309ba7b663496c0…
Patch:
https://github.com/kamailio/kamailio/commit/5a825ddf6bd97f7a309ba7b663496c0…
---
diff --git a/src/modules/pv/pv.c b/src/modules/pv/pv.c
index d619517c07..e9dc36c4d5 100644
--- a/src/modules/pv/pv.c
+++ b/src/modules/pv/pv.c
@@ -375,6 +375,12 @@ static pv_export_t mod_pvs[] = {
{{"Rp", (sizeof("Rp")-1)}, /* */
PVT_OTHER, pv_get_rcvport, 0,
0, 0, 0, 0},
+ {{"RAi", (sizeof("RAi")-1)}, /* */
+ PVT_OTHER, pv_get_rcv_advertised_ip, 0,
+ 0, 0, 0, 0},
+ {{"RAp", (sizeof("RAp")-1)}, /* */
+ PVT_OTHER, pv_get_rcv_advertised_port, 0,
+ 0, 0, 0, 0},
{{"sf", (sizeof("sf")-1)}, /* */
PVT_OTHER, pv_get_sflags, pv_set_sflags,
0, 0, 0, 0},
@@ -950,4 +956,4 @@ int mod_register(char *path, int *dlflags, void *p1, void *p2)
return -1;
}
return register_trans_mod(path, mod_trans);
-}
\ No newline at end of file
+}
diff --git a/src/modules/pv/pv_core.c b/src/modules/pv/pv_core.c
index cf0b60670f..c39f105852 100644
--- a/src/modules/pv/pv_core.c
+++ b/src/modules/pv/pv_core.c
@@ -739,6 +739,34 @@ int pv_get_rcvport(struct sip_msg *msg, pv_param_t *param,
&msg->rcv.bind_address->port_no_str);
}
+int pv_get_rcv_advertised_ip(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->useinfo.address_str.len > 0) {
+ return pv_get_strval(msg, param, res,
&msg->rcv.bind_address->useinfo.address_str);
+ }
+
+ return pv_get_rcvip(msg, param, res);
+}
+
+int pv_get_rcv_advertised_port(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->useinfo.port_no_str.len > 0) {
+ return pv_get_strval(msg, param, res,
&msg->rcv.bind_address->useinfo.port_no_str);
+ }
+
+ return pv_get_rcvport(msg, param, res);
+}
+
/**
*
*/
diff --git a/src/modules/pv/pv_core.h b/src/modules/pv/pv_core.h
index 98e6b56554..3a112a1e31 100644
--- a/src/modules/pv/pv_core.h
+++ b/src/modules/pv/pv_core.h
@@ -142,6 +142,12 @@ int pv_get_rcvip(struct sip_msg *msg, pv_param_t *param,
int pv_get_rcvport(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res);
+int pv_get_rcv_advertised_ip(struct sip_msg *msg, pv_param_t *param,
+ pv_value_t *res);
+
+int pv_get_rcv_advertised_port(struct sip_msg *msg, pv_param_t *param,
+ pv_value_t *res);
+
int pv_get_force_sock(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res);