浏览代码

core: kemi - exported core route function

Daniel-Constantin Mierla 5 年之前
父节点
当前提交
d9dd2abeb8
共有 1 个文件被更改,包括 40 次插入0 次删除
  1. 40 0
      src/core/kemi.c

+ 40 - 0
src/core/kemi.c

@@ -1482,6 +1482,41 @@ static int sr_kemi_core_get_debug(sip_msg_t *msg)
 	return get_cfg_debug_level();
 }
 
+/**
+ *
+ */
+static int sr_kemi_core_route(sip_msg_t *msg, str *route)
+{
+	run_act_ctx_t tctx;
+	run_act_ctx_t *pctx = NULL;
+	int rtid = -1;
+	int ret = 0;
+
+	if(route == NULL || route->s == NULL) {
+		return -1;
+	}
+
+	rtid = route_lookup(&main_rt, route->s);
+	if (rtid < 0) {
+		return -1;
+	}
+
+	if(_sr_kemi_act_ctx != NULL) {
+		pctx = _sr_kemi_act_ctx;
+	} else {
+		init_run_actions_ctx(&tctx);
+		pctx = &tctx;
+	}
+
+	ret=run_actions(pctx, main_rt.rlist[rtid], msg);
+
+	if (pctx->run_flags & EXIT_R_F) {
+		return 0;
+	}
+
+	return ret;
+}
+
 /**
  *
  */
@@ -1881,6 +1916,11 @@ static sr_kemi_t _sr_kemi_core[] = {
 		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
 	},
+	{ str_init(""), str_init("route"),
+		SR_KEMIP_INT, sr_kemi_core_route,
+		{ 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 } }
 };