#
# configuration for Jabber module testing
#
# $ID: daniel $
#


debug=3          # debug level (cmd line: -dddddddddd)
fork=yes          # (cmd. line: -D)
#fork=no
#log_stderror=yes  # (cmd line: -E)
log_stderror=no   # (cmd line: -E)


children=2
check_via=no      # (cmd. line: -v)
dns=off           # (cmd. line: -r)
rev_dns=off       # (cmd. line: -R)
port=5080
#listen=10.0.0.179
#listen=192.168.57.33
loop_checks=0
# for more info: sip_router -h

#modules
loadmodule "modules/print/print.so"
loadmodule "modules/textops/textops.so"
loadmodule "modules/tm/tm.so"

#loadmodule "modules/rr/rr.so"
loadmodule "modules/maxfwd/maxfwd.so"
loadmodule "modules/sl/sl.so"
loadmodule "modules/mysql/mysql.so"
#loadmodule "modules/dbexample/dbexample.so"
loadmodule "modules/jabber/jabber.so"
#loadmodule "modules/cpl/cpl.so"
#loadmodule "modules/pike/pike.so"

modparam("jabber", "contact", "sip:bat.iptel.org:5080")
modparam("jabber", "db_url", "sql://s2jgw:47s2jgw11@127.0.0.1/sip_jab")
modparam("jabber", "jaddress", "bat.iptel.org")
modparam("jabber", "jport", 5222)
modparam("jabber", "workers", 2)
modparam("jabber", "max_jobs", 10)

#modparam("pike", "timeout", 30)

route{
	sl_filter_ACK();

	if ( !mf_process_maxfwd_header("10") )
	{
		sl_send_reply("483", "To Many Hops");
		drop();
	};

	if ((search("To:.*@icq\.iptel\.org")) || (search("To:.*@icq\.bat\.iptel\.org"))
	 || (search("To:.*@sms\.bat\.iptel\.org")) || (search("To:.*@msn\.iptel\.org"))
	 || (search("To:.*@msn\.bat\.iptel\.org")))
	{
		if (method=="MESSAGE")
		{
			log("MESSAGE received -> sending as JABBER\n");
			if (jab_send_message())
			{
				sl_send_reply("202", "Accepted");
			}else{
				sl_send_reply("502", "Bad gateway");
			};
		}else{
			log("NON_Message request received for JABBER gateway->dropt!\n");
			sl_send_reply("501", "Not implemented");
		};
		break;
	};
	forward(uri:host,uri:port);
}
