[sr-dev] git:5.2:b45c9f25: core: kemi - exported functions for equivalent tests of src_port and dst_port

Daniel-Constantin Mierla miconda at gmail.com
Sun Mar 10 10:59:36 CET 2019


Module: kamailio
Branch: 5.2
Commit: b45c9f2525e926a07d9c7fe2e212675327197990
URL: https://github.com/kamailio/kamailio/commit/b45c9f2525e926a07d9c7fe2e212675327197990

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2019-03-10T09:21:24+01:00

core: kemi - exported functions for equivalent tests of src_port and dst_port

(cherry picked from commit 235a10bc7316f3b91ae6ab51960702a07f69f27a)

---

Modified: src/core/kemi.c

---

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

---

diff --git a/src/core/kemi.c b/src/core/kemi.c
index 68a6a80f49..3c6bba057f 100644
--- a/src/core/kemi.c
+++ b/src/core/kemi.c
@@ -1063,6 +1063,25 @@ static int sr_kemi_core_is_af_ipv6(sip_msg_t *msg)
 	return (msg->rcv.bind_address->address.af==AF_INET6)?SR_KEMI_TRUE:SR_KEMI_FALSE;
 }
 
+/**
+ *
+ */
+static int sr_kemi_core_is_src_port(sip_msg_t *msg, int vport)
+{
+	return (vport == (int)msg->rcv.src_port)?SR_KEMI_TRUE:SR_KEMI_FALSE;
+}
+
+/**
+ *
+ */
+static int sr_kemi_core_is_dst_port(sip_msg_t *msg, int vport)
+{
+	if(msg==NULL || msg->rcv.bind_address==NULL) {
+		return SR_KEMI_FALSE;
+	}
+	return (vport == (int)msg->rcv.bind_address->port_no)?SR_KEMI_TRUE:SR_KEMI_FALSE;
+}
+
 /**
  *
  */
@@ -1621,6 +1640,16 @@ static sr_kemi_t _sr_kemi_core[] = {
 		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
 	},
+	{ str_init(""), str_init("is_src_port"),
+		SR_KEMIP_BOOL, sr_kemi_core_is_src_port,
+		{ SR_KEMIP_INT, SR_KEMIP_NONE, SR_KEMIP_NONE,
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+	},
+	{ str_init(""), str_init("is_dst_port"),
+		SR_KEMIP_BOOL, sr_kemi_core_is_dst_port,
+		{ SR_KEMIP_INT, 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 } }
 };




More information about the sr-dev mailing list