#debug=3 # debug level (cmd line: -dddddddddd) fork=yes #memlog=5 # memory debug log level #log_facility=LOG_LOCAL0 # sets the facility used for logging (see syslog(3)) log_stderror=yes check_via=no # (cmd. line: -v) dns=no # (cmd. line: -r) rev_dns=no # (cmd. line: -R) listen=192.168.1.171 port=5060 #children=4 fifo="/tmp/ser_fifo" fifo_db_url="mysql://username:password@localhost/database" user=nobody group=nobody fifo_user=root # owner of the ser fifo fifo_group=root fifo_mode=0777 # 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) alias="proxy.mydomain.com" # ------------------ module loading ---------------------------------- # Uncomment this if you want to use SQL database loadmodule "/usr/local/lib/ser/modules/mysql.so" loadmodule "/usr/local/lib/ser/modules/sl.so" loadmodule "/usr/local/lib/ser/modules/tm.so" loadmodule "/usr/local/lib/ser/modules/rr.so" loadmodule "/usr/local/lib/ser/modules/maxfwd.so" loadmodule "/usr/local/lib/ser/modules/usrloc.so" loadmodule "/usr/local/lib/ser/modules/registrar.so" loadmodule "/usr/local/lib/ser/modules/uri.so" loadmodule "/usr/local/lib/ser/modules/uri_db.so" loadmodule "/usr/local/lib/ser/modules/avpops.so" loadmodule "/usr/local/lib/ser/modules/textops.so" loadmodule "/usr/local/lib/ser/modules/mediaproxy.so" loadmodule "/usr/local/lib/ser/modules/nathelper.so" loadmodule "/usr/local/lib/ser/modules/domain.so" loadmodule "/usr/local/lib/ser/modules/auth.so" loadmodule "/usr/local/lib/ser/modules/auth_db.so" loadmodule "/usr/local/lib/ser/modules/acc.so" loadmodule "/usr/local/lib/ser/modules/exec.so" loadmodule "/usr/local/lib/ser/modules/permissions.so" loadmodule "/usr/local/lib/ser/modules/group.so" modparam("group", "db_url","mysql://username:password@localhost/database") modparam("auth_db|permissions|uri_db|usrloc", "db_url", "mysql://username:password@localhost/database") modparam("acc", "db_url", "mysql://username:password@localhost/database") modparam("acc", "log_level", 1) modparam("acc", "log_flag", 1) modparam("acc", "log_fmt", "cdfimorstup") modparam("acc", "db_flag", 1) modparam("acc", "log_missed_flag", 2) modparam("acc", "db_missed_flag", 2) modparam("acc", "report_cancels", 1) modparam("auth_db", "calculate_ha1", yes) modparam("auth_db", "user_column", "username") modparam("auth_db", "password_column", "password") modparam("nathelper", "rtpproxy_disable", 1) modparam("nathelper", "natping_interval", 0) modparam("mediaproxy","natping_interval", 30) modparam("mediaproxy","mediaproxy_socket", "/var/run/mediaproxy.sock") modparam("mediaproxy","sip_asymmetrics","/usr/local/etc/ser/sip-asymmetric-clients") modparam("mediaproxy","rtp_asymmetrics","/usr/local/etc/ser/rtp-asymmetric-clients") modparam("usrloc", "db_mode", 2) modparam("registrar", "nat_flag", 6) modparam("rr", "enable_full_lr", 1) modparam("tm", "fr_inv_timer", 27) modparam("tm", "fr_inv_timer_avp", "inv_timeout") modparam("permissions", "db_mode", 1) modparam("permissions", "trusted_table", "trusted") modparam("avpops", "avp_url", "mysql://username:password@localhost/database") modparam("avpops", "avp_table", "usr_preferences") route { # ----------------------------------------------------------------- # Sanity Check Section # ----------------------------------------------------------------- if (!mf_process_maxfwd_header("10")) { sl_send_reply("483", "Too Many Hops"); break; }; if (msg:len > max_len) { sl_send_reply("513", "Message Overflow"); break; }; if (method=="INVITE" || method=="BYE" || method=="ACK") { setflag(1); }; # ----------------------------------------------------------------- # Record Route Section # ----------------------------------------------------------------- if (method=="INVITE" && client_nat_test("3")) { # INSERT YOUR IP ADDRESS HERE record_route_preset("192.168.1.171:5060;nat=yes"); } else if (method!="REGISTER") { record_route(); }; # ----------------------------------------------------------------- # Call Tear Down Section # ----------------------------------------------------------------- if (method=="BYE" || method=="CANCEL") { end_media_session(); }; # ----------------------------------------------------------------- # Loose Route Section # ----------------------------------------------------------------- if (loose_route()) { if (has_totag() && (method=="INVITE" || method=="ACK")) { if (client_nat_test("3")||search("^Route:.*nat=yes")){ setflag(6); use_media_proxy(); }; }; route(1); break; }; # ----------------------------------------------------------------- # Call Type Processing Section # ----------------------------------------------------------------- if (uri!=myself) { route(4); route(1); break; }; if (method=="CANCEL") { route(1); break; } else if (method=="INVITE") { route(3); break; } else if (method=="REGISTER") { route(2); break; } else if (method=="ACK"){ route(1); break; }; lookup("aliases"); if (uri!=myself) { route(4); route(1); break; }; if (!lookup("location")) { sl_send_reply("404", "User Not Found"); break; }; route(1); } route[1] { # ----------------------------------------------------------------- # Default Message Handler # ----------------------------------------------------------------- t_on_reply("1"); if (!t_relay()) { if (method=="INVITE" || method=="ACK") { end_media_session(); }; sl_reply_error(); }; } route[2] { # ----------------------------------------------------------------- # REGISTER Message Handler # ----------------------------------------------------------------- sl_send_reply("100", "Trying"); if (!search("^Contact:[ ]*\*") && client_nat_test("7")) { setflag(6); fix_nated_register(); force_rport(); }; if (!www_authorize("","subscriber")) { www_challenge("","0"); break; }; if (!check_to()) { sl_send_reply("401", "Unauthorized"); break; }; consume_credentials(); if (!save("location")) { sl_reply_error(); }; } route[3] { # ----------------------------------------------------------------- # INVITE Message Handler # ----------------------------------------------------------------- #if (!allow_trusted()) { # if (method=="INVITE" && !allow_trusted()) { # if (!proxy_authorize("","subscribe")) { # proxy_challenge("","0"); # break; # } else if (!check_from()) { # sl_send_reply("403", "Use From=ID"); # break; # }; # consume_credentials(); # }; if (client_nat_test("3")) { setflag(7); force_rport(); fix_nated_contact(); }; lookup("aliases"); if (uri!=myself) { route(4); route(1); break; }; if (uri=~"^sip:0011[0-9]*@") { # International PSTN calls to asterisk strip(4); setflag(6); route(4); route(5); break; }; if (!lookup("location")) { if (uri=~"^sip:[0-9]{10}@") { # Trying to send Local setflag(6); route(4); route(5); acc_db_request("Missed Call", "missed_calls"); break; }; if (uri=~"^sip:[0-9]{3}@") { # Trying to send voicemail main to Asterisk setflag(6); route(4); route(5); break; }; if (uri=~"^sip:[0-9]{6}@") { # Trying to send PSTN to Asterisk setflag(6); route(4); route(5); break; }; sl_send_reply("404", "User Not Found"); break; }; if (avp_db_load("$ruri/username", "s:fwdbusy")) { if (!avp_check("s:fwdbusy", "eq/$ruri/i")) { setflag(26); }; }; if (avp_db_load("$ruri/username", "s:fwdnoanswer")) { if (!avp_check("s:fwdnoanswer", "eq/$ruri/i")) { setflag(27); }; }; if (avp_db_load("$ruri/username", "s:callfwd")) { setflag(22); avp_pushto("$ruri", "s:callfwd"); ## route(4); #inserted for incoming did RTP support route(6); break; }; t_on_failure("1"); setflag(6); route(4); route(1); } route[4] { # ----------------------------------------------------------------- # NAT Traversal Section # ----------------------------------------------------------------- if (isflagset(6) || isflagset(7)) { if (!isflagset(8)) { setflag(8); use_media_proxy(); }; }; } route[5] { # ----------------------------------------------------------------- # PSTN Handler # ----------------------------------------------------------------- rewritehost("192.168.1.156"); # INSERT YOUR PSTN GATEWAY IP ADDRESS avp_write("i:45", "inv_timeout"); t_on_failure("1"); route(4); route(1); } route[6] { # ------------------------------------------------------------------------ # Call Forwarding Reply Route Handler # # This must be done as a route block because sl_send_reply() cannot be # called from the failure_route block # ------------------------------------------------------------------------ lookup("aliases"); if (uri!=myself) { if (!isflagset(22)) { append_branch(); }; route(4); route(1); break; }; if (!lookup("location")) { if (uri=~"^sip:[0-9]{10}@") { route(4); route(1); break; }; sl_send_reply("404", "User Not Found"); }; route(4); route(1); } onreply_route[1] { if ((isflagset(6) || isflagset(7)) && (status=~"(180)|(183)|2[0-9][0-9]")) { if (!search("^Content-Length:[ ]*0")) { use_media_proxy(); }; }; if (client_nat_test("1")) { fix_nated_contact(); }; } failure_route[1] { acc_db_request("Missed Call", "missed_calls"); revert_uri(); rewritehostport("192.168.1.156:5060"); append_branch(); t_relay(); break(); if (t_check_status("487")) { break; }; if (isflagset(26) && t_check_status("486")) { if (avp_pushto("$ruri", "s:fwdbusy")) { avp_delete("s:fwdbusy"); resetflag(26); route(6); break; }; }; if (isflagset(27) && t_check_status("408")) { if (avp_pushto("$ruri", "s:fwdnoanswer")) { avp_delete("s:fwdnoanswer"); resetflag(27); route(6); break; }; }; end_media_session(); } route[7] { # ----------------------------------------------------------------- # # ----------------------------------------------------------------- rewritehost("192.168.1.156"); # INSERT YOUR PSTN GATEWAY IP ADDRESS avp_write("i:45", "inv_timeout"); t_on_failure("1"); route(4); route(1); }