Module: kamailio Branch: 5.2 Commit: fc09321222889dac8138d31d2b19247c02041687 URL: https://github.com/kamailio/kamailio/commit/fc09321222889dac8138d31d2b19247c...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2019-03-10T09:20:49+01:00
core: exported functions to check incoming protocol
- corresponding to proto==UDP/TCP/TLS/...
(cherry picked from commit d33d60e08b5081a605149b3bff2a0397c0952e9b)
---
Modified: src/core/kemi.c
---
Diff: https://github.com/kamailio/kamailio/commit/fc09321222889dac8138d31d2b19247c... Patch: https://github.com/kamailio/kamailio/commit/fc09321222889dac8138d31d2b19247c...
---
diff --git a/src/core/kemi.c b/src/core/kemi.c index 282be877c9..82b3ac4ec0 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 } } };