Module: kamailio Branch: master Commit: ab2ca4c9145a537136ea81a21bf257af50bfd18d URL: https://github.com/kamailio/kamailio/commit/ab2ca4c9145a537136ea81a21bf257af...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2016-04-12T14:14:15+02:00
core: ability to run alternative request_route and reply_route handlers
- they can be offered by the embedded interpreters - at this moment app_lua can execute functions from the script loaded with param 'load': - instead of request_route it executes ksr_request_route() - instead of reply_route it executes ksr_reply_route()
---
Modified: receive.c
---
Diff: https://github.com/kamailio/kamailio/commit/ab2ca4c9145a537136ea81a21bf257af... Patch: https://github.com/kamailio/kamailio/commit/ab2ca4c9145a537136ea81a21bf257af...
---
diff --git a/receive.c b/receive.c index 0904de1..67c7df0 100644 --- a/receive.c +++ b/receive.c @@ -54,6 +54,7 @@ #include "tcp_options.h" /* for access to tcp_accept_aliases*/ #include "cfg/cfg.h" #include "core_stats.h" +#include "kemi.h"
#ifdef DEBUG_DMALLOC #include <mem/dmalloc.h> @@ -125,6 +126,7 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info) #endif str inb; sr_net_info_t netinfo; + sr_kemi_eng_t *keng = NULL;
if(sr_event_enabled(SREV_NET_DATA_RECV)) { if(sip_check_fline(buf, len)==0) { @@ -237,9 +239,20 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
set_route_type(REQUEST_ROUTE); /* exec the routing script */ - if (run_top_route(main_rt.rlist[DEFAULT_RT], msg, 0)<0){ - LM_WARN("error while trying script\n"); - goto error_req; + if(unlikely(main_rt.rlist[DEFAULT_RT]==NULL)) { + keng = sr_kemi_eng_get(); + if(keng==NULL) { + LM_ERR("no config routing engine registered\n"); + goto error_req; + } + if(keng->froute(msg, REQUEST_ROUTE, NULL)<0) { + LM_NOTICE("negative return code from engine function\n"); + } + } else { + if (run_top_route(main_rt.rlist[DEFAULT_RT], msg, 0)<0){ + LM_WARN("error while trying script\n"); + goto error_req; + } }
#ifdef STATS @@ -283,7 +296,15 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info) /* exec the onreply routing script */ if (onreply_rt.rlist[DEFAULT_RT]){ set_route_type(CORE_ONREPLY_ROUTE); - ret=run_top_route(onreply_rt.rlist[DEFAULT_RT], msg, &ctx); + ret = 1; + if(unlikely(main_rt.rlist[DEFAULT_RT]==NULL)) { + keng = sr_kemi_eng_get(); + if(keng!=NULL) { + ret = keng->froute(msg, REQUEST_ROUTE, NULL); + } + } else { + ret=run_top_route(onreply_rt.rlist[DEFAULT_RT], msg, &ctx); + } #ifndef NO_ONREPLY_ROUTE_ERROR if (unlikely(ret<0)){ LM_WARN("error while trying onreply script\n");