# # $Id$ # # ----------- global configuration parameters ------------------------ debug=3 # debug level (cmd line: -dddddddddd) fork=yes # daemonize log_stderror=no # (cmd line: -E) check_via=no # (cmd. line: -v) dns=no # (cmd. line: -r) rev_dns=no # (cmd. line: -R) children=4 fifo="/tmp/openser_fifo" listen=udp:10.10.10.10:5060 # # ------------------ module loading ---------------------------------- # Uncomment this if you want to use SQL database mpath="/usr/local/lib/openser/modules" loadmodule "mysql.so" loadmodule "xlog.so" loadmodule "sl.so" loadmodule "tm.so" loadmodule "rr.so" loadmodule "maxfwd.so" loadmodule "usrloc.so" loadmodule "registrar.so" loadmodule "textops.so" loadmodule "avpops.so" loadmodule "auth.so" loadmodule "auth_db.so" loadmodule "group.so" loadmodule "uri.so" # ----------------- setting module-specific parameters --------------- modparam("usrloc|auth_db|avpops|group", "db_url", "mysql://openser:openserrw@localhost/openser") # -- usrloc params -- # persistent storage 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("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"); exit; }; if (msg:len >= 2048 ) { sl_send_reply("513", "Message too big"); exit; }; # 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(); # subsequent messages withing a dialog should take the # path determined by record-routing if (loose_route()) { # mark routing logic in request append_hf("P-hint: rr-enforced\r\n"); route(1); }; if (!uri==myself) { # mark routing logic in request append_hf("P-hint: outbound\r\n"); route(1); }; # 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") { if (!www_authorize("openser.org", "subscriber")) { www_challenge("openser.org", "0"); exit; }; save("location"); exit; }; # requests for Media server if(is_method("INVITE") && !has_totag() && uri=~"sip:\*9") { route(3); exit; } # mark transaction if user is in voicemail group if(is_method("INVITE") && !has_totag() && is_user_in("Request-URI","voicemail")) { xdbg("user [$ru] has voicemail redirection enabled\n"); # backup R-URI avp_write("$ruri", "i:10"); setflag(2); }; # native SIP destinations are handled using our USRLOC DB if (!lookup("location")) { if(isflagset(2)) { # route to Asterisk Media Server prefix("1"); rewritehostport("10.10.10.11:5060"); route(1); } else { sl_send_reply("404", "Not Found"); exit; } }; append_hf("P-hint: usrloc applied\r\n"); }; route(1); } route[1] { if(isflagset(2)) t_on_failure("1"); if (!t_relay()) { sl_reply_error(); }; exit; } # voicemail access # - *98 - listen caller's voice messages, being prompted for pin # - *981 - listen voice messages, being promted for mailbox and pin # - *98XXXX - leave voice message to XXXX # route[3] { # direct voicemail if (uri =~ "sip:\*98@" ) { rewriteuser("1"); xdbg("voicemail access\n"); } else if (uri =~ "sip:\*981@" ) { strip(4); rewriteuser("11"); } else if (uri =~ "sip:\*98.+@" ) { strip(3); prefix("1"); } else { xlog("unknown media extension $rU\n"); sl_send_reply("404", "Unknown media service"); exit; } # route to Asterisk Media Server rewritehostport("10.10.10.11:5060"); route(1); } failure_route[1] { if (t_was_cancelled()) { xdbg("transaction was cancelled by UAC\n"); return; } # restore initial uri avp_pushto("$ruri", "i:10"); prefix("1"); # route to Asterisk Media Server rewritehostport("10.10.10.11:5060"); resetflag(2); route(1); }