Browse code

kemix: functions to get msg buffer and length

Daniel-Constantin Mierla authored on 29/05/2020 08:40:19
Showing 1 changed files
... ...
@@ -843,6 +843,35 @@ static int ki_kx_get_conid(sip_msg_t *msg)
843 843
 	return conid;
844 844
 }
845 845
 
846
+/**
847
+ *
848
+ */
849
+static sr_kemi_xval_t* ki_kx_get_msgbuf(sip_msg_t *msg)
850
+{
851
+	memset(&_sr_kemi_kx_xval, 0, sizeof(sr_kemi_xval_t));
852
+	if(msg==NULL) {
853
+		sr_kemi_xval_null(&_sr_kemi_kx_xval, SR_KEMI_XVAL_NULL_EMPTY);
854
+		return &_sr_kemi_kx_xval;
855
+	}
856
+
857
+	_sr_kemi_kx_xval.vtype = SR_KEMIP_STR;
858
+	_sr_kemi_kx_xval.v.s.s = msg->buf;
859
+	_sr_kemi_kx_xval.v.s.len = msg->len;
860
+	return &_sr_kemi_kx_xval;
861
+}
862
+
863
+/**
864
+ *
865
+ */
866
+static int ki_kx_get_msglen(sip_msg_t *msg)
867
+{
868
+	if(msg==NULL) {
869
+		return -1;
870
+	}
871
+
872
+	return msg->len;
873
+}
874
+
846 875
 /**
847 876
  *
848 877
  */
... ...
@@ -1083,6 +1112,17 @@ static sr_kemi_t sr_kemi_kx_exports[] = {
1083 1112
 		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
1084 1113
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
1085 1114
 	},
1115
+	{ str_init("kx"), str_init("get_msgbuf"),
1116
+		SR_KEMIP_XVAL, ki_kx_get_msgbuf,
1117
+		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
1118
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
1119
+	},
1120
+	{ str_init("kx"), str_init("get_msglen"),
1121
+		SR_KEMIP_INT, ki_kx_get_msglen,
1122
+		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
1123
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
1124
+	},
1125
+
1086 1126
 
1087 1127
 	{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
1088 1128
 };