#
# 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)
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

# ------------------ 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", 10 )
modparam("tm", "fr_inv_timer", 10 )
modparam("tm", "wt_timer", 10 )


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;
#    };

	# UAS script implementation

	# if that is not a new transaction... (t_newtran is a new
	# function which atomically adds a transaction if there is
	# none)
	if (! t_newtran()) {
		# retransmit whatever we have
		t_retransmit_reply();
	} else {
		# do what you want to do
		# if (send_sms()) {
		# this is just a thing which stands for sth real
		if (len_gt( max_len )) {
			# things went well, send ok upstream
			if (!t_send_reply("200", "yes sir, SMS sent over")) {
				# if replying failed, retry statelessly
				sl_reply_error();
			};
		} else {
			if (!t_send_reply("500", "SMS error :-(")) {
				# if replying failed, retry statelessly
				sl_reply_error();
			};
		};
		# transaction conclude it -- junk it now (it will
		# stay there until WAIT timer hits)
		t_release();
	};
	t_unref();
}

