#!/bin/sh
# de:Paket-Filter-Konfiguration anzeigen
# en:Show packet filter config
# fr:Voir la configuration des paquets filtés
# nl:Toon de configuratie van het packetfilter
# default:en

verb=-v 
verb_txt='non verbose'
name=-n
name_txt='show names'
while true
do
    clrhome
    cat <<EOF
1 Input Chain
2 Forward Chain
3 Post Routing (Masquerading/SNAT)
4 Port Forwarding (DNAT)
5 ALL
6 Bug-Report Info
7 $verb_txt
8 $name_txt 
9 return
EOF
    read -p "$LANG_3" choice
    clrhome
    case "$choice" in
	1)
	    iptables $verb $name -L INPUT
	    ;;
	2)
	    iptables $verb $name -L FORWARD
	    ;;
	3)
	    iptables $verb $name -t nat -L POSTROUTING
	    ;;
	4)
	    iptables $verb $name -L FORWARD | grep -e ^Chain -e ^target -e PORTFWACCESS
	    echo
	    iptables $verb $name -L PORTFWACCESS
	    echo
	    iptables $verb $name -t nat -L PREROUTING
	    ;;
	5)
	    iptables $verb $name -L
	    iptables $verb $name -t nat -L 
	    ;;
	6)
	    > /tmp/fwrules.debug
	    if [ -f /boot/rc.cfg ]
	    then
		grep -e IP_NET_ -e PORTFW_ -e INPUT_ -e FORWARD_ -e POSTROUTING -e PREROUTING_ /boot/rc.cfg > /tmp/fwrules.debug
		cat  /tmp/fwrules.debug
	    fi
	    iptables -nvL >> /tmp/fwrules.debug
	    iptables -t nat -nvL >> /tmp/fwrules.debug
	    iptables -nvL INPUT
	    iptables -nvL FORWARD
	    iptables -t nat -nvL
	    ;;
	7)
	    case x$verb in
		x) 
		    verb=-v
		    verb_txt='non verbose'
		    ;;
		*)
		    verb=
		    verb_txt=verbose
		    ;;
	    esac
	    ;;
	8)
	    case x$name in
		x)
		    name=-n
		    name_txt='show names'
		    ;;
		*)
		    name=
		    name_txt='numeric'
		    ;;
	    esac
	    ;;
	9)
	    break
	    ;;
	*)
	    echo "$LANG_5"
	    ;;
    esac
    echo
    read -p "$LANG_4" p
done
