[SR-Users] failure_route does not fire up after
Mino Haluz
mino.haluz at gmail.com
Tue Oct 12 10:07:06 CEST 2010
Hi,
I've been struggling with this problem very long time and I am starting to
be quite desperate.
I'm trying to implement voicemail redirection after 15 secs of ringing. So I
set fr_inv_timer, set the event handler with t_on_failure. But after 15secs
of ringing the failture_route block does not execute at all, the transaction
is lost and after these 15 secs it has strange behaviour (the phone is still
ringing, even after the other side has cancelled the call).
I'm attaching the configuration without sensitive data. Please tell me
whether problem is in the configuration or somewhere outside of kamailio.
Thanks for any suggestion.
#!ifdef ACCDB_COMMENT
ALTER TABLE acc ADD COLUMN src_user VARCHAR(64) NOT NULL DEFAULT '';
ALTER TABLE acc ADD COLUMN src_domain VARCHAR(128) NOT NULL DEFAULT '';
ALTER TABLE acc ADD COLUMN dst_ouser VARCHAR(64) NOT NULL DEFAULT '';
ALTER TABLE acc ADD COLUMN dst_user VARCHAR(64) NOT NULL DEFAULT '';
ALTER TABLE acc ADD COLUMN dst_domain VARCHAR(128) NOT NULL DEFAULT '';
ALTER TABLE missed_calls ADD COLUMN src_user VARCHAR(64) NOT NULL DEFAULT
'';
ALTER TABLE missed_calls ADD COLUMN src_domain VARCHAR(128) NOT NULL
DEFAULT '';
ALTER TABLE missed_calls ADD COLUMN dst_ouser VARCHAR(64) NOT NULL DEFAULT
'';
ALTER TABLE missed_call ADD COLUMN dst_user VARCHAR(64) NOT NULL DEFAULT
'';
ALTER TABLE missed_calls ADD COLUMN dst_domain VARCHAR(128) NOT NULL
DEFAULT '';
#!endif
#
-----------------------------------------------------------------------------------------
#!define WITH_MYSQL
#!define WITH_AUTH
#!define WITH_USRLOCDB
#!define WITH_NAT
#
-----------------------------------------------------------------------------------------
####### Global Parameters #########
#!ifdef WITH_DEBUG
debug=4
log_stderror=yes
#!else
debug=2
log_stderror=no
#!endif
memdbg=5
memlog=5
log_facility=LOG_LOCAL7
fork=yes
#fork=yes
children=4
/* uncomment the next line to disable TCP (default on) */
#disable_tcp=yes
/* uncomment the next line to disable the auto discovery of local aliases
based on revers DNS on IPs (default on) */
#auto_aliases=no
/* uncomment and configure the following line if you want Kamailio to
bind on a specific interface/port/proto (default bind on all available)
*/
listen=udp:1.1.1.1:5060
#
-----------------------------------------------------------------------------------------
alias=test
#
-----------------------------------------------------------------------------------------
port=5060
####### Custom Parameters #########
# These parameters can be modified runtime via RPC interface
# - see the documentation of 'cfg_rpc' module.
#
# Format: group.id = value 'desc' description
# Access: $sel(cfg_get.group.id) or @cfg_get.group.id
#
####### Modules Section ########
#set module path
#mpath="/usr/local/lib/kamailio/modules_k/:/usr/local/lib/kamailio/modules/"
mpath="/lib/kamailio/modules_k/:/lib/kamailio/modules/"
/* uncomment next line for MySQL DB support */
#!ifdef WITH_MYSQL
loadmodule "db_mysql.so"
#!endif
loadmodule "mi_fifo.so"
loadmodule "kex.so"
loadmodule "tm.so"
loadmodule "tmx.so"
loadmodule "sl.so"
loadmodule "rr.so"
loadmodule "pv.so"
loadmodule "maxfwd.so"
loadmodule "usrloc.so"
loadmodule "registrar.so"
loadmodule "textops.so"
loadmodule "uri_db.so"
loadmodule "siputils.so"
loadmodule "xlog.so"
loadmodule "sanity.so"
loadmodule "ctl.so"
loadmodule "mi_rpc.so"
loadmodule "acc.so"
# Addition modules
#
-----------------------------------------------------------------------------------------
loadmodule "avpops.so"
loadmodule "regex.so"
loadmodule "sqlops.so"
loadmodule "dialog.so"
loadmodule "call_control.so"
loadmodule "mediaproxy.so"
loadmodule "siptrace.so"
loadmodule "mi_datagram.so"
loadmodule "group.so"
loadmodule "permissions.so"
#
-----------------------------------------------------------------------------------------
modparam("mi_datagram", "socket_name", "/var/run/kamailio/kamailio.sock")
# The name of a UNIX SOCKET used by Callcontrol
modparam("dialog", "dlg_flag", 4)
#modparam("call_control", "disable", 0)
#modparam("call_control", "signaling_ip_avp", "$avp(s:signaling_ip)")
#
-----------------------------------------------------------------------------------------
modparam("sqlops","sqlcon","ca=>mysql:/") # The definition of a DB
connection
modparam("mediaproxy", "mediaproxy_socket",
"/var/run/mediaproxy/dispatcher.sock") # Path to the filesystem socket
where the mediaproxy dispatcher listens for commands
#
-----------------------------------------------------------------------------------------
modparam("tm", "ruri_matching", 1)
modparam("tm", "restart_fr_on_each_reply", 0) # Final response timer
will be re-triggered for each received provisional reply
#modparam("tm", "fr_timer", 15000) # Timer which hits if no final
reply for an INVITE arrives (15 sec)
modparam("tm", "fr_inv_timer", 15000) # Timer which hits if no
final reply for an INVITE arrives (15 sec)
#
-----------------------------------------------------------------------------------------
modparam("siptrace", "db_url", "") # Database URL
modparam("siptrace", "traced_user_avp", "$avp(s:traced_user)")
modparam("siptrace", "trace_on", 1)
modparam("siptrace", "trace_flag", 22) # Flag is used to
mark messages to trace
#
-----------------------------------------------------------------------------------------
# Radius settings
modparam("acc", "failed_transaction_flag", 1)
modparam("acc", "report_cancels", 0)
modparam("acc", "report_ack", 0)
modparam("acc", "early_media", 0)
modparam("acc", "log_level", 1)
modparam("acc", "log_flag", 1)
modparam("acc", "log_missed_flag", 1)
modparam("acc", "radius_config",
"/etc/radiusclient-ng/radiusclient.conf") # This is the location of
the configuration file of radius client
modparam("acc", "radius_flag", 1)
modparam("acc", "radius_missed_flag", 1)
modparam("acc", "radius_extra", "User-Name=$Au; \
Calling-Station-Id=$from; \
Called-Station-Id=$to; \
Sip-Translated-Request-URI=$avp(s:translated_uri); \
Sip-RPid=$avp(s:rpid); \
Source-IP=$si; \
Source-Port=$sp; \
Canonical-URI=$avp(s:can_uri); \
Billing-Party=$avp(s:billing_party); \
Divert-Reason=$avp(s:divert_reason); \
X-RTP-Stat=$hdr(X-RTP-Stat); \
Contact=$hdr(contact); \
Event=$hdr(event); \
SIP-Proxy-IP=$avp(s:sip_proxy_ip); \
ENUM-TLD=$avp(s:enum_tld)")
#
-----------------------------------------------------------------------------------------
#!ifdef WITH_AUTH
loadmodule "auth.so"
loadmodule "auth_db.so"
#!endif
/* uncomment next line for aliases support
NOTE: a DB (like db_mysql) module must be also loaded */
#loadmodule "alias_db.so"
/* uncomment next line for multi-domain support
NOTE: a DB (like db_mysql) module must be also loaded
NOTE: be sure and enable multi-domain support in all used modules
(see "multi-module params" section ) */
loadmodule "domain.so"
#!ifdef WITH_PRESENCE
loadmodule "presence.so"
loadmodule "presence_xml.so"
#!endif
#!ifdef WITH_NAT
loadmodule "nathelper.so"
#!endif
loadmodule "uac.so"
# ----------------- setting module-specific parameters ---------------
# --- enable CLI with append_rpid_hf ---
modparam("auth", "rpid_prefix", "<sip:")
modparam("auth", "rpid_suffix", "@1.1.1.1;user=phone>;party=calling;
screen=yes; privacy=off")
#modparam("auth", "rpid_avp", "$avp(s:rpid)")
# ----- mi_fifo params -----
#
-----------------------------------------------------------------------------------------
modparam("mi_fifo", "fifo_name", "/tmp/kamailio_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", 1)
# ----- rr params -----
modparam("registrar", "method_filtering", 1)
/* uncomment the next line to disable parallel forking via location */
# modparam("registrar", "append_branches", 0)
/* uncomment the next line not to allow more than 10 contacts per AOR */
#modparam("registrar", "max_contacts", 10)
# ----- uri_db params -----
/* by default we disable the DB support in the module as we do not need it
in this configuration */
modparam("uri_db", "use_uri_table", 0)
modparam("uri_db", "db_url", "mysql://")
modparam("domain", "db_url", "mysql://")
# ----- 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)
modparam("acc", "log_extra",
"src_user=$fU;src_domain=$fd;dst_ouser=$tU;dst_user=$rU;dst_domain=$rd")
/* enhanced DB accounting */
#!ifdef WITH_ACCDB
modparam("acc", "db_flag", 1)
modparam("acc", "db_missed_flag", 2)
modparam("acc", "db_url",
"mysql://")
modparam("acc", "db_extra",
"src_user=$fU;src_domain=$fd;dst_ouser=$tU;dst_user=$rU;dst_domain=$rd")
#!endif
# ----- usrloc params -----
/* enable DB persistency for location entries */
#!ifdef WITH_USRLOCDB
modparam("usrloc", "db_mode", 2)
modparam("usrloc", "db_url",
"mysql://")
#!endif
# ----- auth_db params -----
/* enable the DB based authentication */
#!ifdef WITH_AUTH
modparam("auth_db", "calculate_ha1", yes)
modparam("auth_db", "password_column", "password")
modparam("auth_db", "db_url",
"mysql://")
modparam("auth_db", "load_credentials", "rpid")
#!endif
# -- group params --
/* for grp mysql table usage - groups - siptrace, blocked*/
modparam("group", "db_url", "mysql://")
modparam("group", "table", "grp")
modparam("group", "user_column", "username")
modparam("group", "domain_column", "domain")
modparam("group", "group_column", "grp")
# -- permissions params --
/* for trusted table usage and other functions - other modparam are default
*/
modparam("permissions", "db_url", "mysql://")
modparam("permissions", "db_mode", 1)
# ----- alias_db params -----
/* uncomment the following lines if you want to enable the DB based
aliases */
#modparam("alias_db", "db_url",
# "mysql://")
# ----- domain params -----
/* uncomment the following lines to enable multi-domain detection
support */
#modparam("domain", "db_url",
# "mysql://")
#modparam("domain", "db_mode", 1) # Use caching
# ----- multi-module params -----
/* uncomment the following line if you want to enable multi-domain support
in the modules (dafault off) */
#modparam("alias_db|auth_db|usrloc|uri_db", "use_domain", 1)
# ----- presence params -----
/* enable presence server support */
#!ifdef WITH_PRESENCE
modparam("presence|presence_xml", "db_url",
"mysql://")
modparam("presence_xml", "force_active", 1)
modparam("presence", "server_address", "sip:10.0.0.10:5060")
#!endif
# ----- nathelper -----
#!ifdef WITH_NAT
#modparam("nathelper", "rtpproxy_sock", "udp:127.0.0.1:7722")
#modparam("nathelper", "natping_interval", 30)
#modparam("nathelper", "ping_nated_only", 1)
#modparam("nathelper", "sipping_bflag", 7)
#modparam("nathelper", "sipping_from",
"sip:pinger at kamailio.org<sip%3Apinger at kamailio.org>
")
modparam("registrar|nathelper", "received_avp", "$avp(i:80)")
modparam("usrloc", "nat_bflag", 6)
#!endif
####### Routing Logic ########
# main request routing logic
route{
#------------SANITY
CHECK----------------------------------------------------------------
xlog("L_INFO","XLOG
****************START*($rm)*S_IP($si)*CallID($ci)*********************");
if (!mf_process_maxfwd_header("10")) {
sl_send_reply("483","Too Many Hops");
xlog("L_INFO","XLOG: Too many hops man");
xlog("L_INFO","XLOG: exiting
----------------------------------------");
exit;
}
if(!sanity_check("1511", "7"))
{
xlog("L_INFO","XLOG: Malformed SIP message");
xlog("Malformed SIP message from $si:$sp\n");
xlog("L_INFO","XLOG: exiting
----------------------------------------");
exit;
}
# NAT detection
xlog("L_INFO", "XLOG: Performing NAT detection");
route(NAT);
if (has_totag()) {
# sequential request withing a dialog should
# take the path determined by record-routing
if (loose_route()) {
xlog("L_INFO", "XLOG: loose_route()");
if (is_method("BYE")) {
xlog('L_INFO', 'XLOG: Method is BYE');
setflag(1); # do accounting ...
setflag(3); # ... even if the transaction fails
# end_media_session();
}
route(RELAY);
} else {
if (is_method("SUBSCRIBE") && uri == myself) {
xlog('L_INFO', 'XLOG: Method is SUBSCRIBE and uri ==
myself');
# in-dialog subscribe requests
route(PRESENCE);
#!ifndef WITH_PRESENCE
#added by yenkee
sl_send_reply("403", "Not Allowed");
#!endif
xlog("L_INFO","XLOG: exiting
----------------------------------------");
exit;
}
if ( is_method("ACK") ) {
xlog('L_INFO', 'XLOG: Method is 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
xlog('L_INFO', 'XLOG: t_check_trans()');
t_relay();
xlog("L_INFO","XLOG: exiting
----------------------------------------");
exit;
} else {
xlog('L_INFO', 'XLOG: ACK without matching transaction
... ignore and discard.');
#added by yenkee
sl_send_reply("403", "Not Allowed");
xlog("L_INFO","XLOG: exiting
----------------------------------------");
exit;
}
}
sl_send_reply("404","Not here");
xlog("L_INFO", "XLOG: 404 Not Here
----------------------------------");
}
xlog("L_INFO","XLOG: exiting
----------------------------------------");
exit;
}
#initial requests
# CANCEL processing
if (is_method("CANCEL"))
{
xlog('L_INFO', 'XLOG: Method is CANCEL');
if (t_check_trans())
t_relay();
xlog("L_INFO","XLOG: exiting
----------------------------------------");
exit;
}
t_check_trans();
# authentication
route(AUTH);
setflag(1);
# record routing for dialog forming requests (in case they are routed)
# - remove preloaded route headers
remove_hf("Route");
if (is_method("INVITE|SUBSCRIBE"))
record_route();
# account only INVITEs
if (is_method("INVITE")) {
xlog("L_INFO","XLOG: Method is INVITE");
setflag(1); # do accounting
#
-----------------------------------------------------------------------------------------
$avp(s:can_uri) = $ru; # Canonical-URI will be used for
rating the session
xlog("L_INFO", "XLOG: Engaging Media Proxy");
engage_media_proxy(); # Automatically call use_media_proxy /
end_media_proxy on every request and reply that belongs to the dialog
#
-----------------------------------------------------------------------------------------
}
if (!uri==myself)
/* replace with following line if multi-domain support is used */
##if (!is_uri_host_local())
{
xlog("L_INFO","XLOG: Appeding Hf P-hing: outbound");
append_hf("P-hint: outbound\r\n");
route(RELAY);
}
# requests for my domain
if( is_method("PUBLISH|SUBSCRIBE"))
route(PRESENCE);
if (is_method("REGISTER"))
{
if(isflagset(5))
{
setbflag("6");
# uncomment next line to do SIP NAT pinging
## setbflag("7");
}
if (!save("location"))
sl_reply_error();
xlog("L_INFO","XLOG: exiting
----------------------------------------");
exit;
}
if ($rU==$null) {
# request with no Username in RURI
sl_send_reply("484","Address Incomplete");
xlog("L_INFO","XLOG: exiting
----------------------------------------");
exit;
}
# ---------ENABLING SIP
TRACE--------------------------------------------------------------
# Enable sip tracing for users in grp siptrace in mysql db ( nema vplyv na
zapisovanie acc informacii )
if (is_user_in("From", "siptrace") ) {
xlog("L_INFO","XLOG: Starting sip_trace for From-URI:($fu)");
setflag(22);
# sip_trace(); # mne sip_trace nefungoval iba setflag , ak
sa nastavi flag na hodnotu v modparam bude robit cdr tool sip tracy
}
# route(PSTN);
#
-----------------------------------------------------------------------------------------
# apply DB based aliases (uncomment to enable)
##alias_db_lookup("dbaliases");
if (is_method("INVITE")) {
#------------BLOCK
NUMBER-----------------------------------------------------------------
# Block username
if ( is_user_in("From", "blocked")) {
xlog("L_INFO", "XLOG: [main route] Account ($fu) to ($ru) is
blocked");
sl_send_reply("403", " Account blocked ");
xlog("L_INFO","XLOG: exiting
----------------------------------------");
exit;
}
#
-----------------------------------------------------------------------------------------
# Call control allows one to limit the duration of calls and
automatically end them when they exceed the imposed limit
xlog("L_INFO","XLOG: Before call_control() var rm = ($rm)");
call_control();
switch ($retcode) {
case 2:
# Call with no limit
xlog("L_INFO", "XLOG: [call_control] Call with no limit");
break;
case 1:
# Call with a limit under callcontrol management (either
prepaid or postpaid)
xlog("L_INFO", "XLOG: [call_control] Call with a limit under
callcontrol management");
break;
case -1:
# Not enough credit (prepaid call)
xlog("L_INFO", "XLOG: Call control: not enough credit for
prepaid call");
acc_rad_request("402");
sl_send_reply("402", "Not enough credit");
xlog("L_INFO","XLOG: exiting
----------------------------------------");
exit;
break;
case -2:
# Locked by call in progress (prepaid call)
xlog("L_INFO", "XLOG: Call control: prepaid call locked by
another call in progress");
acc_rad_request("403");
sl_send_reply("403", "Call locked by another call in
progress");
xlog("L_INFO","XLOG: exiting
----------------------------------------");
exit;
break;
default:
# Internal error (message parsing, communication, ...)
xlog("L_INFO", "XLOG: Call control: internal server error");
acc_rad_request("500");
sl_send_reply("500", "Internal server error");
xlog("L_INFO","XLOG: exiting
----------------------------------------");
exit;
}
#
-----------------------------------------------------------------------------------------
#
-----------------------------------------------------------------------------------------
# Return error message when you are calling on your own number
# fU - From username
# tU - To username
if ($fU==$tU) {
sl_send_reply("403","Forbidden calling own number");
xlog("L_INFO","XLOG: Call on your own number: Request-URI:($ru)
From-URI:($fu). Sending 403 Forbidden");
xlog("L_INFO","XLOG: exiting
----------------------------------------");
exit;
}
#
-----------------------------------------------------------------------------------------
}
#
-----------------------------------------------------------------------------------------
#
-----------------------------------------------------------------------------------------
#
-----------------------------------------------------------------------------------------
#
-----------------------------------------------------------------------------------------
xlog("L_INFO","XLOG: Performing lookup( location) ");
if (!lookup("location")) {
switch ($rc) {
case -1:
case -3:
t_newtran();
t_reply("404", "[local failed] Not Found");
xlog("L_INFO","XLOG: exiting
----------------------------------------");
exit;
break;
# commented - not used with PSTN
case -2:
sl_send_reply("405", "Method Not Allowed");
xlog("L_INFO","XLOG: exiting
----------------------------------------");
exit;
}
#
-----------------------------------------------------------------------------------------
#
-----------------------------------------------------------------------------------------
#
-----------------------------------------------------------------------------------------
# Replacing plus sign with 00
if ($ru=~".*sip:\+.*@.*") { # Check if URI contains
plus sign
$avp(s:to)=$ru;
avp_subst("$avp(s:to)", "/(sip:)\+/sip:00/"); # Replace plus
sign with 00
avp_pushto("$ru", "$avp(s:to)"); # Push the value of AVP
with name into the SIP message as Request-URI
xlog("L_INFO","XLOG: Replacing plus sign in Request-URI ($ru)");
}
#
-----------------------------------------------------------------------------------------
#
-----------------------------------------------------------------------------------------
}
# when routing via usrloc, log the missed calls also
setflag(2);
route(RELAY);
}
route[RELAY] {
xlog("L_INFO", "XLOG: [RELAY] Jumped to route(RELAY)");
#!ifdef WITH_NAT
if (check_route_param("nat=yes")) {
xlog("L_INFO","XLOG: [RELAY] check_route_param('nat=yes') == 1");
setbflag("6");
}
if (isflagset(5) || isbflagset("6")) {
xlog("L_INFO","XLOG: [RELAY] isflagset(5) && isbflagset(6)");
route(RTPPROXY);
}
#!endif
#
-----------------------------------------------------------------------------------------
/* example how to enable some additional event routes */
if (is_method("INVITE")) {
# $avp(s:callee_fr_inv_timer) = 10;
xlog("L_INFO", "XLOG: [RELAY] Routing of failure and reply
messages");
# t_on_branch("BRANCH_ONE");
t_set_fr(10000);
t_on_reply("REPLY_ONE");
t_on_failure("1"); # Registering failure route
}
if (!t_relay()) {
sl_reply_error();
}
xlog("L_INFO","XLOG: exiting FROM RELAY
------------------------------------");
exit;
}
# Presence server route
route[PRESENCE]
{
#!ifdef WITH_PRESENCE
if (!t_newtran())
{
sl_reply_error();
xlog("L_INFO","XLOG: exiting
----------------------------------------");
exit;
};
if(is_method("PUBLISH"))
{
handle_publish();
t_release();
}
else
if( is_method("SUBSCRIBE"))
{
handle_subscribe();
t_release();
}
xlog("L_INFO","XLOG: exiting ----------------------------------------");
exit;
#!endif
# if presence enabled, this part will not be executed
if (is_method("PUBLISH") || $rU==$null)
{
sl_send_reply("404", "Not here");
xlog("L_INFO","XLOG: exiting
----------------------------------------");
exit;
}
return;
}
# Authentication route
route[AUTH] {
xlog("L_INFO", "XLOG: Jumped to route[AUTH]");
#!ifdef WITH_AUTH
if (is_method("REGISTER"))
{
xlog("L_INFO","XLOG: [AUTH] Register pred ifom From-URI:($fu)");
# authenticate the REGISTER requests (uncomment to enable auth)
if (!www_authorize("", "subscriber"))
{
xlog("L_INFO", "XLOG: [AUTH] www_challenge()");
www_challenge("", "0");
xlog("L_INFO","XLOG: exiting
----------------------------------------");
exit;
}
if ($au!=$tU)
{
xlog("L_INFO", "XLOG: [AUTH] Forbidden auth ID From-URI:($fu)");
sl_send_reply("403","Forbidden auth ID");
xlog("L_INFO","XLOG: exiting
----------------------------------------");
exit;
}
} else {
# authenticate if from local subscriber (uncomment to enable auth)
if (from_uri==myself)
{
xlog("L_INFO","XLOG: [AUTH] Message is not REGISTER, and
from_uri == myself");
if (!proxy_authorize("", "subscriber")) {
xlog("L_INFO", "XLOG: [AUTH] proxy_challenge()");
xlog("L_INFO","XLOG: exiting
----------------------------------------");
proxy_challenge("", "0");
exit;
}
if (is_method("PUBLISH"))
{
if ($au!=$tU) {
sl_send_reply("403","Forbidden auth ID");
xlog("L_INFO","XLOG: exiting
----------------------------------------");
exit;
}
} else {
if ($au!=$fU) {
sl_send_reply("403","Forbidden auth ID");
xlog("L_INFO","XLOG: exiting
----------------------------------------");
exit;
}
}
xlog("L_INFO","XLOG: [AUTH] consumer_credentials()");
consume_credentials();
# caller authenticated
}
}
#!endif
return;
}
# Caller NAT detection route
route[NAT]{
#!ifdef WITH_NAT
force_rport();
xlog("L_INFO", "XLOG: Checking nat_uac_test('19')");
if (nat_uac_test("19")) {
if (method=="REGISTER") {
xlog("L_INFO", "XLOG: fix_nated_register()");
fix_nated_register();
} else {
xlog("L_INFO", "XLOG: fix_nated_contact()");
fix_nated_contact();
}
setflag(5);
}
#!endif
return;
}
# RTPProxy control
route[RTPPROXY] {
xlog("L_INFO","XLOG: Jumped to route[RTPPROXY]");
#!ifdef WITH_NAT
# if (is_method("BYE")) {
# unforce_rtp_proxy();
# } else if (is_method("INVITE")){
# force_rtp_proxy();
# }
if (!has_totag()) {
add_rr_param(";nat=yes");
xlog("L_INFO","XLOG: Adding RR param(';nat=yes')");
}
#!endif
return;
}
# PSTN GW routing
route[PSTN] {
#!ifdef WITH_PSTN
# check if PSTN GW IP is defined
if (strempty($sel(cfg_get.pstn.gw_ip))) {
xlog("SCRIPT: PSTN rotuing enabled but pstn.gw_ip not defined\n");
return;
}
# route to PSTN dialed numbers starting with '+' or '00'
# (international format)
# - update the condition to match your dialing rules for PSTN routing
if(!($rU=~"^(\+|00)[1-9][0-9]{3,20}$"))
return;
# only local users allowed to call
if(from_uri!=myself) {
sl_send_reply("403", "Not Allowed");
xlog("L_INFO","XLOG: exiting
----------------------------------------");
exit;
}
$ru = "sip:" + $rU + "@" + $sel(cfg_get.pstn.gw_ip);
route(RELAY);
xlog("L_INFO","XLOG: exiting ----------------------------------------");
exit;
#!endif
return;
}
# Sample branch router
branch_route[BRANCH_ONE] {
xlog("L_INFO","XLOG: BRANCH ROUTE ");
exit;
}
# Sample onreply route
onreply_route[REPLY_ONE] {
#xdbg("incoming reply\n");
xlog("L_INFO","XLOG: REPLY ROUTE ");
#!ifdef WITH_NAT
# if ((isflagset(5) || isbflagset("6")) && status=~"(183)|(2[0-9][0-9])")
{
# force_rtp_proxy();
# }
if (isbflagset("6")) {
fix_nated_contact();
}
#!endif
}
# Sample failure route
failure_route[1] {
#!ifdef WITH_NAT
# if (is_method("INVITE")
# && (isbflagset("6") || isflagset(5))) {
# unforce_rtp_proxy();
# }
#!endif
xlog("L_INFO","XLOG
****************FAILROUTE*($rm)*S_IP($si)**CallID($ci)********************");
if (t_is_canceled()) {
xlog("L_INFO","XLOG: exiting
----------------------------------------");
exit;
}
#
-----------------------------------------------------------------------------------------
# Forward call on Voicemail when spefified SIP Status Code is returned.
Failure route registered using t_on_failure.
# 486 - Busy Here
# 408 - Request Timeout
# 480 Temporarily Unavailable
# if (t_check_status("486|408|480")) {
if (t_check_status("486|408")) {
xlog("L_INFO","XLOG: [failure route] Forwarding on Voicemail");
}
#
-----------------------------------------------------------------------------------------
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20101012/ba2fef47/attachment-0001.htm>
More information about the sr-users
mailing list