Module: kamailio
Branch: master
Commit: 71fe612c7d9a48890095fc2ec3c2496c79d0df83
URL:
https://github.com/kamailio/kamailio/commit/71fe612c7d9a48890095fc2ec3c2496…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2020-02-05T09:38:43+01:00
kemix: exported function to get call-id
---
Modified: src/modules/kemix/kemix_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/71fe612c7d9a48890095fc2ec3c2496…
Patch:
https://github.com/kamailio/kamailio/commit/71fe612c7d9a48890095fc2ec3c2496…
---
diff --git a/src/modules/kemix/kemix_mod.c b/src/modules/kemix/kemix_mod.c
index 8ec834d365..b5b1047e0b 100644
--- a/src/modules/kemix/kemix_mod.c
+++ b/src/modules/kemix/kemix_mod.c
@@ -35,6 +35,7 @@
MODULE_VERSION
+/* clang-format off */
struct module_exports exports = {
"kemix", /* module name */
DEFAULT_DLFLAGS, /* dlopen flags */
@@ -47,6 +48,7 @@ struct module_exports exports = {
0, /* per-child init function */
0 /* module destroy function */
};
+/* clang-format on */
/**
@@ -719,6 +721,28 @@ static int ki_kx_get_timestamp(sip_msg_t *msg)
return (int)time(NULL);
}
+/**
+ *
+ */
+static sr_kemi_xval_t* ki_kx_get_callid(sip_msg_t *msg)
+{
+ memset(&_sr_kemi_kx_xval, 0, sizeof(sr_kemi_xval_t));
+ if(msg==NULL) {
+ sr_kemi_xval_null(&_sr_kemi_kx_xval, SR_KEMI_XVAL_NULL_EMPTY);
+ return &_sr_kemi_kx_xval;
+ }
+ if(msg->callid==NULL && ((parse_headers(msg, HDR_CALLID_F, 0)==-1)
+ || (msg->callid==NULL))) {
+ sr_kemi_xval_null(&_sr_kemi_kx_xval, SR_KEMI_XVAL_NULL_EMPTY);
+ return &_sr_kemi_kx_xval;
+ }
+
+ _sr_kemi_kx_xval.vtype = SR_KEMIP_STR;
+ _sr_kemi_kx_xval.v.s = msg->callid->body;
+ return &_sr_kemi_kx_xval;
+}
+
+
/**
*
*/
@@ -915,6 +939,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_callid"),
+ SR_KEMIP_XVAL, ki_kx_get_callid,
+ { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+ },
{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
};