summaryrefslogtreecommitdiffstats
path: root/ttcn3-tcpdump-start.sh
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2019-03-14 18:15:27 +0100
committerMax <msuraev@sysmocom.de>2019-03-14 20:46:51 +0000
commite521445fee7bb06b4b802cfd04e039555df10ed3 (patch)
treed83b60306c45abe22b298a9f1cf488dee6a23c50 /ttcn3-tcpdump-start.sh
parent6e05304843620f8aa92258a2e76239bc5b36dc2d (diff)
Generalize ttcn3-tcpdump-*.sh
Prepare for supporting alternative packet dumpers: * reword comments * rename pidfile * move tcpdump-specific option inside if * move comment about sudo closer to actual sudo invocation Those are cosmetic changes which do not affect how packet dump is made but makes it easier to support alternative packet dumpers in follow-up commit. Change-Id: Ib2528db65348c0422fe8b7c7c53656fbce4f6405
Diffstat (limited to 'ttcn3-tcpdump-start.sh')
-rwxr-xr-xttcn3-tcpdump-start.sh18
1 files changed, 9 insertions, 9 deletions
diff --git a/ttcn3-tcpdump-start.sh b/ttcn3-tcpdump-start.sh
index 747002b..b8ad01a 100755
--- a/ttcn3-tcpdump-start.sh
+++ b/ttcn3-tcpdump-start.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-PIDFILE=/tmp/tcpdump.pid
+PIDFILE=/tmp/dumper.pid
TCPDUMP=/usr/sbin/tcpdump
TESTCASE=$1
@@ -16,19 +16,19 @@ if [ -e $PIDFILE ]; then
rm $PIDFILE
fi
-# NOTE: This requires you to be root or something like
-# "laforge ALL=NOPASSWD: /usr/sbin/tcpdump, /bin/kill" in your sudoers file
if [ "$(id -u)" = "0" ]; then
- CMD=$TCPDUMP
+ CMD="$TCPDUMP -U"
else
- CMD="sudo $TCPDUMP"
+# NOTE: This requires you to be root or something like
+# "laforge ALL=NOPASSWD: /usr/sbin/tcpdump, /bin/kill" in your sudoers file
+ CMD="sudo $TCPDUMP -U"
fi
-$CMD -U -s 1500 -n -i any -w "$TTCN3_PCAP_PATH/$TESTCASE.pcap" >$TTCN3_PCAP_PATH/$TESTCASE.pcap.stdout 2>&1 &
+$CMD -s 1500 -n -i any -w "$TTCN3_PCAP_PATH/$TESTCASE.pcap" >$TTCN3_PCAP_PATH/$TESTCASE.pcap.stdout 2>&1 &
PID=$!
echo $PID > $PIDFILE
-# Wait until tcpdump creates the pcap file and starts recording.
-# We generate some traffic until we see tcpdump catches it.
+# Wait until packet dumper creates the pcap file and starts recording.
+# We generate some traffic until we see packet dumper catches it.
# Timeout is 10 seconds.
ping 127.0.0.1 >/dev/null 2>&1 &
PID=$!
@@ -36,7 +36,7 @@ i=0
while [ ! -f "$TTCN3_PCAP_PATH/$TESTCASE.pcap" ] ||
[ "$(stat -c '%s' "$TTCN3_PCAP_PATH/$TESTCASE.pcap")" -eq 32 ]
do
- echo "Waiting for tcpdump to start... $i"
+ echo "Waiting for packet dumper to start... $i"
sleep 1
i=$((i+1))
if [ $i -eq 10 ]; then