#!/bin/sh

display=""

rules=""
nat=""
tables=""

while [ -n "${1}" ]
do
        case "${1}" in
        r*)
                rules="YES"
                ;;
        n*)
                nat="YES"
                ;;
        t*)
                tables="YES"
                ;;
        a*)
                rules="YES"
                nat="YES"
                tables="YES"
                ;;
        *)
                # meow
                ;;
        esac
        shift
done

if [ -n "${rules}" -o -n "${nat}" ]
then
        echo -n "=> "
        [ -n "${nat}" ] && echo -n "NAT"
        [ -n "${nat}" -a -n "${rules}" ] && echo -n "/"
        [ -n "${rules}" ] && echo -n "Rules"
        echo " <="

        for anchor in $(pfctl -vvsAnchor)
        do
                echo "==> ${anchor}"
                [ -n "${nat}" ] && pfctl -a ${anchor} -s nat
                [ -n "${rules}" ] && pfctl -a ${anchor} -s rules
                echo ""
        done
fi

if [ -n "${tables}" ]
then
        echo "=> Tables <="

        for table in $(pfctl -sTable)
        do
                echo "==> ${table}"
                pfctl -t ${table} -T show
                echo ""
        done
fi

exit 0
echo "=> NAT/Rules <="
for anchor in $(pfctl -vvsAnchor)
do
        echo "==> ${anchor}"
        pfctl -a${anchor} -snat
        pfctl -a${anchor} -srules
        echo ""
done

echo ""
echo "=> Tables <="
for table in $(pfctl -sTable)
do
        echo "==> ${table}"
        pfctl -t ${table} -T show
        echo ""
done