Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- debug=3
- log_stderror=yes
- log_facility=LOG_LOCAL0
- fork=yes
- children=4
- disable_tcp=yes
- auto_aliases=no
- sip_warning=yes
- listen=udp:EXTERNAL_IP:5060
- listen=udp:INTERNAL_IP:5060
- mhomed=1
- group=nobody
- user=nobody
- server_header="SBC"
- server_signature = off
- user_agent_header="User-Agent: SBC"
- ####### Modules Section ########
- #set module path
- mpath="/zxa/server/opensips/lib/modules/"
- loadmodule "db_text.so"
- loadmodule "signaling.so"
- loadmodule "sl.so"
- loadmodule "tm.so"
- loadmodule "rr.so"
- loadmodule "maxfwd.so"
- loadmodule "textops.so"
- loadmodule "mi_fifo.so"
- loadmodule "usrloc.so"
- loadmodule "acc.so"
- loadmodule "uri.so"
- loadmodule "rtpproxy.so"
- loadmodule "nat_traversal.so"
- loadmodule "nathelper.so"
- #loadmodule "userblacklist.so"
- modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")
- #modparam("permissions", "default_allow_file", "/zxa/server/opensips/config/permissions.allow")
- modparam("nat_traversal", "keepalive_state_file", "/zxa/server/opensips/config/nat_keepalive_state")
- modparam("rr", "append_fromtag", 0)
- modparam("uri", "use_uri_table", 0)
- modparam("rtpproxy","rtpproxy_sock", "udp:127.0.0.1:7980")
- modparam("usrloc", "db_mode", 0)
- modparam("acc", "log_level", 2)
- modparam("acc", "log_flag", 2)
- modparam("acc", "log_facility", "LOG_LOCAL0")
- modparam("acc", "report_cancels", 1)
- modparam("acc", "detect_direction", 0)
- modparam("acc", "failed_transaction_flag", 4)
- modparam("acc", "service_type", 15)
- ####### Routing Logic ########
- # main request routing logic
- route{
- xlog("=== TOP ===\n");
- xlog("%%%% tu= $tu | fu= $fu | od= $od | ReceivedINT: $Ri | SourceIP: $si %%%\n");
- #if (!check_address("1","$si","$sp","$proto"))
- #{
- # xlog("=== ACCESS FAILED ===\n");
- # xlog("=== $si| $sp | $proto ===\n");
- # sl_send_reply("403","Forbidden A");
- # exit;
- #}
- if (!mf_process_maxfwd_header("10"))
- {
- xlog("=== TOO MANY HOPS ===\n");
- sl_send_reply("483","Too Many Hops");
- exit;
- }
- #---- NAT Detection ----#
- force_rport();
- if (nat_uac_test("18")) && !($od =~ "^10\.*") {
- xlog("***** NAT YES *****\n");
- fix_nated_contact();
- xlog("fix sdp\n");
- fix_nated_sdp("8","EXTERNAL_IP");
- setflag(5);
- }
- #CANCEL processing
- if (is_method("CANCEL"))
- {
- xlog("=== CANCEL ===\n");
- if (t_check_trans())
- t_relay();
- exit;
- }
- if (is_method("PUBLISH"))
- {
- sl_send_reply("503", "Service Unavailable");
- exit;
- }
- if (has_totag())
- {
- xlog("=== HAS TO TAG ===\n");
- if (loose_route())
- {
- xlog("=== HAS LOOSE ===\n");
- if (is_method("BYE"))
- {
- xlog("=== LOOSE BYE ===\n");
- setflag(1); # Accounting bye
- } else if (is_method("INVITE")) {
- xlog("=== RE-INVITE LOOSE ===\n");
- if( $od =~ "^10\.*")
- {
- xlog("^^^^ DEST INTERNAL ^^^^\n");
- $avp(gw_attrs) = "internal";
- }
- record_route();
- }
- xlog("In loouse going to Route 1\n");
- route(1);
- } else {
- if ( is_method("ACK") )
- {
- xlog("=== LOOSE ELSE ACK ===\n");
- if ( t_check_trans() )
- {
- t_relay();
- exit;
- } else {
- xlog("=== LOOSE Discard ACK ===\n");
- exit;
- }
- }
- sl_send_reply("404","Not here");
- }
- exit;
- }
- t_check_trans();
- if (loose_route())
- {
- xlog("L_ERR","Attempt to route with preloaded Route's [$fu/$tu/$ru/$ci]\n");
- if (!is_method("ACK"))
- {
- sl_send_reply("403","Preload Route denied");
- exit;
- }
- }
- # record routing
- if (!is_method("REGISTER|MESSAGE"))
- {
- record_route();
- }
- if ($rU==NULL)
- {
- # request with no Username in RURI
- sl_send_reply("484","Address Incomplete");
- exit;
- }
- if (is_method("INVITE") && (!has_totag()) )
- {
- xlog("((((((((( NEW CALL ))))))))))\n");
- route(1);
- send_reply("420", "Invalid Extension");
- exit;
- }
- }
- route[1] {
- rewritehostport("OUTBOUNT SIP");
- #---- RTP Proxy handling ---#
- xlog("=== ROUTE 1 ===\n");
- if (isflagset(5)){
- search_append('Contact:.*sip:[^>[:cntrl:]]*', ';nat=yes');
- }
- if (subst_uri('/(sip:.*);nat=yes/\1/')){
- setbflag(6);
- }
- if (is_method("BYE|CANCEL"))
- {
- unforce_rtp_proxy();
- }
- if (has_body("application/sdp"))
- {
- if ( $avp(gw_attrs) != "internal" )
- {
- append_hf("P-hint: EI \r\n");
- rtpproxy_offer("EI","EXTERNAL_IP");
- } else {
- append_hf("P-hint: IE \r\n");
- rtpproxy_offer("IE","INTERNAL_IP");
- }
- }
- force_send_socket("EXTERNAL_IP");
- t_on_branch("1");
- t_on_reply("1");
- t_on_failure("1");
- if (!t_relay())
- {
- sl_reply_error();
- }
- exit;
- }
- branch_route[1] {
- xlog("new branch at $ru\n");
- }
- onreply_route[1] {
- xlog("=== ON REPLY ROUTE 2 rs= $rs | fu= $fu | od= $od | si= $si | Ri= $Ri ===\n");
- if ( status=~"(180)|(183)|(2[0-9][0-9])" )
- {
- if ($Ri == "INTERNAL_IP")
- {
- append_hf("P-hint: RR EI \r\n");
- rtpproxy_answer("EI","EXTERNAL_IP");
- } else {
- append_hf("P-hint: RR IE \r\n");
- rtpproxy_answer("IE","INTERNAL_IP");
- }
- }
- if (isbflagset(6)) {
- fix_nated_contact();
- }
- }
- failure_route[1] {
- xlog("=== FAIL ROUTE 2 ===\n");
- unforce_rtp_proxy();
- if (t_was_cancelled())
- {
- exit;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement