Skip to content

Commit

Permalink
app_lua: implemented alternative config file interpreting engine
Browse files Browse the repository at this point in the history
- can be used to execute routing logic for SIP requests and responses by
  using next statement in kamailio.cfg:

  cfgengine="lua"
  • Loading branch information
miconda committed Apr 12, 2016
1 parent ab2ca4c commit 6500dda
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions modules/app_lua/app_lua_mod.c
Expand Up @@ -29,6 +29,7 @@
#include "../../mod_fix.h"
#include "../../rpc.h"
#include "../../rpc_lookup.h"
#include "../../kemi.h"

#include "app_lua_api.h"

Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 6500dda

Please sign in to comment.