[sr-dev] git:master:b59204eb: kemix: exported functions to get socket string and name

Daniel-Constantin Mierla miconda at gmail.com
Mon Nov 23 10:11:55 CET 2020


Module: kamailio
Branch: master
Commit: b59204eb1df8c85bcdde65f2a840f55986f01223
URL: https://github.com/kamailio/kamailio/commit/b59204eb1df8c85bcdde65f2a840f55986f01223

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2020-11-23T08:15:34+01:00

kemix: exported functions to get socket string and name

---

Modified: src/modules/kemix/kemix_mod.c

---

Diff:  https://github.com/kamailio/kamailio/commit/b59204eb1df8c85bcdde65f2a840f55986f01223.diff
Patch: https://github.com/kamailio/kamailio/commit/b59204eb1df8c85bcdde65f2a840f55986f01223.patch

---

diff --git a/src/modules/kemix/kemix_mod.c b/src/modules/kemix/kemix_mod.c
index 66cdcf1bc1..ba56a6c16f 100644
--- a/src/modules/kemix/kemix_mod.c
+++ b/src/modules/kemix/kemix_mod.c
@@ -486,6 +486,39 @@ static sr_kemi_xval_t* ki_kx_get_srcport(sip_msg_t *msg)
 	return &_sr_kemi_kx_xval;
 }
 
+/**
+ *
+ */
+static sr_kemi_xval_t* ki_kx_get_send_sock(sip_msg_t *msg)
+{
+	memset(&_sr_kemi_kx_xval, 0, sizeof(sr_kemi_xval_t));
+	if (msg==NULL || msg->force_send_socket==0) {
+		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->force_send_socket->sock_str;
+	return &_sr_kemi_kx_xval;
+}
+
+/**
+ *
+ */
+static sr_kemi_xval_t* ki_kx_get_send_sock_name(sip_msg_t *msg)
+{
+	memset(&_sr_kemi_kx_xval, 0, sizeof(sr_kemi_xval_t));
+	if (msg==NULL || msg->force_send_socket==0
+			|| msg->force_send_socket->sockname.s==0) {
+		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->force_send_socket->sockname;
+	return &_sr_kemi_kx_xval;
+}
+
 /**
  *
  */
@@ -520,6 +553,23 @@ 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_rcv_sock_name(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->sockname.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->sockname;
+	return &_sr_kemi_kx_xval;
+}
+
 /**
  *
  */
@@ -1107,11 +1157,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_send_sock"),
+		SR_KEMIP_XVAL, ki_kx_get_send_sock,
+		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+	},
+	{ str_init("kx"), str_init("get_send_sock_name"),
+		SR_KEMIP_XVAL, ki_kx_get_send_sock_name,
+		{ 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_rcv_sock_name"),
+		SR_KEMIP_XVAL, ki_kx_get_rcv_sock_name,
+		{ 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,




More information about the sr-dev mailing list