Browse Source

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
Daniel-Constantin Mierla 16 years ago
parent
commit
4ce1715db7

+ 5 - 3
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 ctx;
+	struct run_act_ctx *p;
+	p = (c)?c:&ctx;
 	setsflagsval(0);
 	setsflagsval(0);
 	reset_static_buffer();
 	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);
 }
 }

+ 1 - 1
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 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_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
 #endif

+ 1 - 1
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);
 		set_route_type(BRANCH_ROUTE);
 		tm_ctx_set_branch_index(branch+1);
 		tm_ctx_set_branch_index(branch+1);
 		if (exec_pre_script_cb(i_req, BRANCH_CB_TYPE)>0) {
 		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");
 				LOG(L_ERR, "ERROR: print_uac_request: Error in run_top_route\n");
 			}
 			}
 			exec_post_script_cb(i_req, BRANCH_CB_TYPE);
 			exec_post_script_cb(i_req, BRANCH_CB_TYPE);

+ 3 - 3
modules/tm/t_reply.c

@@ -868,7 +868,7 @@ int run_failure_handlers(struct cell *t, struct sip_msg *rpl,
 		t->on_negative=0;
 		t->on_negative=0;
 		if (exec_pre_script_cb(&faked_req, FAILURE_CB_TYPE)>0) {
 		if (exec_pre_script_cb(&faked_req, FAILURE_CB_TYPE)>0) {
 			/* run a reply_route action if some was marked */
 			/* 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");
 				LOG(L_ERR, "ERROR: run_failure_handlers: Error in run_top_route\n");
 			exec_post_script_cb(&faked_req, FAILURE_CB_TYPE);
 			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
 		/* Pre- and post-script callbacks have already
 		 * been execueted by the core. (Miklos)
 		 * 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");
 			LOG(L_ERR, "ERROR: on_reply processing failed\n");
 		/* transfer current message context back to t */
 		/* transfer current message context back to t */
 		if (t->uas.request) t->uas.request->flags=p_msg->flags;
 		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
 		 * Pre- and post-script callbacks have already
 		 * been execueted by the core. (Miklos)
 		 * 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 {
 	} else {
 		/* let the core forward the reply */
 		/* let the core forward the reply */
 		return 1;
 		return 1;

+ 1 - 1
modules/tm/t_suspend.c

@@ -161,7 +161,7 @@ int t_continue(unsigned int hash_index, unsigned int label,
 	 * of failure route (Miklos)
 	 * of failure route (Miklos)
 	 */
 	 */
 	if (exec_pre_script_cb(&faked_req, FAILURE_CB_TYPE)>0) {
 	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");
 			LOG(L_ERR, "ERROR: t_continue: Error in run_top_route\n");
 		exec_post_script_cb(&faked_req, FAILURE_CB_TYPE);
 		exec_post_script_cb(&faked_req, FAILURE_CB_TYPE);
 	}
 	}

+ 1 - 1
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 */
 	/* run what proxy route is set */
 	if (cpl_env.proxy_route) {
 	if (cpl_env.proxy_route) {
 		/* do not alter route type - it might be REQUEST or FAILURE */
 		/* 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 */
 	/* do t_forward */

+ 1 - 1
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);
 			LM_DBG("executing route %d on timeout\n", dlg->toroute);
 			set_route_type(REQUEST_ROUTE);
 			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);
 			exec_post_script_cb(fmsg, REQUEST_CB_TYPE);
 		}
 		}
 	}
 	}

+ 2 - 2
modules_k/drouting/drouting.c

@@ -619,7 +619,7 @@ static int use_next_gw(struct sip_msg* msg)
 
 
 	if (!avp) return -1;
 	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");
 		LM_ERR("failed to rewite RURI\n");
 		return -1;
 		return -1;
 	}
 	}
@@ -732,7 +732,7 @@ again:
 	}
 	}
 
 
 	if (rt_info->route_idx>0 && rt_info->route_idx<RT_NO) {
 	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) {
 		if (ret<1) {
 			/* drop the action */
 			/* drop the action */
 			LM_DBG("script route %d drops routing "
 			LM_DBG("script route %d drops routing "

+ 1 - 1
modules_k/htable/htable.c

@@ -184,7 +184,7 @@ static int child_init(int rank)
 		fmsg = faked_msg_next();
 		fmsg = faked_msg_next();
 		rtb = get_route_type();
 		rtb = get_route_type();
 		set_route_type(REQUEST_ROUTE);
 		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);
 		set_route_type(rtb);
 	}
 	}
 
 

+ 1 - 1
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 )
 		if (exec_pre_script_cb(&_stm_msg, REQUEST_CB_TYPE)==0 )
 			continue; /* drop the request */
 			continue; /* drop the request */
 		set_route_type(REQUEST_ROUTE);
 		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);
 		exec_post_script_cb(&_stm_msg, REQUEST_CB_TYPE);
 	}
 	}
 }
 }

+ 2 - 2
receive.c

@@ -172,7 +172,7 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
 
 
 		set_route_type(REQUEST_ROUTE);
 		set_route_type(REQUEST_ROUTE);
 		/* exec the routing script */
 		/* 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: "
 			LOG(L_WARN, "WARNING: receive_msg: "
 					"error while trying script\n");
 					"error while trying script\n");
 			goto error_req;
 			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 */
 		/* exec the onreply routing script */
 		if (onreply_rt.rlist[DEFAULT_RT]){
 		if (onreply_rt.rlist[DEFAULT_RT]){
 			set_route_type(ONREPLY_ROUTE);
 			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){
 			if (ret<0){
 				LOG(L_WARN, "WARNING: receive_msg: "
 				LOG(L_WARN, "WARNING: receive_msg: "
 						"error while trying onreply script\n");
 						"error while trying onreply script\n");