gbproxy: Properly capture HDLC/FR traffic in addition to ethernet

We cannot use "-i all" but must list each interface separately,
which is only supported by dumpcap.  We also must write pcapng
files.

Change-Id: Id412af3bb6bcad5e0f2cf40a6dc497d7e4f3d948
diff --git a/ttcn3-dumpcap-stop.sh b/ttcn3-dumpcap-stop.sh
new file mode 100755
index 0000000..e13fbc0
--- /dev/null
+++ b/ttcn3-dumpcap-stop.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+
+PIDFILE_PCAP=/tmp/pcap.pid
+PIDFILE_NETCAT=/tmp/netcat.pid
+TESTCASE=$1
+VERDICT="$2"
+
+kill_rm_pidfile() {
+if [ -e $1 ]; then
+        PSNAME="$(ps -q "$(cat "$1")" -o comm=)"
+	if [ "$PSNAME" != "sudo" ]; then
+		kill "$(cat "$1")"
+	else
+	# NOTE: This requires you to be root or something like
+	# "laforge ALL=NOPASSWD: /usr/sbin/tcpdump, /bin/kill" in your sudoers file
+		sudo kill "$(cat "$1")"
+	fi
+	rm $1
+fi
+}
+
+date
+
+if [ x"$VERDICT" = x"pass" ]; then
+	echo -e "\033[1;32m====== $TESTCASE $VERDICT ======\033[0m"
+else
+	echo -e "\033[1;31m------ $TESTCASE $VERDICT ------\033[0m"
+fi
+echo
+
+if [ "z$TTCN3_PCAP_PATH" = "z" ]; then
+	TTCN3_PCAP_PATH=/tmp
+fi
+
+# Wait for up to 2 seconds if we keep receiving traffinc from packet dumper,
+# otherwise we might lose last packets from test.
+i=0
+prev_count=-1
+count=$(stat --format="%s" "$TTCN3_PCAP_PATH/$TESTCASE.pcapng")
+while [ $count -gt $prev_count ] && [ $i -lt 2 ]
+do
+	echo "Waiting for packet dumper to finish... $i (prev_count=$prev_count, count=$count)"
+	sleep 1
+	prev_count=$count
+	count=$(stat --format="%s" "$TTCN3_PCAP_PATH/$TESTCASE.pcapng")
+	i=$((i+1))
+done
+
+kill_rm_pidfile "$PIDFILE_PCAP"
+kill_rm_pidfile "$PIDFILE_NETCAT"
+
+gzip -f "$TTCN3_PCAP_PATH/$TESTCASE.pcapng"