# ----------- global configuration parameters ------------------------ debug=7 # debug level (cmd line: -dddddddddd) fork=yes log_stderror=no ### (cmd line: -E) /* Uncomment these lines to enter debugging mode 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_db_url="mysql://ser:heslo@localhost/ser" fifo="/tmp/ser_fifo" # ------------------ module loading ---------------------------------- loadmodule "/usr/local/lib/ser/modules/mysql.so" loadmodule "/usr/local/lib/ser/modules/exec.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/acc.so" loadmodule "/usr/local/lib/ser/modules/auth.so" loadmodule "/usr/local/lib/ser/modules/auth_db.so" loadmodule "/usr/local/lib/ser/modules/nathelper.so" loadmodule "/usr/local/lib/ser/modules/avp.so" # ----------------- setting module-specific parameters --------------- modparam("usrloc", "db_mode", 2) modparam("usrloc", "db_url", "mysql://ser:heslo@localhost/ser") # -- auth params -- modparam("auth_db", "db_url", "mysql://ser:heslo@localhost/ser") modparam("auth_db", "calculate_ha1", yes) modparam("auth_db", "password_column", "password") # -- rr params -- modparam("rr", "enable_full_lr", 1) # -- acc params -- modparam("acc", "log_level", 2 ) modparam("acc", "db_flag", 2 ) #modparam("acc", "db_missed_flag", 3) modparam("acc", "db_url", "mysql://ser:heslo@localhost/ser") # !! Nathelper modparam("registrar", "nat_flag", 6) modparam("nathelper", "natping_interval", 30) # Ping interval 30 s modparam("nathelper", "ping_nated_only", 1) # Ping only clients behind NAT # ------------------------- request routing logic ------------------- # main routing logic route{ 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; }; # !! Nathelper if (nat_uac_test("3")) { if (method == "REGISTER" || ! search("^Record-Route:")) { log("LOG: Someone trying to register from private IP, rewriting\n"); fix_nated_contact(); # Rewrite contact with source IP of signalling if (method == "INVITE") { fix_nated_sdp("1"); # Add direction=active to SDP }; force_rport(); # Add rport parameter to topmost Via setflag(6); # Mark as NATed }; }; if (!method=="REGISTER") record_route(); # path determined by record-routing if (loose_route()) { # mark routing logic in request append_hf("P-hint: rr-enforced\r\n"); route(1); break; }; if (!uri==myself) { # mark routing logic in request append_hf("P-hint: outbound\r\n"); route(1); break; }; if (uri==myself) { if (method=="REGISTER") { # Uncomment this if you want to use digest authentication if (!www_authorize("", "subscriber")) { www_challenge("", "1"); sl_send_reply("404", "www_authorize,401 Unauthorized"); break; }; save("location"); break; }; lookup("aliases"); if (!uri==myself) { append_hf("P-hint: outbound alias\r\n"); route(1); break; }; if (method=="INVITE") { if (!www_authorize("", "subscriber")) { www_challenge("", "1"); break; }; if (lookup("location")) { route(1); break; }; if(uri=~"^sip:09[0-9]+@*"){ prefix("123"); rewritehostport("192.168.1.1:5060"); setflag(2); # Set Accounting Flag t_relay(); break; } if (!lookup("location")) { sl_send_reply("202", "User is not online"); #================================Redirect to SEMS================================== # select messages to redirect: if ( method=="ACK" || method=="INVITE" || method=="BYE" || method=="CANCEL" ){ # switch to stateful mode: if (!t_newtran()){ sl_send_reply("500","could not create transaction"); break; }; # prevent timeout on the other side: t_reply("100","Trying - just wait a minute !"); # actively absorb ACKs if (method == "ACK") { t_relay(); break; } if (method=="INVITE"){ # redirect the call to the 'conference' plug-in # if the URI begin with 100 if (uri=~"sip:100.*@") { # assumes that Sems configuration parameter 'socket_name=' # has been set to /tmp/am_sock if(!t_write_req("/tmp/am_fifo","conference")) { t_reply("500","error contacting sems"); }; break; }; # redirect the call to the 'announcement' plug-in # if the URI begin with 200 if (uri=~"sip:200.*@") { if(!t_write_req("/tmp/am_fifo","announcement")) { t_reply("500","error contacting sems"); }; break; }; # no service number, redirect to voicemail. # do not forget to load AVPs so that voicemail gets the # callee's email address. #load_avp("ruri","email",0); if(!t_write_req("/tmp/am_fifo","voicemail")) { t_reply("500","error contacting sems"); }; break; } else if (method=="BYE" || method=="CANCEL") { # Sems should already know which plug-in is handling that # call. "bye" is no plug-in name. It is a reserved name which # tells Sems to terminate the call. if(!t_write_req("/tmp/am_fifo","bye")) { t_reply("500","error contacting sems"); }; }; }; #=================================================================================== #send_reply("404", "Not Found"); break; }; # append_hf("P-hint: usrloc applied\r\n"); # route(1); }; }; } route[1] { # !! Nathelper if (uri=~"[@:](192\.168\.|10\.|172\.(1[6-9]|2[0-9]|3[0-1])\.)" && !search("^Route:")){ sl_send_reply("479", "We don't forward to private IP addresses"); break; }; setflag(2); #Set Accounting Flag # if client or server know to be behind a NAT, enable relay if (isflagset(6)) { force_rtp_proxy(); }; # NAT processing of replies; apply to all transactions (for example, # re-INVITEs from public to private UA are hard to identify as # NATed at the moment of request processing); look at replies t_on_reply("1"); # send it out now; use stateful forwarding as it works reliably # even for UDP2TCP if (!t_relay()) { sl_reply_error(); }; } # !! Nathelper onreply_route[1] { # NATed transaction ? if (isflagset(6) && status =~ "(183)|2[0-9][0-9]") { fix_nated_contact(); force_rtp_proxy(); # otherwise, is it a transaction behind a NAT and we did not # know at time of request processing ? (RFC1918 contacts) } else if (nat_uac_test("1")) { fix_nated_contact(); }; }