Module: kamailio Branch: 5.2 Commit: 6129c28f8c5957ca409a8e51737e4d9fbd860652 URL: https://github.com/kamailio/kamailio/commit/6129c28f8c5957ca409a8e51737e4d9f...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2019-03-10T09:21:01+01:00
core: kemi - corresponding functions to check af==ipv4/ipv6
(cherry picked from commit 61795123af0a2d2cb261c36ac78a4833f03a3321)
---
Modified: src/core/kemi.c
---
Diff: https://github.com/kamailio/kamailio/commit/6129c28f8c5957ca409a8e51737e4d9f... Patch: https://github.com/kamailio/kamailio/commit/6129c28f8c5957ca409a8e51737e4d9f...
---
diff --git a/src/core/kemi.c b/src/core/kemi.c index 82b3ac4ec0..68a6a80f49 100644 --- a/src/core/kemi.c +++ b/src/core/kemi.c @@ -1041,6 +1041,28 @@ static int sr_kemi_core_is_proto_sctp(sip_msg_t *msg) return (msg->rcv.proto == PROTO_SCTP)?SR_KEMI_TRUE:SR_KEMI_FALSE; }
+/** + * + */ +static int sr_kemi_core_is_af_ipv4(sip_msg_t *msg) +{ + if(msg==NULL || msg->rcv.bind_address==NULL) { + return SR_KEMI_FALSE; + } + return (msg->rcv.bind_address->address.af==AF_INET)?SR_KEMI_TRUE:SR_KEMI_FALSE; +} + +/** + * + */ +static int sr_kemi_core_is_af_ipv6(sip_msg_t *msg) +{ + if(msg==NULL || msg->rcv.bind_address==NULL) { + return SR_KEMI_FALSE; + } + return (msg->rcv.bind_address->address.af==AF_INET6)?SR_KEMI_TRUE:SR_KEMI_FALSE; +} + /** * */ @@ -1589,6 +1611,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_IPv4"), + SR_KEMIP_BOOL, sr_kemi_core_is_af_ipv4, + { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE, + SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE } + }, + { str_init(""), str_init("is_IPv6"), + SR_KEMIP_BOOL, sr_kemi_core_is_af_ipv6, + { 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 } } };