MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / run_top_route

Function run_top_route

action.c:212–296  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

210}
211
212int run_top_route(struct script_route sr, struct sip_msg* msg)
213{
214 static int recursing;
215
216 int bk_action_flags, route_stack_start_bkp = -1, route_stack_size_bkp;
217 int ret;
218 context_p ctx = NULL;
219 const char *trace_file = NULL;
220 int trace_line = 0;
221
222 bk_action_flags = action_flags;
223
224 action_flags = 0;
225 init_err_info();
226
227 if (current_processing_ctx==NULL) {
228 if ( (ctx=context_alloc(CONTEXT_GLOBAL))==NULL) {
229 LM_ERR("failed to allocated new global context\n");
230 return -1;
231 }
232 memset( ctx, 0, context_size(CONTEXT_GLOBAL));
233 set_global_context(ctx);
234 }
235
236 /* the recursion support allows run_top_route() to be freely called from
237 * other modules (e.g. dialog) in order to provide contextless script
238 * callbacks using routes, without losing the original route stack */
239 if (recursing) {
240 route_stack_start_bkp = route_stack_start;
241 route_stack_size_bkp = route_stack_size;
242 route_stack_start = route_stack_size;
243 route_stack_size += 1;
244 } else {
245 route_stack_start = 0;
246 route_stack_size = 1;
247 recursing = 1;
248 }
249
250 if (route_type & (ERROR_ROUTE|LOCAL_ROUTE|STARTUP_ROUTE) ||
251 (route_type &
252 (REQUEST_ROUTE|ONREPLY_ROUTE) && !strcmp(sr.name, "0")))
253 route_stack[route_stack_start] = NULL;
254 else
255 route_stack[route_stack_start] = sr.name;
256
257 if (profiling_enabled(PROFILING_DATA_TYPE_SCRIPT)) {
258 if (sr.a && sr.a->file) {
259 trace_file = sr.a->file;
260 trace_line = sr.a->line;
261 }
262 profiling_msg_start(msg, route_type, route_stack[route_stack_start],
263 route_stack_size - route_stack_start);
264 profiling_route_enter(msg, route_type, route_stack[route_stack_start],
265 trace_file, trace_line, route_stack_size - route_stack_start);
266 }
267
268 run_actions(sr.a, msg);
269 ret = action_flags;

Callers 15

receive_msgFunction · 0.85
async_launch_resumeFunction · 0.85
async_script_launchFunction · 0.85
run_startup_routeFunction · 0.85
route_timer_fFunction · 0.85
run_msrp_auth_routeFunction · 0.85
run_msrp_socket_routeFunction · 0.85
run_dfks_routeFunction · 0.85
handle_ebr_ipcFunction · 0.85
b2b_prescript_fFunction · 0.85
b2b_tm_cbackFunction · 0.85

Calls 9

init_err_infoFunction · 0.85
context_allocFunction · 0.85
profiling_enabledFunction · 0.85
profiling_msg_startFunction · 0.85
profiling_route_enterFunction · 0.85
run_actionsFunction · 0.85
profiling_route_exitFunction · 0.85
profiling_msg_endFunction · 0.85
context_destroyFunction · 0.85

Tested by

no test coverage detected