Story of my life, forgot to attach the config.....
Jev wrote:
Hi all,
[snip]
# # $Id: ser.cfg,v 1.21.4.1 2003/11/10 15:35:15 andrei Exp $ # # simple quick-start config script #
# ----------- global configuration parameters ------------------------
debug=9 # debug level (cmd line: -dddddddddd) fork=yes log_stderror=no # (cmd line: -E)
/* Uncomment these lines to enter debugging mode debug=9 fork=no log_stderror=yes */
check_via=no # (cmd. line: -v) dns=no # (cmd. line: -r) rev_dns=no # (cmd. line: -R) port=5060 #children=4 fifo="/tmp/ser_fifo"
sip_warning=yes
# ------------------ module loading ----------------------------------
# Uncomment this if you want to use SQL database loadmodule "/usr/local/lib/ser/modules/mysql.so"
loadmodule "/usr/local/lib/ser/modules/sl.so" loadmodule "/usr/local/lib/ser/modules/tm.so" loadmodule "/usr/local/lib/ser/modules/rr.so" loadmodule "/usr/local/lib/ser/modules/maxfwd.so" loadmodule "/usr/local/lib/ser/modules/usrloc.so" loadmodule "/usr/local/lib/ser/modules/registrar.so" loadmodule "/usr/local/lib/ser/modules/textops.so" loadmodule "/usr/local/lib/ser/modules/domain.so" loadmodule "/usr/local/lib/ser/modules/xlog.so" loadmodule "/usr/local/lib/ser/modules/mediaproxy.so"
# Uncomment this if you want digest authentication # mysql.so must be loaded ! loadmodule "/usr/local/lib/ser/modules/auth.so" loadmodule "/usr/local/lib/ser/modules/auth_db.so"
# ----------------- setting module-specific parameters ---------------
# -- usrloc params --
#modparam("usrloc", "db_mode", 0)
# Uncomment this if you want to use SQL database # for persistent storage and comment the previous line modparam("usrloc", "db_mode", 2)
# -- auth params -- # Uncomment if you are using auth module # modparam("auth_db", "calculate_ha1", yes) # # If you set "calculate_ha1" parameter to yes (which true in this config), # uncomment also the following parameter) # modparam("auth_db", "password_column", "password")
# -- rr params -- # add value to ;lr param to make some broken UAs happy modparam("rr", "enable_full_lr", 1)
modparam("registrar", "nat_flag", 6) #modparam("mediaproxy", "natping_interval", 4) # Ping interval 30 s modparam("mediaproxy", "natping_interval", 60) # Ping interval 30 s
# ------------------------- request routing logic -------------------
# main routing logic
route{
log(1, "-------------------------------------------\n"); log(1, "entering main loop\n");
if (client_nat_test("2")) { log(1, "src address different than via header->NAT detected\n"); log(1, "force_rport and fix_contact and setflag(5)\n"); #try NAT traversal, works only if the client is symmetrical force_rport(); fix_contact(); append_hf("P-hint: fixed NAT contact for request\r\n"); # flag 5 indicates that incoming request is from NATed client setflag(5); };
xlog("L_ERR", "[%rm] from [%fu] to [%tu]");
# 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 ) { sl_send_reply("513", "Message too big"); break; };
# we record-route all messages -- to make sure that # subsequent messages will go through our proxy; that's # particularly good if upstream and downstream entities # use different transport protocol record_route(); # loose-route processing if (loose_route()) { t_relay(); break; };
# 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") { log(1, "analyzing REGISTER request\n"); # Uncomment this if you want to use digest authentication if (!www_authorize("bottom.example.com", "subscriber")) { www_challenge("bottom.example.com", "0"); break; }; if (isflagset(5)) { #register from nated client, save nat_flag=6 #in location table log(1, "REGISTER from nated client\n"); setflag(6); }; if (!save("location")) { log(1, "save location error\n"); sl_reply_error(); }; break;
};
# native SIP destinations are handled using our USRLOC DB if (!lookup("aliases")) { log(1, "lookup(aliases) called\n"); } if (!lookup("location")) { ## Route local Vancouver numbers to the Peer1 Cisco #778, local fido mobile numbers. if (uri=~"^sip:604[0-9]*@.*" || uri=~"^sip:778[0-9]*@.*") { prefix("1"); log(1, "604 or 778 number, uri prefixed with 1\n"); route(2); break; } else if (uri=~"^sip:1[0-9]*@.*") { log(1, "Forwarding to Cisco\n"); route(2); break; }; sl_send_reply("404", "Not Found"); break; }; };
route(1); } route[1]{ log(1, "-------------------------------------------\n"); log(1, "entering route[1] - relaying SIP message\n"); if ((isflagset(5)) || (isflagset(6))) { log(1, "at least one of the participants is NATed->record_route\n"); record_route(); log(1, " -->setting up reply processing ->onreply_route[1]"); t_on_reply("1"); if (method=="INVITE") { log(1, " INVITE request-->use_media_proxy, set NATED-INVITE flag(7)"); use_media_proxy(); append_hf("P-hint: request forced to mediaproxy\r\n"); setflag(7); }; };
log(1, "relaying message ...\n"); if (!t_relay()) { log(1, "t_relay error occured\n"); sl_reply_error(); }; }
route[2]{ if ((isflagset(5)) || (isflagset(6))) { log(1, "at least one of the participants is NATed->record_route\n"); record_route(); log(1, " -->setting up reply processing ->onreply_route[2]"); t_on_reply("1"); if (method=="INVITE") { log(1, " INVITE request-->use_media_proxy, set NATED-INVITE flag(7)"); use_media_proxy(); append_hf("P-hint: request forced to mediaproxy\r\n"); setflag(7); }; };
log(1, "Forwarding to Cisco\n"); rewritehostport("127.0.0.1:5060"); if(!t_relay()){ log(1, "Relay to Cisco failed"); break; }; } #all incoming replies for t_onrepli-ed transactions enter here onreply_route[1] { log(1, "-------------------------------------------\n"); log(1, "onreply_route[1] entered\n");
if (isflagset(6)) { log(1, "transaction was sent to a NATED client -> fix nated contact\n"); fix_contact(); append_hf("P-hint: fixed NAT contact for response\r\n"); }
if ( (status=~"100") ) { log(1, "status 100 received\n"); };
if ( (status=~"180") ) { log(1, "status 180 received\n"); };
if ( (status=~"202") ) { log(1, "status 202 received\n"); };
if ( (status=~"200" || status=~"183") ) { log(1, "status 2xx or 183"); if ( isflagset(7) ) { log(1, "marked(7) as NATED-INVITE -> use_media_proxy \n"); use_media_proxy(); append_hf("P-hint: response forced to mediaproxy\r\n"); }; }; } onreply_route[2] { log(1, "-------------------------------------------\n"); log(1, "onreply_route[2] entered\n");
if (isflagset(6)) { log(1, "transaction was sent to a NATED client -> fix nated contact\n"); fix_contact(); append_hf("P-hint: fixed NAT contact for response\r\n"); }
if ( (status=~"100") ) { log(1, "status 100 received\n"); };
if ( (status=~"180") ) { log(1, "status 180 received\n"); };
if ( (status=~"202") ) { log(1, "status 202 received\n"); };
if ( (status=~"200" || status=~"183") ) { log(1, "status 2xx or 183"); if ( isflagset(7) ) { log(1, "marked(7) as NATED-INVITE -> use_media_proxy \n"); use_media_proxy(); append_hf("P-hint: response forced to mediaproxy\r\n"); }; }; }