[Kamailio-Users] RES: Can someone help me?

Rafael Moreno Gomes rafael at matrixtelecom.net.br
Tue Jul 28 15:03:46 CEST 2009


Hi Raul

Here it is,

 

# ----------- global configuration parameters ------------------------

debug=3          

fork=yes

log_stderror=yes 

children=1

disable_tcp=no

log_facility=LOG_LOCAL0

 

# ------------------ module loading ----------------------------------

#set module path

mpath="/usr/lib/kamailio/modules/"

 

loadmodule "sl.so"

loadmodule "tm.so"

modparam("tm", "fr_timer", 5)

modparam("tm", "fr_inv_timer_avp", "$avp(i:704)")

loadmodule "rr.so"

loadmodule "usrloc.so"

loadmodule "maxfwd.so"

loadmodule "textops.so"

loadmodule "xlog.so"

loadmodule "avpops.so"

loadmodule "registrar.so"

loadmodule "uri_db.so"

loadmodule "db_mysql.so"

loadmodule "siputils.so"

loadmodule "auth.so"

loadmodule "auth_db.so"

loadmodule "mi_fifo.so"

loadmodule "acc.so"

loadmodule "pv.so"

modparam("mi_fifo", "fifo_name", "/tmp/openser_fifo")

 

loadmodule "lcr.so"

modparam("lcr", "db_url", "mysql://root:mypass@localhost/openser")

modparam("lcr", "gw_uri_avp", "$avp(i:709)")

modparam("lcr", "ruri_user_avp", "$avp(i:500)")

modparam("lcr", "rpid_avp", "$avp(i:302)")

modparam("lcr", "flags_avp", "$avp(i:712)")

 

# -------------------------  request routing logic -------------------

 

route{

 

                if (!mf_process_maxfwd_header("10")) {

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

                               exit;

                }

                route(4);

                if (has_totag()) {

                               if (loose_route()) {

                                               if (is_method("BYE")) {

                                                               setflag(1); 

                                                               setflag(3); 

                                               }

                                               route(1);

                               } else {

                                               if (is_method("SUBSCRIBE") &&
uri == myself) {

                                                               route(2);

                                                               exit;

                                               }

                                               if ( is_method("ACK") ) {

                                                               if (
t_check_trans() ) {

                

 
t_relay();

 
exit;

                                                               } else {

 
exit;

                                                               }

                                               }

                                               sl_send_reply("404","Not
here");

                               }

                               exit;

                }

                if (is_method("CANCEL"))

                {

                               if (t_check_trans())

                                               t_relay();

                               exit;

                }

 

                t_check_trans();

                route(3);

                if (!is_method("REGISTER|MESSAGE"))

                               record_route();

                if (is_method("INVITE")) {

                               setflag(1);

                }

                if (!uri==myself)

                if( is_method("PUBLISH|SUBSCRIBE"))

                               route(2);

 

                if (is_method("REGISTER"))

                {

                               if (!save("location"))

                                               sl_reply_error();

 

                               exit;

                }

 

                if ($rU==NULL) {

                               # request with no Username in RURI

                               sl_send_reply("484","Address Incomplete");

                               exit;

                }

                if (!lookup("location")) {

                               switch ($retcode) {

                                               case -1:

                                               case -3:

                                                               t_newtran();

 
t_reply("404", "Not Found");

                                                               exit;

                                               case -2:

 
sl_send_reply("405", "Method Not Allowed");

                                                               exit;

                               }

                }

                setflag(2);

 

                route(1);

}

 

 

route[1] {

                if (!t_relay()) {

                               sl_reply_error();

                };

                exit;

}

 

route[2] {

                if (!load_gws()) {

                               sl_send_reply("503", "Unable to load
gateways");

                               exit;

                } else {

                               $var(i) = 0;

                               while(is_avp_set("$(avp(i:709)[$var(i)])")) {

                                               xlog("L_INFO", "loading
gw_uri_avp[$var(i)]='$(avp(i:709)[$var(i)])'\n");

                                               $var(i) = $var(i) + 1;

                               };

                               if(is_avp_set("$avp(i:709)")) {

                                               xlog("L_INFO", "trying
gateway '$avp(i:709)'\n");

                               } else {

                                               xlog("L_INFO", "no available
gateways ...\n");

                               };

                               if (next_gw()) {

                                               xlog("L_INFO",
"ruri_user_avp='$avp(i:500)'\n");

                                               t_on_failure("2");

                                               route(1);

                               } else {

                                               sl_send_reply("503", "No
available gateways");

                                               exit;

                               };

                };

                exit;

}

 

 

failure_route[2] {

                xlog("L_INFO", "entering failure_route[2] for reply code
'$T_reply_code'\n");

                if (t_check_status("408|50[34]")) {

                               if(is_avp_set("$avp(i:709)")) {

                                               xlog("L_INFO", "trying next
gateway '$avp(i:709)'\n");

                               } else {

                                               xlog("L_INFO", "no more
gateways to try ...\n");

                               };

                               if (next_gw()) {

                                               t_on_failure("2");

                                               route(1);

                               } else {

                                               t_reply("503", "No
gateways");

                                               exit;

                               };

                               exit;

                };

}

 

Rafael Moreno

Matrix Telecom

www.matrixtelecom.net.br / Phone: 55.11.3323-9207

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20090728/a7ca1ccc/attachment.htm>


More information about the sr-users mailing list