#
# configuration for TurboSIP testing
#
# $ID: $
#

debug=1          # debug level (cmd line: -dddddddddd)
check_via=yes     # (cmd. line: -v)
dns=on           # (cmd. line: -r)
rev_dns=yes      # (cmd. line: -R)
#fork=yes          # (cmd. line: -D)
fork=no
children=16
log_stderror=yes # (cmd line: -E)
log_stderror=no	# (cmd line: -E)
port=5080
#listen=127.0.0.1
listen=192.168.99.100
loop_checks=1
# for more info: sip_router -h

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

route{
	if ( t_lookup_request()) {
		if ( method=="ACK" )	{
			log("SER: ACK received -> t_release\n");
			if (! t_forward("bat.iptel.org", "5090" )) {
				log("SER: WARNING: bad forward\n");
			};
			if (! t_release()) {
				log("SER: WARNING: bad t_release\n");
			};
		} else {
			if (! t_retransmit_reply()) {
				log("SER: WARNING: bad t_retransmit_reply\n");
			};
			log("SER: yet another annoying retranmission\n");
		};
		t_unref();
	} else {
		if (method=="ACK") {
			# no established transaction ... forward ACK just statelessly
			forward("bat.iptel.org", 5090);
		} else {
			# establish transaction
			if (! t_add_transaction()){
				log("ERROR in ser: t_add_transaction\n");
			};
			# reply
			if (method=="CANCEL") {
				log("SER: new CANCEL\n");
				if (! t_send_reply( "200", "glad to cancel")){
					log("SER:ERROR: t_send_reply\n");
				};
			} else {
				log("SER: new transaction\n");
				if (! t_send_reply("100", "trying -- your call is important to us")
					){
					log("SER: ERROR: t_send_reply (100)\n");
				};
			};
			if (! t_forward("bat.iptel.org", "5090")){
				log("SER:ERROR: t_forward (..., 5555)\n");
			};
			t_unref();
		};
	};
}