route{
# initial sanity checks -- messages with
# max_forwards==0, or excessively long requests
if (!mf_process_maxfwd_header("10")) {
sl_send_reply("483","Too Many Hops");
break;
};
if ( msg:len > max_len ) {
if( method!="ACK") {
sl_send_reply("513", "Message too big");
};
break;
};
if (method=="REGISTER"||!search("^Record-Route:")) {
if (is_from_local()) {
# Mark as NAT'ed
log("LOG: Someone trying to register from private IOP, rewriting
\n");
if (client_nat_test("3")) {
setflag(2);
force_rport();
fix_contact();
};
};
};
if(method=="REGISTER")
{
save("location");
break;
};
lookup("aliases");
#if(method=="INVITE")
#{
#if(!(is_from_local()||is_uri_host_local()))
#{
# sl_send_reply("403","Relaying is forbidden");
# break;
#};
#t_on_failure("1");
#}
#else if(method=="BYE"||method=="CANCEL")
#{
# end_media_session();
#};
if( loose_route())
{
if(method=="INVITE"||method=="ACK")
{
use_media_proxy();
};
t_relay();
break;
};
if (method == "INVITE") {
record_route();
};
if (client_nat_test("3") && !search("^Record-Route:")) {
# Mark as NAT'ed
force_rport();
fix_contact();
};
if (method=="INVITE") {
t_on_reply("1");
};
if (is_uri_host_local()) {
if (!lookup("location")) {
sl_send_reply("404", "User not found");
break;
};
};
if (method=="INVITE" || method=="ACK") {
use_media_proxy();
};
if (!t_relay()) {
if (method=="INVITE" || method=="ACK") {
end_media_session();
};
sl_reply_error();
};
}
failure_route[1] {
end_media_session();
}
onreply_route[1] {
if (status=~"(183)|(2[0-9][0-9])") {
if (client_nat_test("1")) {
fix_contact();
};
use_media_proxy();
};
}