# # $Id: ser.cfg,v 1.21.2.1 2003/07/30 16:46:18 andrei Exp $ # # simple quick-start config script # # ----------- global configuration parameters ------------------------ debug=2 # debug level (cmd line: -dddddddddd) fork=yes log_stderror=no # (cmd line: -E) #listen=128.59.39.127 check_via=yes # (cmd. line: -v) dns=no # (cmd. line: -r) rev_dns=no # (cmd. line: -R) port=5060 children=4 fifo="/tmp/ser_fifo" alias="columbia.edu" # ------------------ module loading ---------------------------------- # Uncomment this if you want to use SQL database loadmodule "/usr/lib/ser/modules/mysql.so" loadmodule "/usr/lib/ser/modules/acc.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" # Uncomment this if you want digest authentication # mysql.so must be loaded ! loadmodule "/usr/lib/ser/modules/auth.so" loadmodule "/usr/lib/ser/modules/auth_db.so" loadmodule "/usr/lib/ser/modules/exec.so" # ----------------- setting module-specific parameters --------------- # -- transaction timers -- modparam("tm", "fr_inv_timer", 15 ) modparam("tm", "fr_timer", 10 ) # -- usrloc params -- # modparam("usrloc", "db_mode", 2) modparam("usrloc", "timer_interval", 10) # -- auth params -- modparam("auth_db", "calculate_ha1", yes) 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) # -- acc params -- modparam("acc", "log_level", 1) modparam("acc", "log_flag", 1 ) modparam("acc", "log_missed_flag", 2) # ------------------------- request routing logic ------------------- # main routing logic route{ /* ********* ROUTINE CHECKS ********************************** */ # 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; }; lookup("aliases"); # 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; }; setflag(2); # 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=~"^sip:(.+@)?columbia.edu") { if (method=="REGISTER") { log(1, "REGISTER received\n"); if (!www_authorize("columbia.edu", "subscriber")) { www_challenge("columbia.edu", "0"); break; }; save("location"); break; }; /* ********** Dial out to PSTN logic ************* */ # 5 Digit dialing, interior calls if (uri=~"^sip:[1347][0-9]{4}@columbia\.edu") { rewritehostport("128.59.59.242:5060"); log(1,"5 digit expression match"); route(2); break; }; # 10 Digit dialing with outlide line if (uri=~"^sip:931[0-9]{10}@columbia\.edu") { if(!(src_ip=="128.59.59.242") & !(proxy_authorize("columbia.edu","subscriber"))) { proxy_challenge("columbia.edu", "1"); break; } else { rewritehostport("128.59.59.242:5060"); log(1," 93 Outside line with 10 digit expression match"); route(2); break; }; }; /* voicemail access */ if (uri=~"^sip:\*86@columbia\.edu" |uri=~"^sip:vm@columbia\.edu" |uri=~"^sip:voicemail@columbia\.edu") { route(3); break; }; # native SIP destinations are handled using our USRLOC DB if (!lookup("location")) { if (!exec_dset("/etc/ser/sipldap")) { sl_send_reply("404", "Not Found"); break; } else { log(1," sipldap call"); }; }; #!lookup }; if (method == "INVITE") { t_on_failure("1"); }; # forward to current uri now; use stateful forwarding; that # works reliably even if we forward from TCP to UDP if (!t_relay()) { sl_reply_error(); }; } route[2] { log(1,"route[2]:SIP-to-PSTN call routed"); if (!t_relay()) { sl_reply_error(); }; } # ---- voicemail user access ---- route[3] { rewritehostport("127.0.0.1:5069"); log(1,"voicemail access"); if (!t_relay()) { sl_reply_error(); }; } # ------------- handling of unregistered user ------------------ route[4] { log(1,"route[4]: user not registered"); # non-Voip -- just send "off-line" if (!(method == "INVITE" || method == "ACK" || method == "CANCEL")) { sl_send_reply("404", "Not Found"); break; }; # not voicemail subscriber # if (!isflagset(4)) { # sl_send_reply("404", "Not Found and no voicemail turned on"); # break; # }; # forward to voicemail now prefix("vm*u"); rewritehostport("127.0.0.1:5069"); t_relay_to_udp("127.0.0.1", "5069"); } failure_route[1] { # transfer to asterisk voicemail with uMAILBOX for unavailable. # sip:USER@columbia.edu -> sip:vm*uUSER@127.0.0.1:5069 t_on_failure("2"); prefix("vm*u"); rewritehostport("127.0.0.1:5069"); append_branch(); log(1,"redirection to voicemail\n"); t_relay(); } failure_route[2] { # forwarding failed (voicemail down?) log(1,"voicemail failed\n"); t_reply("500","Weasels have eaten voicemail again"); }