[OpenSIPS-Users] Change in SDP/RTP routing with Opensips 1.4 and 1.6

Chris Stone axisml at gmail.com
Mon Feb 7 19:10:24 CET 2011


On Mon, Feb 7, 2011 at 10:35 AM, Ovidiu Sas <osas at voipembedded.com> wrote:
> You are re-posting the same question again without providing any
> additional info:
> http://lists.opensips.org/pipermail/users/2011-February/016626.html

Sorry, did not see my original message in my Gmail sent messages, or a
reply - so, figured it did not get sent and resent.

> Have you checked if the your config is altering the SDP?
> Check the SDP for the same message before coming to your opensips
> server and after leaving the opensips server.
> If the SDP is altered and the IP in SDP is pointing to your opensips
> server, then there is your problem.

The config does nothing with the SDP. The config is nearly identical
(is identical functionality wise) to what we're running with Opensips
1.4. Was there some 'default' behavior change between 1.4 and 1.6 that
might be the cause?

For reference, here's our config for the 1.6 installation:

####### Global Parameters #########

#debug=3
debug=9
log_stderror=no
#log_facility=LOG_LOCAL0

fork=yes
children=25

/* uncomment the following lines to enable TLS support  (default off) */
#disable_tls = no
#listen = tls:your_IP:5061
#tls_verify_server = 1
#tls_verify_client = 1
#tls_require_client_certificate = 0
#tls_method = TLSv1
#tls_certificate = "/etc/opensips/tls/user/user-cert.pem"
#tls_private_key = "/etc/opensips/tls/user/user-privkey.pem"
#tls_ca_list = "/etc/opensips/tls/user/user-calist.pem"

port=5060

sip_warning=1
tos=IPTOS_LOWDELAY

####### Modules Section ########

#set module path
mpath="/usr/lib64/opensips/modules"

/* uncomment next line for MySQL DB support */
loadmodule "signaling.so"
loadmodule "sl.so"
loadmodule "tm.so"
loadmodule "rr.so"
loadmodule "maxfwd.so"
loadmodule "textops.so"
loadmodule "mi_fifo.so"
loadmodule "uri.so"
loadmodule "acc.so"
loadmodule "avpops.so"

loadmodule "perl.so"

# originate/terminate permissions
loadmodule "permissions.so"

# dispatcher
loadmodule "dispatcher.so"

# ----------------- setting module-specific parameters ---------------

# ----- mi_fifo params -----
modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")


# ----- rr params -----
# add value to ;lr param to cope with most of the UAs
modparam("rr", "enable_full_lr", 1)
# do not append from tag to the RR (no need for this script)
modparam("rr", "append_fromtag", 0)


# ----- uri params -----
modparam("uri", "use_uri_table", 0)


# ----- acc params -----
/* what sepcial events should be accounted ? */
modparam("acc", "early_media", 1)
modparam("acc", "report_ack", 1)
modparam("acc", "report_cancels", 1)
/* by default ww do not adjust the direct of the sequential requests.
   if you enable this parameter, be sure the enable "append_fromtag"
   in "rr" module */
modparam("acc", "detect_direction", 0)
/* account triggers (flags) */
modparam("acc", "failed_transaction_flag", 3)
modparam("acc", "log_flag", 1)
modparam("acc", "log_missed_flag", 2)
/* uncomment the following lines to enable DB accounting also */
modparam("acc", "db_flag", 1)
modparam("acc", "db_missed_flag", 2)


# ----- perl params -----
modparam("perl", "modpath", "/usr/lib64/opensips/modules/")
modparam("perl", "filename", "/usr/local/sbin/perl_sql_routing.pl")


# ----- permissions params -----
modparam("permissions", "default_deny_file", "/etc/opensips/permissions.deny")
modparam("permissions", "default_allow_file", "/etc/opensips/permissions.allow")


# ----- dispatcher params ----
modparam("dispatcher","list_file","/etc/opensips/dispatcher.list")
modparam("dispatcher","force_dst",1)
modparam("dispatcher","flags",3)
modparam("dispatcher", "dst_avp", "$avp(i:271)")
modparam("dispatcher", "grp_avp", "$avp(i:272)")
modparam("dispatcher", "cnt_avp", "$avp(i:273)")


####### Routing Logic ########


# main request routing logic

route{

        if (!mf_process_maxfwd_header("32")) {
                xlog("L_ERR", " <$rm> from <$fu> to <$tu> r-uri <$ru>
src_ip <$si> [483 - Too Many Hops]\n");
                sl_send_reply("483","Too Many Hops");
                exit;
        }

        if (msg:len > 16384 ) {
                xlog("L_ERR", " <$rm> from <$fu> to <$tu> r-uri <$ru>
src_ip <$si> [413 - Message is too big - greater than 16384
bytes]\n");
                sl_send_reply("413", "Message is too big - greater
than 16384 bytes]");
                exit;
        };

        if (is_method("REGISTER")) {
                xlog("L_ERR", " <$rm> from <$fu> to <$tu> r-uri <$ru>
src_ip <$si> [503 - Registration Unavailable]\n");
                sl_send_reply("503"," Registration Unavailable via
this proxy - contact support at axint.net for assistance");
                exit;
        }

        if (is_method("PUBLISH"))
        {
                xlog("L_ERR", " <$rm> from <$fu> to <$tu> r-uri <$ru>
src_ip <$si> [503 - Publish Service Unavailable]\n");
                sl_send_reply("503", "Service Unavailable");
                exit;
        }

        if (has_totag()) {
                #xlog("L_ERR", "Request has_totag(). Request: <$rm>
from <$fu> to <$tu> r-uri <$ru> src_ip <$si>\n");
                # sequential request withing a dialog should
                # take the path determined by record-routing
                if (loose_route()) {
                        if (is_method("BYE")) {
                                #xlog("L_ERR", "Request is BYE - doing
accounting. Request: <$rm> from <$fu> to <$tu> r-uri <$ru> src_ip
<$si>\n");
                                setflag(1); # do accounting ...
                                setflag(3); # ... even if the transaction fails
                        } else if (is_method("INVITE")) {
                                #xlog("L_ERR", "Request is INVITE -
recording route. Request: <$rm> from <$fu> to <$tu> r-uri <$ru> src_ip
<$si>\n");
                                # 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).
                        #xlog("L_ERR", " <$rm> from <$fu> to <$tu>
r-uri <$ru> src_ip <$si> route(1 - BYE or reINVITE)\n");
                        route(1);
                } else {
                        /* uncomment the following lines if you want
to enable presence */
                        ##if (is_method("SUBSCRIBE") && $rd ==
"your.server.ip.address") {
                        ##      # in-dialog subscribe requests
                        ##      route(2);
                        ##      exit;
                        ##}
                        if ( is_method("ACK") ) {
                                if ( t_check_trans() ) {
                                        #xlog("L_ERR", " <$rm> from
<$fu> to <$tu> r-uri <$ru> src_ip <$si> route(relay ACK)\n");
                                        # non loose-route, but
stateful ACK; must be an ACK after
                                        # a 487 or e.g. 404 from upstream server
                                        t_relay();
                                        exit;
                                } else {
                                        #xlog("L_ERR", " <$rm> from
<$fu> to <$tu> r-uri <$ru> src_ip <$si> ruote(none - discarding
unmatched ACK)\n");
                                        # ACK without matching transaction ->
                                        # ignore and discard
                                        exit;
                                }
                        }
                        xlog("L_ERR", " <$rm> from <$fu> to <$tu>
r-uri <$ru> src_ip <$si> [404 - Not here]\n");
                        sl_send_reply("404","Not here");
                }
                exit;
        }

        #initial requests

        # CANCEL processing
        if (is_method("CANCEL"))
        {
                xlog("L_ERR", " <$rm> from <$fu> to <$tu> r-uri <$ru>
src_ip <$si> [200 - CANCEL request processing]\n");
                if (t_check_trans())
                        t_relay();
                exit;
        }

        t_check_trans();

        # preloaded route checking
        if (loose_route()) {
                #xlog("L_ERR", "loose_route(), so add P_hint
rr-enforced header and route request: <$rm> from <$fu> to <$tu> r-uri
<$ru> src_ip <$si>\n");
                # mark routing logic in request
               append_hf("P-hint: rr-enforced\r\n");
               route(1);
                exit;
        }

        # record routing
        if (!is_method("REGISTER|MESSAGE")) {
                #xlog("L_ERR", "Not REGISTER or MESSAGE, so recording
route for request: <$rm> from <$fu> to <$tu> r-uri <$ru> src_ip
<$si>\n");
                record_route();
        }

        # account only INVITEs
        if (is_method("INVITE")) {
                #xlog("L_ERR", "Is INVITE so do accounting for
request: <$rm> from <$fu> to <$tu> r-uri <$ru> src_ip <$si>\n");
                setflag(1); # do accounting
        }

        # do lookup with method filtering
#       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;
#               }
#       }

        if (is_method("ACK"))
        {
                xlog("L_ERR", "ACK - <$rm> from <$fu> to <$tu> r-uri
<$ru> src_ip <$si> [200 - OK]\n");
                if (t_check_trans())
                        t_relay();
                exit;
        }

        # verify user has rights to originate/terminate calls
        if (is_method("INVITE")) {
                if (!allow_routing()) {
                        xlog("L_ERR", " <$rm> from <$fu> to <$tu>
r-uri <$ru> src_ip <$si> [503 Service Unavailable (route denied)]\n");
                        sl_send_reply("503", " Service unavailable at
this time");
                        exit;
                };
                xlog("L_ERR", " ORIGINAL-INVITE [method=$rm, from=$fu,
to=$ru, src_ip=$si]\n");
        };

        # when routing via usrloc, log the missed calls also
        setflag(2);

        # prefix 1-areacode if seven digit dialing - use areacode from
 the from_uri (caller)
        if (uri=~"^sip:[0-9]{7}@") {
                if (from_uri=~"^sip:1303[0-9]{7}@") {
                        prefix("+1303");
                } else if (from_uri=~"^sip:1720[0-9]{7}@") {
                        prefix("+1720");
                } else if (from_uri=~"^sip:1970[0-9]{7}@") {
                        prefix("+1970");
                } else if (from_uri=~"^sip:1925[0-9]{7}@") {
                        prefix("+1925");
                } else if (from_uri=~"^sip:1312[0-9]{7}@") {
                        prefix("+1312");
                } else if (from_uri=~"^sip:1406[0-9]{7}@") {
                        prefix("+1406");
                } else if (from_uri=~"^sip:1415[0-9]{7}@") {
                        prefix("+1415");
                } else if (from_uri=~"^sip:1602[0-9]{7}@") {
                        prefix("+1602");
                } else if (from_uri=~"^sip:1631[0-9]{7}@") {
                        prefix("+1631");
                } else if (from_uri=~"^sip:1617[0-9]{7}@") {
                        prefix("+1617");
                } else if (from_uri=~"^sip:1909[0-9]{7}@") {
                        prefix("+1909");
                } else if (from_uri=~"^sip:1925[0-9]{7}@") {
                        prefix("+1925");
                } else if (from_uri=~"^sip:1305[0-9]{7}@") {
                        prefix("+1305");
                } else if (from_uri=~"^sip:1768[0-9]{7}@") {
                        prefix("+1768");
                } else if (from_uri=~"^sip:1505[0-9]{7}@") {
                        prefix("+1505");
                } else if (from_uri=~"^sip:1254[0-9]{7}@") {
                        prefix("+1254");
                } else if (from_uri=~"^sip:1480[0-9]{7}@") {
                        prefix("+1480");
                };
        };

        # prefix 1 for 10 digits dialed
        if (uri =~ "^sip:[0-9]{10}@") {
                prefix("+1");
        };

        # make sure the destination number has a + prefix
        if (uri =~ "^sip:[0-9]{7,}@") {
                prefix("+");
        };

        # determine call route to take from sql query in perl addin
module script
        $avp(i:369) = 10;
        perl_exec("get_route_sql");
#   avp_print();
        if ($avp(i:369) == "1") {
                route(1);               # route transaction replies
                exit;
        } else if ($avp(i:369) == "2") {
                route(2);               # route to voip01
                exit;
        } else if ($avp(i:369) == "3") {
                route(3);               # route to voip02
                exit;
        } else if ($avp(i:369) == "4") {
                route(4);               # route reply error
                exit;
        } else if ($avp(i:369) == "5") {
                # 2009-11-29 (cstone) - if 7, 10 or 11 digits on
destination number - route out to DASH
                if (uri =~ "^sip:\+?[0-9]{7}@") {
                xlog("L_ERR", "INVITE - 7 DIGIT DESTINATION - FORCED
route to DASH\n");
                        route(10);
                        exit;
                }
                if (uri =~ "^sip:\+?[0-9]{10,11}@") {
                xlog("L_ERR", "INVITE - 10 or 11 DIGIT DESTINATION -
FORCED route to DASH\n");
                        route(10);
                        exit;
                }
                if (uri =~ "^sip:\+?411@") {
                xlog("L_ERR", "INVITE - 411 DESTINATION - FORCED route
to DASH\n");
                        route(10);
                        exit;
                }
                # continue on through verizon
                route(5);               # route out to Verizon
                exit;
        } else if ($avp(i:369) == "6") {
                route(6);               # route out to GlobalPOP
                exit;
        } else if ($avp(i:369) == "7") {
                route(7);               # route to tranquility networks server 1
                exit;
        } else if ($avp(i:369) == "8") {
                route(8);               # route to inmate-relay server
                exit;
        } else if ($avp(i:369) == "9") {
                route(9);               # route to west-fax server
                exit;
        } else if ($avp(i:369) == "10") {
                route(10);              # route to out to dash
                exit;
        } else if ($avp(i:369) == "11") {
                route(11);              # route to demo server
                exit;
        } else if ($avp(i:369) == "12") {
                route(12);              # route to CoroWare server
                exit;
        } else if ($avp(i:369) == "13") {
                route(13);              # CALL KILLER ROUTE
                exit;
        } else if ($avp(i:369) == "14") {
                route(14);              # route to old inmate-relay server
                exit;
        } else if ($avp(i:369) == "15") {
                route(15);              # route to voip02 server
                exit;
        } else if ($avp(i:369) == "25") {
                route(25);              # route to new venus
                exit;
        }

   if (is_method("INVITE|BYE")) {
         xlog("L_ERR", "USING DEFAULT FALL THROUGH ROUTING TO DASH\n");
            route(10);
            exit;
        };

        route(1);
}


route[1] {
        # for INVITEs enable some additional helper routes
        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] {
   # strip the leading + sign from the To: uri
   subst_uri('/^sip:\+([0-9]+)@(.*)$/sip:\1@\2/i');
   replace_all("sip:\+","sip:");

   # send call to server voip01.axint.net
   xlog("L_ERR", " [method=$rm, from=$fu, to=$ru, src_ip=$si] =>
route(in to voip01)\n");
   forward("10.10.10.10");
   exit;
}

route[3] {
   # strip the leading + sign from the To: uri
   subst_uri('/^sip:\+([0-9]+)@(.*)$/sip:\1@\2/i');
   replace_all("sip:\+","sip:");

   # send call to server voip02.axint.net
   if (is_method("INVITE|BYE|CANCEL")) {
      xlog("L_ERR", " [method=$rm, from=$fu, to=$ru, src_ip=$si] =>
route(in to voip02)\n");
   };
   forward("10.10.10.11");
   exit;
}

route[4] {
   #if (!save("location")) {
      sl_reply_error();
   #};
}

# send calls to MCI/Verizon for routing to PSTN network (or other VoIP networks)
route[5] {
        if (is_method("OPTIONS")) {
                xlog("L_ERR", " <$rm> from <$fu> to <$tu> r-uri <$ru>
src_ip <$si> [503 OPTIONS to gateway invalid - not forwarding to
verizon]");
                sl_send_reply("503"," SIP OPTIONS packet to gateway
invalid - contact support at axint.net for assistance");
                exit;
        }

   # Add P-Asserted-Identity header field if not already present
   if (!is_present_hf("P-Asserted-Identity")) {
      xlog("L_ERR", " MCI/Verizon route - P-Asserted-Identity header
missing - adding to SIP request\n");
      $avp(i:678) = $fu;
      avp_subst("$avp(i:678)", "/sip:([0-9]+)@(.*)>?$/<sip:+\1@\2:5060>/");
      #avp_print();
      append_hf("P-Asserted-Identity: $avp(i:678)\r\n");
   };

   ds_select_domain("1","4");

   # log the call information
   xlog("L_ERR", " [method=$rm, from=$fu, to=$ru, src_ip=$si] =>
route(out to verizon)\n");

   forward();
   exit;
}

# send calls to GlobalPOP server (TESTING-TESTING)
route[6] {
   # log the call information
   xlog("L_ERR", " [method=$rm, from=$fu, to=$ru, src_ip=$si] =>
route(out to GlobalPOP)\n");

   forward("10.0.0.10");
   exit;
}

route[7] {
   # strip the leading + sign from the To: uri
   subst_uri('/^sip:\+([0-9]+)@(.*)$/sip:\1@\2/i');
   replace_all("sip:\+","sip:");

   # send call to server Tranquility Networks Asterisk server
   if (is_method("INVITE|BYE|CANCEL")) {
      xlog("L_ERR", " [method=$rm, from=$fu, to=$ru, src_ip=$si] =>
route(in to tranquility)\n");
   };
   forward("10.10.0.10");
   exit;
}

# send calls to inmate-relay server
route[8] {
   # strip the leading + sign from the To: uri
   subst_uri('/^sip:\+([0-9]+)@(.*)$/sip:\1@\2/i');
   replace_all("sip:\+","sip:");

   # send call to server inmate-relay.axint.net
   #if (is_method("INVITE|BYE|CANCEL")) {
      xlog("L_ERR", " [method=$rm, from=$fu, to=$ru, src_ip=$si] =>
route(in to inmate-relay)\n");
   #};
   forward("10.10.10.12");
   exit;
}

# send calls to West FAX server
route[9] {
   # strip the leading + sign from the To: uri
   subst_uri('/^sip:\+([0-9]+)@(.*)$/sip:\1@\2/i');
   replace_all("sip:\+","sip:");

   # send call to server West Fax Asterisk server
   if (is_method("INVITE|BYE|CANCEL")) {
      xlog("L_ERR", " [method=$rm, from=$fu, to=$ru, src_ip=$si] =>
route(in to west-fax)\n");
   };
   forward("10.10.100.10");
   exit;
}

# send calls to Dash for routing to PSTN network (or other VoIP networks)
route[10] {
        if (is_method("OPTIONS")) {
                xlog("L_ERR", " <$rm> from <$fu> to <$tu> r-uri <$ru>
src_ip <$si> [503 OPTIONS to gateway invalid - not forwarding to
dash]");
                sl_send_reply("503"," SIP OPTIONS packet to gateway
invalid - contact support at axint.net for assistance");
                exit;
        }

   #xlog("L_ERR", " [method=$rm, from=$fu, to=$ru, src_ip=$si] =>
route(preparing to route to dash)\n");

   ds_select_domain("2","4");

   # log the call information
   xlog("L_ERR", " [method=$rm, from=$fu, to=$ru, src_ip=$si] =>
route(out to dash)\n");

   forward();
   exit;
}

# send calls to Demo server
route[11] {
   # strip the leading + sign from the To: uri
   subst_uri('/^sip:\+([0-9]+)@(.*)$/sip:\1@\2/i');
   replace_all("sip:\+","sip:");

   # send call to server ScanOne server
   if (is_method("INVITE|BYE|CANCEL")) {
      xlog("L_ERR", " [method=$rm, from=$fu, to=$ru, src_ip=$si] =>
route(in to demo server)\n");
   };
   forward("10.10.10.13");
   exit;
}

# send calls to CoroWare server
route[12] {
   # strip the leading + sign from the To: uri
   subst_uri('/^sip:\+([0-9]+)@(.*)$/sip:\1@\2/i');
   replace_all("sip:\+","sip:");

   # send call to server ScanOne server
   if (is_method("INVITE|BYE|CANCEL")) {
      xlog("L_ERR", " [method=$rm, from=$fu, to=$ru, src_ip=$si] =>
route(in to CoroWare)\n");
   };
   forward("10.100.100.10");
   exit;
}

# CALL KILLER ROUTE
route[13] {
        xlog("L_ERR", " <$rm> from <$fu> to <$tu> r-uri <$ru> src_ip
<$si> [604 Does not exist anywhere - prohibited destination]\n");
        sl_send_reply("604","Does not exist anywhere - prohibited destination");
        exit;
}

# send calls to inmate-relay server
route[14] {
   # strip the leading + sign from the To: uri
   subst_uri('/^sip:\+([0-9]+)@(.*)$/sip:\1@\2/i');
   replace_all("sip:\+","sip:");

   # send call to server inmate-relay.axint.net
   if (is_method("INVITE|BYE|CANCEL")) {
      xlog("L_ERR", " [method=$rm, from=$fu, to=$ru, src_ip=$si] =>
route(in to old-inmate-relay)\n");
   };
   forward("10.10.10.15");
   exit;
}

# send calls to voip02 server
route[15] {
   # strip the leading + sign from the To: uri
   subst_uri('/^sip:\+([0-9]+)@(.*)$/sip:\1@\2/i');
   replace_all("sip:\+","sip:");

   # send call to server
   if (is_method("INVITE|BYE|CANCEL")) {
      xlog("L_ERR", " [method=$rm, from=$fu, to=$ru, src_ip=$si] =>
route(in to new-voip02)\n");
   };
   forward("10.10.10.20");
   exit;
}

# send call to server at PP
route[25] {
   # strip the leading + sign from the To: uri
   subst_uri('/^sip:\+([0-9]+)@(.*)$/sip:\1@\2/i');
   replace_all("sip:\+","sip:");

   # send call to server
   if (is_method("INVITE|BYE|CANCEL")) {
      xlog("L_ERR", " [method=$rm, from=$fu, to=$ru, src_ip=$si] =>
route(in to venus)\n");
   };

   if (is_method("INVITE")) {
          create_dialog();
          engage_media_proxy();
   }

   forward("10.10.10.25");
   exit;
}


branch_route[2] {
        xlog("new branch at $ru\n");
}


onreply_route[2] {
        xlog("incoming reply\n");
}


failure_route[1] {
        if (t_was_cancelled()) {
                exit;
        }

        # uncomment the following lines if you want to block client
        # redirect based on 3xx replies.
        ##if (t_check_status("3[0-9][0-9]")) {
        ##t_reply("404","Not found");
        ##      exit;
        ##}

        # uncomment the following lines if you want to redirect the failed
        # calls to a different new destination
        ##if (t_check_status("486|408")) {
        ##      sethostport("192.168.2.100:5060");
        ##      # do not set the missed call flag again
        ##      t_relay();
        ##}
}

error_route {
        xlog("--- error route class=$(err.class) level=$(err.level)
info=$(err.info) rcode=$(err.rcode) rreason=$(err.rreason) ---\n");
        xlog("--- error from [$si:$sp]\n+++++\n$mb\n++++\n");
        sl_send_reply("$err.rcode", "$err.rreason");
        exit;
}




Chris



More information about the Users mailing list