Changeset View
Changeset View
Standalone View
Standalone View
head/tests/sys/netpfil/common/utils.subr
Show All 31 Lines | |||||
firewall_config() | firewall_config() | ||||
{ | { | ||||
jname=$1 | jname=$1 | ||||
shift | shift | ||||
fw=$1 | fw=$1 | ||||
shift | shift | ||||
while [ $# -gt 0 ]; do | while [ $# -gt 0 ]; do | ||||
if [ $(is_firewall $fw) -eq 1 ]; then | if [ $(is_firewall "$1") -eq 1 ]; then | ||||
current_fw="$1" | current_fw="$1" | ||||
shift | shift | ||||
filename=${current_fw}.rule | filename=${current_fw}.rule | ||||
cwd=$(pwd) | cwd=$(pwd) | ||||
if [ -f ${current_fw}.rule ]; then | if [ -f ${current_fw}.rule ]; then | ||||
rm ${current_fw}.rule | rm ${current_fw}.rule | ||||
fi | fi | ||||
fi | fi | ||||
Show All 40 Lines | elif [ ${firewall} == "pf" ]; then | ||||
if [ ! -c /dev/pf ]; then | if [ ! -c /dev/pf ]; then | ||||
atf_skip "This test requires pf" | atf_skip "This test requires pf" | ||||
fi | fi | ||||
elif [ ${firewall} == "ipf" ]; then | elif [ ${firewall} == "ipf" ]; then | ||||
if ! kldstat -q -m ipfilter; then | if ! kldstat -q -m ipfilter; then | ||||
atf_skip "This test requires ipf" | atf_skip "This test requires ipf" | ||||
fi | fi | ||||
elif [ ${firewall} == "ipfnat" ]; then | elif [ ${firewall} == "ipfnat" ]; then | ||||
if ! kldstat -q -m ipfw_nat; then | if ! kldstat -q -m ipfilter; then | ||||
atf_skip "This test requires ipfw_nat" | atf_skip "This test requires ipf" | ||||
fi | fi | ||||
else | else | ||||
atf_fail "$fw is not a valid firewall to initialize" | atf_fail "$fw is not a valid firewall to initialize" | ||||
fi | fi | ||||
} | |||||
nat_init() | |||||
{ | |||||
firewall=$1 | |||||
if [ ${firewall} == "ipfw" ]; then | |||||
if ! kldstat -q -m ipfw_nat; then | |||||
atf_skip "This test requires ipfw_nat" | |||||
fi | |||||
fi | |||||
} | } | ||||
is_firewall() | is_firewall() | ||||
{ | { | ||||
if [ "$1" = "pf" -o "$1" = "ipfw" -o "$1" = "ipf" -o "$1" = "ipfnat" ]; then | if [ "$1" = "pf" -o "$1" = "ipfw" -o "$1" = "ipf" -o "$1" = "ipfnat" ]; then | ||||
echo 1 | echo 1 | ||||
else | else | ||||
echo 0 | echo 0 | ||||
fi | fi | ||||
} | } | ||||
No newline at end of file |