2005-12-13 23:15:20 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
2006-05-22 08:21:22 +00:00
|
|
|
# Test the capture engine of the Wireshark tools
|
2005-12-13 23:15:20 +00:00
|
|
|
#
|
2006-05-21 05:12:17 +00:00
|
|
|
# Wireshark - Network traffic analyzer
|
|
|
|
# By Gerald Combs <gerald@wireshark.org>
|
2005-12-13 23:15:20 +00:00
|
|
|
# Copyright 2005 Ulf Lamping
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
2006-12-11 18:24:27 +00:00
|
|
|
# along with this program; if not, writeto the Free Software
|
2012-06-28 22:56:06 +00:00
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2006-10-09 18:47:42 +00:00
|
|
|
#
|
2005-12-13 23:15:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
# common exit status values
|
|
|
|
EXIT_OK=0
|
|
|
|
EXIT_COMMAND_LINE=1
|
|
|
|
EXIT_ERROR=2
|
|
|
|
|
2014-10-01 19:44:14 +00:00
|
|
|
WIRESHARK_CMD="$WIRESHARK -o gui.update.enabled:FALSE -k"
|
2014-08-28 23:48:53 +00:00
|
|
|
WIRESHARK_GTK_CMD="$WIRESHARK_GTK -o gui.update.enabled:FALSE -k"
|
2012-05-30 21:42:24 +00:00
|
|
|
|
2014-10-07 17:11:45 +00:00
|
|
|
PING_PID=
|
|
|
|
|
2007-01-28 18:56:17 +00:00
|
|
|
capture_test_output_print() {
|
|
|
|
wait
|
|
|
|
for f in "$@"; do
|
|
|
|
if [[ -f "$f" ]]; then
|
2013-03-01 16:13:44 +00:00
|
|
|
printf " --> $f\n"
|
|
|
|
cat "$f"
|
|
|
|
printf "\n"
|
2007-01-28 18:56:17 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2016-04-26 21:57:15 +00:00
|
|
|
capture_test_output_capinfos() {
|
|
|
|
wait
|
|
|
|
for f in "$@"; do
|
|
|
|
if [[ -f "$f" ]]; then
|
|
|
|
$CAPINFOS "$f"
|
|
|
|
else
|
|
|
|
printf "$f not found.\n"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2006-12-11 18:24:27 +00:00
|
|
|
traffic_gen_ping() {
|
|
|
|
# Generate some traffic for quiet networks.
|
2014-10-07 17:11:45 +00:00
|
|
|
# The following will run in the background and return immediately
|
2007-05-17 02:43:38 +00:00
|
|
|
{
|
2007-11-08 16:59:30 +00:00
|
|
|
date
|
2014-10-07 17:11:45 +00:00
|
|
|
for sweep_size in {1..240} # try to number the packets
|
2007-05-17 02:43:38 +00:00
|
|
|
do
|
2007-09-28 23:40:51 +00:00
|
|
|
# How does ping _not_ have a standard set of arguments?
|
|
|
|
case $WS_SYSTEM in
|
|
|
|
Windows)
|
2014-10-07 17:11:45 +00:00
|
|
|
ping -n 1 -l $sweep_size www.wireshark.org ;;
|
2007-09-28 23:40:51 +00:00
|
|
|
SunOS)
|
2014-10-07 17:11:45 +00:00
|
|
|
/usr/sbin/ping www.wireshark.org $sweep_size 1 ;;
|
2007-09-28 23:40:51 +00:00
|
|
|
*) # *BSD, Linux
|
2014-10-07 17:11:45 +00:00
|
|
|
ping -c 1 -s $sweep_size www.wireshark.org ;;
|
2007-09-28 23:40:51 +00:00
|
|
|
esac
|
2014-10-07 17:11:45 +00:00
|
|
|
sleep 0.25 # 240 * 0.25 = 60-ish seconds
|
2007-05-17 02:43:38 +00:00
|
|
|
done
|
|
|
|
date
|
|
|
|
} > ./testout_ping.txt 2>&1 &
|
2014-12-22 15:29:01 +00:00
|
|
|
PING_PID=$!
|
2007-01-28 18:56:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ping_cleanup() {
|
2014-10-07 17:11:45 +00:00
|
|
|
if [ -n "$PING_PID" ] ; then
|
|
|
|
kill $PING_PID
|
|
|
|
PING_PID=
|
|
|
|
fi
|
|
|
|
wait 2> /dev/null
|
2007-01-28 18:56:17 +00:00
|
|
|
rm -f ./testout_ping.txt
|
2006-12-11 18:24:27 +00:00
|
|
|
}
|
2005-12-13 23:15:20 +00:00
|
|
|
|
|
|
|
# capture exactly 10 packets
|
|
|
|
capture_step_10packets() {
|
2007-09-28 23:40:51 +00:00
|
|
|
if [ $SKIP_CAPTURE -ne 0 ] ; then
|
2006-12-11 18:24:27 +00:00
|
|
|
test_step_skipped
|
|
|
|
return
|
|
|
|
fi
|
2006-10-09 18:47:42 +00:00
|
|
|
|
2006-12-11 18:24:27 +00:00
|
|
|
traffic_gen_ping
|
2007-02-05 00:57:59 +00:00
|
|
|
|
|
|
|
date > ./testout.txt
|
2006-12-11 18:24:27 +00:00
|
|
|
$DUT -i $TRAFFIC_CAPTURE_IFACE $TRAFFIC_CAPTURE_PROMISC \
|
|
|
|
-w ./testout.pcap \
|
2014-12-22 15:29:01 +00:00
|
|
|
-c 10 \
|
2006-12-11 18:24:27 +00:00
|
|
|
-a duration:$TRAFFIC_CAPTURE_DURATION \
|
2015-12-12 00:30:39 +00:00
|
|
|
-f "icmp || icmp6" \
|
2007-02-05 00:57:59 +00:00
|
|
|
>> ./testout.txt 2>&1
|
2005-12-13 23:15:20 +00:00
|
|
|
RETURNVALUE=$?
|
2007-02-05 00:57:59 +00:00
|
|
|
date >> ./testout.txt
|
2005-12-13 23:15:20 +00:00
|
|
|
if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
|
2006-12-22 04:46:26 +00:00
|
|
|
echo
|
2007-01-28 18:56:17 +00:00
|
|
|
capture_test_output_print ./testout.txt
|
2005-12-13 23:15:20 +00:00
|
|
|
# part of the Prerequisite checks
|
2006-12-22 04:46:26 +00:00
|
|
|
# wrong interface ? output the possible interfaces
|
2006-05-31 17:38:42 +00:00
|
|
|
$TSHARK -D
|
2006-12-22 04:46:26 +00:00
|
|
|
test_step_failed "exit status of $DUT: $RETURNVALUE"
|
2005-12-13 23:15:20 +00:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
# we should have an output file now
|
|
|
|
if [ ! -f "./testout.pcap" ]; then
|
2011-07-11 22:41:53 +00:00
|
|
|
capture_test_output_print ./testout.txt
|
2005-12-13 23:15:20 +00:00
|
|
|
test_step_failed "No output file!"
|
|
|
|
return
|
|
|
|
fi
|
2006-10-09 18:47:42 +00:00
|
|
|
|
2005-12-13 23:15:20 +00:00
|
|
|
# ok, we got a capture file, does it contain exactly 10 packets?
|
2007-01-28 18:56:17 +00:00
|
|
|
$CAPINFOS ./testout.pcap > ./testout2.txt
|
2009-05-11 18:57:08 +00:00
|
|
|
grep -Ei 'Number of packets:[[:blank:]]+10' ./testout2.txt > /dev/null
|
2005-12-13 23:15:20 +00:00
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
test_step_ok
|
|
|
|
else
|
|
|
|
echo
|
2013-03-01 16:13:44 +00:00
|
|
|
$TSHARK -ta -r ./testout.pcap >> ./testout2.txt
|
2007-01-28 18:56:17 +00:00
|
|
|
capture_test_output_print ./testout_ping.txt ./testout.txt ./testout2.txt
|
2006-01-05 22:26:05 +00:00
|
|
|
# part of the Prerequisite checks
|
|
|
|
# probably wrong interface, output the possible interfaces
|
2006-05-31 17:38:42 +00:00
|
|
|
$TSHARK -D
|
2006-01-05 22:26:05 +00:00
|
|
|
test_step_failed "No or not enough traffic captured. Probably the wrong interface: $TRAFFIC_CAPTURE_IFACE!"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# capture exactly 10 packets using "-w -" (piping to stdout)
|
|
|
|
capture_step_10packets_stdout() {
|
2013-03-01 16:13:44 +00:00
|
|
|
if [ $SKIP_CAPTURE -ne 0 ] ; then
|
|
|
|
test_step_skipped
|
|
|
|
return
|
|
|
|
fi
|
2006-10-09 18:47:42 +00:00
|
|
|
|
2006-12-11 18:24:27 +00:00
|
|
|
traffic_gen_ping
|
2007-02-05 00:57:59 +00:00
|
|
|
|
|
|
|
date > ./testout.txt
|
2006-12-11 18:24:27 +00:00
|
|
|
$DUT -i $TRAFFIC_CAPTURE_IFACE $TRAFFIC_CAPTURE_PROMISC \
|
|
|
|
-c 10 \
|
|
|
|
-a duration:$TRAFFIC_CAPTURE_DURATION \
|
|
|
|
-w - \
|
2015-12-12 00:30:39 +00:00
|
|
|
-f "icmp || icmp6" \
|
2007-02-05 00:57:59 +00:00
|
|
|
> ./testout.pcap 2>>./testout.txt
|
2006-01-05 22:26:05 +00:00
|
|
|
RETURNVALUE=$?
|
2007-02-05 00:57:59 +00:00
|
|
|
date >> ./testout.txt
|
2006-01-05 22:26:05 +00:00
|
|
|
if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
|
2006-12-22 13:00:40 +00:00
|
|
|
echo
|
2011-06-28 23:08:05 +00:00
|
|
|
capture_test_output_print ./testout.txt
|
2006-05-31 17:38:42 +00:00
|
|
|
$TSHARK -D
|
2006-12-22 04:46:26 +00:00
|
|
|
test_step_failed "exit status of $DUT: $RETURNVALUE"
|
2006-01-05 22:26:05 +00:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
# we should have an output file now
|
|
|
|
if [ ! -f "./testout.pcap" ]; then
|
|
|
|
test_step_failed "No output file!"
|
|
|
|
return
|
|
|
|
fi
|
2006-10-09 18:47:42 +00:00
|
|
|
|
2006-01-05 22:26:05 +00:00
|
|
|
# ok, we got a capture file, does it contain exactly 10 packets?
|
|
|
|
$CAPINFOS ./testout.pcap > ./testout2.txt 2>&1
|
2009-05-11 18:57:08 +00:00
|
|
|
grep -Ei 'Number of packets:[[:blank:]]+10' ./testout2.txt > /dev/null
|
2006-01-05 22:26:05 +00:00
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
test_step_ok
|
|
|
|
else
|
|
|
|
echo
|
2011-06-28 23:08:05 +00:00
|
|
|
capture_test_output_print ./testout.txt ./testout2.txt
|
2006-05-31 17:38:42 +00:00
|
|
|
$TSHARK -D
|
2006-01-05 22:26:05 +00:00
|
|
|
test_step_failed "No or not enough traffic captured. Probably the wrong interface: $TRAFFIC_CAPTURE_IFACE!"
|
2005-12-13 23:15:20 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2006-10-08 22:57:32 +00:00
|
|
|
# capture packets via a fifo
|
|
|
|
capture_step_fifo() {
|
|
|
|
mkfifo 'fifo'
|
2012-03-30 18:19:35 +00:00
|
|
|
(cat "${CAPTURE_DIR}dhcp.pcap"; sleep 1; tail -c +25 "${CAPTURE_DIR}dhcp.pcap") > fifo &
|
2006-12-11 18:24:27 +00:00
|
|
|
$DUT -i fifo $TRAFFIC_CAPTURE_PROMISC \
|
|
|
|
-w ./testout.pcap \
|
|
|
|
-a duration:$TRAFFIC_CAPTURE_DURATION \
|
|
|
|
> ./testout.txt 2>&1
|
2006-10-08 22:57:32 +00:00
|
|
|
RETURNVALUE=$?
|
|
|
|
rm 'fifo'
|
|
|
|
if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
|
2011-06-28 23:08:05 +00:00
|
|
|
capture_test_output_print ./testout.txt
|
2006-10-08 22:57:32 +00:00
|
|
|
test_step_failed "exit status of $DUT: $RETURNVALUE"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
# we should have an output file now
|
|
|
|
if [ ! -f "./testout.pcap" ]; then
|
|
|
|
test_step_failed "No output file!"
|
|
|
|
return
|
|
|
|
fi
|
2006-10-09 18:47:42 +00:00
|
|
|
|
2006-10-08 22:57:32 +00:00
|
|
|
# ok, we got a capture file, does it contain exactly 8 packets?
|
|
|
|
$CAPINFOS ./testout.pcap > ./testout.txt
|
2009-05-11 18:57:08 +00:00
|
|
|
grep -Ei 'Number of packets:[[:blank:]]+8' ./testout.txt > /dev/null
|
2006-10-08 22:57:32 +00:00
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
test_step_ok
|
|
|
|
else
|
|
|
|
echo
|
2011-06-28 23:08:05 +00:00
|
|
|
capture_test_output_print ./testout.txt
|
2006-10-08 22:57:32 +00:00
|
|
|
test_step_failed "No or not enough traffic captured."
|
|
|
|
fi
|
2006-10-09 18:47:42 +00:00
|
|
|
}
|
2006-10-08 22:57:32 +00:00
|
|
|
|
2011-05-26 20:23:38 +00:00
|
|
|
# capture packets via a fifo
|
|
|
|
capture_step_stdin() {
|
2013-03-01 16:13:44 +00:00
|
|
|
CONSOLE_LOG_ARGS=""
|
2014-10-01 19:44:14 +00:00
|
|
|
if [[ ( "$DUT" == "$WIRESHARK_CMD" || "$DUT" == "$WIRESHARK_GTK_CMD" ) && "$WS_SYSTEM" == "Windows" ]] ; then
|
2013-03-01 16:13:44 +00:00
|
|
|
CONSOLE_LOG_ARGS="-o console.log.level:127"
|
|
|
|
fi
|
2012-05-30 21:42:24 +00:00
|
|
|
|
2012-03-30 18:19:35 +00:00
|
|
|
(cat "${CAPTURE_DIR}dhcp.pcap"; sleep 1; tail -c +25 "${CAPTURE_DIR}dhcp.pcap") | \
|
2011-05-26 20:23:38 +00:00
|
|
|
$DUT -i - $TRAFFIC_CAPTURE_PROMISC \
|
|
|
|
-w ./testout.pcap \
|
|
|
|
-a duration:$TRAFFIC_CAPTURE_DURATION \
|
2013-03-01 16:13:44 +00:00
|
|
|
$CONSOLE_LOG_ARGS \
|
2012-05-30 21:42:24 +00:00
|
|
|
> ./testout.txt 2> ./testerr.txt
|
2011-05-26 20:23:38 +00:00
|
|
|
RETURNVALUE=$?
|
|
|
|
if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
|
2012-05-30 21:42:24 +00:00
|
|
|
capture_test_output_print ./testout.txt ./testerr.txt ./dumpcap_debug_log.tmp
|
2016-04-26 21:57:15 +00:00
|
|
|
capture_test_output_capinfos ./testout.pcap
|
2012-05-30 21:42:24 +00:00
|
|
|
test_step_failed "Exit status of $DUT: $RETURNVALUE"
|
2011-05-26 20:23:38 +00:00
|
|
|
return
|
|
|
|
fi
|
2013-03-01 06:20:41 +00:00
|
|
|
|
2013-03-01 16:13:44 +00:00
|
|
|
if [ -n "$CONSOLE_LOG_ARGS" ] ; then
|
|
|
|
grep "Wireshark is up and ready to go" ./testout.txt > /dev/null 2>&1
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
test_step_failed "No startup message!"
|
|
|
|
fi
|
2012-05-30 21:42:24 +00:00
|
|
|
|
2013-03-01 16:13:44 +00:00
|
|
|
grep "Capture started" ./testerr.txt > /dev/null 2>&1
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
test_step_failed "No capture started message!"
|
|
|
|
fi
|
2012-05-30 21:42:24 +00:00
|
|
|
|
2013-03-01 16:13:44 +00:00
|
|
|
grep "Capture stopped" ./testerr.txt > /dev/null 2>&1
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
test_step_failed "No capture stopped message!"
|
|
|
|
fi
|
|
|
|
fi
|
2011-05-26 20:23:38 +00:00
|
|
|
|
|
|
|
# we should have an output file now
|
|
|
|
if [ ! -f "./testout.pcap" ]; then
|
|
|
|
test_step_failed "No output file!"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
# ok, we got a capture file, does it contain exactly 8 packets?
|
|
|
|
$CAPINFOS ./testout.pcap > ./testout.txt
|
|
|
|
grep -Ei 'Number of packets:[[:blank:]]+8' ./testout.txt > /dev/null
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
test_step_ok
|
|
|
|
else
|
|
|
|
echo
|
2011-06-28 23:08:05 +00:00
|
|
|
capture_test_output_print ./testout.txt
|
2011-05-26 20:23:38 +00:00
|
|
|
test_step_failed "No or not enough traffic captured."
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2006-01-05 22:26:05 +00:00
|
|
|
# capture exactly 2 times 10 packets (multiple files)
|
2005-12-13 23:15:20 +00:00
|
|
|
capture_step_2multi_10packets() {
|
2013-03-01 16:13:44 +00:00
|
|
|
if [ $SKIP_CAPTURE -ne 0 ] ; then
|
|
|
|
test_step_skipped
|
|
|
|
return
|
|
|
|
fi
|
2006-10-09 18:47:42 +00:00
|
|
|
|
2006-12-11 18:24:27 +00:00
|
|
|
traffic_gen_ping
|
2007-02-05 00:57:59 +00:00
|
|
|
|
|
|
|
date > ./testout.txt
|
2006-12-11 18:24:27 +00:00
|
|
|
$DUT -i $TRAFFIC_CAPTURE_IFACE $TRAFFIC_CAPTURE_PROMISC \
|
|
|
|
-w ./testout.pcap \
|
|
|
|
-c 10 \
|
|
|
|
-a duration:$TRAFFIC_CAPTURE_DURATION \
|
2015-12-12 00:30:39 +00:00
|
|
|
-f "icmp || icmp6" \
|
2007-02-05 00:57:59 +00:00
|
|
|
>> ./testout.txt 2>&1
|
2006-12-11 18:24:27 +00:00
|
|
|
|
2005-12-13 23:15:20 +00:00
|
|
|
RETURNVALUE=$?
|
2007-02-05 00:57:59 +00:00
|
|
|
date >> ./testout.txt
|
2005-12-13 23:15:20 +00:00
|
|
|
if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
|
2006-12-22 13:00:40 +00:00
|
|
|
echo
|
2011-06-28 23:08:05 +00:00
|
|
|
capture_test_output_print ./testout.txt
|
2005-12-13 23:15:20 +00:00
|
|
|
# part of the Prerequisite checks
|
|
|
|
# probably wrong interface, output the possible interfaces
|
2006-05-31 17:38:42 +00:00
|
|
|
$TSHARK -D
|
2006-12-22 04:46:26 +00:00
|
|
|
test_step_failed "exit status of $DUT: $RETURNVALUE"
|
2005-12-13 23:15:20 +00:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
# we should have an output file now
|
|
|
|
if [ ! -f "./testout.pcap" ]; then
|
|
|
|
test_step_failed "No output file!"
|
|
|
|
return
|
|
|
|
fi
|
2006-10-09 18:47:42 +00:00
|
|
|
|
2005-12-13 23:15:20 +00:00
|
|
|
# ok, we got a capture file, does it contain exactly 10 packets?
|
|
|
|
$CAPINFOS ./testout.pcap > ./testout.txt
|
2009-05-11 18:57:08 +00:00
|
|
|
grep -Ei 'Number of packets:[[:blank:]]+10' ./testout.txt > /dev/null
|
2005-12-13 23:15:20 +00:00
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
test_step_ok
|
|
|
|
else
|
|
|
|
echo
|
2011-06-28 23:08:05 +00:00
|
|
|
capture_test_output_print ./testout.txt
|
2005-12-13 23:15:20 +00:00
|
|
|
test_step_failed "Probably the wrong interface (no traffic captured)!"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# capture with a very unlikely read filter, packets must be zero afterwards
|
|
|
|
capture_step_read_filter() {
|
2013-03-01 16:13:44 +00:00
|
|
|
if [ $SKIP_CAPTURE -ne 0 ] ; then
|
|
|
|
test_step_skipped
|
|
|
|
return
|
|
|
|
fi
|
2006-10-09 18:47:42 +00:00
|
|
|
|
2006-12-11 18:24:27 +00:00
|
|
|
traffic_gen_ping
|
2007-02-05 00:57:59 +00:00
|
|
|
|
2005-12-13 23:15:20 +00:00
|
|
|
# valid, but very unlikely filter
|
2007-02-05 00:57:59 +00:00
|
|
|
date > ./testout.txt
|
2006-12-11 18:24:27 +00:00
|
|
|
$DUT -i $TRAFFIC_CAPTURE_IFACE $TRAFFIC_CAPTURE_PROMISC \
|
|
|
|
-w ./testout.pcap \
|
|
|
|
-a duration:$TRAFFIC_CAPTURE_DURATION \
|
2013-08-28 02:30:50 +00:00
|
|
|
-2 -R 'dcerpc.cn_call_id==123456' \
|
2006-12-11 18:24:27 +00:00
|
|
|
-c 10 \
|
2015-12-12 00:30:39 +00:00
|
|
|
-f "icmp || icmp6" \
|
2007-02-05 00:57:59 +00:00
|
|
|
>> ./testout.txt 2>&1
|
2005-12-13 23:15:20 +00:00
|
|
|
RETURNVALUE=$?
|
2007-02-05 00:57:59 +00:00
|
|
|
date >> ./testout.txt
|
2005-12-13 23:15:20 +00:00
|
|
|
if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
|
2006-12-22 13:00:40 +00:00
|
|
|
echo
|
2011-06-28 23:08:05 +00:00
|
|
|
capture_test_output_print ./testout.txt
|
2006-12-22 13:00:40 +00:00
|
|
|
# part of the Prerequisite checks
|
|
|
|
# wrong interface ? output the possible interfaces
|
|
|
|
$TSHARK -D
|
2005-12-13 23:15:20 +00:00
|
|
|
test_step_failed "exit status: $RETURNVALUE"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
# we should have an output file now
|
|
|
|
if [ ! -f "./testout.pcap" ]; then
|
|
|
|
test_step_failed "No output file!"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
# ok, we got a capture file, does it contain exactly 0 packets?
|
|
|
|
$CAPINFOS ./testout.pcap > ./testout.txt
|
2009-05-11 18:57:08 +00:00
|
|
|
grep -Ei 'Number of packets:[[:blank:]]+0' ./testout.txt > /dev/null
|
2005-12-13 23:15:20 +00:00
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
test_step_ok
|
|
|
|
else
|
|
|
|
echo
|
2011-06-28 23:08:05 +00:00
|
|
|
capture_test_output_print ./testout.txt
|
2005-12-13 23:15:20 +00:00
|
|
|
test_step_failed "Capture file should contain zero packets!"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# capture with a snapshot length
|
|
|
|
capture_step_snapshot() {
|
2013-03-01 06:20:41 +00:00
|
|
|
if [ $SKIP_CAPTURE -ne 0 ] ; then
|
|
|
|
test_step_skipped
|
|
|
|
return
|
|
|
|
fi
|
2006-10-09 18:47:42 +00:00
|
|
|
|
2006-12-11 18:24:27 +00:00
|
|
|
traffic_gen_ping
|
|
|
|
|
2005-12-13 23:15:20 +00:00
|
|
|
# capture with a snapshot length of 68 bytes for $TRAFFIC_CAPTURE_DURATION seconds
|
2007-05-17 02:43:38 +00:00
|
|
|
# this should result in no packets greater than 68 bytes
|
2007-02-05 00:57:59 +00:00
|
|
|
date > ./testout.txt
|
2006-12-11 18:24:27 +00:00
|
|
|
$DUT -i $TRAFFIC_CAPTURE_IFACE $TRAFFIC_CAPTURE_PROMISC \
|
|
|
|
-w ./testout.pcap \
|
|
|
|
-s 68 \
|
2006-12-22 18:16:22 +00:00
|
|
|
-a duration:$TRAFFIC_CAPTURE_DURATION \
|
2015-12-12 00:30:39 +00:00
|
|
|
-f "icmp || icmp6" \
|
2007-02-05 00:57:59 +00:00
|
|
|
>> ./testout.txt 2>&1
|
2005-12-13 23:15:20 +00:00
|
|
|
RETURNVALUE=$?
|
2007-02-05 00:57:59 +00:00
|
|
|
date >> ./testout.txt
|
2005-12-13 23:15:20 +00:00
|
|
|
if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
|
2006-12-22 13:00:40 +00:00
|
|
|
echo
|
2011-06-28 23:08:05 +00:00
|
|
|
capture_test_output_print ./testout.txt
|
2006-12-22 13:00:40 +00:00
|
|
|
# part of the Prerequisite checks
|
|
|
|
# wrong interface ? output the possible interfaces
|
|
|
|
$TSHARK -D
|
2005-12-13 23:15:20 +00:00
|
|
|
test_step_failed "exit status: $RETURNVALUE"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
# we should have an output file now
|
|
|
|
if [ ! -f "./testout.pcap" ]; then
|
|
|
|
test_step_failed "No output file!"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2006-05-31 17:38:42 +00:00
|
|
|
# use tshark to filter out all packets, which are larger than 68 bytes
|
2013-08-28 02:30:50 +00:00
|
|
|
$TSHARK -r ./testout.pcap -w ./testout2.pcap -Y 'frame.cap_len>68' > ./testout.txt 2>&1
|
2011-06-23 19:22:21 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo
|
2011-06-28 23:08:05 +00:00
|
|
|
capture_test_output_print ./testout.txt
|
2011-06-23 19:22:21 +00:00
|
|
|
test_step_failed "Problem running TShark!"
|
|
|
|
return
|
|
|
|
fi
|
2005-12-13 23:15:20 +00:00
|
|
|
|
|
|
|
# ok, we got a capture file, does it contain exactly 0 packets?
|
|
|
|
$CAPINFOS ./testout2.pcap > ./testout.txt
|
2009-05-11 18:57:08 +00:00
|
|
|
grep -Ei 'Number of packets:[[:blank:]]+0' ./testout.txt > /dev/null
|
2005-12-13 23:15:20 +00:00
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
test_step_ok
|
|
|
|
else
|
|
|
|
echo
|
2011-06-28 23:08:05 +00:00
|
|
|
capture_test_output_print ./testout.txt
|
2005-12-13 23:15:20 +00:00
|
|
|
test_step_failed "Capture file should contain zero packets!"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2006-06-17 11:49:03 +00:00
|
|
|
wireshark_capture_suite() {
|
2011-08-29 21:16:29 +00:00
|
|
|
# k: start capture immediately
|
|
|
|
# WIRESHARK_QUIT_AFTER_CAPTURE needs to be set.
|
2013-09-22 21:51:05 +00:00
|
|
|
|
2014-10-01 19:44:14 +00:00
|
|
|
#
|
|
|
|
# NOTE: This may not do the right thing if we use toolkits
|
|
|
|
# that use Wayland or Mir directly, unless they also depend
|
|
|
|
# on the DISPLAY environment variable.
|
|
|
|
#
|
2014-10-02 20:59:16 +00:00
|
|
|
#if [[ $WS_SYSTEM != Windows && $WS_SYSTEM != Darwin ]] && [ -z "$DISPLAY" ]; then
|
|
|
|
|
|
|
|
# Qt requires XKEYBOARD and Xrender, which our buildbots don't provide
|
|
|
|
if [[ $WS_SYSTEM != "Windows" && $WS_SYSTEM != "Darwin" ]]; then
|
|
|
|
echo -n " (assuming Xvnc, which doesn't support Xrender)"
|
2014-10-01 19:44:14 +00:00
|
|
|
test_step_skipped
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
DUT="$WIRESHARK_CMD"
|
|
|
|
test_step_add "Capture 10 packets" capture_step_10packets
|
|
|
|
# piping to stdout doesn't work with Wireshark and capturing!
|
|
|
|
#test_step_add "Capture 10 packets using stdout: -w -" capture_step_10packets_stdout
|
|
|
|
if [ $TEST_FIFO ]; then
|
|
|
|
test_step_add "Capture via fifo" capture_step_fifo
|
|
|
|
fi
|
|
|
|
test_step_add "Capture via stdin" capture_step_stdin
|
|
|
|
# read filter doesn't work with Wireshark and capturing!
|
|
|
|
#test_step_add "Capture read filter (${TRAFFIC_CAPTURE_DURATION}s)" capture_step_read_filter
|
|
|
|
test_step_add "Capture snapshot length 68 bytes (${TRAFFIC_CAPTURE_DURATION}s)" capture_step_snapshot
|
|
|
|
}
|
|
|
|
|
|
|
|
wireshark_gtk_capture_suite() {
|
2016-10-20 21:33:48 +00:00
|
|
|
if [ ! -x "$WIRESHARK_GTK" ]; then
|
|
|
|
echo -n ' (no GTK support)'
|
|
|
|
test_step_skipped
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2014-10-01 19:44:14 +00:00
|
|
|
# k: start capture immediately
|
|
|
|
# WIRESHARK_QUIT_AFTER_CAPTURE needs to be set.
|
|
|
|
|
2013-09-22 21:51:05 +00:00
|
|
|
#
|
|
|
|
# NOTE: if, on OS X, we start using a native-Quartz toolkit,
|
|
|
|
# this would need to change to check for WS_SYSTEM being
|
|
|
|
# "Darwin" and, if it is, check whether the standard output
|
|
|
|
# of "launchctl managername" is "Aqua".
|
|
|
|
#
|
|
|
|
# This may not do the right thing if we use toolkits that
|
|
|
|
# use Wayland or Mir directly, unless they also depend on
|
|
|
|
# the DISPLAY environment variable.
|
|
|
|
#
|
|
|
|
if [[ $WS_SYSTEM != Windows ]] && [ -z "$DISPLAY" ]; then
|
|
|
|
echo -n ' (X server not available)'
|
|
|
|
test_step_skipped
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2014-08-28 23:48:53 +00:00
|
|
|
DUT="$WIRESHARK_GTK_CMD"
|
2005-12-13 23:15:20 +00:00
|
|
|
test_step_add "Capture 10 packets" capture_step_10packets
|
2006-06-17 11:49:03 +00:00
|
|
|
# piping to stdout doesn't work with Wireshark and capturing!
|
2006-01-06 01:11:31 +00:00
|
|
|
#test_step_add "Capture 10 packets using stdout: -w -" capture_step_10packets_stdout
|
2011-05-31 18:34:24 +00:00
|
|
|
if [ $TEST_FIFO ]; then
|
|
|
|
test_step_add "Capture via fifo" capture_step_fifo
|
|
|
|
fi
|
|
|
|
test_step_add "Capture via stdin" capture_step_stdin
|
2006-06-17 11:49:03 +00:00
|
|
|
# read filter doesn't work with Wireshark and capturing!
|
2005-12-13 23:15:20 +00:00
|
|
|
#test_step_add "Capture read filter (${TRAFFIC_CAPTURE_DURATION}s)" capture_step_read_filter
|
|
|
|
test_step_add "Capture snapshot length 68 bytes (${TRAFFIC_CAPTURE_DURATION}s)" capture_step_snapshot
|
|
|
|
}
|
|
|
|
|
2006-05-31 17:38:42 +00:00
|
|
|
tshark_capture_suite() {
|
|
|
|
DUT=$TSHARK
|
2005-12-13 23:15:20 +00:00
|
|
|
test_step_add "Capture 10 packets" capture_step_10packets
|
2007-10-09 13:34:08 +00:00
|
|
|
test_step_add "Capture 10 packets using stdout: -w -" capture_step_10packets_stdout
|
2006-10-08 22:57:32 +00:00
|
|
|
if [ $TEST_FIFO ]; then
|
|
|
|
test_step_add "Capture via fifo" capture_step_fifo
|
|
|
|
fi
|
2011-05-26 20:23:38 +00:00
|
|
|
test_step_add "Capture via stdin" capture_step_stdin
|
2010-06-05 02:19:45 +00:00
|
|
|
# tshark now using dumpcap for capturing, read filters won't work by definition
|
2007-11-23 08:39:11 +00:00
|
|
|
#test_step_add "Capture read filter (${TRAFFIC_CAPTURE_DURATION}s)" capture_step_read_filter
|
2005-12-13 23:15:20 +00:00
|
|
|
test_step_add "Capture snapshot length 68 bytes (${TRAFFIC_CAPTURE_DURATION}s)" capture_step_snapshot
|
|
|
|
}
|
|
|
|
|
|
|
|
dumpcap_capture_suite() {
|
|
|
|
#DUT="$DUMPCAP -Q"
|
|
|
|
DUT=$DUMPCAP
|
|
|
|
test_step_add "Capture 10 packets" capture_step_10packets
|
2006-01-07 01:14:29 +00:00
|
|
|
test_step_add "Capture 10 packets using stdout: -w -" capture_step_10packets_stdout
|
2006-10-08 22:57:32 +00:00
|
|
|
if [ $TEST_FIFO ]; then
|
|
|
|
test_step_add "Capture via fifo" capture_step_fifo
|
|
|
|
fi
|
2011-05-26 20:23:38 +00:00
|
|
|
test_step_add "Capture via stdin" capture_step_stdin
|
2006-01-07 01:14:29 +00:00
|
|
|
# read (display) filters intentionally doesn't work with dumpcap!
|
2005-12-13 23:15:20 +00:00
|
|
|
#test_step_add "Capture read filter (${TRAFFIC_CAPTURE_DURATION}s)" capture_step_read_filter
|
|
|
|
test_step_add "Capture snapshot length 68 bytes (${TRAFFIC_CAPTURE_DURATION}s)" capture_step_snapshot
|
|
|
|
}
|
|
|
|
|
2006-01-05 22:26:05 +00:00
|
|
|
capture_cleanup_step() {
|
2007-01-28 18:56:17 +00:00
|
|
|
ping_cleanup
|
2005-12-13 23:15:20 +00:00
|
|
|
rm -f ./testout.txt
|
2012-05-30 21:42:24 +00:00
|
|
|
rm -f ./testerr.txt
|
2006-01-05 22:26:05 +00:00
|
|
|
rm -f ./testout2.txt
|
2005-12-13 23:15:20 +00:00
|
|
|
rm -f ./testout.pcap
|
|
|
|
rm -f ./testout2.pcap
|
|
|
|
}
|
|
|
|
|
|
|
|
capture_suite() {
|
2006-01-05 22:26:05 +00:00
|
|
|
test_step_set_pre capture_cleanup_step
|
|
|
|
test_step_set_post capture_cleanup_step
|
|
|
|
test_remark_add "Capture - need some traffic on interface: \"$TRAFFIC_CAPTURE_IFACE\""
|
2007-08-28 17:49:16 +00:00
|
|
|
test_suite_add "Dumpcap capture" dumpcap_capture_suite
|
|
|
|
test_suite_add "TShark capture" tshark_capture_suite
|
2014-10-03 00:02:13 +00:00
|
|
|
test_suite_add "Wireshark capture" wireshark_capture_suite
|
2014-10-01 19:44:14 +00:00
|
|
|
test_suite_add "Wireshark 1 capture" wireshark_gtk_capture_suite
|
2005-12-13 23:15:20 +00:00
|
|
|
}
|
2013-03-01 16:13:44 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Editor modelines - http://www.wireshark.org/tools/modelines.html
|
|
|
|
#
|
|
|
|
# Local variables:
|
2016-02-03 09:27:09 +00:00
|
|
|
# sh-basic-offset: 8
|
2013-03-01 16:13:44 +00:00
|
|
|
# tab-width: 8
|
|
|
|
# indent-tabs-mode: t
|
|
|
|
# End:
|
|
|
|
#
|
|
|
|
# vi: set shiftwidth=8 tabstop=8 noexpandtab:
|
|
|
|
# :indentSize=8:tabSize=8:noTabs=false:
|
|
|
|
#
|