route { force_rport(); if (!mf_process_maxfwd_header("2")) { sl_send_reply("483","Too Many Hops"); exit; } if (has_totag()) { xlog("Into Existing Session method!\n"); if (loose_route()) { if ( $DLG_status!=NULL && !validate_dialog() ) { xlog("In-Dialog $rm from $si (callid=$ci) is not valid according to dialog\n"); } if (is_method("BYE")) { xlog("End Call!\n"); setflag(ACC_DO); setflag(ACC_FAILED); } else if (is_method("INVITE")) { record_route(); } route(relay); } else { if ( is_method("ACK") ) { if ( t_check_trans() ) { t_relay(); exit; } else { exit; } } sl_send_reply("404","Not here"); } exit; } if (is_method("CANCEL")) { xlog("Into cancel method line 265.\n"); if ( t_check_trans() ) { t_relay(); } exit; } t_check_trans(); 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; } if ( !(is_method("REGISTER") || (src_ip==192.168.1.30 && src_port==5060) ) ) { if (from_uri==myself) { } else { if (!uri==myself) { send_reply("403","Rely forbidden"); } } } if (!is_method("REGISTER|MESSAGE")) record_route(); if (is_method("INVITE")) { xlog("Into invite method.\n"); if ( !create_dialog("B") ) { send_reply("500","Internal Server Error"); exit; } setflag(ACC_DO); } if (is_method("PUBLISH|SUBSCRIBE")){ sl_send_reply("503","Service disabled"); } if (is_method("REGISTER")) { xlog("Into Register method line 304.\n"); if (!save("location")){ sl_reply_error(); } exit; } if ($rU==NULL) { sl_send_reply("484","Address Incomplete"); exit; } alias_db_lookup("dbaliases"); xlog("Recipient: $rU@$rd"); #FreeSWITCH route(freeswitch); #Outbound route(outbound); if (!lookup("location", "m")) { t_newtran(); t_reply("404", "Not Found"); exit; } setflag(ACC_MISSED); xlog("Reaching lowest Call Relay.\n"); route(relay); } route[outbound] { xlog("Jumped to Outbound.\n"); if(!is_method("INVITE")){ return; } if ($rU=~"^[1-9][0-9]+$") { xlog("FS tries to call PBX! $rU@$rd:$rp via $si"); $rd="192.168.1.30"; $rp="5060"; force_send_socket(udp:192.168.1.150:5060); xlog("FS tries to call PBX! $rU@$rd:$rp via $si"); route(relay); exit; } } route[freeswitch] { if(!is_method("INVITE")){ return; } if ( ($rU=~"^[5]$" || $rU=~"^[7]$") && src_ip==192.168.1.30 && src_port==5060) { xlog("PBX tries to call FS! $rU@$rd:$rp via $si"); $rd="10.250.5.50"; $rp="5090"; force_send_socket(udp:10.250.5.3:5080); route(relay); exit; } } route[relay] { if (is_method("INVITE")) { if (has_body("application/sdp") && $si=="192.168.1.30") { xlog("Offer rtpp Inbound.\n"); rtpproxy_offer("rei"); }else{ xlog("Offer rtpp Outbound.\n"); rtpproxy_offer("rie"); } t_on_branch("per_branch_ops"); t_on_reply("handle_nat"); t_on_failure("missed_call"); } if (is_method("CANCEL|BYE")) { rtpproxy_unforce(); } if (!t_relay()) { send_reply("500","Internal Error"); }; exit; } branch_route[per_branch_ops] { xlog("new branch at $ru\n"); } onreply_route[handle_nat] { if( is_method("ACK") && has_body("application/sdp")){ xlog("Answer rtpp reply\n"); rtpproxy_answer("rie"); } else if(has_body("application/sdp")) { xlog("Offer rtpp reply\n"); rtpproxy_offer("rei"); } xlog("incoming reply\n"); } failure_route[missed_call] { if (t_was_cancelled()) { xlog("Call cancelled.\n"); exit; } } local_route { if (is_method("BYE") && $DLG_dir=="UPSTREAM") { acc_db_request("200 Dialog Timeout", "acc"); } }