loadmodule "/home/ser-0.9.3/modules/sl/sl.so"
loadmodule
"/home/ser-0.9.3/modules/tm/tm.so"
loadmodule
"/home/ser-0.9.3/modules/rr/rr.so"
loadmodule
"/home/ser-0.9.3/modules/maxfwd/maxfwd.so"
loadmodule
"/home/ser-0.9.3/modules/usrloc/usrloc.so"
loadmodule
"/home/ser-0.9.3/modules/textops/textops.so"
loadmodule
"/home/ser-0.9.3/modules/registrar/registrar.so"
loadmodule
"/home/ser-0.9.3/modules/nathelper/nathelper.so"
loadmodule
"/home/ser-0.9.3/modules/uri/uri.so"
# ----------------- setting module-specific parameters
---------------
# -- usrloc params --
modparam("registrar", "nat_flag", 6)
modparam("usrloc",
"db_mode", 0)
modparam("nathelper", "natping_interval", 30) # Ping interval 30
s
modparam("nathelper", "ping_nated_only", 1) # Ping only clients
behind NAT
modparam("nathelper", "rtpproxy_sock",
"/var/run/rtpproxy.sock")
modparam("rr", "enable_full_lr", 1)
# ------------------------- request routing logic
-------------------
route{
#
-----------------------------------------------------------------
# Sanity Check Section
#
-----------------------------------------------------------------
if (!mf_process_maxfwd_header("10"))
{
sl_send_reply("483", "Too Many
Hops");
break;
};
if (msg:len > max_len)
{
sl_send_reply("513", "Message
Overflow");
break;
};
#---------------
if (! search("^Record-Route:"))
{
append_hf("Alex-hint:
NAThelper\r\n");
fix_nated_contact();
if(method
==
"REGISTER")
{
fix_nated_register();
save_noreply("location");
};
if (method == "INVITE")
{
append_hf("Alex-hint: SDP
rewritten\r\n");
force_rtp_proxy();
};
force_rport();
setflag(6);
};
#---------------
#
-----------------------------------------------------------------
# Record Route Section
#
-----------------------------------------------------------------
if(method
!=
"REGISTER")
{
record_route();
};
if (method=="BYE" ||
method=="CANCEL")
{
unforce_rtp_proxy();
}
#
-----------------------------------------------------------------
# Loose Route Section
#
-----------------------------------------------------------------
if (loose_route()) {
if (has_totag() && (method=="INVITE" || method=="ACK"))
{
if (nat_uac_test("19"))
{
setflag(6);
force_rport();
};
force_rtp_proxy("l");
append_hf("Alex-hint:
Loose
Route\r\n");
};
route(1);
break;
};
#
-----------------------------------------------------------------
# Call Type Processing Section
#
-----------------------------------------------------------------
if (uri!=myself)
{
route(1);
break;
};
if (uri==myself) {
if (method=="CANCEL")
{
route(3);
break;
} else if (method=="INVITE")
{
route(3);
break;
} else if (method=="REGISTER")
{
route(2);
break;
} else if (method=="ACK")
{
route(3);
break;
} else if (method=="BYE")
{
route(3);
break;
};
lookup("aliases");
if (uri!=myself)
{
route(1);
break;
};
if
(!lookup("location"))
{
sl_send_reply("404",
"User Not
Found,aaa");
break;
};
};
route(1);
}
route[1] {
#
-----------------------------------------------------------------
# Default Message Handler
#
-----------------------------------------------------------------
t_on_reply("1");
if (!t_relay())
{
if (method=="INVITE" && isflagset(6))
{
unforce_rtp_proxy();
};
sl_reply_error();
};
}
route[2] {
#
-----------------------------------------------------------------
# REGISTER Message Handler
#
----------------------------------------------------------------
if (!search("^Contact:\ +\*")
&& nat_uac_test("19"))
{
setflag(6);
fix_nated_register();
force_rport();
};
sl_send_reply("100",
"Trying");
if(!save("location"))
{
sl_reply_error();
} else append_hf("Alex-hint: save
location\r\n");
}
route[3] {
#
-----------------------------------------------------------------
# CANCEL and INVITE Message
Handler
#
-----------------------------------------------------------------
if (nat_uac_test("19"))
{
setflag(6);
};
if (uri!=myself)
{
route(1);
break;
};
if (method == "INVITE"
&& !lookup("location"))
{
sl_send_reply("404", "User Not Found
haha");
break;
};
if (isflagset(6))
{
force_rport();
fix_nated_contact();
force_rtp_proxy();
};
t_on_reply("1");
if (!t_relay())
{
if(isflagset(6))
{
unforce_rtp_proxy();
}
sl_reply_error();
};
}
onreply_route[1] {
if (isflagset(6) || status=~"(180)|(183)|2[0-9][0-9]")
{
fix_nated_contact();
if
(!search("^Content-Length:\ +0"))
{
force_rtp_proxy();
append_hf("NAT:
1\r\n");
};
};
}