####### Routing Logic ######## route[0] { xlog("L_INFO", "New request - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n"); if(loose_route()) { if(!has_totag()) { xlog("L_INFO", "Initial loose-routing rejected - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n"); sl_send_reply("403", "Initial Loose-Routing Rejected"); exit; } t_on_reply("1"); t_on_failure("1"); } if(!is_method("REGISTER")) { #record_route(); } if(is_method("CANCEL") || is_method("ACK")) { t_on_reply("1"); if(t_check_trans()) { if(!t_relay()) { sl_reply_error(); } } else { xlog("L_INFO", "Dropping mis-routed request - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n"); } exit; } t_check_trans(); if(is_method("REGISTER")) { sl_send_reply("100", "Trying"); if(!save("location")) { xlog("L_ERR", "Register FAIL - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n"); sl_reply_error(); exit; } xlog("L_INFO", "Register OK - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n"); exit; } if(is_method("INVITE")) { $avp(s:dlgtimeout)=5; $avp(s:ringtimeout)=10; setflag(4); sl_send_reply("100", "Trying"); } if(is_method("BYE")) { route(1); } if (!lookup("location")) { switch ($retcode) { case -1: case -3: t_newtran(); t_reply("404", "Not Found"); exit; case -2: sl_send_reply("405", "Method Not Allowed"); exit; } } route(1); } route[1] { if (is_method("INVITE")) { t_on_branch("1"); t_on_reply("1"); t_on_failure("1"); } if (!t_relay()) { sl_reply_error(); }; exit; } branch_route[1] { xlog("L_INFO", "BRANCH - S=$rs R=$ru D=$rr F=$fu T=$tu IP=$si ID=$ci\n"); } onreply_route[1] { xlog("L_INFO", "Reply - S=$rs R=$ru D=$rr F=$fu T=$tu IP=$si ID=$ci\n"); } failure_route[1] { if (t_was_cancelled()) { exit; } }