########################################################################
# This configuration is autogenerated by sip:wizard
# (http://www.sipwise.com/wizard) on Mon Sep 01 11:11:27 +0200 2008
# for OpenSER 1.2
#
# Copyright (C) 2007 Sipwise (support@sipwise.com)
########################################################################
########################################################################
# By obtaining, using, and/or copying this configuration and/or its
# associated documentation, you agree that you have read, understood,
# and will comply with the Terms of Usage provided at
#
http://www.sipwise.com/news/?page_id=6 as well as the following
# additions:
#
# Permission to use, copy, modify, and distribute this configuration and
# its associated documentation for any purpose and without fee is hereby
# granted, provided that the above copyright notice appears in all
# copies, and that both that copyright notice and this permission notice
# appear in supporting documentation, and that the name of Sipwise or
# the author will not be used in advertising or publicity pertaining to
# distribution of the configuration without specific, written prior
# permission.
########################################################################
########################################################################
# Before using this configuration, read the following prerequisites in
# order to gain the designated functionallity:
#
# base:
# You have to insert all locally served domains (i.e.
# "openserctl domain add your.domain.com").
#
########################################################################
########################################################################
# Configuration 'sip:wizard - Mon Sep 01 11:11:27 +0200 2008'
########################################################################
advertised_address="192.168.5.3"
mpath = "//lib/kamailio/modules"
children = 8
debug = 4
fork = yes
disable_tcp = no
log_facility = LOG_DAEMON
log_stderror = no
tcp_children = 4
mhomed = no
server_signature = yes
reply_to_via = no
sip_warning = no
check_via = no
dns = no
rev_dns = no
disable_core_dump = no
dns_try_ipv6 = yes
dns_use_search_list = yes
loadmodule "usrloc.so"
modparam("usrloc", "user_column", "username")
modparam("usrloc", "domain_column", "domain")
modparam("usrloc", "contact_column", "contact")
modparam("usrloc", "expires_column", "expires")
modparam("usrloc", "q_column", "q")
modparam("usrloc", "callid_column", "callid")
modparam("usrloc", "cseq_column", "cseq")
modparam("usrloc", "methods_column", "methods")
modparam("usrloc", "flags_column", "flags")
modparam("usrloc", "user_agent_column", "user_agent")
modparam("usrloc", "received_column", "received")
modparam("usrloc", "socket_column", "socket")
modparam("usrloc", "use_domain", 0)
modparam("usrloc", "desc_time_order", 0)
modparam("usrloc", "timer_interval", 60)
modparam("usrloc", "db_url", "mysql://openser:openserrw@localhost/openser")
modparam("usrloc", "db_mode", 1)
modparam("usrloc", "matching_mode", 0)
modparam("usrloc", "cseq_delay", 20)
loadmodule "uri.so"
loadmodule "rr.so"
#modparam("rr", "enable_full_lr", 1)
#modparam("rr", "append_fromtag", 1)
#modparam("rr", "enable_double_rr", 1)
#modparam("rr", "add_username", 0)
# ----- 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)
loadmodule "tm.so"
modparam("tm", "fr_timer", 30)
modparam("tm", "fr_inv_timer", 120)
modparam("tm", "wt_timer", 5)
modparam("tm", "delete_timer", 2)
#modparam("tm", "noisy_ctimer", 0)
modparam("tm", "ruri_matching", 1)
modparam("tm", "via1_matching", 1)
modparam("tm", "unix_tx_timeout", 2)
modparam("tm", "restart_fr_on_each_reply", 1)
modparam("tm", "pass_provisional_replies", 0)
loadmodule "xlog.so"
modparam("xlog", "buf_size", 4096)
modparam("xlog", "force_color", 5)
loadmodule "mi_fifo.so"
modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")
loadmodule "domain.so"
modparam("domain", "db_url", "mysql://openser:openserrw@localhost/openser")
modparam("domain", "db_mode", 1)
modparam("domain", "domain_table", "domain")
modparam("domain", "domain_col", "domain")
loadmodule "sl.so"
modparam("sl", "enable_stats", 1)
loadmodule "registrar.so"
modparam("registrar", "default_expires", 3600)
modparam("registrar", "min_expires", 60)
modparam("registrar", "max_expires", 0)
modparam("registrar", "default_q", 0)
modparam("registrar", "append_branches", 1)
modparam("registrar", "case_sensitive", 0)
modparam("registrar", "received_param", "received")
modparam("registrar", "max_contacts", 0)
modparam("registrar", "retry_after", 0)
modparam("registrar", "method_filtering", 0)
modparam("registrar", "path_mode", 2)
modparam("registrar", "path_use_received", 0)
loadmodule "maxfwd.so"
modparam("maxfwd", "max_limit", 256)
loadmodule "db_mysql.so"
modparam("db_mysql", "ping_interval", 300)
modparam("db_mysql", "auto_reconnect", 1)
loadmodule "auth.so"
modparam("auth", "nonce_expire", 300)
modparam("auth", "rpid_suffix", ";party=calling;id-type=subscriber;screen=yes")
modparam("auth", "rpid_avp", "$avp(s:rpid)")
loadmodule "auth_db.so"
modparam("auth_db", "db_url", "mysql://openser:openserrw@localhost/openser")
modparam("auth_db", "user_column", "username")
modparam("auth_db", "domain_column", "domain")
modparam("auth_db", "password_column", "password")
modparam("auth_db", "password_column_2", "ha1b")
modparam("auth_db", "calculate_ha1", 1)
modparam("auth_db", "use_domain", 0)
modparam("auth_db", "load_credentials", "rpid")
loadmodule "uri_db.so"
#modparam("uri_db", "db_url", "mysql://openser:openserrw@localhost/openser")
#modparam("uri_db", "uri_table", "uri")
#modparam("uri_db", "uri_user_column", "username")
#modparam("uri_db", "uri_domain_column", "domain")
#modparam("uri_db", "uri_uriuser_column", "uri_user")
#modparam("uri_db", "subscriber_table", "subscriber")
#modparam("uri_db", "subscriber_user_column", "username")
#modparam("uri_db", "subscriber_domain_column", "domain")
#modparam("uri_db", "use_uri_table", 0)
#modparam("uri_db", "use_domain", 0)
loadmodule "textops.so"
loadmodule "group.so"
loadmodule "uac.so"
loadmodule "avpops.so"
modparam("avpops", "db_url", "mysql://openser:openserrw@localhost/openser")
modparam("avpops", "avp_table", "usr_preferences")
modparam("avpops", "use_domain", 0)
modparam("avpops", "uuid_column", "uuid")
modparam("avpops", "username_column", "username")
modparam("avpops", "domain_column", "domain")
modparam("avpops", "attribute_column", "attribute")
modparam("avpops", "value_column", "value")
modparam("avpops", "type_column", "type")
loadmodule "permissions.so"
modparam("permissions", "db_mode", 1)
modparam("permissions", "trusted_table", "trusted")
modparam("permissions", "db_url", "mysql://openser:openserrw@localhost/openser")
loadmodule "acc.so"
modparam("acc", "radius_config","/usr/local/etc/radiusclient/radiusclient.conf")
modparam("acc", "radius_flag",2)
modparam("acc", "radius_missed_flag", 3)
#modparam("acc", "radius_extra", "Sip-Src-IP=$si;Sip-Src-Port=$sp")
#modparam("acc", "radius_extra", "User-Name=$Au; Calling-Station-Id=$from; Called-Station-Id=$to; Sip-Translated-Request-URI=$ruri; Sip-RPid=$avp(s:rpid);")
modparam("acc", "radius_extra", "User-Name=$Au; Calling-Station-Id=$from; Called-Station-Id=$to; Sip-Translated-Request-URI=$ruri; 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)")
modparam("acc", "failed_transaction_flag", 4)
########################################################################
# Request route 'main'
########################################################################
route[0]
{
#xlog("L_INFO", "New request - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");
#if (is_method("INVITE")){xlog("L_INFO", "New request - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");}
if (!is_method("REGISTER|OPTIONS")){xlog("L_INFO", "New request - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");}
if(msg:len > max_len)
{
xlog("L_INFO", "Message too big - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");
sl_send_reply("513", "Message Too Big");
exit;
}
record_route();
if (!mf_process_maxfwd_header("100"))
{
xlog("L_INFO", "Too many hops - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");
sl_send_reply("483", "Too Many Hops");
exit;
}
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
}
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() ) {
# 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.\n");
exit;
}
}
sl_send_reply("404","Not here");
}
exit;
}
if(is_method("REGISTER"))
{
route(1);
}
if(is_method("INVITE"))
{
route(3);
}
if(is_method("CANCEL") || is_method("ACK"))
{
route(7);
}
route(

;
}
########################################################################
# Request route 'base-route-register'
########################################################################
route[1]
{
#xlog("~~~~~~~~~~~~~~~~~~ROUTE 1~~~~~~~~~~~~~~~~~~~~~~");
sl_send_reply("100", "Trying");
if(!www_authorize("", "subscriber"))
#if(!proxy_authorize("", "subscriber"))
{
#xlog("L_INFO", "Register authentication failed - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");
www_challenge("", "0");
#proxy_challenge("", "0");
exit;
}
# if(!check_to())
# {
#
# xlog("L_INFO", "Spoofed To-URI detected - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");
# sl_send_reply("403", "Spoofed To-URI Detected");
# exit;
# }
consume_credentials();
save("location");
#xlog("L_INFO", "Registration successful - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");
exit;
}
########################################################################
# Request route 'base-outbound'
########################################################################
route[2]
{
xlog("~~~~~~~~~~~~~~~~~~ROUTE 2~~~~~~~~~~~~~~~~~~~~~~");
#append_branch();
#t_on_failure("1");
#t_on_reply("1");
# if(!isflagset(21))
# {
#
# t_on_failure("1");
# }
# if(isflagset(29))
# {
# append_branch();
# }
# if(is_present_hf("Proxy-Authorization"))
# {
# consume_credentials();
# }
#
xlog("L_INFO", "Request leaving server, D-URI='$du' - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");
# no 100 (we already sent it) and no DNS blacklisting
if(!t_relay("0x05"))
{
#sl_reply_error();
}
exit;
}
########################################################################
# Request route 'base-route-invite'
########################################################################
route[3]
{
xlog("~~~~~~~~~~~~~~~~~~ROUTE 3~~~~~~~~~~~~~~~~~~~~~~");
if(!is_from_local()){setflag(15);}
if (uri=~"^sip:18[0-9]{2}@") {
xlog(" NUMERIS PRASIDEDA 18 IR YRA 2 skaitmenys ");
route(10);
exit;}
if (uri=~"^sip:117@") {
xlog(" NUMERIS PRASIDEDA 117 IR YRA 3 skaitmenys ");
strip(3);
prefix("37052104154");
append_branch();
rewritehostport("192.168.5.2");
route(2);
}
# if (is_from_local() || is_user_in("from","vilnius")) {
# xlog("USER IS IN VILNIUS");
if (is_from_local()) {
if (uri=~"^sip:8[1-9].") {
xlog(" PIRMAS REGEXPR PRAEJO numeris prasideda 8 ir 9 skaitmenys ");
strip(1);
# route(6);
}
if (uri=~"^sip:00[1-9].") {
xlog(" ANTRAS REGEXPR PRAEJO numeris prasideda 00 ");
strip(2);
prefix("1031"); #######################reikia nuimti 2 nuliukus
xlog("L_INFO", "Call to foreign domain TIESIAI I GEITWEJU SU 1031 PREFIXU - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");
rewritehostport("192.168.5.2");
#append_branch();
route(2);
exit;}
if (uri=~"^sip:[2-9][0-9]{6}@") {
xlog(" TRECIAS REGEXPR PRAEJO numeris prasideda 2-9 ir 7 skaitmenys. cia skirta laidinams ");
if (is_from_local()){ prefix("5");}
#route(6);
};
#if (uri=~"^sip:370[0-9]{8}@") {
#xlog(" ketvirtas REGEXPR PRAEJO numeris prasideda 370 ir 11 skaitmenu ");
# strip(3);
# route(6);
# }
#xlog(" !");
#if (uri=~"^sip:[0-9].") {
# xlog(" 5TAS REGEXPR PRAEJO pasakom zmogui kad era tokio numerio ");
# prefix("926");
# rewritehostport("192.168.5.1");
# append_branch();
# route(2);}
#}
}
if (is_user_in("from","kaunas")) {
xlog("USER IS IN KAUNAS");
if (uri=~"^sip:8[0-9]{8}@") {
xlog(" PIRMAS REGEXPR PRAEJO numeris prasideda 8 ir 9 skaitmenys ");
strip(1);
route(6);
}
if (uri=~"^sip:00[1-9]@") {
xlog(" ANTRAS REGEXPR PRAEJO numeris prasideda 00 ");
strip(2);
prefix("1031"); #######################reikia nuimti 2 nuliukus
xlog("L_INFO", "Call to foreign domain TIESIAI I GEITWEJU SU 1031 PREFIXU - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");
rewritehostport("192.168.5.2");
append_branch();
route(2);
exit;}
if (uri=~"^sip:[2-9][0-9]{5}@") {
xlog(" TRECIAS REGEXPR PRAEJO numeris prasideda 2-9 ir 7 skaitmenys. cia skirta laidiniams ");
prefix("37");
route(6);
}
if (uri=~"^sip:370[0-9]{8}@") {
xlog(" ketvirtas REGEXPR PRAEJO numeris prasideda 370 ir 11 skaitmenu ");
strip(3);
route(6);
}
# if (uri=~"^sip:[0-9].") {
# xlog(" 5TAS REGEXPR PRAEJO pasakom zmogui kad era tokio numerio ");
# prefix("926");
# rewritehostport("192.168.5.1");
# append_branch();
# route(2);}
xlog("nepraejo NEVIENAS regexpas!");
}
sl_send_reply("100", "Trying");
if(allow_trusted()){ xlog("allow trusted"); route(4);}
xlog("not allow trusted");
if(!www_authorize("", "subscriber") || !proxy_authorize("", "subscriber"))
#if(!proxy_authorize("", "subscriber"))
{
xlog("L_INFO", "Proxy authentication failed - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");
proxy_challenge("", "0");
exit;
}
# if(!check_from())
# {
#
# xlog("L_INFO", "Spoofed From-URI detected - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");
# sl_send_reply("403", "Spoofed From-URI Detected");
# exit;
# }
route(4);
}
########################################################################
# Request route 'invite-find-callee'
########################################################################
route[4]
{
xlog("~~~~~~~~~~~~~~~~~~ROUTE 4~~~~~~~~~~~~~~~~~~~~~~");
if(!is_domain_local("$rd"))
{
setflag(20);
route(6);
}
if(does_uri_exist())
{
xlog("L_INFO", "Callee is local - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");
route(5);
}
else
{
xlog("L_INFO", "Callee is not local - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");
route(6);
}
exit;
}
########################################################################
# Request route 'invite-to-internal'
########################################################################
route[5]
{
xlog("~~~~~~~~~~~~~~~~~~ROUTE 5~~~~~~~~~~~~~~~~~~~~~~");
t_on_failure("1");
if(!lookup("location"))
{
xlog("L_INFO", "LOCAL USER IS OFFLINE - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");
prefix("924");
rewritehostport("192.168.5.1");
append_branch();
route(2);
exit;
#sl_send_reply("404", "User Offline");
}
else
{
xlog("L_INFO", "Local user online - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");
setflag(2);
route(2);
}
exit;
}
########################################################################
# Request route 'invite-to-external'
########################################################################
route[6]
{
xlog("~~~~~~~~~~~~~~~~~~ROUTE 6~~~~~~~~~~~~~~~~~~~~~~");
#t_on_failure("1");
if(isflagset(15)){
xlog(" IS ISORES Y ISORE. negalima taip. nuskambes pranesimas ");
prefix("925");
rewritehostport("192.168.5.1");
append_branch();
route(2);
exit;
}
append_hf("P-hint: outbuond \r\n");
prefix("370");
xlog("L_INFO", "|||||||||||||||||Call to foreign domain - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");
#uac_replace_from("batman","+37066205555");
#uac_replace_from("+370asasas$fu", "ASASAD");
#rewriteuri("+37066205409");
#xlog("L_INFO", "TURETU PAKAEIST FU - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");
rewritehostport("192.168.5.2");
#append_branch();
setflag(2);
route(2);
exit;
}
########################################################################
# Request route 'base-route-local'
########################################################################
route[7]
{
xlog("~~~~~~~~~~~~~~~~~~ROUTE 7~~~~~~~~~~~~~~~~~~~~~~");
#t_on_reply("1");
if(t_check_trans())
{
xlog("L_INFO", "Request leaving server - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");
if(!t_relay())
{
sl_reply_error();
}
}
else
{
xlog("L_INFO", "Dropping mis-routed request - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");
}
exit;
}
########################################################################
# Request route 'base-route-generic'
########################################################################
route[8]
{
#xlog("~~~~~~~~~~~~~~~~~~ROUTE 8~~~~~~~~~~~~~~~~~~~~~~");
if (!is_method("OPTIONS")){xlog("L_INFO", "Method not supported - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");}
sl_send_reply("501", "Method Not Supported Here");
exit;
}
########################################################################
# Request route 'base-filter-failover'
########################################################################
route[9]
{
xlog("~~~~~~~~~~~~~~~~~~ROUTE 9~~~~~~~~~~~~~~~~~~~~~~");
if(t_check_status("500|501|502|503|504|505")){
xlog("L_INFO", "SERVERIO KLAIDA ISKILO - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");
exit;
}
xlog("L_INFO","Received failure cause $T_reply_code from $si to $du");
if (t_check_status("486")) {
exit;
revert_uri();
prefix("926");#turi but 926
xlog("L_INFO","Stepped into the 486 ruri=<$ru>");
rewritehostport("192.168.5.1");
#append_branch();
route(2);
exit;
};
if (t_check_status("408") || t_check_status("480")) {
revert_uri();
prefix("926");
xlog("L_INFO","Stepped into the 480 ruri=<$ru>");
rewritehostport("192.168.5.1");
append_branch();
route(2);
exit;
};
if (t_check_status("404")){# || t_check_status("484")) {
xlog("L_INFO","Stepped into the 404 duri=<$du> ruri=<$ru>");
revert_uri();
prefix("925");
xlog("L_INFO","Stepped into the 404 duri=<$du> ruri=<$ru> sourceip=<$si>");
rewritehostport("192.168.5.1");
append_branch();
route(2);
exit;
};
exit;
}
########################################################################
# Request route '18xx'
########################################################################
route[10]
{
xlog("~~~~~~~~~~~~~~~~~~ROUTE 10~~~~~~~~~~~~~~~~~~~~~");
xlog(" ROUTE _18xx ENTERED ");
if (uri=~"^sip:1800@") {
strip(4);
prefix("37052666662");
rewritehostport("192.168.5.2");
append_branch();
xlog(" 1800 NUMERIS SURINKTAS ");
route(2);
exit;}
if (uri=~"^sip:1802@") {
strip(4);
prefix("37057242024");
rewritehostport("192.168.5.2");
append_branch();
xlog(" 1802 NUMERIS SURINKTAS ");
route(2);
exit;}
if (uri=~"^sip:1810@") {
strip(4);
prefix("37052644020");
rewritehostport("192.168.5.2");
append_branch();
xlog(" 1810 NUMERIS SURINKTAS ");
route(2);
exit;}
if (uri=~"^sip:1813@") {
strip(4);
prefix("37052032233");
rewritehostport("192.168.5.2");
append_branch();
xlog(" 1800 NUMERIS SURINKTAS ");
route(2);
exit;}
}
########################################################################
# Reply route 'base-standard-reply'
########################################################################
onreply_route[1]
{
xlog("~~~~~~~~~~~~~~~~~~ONREPLY_ROUTE 1~~~~~~~~~~~~~~~~~~~~~~");
xlog("L_INFO", "REPLY ROUTE : Reply - S=$rs D=$rr F=$fu T=$tu IP=$si ID=$ci\n");
#route(9);
#exit;
}
########################################################################
# Failure route 'base-standard-failure'
########################################################################
failure_route[1]
{
xlog("~~~~~~~~~~~~~~~~~~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;
##}
if (t_check_status("486|408")) {
prefix("925");
#xlog("L_INFO","Stepped into the 404 duri=<$du> ruri=<$ru> sourceip=<$si>");
#rewritehostport("192.168.5.1");
sethostport("192.168.5.1:5060");
#append_branch();
# do not set the missed call flag again
t_relay();
}
xlog("L_INFO", "FAILURE ROUTE : Reply - S=$rs D=$rr F=$fu T=$tu IP=$si ID=$ci\n");
#route(9);
}