Browse code

kemi: exported function to get msg type

Daniel-Constantin Mierla authored on 30/05/2020 07:11:06
Showing 1 changed files
... ...
@@ -872,6 +872,25 @@ static int ki_kx_get_msglen(sip_msg_t *msg)
872 872
 	return msg->len;
873 873
 }
874 874
 
875
+/**
876
+ *
877
+ */
878
+static int ki_kx_get_msgtype(sip_msg_t *msg)
879
+{
880
+	if(msg==NULL) {
881
+		return -1;
882
+	}
883
+
884
+	if(msg->first_line.type == SIP_REQUEST) {
885
+		return 1;
886
+	} else if(msg->first_line.type == SIP_REPLY) {
887
+		return 2;
888
+	}
889
+
890
+	return 0;
891
+}
892
+
893
+
875 894
 /**
876 895
  *
877 896
  */
... ...
@@ -1122,6 +1141,11 @@ static sr_kemi_t sr_kemi_kx_exports[] = {
1122 1141
 		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
1123 1142
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
1124 1143
 	},
1144
+	{ str_init("kx"), str_init("get_msgtype"),
1145
+		SR_KEMIP_INT, ki_kx_get_msgtype,
1146
+		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
1147
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
1148
+	},
1125 1149
 
1126 1150
 
1127 1151
 	{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }