# # $Id: openser.cfg,v 1.5 2005/10/28 19:45:33 bogdan_iancu Exp $ # # simple quick-start config script # # ----------- global configuration parameters ------------------------ debug=3 # debug level (cmd line: -dddddddddd) listen=195.10.143.38 fork=yes log_stderror=no # (cmd line: -E) /* Uncomment these lines to enter debugging mode fork=no 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/openser_fifo" unix_sock = "/tmp/openser_sock" # # uncomment the following lines for TLS support #disable_tls = 0 #listen = tls:your_IP:5061 #tls_verify = 1 #tls_require_certificate = 0 #tls_method = TLSv1 #tls_certificate = "/usr/local/etc/openser/tls/user/user-cert.pem" #tls_private_key = "/usr/local/etc/openser/tls/user/user-privkey.pem" #tls_ca_list = "/usr/local/etc/openser/tls/user/user-calist.pem" # ------------------ module loading ---------------------------------- # Uncomment this if you want to use SQL database loadmodule "/usr/local/lib/openser/modules/mysql.so" loadmodule "/usr/local/lib/openser/modules/sl.so" loadmodule "/usr/local/lib/openser/modules/tm.so" loadmodule "/usr/local/lib/openser/modules/rr.so" loadmodule "/usr/local/lib/openser/modules/maxfwd.so" loadmodule "/usr/local/lib/openser/modules/usrloc.so" loadmodule "/usr/local/lib/openser/modules/registrar.so" loadmodule "/usr/local/lib/openser/modules/textops.so" loadmodule "/usr/local/lib/openser/modules/xlog.so" loadmodule "/usr/local/lib/openser/modules/enum.so" loadmodule "/usr/local/lib/openser/modules/avpops.so" loadmodule "/usr/local/lib/openser/modules/uac.so" loadmodule "/usr/local/lib/openser/modules/uri.so" loadmodule "/usr/local/lib/openser/modules/options.so" loadmodule "/usr/local/lib/openser/modules/lcr.so" loadmodule "/usr/local/lib/openser/modules/nathelper.so" # Uncomment this if you want digest authentication # mysql.so must be loaded ! #loadmodule "/usr/local/lib/openser/modules/auth.so" #loadmodule "/usr/local/lib/openser/modules/auth_db.so" # ----------------- setting module-specific parameters --------------- # -- usrloc params -- modparam("usrloc", "db_mode", 0) # Uncomment this if you want to use SQL database # for persistent storage and comment the previous line #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) # -- tm params modparam("tm", "fr_inv_timer", 160) modparam("tm", "fr_timer", 20) modparam("tm", "pass_provisional_replies", 1) # -- enum params modparam("enum", "domain_suffix", "trunk.e164.arpa.") # -- nathelper params modparam("nathelper", "rtpproxy_disable", 1) # ------------------------- request routing logic ------------------- # main routing logic route{ force_rport(); # 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 ( is_method("REGISTER") ) { sl_send_reply("405", "Method Not Allowed"); exit; } if ( nat_uac_test("3") ) { record_route(";nat=yes"); } else { record_route(); } if (uri=~"85665684" || uri=~"foo") { if (is_method("INVITE|ACK|BYE|SUBSCRIBE")) { xlog("L_ERR", "SEMS: $rm <$ru> [From: $fu] [To: $tu]\n"); if (!t_newtran()){ log(1, "could not create transaction\n"); sl_send_reply("500","could not create transaction"); exit; } t_reply("100","Trying - just wait a minute!"); if (is_method("INVITE") && uri=~"foo") { if(!t_write_unix("/tmp/sems_sock", "conference")){ log(1, "could not contact sems\n"); t_reply("500", "Could not contact media server"); } log(1, "!!! CALLED SEMS CONFERENCE PLUGIN"); } else if (is_method("INVITE") && uri=~"85665684") { if(!t_write_unix("/tmp/sems_sock", "ivr")){ log(1, "could not contact sems\n"); t_reply("500", "Could not contact media server"); } log(1, "!!! CALLED SEMS IVR PLUGIN"); } else if (is_method("CANCEL|BYE")) { if(!t_write_unix("/tmp/sems_sock", "bye")) { t_reply("500","error contacting sems"); } } else if (is_method("ACK")) { if (!t_relay()) { sl_reply_error(); } } else if (is_method("CANCEL")) { sl_send_reply("200", "cancels are junked here"); } else { sl_send_reply("501", "method not understood here"); } } exit; } xlog("L_ERR", "route[0]: $rm <$ru> [From: $fu] [To: $tu]\n"); # subsequent messages withing a dialog should take the # path determined by record-routing if (loose_route()) { xlog("L_ERR", "route[0] (loose route): $rm <$ru> [From: $fu] [To: $tu]\n"); if(!has_totag()) { xlog("L_INFO", "Initial loose-routing rejected - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n "); sl_send_reply("403", "Initial Loose-Routing Rejected"); exit; } if(nat_uac_test("19") || search("^Route:.*;nat=yes")) { xlog("L_INFO", "Nat-Request from Loose-Route - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n") ; fix_nated_contact(); if(!search("^Content-Length:[ ]*0")) { fix_nated_sdp("3"); setflag(6); } } route(1); } if (uri==myself) { if (is_method("OPTIONS") && (!uri=~"sip:.*[@]+.*")) { options_reply(); } } if (is_method("INVITE")) { if (nat_uac_test("19")) { setflag(6); } } # BEGIN LCR from_gw() if (from_gw()) { if (nat_uac_test("3")) { fix_nated_contact(); xlog("L_INFO", "Nat-Request from gw - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n"); } if ( !search("^Content-Length:[ ]*0") ) { if (nat_uac_test("8")) { fix_nated_sdp("3"); xlog("L_INFO", "Nat-Request from gw - - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n" ); } } } if (from_gw("1")) { # National customers route(4); } else if (from_gw("2")) { # International customers route(2); } else if (from_gw("3")) { # Alcatel customers, need special modification for CLIR route(5); } else if (from_gw("4")) { # Audiocodes customers, need special modification fro CLIR route(6); } else if (from_gw("5")) { # Skype A number modification route(7); } else if (from_gw("6")) { # Click 2 Dial test route(8); } # END LCR from_gw() if (src_ip==62.236.5.233 && (method=='INVITE' || method=='CANCEL' || method=='ACK' || method=='BYE' || meth od =='PRACK')) { replace("User-Agent:.*Cisco-SIPGateway/IOS-12.x", "User-Agent: song gw"); route(3); exit; }; sl_send_reply("403", "Forbidden - direct calls not allowed"); log(1, "403 - Forbidden, direct calls not allowed"); exit; } route[1] { xlog("L_ERR", "route[1]: $rm <$ru> [From: $fu] [To: $tu]\n"); if ( isflagset(6) ) { fix_nated_contact(); } t_on_reply("1"); xlog("L_INFO", "Request leaving server - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n"); if (!t_relay()) { sl_reply_error(); }; exit; } route[2] { xlog("L_ERR", "route[2]: $rm <$ru> [From: $fu] [To: $tu]\n"); sethost("62.236.5.233"); # if (msg:len > 1300) { # add_uri_param("transport=tcp"); # } if (!t_relay()) { sl_reply_error(); } exit; } route[3] { if (enum_query("lab.ext.e164.arpa.")) { log(1, "enum query: ok\n"); } else { log(1, "enum query: not ok\n"); } route(1); exit; } route[4] { xlog("L_ERR", "route[4]: $rm <$ru> [From: $fu] [To: $tu]\n"); # local number transport ops etc private info } route[5] { if (method == 'INVITE')) { if ( is_present_hf("P-Asserted-Identity") ) { remove_hf("Remote-Party-ID"); avp_write("$hdr(P-Asserted-Identity)", "$avp(s:pai)"); avp_write("$avp(s:pai)", "$avp(s:rpid)"); avp_printf("$avp(s:rpid)", "<$avp(s:rpid)>;party=calling;screen=yes;privacy="); if ( search("[Pp]rivacy:.*;?[Ii][Dd]") ) { avp_printf("$avp(s:rpid)", "$avp(s:rpid)full"); } else { avp_printf("$avp(s:rpid)", "$avp(s:rpid)off"); } append_hf("Remote-Party-ID: $avp(s:rpid)\r\n"); remove_hf("P-Asserted-Identity"); } } route(4); exit; } route[6] { if (is_method("INVITE")) { # From: if ( search("From: *") ) { if ( is_present_hf("P-Asserted-Identity") ) { if ( is_present_hf("Remote-Party-ID") ) { remove_hf("Remote-Party-ID"); } avp_write("$hdr(P-Asserted-Identity)", "$avp(s:pai)"); # P-Asserted-Identity: tel:0985665661 avp_subst('$avp(s:pai)/$avp(s:pai)', '/tel://i'); avp_subst('$avp(s:pai)/$avp(s:pai)', '/^0([1-9])/\+358\1/'); avp_write("$avp(s:pai)", "$avp(s:rpid)"); avp_printf("$avp(s:rpid)", "<$avp(s:rpid)>;party=calling;screen=yes;privacy="); remove_hf("P-Asserted-Identidy"); if ( search("[Pp]rivacy:.*;?[Ii][Dd]") ) { avp_printf("$avp(s:rpid)", "$avp(s:rpid)full"); } else { avp_printf("$avp(s:rpid)", "$avp(s:rpid)off"); } append_hf("Remote-Party-ID: $avp(s:rpid)\r\n"); } } } if ( is_method("INVITE|CANCEL|BYE|ACK|PRACK")) { if (!has_totag()) { avp_write("$hdr(P-Asserted-Identity)", "$avp(s:pai)"); # P-Asserted-Identity: tel:09856681 avp_subst('$avp(s:pai)/$avp(s:pai)', '/tel://i'); avp_subst('$avp(s:pai)/$avp(s:pai)', '/^0([1-9](.*)$/\+358\1\2/'); avp_write("$avp(s:pai)", "$avp(s:from)"); uac_replace_from("", "$avp(s:from)"); } } } route(4); exit; } route[7] { # very private customer A number modification here } route[8] { if (method == 'INVITE') { if (is_present_hf('Remote-Party-ID')) { remove_hf('Remote-Party-ID'); } avp_printf("$avp(s:rpid)", ";party=calling;screen=yes;priv acy=off"); append_hf("Remote-Party-ID: $avp(s:rpid)\r\n", "Contact"); } route(4); exit; } onreply_route[1] { xlog("L_INFO", "NAT-Reply - S=$rs D=$rr F=$fu T=$tu IP=$si ID=$ci\n"); if (nat_uac_test("1")) { fix_nated_contact(); xlog("L_INFO", "Nat-Reply, Fixing Contact - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n"); setflag(6); } if (isflagset(6) && !search("^Content-Length:[ ]*0")) { if (nat_uac_test("8") && status=~"(180)|(183)|2[0-9][0-9]") { fix_nated_sdp("3"); xlog("L_INFO", "Nat-Reply, Fixing SDP - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n"); } } exit; }