Module: sip-router Branch: master Commit: 4ce1715db779ce1c805cbaa257a99e14adc44056 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=4ce1715d...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Thu Jul 9 11:23:14 2009 +0200
core: run_top_route() can be give action context
- functions calling run_top_route() can get access to context fields if they need - modules updated to new function signature
---
action.c | 8 +++++--- action.h | 2 +- modules/tm/t_fwd.c | 2 +- modules/tm/t_reply.c | 6 +++--- modules/tm/t_suspend.c | 2 +- modules_k/cpl-c/cpl_sig.c | 2 +- modules_k/dialog/dlg_handlers.c | 2 +- modules_k/drouting/drouting.c | 4 ++-- modules_k/htable/htable.c | 2 +- modules_k/rtimer/rtimer_mod.c | 2 +- receive.c | 4 ++-- 11 files changed, 19 insertions(+), 17 deletions(-)
diff --git a/action.c b/action.c index 9f89ac6..e360730 100644 --- a/action.c +++ b/action.c @@ -1292,11 +1292,13 @@ error: }
-int run_top_route(struct action* a, sip_msg_t* msg) +int run_top_route(struct action* a, sip_msg_t* msg, struct run_act_ctx *c) { struct run_act_ctx ctx; + struct run_act_ctx *p; + p = (c)?c:&ctx; setsflagsval(0); reset_static_buffer(); - init_run_actions_ctx(&ctx); - return run_actions(&ctx, a, msg); + init_run_actions_ctx(p); + return run_actions(p, a, msg); } diff --git a/action.h b/action.h index 05b68cf..c07b9ae 100644 --- a/action.h +++ b/action.h @@ -59,6 +59,6 @@ struct run_act_ctx{ int do_action(struct run_act_ctx* c, struct action* a, struct sip_msg* msg); int run_actions(struct run_act_ctx* c, struct action* a, struct sip_msg* msg);
-int run_top_route(struct action* a, sip_msg_t* msg); +int run_top_route(struct action* a, sip_msg_t* msg, struct run_act_ctx* c);
#endif diff --git a/modules/tm/t_fwd.c b/modules/tm/t_fwd.c index 61e4315..969720b 100644 --- a/modules/tm/t_fwd.c +++ b/modules/tm/t_fwd.c @@ -196,7 +196,7 @@ static char *print_uac_request( struct cell *t, struct sip_msg *i_req, set_route_type(BRANCH_ROUTE); tm_ctx_set_branch_index(branch+1); if (exec_pre_script_cb(i_req, BRANCH_CB_TYPE)>0) { - if (run_top_route(branch_rt.rlist[branch_route], i_req) < 0) { + if (run_top_route(branch_rt.rlist[branch_route], i_req, 0) < 0) { LOG(L_ERR, "ERROR: print_uac_request: Error in run_top_route\n"); } exec_post_script_cb(i_req, BRANCH_CB_TYPE); diff --git a/modules/tm/t_reply.c b/modules/tm/t_reply.c index 3d46f6f..b6f4229 100644 --- a/modules/tm/t_reply.c +++ b/modules/tm/t_reply.c @@ -868,7 +868,7 @@ int run_failure_handlers(struct cell *t, struct sip_msg *rpl, t->on_negative=0; if (exec_pre_script_cb(&faked_req, FAILURE_CB_TYPE)>0) { /* run a reply_route action if some was marked */ - if (run_top_route(failure_rt.rlist[on_failure], &faked_req)<0) + if (run_top_route(failure_rt.rlist[on_failure], &faked_req, 0)<0) LOG(L_ERR, "ERROR: run_failure_handlers: Error in run_top_route\n"); exec_post_script_cb(&faked_req, FAILURE_CB_TYPE); } @@ -1976,7 +1976,7 @@ int reply_received( struct sip_msg *p_msg ) /* Pre- and post-script callbacks have already * been execueted by the core. (Miklos) */ - if (run_top_route(onreply_rt.rlist[t->on_reply], p_msg)<0) + if (run_top_route(onreply_rt.rlist[t->on_reply], p_msg, 0)<0) LOG(L_ERR, "ERROR: on_reply processing failed\n"); /* transfer current message context back to t */ if (t->uas.request) t->uas.request->flags=p_msg->flags; @@ -2108,7 +2108,7 @@ trans_not_found: * 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); + return run_top_route(onreply_rt.rlist[goto_on_sl_reply], p_msg, 0); } else { /* let the core forward the reply */ return 1; diff --git a/modules/tm/t_suspend.c b/modules/tm/t_suspend.c index 2a0cb05..f05e7eb 100644 --- a/modules/tm/t_suspend.c +++ b/modules/tm/t_suspend.c @@ -161,7 +161,7 @@ int t_continue(unsigned int hash_index, unsigned int label, * of failure route (Miklos) */ if (exec_pre_script_cb(&faked_req, FAILURE_CB_TYPE)>0) { - if (run_top_route(route, &faked_req)<0) + if (run_top_route(route, &faked_req, 0)<0) LOG(L_ERR, "ERROR: t_continue: Error in run_top_route\n"); exec_post_script_cb(&faked_req, FAILURE_CB_TYPE); } diff --git a/modules_k/cpl-c/cpl_sig.c b/modules_k/cpl-c/cpl_sig.c index eaf3be7..d77c1fc 100644 --- a/modules_k/cpl-c/cpl_sig.c +++ b/modules_k/cpl-c/cpl_sig.c @@ -102,7 +102,7 @@ int cpl_proxy_to_loc_set( struct sip_msg *msg, struct location **locs, /* run what proxy route is set */ if (cpl_env.proxy_route) { /* do not alter route type - it might be REQUEST or FAILURE */ - run_top_route( main_rt.rlist[cpl_env.proxy_route], msg); + run_top_route( main_rt.rlist[cpl_env.proxy_route], msg, 0); }
/* do t_forward */ diff --git a/modules_k/dialog/dlg_handlers.c b/modules_k/dialog/dlg_handlers.c index 9fb0be5..491a1f1 100644 --- a/modules_k/dialog/dlg_handlers.c +++ b/modules_k/dialog/dlg_handlers.c @@ -973,7 +973,7 @@ void dlg_ontimeout( struct dlg_tl *tl) { LM_DBG("executing route %d on timeout\n", dlg->toroute); set_route_type(REQUEST_ROUTE); - run_top_route(main_rt.rlist[dlg->toroute], fmsg); + run_top_route(main_rt.rlist[dlg->toroute], fmsg, 0); exec_post_script_cb(fmsg, REQUEST_CB_TYPE); } } diff --git a/modules_k/drouting/drouting.c b/modules_k/drouting/drouting.c index 7120338..80284dc 100644 --- a/modules_k/drouting/drouting.c +++ b/modules_k/drouting/drouting.c @@ -619,7 +619,7 @@ static int use_next_gw(struct sip_msg* msg)
if (!avp) return -1;
- if (rewrite_ruri(msg, &val)==-1) { + if (rewrite_ruri(msg, val.s.s)==-1) { LM_ERR("failed to rewite RURI\n"); return -1; } @@ -732,7 +732,7 @@ again: }
if (rt_info->route_idx>0 && rt_info->route_idx<RT_NO) { - ret = run_top_route(main_rt.rlist[rt_info->route_idx], msg ); + ret = run_top_route(main_rt.rlist[rt_info->route_idx], msg, 0); if (ret<1) { /* drop the action */ LM_DBG("script route %d drops routing " diff --git a/modules_k/htable/htable.c b/modules_k/htable/htable.c index 2f75738..648ab09 100644 --- a/modules_k/htable/htable.c +++ b/modules_k/htable/htable.c @@ -184,7 +184,7 @@ static int child_init(int rank) fmsg = faked_msg_next(); rtb = get_route_type(); set_route_type(REQUEST_ROUTE); - run_top_route(event_rt.rlist[rt], fmsg); + run_top_route(event_rt.rlist[rt], fmsg, 0); set_route_type(rtb); }
diff --git a/modules_k/rtimer/rtimer_mod.c b/modules_k/rtimer/rtimer_mod.c index c10e3d6..d0ed96c 100644 --- a/modules_k/rtimer/rtimer_mod.c +++ b/modules_k/rtimer/rtimer_mod.c @@ -191,7 +191,7 @@ void stm_timer_exec(unsigned int ticks, void *param) if (exec_pre_script_cb(&_stm_msg, REQUEST_CB_TYPE)==0 ) continue; /* drop the request */ set_route_type(REQUEST_ROUTE); - run_top_route(main_rt.rlist[rt->route], &_stm_msg); + run_top_route(main_rt.rlist[rt->route], &_stm_msg, 0); exec_post_script_cb(&_stm_msg, REQUEST_CB_TYPE); } } diff --git a/receive.c b/receive.c index d5215bf..1ec9631 100644 --- a/receive.c +++ b/receive.c @@ -172,7 +172,7 @@ 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){ + if (run_top_route(main_rt.rlist[DEFAULT_RT], msg, 0)<0){ LOG(L_WARN, "WARNING: receive_msg: " "error while trying script\n"); goto error_req; @@ -215,7 +215,7 @@ 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(ONREPLY_ROUTE); - ret=run_top_route(onreply_rt.rlist[DEFAULT_RT], msg); + ret=run_top_route(onreply_rt.rlist[DEFAULT_RT], msg, 0); if (ret<0){ LOG(L_WARN, "WARNING: receive_msg: " "error while trying onreply script\n");