[sr-dev] git:master:7116c04c: evapi: export async_unicast() to kemi

Daniel-Constantin Mierla miconda at gmail.com
Thu Jul 30 10:37:13 CEST 2020


Module: kamailio
Branch: master
Commit: 7116c04c61cf789a371568fb593c109e195a1574
URL: https://github.com/kamailio/kamailio/commit/7116c04c61cf789a371568fb593c109e195a1574

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2020-07-30T10:36:01+02:00

evapi: export async_unicast() to kemi

- PR #2415

---

Modified: src/modules/evapi/evapi_mod.c

---

Diff:  https://github.com/kamailio/kamailio/commit/7116c04c61cf789a371568fb593c109e195a1574.diff
Patch: https://github.com/kamailio/kamailio/commit/7116c04c61cf789a371568fb593c109e195a1574.patch

---

diff --git a/src/modules/evapi/evapi_mod.c b/src/modules/evapi/evapi_mod.c
index c0531bba2e..bcc582f6e3 100644
--- a/src/modules/evapi/evapi_mod.c
+++ b/src/modules/evapi/evapi_mod.c
@@ -703,6 +703,59 @@ static int ki_evapi_async_relay(sip_msg_t *msg, str *sdata)
 	return 1;
 }
 
+static int ki_evapi_async_unicast(sip_msg_t *msg, str *sdata, str *stag)
+{
+	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(stag->s==NULL || stag->len == 0) {
+		LM_ERR("invalid tag parameter\n");
+		return -1;
+	}
+
+	if(evapi_relay_unicast(sdata, stag)<0) {
+		LM_ERR("failed to relay event: [[%.*s]] to [%.*s] \n",
+				sdata->len, sdata->s, stag->len, stag->s);
+		return -2;
+	}
+	return 1;
+}
+
 /**
  *
  */
@@ -766,6 +819,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_unicast"),
+		SR_KEMIP_INT, ki_evapi_async_unicast,
+		{ SR_KEMIP_STR, SR_KEMIP_STR, 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 */




More information about the sr-dev mailing list