Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- debug=3
- log_stderror=no
- log_facility=LOG_LOCAL0
- fork=yes
- children=4
- disable_tcp=yes
- auto_aliases=yes
- sip_warning=yes
- port=5060
- listen=udp:XXX.XXX.XXX.XXX:5060
- group=nobody
- user=nobody
- ####### Modules Section ########
- #set module path
- mpath="/usr/local/lib64/opensips/modules/"
- /* uncomment next line for MySQL DB support */
- loadmodule "db_mysql.so"
- loadmodule "signaling.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.so"
- loadmodule "acc.so"
- loadmodule "auth.so"
- loadmodule "auth_db.so"
- loadmodule "alias_db.so"
- loadmodule "domain.so"
- loadmodule "drouting.so"
- loadmodule "avpops.so"
- loadmodule "dialplan.so"
- loadmodule "permissions.so"
- loadmodule "dialog.so"
- loadmodule "nathelper.so"
- loadmodule "siptrace.so"
- loadmodule "nat_traversal.so"
- loadmodule "userblacklist.so"
- loadmodule "aaa_radius.so"
- modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")
- modparam("rr", "enable_full_lr", 1)
- modparam("rr", "append_fromtag", 0)
- modparam("usrloc", "db_mode", 2)
- modparam("usrloc", "db_url","mysql://X:X@localhost/opensips16")
- modparam("usrloc","nat_bflag", 6)
- modparam("uri", "use_uri_table", 0)
- modparam("acc", "report_ack", 0)
- modparam("acc", "log_level", 2)
- modparam("acc", "report_cancels", 1)
- modparam("acc", "detect_direction", 0)
- modparam("acc", "failed_transaction_flag", 3)
- modparam("acc", "aaa_url", "radius:/usr/local/etc/radiusclient-ng/radiusclient.conf")
- modparam("acc", "aaa_flag", 1)
- modparam("acc", "aaa_missed_flag", 0)
- modparam("acc", "aaa_extra", "User-Name=$Au;
- Calling-Station-Id=$from;
- Called-Station-Id=$to;
- Sip-Translated-Request-URI=$ru;
- Sip-RPid=$avp(s:rpid);
- Source-IP=$avp(s:source_ip);
- Source-Port=$avp(s:source_port);
- SIP-Proxy-IP=$avp(s:sip_proxy_ip);
- Canonical-URI=$avp(s:can_uri);
- Billing-Party=$avp(s:billing_party);
- Divert-Reason=$avp(s:divert_reason);
- User-Agent=$hdr(user-agent);
- Contact=$hdr(contact);
- Event=$hdr(event);
- ENUM-TLD=$avp(s:enum_tld)")
- modparam("auth_db", "calculate_ha1", yes)
- modparam("auth_db", "password_column", "password")
- modparam("auth_db", "db_url","mysql://X:X@localhost/opensips16")
- modparam("auth_db", "load_credentials", "")
- modparam("alias_db", "db_url","mysql://X:X@localhost/opensips16")
- modparam("domain", "db_url","mysql://X:X@localhost/opensips16")
- modparam("domain", "db_mode", 1) # Use caching
- modparam("drouting", "use_domain", 1)
- modparam("drouting","db_url", "mysql://X:X@localhost/opensips16")
- modparam("avpops", "db_url", "mysql://X:X@localhost/opensips16")
- modparam("avpops", "avp_table", "usr_preferences")
- modparam("dialplan", "db_url","mysql://X:X@localhost/opensips16")
- modparam("dialplan", "attrs_pvar", "$avp(s:dest)")
- modparam("permissions", "db_url","mysql://X:X@localhost/opensips16")
- modparam("nathelper","rtpproxy_sock", "udp:xxx.xxx.xxx.xxx:7777")
- #modparam("nathelper","rtpproxy_sock", "unix:/var/run/rtpproxy.sock")
- modparam("nathelper","natping_interval", 30)
- modparam("nathelper","ping_nated_only", 0)
- modparam("nathelper","sipping_bflag", 7)
- modparam("nathelper","sipping_from", "sip:[email protected]")
- modparam("nathelper","received_avp", "$avp(i:42)")
- modparam("registrar","received_avp", "$avp(i:42)")
- modparam("registrar", "max_contacts", 10)
- modparam("siptrace", "db_url", "mysql://X:X@localhost/opensips16")
- modparam("siptrace", "trace_on", 1)
- modparam("siptrace", "trace_flag", 2)
- modparam("siptrace", "traced_user_avp", "$avp(s:traceuser)")
- modparam("siptrace", "trace_local_ip", "XXX.XXX.XXX.XXX")
- modparam("userblacklist", "db_url","mysql://X:X@localhost/opensips16")
- ####### Routing Logic ########
- # main request routing logic
- route{
- xlog("New Call for route [ fu=$fu/ tu=$tu /ru=$ru/ ci=$ci]");
- if (!mf_process_maxfwd_header("10")) {
- sl_send_reply("483","Too Many Hops");
- exit;
- }
- if (has_totag()) {
- if (loose_route()) {
- if (is_method("BYE")) {
- setflag(1); # do accounting ...
- setflag(3); # account fails
- } else if (is_method("INVITE")) {
- record_route();
- }
- route(1);
- } else {
- if ( is_method("ACK") ) {
- if ( t_check_trans() ) {
- t_relay();
- exit;
- } else {
- exit;
- }
- }
- sl_send_reply("404","Not here");
- }
- exit;
- }
- #initial requests
- # CANCEL processing
- if (is_method("CANCEL"))
- {
- if (t_check_trans())
- t_relay();
- exit;
- }
- t_check_trans();
- if (!(method=="REGISTER") && is_from_local()) /*multidomain version*/
- {
- if (!proxy_authorize("", "subscriber")) {
- proxy_challenge("", "0");
- exit;
- }
- if (!db_check_from()) {
- sl_send_reply("403","Forbidden auth ID");
- exit;
- }
- consume_credentials();
- # caller authenticated
- }
- # preloaded route checking
- if (loose_route()) {
- xlog("L_ERR","Attempt to route with preloaded Route's [$fu/$tu/$ru/$ci]");
- if (!is_method("ACK"))
- sl_send_reply("403","Preload Route denied");
- exit;
- }
- # record routing
- if (!is_method("REGISTER|MESSAGE"))
- record_route();
- # account only INVITEs
- if (is_method("INVITE")) {
- xlog("set acc");
- setflag(1); # do accounting
- setflag(3); # Account failed transactions
- $avp(s:can_uri) = $ru;
- }
- if (!is_uri_host_local())
- {
- append_hf("P-hint: outbound\r\n");
- route(1);
- }
- if (is_method("PUBLISH"))
- {
- sl_send_reply("503", "Service Unavailable");
- exit;
- }
- if (is_method("REGISTER"))
- {
- if (!www_authorize("", "subscriber"))
- {
- www_challenge("", "0");
- exit;
- }
- if (!db_check_to())
- {
- sl_send_reply("403","Forbidden auth ID");
- exit;
- }
- if (!save("location"))
- sl_reply_error();
- exit;
- }
- if ($rU==NULL) {
- # request with no Username in RURI
- sl_send_reply("484","Address Incomplete");
- exit;
- }
- if(avp_db_load("$fu","$avp(s:trace)")) {
- $avp(s:traceuser)=$fu;
- setflag(22);
- sip_trace();
- xlog("L_INFO","User $fu being traced");
- }
- if(!dp_translate("1","$rU/$rU")){
- xlog("Invalid Destination :$rU/$rU");
- send_reply("420", "Invalid Destination");
- exit;
- }
- xlog("info: $avp(s:dest)");
- if ($avp(s:dest)=="usrloc") {
- #Route to usrloc
- route(3);
- }
- if ($avp(s:dest)=="pstn") {
- #route to pstn
- route(4);
- }
- if ($avp(s:dest)=="media") {
- #route to media server
- route(5);
- }
- send_reply("420", "Invalid Extension");
- exit;
- }
- route[1] {
- if (!check_blacklist("userblacklist")) {
- sl_send_reply("403", "DID Forbidden");
- exit;
- }
- xlog("Enter route 1");
- if (has_body("application/sdp")) {
- xlog("Route1 on RTP");
- rtpproxy_offer();
- }
- if (is_method("INVITE")) {
- t_on_branch("2");
- t_on_reply("2");
- t_on_failure("1");
- }
- if (!t_relay()) {
- sl_reply_error();
- }
- exit;
- }
- route[2] {
- #if (has_body("application/sdp")) {
- #
- # if (client_nat_test("3")) {
- # xlog("--->internal<---");
- # rtpproxy_offer();
- # } else {
- # xlog("--->ext<---");
- # rtpproxy_offer();
- # }
- #}
- route(1);
- }
- route[3]{
- xlog("Enter Route 3 USRLOC");
- alias_db_lookup("dbaliases");
- if (!lookup("location", "m")) {
- switch ($retcode) {
- case -1:
- case -3:
- t_newtran();
- t_reply("404", "Not Found");
- exit;
- case -2:
- sl_send_reply("405", "Method Not Allowed");
- exit;
- }
- }
- route(1);
- }
- route[4] {
- #---- PSTN route ----#
- if(!check_source_address("0")) {
- if (!db_check_from()) {
- xlog("Forbidden auth ID route 4");
- xlog("Forbidden rs= $rs/ rb= $rb / fd= $fd / fu= $fu / rr= $rr / rs= $rs / Ri= $Ri / si= $si");
- sl_send_reply("403","Forbidden");
- exit;
- }
- }
- if(!do_routing("0")){
- xlog("No rules found matching the URI prefix");
- send_reply("503", "No rules found matching the URI prefix");
- exit;
- }
- # flag 10 – failure route
- setflag(10);
- route(1);
- }
- route[5] {
- #---- Route to media servers ----#
- xlog("route to media servers");
- }
- failure_route[1] {
- unforce_rtp_proxy();
- if (t_was_cancelled()) {
- exit;
- }
- if(isflagset(10)){
- if (use_next_gw()) {
- #xlog ("next gateway $ru \n");
- t_on_failure("1");
- t_relay();
- exit;
- } else {
- t_reply("503", "Service not available, no more gateways");
- exit;
- }
- }
- }
- branch_route[2] {
- xlog("new branch at $ru\n");
- }
- onreply_route[2] {
- xlog("ACK with rs= $rs/ rb= $rb / fd= $fd / fu= $fu / rr= $rr / rs= $rs / Ri= $Ri / si= $si");
- if ($rs == "200" && $si == "xxx.xxx.xxx.xxx") {
- xlog("==ACC== $si | $rs ");
- setflag(1); # do accounting
- }
- if (has_body("application/sdp")) {
- xlog("reply 2 turn on rtp");
- rtpproxy_answer();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement