diff --git a/src/modules/tm/t_reply.c b/src/modules/tm/t_reply.c index 1fa7f9dda85..30006ae8a67 100644 --- a/src/modules/tm/t_reply.c +++ b/src/modules/tm/t_reply.c @@ -2162,7 +2162,6 @@ enum rps local_reply( struct cell *t, struct sip_msg *p_msg, int branch, */ int reply_received( struct sip_msg *p_msg ) { - int msg_status; int last_uac_status; char *ack; @@ -2192,6 +2191,8 @@ int reply_received( struct sip_msg *p_msg ) struct run_act_ctx ctx; struct run_act_ctx *bctx; sr_kemi_eng_t *keng = NULL; + int ret; + str evname = str_init("on_sl_reply"); /* make sure we know the associated transaction ... */ branch = T_BR_UNDEFINED; @@ -2566,17 +2567,40 @@ int reply_received( struct sip_msg *p_msg ) trans_not_found: /* transaction context was not found */ - if (goto_on_sl_reply) { - /* The script writer has a chance to decide whether to - * forward the reply or not. - * Pre- and post-script callbacks have already - * been execueted by the core. (Miklos) - */ - return run_top_route(onreply_rt.rlist[goto_on_sl_reply], p_msg, 0); - } else { - /* let the core forward the reply */ - return 1; + if(on_sl_reply_name.s!=NULL && on_sl_reply_name.len>0) { + keng = sr_kemi_eng_get(); + if(keng==NULL) { + if (goto_on_sl_reply) { + /* The script writer has a chance to decide whether to + * forward the reply or not. + * Pre- and post-script callbacks have already + * been execueted by the core. (Miklos) + */ + return run_top_route(onreply_rt.rlist[goto_on_sl_reply], p_msg, 0); + } else { + /* let the core forward the reply */ + return 1; + } + } else { + bctx = sr_kemi_act_ctx_get(); + init_run_actions_ctx(&ctx); + sr_kemi_act_ctx_set(&ctx); + ret = sr_kemi_ctx_route(keng, &ctx, p_msg, EVENT_ROUTE, + &on_sl_reply_name, &evname); + sr_kemi_act_ctx_set(bctx); + if(ret<0) { + LM_ERR("error running on sl reply callback\n"); + return -1; + } + if(unlikely(ctx.run_flags & DROP_R_F)) { + LM_DBG("drop flag set - skip forwarding the reply\n"); + return 0; + } + /* let the core forward the reply */ + return 1; + } } + return 1; } diff --git a/src/modules/tm/tm.c b/src/modules/tm/tm.c index 105bbaf1f23..99e20afcd3b 100644 --- a/src/modules/tm/tm.c +++ b/src/modules/tm/tm.c @@ -689,6 +689,8 @@ static int script_init( struct sip_msg *foo, unsigned int flags, void *bar) static int mod_init(void) { + sr_kemi_eng_t *keng = NULL; + DBG( "TM - (sizeof cell=%ld, sip_msg=%ld) initializing...\n", (long)sizeof(struct cell), (long)sizeof(struct sip_msg)); @@ -701,10 +703,13 @@ static int mod_init(void) } if(on_sl_reply_name.s!=NULL && on_sl_reply_name.len>0) { - goto_on_sl_reply=route_get(&onreply_rt, on_sl_reply_name.s); - if (goto_on_sl_reply==-1){ - LM_ERR("route get failed for on_sl_reply\n"); - return -1; + keng = sr_kemi_eng_get(); + if(keng==NULL) { + goto_on_sl_reply=route_get(&onreply_rt, on_sl_reply_name.s); + if (goto_on_sl_reply==-1){ + LM_ERR("route get failed for on_sl_reply\n"); + return -1; + } } } if (init_callid() < 0) {