# -- nat ping --
modparam("mediaproxy", "natping_interval", 10)
modparam("mediaproxy", "mediaproxy_socket", "/var/run/mediaproxy.sock")
# ------------------------- request routing logic -------------------
# main routing logic
record_route();
# loose-route processing
if (loose_route()) {
t_relay();
break;
};
# -- nat code --
if (method == "BYE" || method == "CANCEL") {
end_media_session();
};
if (client_nat_test("3")) {
if (method == "REGISTER" || ! search("^Record-Route:")) {
fix_contact();
force_rport();
};
};
if (method=="INVITE") {
use_media_proxy();
t_on_reply("1");
setflag(6);
};
# if the request is for other domain use UsrLoc
# (in case, it does not work, use the following command
# with proper names and addresses in it)
if (uri==myself) {
if (method=="REGISTER") {
save("location");
break;
};
# setflag(1);
# native SIP destinations are handled using our USRLOC DB
if (!lookup("location")) {
log (1, "********************** Rewriting the host:port ***********************************");
rewritehostport ("PSTN Gateway Ip:5060");
};
};
if (method == "INVITE"){
t_relay();
sl_send_reply ("180", "Ringing");
break;
}
if (!t_relay()) {
sl_send_reply("404", "Not Found");
break;
};
# -- nat code ----
}
onreply_route[1] {
if (status=~"(183)|2[0-9][0-9]") {
if (client_nat_test("1")) {
fix_contact();
};
use_media_proxy();
};
if (status=~"[3-4]0[0-9]") {
end_media_session();
break;
};
}