#
#
# $Id$
#
# echo: rewrite userpart or r-uri to value from From header field
#

debug=3         # debug level (cmd line: -dddddddddd)
fork=no
log_stderror=yes

memlog=4

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

listen=192.168.2.16

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

# Uncomment this if you want to use SQL database
#loadmodule "/usr/local/lib/ser/modules/mysql.so"

loadmodule "modules/sl/sl.so"
loadmodule "modules/exec/exec.so"

route {

		log(1, "request received\n");

		if (method=="REGISTER") {
			log(1, "register received\n");
			sl_send_reply("200", "ok happy registratiion");
			break;
		};

        if (exec_dset('
			set -x
			SIP_UID_FROM=`echo $SIP_HF_FROM | sed -e "s/^.*sip:\([a-zA-Z0-9_\.]*\)@.*$/\1/g"`
			echo sip:$SIP_UID_FROM@vm04.foobar.com
			echo sip:$SIP_UID_FROM@proxy01.foobar.com
			echo>/dev/null ')) {
                log(1, "trying to rewrite\n");
				sl_send_reply("300", "redirect");
        } else {
                sl_send_reply("500", "exec error");
                log(1, "alas, rewriting failed\n");
        };
}