Browse code

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

(cherry picked from commit 235a10bc7316f3b91ae6ab51960702a07f69f27a)

Daniel-Constantin Mierla authored on 08/03/2019 17:37:38
Showing 1 changed files
... ...
@@ -1063,6 +1063,25 @@ static int sr_kemi_core_is_af_ipv6(sip_msg_t *msg)
1063 1063
 	return (msg->rcv.bind_address->address.af==AF_INET6)?SR_KEMI_TRUE:SR_KEMI_FALSE;
1064 1064
 }
1065 1065
 
1066
+/**
1067
+ *
1068
+ */
1069
+static int sr_kemi_core_is_src_port(sip_msg_t *msg, int vport)
1070
+{
1071
+	return (vport == (int)msg->rcv.src_port)?SR_KEMI_TRUE:SR_KEMI_FALSE;
1072
+}
1073
+
1074
+/**
1075
+ *
1076
+ */
1077
+static int sr_kemi_core_is_dst_port(sip_msg_t *msg, int vport)
1078
+{
1079
+	if(msg==NULL || msg->rcv.bind_address==NULL) {
1080
+		return SR_KEMI_FALSE;
1081
+	}
1082
+	return (vport == (int)msg->rcv.bind_address->port_no)?SR_KEMI_TRUE:SR_KEMI_FALSE;
1083
+}
1084
+
1066 1085
 /**
1067 1086
  *
1068 1087
  */
... ...
@@ -1621,6 +1640,16 @@ static sr_kemi_t _sr_kemi_core[] = {
1621 1640
 		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
1622 1641
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
1623 1642
 	},
1643
+	{ str_init(""), str_init("is_src_port"),
1644
+		SR_KEMIP_BOOL, sr_kemi_core_is_src_port,
1645
+		{ SR_KEMIP_INT, SR_KEMIP_NONE, SR_KEMIP_NONE,
1646
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
1647
+	},
1648
+	{ str_init(""), str_init("is_dst_port"),
1649
+		SR_KEMIP_BOOL, sr_kemi_core_is_dst_port,
1650
+		{ SR_KEMIP_INT, SR_KEMIP_NONE, SR_KEMIP_NONE,
1651
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
1652
+	},
1624 1653
 
1625 1654
 	{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
1626 1655
 };