#
# this is a ser 0.9.6 test configuration for voicebox - 
# 1 to listen to message, other numbers to leave a message
#
# ----------- global configuration parameters ------------------------
debug=3 #5         # debug level (cmd line: -dddddddddd)
fork=yes
log_stderror=yes	# (cmd line: -E)

check_via=no	   # (cmd. line: -v)
dns=no             # (cmd. line: -r)
rev_dns=no         # (cmd. line: -R)
port=5060
children=4

#listen=eth0


loadmodule "/usr/lib/msp-ser/modules/sl.so"
loadmodule "/usr/lib/msp-ser/modules/tm.so"
loadmodule "/usr/lib/msp-ser/modules/rr.so"
loadmodule "/usr/lib/msp-ser/modules/maxfwd.so"
loadmodule "/usr/lib/msp-ser/modules/textops.so"
# ----------------- setting module-specific parameters ---------------
# add value to ;lr param to make some broken UAs happy
modparam("rr", "enable_full_lr", 1)


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

route{

	# initial sanity checks -- messages with
	# max_forwards==0, or excessively long requests
	if (!mf_process_maxfwd_header("10")) {
		sl_send_reply("483","Too Many Hops");
		break;
	};

	if (!(method=="REGISTER")) record_route();

	if ((method=="ACK") || (loose_route()) || (!uri==myself)) {
                t_relay();
                break;	
	};

	if (method=="REGISTER") {
	sl_send_reply("200", "okey");
#              save("location");
              break;
    	};
	
    if ((method == "INVITE" ) || (method=="CANCEL") || (method=="REFER")) {


	if (uri=~"sip:1.*") {
		append_hf("P-App-Name: voicebox\r\n");
		append_hf("P-App-Param: User=stefan;Domain=iptego-voice.de;Language=english\r\n");
		rewritehostport("62.220.31.201:5070");
		t_relay_to_udp("62.220.31.201","5070");
		break;	
	}

	append_hf("P-App-Name: voicemail\r\n");
	append_hf("P-App-Param: User=stefan;Domain=iptego-voice.de;Language=english;Sender=someone;Mode=box\r\n");
	rewritehostport("62.220.31.201:5070");
	t_relay_to_udp("62.220.31.201","5070");
	break;	
    }

    sl_send_reply("501", "method not understood here");
    break;
}
