# -------------------------------------------------------------------- # # start RTPProxy with: rtpproxy -l 77.77.77.777 -s udp:localhost:7890 # # ----------- global configuration parameters ------------------------ debug=3 log_stderror=no log_facility=LOG_LOCAL0 fork=yes children=4 /* uncomment the following lines to enable debugging */ #debug=9 #fork=no #log_stderror=yes port=5060 listen=77.77.77.777 children=4 # --- module loading mpath="//lib64/opensips/modules/" loadmodule "db_mysql.so" loadmodule "sl.so" loadmodule "tm.so" loadmodule "rr.so" loadmodule "maxfwd.so" loadmodule "usrloc.so" loadmodule "registrar.so" loadmodule "textops.so" loadmodule "mi_fifo.so" loadmodule "uri_db.so" loadmodule "uri.so" loadmodule "xlog.so" loadmodule "dialog.so" loadmodule "nat_traversal.so" loadmodule "nathelper.so" loadmodule "domain.so" # --- setting module parameters # -- mi_fifo params -- modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo") # -- rr params -- modparam("rr", "enable_full_lr", 1) modparam("rr", "append_fromtag", 0) # -- registrar params -- modparam("registrar", "method_filtering", 1) modparam("registrar|nathelper", "received_avp", "$avp(i:42)") # ----- uri_db params ----- modparam("uri_db", "use_uri_table", 0) modparam("uri_db", "db_url", "") # -- usrloc params -- modparam("usrloc", "db_mode", 0) modparam("usrloc", "nat_bflag", 6) # ----- domain params ----- modparam("domain", "db_url", "mysql://opensips:opensipsrw@localhost/opensips") modparam("domain", "db_mode", 1) # Use caching # ----- multi-module params ----- modparam("alias_db|auth_db|usrloc|uri_db", "use_domain", 1) # -- nathelper modparam("nathelper", "rtpproxy_sock", "udp:127.0.0.1:7890") modparam("nathelper", "sipping_bflag", 7) #-------------------------Dialog Params--------------------------- modparam("dialog", "dlg_flag", 4) # --- main routing logic route{ if (!mf_process_maxfwd_header("10")) { sl_send_reply("483","Too Many Hops"); exit; }; # NAT detection route(2); if (loose_route()) { xlog("LOOSE ROUTE\n"); append_hf("P-hint: rr-enforced\r\n"); route(1); }; if (!is_uri_host_local()) { xlog("THIS IS OUTBOUND!\n"); append_hf("P-hint: outbound\r\n"); route(1); }; if (is_uri_host_local()) { if (method=="REGISTER") { if (isflagset(5)) { setbflag(6); # if you want OPTIONS natpings uncomment next # setbflag(7); }; if(!save("location")) { xlog("Saving contact failed - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n"); sl_reply_error(); exit; } exit; }; if (!lookup("location")) { sl_send_reply("404", "Not Found"); exit; }; append_hf("P-hint: usrloc applied\r\n"); }; route(1); } route[1] { if (subst_uri('/(sip:.*);nat=yes/\1/')){ setbflag(6); }; if (isflagset(5)||isbflagset(6)) { route(3); } if (!t_relay()) { sl_reply_error(); }; exit; } route[2]{ force_rport(); if (nat_uac_test("19")) { if (is_method("REGISTER")) { fix_nated_register(); } else { fix_nated_contact(); }; setflag(5); }; if(!is_method("REGISTER")){ if(nat_uac_test("19")){ record_route(";nat=yes"); } else { record_route(); }; }; } route[3] { if (is_method("BYE|CANCEL")) { unforce_rtp_proxy(); } else if (is_method("INVITE")){ force_rtp_proxy(); t_on_failure("1"); }; if (isflagset(5)) { search_append('Contact:.*sip:[^>[:cntrl:]]*', ';nat=yes'); } t_on_reply("1"); } failure_route[1] { if (isbflagset(6) || isflagset(5)) { unforce_rtp_proxy(); } } onreply_route[1] { if ((isflagset(5) || isbflagset(6)) && status=~"(183)|(2[0-9][0-9])") { if (has_body()) { force_rtp_proxy(); } } search_append('Contact:.*sip:[^>[:cntrl:]]*', ';nat=yes'); if (isbflagset(6)) { fix_nated_contact(); } }