X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=test%2Fbasic_ipfw.sh;fp=test%2Fbasic_ipfw.sh;h=08b66f903eac13a43b87b201b03f44aed03020e8;hb=40445faa1db58b90083115bc315d095e7eb2fe51;hp=0000000000000000000000000000000000000000;hpb=fccf30d4bf6b00b317756a9ff9d2135b361d2599;p=ipfw.git diff --git a/test/basic_ipfw.sh b/test/basic_ipfw.sh new file mode 100755 index 0000000..08b66f9 --- /dev/null +++ b/test/basic_ipfw.sh @@ -0,0 +1,72 @@ +#!/bin/sh + +IPFW=./ipfw/ipfw +PING=/bin/ping +RH=127.0.0.1 # remote host +R=10 # test rule number +P=1 # test pipe number + +abort() +{ +echo $* +} + +#insmod dummynet2/ipfw_mod.ko +#$IPFW show > /dev/null +#$IPFW pipe show +echo "Flushing rules, do you agree ?" +$IPFW flush + +# test_msg rule counter +clean() +{ + $IPFW delete $R 2> /dev/null + $IPFW pipe $P delete 2> /dev/null +} + +# simple counter/allow test +echo -n "counter/allow test..." +clean +$IPFW add $R allow icmp from any to 127.0.0.1 > /dev/null +$PING -f -c100 $RH > /dev/null +counter=`$IPFW show | grep $R | head -n 1 | cut -d " " -f3` +[ ! $counter -eq 400 ] && abort "Wrong counter $counter 400" +echo "...OK" + +# simple drop test +echo -n "deny test..." +clean +$IPFW add $R deny icmp from any to 127.0.0.1 > /dev/null +$PING -f -c10 -W 1 $RH > /dev/null +counter=`$IPFW show | grep $R | head -n 1 | cut -d " " -f4` +[ ! $counter -eq 10 ] && abort "Wrong counter $counter 10" +echo "...OK" + +# pipe delay test +echo -n "pipe delay test..." +clean +$IPFW pipe $P config delay 2000ms >/dev/null +$IPFW add $R pipe $P icmp from any to $RH >/dev/null +$PING -f -c10 -W 1 $RH > /dev/null +counter1=`$IPFW show | grep $R | head -n 1 | cut -d " " -f4` +sleep 2 +counter2=`$IPFW show | grep $R | head -n 1 | cut -d " " -f4` +[ ! $counter1 -eq 10 ] && abort "Wrong counter $counter 10" +[ ! $counter2 -eq 20 ] && abort "Wrong counter $counter 20" +echo "...OK" + +# pipe bw test +echo -n "pipe bw test..." +clean +$IPFW pipe $P config bw 2Kbit/s >/dev/null +$IPFW add $R pipe $P icmp from any to $RH >/dev/null +$PING -i 0.1 -c10 -W 1 $RH > /dev/null +counter=`$IPFW show | grep $R | head -n 1 | cut -d " " -f4` +[ $counter -gt 30 ] && abort "Wrong counter $counter should be < 30" +sleep 1 +counter=`$IPFW show | grep $R | head -n 1 | cut -d " " -f4` +[ $counter -gt 30 ] && abort "Wrong counter $counter should be < 30" +echo "...OK" + +# Final clean +clean