#
# $Id$
#
# example script showing both types of forking;
# incoming message is foked in parallel to
# 'nobody' and 'parallel', if no positive reply
# appears with final_response timer, nonsense
# is retried (serial forking); than, destination
# 'foo' is given last chance

# ----------- global configuration parameters ------------------------

debug=3
fork=no
log_stderror=yes	# (cmd line: -E)
check_via=no # (cmd. line: -v)
dns=no # (cmd. line: -r)
syn_branch=1
reply_to_via=0


# ------------------ module loading ----------------------------------

loadmodule "/usr/lib/ser/modules/sl.so"
loadmodule "/usr/lib/ser/modules/print.so"
loadmodule "/usr/lib/ser/modules/tm.so"

# ----------------- setting module-specific parameters ---------------

# -- tm params --
modparam("tm", "fr_timer", 10 )
modparam("tm", "fr_inv_timer", 5 )

# -------------------------  request routing logic -------------------

# main routing logic

route{
	# for testing purposes, simply okay all REGISTERs
	if (method=="REGISTER") {
		log("REGISTER");
		sl_send_reply("200", "ok");
		break;
	};
	# print a message if a call was missed
	seturi("sip:nobody@iptel.org");
	/* parallel branch to sink port -- that will make it
	   wait until timer hits
	*/
	append_branch("sip:parallel@iptel.org:9");
	t_on_negative("1");
	# start parallel forking to nobody and wer.xmla	
	log(1,"about to relay\n");
	t_relay();
}

reply_route[1] {
	rewriteuri("sip:nonsense@iptel.org");
	append_branch();
	log(1,"first redirection\n");
	t_on_negative("2");
}

reply_route[2] {
	rewriteuri("sip:foo@iptel.org");
	log(1, "second redirection\n");
	append_branch();
}