examples/kamailio/msilo.cfg
91301510
 #
 # MSILO usage example
 #
 # $ID: daniel $
 #
 
 
 
 children=2
 check_via=no      # (cmd. line: -v)
 dns=off           # (cmd. line: -r)
 rev_dns=off       # (cmd. line: -R)
 
 
 # ------------------ module loading ----------------------------------
8a79b963
 #set module path
f41e32d6
 mpath="/usr/local/lib/kamailio/modules/"
91301510
 
8a79b963
 loadmodule "textops.so"
 
 loadmodule "sl.so"
2573b4bf
 loadmodule "db_mysql.so"
8a79b963
 loadmodule "maxfwd.so"
 loadmodule "tm.so"
 loadmodule "usrloc.so"
2573b4bf
 loadmodule "registrar.so"
 loadmodule "msilo.so"
91301510
 
 # ----------------- setting module-specific parameters ---------------
 
 # -- registrar params --
 
 modparam("registrar", "default_expires", 120)
 
 # -- registrar params --
 
 modparam("usrloc", "db_mode", 0)
 
 # -- msilo params --
 
f41e32d6
 modparam("msilo", "db_url", "mysql://kamailio:kamailiorw@localhost/kamailio")
91301510
 
 # -- tm params --
 
 modparam("tm", "fr_timer", 10 )
 modparam("tm", "fr_inv_timer", 15 )
 modparam("tm", "wt_timer", 10 )
 
 
 route{
 	if ( !mf_process_maxfwd_header("10") )
 	{
 		sl_send_reply("483","To Many Hops");
00daf736
 		exit;
91301510
 	};
 
 
 	if (uri==myself) {
 		# for testing purposes, simply okay all REGISTERs
8a79b963
 		# is_method("XYZ") is faster than (method=="XYZ")
 		#  but requires textops module
 		if (is_method("REGISTER"))
91301510
 		{
 			save("location");
 			log("REGISTER received -> dumping messages with MSILO\n");
 
 			# MSILO - dumping user's offline messages
 			if (m_dump())
 			{
 				log("MSILO: offline messages dumped - if they were\n");
 			}else{
 				log("MSILO: no offline messages dumped\n");
 			};
00daf736
 			exit;
91301510
 		};
 
8a79b963
 		# backup r-uri for m_dump() in case of delivery failure
 		$avp(i:11) = $ru;
 
91301510
 		# domestic SIP destinations are handled using our USRLOC DB
 		
 		if(!lookup("location")) 
 		{
 			if (! t_newtran())
00daf736
 			{
91301510
 				sl_reply_error();
00daf736
 				exit;
 			};
91301510
 			# we do not care about anything else but MESSAGEs
8a79b963
 			if (!is_method("MESSAGE"))
91301510
 			{
 				if (!t_reply("404", "Not found")) 
 				{
 					sl_reply_error();
 				};
00daf736
 				exit;
91301510
 			};
 			log("MESSAGE received -> storing using MSILO\n");
 			# MSILO - storing as offline message
8a79b963
 			if (m_store("$ru"))
91301510
 			{
 				log("MSILO: offline message stored\n");
 				if (!t_reply("202", "Accepted")) 
 				{
 					sl_reply_error();
 				};
 			}else{
 				log("MSILO: offline message NOT stored\n");
 				if (!t_reply("503", "Service Unavailable")) 
 				{
 					sl_reply_error();
 				};
 			};
00daf736
 			exit;
91301510
 		};
 		# if the downstream UA does not support MESSAGE requests
 		# go to failure_route[1]
 		t_on_failure("1");
 		t_relay();
00daf736
 		exit;
91301510
 	};
 
 	# forward anything else
 	t_relay();
 }
 
 failure_route[1] {
 	# forwarding failed -- check if the request was a MESSAGE 
8a79b963
 	if (!is_method("MESSAGE"))
91301510
 	{
00daf736
 		exit;
91301510
 	};
 	
 	log(1,"MSILO: the downstream UA does not support MESSAGE requests ...\n");
 	# we have changed the R-URI with the contact address -- ignore it now
8a79b963
 	if (m_store("$avp(i:11)"))
91301510
 	{
 		log("MSILO: offline message stored\n");
 		t_reply("202", "Accepted"); 
 	}else{
 		log("MSILO: offline message NOT stored\n");
 		t_reply("503", "Service Unavailable");
 	};
 }