# Sample Kamailio Configuration 
# 23 June 2010 - For Alpine Linux 
# Accepts all registrations; routes calls to any registered AOR

#--------------------------------------------------------
# Section 1:  Global Definitions
#--------------------------------------------------------
debug		=	2
fork		=	yes
log_stderror	=	no
# listen		=	0.0.0.0
port		=	5060
children	=	4

dns		=	no
rev_dns		=	no

mpath		=	"/usr/lib/kamailio/modules_k/:/usr/lib/kamailio/modules/"

#--------------------------------------------------------
# Section 2:  Modules
#--------------------------------------------------------

loadmodule	"tm.so"		
loadmodule	"sl.so"
loadmodule	"tmx.so"		
loadmodule	"rr.so"
loadmodule	"maxfwd.so"
loadmodule	"usrloc.so"
loadmodule	"registrar.so"
loadmodule	"mi_fifo.so"
loadmodule	"pv.so"
loadmodule	"xlog.so"

#--------------------------------------------------------
# Section 3:  Module Configuration
#--------------------------------------------------------

modparam ( "usrloc", "db_mode", 0 )
modparam ( "rr", "enable_full_lr", 1 )
modparam ( "mi_fifo", "fifo_name", "/tmp/kamailio_fifo")

#--------------------------------------------------------
# Section 4:  Main Route Block
#--------------------------------------------------------

route 
  {	
	# Uncomment next line if you  want to see
	# each incoming message
	xlog( "L_INFO", "$rm: $fu -> $ru" );
	
	if (!mf_process_maxfwd_header("10")) 
		{	
		sl_send_reply("483", "Too Many Hops");
		return;
		}
 
	if (msg:len > 4096)
		{
		sl_send_reply("513", "Message too big" );
		return;
		}
	
	if (method == "REGISTER" )
		{
		route(REGISTER);
		return;
		}

	loose_route();
	
	if (!lookup("location")) {
		sl_send_reply("404", "User Not Found");
		return;
		}
		
	route(RELAY);
		
}
#--------------------------------------------------------
# Section 5:  Secondary Route Blocks
#--------------------------------------------------------

# - Default message handler
route[RELAY] {
	if (!t_relay()) {
		sl_reply_error();
		}
}

#- Registration Request
route[REGISTER] {
	if (!save("location")) {
		sl_reply_error();
	}
}

#--------------------------------------------------------
# Section 6:  Reply Route Block
#--------------------------------------------------------


#--------------------------------------------------------
# Section 7:  Failure Route Block
#--------------------------------------------------------