# Kamailio config for lookup / registrar testing

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

#-----------------------Loading Modiules-------------------------------------
loadmodule "tm"
loadmodule "db_mysql"
loadmodule "usrloc/usrloc.so"
loadmodule "registrar"
loadmodule "sl/sl.so"
loadmodule "maxfwd/maxfwd.so"
loadmodule "acc/acc.so"
#for debugging purposes only
loadmodule "jsonrpcs/jsonrpcs.so"
loadmodule "xlog/xlog.so"


#-----------------------Module parameters-------------------------------------
modparam("jsonrpcs", "transport", 2)
modparam("jsonrpcs", "fifo_name", "kamailio_rpc.fifo")
modparam("usrloc", "db_mode", 3)
modparam("usrloc", "db_url", "mysql://kamailio:kamailiorw@127.0.0.1/kamailio")
modparam("acc", "log_flag", 1)
modparam("db_mysql", "timeout_interval", 2)


#-----------------------Routing configuration---------------------------------#

request_route {
	if (!mf_process_maxfwd_header("10")) {
		sl_send_reply("483","Too Many Hops");
		exit;
	}

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

	if(method=="INVITE") {
		setflag(1);
	}

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