5 RH=127.0.0.1 # remote host
6 R=10 # test rule number
14 #insmod dummynet2/ipfw_mod.ko
15 #$IPFW show > /dev/null
17 echo "Flushing rules, do you agree ?"
20 # test_msg rule counter
23 $IPFW delete $R 2> /dev/null
24 $IPFW pipe $P delete 2> /dev/null
27 # simple counter/allow test
28 echo -n "counter/allow test..."
30 $IPFW add $R allow icmp from any to 127.0.0.1 > /dev/null
31 $PING -f -c100 $RH > /dev/null
32 counter=`$IPFW show | grep $R | head -n 1 | cut -d " " -f3`
33 [ ! $counter -eq 400 ] && abort "Wrong counter $counter 400"
37 echo -n "deny test..."
39 $IPFW add $R deny icmp from any to 127.0.0.1 > /dev/null
40 $PING -f -c10 -W 1 $RH > /dev/null
41 counter=`$IPFW show | grep $R | head -n 1 | cut -d " " -f4`
42 [ ! $counter -eq 10 ] && abort "Wrong counter $counter 10"
46 echo -n "pipe delay test..."
48 $IPFW pipe $P config delay 2000ms >/dev/null
49 $IPFW add $R pipe $P icmp from any to $RH >/dev/null
50 $PING -f -c10 -W 1 $RH > /dev/null
51 counter1=`$IPFW show | grep $R | head -n 1 | cut -d " " -f4`
53 counter2=`$IPFW show | grep $R | head -n 1 | cut -d " " -f4`
54 [ ! $counter1 -eq 10 ] && abort "Wrong counter $counter 10"
55 [ ! $counter2 -eq 20 ] && abort "Wrong counter $counter 20"
59 echo -n "pipe bw test..."
61 $IPFW pipe $P config bw 2Kbit/s >/dev/null
62 $IPFW add $R pipe $P icmp from any to $RH >/dev/null
63 $PING -i 0.1 -c10 -W 1 $RH > /dev/null
64 counter=`$IPFW show | grep $R | head -n 1 | cut -d " " -f4`
65 [ $counter -gt 30 ] && abort "Wrong counter $counter should be < 30"
67 counter=`$IPFW show | grep $R | head -n 1 | cut -d " " -f4`
68 [ $counter -gt 30 ] && abort "Wrong counter $counter should be < 30"