diff --git a/tests/p_tcpdump/tcp6dump_lo.sh b/tests/p_tcpdump/tcp6dump_lo.sh index 5b1c2c8..0259806 100755 --- a/tests/p_tcpdump/tcp6dump_lo.sh +++ b/tests/p_tcpdump/tcp6dump_lo.sh @@ -11,19 +11,21 @@ if [[ $IP =~ $regex ]] then t_Log "IPv6 seems to be enabled - runing test" FILE='/var/tmp/lo_test6.pcap' - #Dumping 4 ping6s to loopback to file + COUNT='4' + #Dumping ping6s to loopback to file tcpdump -q -n -p -i lo -w $FILE & # If we don't wait a short time, the first paket will be missed by tcpdump sleep 1 - ping6 -q -c 4 -i 0.25 ::1 + ping6 -q -c $COUNT -i 0.25 ::1 sleep 1 killall -s SIGINT tcpdump # reading from file, for each ping we should see two pakets WORKING=$( tcpdump -r $FILE | grep -ci icmp6 ) - if [ $WORKING == 8 ]; then + if [ $WORKING == $[COUNT*2] ]; then ret_val=0 else + t_Log "ping6 to loopback droped pakets!! This should not happen on loopback" ret_val=1 fi # Remove file afterwards diff --git a/tests/p_tcpdump/tcpdump_eth0.sh b/tests/p_tcpdump/tcpdump_eth0.sh new file mode 100755 index 0000000..67a7d9a --- /dev/null +++ b/tests/p_tcpdump/tcpdump_eth0.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# Author: Christoph Galuschka +# Athmane Madjoudj + +t_Log "Running $0 - TCPdump test to Default-GW with IPv4" + +# Grabing Default-Router of eth0 +IP=$(ip route list default | grep 'default via ') +regex='.*via\ (.*)\ dev.*' +if [[ $IP =~ $regex ]] + then + t_Log "Found Default-GW - starting tcpdump test" + #Dumping 4 pings via eth0 to file + FILE='/var/tmp/eth0_test.pcap' + COUNT='4' + tcpdump -q -n -p -i eth0 -w $FILE & + # If we don't wait a short time, the first paket will be missed by tcpdump + sleep 1 + ping -q -c $COUNT -i 0.25 ${BASH_REMATCH[1]} + sleep 1 + killall -s SIGINT tcpdump + # reading from file, for each ping we should see two pakets + WORKING=$( tcpdump -r $FILE | grep -ci icmp ) + # The script will allways work, but if we the log does not contain + # what we expect, we will log it + if [ $WORKING == $[COUNT*2] ] + then + ret_val=0 + else + t_Log "ping to Default-Gateway droped pakets!! Only "$WORKING" of "$[COUNT*2]" entries were found!!" + ret_val=1 + fi +else + t_Log "Found Default-GW - skiping test" + ret_val=0 +fi +# Remove file afterwards +/bin/rm $FILE + +t_CheckExitStatus $ret_val diff --git a/tests/p_tcpdump/tcpdump_lo.sh b/tests/p_tcpdump/tcpdump_lo.sh index 4318473..92516e2 100755 --- a/tests/p_tcpdump/tcpdump_lo.sh +++ b/tests/p_tcpdump/tcpdump_lo.sh @@ -4,22 +4,24 @@ t_Log "Running $0 - TCPdump test to lo" -#Dumping 4 pings to loopback to file +#Dumping pings to loopback to file FILE='/var/tmp/lo_test.pcap' +COUNT='4' tcpdump -q -n -p -i lo -w $FILE & # If we don't wait a short time, the first paket will be missed by tcpdump sleep 1 -ping -q -c 4 -i 0.25 127.0.0.1 +ping -q -c $COUNT -i 0.25 127.0.0.1 sleep 1 killall -s SIGINT tcpdump # reading from file, for each ping we should see two pakets WORKING=$( tcpdump -r $FILE | grep -ci icmp ) -if [ $WORKING == 8 ] +if [ $WORKING == $[COUNT*2] ] then ret_val=0 else + t_Log "ping to loopback droped pakets!! This should not happen on loopback" ret_val=1 fi