Module: kamailio Branch: master Commit: 6500dda7ac1729c1ddf0600de2c1b679f74fba6f URL: https://github.com/kamailio/kamailio/commit/6500dda7ac1729c1ddf0600de2c1b679...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2016-04-12T14:16:44+02:00
app_lua: implemented alternative config file interpreting engine
- can be used to execute routing logic for SIP requests and responses by using next statement in kamailio.cfg:
cfgengine="lua"
---
Modified: modules/app_lua/app_lua_mod.c
---
Diff: https://github.com/kamailio/kamailio/commit/6500dda7ac1729c1ddf0600de2c1b679... Patch: https://github.com/kamailio/kamailio/commit/6500dda7ac1729c1ddf0600de2c1b679...
---
diff --git a/modules/app_lua/app_lua_mod.c b/modules/app_lua/app_lua_mod.c index 3bd1289..693d2c8 100644 --- a/modules/app_lua/app_lua_mod.c +++ b/modules/app_lua/app_lua_mod.c @@ -29,6 +29,7 @@ #include "../../mod_fix.h" #include "../../rpc.h" #include "../../rpc_lookup.h" +#include "../../kemi.h"
#include "app_lua_api.h"
@@ -103,9 +104,49 @@ struct module_exports exports = { child_init /* per child init function */ };
+/** + * + */ +int sr_kemi_config_engine_lua(sip_msg_t *msg, int rtype, str *rname) +{ + int ret; + + if(rtype==REQUEST_ROUTE) { + ret = app_lua_run(msg, "ksr_request_route", NULL, NULL, NULL); + } else if(rtype==CORE_ONREPLY_ROUTE) { + ret = app_lua_run(msg, "ksr_reply_route", NULL, NULL, NULL); + } else { + if(rname!=NULL) { + LM_ERR("route type %d with name [%.*s] not implemented\n", + rtype, rname->len, rname->s); + } else { + LM_ERR("route type %d with no name not implemented\n", + rtype); + } + } + + if(rname!=NULL) { + LM_DBG("execution of route type %d with name [%.*s] returned %d\n", + rtype, rname->len, rname->s, ret); + } else { + LM_DBG("execution of route type %d with no name returned %d\n", + rtype, ret); + } + + return 1; +} + +/** + * + */ int mod_register(char *path, int *dlflags, void *p1, void *p2) { + str ename = str_init("lua"); + *dlflags = RTLD_NOW | RTLD_GLOBAL; + + sr_kemi_eng_register(&ename, sr_kemi_config_engine_lua); + return 0; }