Browse code

kemix: function to get the body length

Daniel-Constantin Mierla authored on 08/06/2020 18:44:24
Showing 1 changed files
... ...
@@ -739,6 +739,30 @@ static sr_kemi_xval_t* ki_kx_getw_body(sip_msg_t *msg)
739 739
 	return ki_kx_get_body_mode(msg, SR_KEMI_XVAL_NULL_PRINT);
740 740
 }
741 741
 
742
+/**
743
+ *
744
+ */
745
+static int ki_kx_get_bodylen(sip_msg_t *msg)
746
+{
747
+	str s;
748
+	memset(&_sr_kemi_kx_xval, 0, sizeof(sr_kemi_xval_t));
749
+	if(msg==NULL) {
750
+		return 0;
751
+	}
752
+
753
+	s.s = get_body(msg);
754
+
755
+	if(s.s == NULL) {
756
+		return 0;
757
+	}
758
+	s.len = msg->buf + msg->len - s.s;
759
+	if(s.len <=0) {
760
+		return 0;
761
+	}
762
+
763
+	return s.len;
764
+}
765
+
742 766
 /**
743 767
  *
744 768
  */
... ...
@@ -1116,6 +1140,11 @@ static sr_kemi_t sr_kemi_kx_exports[] = {
1116 1140
 		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
1117 1141
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
1118 1142
 	},
1143
+	{ str_init("kx"), str_init("get_bodylen"),
1144
+		SR_KEMIP_INT, ki_kx_get_bodylen,
1145
+		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
1146
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
1147
+	},
1119 1148
 	{ str_init("kx"), str_init("get_timestamp"),
1120 1149
 		SR_KEMIP_INT, ki_kx_get_timestamp,
1121 1150
 		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,