Browse code

core: kemi - exported core route function

Daniel-Constantin Mierla authored on 20/08/2020 14:16:56
Showing 1 changed files
... ...
@@ -1482,6 +1482,41 @@ static int sr_kemi_core_get_debug(sip_msg_t *msg)
1482 1482
 	return get_cfg_debug_level();
1483 1483
 }
1484 1484
 
1485
+/**
1486
+ *
1487
+ */
1488
+static int sr_kemi_core_route(sip_msg_t *msg, str *route)
1489
+{
1490
+	run_act_ctx_t tctx;
1491
+	run_act_ctx_t *pctx = NULL;
1492
+	int rtid = -1;
1493
+	int ret = 0;
1494
+
1495
+	if(route == NULL || route->s == NULL) {
1496
+		return -1;
1497
+	}
1498
+
1499
+	rtid = route_lookup(&main_rt, route->s);
1500
+	if (rtid < 0) {
1501
+		return -1;
1502
+	}
1503
+
1504
+	if(_sr_kemi_act_ctx != NULL) {
1505
+		pctx = _sr_kemi_act_ctx;
1506
+	} else {
1507
+		init_run_actions_ctx(&tctx);
1508
+		pctx = &tctx;
1509
+	}
1510
+
1511
+	ret=run_actions(pctx, main_rt.rlist[rtid], msg);
1512
+
1513
+	if (pctx->run_flags & EXIT_R_F) {
1514
+		return 0;
1515
+	}
1516
+
1517
+	return ret;
1518
+}
1519
+
1485 1520
 /**
1486 1521
  *
1487 1522
  */
... ...
@@ -1881,6 +1916,11 @@ static sr_kemi_t _sr_kemi_core[] = {
1881 1916
 		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
1882 1917
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
1883 1918
 	},
1919
+	{ str_init(""), str_init("route"),
1920
+		SR_KEMIP_INT, sr_kemi_core_route,
1921
+		{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
1922
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
1923
+	},
1884 1924
 
1885 1925
 	{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
1886 1926
 };