Browse code

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 authored on 09/07/2009 09:23:14
Showing 11 changed files
... ...
@@ -1292,11 +1292,13 @@ error:
1292 1292
 }
1293 1293
 
1294 1294
 
1295
-int run_top_route(struct action* a, sip_msg_t* msg)
1295
+int run_top_route(struct action* a, sip_msg_t* msg, struct run_act_ctx *c)
1296 1296
 {
1297 1297
 	struct run_act_ctx ctx;
1298
+	struct run_act_ctx *p;
1299
+	p = (c)?c:&ctx;
1298 1300
 	setsflagsval(0);
1299 1301
 	reset_static_buffer();
1300
-	init_run_actions_ctx(&ctx);
1301
-	return run_actions(&ctx, a, msg);
1302
+	init_run_actions_ctx(p);
1303
+	return run_actions(p, a, msg);
1302 1304
 }
... ...
@@ -59,6 +59,6 @@ struct run_act_ctx{
59 59
 int do_action(struct run_act_ctx* c, struct action* a, struct sip_msg* msg);
60 60
 int run_actions(struct run_act_ctx* c, struct action* a, struct sip_msg* msg);
61 61
 
62
-int run_top_route(struct action* a, sip_msg_t* msg);
62
+int run_top_route(struct action* a, sip_msg_t* msg, struct run_act_ctx* c);
63 63
 
64 64
 #endif
... ...
@@ -196,7 +196,7 @@ static char *print_uac_request( struct cell *t, struct sip_msg *i_req,
196 196
 		set_route_type(BRANCH_ROUTE);
197 197
 		tm_ctx_set_branch_index(branch+1);
198 198
 		if (exec_pre_script_cb(i_req, BRANCH_CB_TYPE)>0) {
199
-			if (run_top_route(branch_rt.rlist[branch_route], i_req) < 0) {
199
+			if (run_top_route(branch_rt.rlist[branch_route], i_req, 0) < 0) {
200 200
 				LOG(L_ERR, "ERROR: print_uac_request: Error in run_top_route\n");
201 201
 			}
202 202
 			exec_post_script_cb(i_req, BRANCH_CB_TYPE);
... ...
@@ -868,7 +868,7 @@ int run_failure_handlers(struct cell *t, struct sip_msg *rpl,
868 868
 		t->on_negative=0;
869 869
 		if (exec_pre_script_cb(&faked_req, FAILURE_CB_TYPE)>0) {
870 870
 			/* run a reply_route action if some was marked */
871
-			if (run_top_route(failure_rt.rlist[on_failure], &faked_req)<0)
871
+			if (run_top_route(failure_rt.rlist[on_failure], &faked_req, 0)<0)
872 872
 				LOG(L_ERR, "ERROR: run_failure_handlers: Error in run_top_route\n");
873 873
 			exec_post_script_cb(&faked_req, FAILURE_CB_TYPE);
874 874
 		}
... ...
@@ -1976,7 +1976,7 @@ int reply_received( struct sip_msg  *p_msg )
1976 1976
 		/* Pre- and post-script callbacks have already
1977 1977
 		 * been execueted by the core. (Miklos)
1978 1978
 		 */
1979
-		if (run_top_route(onreply_rt.rlist[t->on_reply], p_msg)<0)
1979
+		if (run_top_route(onreply_rt.rlist[t->on_reply], p_msg, 0)<0)
1980 1980
 			LOG(L_ERR, "ERROR: on_reply processing failed\n");
1981 1981
 		/* transfer current message context back to t */
1982 1982
 		if (t->uas.request) t->uas.request->flags=p_msg->flags;
... ...
@@ -2108,7 +2108,7 @@ trans_not_found:
2108 2108
 		 * Pre- and post-script callbacks have already
2109 2109
 		 * been execueted by the core. (Miklos)
2110 2110
 		 */
2111
-		return run_top_route(onreply_rt.rlist[goto_on_sl_reply], p_msg);
2111
+		return run_top_route(onreply_rt.rlist[goto_on_sl_reply], p_msg, 0);
2112 2112
 	} else {
2113 2113
 		/* let the core forward the reply */
2114 2114
 		return 1;
... ...
@@ -161,7 +161,7 @@ int t_continue(unsigned int hash_index, unsigned int label,
161 161
 	 * of failure route (Miklos)
162 162
 	 */
163 163
 	if (exec_pre_script_cb(&faked_req, FAILURE_CB_TYPE)>0) {
164
-		if (run_top_route(route, &faked_req)<0)
164
+		if (run_top_route(route, &faked_req, 0)<0)
165 165
 			LOG(L_ERR, "ERROR: t_continue: Error in run_top_route\n");
166 166
 		exec_post_script_cb(&faked_req, FAILURE_CB_TYPE);
167 167
 	}
... ...
@@ -102,7 +102,7 @@ int cpl_proxy_to_loc_set( struct sip_msg *msg, struct location **locs,
102 102
 	/* run what proxy route is set */
103 103
 	if (cpl_env.proxy_route) {
104 104
 		/* do not alter route type - it might be REQUEST or FAILURE */
105
-		run_top_route( main_rt.rlist[cpl_env.proxy_route], msg);
105
+		run_top_route( main_rt.rlist[cpl_env.proxy_route], msg, 0);
106 106
 	}
107 107
 
108 108
 	/* do t_forward */
... ...
@@ -973,7 +973,7 @@ void dlg_ontimeout( struct dlg_tl *tl)
973 973
 		{
974 974
 			LM_DBG("executing route %d on timeout\n", dlg->toroute);
975 975
 			set_route_type(REQUEST_ROUTE);
976
-			run_top_route(main_rt.rlist[dlg->toroute], fmsg);
976
+			run_top_route(main_rt.rlist[dlg->toroute], fmsg, 0);
977 977
 			exec_post_script_cb(fmsg, REQUEST_CB_TYPE);
978 978
 		}
979 979
 	}
... ...
@@ -619,7 +619,7 @@ static int use_next_gw(struct sip_msg* msg)
619 619
 
620 620
 	if (!avp) return -1;
621 621
 
622
-	if (rewrite_ruri(msg, &val)==-1) {
622
+	if (rewrite_ruri(msg, val.s.s)==-1) {
623 623
 		LM_ERR("failed to rewite RURI\n");
624 624
 		return -1;
625 625
 	}
... ...
@@ -732,7 +732,7 @@ again:
732 732
 	}
733 733
 
734 734
 	if (rt_info->route_idx>0 && rt_info->route_idx<RT_NO) {
735
-		ret = run_top_route(main_rt.rlist[rt_info->route_idx], msg );
735
+		ret = run_top_route(main_rt.rlist[rt_info->route_idx], msg, 0);
736 736
 		if (ret<1) {
737 737
 			/* drop the action */
738 738
 			LM_DBG("script route %d drops routing "
... ...
@@ -184,7 +184,7 @@ static int child_init(int rank)
184 184
 		fmsg = faked_msg_next();
185 185
 		rtb = get_route_type();
186 186
 		set_route_type(REQUEST_ROUTE);
187
-		run_top_route(event_rt.rlist[rt], fmsg);
187
+		run_top_route(event_rt.rlist[rt], fmsg, 0);
188 188
 		set_route_type(rtb);
189 189
 	}
190 190
 
... ...
@@ -191,7 +191,7 @@ void stm_timer_exec(unsigned int ticks, void *param)
191 191
 		if (exec_pre_script_cb(&_stm_msg, REQUEST_CB_TYPE)==0 )
192 192
 			continue; /* drop the request */
193 193
 		set_route_type(REQUEST_ROUTE);
194
-		run_top_route(main_rt.rlist[rt->route], &_stm_msg);
194
+		run_top_route(main_rt.rlist[rt->route], &_stm_msg, 0);
195 195
 		exec_post_script_cb(&_stm_msg, REQUEST_CB_TYPE);
196 196
 	}
197 197
 }
... ...
@@ -172,7 +172,7 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
172 172
 
173 173
 		set_route_type(REQUEST_ROUTE);
174 174
 		/* exec the routing script */
175
-		if (run_top_route(main_rt.rlist[DEFAULT_RT], msg)<0){
175
+		if (run_top_route(main_rt.rlist[DEFAULT_RT], msg, 0)<0){
176 176
 			LOG(L_WARN, "WARNING: receive_msg: "
177 177
 					"error while trying script\n");
178 178
 			goto error_req;
... ...
@@ -215,7 +215,7 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
215 215
 		/* exec the onreply routing script */
216 216
 		if (onreply_rt.rlist[DEFAULT_RT]){
217 217
 			set_route_type(ONREPLY_ROUTE);
218
-			ret=run_top_route(onreply_rt.rlist[DEFAULT_RT], msg);
218
+			ret=run_top_route(onreply_rt.rlist[DEFAULT_RT], msg, 0);
219 219
 			if (ret<0){
220 220
 				LOG(L_WARN, "WARNING: receive_msg: "
221 221
 						"error while trying onreply script\n");