script_name=test-portfw.sh

. ./test.inc

do_add_dnat_rule ()
{
    echo "do_rule nat PREROUTING A \"$1\" '' \"exec_portfw_rule\""
    do_rule nat PREROUTING A "$1" '' "exec_portfw_rule"
}

pf_type=dynamic
pf_ip=1.2.3.4

if [ $# -eq 0 ]
then
    cat <<EOF > test-rules.tmp$$
#
# DNAT
#
prot:tcp 22 DNAT:@sybille
prot:tcp 22 DNAT:@sybille:88
prot:tcp @sybille:22 DNAT:1.2.3.4
prot:tcp @sybille:22 DNAT:1.2.3.4:88
tmpl:xbl dynamic:10 DNAT:@sybille

EOF
    cat test-rules.tmp$$ |\
	while read y
	do 
	    # skip comments and empty lines
	    if ! echo $y | grep -q -e '^[[:space:]]*#.*$' -e '^[[:space:]]*$' 
	    then
	    	case "$y" in
		    *dynamic*)
		        pf_type=dynamic ;;
		    *)
		    	pf_type=;;
		esac
		echo "parse_rule \"$y\""
		do_add_dnat_rule "$y"
	    else
		echo "$y"
	    fi
	done

    rm -f test-rules.tmp$$
else
    do_add_dnat_rule "$1"
fi

