1# $FreeBSD$ 2# Utility functions 3## 4 5. $(atf_get_srcdir)/../../common/vnet.subr 6 7pft_init() 8{ 9 vnet_init 10 11 if [ ! -c /dev/pf ]; then 12 atf_skip "This test requires pf" 13 fi 14} 15 16pfsynct_init() 17{ 18 pft_init 19 20 if ! kldstat -q -m pfsync; then 21 atf_skip "This test requires pfsync" 22 fi 23} 24 25pft_set_rules() 26{ 27 jname=$1 28 shift 29 30 if [ $jname == "noflush" ]; 31 then 32 jname=$1 33 shift 34 else 35 # Flush all states, rules, fragments, ... 36 jexec ${jname} pfctl -F all 37 fi 38 39 while [ $# -gt 0 ]; do 40 printf "$1\n" 41 shift 42 done | jexec ${jname} pfctl -f - 43 if [ $? -ne 0 ]; 44 then 45 atf_fail "Failed to set PF rules in ${jname}" 46 fi 47} 48 49pft_cleanup() 50{ 51 vnet_cleanup 52} 53 54pfsynct_cleanup() 55{ 56 pft_cleanup 57} 58