#
# iptel.org real world configuration
#
# $Id$
#

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

debug=4          # debug level (cmd line: -dddddddddd)
#fork=yes
fork=no
#log_stderror=no	# (cmd line: -E)
log_stderror=yes	# (cmd line: -E)
#check_via=yes     # (cmd. line: -v)
check_via=no# (cmd. line: -v)
dns=on           # (cmd. line: -r)
rev_dns=yes      # (cmd. line: -R)
port=5060
children=1

# advertise IP address in Via (as opposed to advertising DNS name
# which is annoying for downstream servers and some phones can
# not handle DNS at all)
listen=195.37.77.100
#listen=bat.iptel.org

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

loadmodule "../sip_router/modules/print/print.so"
#loadmodule "../sip_router/modules/tm/tm.so"
loadmodule "../sip_router/modules/sl/sl.so"
loadmodule "../sip_router/modules/maxfwd/maxfwd.so"

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

# -- tm params --
modparam("tm", "fr_timer", 12 )
modparam("tm", "fr_inv_timer", 12 )
modparam("tm", "wt_timer", 3 )
modparam("tm", "retr_timer2", 1 )
modparam("tm", "retr_timer1p1", 1 )
modparam("tm", "retr_timer1p2", 1 )
modparam("tm", "retr_timer1p3", 1 )


route{
    # filter local stateless ACK generated by authentication of mf replies
    sl_filter_ACK();

	if (len_gt( max_len )) {
#	if (len_gt( 100 )) {
		sl_send_reply("513", "Riesengross -- Message too large");
		log("XXX Riessengross: dropped\n");
		break;
	};


    # filter too old messages
    log("LOG: Checking maxfwd\n");
    if (!mf_process_maxfwd_header("0")) {
        log("LOG: Too many hops\n");
        sl_send_reply("483","Too Many Hops");
        break;
    };

#	if (uri=~"jiri@") {
#		seturi("sip:jiri2@bat.iptel.org");
#		log("jiri");
#	};

#	seturi("sip:100@bat.iptel.org:5064");
	seturi("sip:jirim@iptel.org");
#	t_fork_on_no_response("sip:jirim@iptel.org");
#	sethost("iptel.org");
#	seturi("sip:devnull@iptel.org:9");
	t_fork_to_uri("sip:200@bat.iptel.org:5064");
#	if (not method=="ACK") seturi("sip:jirim@iptel.org:5060");
	if (!t_relay()) {
#	if (!t_relay_to("iptel.org", "5060")) {
		sl_reply_error();
		break;
	};

#   THERE IT IS
#	seturi("sip:7271@iptel.org:5060");
#	t_fork_on_no_response("sip:jirim@iptel.org");
#	t_relay();


#	t_relay_to("iptel.org","5060");
#	forward( uri:host, uri:port );
#	strip(9);
#	t_relay_to( "localhost", "9" );

}