# Kamailio config for lookup / registrar testing

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

#-----------------------Loading Modules-------------------------------------
loadmodule "tm"
loadmodule "db_mysql"
loadmodule "usrloc"
loadmodule "registrar/registrar.so"
loadmodule "sl/sl.so"
loadmodule "maxfwd/maxfwd.so"
loadmodule "pv/pv.so"
#for debugging purposes only
loadmodule "jsonrpcs"
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@localhost/kamailio")

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

	if (registered("location")) {
		xlog("contact registered");
	}


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

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

