Module: kamailio
Branch: master
Commit: 0d688a69e27b1ea49bf8c06469e1ce2e11006d95
URL:
https://github.com/kamailio/kamailio/commit/0d688a69e27b1ea49bf8c06469e1ce2…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2022-02-16T12:05:40+01:00
async: exported functions to kemi to get async group name and data
---
Modified: src/modules/async/async_mod.c
Modified: src/modules/async/async_sleep.c
Modified: src/modules/async/async_sleep.h
---
Diff:
https://github.com/kamailio/kamailio/commit/0d688a69e27b1ea49bf8c06469e1ce2…
Patch:
https://github.com/kamailio/kamailio/commit/0d688a69e27b1ea49bf8c06469e1ce2…
---
diff --git a/src/modules/async/async_mod.c b/src/modules/async/async_mod.c
index 60cd10e677..ee69e96e14 100644
--- a/src/modules/async/async_mod.c
+++ b/src/modules/async/async_mod.c
@@ -674,6 +674,16 @@ static sr_kemi_t sr_kemi_async_exports[] = {
{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_STR,
SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
},
+ { str_init("async"), str_init("get_gname"),
+ SR_KEMIP_XVAL, ki_async_get_gname,
+ { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+ },
+ { str_init("async"), str_init("get_data"),
+ SR_KEMIP_XVAL, ki_async_get_data,
+ { 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 } }
};
diff --git a/src/modules/async/async_sleep.c b/src/modules/async/async_sleep.c
index cfbfe98cef..b51887e351 100644
--- a/src/modules/async/async_sleep.c
+++ b/src/modules/async/async_sleep.c
@@ -675,3 +675,44 @@ int pv_parse_geoip_name(pv_spec_t *sp, str *in)
LM_ERR("unknown PV time name %.*s\n", in->len, in->s);
return -1;
}
+
+/**
+ *
+ */
+static sr_kemi_xval_t _ksr_kemi_async_xval = {0};
+
+/**
+ *
+ */
+sr_kemi_xval_t* ki_async_get_gname(sip_msg_t *msg)
+{
+ async_wgroup_t *awg = NULL;
+
+ memset(&_ksr_kemi_async_xval, 0, sizeof(sr_kemi_xval_t));
+
+ awg = async_task_workers_get_crt();
+ if(awg==NULL || awg->name.s==NULL || awg->name.len<0) {
+ sr_kemi_xval_null(&_ksr_kemi_async_xval, SR_KEMI_XVAL_NULL_EMPTY);
+ return &_ksr_kemi_async_xval;
+ }
+ _ksr_kemi_async_xval.vtype = SR_KEMIP_STR;
+ _ksr_kemi_async_xval.v.s = awg->name;
+ return &_ksr_kemi_async_xval;
+}
+
+/**
+ *
+ */
+sr_kemi_xval_t* ki_async_get_data(sip_msg_t *msg)
+{
+ memset(&_ksr_kemi_async_xval, 0, sizeof(sr_kemi_xval_t));
+
+ if(_ksr_async_data_param==NULL || _ksr_async_data_param->sval.s==NULL
+ || _ksr_async_data_param->sval.len<0) {
+ sr_kemi_xval_null(&_ksr_kemi_async_xval, SR_KEMI_XVAL_NULL_EMPTY);
+ return &_ksr_kemi_async_xval;
+ }
+ _ksr_kemi_async_xval.vtype = SR_KEMIP_STR;
+ _ksr_kemi_async_xval.v.s = _ksr_async_data_param->sval;
+ return &_ksr_kemi_async_xval;
+}
diff --git a/src/modules/async/async_sleep.h b/src/modules/async/async_sleep.h
index bb7dd042ce..254962bd70 100644
--- a/src/modules/async/async_sleep.h
+++ b/src/modules/async/async_sleep.h
@@ -56,4 +56,7 @@ int async_send_data(sip_msg_t *msg, cfg_action_t *act, str *cbname, str
*gname,
int pv_get_async(sip_msg_t *msg, pv_param_t *param, pv_value_t *res);
int pv_parse_async_name(pv_spec_t *sp, str *in);
+sr_kemi_xval_t* ki_async_get_gname(sip_msg_t *msg);
+sr_kemi_xval_t* ki_async_get_data(sip_msg_t *msg);
+
#endif