#!KAMAILIO

####### Defined Values #########
#!define DBURL "mysql://kamailio:password@10.66.0.190/kamailio"

####### Features #########
#!define WITH_ANTIFLOOD
#!define WITH_CACHE

####### Flags #########
#!define FLT_ACC 1
#!define FLT_ACCMISSED 2
#!define FLT_ACCFAILED 3
#!define FLAG_FROMSUBSCRIBER 4
#!define FLAG_TOSUBSCRIBER 5
#!define FLAG_GATEWAY 6
#!define FLT_DLG 7
#!define FLB_NATB 8
#!define FLAG_TOVOICEMAIL 9
#!define FLAG_FORWARDEDCALL 10

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

debug=4
log_stderror=yes

memdbg=5
memlog=5

log_facility=LOG_LOCAL1

fork=yes
children=4
tcp_children=1

listen=udp:10.66.0.201:5060
listen=tcp:127.0.0.1:8080

# Control whether to throw or not error when there is no Content-Length header for requests received over TCP. 
tcp_accept_no_cl=yes

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

# set paths to location of modules (to sources or installation folders)
mpath="/usr/lib/x86_64-linux-gnu/kamailio/modules/"

loadmodule "jsonrpcs.so"
loadmodule "db_mysql.so"
loadmodule "kex.so"
loadmodule "corex.so"
loadmodule "tm.so"
loadmodule "tmx.so"
loadmodule "sl.so"
loadmodule "rr.so"
loadmodule "pv.so"
loadmodule "uac.so"
loadmodule "avpops.so"
loadmodule "maxfwd.so"
loadmodule "app_lua.so"
loadmodule "usrloc.so"
loadmodule "dmq.so"
loadmodule "dmq_usrloc.so"
loadmodule "auth.so"
loadmodule "auth_db.so"
loadmodule "textops.so"
loadmodule "textopsx.so"
loadmodule "siputils.so"
loadmodule "xlog.so"
loadmodule "sanity.so"
loadmodule "ctl.so"
loadmodule "cfg_rpc.so"
loadmodule "permissions.so"
loadmodule "domain.so"
loadmodule "htable.so"
loadmodule "pike.so"
loadmodule "dialplan.so"
loadmodule "xhttp.so"
loadmodule "sqlops.so"
loadmodule "dialog.so"
loadmodule "exec.so"
loadmodule "acc.so"
loadmodule "uac_redirect.so"

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


# ----- mi_fifo params -----
modparam("jsonrpcs", "fifo_name", "/var/run/kamailio/kamailio_rpc.fifo")

# ----- ctl params -----
modparam("ctl", "binrpc", "unix:/var/run/kamailio/kamailio_ctl")

# ----- tm params -----
modparam("tm", "failure_reply_mode", 3)

modparam("tm", "fr_timer", 2000)
modparam("tm", "fr_inv_timer", 130000)
modparam("tm", "retr_timer2", 2000)

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

# ----- domain params -----
modparam("domain", "db_url", DBURL)
# register callback to match myself condition with domains list
modparam("domain", "register_myself", 1)

# ----- pike params -----
modparam("pike", "sampling_time_unit", 2)
modparam("pike", "reqs_density_per_unit", 16)
modparam("pike", "remove_latency", 4)

## ----- htable params -----
## ip ban htable with autoexpire after 5 minutes
modparam("htable", "htable", "ipban=>size=8;autoexpire=300;")

# ----- usrloc params -----
/* enable DB persistency for location entries */
modparam("usrloc", "db_url", DBURL)
modparam("usrloc", "db_mode", 0)
modparam("usrloc", "use_domain", 1)
modparam("usrloc", "nat_bflag", FLB_NATB)

# ----- auth_db params -----
modparam("auth_db", "db_url", DBURL)
modparam("auth_db", "calculate_ha1", yes)
modparam("auth_db", "password_column", "password")
modparam("auth_db", "load_credentials", "$avp(password)=password")
modparam("auth_db", "use_domain", 1)


# ----- dialplan params -----
modparam("dialplan", "db_url", DBURL)
modparam("dialplan", "attrs_pvar", "$avp(s:dest)")

# ----- avpops params -----
modparam("avpops","db_url", DBURL)
modparam("avpops", "avp_table", "usr_preferences")
modparam("avpops","use_domain",1)

# ----- dialog params -----
modparam("dialog", "enable_stats", 1)
modparam("dialog", "dlg_match_mode", 1)
modparam("dialog", "dlg_flag", FLT_DLG)
modparam("dialog", "rr_param", "did")
modparam("dialog", "wait_ack", 1)
modparam("dialog", "timeout_avp", "$avp(sst_timeout)")
modparam("dialog", "ka_timer", 10)
modparam("dialog", "ka_interval", 30)
modparam("dialog", "send_bye", 1)
modparam("dialog", "timer_procs", 2)
modparam("dialog", "enable_dmq", 0)
modparam("dialog", "profiles_no_value", "inbound;outbound;internal;onnet")
modparam("dialog", "profiles_with_value", "callcount")

# ----- sqlops params -----
modparam("sqlops","sqlcon","kamailio=>mysql://kamailio:password@10.66.0.190/kamailio")

# ----- exec params -----
modparam("exec", "time_to_kill", 20)
modparam("exec", "setvars", 0)

# ----- uac params -----
modparam("uac","restore_mode","auto")
modparam("uac", "restore_dlg", 1)

# ----- dmq params -----
modparam("dmq", "server_address", "sip:10.66.0.201:5060")
modparam("dmq", "num_workers", 4)
modparam("dmq", "ping_interval", 90)
modparam("dmq", "notification_address", "sip:10.66.0.210:5060")


# ----- dmq_usrloc params -----
modparam("dmq_usrloc", "enable", 1)
modparam("dmq_usrloc", "sync", 1)

# ----- acc params -----
/* General settings */
modparam("acc", "log_level", 0)
modparam("acc", "log_facility", "LOG_LOCAL2")
modparam("acc", "db_url", DBURL)

/* Enable cdr's */
modparam("acc", "cdr_enable", 1)
modparam("acc", "cdrs_table", "acc_cdrs")
modparam("acc", "cdr_log_enable", 1)
modparam("acc", "cdr_start_on_confirmed", 1)
modparam("acc", "cdr_facility", "LOG_LOCAL2")
modparam("acc", "cdr_on_failed", 1)
modparam("acc", "multi_leg_info", "Dst_Number=$avp(dest_number)")

# ----- app_lua params -----
modparam("app_lua", "load", "/etc/kamailio/kamailio_functions.lua")
modparam("app_lua", "register", "sqlops")
modparam("app_lua", "register", "siputils")
modparam("app_lua", "register", "xhttp")


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


# Main SIP request routing logic
# - processing of any incoming SIP request starts with this route
# - note: this is the same as route { ... }
request_route {
        drop();

}

event_route[xhttp:request] {
 drop();

}
