Module: kamailio
Branch: master
Commit: 070a9c042a1caf19162d3d97b26f8d7548747cbb
URL:
https://github.com/kamailio/kamailio/commit/070a9c042a1caf19162d3d97b26f8d7…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2020-11-20T08:12:18+01:00
kemix: exported function get_rcvadvip() and get_rcvadvport()
- return advertised address and port of the receiving socket
---
Modified: src/modules/kemix/kemix_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/070a9c042a1caf19162d3d97b26f8d7…
Patch:
https://github.com/kamailio/kamailio/commit/070a9c042a1caf19162d3d97b26f8d7…
---
diff --git a/src/modules/kemix/kemix_mod.c b/src/modules/kemix/kemix_mod.c
index 4bd6f839d1..66cdcf1bc1 100644
--- a/src/modules/kemix/kemix_mod.c
+++ b/src/modules/kemix/kemix_mod.c
@@ -520,6 +520,38 @@ static sr_kemi_xval_t* ki_kx_get_rcvport(sip_msg_t *msg)
return &_sr_kemi_kx_xval;
}
+/**
+ *
+ */
+static sr_kemi_xval_t* ki_kx_get_rcvadvip(sip_msg_t *msg)
+{
+ memset(&_sr_kemi_kx_xval, 0, sizeof(sr_kemi_xval_t));
+ if(msg->rcv.bind_address!=NULL
+ && msg->rcv.bind_address->useinfo.address_str.len > 0) {
+ _sr_kemi_kx_xval.vtype = SR_KEMIP_STR;
+ _sr_kemi_kx_xval.v.s = msg->rcv.bind_address->useinfo.address_str;
+ return &_sr_kemi_kx_xval;
+ }
+
+ return ki_kx_get_rcvip(msg);
+}
+
+/**
+ *
+ */
+static sr_kemi_xval_t* ki_kx_get_rcvadvport(sip_msg_t *msg)
+{
+ memset(&_sr_kemi_kx_xval, 0, sizeof(sr_kemi_xval_t));
+ if(msg->rcv.bind_address!=NULL
+ && msg->rcv.bind_address->useinfo.port_no_str.len > 0) {
+ _sr_kemi_kx_xval.vtype = SR_KEMIP_INT;
+ _sr_kemi_kx_xval.v.n = (int)msg->rcv.bind_address->useinfo.port_no;
+ return &_sr_kemi_kx_xval;
+ }
+
+ return ki_kx_get_rcvport(msg);
+}
+
/**
*
*/
@@ -1085,6 +1117,16 @@ static sr_kemi_t sr_kemi_kx_exports[] = {
{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
},
+ { str_init("kx"), str_init("get_rcvadvip"),
+ SR_KEMIP_XVAL, ki_kx_get_rcvadvip,
+ { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+ },
+ { str_init("kx"), str_init("get_rcvadvport"),
+ SR_KEMIP_XVAL, ki_kx_get_rcvadvport,
+ { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+ },
{ str_init("kx"), str_init("get_proto"),
SR_KEMIP_XVAL, ki_kx_get_proto,
{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,