Module: kamailio
Branch: master
Commit: 0607cd0b42ff2c692e8a096a73df41017449bde5
URL:
https://github.com/kamailio/kamailio/commit/0607cd0b42ff2c692e8a096a73df410…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2020-06-09T10:44:24+02:00
kemix: function to get the body length
---
Modified: src/modules/kemix/kemix_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/0607cd0b42ff2c692e8a096a73df410…
Patch:
https://github.com/kamailio/kamailio/commit/0607cd0b42ff2c692e8a096a73df410…
---
diff --git a/src/modules/kemix/kemix_mod.c b/src/modules/kemix/kemix_mod.c
index fdedda04be..4bd6f839d1 100644
--- a/src/modules/kemix/kemix_mod.c
+++ b/src/modules/kemix/kemix_mod.c
@@ -739,6 +739,30 @@ static sr_kemi_xval_t* ki_kx_getw_body(sip_msg_t *msg)
return ki_kx_get_body_mode(msg, SR_KEMI_XVAL_NULL_PRINT);
}
+/**
+ *
+ */
+static int ki_kx_get_bodylen(sip_msg_t *msg)
+{
+ str s;
+ memset(&_sr_kemi_kx_xval, 0, sizeof(sr_kemi_xval_t));
+ if(msg==NULL) {
+ return 0;
+ }
+
+ s.s = get_body(msg);
+
+ if(s.s == NULL) {
+ return 0;
+ }
+ s.len = msg->buf + msg->len - s.s;
+ if(s.len <=0) {
+ return 0;
+ }
+
+ return s.len;
+}
+
/**
*
*/
@@ -1116,6 +1140,11 @@ static sr_kemi_t sr_kemi_kx_exports[] = {
{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
},
+ { str_init("kx"), str_init("get_bodylen"),
+ SR_KEMIP_INT, ki_kx_get_bodylen,
+ { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+ },
{ str_init("kx"), str_init("get_timestamp"),
SR_KEMIP_INT, ki_kx_get_timestamp,
{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,