# Kamailio config for lookup / registrar testing

#------------------------Global configuration----------------------------------
debug=3
fork=yes
log_stderror=no
listen=127.0.0.1
port=5060
dns=no
rev_dns=no

#-----------------------Loading Modules-------------------------------------
loadmodule "db_mysql/db_mysql.so"
loadmodule "usrloc/usrloc.so"
loadmodule "registrar/registrar.so"
loadmodule "sl/sl.so"
loadmodule "tm/tm.so"
loadmodule "pv/pv.so"
loadmodule "permissions/permissions.so"
loadmodule "maxfwd/maxfwd.so"
loadmodule "mi_fifo/mi_fifo.so"
loadmodule "xlog/xlog.so"


#-----------------------Module parameters-------------------------------------
modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")
modparam("usrloc", "db_mode", 3)
modparam("usrloc|permissions", "db_url", "mysql://kamailio:kamailiorw@localhost/kamailio")

#-----------------------Routing configuration---------------------------------#
route{
if (!mf_process_maxfwd_header("10")) {
	sl_send_reply("483","Too Many Hops");
	exit();
}

if (!allow_address("0", "$si", "$sp") || !allow_source_address("0")) {
	#xlog("permissions allow_address");
	sl_send_reply("403", "Forbidden");
}

if (!allow_trusted())  {
	xlog("permissions allow_trusted");
	sl_send_reply("403", "Forbidden");
}

if(!lookup ("location")){
	sl_send_reply("404", "Not Found");
}

if (!t_relay()) {
	sl_reply_error();
	}
}