Blame SOURCES/ebtables-save

b43dd3
#!/bin/bash
b43dd3
b43dd3
EBTABLES="/sbin/ebtables"
b43dd3
b43dd3
[ -x "$EBTABLES" ] || exit 1
b43dd3
b43dd3
echo "# Generated by ebtables-save v1.0 on $(date)"
b43dd3
b43dd3
cnt=""
b43dd3
[ "x$EBTABLES_SAVE_COUNTER" = "xyes" ] && cnt="--Lc"
b43dd3
b43dd3
for table_name in $(grep -E '^ebtable_' /proc/modules | cut -f1 -d' ' | sed s/ebtable_//); do
b43dd3
    table=$($EBTABLES -t $table_name -L $cnt)
b43dd3
    [ $? -eq 0 ] || { echo "$table"; exit -1; }
b43dd3
b43dd3
    chain=""
b43dd3
    rules=""
b43dd3
    while read line; do
b43dd3
	[ -z "$line" ] && continue
b43dd3
b43dd3
	case "$line" in 
b43dd3
	    Bridge\ table:\ *)
b43dd3
		echo "*${line:14}"
b43dd3
		;;
b43dd3
	    Bridge\ chain:\ *)
b43dd3
		chain="${line:14}"
b43dd3
		chain="${chain%%,*}"
b43dd3
		policy="${line##*policy: }"
b43dd3
		echo ":$chain $policy"
b43dd3
		;;
b43dd3
	    *)
b43dd3
		if [ "$cnt" = "--Lc" ]; then
b43dd3
		    line=${line/, pcnt \=/ -c}
b43dd3
		    line=${line/-- bcnt \=/}
b43dd3
		fi
b43dd3
		rules="$rules-A $chain $line\n"
b43dd3
		;;
b43dd3
	esac
b43dd3
    done <
b43dd3
$table
b43dd3
EOF
b43dd3
    echo -e $rules
b43dd3
done