# 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 "db_mysql/db_mysql.so"
loadmodule "usrloc/usrloc.so"
loadmodule "registrar/registrar.so"
loadmodule "sl/sl.so"
loadmodule "tm/tm.so"
loadmodule "maxfwd/maxfwd.so"
loadmodule "pv/pv.so"
loadmodule "cfgutils.so"
loadmodule "memcached.so"
#for debugging purposes only
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", "db_url", "mysql://kamailio:kamailiorw@localhost/kamailio")
modparam("memcached", "memory", 0)

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

	$mct(test) = "1";
	$mct(test) = 5;
	xlog("stored value is $mct(test)");
	$mct(test) = $null;
	xlog("stored value is $mct(test) - expected empty");

	$mct(cnt) = 1;
	$mcinc(cnt) = 1; # increment by 1
	xlog("counter is now $mct(cnt)");
	$mcdec(cnt) = 1; # decrement by 1
	xlog("counter is now $mct(cnt)");

	$mct(test) = 111;
	xlog("stored value is $mct(test)");
	$mctex(test) = 1;
	sleep("2");
	xlog("stored value is now $mct(test)");

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

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

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