https://www.opensips.org/Documentation/Script-Routes-2-3
route { if(is_method("OPTIONS")) { # send reply for each options request sl_send_reply("200", "ok"); exit(); } route(1); } route[1] { # forward according to uri forward(); }
route { lookup("location"); t_on_branch("1"); if(!t_relay()) { sl_send_reply("500", "relaying failed"); } } branch_route[1] { if(uri=~"10\.10\.10\.10") { # discard branches that go to 10.10.10.10 drop(); } }route { lookup("location"); t_on_failure("1"); if(!t_relay()) { sl_send_reply("500", "relaying failed"); } } failure_route[1] { if(is_method("INVITE")) { # call failed - relay to voice mail t_relay("udp:voicemail.server.com:5060"); } }route { seturi("sip:bob@opensips.org"); # first branch append_branch("sip:alice@opensips.org"); # second branch t_on_reply("global"); # the "global" reply route # is set the whole transaction t_on_branch("1"); t_relay(); } branch_route[1] { if ($rU=="alice") t_on_reply("alice"); # the "alice" reply route # is set only for second branch } onreply_route { xlog("OpenSIPS received a reply from $si\n"); } onreply_route[alice] { xlog("received reply on the branch from alice\n"); } onreply_route[global] { if (t_check_status("1[0-9][0-9]")) { setflag(1); log("provisional reply received\n"); if (t_check_status("183")) drop; } }error_route { xlog("--- error route class=$(err.class) level=$(err.level) info=$(err.info) rcode=$(err.rcode) rreason=$(err.rreason) ---\n"); xlog("--- error from [$si:$sp]\n+++++\n$mb\n++++\n"); sl_send_reply("$err.rcode", "$err.rreason"); exit; }local_route { if (is_method("INVITE") && $ru=~"@foreign.com") { append_hf("P-hint: foreign request\r\n"); exit; } if (is_method("BYE") ) { acc_log_request("internally generated BYE"); } }startup_route { avp_db_query("select gwlist where ruleid==1",$avp(i:100)); cache_store("local", "rule1", "$avp(i:100)"); }timer_route[gw_update, 300] { avp_db_query("select gwlist where ruleid==1",$avp(i:100)); $shv(i:100) =$avp(i:100); }event_route[E_PIKE_BLOCKED] { xlog("The E_PIKE_BLOCKED event was raised\n"); }event_route[E_PIKE_BLOCKED, async] { xlog("The E_PIKE_BLOCKED event was raised\n"); }