diff --git a/src/modules/tm/t_suspend.c b/src/modules/tm/t_suspend.c index d8f0ee77b3e..a1508296990 100644 --- a/src/modules/tm/t_suspend.c +++ b/src/modules/tm/t_suspend.c @@ -23,6 +23,7 @@ #include "../../core/script_cb.h" #include "../../core/dset.h" #include "../../core/cfg/cfg_struct.h" +#include "../../core/kemi.h" #include "config.h" #include "sip_msg.h" @@ -162,8 +163,8 @@ int t_suspend(struct sip_msg *msg, * 0 - success * <0 - failure */ -int t_continue(unsigned int hash_index, unsigned int label, - struct action *route) +int t_continue_helper(unsigned int hash_index, unsigned int label, + struct action *rtact, str *cbname, str *cbparam) { struct cell *t; sip_msg_t *faked_req; @@ -181,6 +182,8 @@ int t_continue(unsigned int hash_index, unsigned int label, int do_put_on_wait; struct hdr_field *hdr, *prev = 0, *tmp = 0; int route_type_bk; + sr_kemi_eng_t *keng = NULL; + str evname = str_init("tm:continue"); cfg_update(); @@ -292,8 +295,30 @@ int t_continue(unsigned int hash_index, unsigned int label, set_route_type(FAILURE_ROUTE); /* execute the pre/post -script callbacks based on original route block */ if (exec_pre_script_cb(faked_req, cb_type)>0) { - if (run_top_route(route, faked_req, 0)<0) - LM_ERR("failure inside run_top_route\n"); + if(rtact!=NULL) { + if (run_top_route(rtact, faked_req, 0)<0) { + LM_ERR("failure inside run_top_route\n"); + } + } else { + if(cbname!=NULL && cbname->s!=NULL) { + keng = sr_kemi_eng_get(); + if(keng!=NULL) { + if(cbparam && cbparam->s) { + evname = *cbparam; + } + if(keng->froute(faked_req, FAILURE_ROUTE, cbname, + &evname)<0) { + LM_ERR("error running event route kemi callback\n"); + return -1; + } + } else { + LM_DBG("event callback (%.*s) set, but no cfg engine\n", + cbname->len, cbname->s); + } + } else { + LM_WARN("no continue callback\n"); + } + } exec_post_script_cb(faked_req, cb_type); } set_route_type(route_type_bk); @@ -348,8 +373,29 @@ int t_continue(unsigned int hash_index, unsigned int label, faked_env( t, t->uac[branch].reply, 1); if (exec_pre_script_cb(t->uac[branch].reply, cb_type)>0) { - if (run_top_route(route, t->uac[branch].reply, 0)<0){ - LM_ERR("Error in run_top_route\n"); + if(rtact!=NULL) { + if (run_top_route(rtact, t->uac[branch].reply, 0)<0){ + LM_ERR("Error in run_top_route\n"); + } + } else { + if(cbname!=NULL && cbname->s!=NULL) { + keng = sr_kemi_eng_get(); + if(keng!=NULL) { + if(cbparam && cbparam->s) { + evname = *cbparam; + } + if(keng->froute(t->uac[branch].reply, TM_ONREPLY_ROUTE, + cbname, &evname)<0) { + LM_ERR("error running event route kemi callback\n"); + return -1; + } + } else { + LM_DBG("event callback (%.*s) set, but no cfg engine\n", + cbname->len, cbname->s); + } + } else { + LM_WARN("no continue callback\n"); + } } exec_post_script_cb(t->uac[branch].reply, cb_type); } @@ -523,6 +569,18 @@ int t_continue(unsigned int hash_index, unsigned int label, return ret; } +int t_continue(unsigned int hash_index, unsigned int label, + struct action *route) +{ + return t_continue_helper(hash_index, label, route, NULL, NULL); +} + +int t_continue_cb(unsigned int hash_index, unsigned int label, + str *cbname, str *cbparam) +{ + return t_continue_helper(hash_index, label, NULL, cbname, cbparam); +} + /* Revoke the suspension of the SIP request, i.e. * cancel the fr timer of the blind uac. * This function can be called when something fails diff --git a/src/modules/tm/t_suspend.h b/src/modules/tm/t_suspend.h index 2e411b3bc44..fcbe182ad14 100644 --- a/src/modules/tm/t_suspend.h +++ b/src/modules/tm/t_suspend.h @@ -32,6 +32,11 @@ int t_continue(unsigned int hash_index, unsigned int label, typedef int (*t_continue_f)(unsigned int hash_index, unsigned int label, struct action *route); +int t_continue_cb(unsigned int hash_index, unsigned int label, + str *cbname, str *cbparam); +typedef int (*t_continue_cb_f)(unsigned int hash_index, unsigned int label, + str *cbname, str *cbparam); + int t_cancel_suspend(unsigned int hash_index, unsigned int label); typedef int (*t_cancel_suspend_f)(unsigned int hash_index, unsigned int label); diff --git a/src/modules/tm/tm_load.c b/src/modules/tm/tm_load.c index 5f0f7160a54..be5356fa131 100644 --- a/src/modules/tm/tm_load.c +++ b/src/modules/tm/tm_load.c @@ -119,6 +119,7 @@ int load_tm( struct tm_binds *tmb) #endif tmb->t_suspend = t_suspend; tmb->t_continue = t_continue; + tmb->t_continue_cb = t_continue_cb; tmb->t_cancel_suspend = t_cancel_suspend; tmb->t_get_reply_totag = t_get_reply_totag; tmb->t_get_picked_branch = t_get_picked_branch; diff --git a/src/modules/tm/tm_load.h b/src/modules/tm/tm_load.h index 9fd36e94861..c1fece44035 100644 --- a/src/modules/tm/tm_load.h +++ b/src/modules/tm/tm_load.h @@ -103,6 +103,7 @@ struct tm_binds { #endif t_suspend_f t_suspend; t_continue_f t_continue; + t_continue_cb_f t_continue_cb; t_cancel_suspend_f t_cancel_suspend; tget_reply_totag_f t_get_reply_totag; tget_picked_f t_get_picked_branch;