Module: kamailio
Branch: master
Commit: 4add1751ed673f062f2c79a2bc4c8f31955b6d1d
URL:
https://github.com/kamailio/kamailio/commit/4add1751ed673f062f2c79a2bc4c8f3…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2020-12-15T09:28:26+01:00
kemix: exported functions to get define values
---
Modified: src/modules/kemix/kemix_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/4add1751ed673f062f2c79a2bc4c8f3…
Patch:
https://github.com/kamailio/kamailio/commit/4add1751ed673f062f2c79a2bc4c8f3…
---
diff --git a/src/modules/kemix/kemix_mod.c b/src/modules/kemix/kemix_mod.c
index 37854bfa86..269dbd3dee 100644
--- a/src/modules/kemix/kemix_mod.c
+++ b/src/modules/kemix/kemix_mod.c
@@ -28,6 +28,7 @@
#include "../../core/sr_module.h"
#include "../../core/dprint.h"
#include "../../core/kemi.h"
+#include "../../core/ppcfg.h"
#include "../../core/parser/parse_uri.h"
#include "../../core/parser/parse_from.h"
#include "../../core/parser/parse_to.h"
@@ -1054,6 +1055,45 @@ static sr_kemi_xval_t* ki_kx_gete_cturi(sip_msg_t *msg)
return ki_kx_get_cturi_mode(msg, SR_KEMI_XVAL_NULL_EMPTY);
}
+/**
+ *
+ */
+static sr_kemi_xval_t* ki_kx_get_def(sip_msg_t *msg, str *dname)
+{
+ str *val;
+
+ val = pp_define_get(dname->len, dname->s);
+
+ memset(&_sr_kemi_kx_xval, 0, sizeof(sr_kemi_xval_t));
+ if (val==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.s = val->s;
+ _sr_kemi_kx_xval.v.s.len = val->len;
+ return &_sr_kemi_kx_xval;
+}
+
+/**
+ *
+ */
+static int ki_kx_get_defn(sip_msg_t *msg, str *dname)
+{
+ str *val;
+ int n = 0;
+
+ val = pp_define_get(dname->len, dname->s);
+
+ if (val != NULL) {
+ str2sint(val, &n);
+ }
+
+ return n;
+}
+
+
/**
*
*/
@@ -1354,6 +1394,16 @@ 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_def"),
+ SR_KEMIP_XVAL, ki_kx_get_def,
+ { SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+ },
+ { str_init("kx"), str_init("get_defn"),
+ SR_KEMIP_INT, ki_kx_get_defn,
+ { SR_KEMIP_STR, 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 } }