Module: kamailio
Branch: master
Commit: 7c347e244cf761d04d5aff906e88571cd68217f3
URL:
https://github.com/kamailio/kamailio/commit/7c347e244cf761d04d5aff906e88571…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2022-05-20T16:07:56+02:00
dialog: reworked kemi export for dlg_get_var()
- return SR_KEMIP_XVAL type
---
Modified: src/modules/dialog/dialog.c
---
Diff:
https://github.com/kamailio/kamailio/commit/7c347e244cf761d04d5aff906e88571…
Patch:
https://github.com/kamailio/kamailio/commit/7c347e244cf761d04d5aff906e88571…
---
diff --git a/src/modules/dialog/dialog.c b/src/modules/dialog/dialog.c
index b169dc2d26..5347c0fa1d 100644
--- a/src/modules/dialog/dialog.c
+++ b/src/modules/dialog/dialog.c
@@ -1511,7 +1511,7 @@ static int fixup_dlg_bridge(void** param, int param_no)
return 0;
}
-static str *ki_dlg_get_var(sip_msg_t *msg, str *sc, str *sf, str *st, str *key)
+static str *ki_dlg_get_var_helper(sip_msg_t *msg, str *sc, str *sf, str *st, str *key)
{
dlg_cell_t *dlg = NULL;
unsigned int dir = 0;
@@ -1538,6 +1538,30 @@ static str *ki_dlg_get_var(sip_msg_t *msg, str *sc, str *sf, str
*st, str *key)
return val;
}
+/**
+ *
+ */
+static sr_kemi_xval_t _sr_kemi_dialog_xval = {0};
+
+static sr_kemi_xval_t *ki_dlg_get_var(sip_msg_t *msg, str *sc, str *sf, str *st, str
*key)
+{
+ str *val = NULL;
+
+ memset(&_sr_kemi_dialog_xval, 0, sizeof(sr_kemi_xval_t));
+
+ val = ki_dlg_get_var_helper(msg, &sc, &sf, &st, &k);
+ if(!val) {
+ sr_kemi_xval_null(&_sr_kemi_dialog_xval, SR_KEMI_XVAL_NULL_NONE);
+ return &_sr_kemi_dialog_xval;
+ }
+
+ _sr_kemi_dialog_xval.vtype = SR_KEMIP_STR;
+ _sr_kemi_dialog_xval.v.s = *pval;
+
+ return &_sr_kemi_dialog_xval;
+
+}
+
static int w_dlg_get_var(struct sip_msg *msg, char *ci, char *ft, char *tt, char *key,
char *pv)
{
str sc = STR_NULL;
@@ -1582,7 +1606,7 @@ static int w_dlg_get_var(struct sip_msg *msg, char *ci, char *ft,
char *tt, char
return -1;
}
dst_pv = (pv_spec_t *)pv;
- val = ki_dlg_get_var(msg, &sc, &sf, &st, &k);
+ val = ki_dlg_get_var_helper(msg, &sc, &sf, &st, &k);
if(val) {
memset(&dst_val, 0, sizeof(pv_value_t));
dst_val.flags |= PV_VAL_STR;
@@ -2155,11 +2179,6 @@ static int ki_dlg_var_sets(sip_msg_t *msg, str *name, str *val)
return (ret==0)?1:ret;
}
-/**
- *
- */
-static sr_kemi_xval_t _sr_kemi_dialog_xval = {0};
-
/**
*
*/
@@ -2289,7 +2308,7 @@ static sr_kemi_t sr_kemi_dialog_exports[] = {
SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
},
{ str_init("dialog"), str_init("dlg_get_var"),
- SR_KEMIP_STR, ki_dlg_get_var,
+ SR_KEMIP_XVAL, ki_dlg_get_var,
{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_STR,
SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE }
},