[SR-Users] Strict routing configuration

julian arsanches guandulito.com at gmail.com
Fri Jun 7 23:03:31 CEST 2013


If anyone can help me on this one thanks before hand, i have a setup on
kamilio and everything has been working fine, i need to interface with a
huge carrier and they don't like the way kamailio sends the invites so i
need to implement stric routing .

now when kamailio sends an invite it goes like
 +0.000140 Kamailio:5060 -> CarrierIP:5060
INVITE sip:XXXXXX at Kamailio IP SIP/2.0.

Record-Route: <sip:Kamailio
IP;lr=on;ftag=as4640f260<sip:54.236.192.19;lr=on;ftag=as4640f260>
>.

Via: SIP/2.0/UDP Kamailio IP:5060;branch=z9hG4bK9156.eeb6fbf7.0.

Via: SIP/2.0/UDP Kamailio IP:5060;branch=z9hG4bK7aeceb75;rport=5060.

Max-Forwards: 16.

To: sip:XXXXXX at KAMAILIO
IP at 54.236.192.19<sip:85630573108863792 at 54.236.192.19@54.236.192.19>
.


and they wanted to receive it like this

INVITE sip:XXXXXX at CARRIER IP;user=phone SIP/2.0.

Via: SIP/2.0/UDP KAMAILIO IP:5062;

From: <sip:XXXXXX at KAMAILIOIP:5060;user=phone>;tag=514594693-3792808143-4087363760-57672641.

To: <sip:XXXXXXXX at CARRIERIP;user=phone>.

Call-ID: 8517ac46cfa811e2b038a0f3c1037003 at 204.2.202.12.

CSeq: 1 INVITE.


I dont know how to achieve this in kamailio, i am working fine with several
carriers using loose routing


here is my config any help is greatly apreciated

debug=4

log_stderror=yes

#!else

#debug=2

#log_stderror=yes

#!endif


memdbg=5

memlog=5


log_facility=LOG_LOCAL7


fork=yes

children=6


auto_aliases=no


#listen=udp:KAMAILIO IP

listen=udp:KAMAILIO IP:5060 advertise EXTERNALIP:5060



port=5060


enable_tls=no


#tcp_connection_lifetime=3605


#!ifdef WITH_SRCPATH

mpath="modules_k:modules"

#!else

mpath="/usr/lib64/kamailio/modules_k/:/usr/lib64/kamailio/modules/"

#path="/usr/lib64/kamailio/modules_k/:/usr/lib64/kamailio/modules/"

oadmodule "db_mysql.so"

loadmodule "tm.so"

loadmodule "sl.so"

loadmodule "acc.so"

loadmodule "rr.so"

loadmodule "maxfwd.so"

loadmodule "textops.so"

loadmodule "pv.so"

loadmodule "dispatcher.so"

loadmodule "usrloc.so"

loadmodule "registrar.so"

loadmodule "siputils.so"

loadmodule "sanity.so"

loadmodule "ctl.so"

loadmodule "mi_rpc.so"

loadmodule "avpops.so"

#!ifdef WITH_NAT

loadmodule "nathelper.so"

loadmodule "rtpproxy.so"

#!endif

loadmodule "xlog.so"

#mysqlcdr

modparam("acc", "db_flag", 2)

modparam("acc", "db_missed_flag", 3)

modparam("acc", "db_url", "mysql://some mysql server/openser")

modparam("acc", "db_extra", "some credentials" )


#loadmodule "carrierroute"


modparam("tm", "failure_reply_mode", 3)

modparam("tm", "fr_timer", 30000)

modparam("tm", "fr_inv_timer", 120000)


modparam("dispatcher", "list_file", "/etc/kamailio/dispatcher.lst")

modparam("rr", "enable_full_lr", 1)


!ifdef WITH_NAT

# ----- rtpproxy params -----

modparam("rtpproxy", "rtpproxy_sock", "udp:127.0.0.1:7722")


# ----- nathelper params -----

modparam("nathelper", "natping_interval", 30)

modparam("nathelper", "ping_nated_only", 1)

modparam("nathelper", "sipping_bflag", FLB_NATSIPPING)

modparam("nathelper", "sipping_from", "sip:pinger at kamailio.org")


# params needed for NAT traversal in other modules

modparam("nathelper|registrar", "received_avp", "$avp(RECEIVED)")

modparam("usrloc", "nat_bflag", FLB_NATB)

#!endif

modparam("xlog", "buf_size", 8192)

modparam("xlog", "force_color", 1)

#carrierroute

#modparam("carrierroute", "config_file", "/etc/kamailio/carrierroute.conf")

#end carrierroute


modparam("pv", "shvset", "ruta=s:$ru")




request_route {


        if (!mf_process_maxfwd_header("10")) {

                sl_send_reply("483","Too Many Hops");

                exit;

        }


#

        if(is_method("OPTIONS")) {

            # send reply for each options request

            sl_send_reply("200", "ok");

            exit();

         }

#

   if(method=="BYE") {

   #Account BYE transactions

setflag(2);

};


#CANCEL processing

if (method=="CANCEL") {

setflag(2);

if (t_check_trans()) t_relay();


exit;

};


#

       if (loose_route()) {

                        if(method=="BYE") {

   #Account BYE transactions

setflag(2);

};

##CANCEL processing

if (method=="CANCEL") {

setflag(3);

if (t_check_trans()) t_relay();


exit;

};

                        if (!t_relay()) {

                        sl_reply_error();

                }

                exit;

       }

   if (is_method("INVITE")) {


     # Account INVITE packets

setflag(2);

# Account Missed calls

setflag(3);

                record_route();



        }





#removed 1 from string

#(ai{s.substr,4,0});


xlog("before strip,< time [$Tf] > Aip= $src_ip, r-uri($ru\n");


#MYvariables

$var(x) = $ru;


$var(y)=$(var(x){s.substr,4,3});


$var(z)=$(var(y){s.int});


$var(t)=$(var(x){s.substr,7,0});



xlog("dsroute $var(z)fullruri($ru)\n");


xlog(">>>>>>>>>>>>>>>>>la header TO
$var(t)----------fullruri($ru)<<<<<<<<<<<<<<<<<<\n");


xlog("all---$Tf,$ct,$cs,<$cs>,callid-$ci,$re,$du,$rt,$ru,$si,$sp,$ua,$rm,$rs,$fn,$fd,$fu,$fU
");


strip(3);


xlog("after strip time [$Tf] method ($rm) via el code ($var(z)--
($var(y))\n");



ds_select_dst("$var(z)", "4");#carrer dynamic


#ds_select_dst("103", "4");#to change static carrier


xlog("print el destination y el $var(z) ($du)>>($td)>>> ($ru)\n");


xlog("errors---$err.info,$err.rcode,$err.rreason,$rc,$rc,$rc,$rr,--end
errors  ");


#remove_hf("To") ;

#$insert_hf("To: sip:$var(t)@$rd\r\n", "From"); # trying to change to header


  #if (!forward()){; #if forwarding

 # if(!t_relay()){;

     if (!t_relay_to_udp()) {#proxing


sl_reply_error();

exit;

};


}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20130607/2a4cd210/attachment-0001.html>


More information about the sr-users mailing list