# # $Id: ser.cfg,v 1.25.2.1 2005/02/18 14:30:44 andrei Exp $ # # # # ----------- global configuration parameters ------------------------ debug=3 # 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) listen=65.208.39.215 port=5060 alias=65.208.39.215 alias=sip.telereunion.com.mx children=4 fifo_mode=0666 fifo="/tmp/ser_fifo" fifo_db_url="mysql://ser:heslo@localhost/ser" # ------------------ 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/uri.so" loadmodule "/usr/local/lib/ser/modules/uri_db.so" loadmodule "/usr/local/lib/ser/modules/group.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/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) modparam("domain", "db_mode", 1) modparam("auth_db|usrloc|domain|group", "db_url", "mysql://ser:heslo@localhost/ser") modparam("group", "use_domain", 0) # -- 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("mediaproxy", "natping_interval", 60) modparam("registrar", "nat_flag", 2) # ------------------------- request routing logic ------------------- # main routing logic route{ # initial sanity checks -- messages with # max_forwards==0, or excessively long requests if (!mf_process_maxfwd_header("10")) { if (method!="ACK") { sl_send_reply("483","Too Many Hops"); }; break; }; if (msg:len >= 2048 ) { if (method!="ACK") { 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 if (!method=="REGISTER") record_route(); if (method=="REGISTER") { if (uri==myself || is_from_local()) { # Mark as NAT'ed if (client_nat_test("3")) { setflag(2); force_rport(); fix_contact(); }; if (!www_authorize("", "subscriber")) { www_challenge("", "0"); break; } else if (!check_to()) { sl_send_reply("403", "Username!=To not allowed"); break; }; if (!save("location")) { sl_reply_error(); }; } else { append_hf("P-hint: outbound alias\r\n"); sl_send_reply("403", "This domain is not served here"); }; break; }; if (method=="INVITE") { if (!(is_from_local() || uri==myself || 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(); }; # subsequent messages withing a dialog should take the # path determined by record-routing if (loose_route()) { append_hf("P-hint: rr-enforced\r\n"); # The following lines are added due media proxy if (method=="INVITE" || method=="ACK") { use_media_proxy(); }; # end media session for BYE and CANCEL is done above # before entering the loose route. no need to call it here t_relay(); break; }; if (client_nat_test("3") && !search("^Record-Route:")) { # Mark as NAT'ed force_rport(); fix_contact(); }; ### Begin PSTN evaluation if (method=="INVITE") { if (uri=~"sip:01[1-9][0-9]+@.*") { if (!is_user_in("From", "ld")) { sl_send_reply("403", "LD permissions needed"); break; }; rewritehostport("65.208.39.219:5060"); } else if (uri=~"sip:00[1-9][0-9]+@.*") { if (!is_user_in("From", "int")) { sl_send_reply("403", "International permissions needed"); break; }; rewritehost("65.208.39.219"); }; t_on_reply("1"); }; ### End PSTN evaluation if (is_uri_host_local() || uri==myself) { # join with next if? # native SIP destinations are handled using our USRLOC DB if (!lookup("location")) { sl_send_reply("404", "User not found"); break; }; }; if (method=="INVITE" || method=="ACK") { use_media_proxy(); }; if (!uri==myself) { # mark routing logic in request append_hf("P-hint: outbound\r\n"); }; # forward to current uri now; use stateful forwarding; that # works reliably even if we forward from TCP to UDP 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=~"(180)|(183)|(2[0-9][0-9])") { if (client_nat_test("1")) { fix_contact(); }; use_media_proxy(); }; }