Module: kamailio
Branch: master
Commit: 1a3fc004e27555063a8bc942c946f6d54f84cf45
URL:
https://github.com/kamailio/kamailio/commit/1a3fc004e27555063a8bc942c946f6d…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2019-06-14T09:01:37+02:00
kemix: functions to get src/rcv ip and port
---
Modified: src/modules/kemix/kemix_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/1a3fc004e27555063a8bc942c946f6d…
Patch:
https://github.com/kamailio/kamailio/commit/1a3fc004e27555063a8bc942c946f6d…
---
diff --git a/src/modules/kemix/kemix_mod.c b/src/modules/kemix/kemix_mod.c
index d3464b9a42..add50f09cb 100644
--- a/src/modules/kemix/kemix_mod.c
+++ b/src/modules/kemix/kemix_mod.c
@@ -317,6 +317,74 @@ static sr_kemi_xval_t* ki_kx_getw_ua(sip_msg_t *msg)
return ki_kx_get_ua_mode(msg, SR_KEMI_XVAL_NULL_PRINT);
}
+/**
+ *
+ */
+static sr_kemi_xval_t* ki_kx_get_srcip(sip_msg_t *msg)
+{
+ memset(&_sr_kemi_kx_xval, 0, sizeof(sr_kemi_xval_t));
+ if(msg==NULL) {
+ sr_kemi_xval_null(&_sr_kemi_kx_xval, SR_KEMI_XVAL_NULL_NONE);
+ return &_sr_kemi_kx_xval;
+ }
+
+ _sr_kemi_kx_xval.vtype = SR_KEMIP_STR;
+ _sr_kemi_kx_xval.v.s.s = ip_addr2a(&msg->rcv.src_ip);
+ _sr_kemi_kx_xval.v.s.len = strlen(_sr_kemi_kx_xval.v.s.s);
+ return &_sr_kemi_kx_xval;
+}
+
+/**
+ *
+ */
+static sr_kemi_xval_t* ki_kx_get_srcport(sip_msg_t *msg)
+{
+ memset(&_sr_kemi_kx_xval, 0, sizeof(sr_kemi_xval_t));
+ if(msg==NULL) {
+ _sr_kemi_kx_xval.vtype = SR_KEMIP_INT;
+ _sr_kemi_kx_xval.v.n = 0;
+ return &_sr_kemi_kx_xval;
+ }
+
+ _sr_kemi_kx_xval.vtype = SR_KEMIP_INT;
+ _sr_kemi_kx_xval.v.n = (int)msg->rcv.src_port;
+ return &_sr_kemi_kx_xval;
+}
+
+/**
+ *
+ */
+static sr_kemi_xval_t* ki_kx_get_rcvip(sip_msg_t *msg)
+{
+ memset(&_sr_kemi_kx_xval, 0, sizeof(sr_kemi_xval_t));
+ if(msg==NULL || msg->rcv.bind_address==NULL
+ || msg->rcv.bind_address->address_str.s==NULL) {
+ sr_kemi_xval_null(&_sr_kemi_kx_xval, SR_KEMI_XVAL_NULL_NONE);
+ return &_sr_kemi_kx_xval;
+ }
+
+ _sr_kemi_kx_xval.vtype = SR_KEMIP_STR;
+ _sr_kemi_kx_xval.v.s = msg->rcv.bind_address->address_str;
+ return &_sr_kemi_kx_xval;
+}
+
+/**
+ *
+ */
+static sr_kemi_xval_t* ki_kx_get_rcvport(sip_msg_t *msg)
+{
+ memset(&_sr_kemi_kx_xval, 0, sizeof(sr_kemi_xval_t));
+ if(msg==NULL || msg->rcv.bind_address==NULL) {
+ _sr_kemi_kx_xval.vtype = SR_KEMIP_INT;
+ _sr_kemi_kx_xval.v.n = 0;
+ return &_sr_kemi_kx_xval;
+ }
+
+ _sr_kemi_kx_xval.vtype = SR_KEMIP_INT;
+ _sr_kemi_kx_xval.v.n = (int)msg->rcv.bind_address->port_no;
+ return &_sr_kemi_kx_xval;
+}
+
/**
*
*/
@@ -387,6 +455,26 @@ 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_srcip"),
+ SR_KEMIP_XVAL, ki_kx_get_srcip,
+ { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+ },
+ { str_init("kx"), str_init("get_srcport"),
+ SR_KEMIP_XVAL, ki_kx_get_srcport,
+ { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+ },
+ { str_init("kx"), str_init("get_rcvip"),
+ SR_KEMIP_XVAL, ki_kx_get_rcvip,
+ { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+ },
+ { str_init("kx"), str_init("get_rcvport"),
+ SR_KEMIP_XVAL, ki_kx_get_rcvport,
+ { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+ },
{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
};