Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- route{
- if (!mf_process_maxfwd_header("10")) {
- sl_send_reply("483","Too Many Hops");
- exit;
- }
- if($ua=~"friendly-scanner"){
- drop();
- }
- if ($Ri == "192.168.88.1") {
- ### - Call from Internal Network
- ### - if $Ri is equal to the IP address set on our Internal Interface then
- ### - the SIP message came from an internal device
- route(FromInternal);
- }
- if ($Ri == "99.XX.XX.161") {
- ### - Call from External Network
- ### - if $Ri is equal to the IP address set on our Outside Interface then
- ### - the SIP message came from the internet
- if ($si == "50.XX.XX.156") {
- ### - We want to make sure the SIP message
- ### - came from our SIP PBX in the cloud
- ### - so $si needs to equal our IP address
- route(FromExternal);
- }
- }
- exit;
- }
- route[FromInternal] {
- if (is_method("REGISTER")){
- ### - We want to save the internal
- ### - devices contact uri so that when messages
- ### - come from the PBX we know how to route to the device
- save("irock.com","mr","$fu");
- };
- if(!is_method("REGISTER|MESSAGE")){
- record_route();
- };
- if (has_totag()) {
- # sequential request withing a dialog should
- # take the path determined by record-routing
- if (loose_route()) {
- if (is_method("BYE")) {
- #setflag(1); # do accounting ...
- #setflag(3); # ... even if the transaction fails
- } else if (is_method("INVITE")) {
- # even if in most of the cases is useless, do RR for
- # re-INVITEs alos, as some buggy clients do change route set
- # during the dialog.
- record_route();
- }
- force_send_socket(99.XX.XX.161:5060);
- t_relay("udp:50.XX.XX.156:5060");
- } else {
- if ( is_method("ACK") ) {
- if ( t_check_trans() ) {
- # non loose-route, but stateful ACK; must be an ACK after
- # a 487 or e.g. 404 from upstream server
- force_send_socket(99.XX.XX.161:5060);
- t_relay("udp:50.XX.XX.156:5060");
- exit;
- } else {
- # ACK without matching transaction ->
- # ignore and discard
- exit;
- }
- }
- sl_send_reply("404","Not here");
- }
- exit;
- }
- # 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;
- }
- lookup("irock.com");
- force_send_socket(99.XX.XX.161:5060);
- t_relay("udp:50.XX.XX.156:5060");
- exit;
- }
- route[FromExternal] {
- if (has_totag()) {
- # sequential request withing a dialog should
- # take the path determined by record-routing
- if (loose_route()) {
- if (is_method("BYE")) {
- #setflag(1); # do accounting ...
- #setflag(3); # ... even if the transaction fails
- } else if (is_method("INVITE")) {
- # even if in most of the cases is useless, do RR for
- # re-INVITEs alos, as some buggy clients do change route set
- # during the dialog.
- record_route();
- }
- # route it out to whatever destination was set by loose_route()
- # in $du (destination URI).
- t_relay();
- } else {
- if ( is_method("ACK") ) {
- if ( t_check_trans() ) {
- # non loose-route, but stateful ACK; must be an ACK after
- # a 487 or e.g. 404 from upstream server
- t_relay();
- exit;
- } else {
- # ACK without matching transaction ->
- # ignore and discard
- exit;
- }
- }
- sl_send_reply("404","Not here");
- }
- exit;
- }
- lookup("irock.com");
- ### - SIP message is from our SIP Proxy
- t_relay();
- exit;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement