Module: kamailio
Branch: master
Commit: 752e875faece8233d39f8c91d7d553517ee94cd6
URL:
https://github.com/kamailio/kamailio/commit/752e875faece8233d39f8c91d7d5535…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: GitHub <noreply(a)github.com>
Date: 2018-06-22T10:32:49+02:00
Merge pull request #1563 from surendratiwari3/evapi_async_relay_kemi
Modules: Evapi async_relay export to kemi
---
Modified: src/modules/evapi/evapi_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/752e875faece8233d39f8c91d7d5535…
Patch:
https://github.com/kamailio/kamailio/commit/752e875faece8233d39f8c91d7d5535…
---
diff --git a/src/modules/evapi/evapi_mod.c b/src/modules/evapi/evapi_mod.c
index 7673cb262e..9ed8bd6d9a 100644
--- a/src/modules/evapi/evapi_mod.c
+++ b/src/modules/evapi/evapi_mod.c
@@ -591,6 +591,56 @@ static int ki_evapi_relay(sip_msg_t *msg, str *sdata)
return evapi_relay(sdata);
}
+/**
+ *
+ */
+static int ki_evapi_async_relay(sip_msg_t *msg, str *sdata)
+{
+ unsigned int tindex;
+ unsigned int tlabel;
+ tm_cell_t *t = 0;
+
+
+ if(tmb.t_suspend==NULL) {
+ LM_ERR("evapi async relay is disabled - tm module not loaded\n");
+ return -1;
+ }
+
+ t = tmb.t_gett();
+ if (t==NULL || t==T_UNDEFINED)
+ {
+ if(tmb.t_newtran(msg)<0)
+ {
+ LM_ERR("cannot create the transaction\n");
+ return -1;
+ }
+ t = tmb.t_gett();
+ if (t==NULL || t==T_UNDEFINED)
+ {
+ LM_ERR("cannot lookup the transaction\n");
+ return -1;
+ }
+ }
+ if(tmb.t_suspend(msg, &tindex, &tlabel)<0)
+ {
+ LM_ERR("failed to suspend request processing\n");
+ return -1;
+ }
+
+ LM_DBG("transaction suspended [%u:%u]\n", tindex, tlabel);
+
+ if(sdata->s==NULL || sdata->len == 0) {
+ LM_ERR("invalid data parameter\n");
+ return -1;
+ }
+
+ if(evapi_relay(sdata)<0) {
+ LM_ERR("failed to relay event: %.*s\n", sdata->len, sdata->s);
+ return -2;
+ }
+ return 1;
+}
+
/**
*
*/
@@ -637,7 +687,11 @@ static sr_kemi_t sr_kemi_evapi_exports[] = {
{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
},
-
+ { str_init("evapi"), str_init("async_relay"),
+ SR_KEMIP_INT, ki_evapi_async_relay,
+ { 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 } }
};
/* clang-format on */