# $Id: ser.cfg,v 1.27 2005/03/10 14:16:25 Exp $ # # # ----------- global configuration parameters ------------------------ debug=3 # debug level (cmd line: -dddddddddd) fork=yes log_stderror=no # (cmd line: -E) #memlog=5 # memory debug log level #log_facility=LOG_LOCAL0 # sets the facility used for logging (see syslog(3)) /* 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="/tmp/ser_fifo" fifo_db_url="mysql://ser:heslo@nxs.yi.org/ser" user=root group=ser fifo_user=root # owner of the ser fifo fifo_group=ser fifo_mode=0660 # fifo's permissions #disable_core=yes #disables core dumping #open_fd_limit=1024 # sets the open file descriptors limit #mhomed=yes # usefull for multihomed hosts, small performance penalty #disable_tcp=yes #tcp_accept_aliases=yes # accepts the tcp alias via option (see NEWS) # listen=80.119.10.14 # ------------------ module loading ---------------------------------- loadmodule "/usr/lib/ser/modules/mysql.so" loadmodule "/usr/lib/ser/modules/sl.so" loadmodule "/usr/lib/ser/modules/tm.so" loadmodule "/usr/lib/ser/modules/rr.so" loadmodule "/usr/lib/ser/modules/maxfwd.so" loadmodule "/usr/lib/ser/modules/usrloc.so" loadmodule "/usr/lib/ser/modules/registrar.so" loadmodule "/usr/lib/ser/modules/uri.so" loadmodule "/usr/lib/ser/modules/uri_db.so" loadmodule "/usr/lib/ser/modules/nathelper.so" loadmodule "/usr/lib/ser/modules/auth.so" loadmodule "/usr/lib/ser/modules/auth_db.so" loadmodule "/usr/lib/ser/modules/textops.so" loadmodule "/usr/lib/ser/modules/permissions.so" loadmodule "/usr/lib/ser/modules/domain.so" loadmodule "/usr/lib/ser/modules/group.so" loadmodule "/usr/lib/ser/modules/acc.so" loadmodule "/usr/lib/ser/modules/msilo.so" loadmodule "/usr/lib/ser/modules/avpops.so" # ----------------- setting module-specific parameters --------------- # -- usrloc params-- modparam("usrloc", "db_mode", 2) modparam("usrloc", "use_domain", 1) # -- autdb_params-- modparam("auth_db", "calculate_ha1", yes) modparam("auth_db", "password_column", "password") modparam("auth_db", "use_domain", 1) # -- rr params -- # add value to ;lr param to make some broken UAs happy modparam("rr", "enable_full_lr", 1) # -- nathelper params -- modparam("nathelper", "natping_interval", 30) modparam("nathelper", "ping_nated_only", 1) # -- registrar params -- modparam("registrar", "nat_flag", 7) modparam("registrar", "use_domain", 1) # -- tm params -- modparam("tm", "fr_inv_timer", 15) modparam("tm", "fr_timer", 10) # --domain params -- modparam("domain", "db_url", "mysql://ser:heslo@nxs.yi.org/ser") modparam("domain", "domain_table", "domain") modparam("domain", "db_mode", 1) # Use caching # -- permissions params -- modparam("permissions", "db_url", "mysql://ser:heslo@nxs.yi.org/ser") modparam("permissions", "db_mode", 1) modparam("permissions", "trusted_table", "trusted") modparam("permissions", "default_deny_file", "/etc/ser/permissions.deny") modparam("permissions", "default_allow_file", "/etc/ser/permissions.allow") # -- acc params -- modparam("acc", "db_url", "mysql://ser:heslo@nxs.yi.org/ser") modparam("acc", "radius_config", "/etc/radiusclient-ng/radiusclient.conf") modparam("acc", "log_fmt", "miocfsp") modparam("acc", "failed_transactions", 1) modparam("acc", "db_flag", 2) modparam("acc", "db_missed_flag", 3) modparam("acc", "service_type", 15) modparam("acc", "radius_flag", 4) modparam("acc", "radius_missed_flag", 5) # -- msilo params -- modparam("msilo", "db_url", "mysql://ser:heslo@nxs.yi.org/ser") modparam("msilo", "check_time", 10) # -- avpos params -- modparam("avpops","avp_url","mysql://ser:heslo@nxs.yi.org/ser") modparam("avpops","avp_table","usr_preferences") # ------------------------- 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")) { 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 if (!method=="REGISTER") { record_route(); }; if (method=="CANCEL" || method=="BYE") { unforce_rtp_proxy(); setflag(4); }; # subsequent messages withing a dialog should take the # path determined by record-routing if (loose_route()) { route(9); route(1); break; }; ############################ # Request from our domains # ############################ if (is_uri_host_local() && is_from_local()) { if (method=="CANCEL") { route(3); break; } else if (method=="INVITE") { route(3); break; } else if (method=="REGISTER") { route(2); break; } else if (method=="MESSAGE") { route(7); break; } else if (method=="SUBSCRIBE" || method=="NOTIFY") { route(8); break; }; route(9); route(1); break; }; ############################## # Requests to others domains # ############################## if (!is_uri_host_local() && is_from_local()) { # Checking Authorization if (!proxy_authorize("","subscriber")) { proxy_challenge("","0"); sl_send_reply("407", "Proxy Authentication Required"); break; }; if (method=="MESSAGE") { route(1); break; }; # mark routing logic in request append_hf("P-hint: outbound\r\n"); route(9); route(1); break; }; ########################## # Requests to my domains # ########################## if (is_uri_host_local() && !is_from_local()) { if (method=="INVITE") { route(3); break; } else if (method=="MESSAGE") { route(7); break; } else if (method=="SUBSCRIBE" || method=="NOTIFY") { route(8); break; }; route(1); break; }; route(1); break; } route[1] { ########################### # Default Message Handler # ########################### t_on_reply("1"); # send it out now; use stateful forwarding as it works reliably # even for UDP2TCP if (!t_relay()) { sl_reply_error(); }; } route[2] { ############################ # Register Message Handler # ############################ if (nat_uac_test("19")) { setflag(7); force_rport(); fix_nated_register(); }; if (!www_authorize("", "subscriber")) { www_challenge("", "0"); sl_send_reply("401", "Unauthorized"); break; }; if (!is_from_local()) { sl_send_reply("401", "Unauthorized"); break; }; consume_credentials(); fix_nated_contact(); if (!save("location")) { sl_reply_error(); break; }; m_dump(); } route[3] { ############################# # CANCEL and INVITE handler # ############################# # SIP destinations to PSTN if (uri=~"^sip:[0-9]{4}@.*$" || uri=~"^sip:[0-9]{10}@.*$" || uri=~"^sip:06[0-9]{8}@.*$" || uri=~"^sip:00.*@.*$") { route(4); break; }; # SIP destinations to IPBX if (uri=~"^sip:8[0-3]@.*$") { route(5); break; } # Check AVPs for Voicemail if ((avp_db_load("$ruri","s:fw_voicemail/usr_preferences") && avp_check("fw_voicemail", "eq/i:1"))) { route(6); route(1); break; }; # accounting db flags setflag(2); setflag(3); setflag(4); setflag(5); acc_db_request("404 missed call", "missed_calls"); # Check ACL for Voicemail if (is_user_in("Request-URI","voicemail")) { setflag(6); }; # native SIP destinations are handled using our USRLOC DB lookup("aliases"); if (!lookup("location")) { if (isflagset(6)) { route(6); route(1); break; } else { sl_send_reply("404", "User Not Found"); break; }; }; t_on_failure("1"); route(9); route(1); break; } route[4] { ########################## # Outgoing PSTN Handler # ########################## # Checking Authorization to PSTN if (!proxy_authorize("","subscriber")) { proxy_challenge("","0"); sl_send_reply("407", "Proxy Authentication Required"); break; }; setflag(4); setflag(5); if (uri=~"^sip:[0-9]{4}@.*$") { if (!is_user_in("From", "local")) { sl_send_reply("403", "Forbidden"); break; }; } else if (uri=~"^sip:[0-9]{10}@.*$") { if (!is_user_in("From", "local")) { sl_send_reply("403", "Forbidden"); break; }; } else if (uri=~"^sip:06[0-9]{8}@.*$") { if (!is_user_in("From", "cellphone")) { sl_send_reply("403", "Forbidden"); break; }; } else if (uri=~"^sip:00.@.*$") { if (!is_user_in("From", "int")) { sl_send_reply("403", "Forbidden"); break; }; }; prefix("0"); rewritehostport("nxs.yi.org:5050"); route(9); route(1); break; } route[5] { ########################## # Asterisk Handler # ########################## # Checking Authorization to Asterisk if (!proxy_authorize("","subscriber")) { proxy_challenge("","0"); sl_send_reply("407", "Proxy Authentication Required"); break; }; if (uri=~"^sip:8[0-3]@.*$") { if (!is_user_in("From", "local")) { sl_send_reply("403", "Forbidden"); break; }; }; rewritehostport("nxs.yi.org:5050"); route(9); route(1); break; } route[6] { ########################## # Voicemail Handler # ########################## revert_uri(); # resend to voicemail with original request URI prefix("u"); rewritehostport("nxs.yi.org:5050"); break; } route[7] { ########################## # Message Handler # ########################### lookup("aliases"); if (!lookup("location")) { if (method == "MESSAGE") { if (!t_newtran()) { sl_reply_error(); break; }; if (m_store("0")) { t_reply("202", "Accepted for Later Delivery"); break; }; t_reply("503", "Service Unavailable"); break; }; }; route(1); } route[8] { ################################ # SUBSCRIBE/NOTIFY Handler # ################################ # Checking Authorization if (!proxy_authorize("","subscriber")) { proxy_challenge("","0"); sl_send_reply("407", "Proxy Authentication Required"); break; }; lookup("aliases"); if (!lookup("location")) { sl_send_reply("404", "User Not Found"); break; }; route(1); } route[9] { ############### # Nat Handler # ############### if (nat_uac_test("19")) { setflag(7); }; if (isflagset(7)) { force_rport(); fix_nated_contact(); force_rtp_proxy(); }; } onreply_route[1] { ########################## # Statefull Handler # ########################## if (status=~"(180) || (183) || 2[0-9][0-9]") { if(search("^Content-Type: .*$")) { force_rtp_proxy(); }; }; } failure_route[1] { ########################## # Voicemail Handler # ########################## if (t_check_status("486")) { revert_uri(); # resend to voicemail with original request URI prefix("b"); rewritehostport("nxs.yi.org:5050"); append_branch(); t_relay_to_udp("nxs.yi.org","5050"); break; }; if (t_check_status("408")) { revert_uri(); # resend to voicemail with original request URI prefix("u"); rewritehostport("nxs.yi.org:5050"); append_branch(); t_relay_to_udp("nxs.yi.org","5050"); break; }; }