# $Id: ser.cfg,v 1.20 2003/05/31 21:12:19 jiri Exp $ # # simple quick-start config script # # ----------- global configuration parameters ------------------------ debug=8 fork=yes 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" sip_warning=no # # ------------------ module loading ---------------------------------- # # loadmodule "/usr/lib/ser/modules/tm.so" loadmodule "/usr/lib/ser/modules/sl.so" loadmodule "/usr/lib/ser/modules/acc.so" loadmodule "/usr/lib/ser/modules/rr.so" loadmodule "/usr/lib/ser/modules/usrloc.so" loadmodule "/usr/lib/ser/modules/uri.so" loadmodule "/usr/lib/ser/modules/registrar.so" loadmodule "/usr/lib/ser/modules/maxfwd.so" loadmodule "/usr/lib/ser/modules/mysql.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/group.so" loadmodule "/usr/lib/ser/modules/pa.so" #loadmodule "/usr/lib/ser/modules/msilo.so" # modparam("acc", "log_level", 1) modparam("acc", "log_flag", 2) modparam("acc", "log_missed_flag", 2) modparam("acc", "log_fmt", "fimos") # #modparam("tm", "fr_inv_timer", 35) #INVITE timeout # modparam("auth_db", "db_url","sql://ser:secret@localhost/ser") modparam("usrloc", "db_url", "sql://ser:secret@localhost/ser") modparam("usrloc", "db_mode", 2) modparam("auth_db", "calculate_ha1", yes) modparam("auth_db", "password_column", "password") # ----------------- setting module-specific parameters --------------- # main routing logic alias="coptalk.com" alias="sip" alias="64.189.165.205" alias="sip.coptalk.com" # route{ log(1,"entering main 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 record_route(); # loose-route processing if (loose_route()) { t_relay(); break; }; setflag(2); #set flag for accounting # 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") { # digest authentication log(1,"request for registration"); if (!www_authorize("sip.coptalk.com", "subscriber")) { www_challenge("sip.coptalk.com", "0"); break; }; save("location"); break; }; /* ********** Dial out to PSTN logic ************* */ #forward numerical 7 digit requests to gateway # if request URI is numerical, forward the request to PSTN gateway... if (uri=~"^sip:[0-9]+@coptalk.com") { # match using a regular expression forward( 65.189.155.101, 5060 ); } else { # ... forward the request to user location server otherwise forward( 65.189.155.101, 5060 ); }; #forward numerical 10 digit requests to gateway, append a 7 first if(uri=~"^sip:[0-9]{10}@(coptalk\.com|64\.189\.165\.205)"){ prefix("7"); rewritehostport("65.189.155.101:5060"); log(1,"10 digit expression match, prefix 1"); route(2); break; }; #forward numerical 11 digit requests that start with a 1 to GW if(uri=~"^sip:7[0-9]{10}@(coptalk\.com|64\.189\.165\.205)"){ rewritehostport("65.189.155.101:5060"); log(1,"10 digit exp match w/leading 1"); route(2); break; }; #forward international N digit requests to gateway if(uri=~"^sip:011[0-9]+@(coptalk\.com|64\.189\.165\.205)"){ rewritehostport("65.189.155.101:5060"); log(1,"international expression match"); route(2); break; }; /* ****** Find Aliases and Locations of users ********* */ # It is very important to lookup "aliases" before looking up "locations" if(!lookup("aliases")){ log(1,"Couldn't find any matching alias"); sl_send_reply("404", "User does not exist"); break; }; if(!lookup("location")) { log(1,"unable to locate user"); route(3); break; }; }; # forward to current uri now; use stateful forwarding; that # works reliably even if we forward from TCP to UDP t_on_failure("1"); if (!t_relay()) { sl_reply_error(); }; log(1,"eof"); } route[2]{ log(1,"route[2]:SIP-to-PSTN call routed"); if(!t_relay()){ sl_reply_error(); }; }