[sr-dev] git:master:d33d60e0: core: exported functions to check incoming protocol

Daniel-Constantin Mierla miconda at gmail.com
Thu Mar 7 16:25:43 CET 2019


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

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

core: exported functions to check incoming protocol

- corresponding to proto==UDP/TCP/TLS/...

---

Modified: src/core/kemi.c

---

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

---

diff --git a/src/core/kemi.c b/src/core/kemi.c
index 3457c6e860..5480405f24 100644
--- a/src/core/kemi.c
+++ b/src/core/kemi.c
@@ -993,6 +993,54 @@ static int sr_kemi_core_is_method_prack(sip_msg_t *msg)
 	return sr_kemi_core_is_method_type(msg, METHOD_PRACK);
 }
 
+/**
+ *
+ */
+static int sr_kemi_core_is_proto_udp(sip_msg_t *msg)
+{
+	return (msg->rcv.proto == PROTO_UDP)?SR_KEMI_TRUE:SR_KEMI_FALSE;
+}
+
+/**
+ *
+ */
+static int sr_kemi_core_is_proto_tcp(sip_msg_t *msg)
+{
+	return (msg->rcv.proto == PROTO_TCP)?SR_KEMI_TRUE:SR_KEMI_FALSE;
+}
+
+/**
+ *
+ */
+static int sr_kemi_core_is_proto_tls(sip_msg_t *msg)
+{
+	return (msg->rcv.proto == PROTO_TLS)?SR_KEMI_TRUE:SR_KEMI_FALSE;
+}
+
+/**
+ *
+ */
+static int sr_kemi_core_is_proto_ws(sip_msg_t *msg)
+{
+	return (msg->rcv.proto == PROTO_WS)?SR_KEMI_TRUE:SR_KEMI_FALSE;
+}
+
+/**
+ *
+ */
+static int sr_kemi_core_is_proto_wss(sip_msg_t *msg)
+{
+	return (msg->rcv.proto == PROTO_WSS)?SR_KEMI_TRUE:SR_KEMI_FALSE;
+}
+
+/**
+ *
+ */
+static int sr_kemi_core_is_proto_sctp(sip_msg_t *msg)
+{
+	return (msg->rcv.proto == PROTO_SCTP)?SR_KEMI_TRUE:SR_KEMI_FALSE;
+}
+
 /**
  *
  */
@@ -1511,6 +1559,36 @@ 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_UDP"),
+		SR_KEMIP_BOOL, sr_kemi_core_is_proto_udp,
+		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+	},
+	{ str_init(""), str_init("is_TCP"),
+		SR_KEMIP_BOOL, sr_kemi_core_is_proto_tcp,
+		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+	},
+	{ str_init(""), str_init("is_TLS"),
+		SR_KEMIP_BOOL, sr_kemi_core_is_proto_tls,
+		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+	},
+	{ str_init(""), str_init("is_WS"),
+		SR_KEMIP_BOOL, sr_kemi_core_is_proto_ws,
+		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+	},
+	{ str_init(""), str_init("is_WSS"),
+		SR_KEMIP_BOOL, sr_kemi_core_is_proto_wss,
+		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+	},
+	{ str_init(""), str_init("is_SCTP"),
+		SR_KEMIP_BOOL, sr_kemi_core_is_proto_sctp,
+		{ 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 } }
 };




More information about the sr-dev mailing list