Browse code

core: kemi - corresponding functions to check af==ipv4/ipv6

(cherry picked from commit 61795123af0a2d2cb261c36ac78a4833f03a3321)

Daniel-Constantin Mierla authored on 08/03/2019 07:40:09
Showing 1 changed files
... ...
@@ -1041,6 +1041,28 @@ static int sr_kemi_core_is_proto_sctp(sip_msg_t *msg)
1041 1041
 	return (msg->rcv.proto == PROTO_SCTP)?SR_KEMI_TRUE:SR_KEMI_FALSE;
1042 1042
 }
1043 1043
 
1044
+/**
1045
+ *
1046
+ */
1047
+static int sr_kemi_core_is_af_ipv4(sip_msg_t *msg)
1048
+{
1049
+	if(msg==NULL || msg->rcv.bind_address==NULL) {
1050
+		return SR_KEMI_FALSE;
1051
+	}
1052
+	return (msg->rcv.bind_address->address.af==AF_INET)?SR_KEMI_TRUE:SR_KEMI_FALSE;
1053
+}
1054
+
1055
+/**
1056
+ *
1057
+ */
1058
+static int sr_kemi_core_is_af_ipv6(sip_msg_t *msg)
1059
+{
1060
+	if(msg==NULL || msg->rcv.bind_address==NULL) {
1061
+		return SR_KEMI_FALSE;
1062
+	}
1063
+	return (msg->rcv.bind_address->address.af==AF_INET6)?SR_KEMI_TRUE:SR_KEMI_FALSE;
1064
+}
1065
+
1044 1066
 /**
1045 1067
  *
1046 1068
  */
... ...
@@ -1589,6 +1611,16 @@ static sr_kemi_t _sr_kemi_core[] = {
1589 1611
 		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
1590 1612
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
1591 1613
 	},
1614
+	{ str_init(""), str_init("is_IPv4"),
1615
+		SR_KEMIP_BOOL, sr_kemi_core_is_af_ipv4,
1616
+		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
1617
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
1618
+	},
1619
+	{ str_init(""), str_init("is_IPv6"),
1620
+		SR_KEMIP_BOOL, sr_kemi_core_is_af_ipv6,
1621
+		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
1622
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
1623
+	},
1592 1624
 
1593 1625
 	{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
1594 1626
 };