# # v4 - adds accounting, voicemail # # ----------- global configuration parameters ------------------------ debug=3 #fork=yes log_stderror=no children=4 # Uncomment these lines to enter debugging mode #debug=10 fork=no #log_stderror=yes listen=xxx # port=5060 # ------------------ module loading ---------------------------------- #set module path mpath="/usr/local/lib/openser/modules/" loadmodule "sl.so" loadmodule "tm.so" loadmodule "rr.so" loadmodule "maxfwd.so" loadmodule "usrloc.so" loadmodule "registrar.so" loadmodule "textops.so" loadmodule "auth.so" loadmodule "auth_db.so" loadmodule "postgres.so" loadmodule "enum.so" loadmodule "acc.so" #for diagnostic purposes loadmodule "mi_fifo.so" loadmodule "xlog.so" # ----------------- setting module-specific parameters --------------- #for diagnostic purposes modparam("mi_fifo", "fifo_name", "/tmp/openser_fifo") modparam("usrloc", "db_mode", 0) modparam("auth_db", "db_url", "postgres://xxx") modparam("auth_db", "user_column", "username") modparam("auth_db", "password_column", "password") modparam("auth_db", "calculate_ha1", yes) modparam("rr", "enable_full_lr", 1) modparam("enum", "domain_suffix", "xxx") modparam("acc", "db_flag", 10) modparam("acc", "db_table_acc", "acc") modparam("acc", "db_url", "postgres://xxx") modparam("acc", "db_extra", "source=$fU; dest=$rU") modparam("tm", "fr_timer", 3) modparam("tm", "fr_inv_timer", 15) modparam("tm", "noisy_ctimer", 1) # ------------------------- request routing logic ------------------- # main routing logic # ------------------ route{ # initial checks 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; }; # record-route;subsequent messages will go through our proxy if (!method=="REGISTER") { record_route(); } # subsequent messages within a dialog should take the # path determined by record-routing if (loose_route()) { route(1); }; # send the call out if (!uri==myself) { route(1); }; # if message is to myself if(uri==myself){ if(method == "REGISTER"){ route(2); exit; } else if(method == "INVITE"){ route(3); exit; } else if(method == "BYE" || method == "CANCEL"){ route(4); exit; }; }; route(1); } # Default Message Handling # route call out # ------------------------ route[1] { setflag(10); xlog("--> entered route[1] -->"); xlog("routed: $rm to: $ruri"); if(method == "INVITE" && isflagset(11)){ xlog("ENTERED GATE TO FAILURE"); t_on_failure("1"); } if(!t_relay()) { xlog("RELAY FAILED"); sl_reply_error(); }; xlog("<-- exited route[1] <--"); exit; } # Register Message Handling # ------------------------- route[2] { if (!www_authorize("", "subscriber")) { www_challenge("", "0"); exit; }; consume_credentials(); save("location"); } # Invite Message Handling # ----------------------- route[3] { # run a check to see if ruri has voicemail setflag(11); # if proxy_authorize & challenge # Looks up local SIP users via USRLOC DB if(lookup("location")){ route(1); exit; }; # makes uri E164 style $ruri.user = "+" + $ruri.user; if(enum_query()){ route(1); exit; } # forwards to GATEWAY $ruri.domain = "xxx"; route(1); } # CANCEL and BYE Message Handling # ------------------------------- route[4] { route(1); } # For voicemail # ------------- failure_route[1] { xlog("MESSAGE FAILURE -> TO VOICEMAIL"); $ruri = "sip:500@xxx"; append_branch(); resetflag(11); route(1); }