aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJeff Morriss <jeff.morriss@ulticom.com>2011-04-04 19:10:30 +0000
committerJeff Morriss <jeff.morriss@ulticom.com>2011-04-04 19:10:30 +0000
commit8dba97226a0914024dea8e5ecf7e126ad3019abb (patch)
treeacf6fc426f932ec9e308215bd9a87b9751a218b4 /tools
parent4cbe8ff6dbacc9f86aa4942eec21001e04d3bd9e (diff)
Based on idea from Bill Meier:
A little script to extract the protocols used in given capture files. (Just so I don't have to remember how to do it again.) svn path=/trunk/; revision=36462
Diffstat (limited to 'tools')
-rw-r--r--tools/Makefile.am1
-rwxr-xr-xtools/list_protos_in_cap.sh76
2 files changed, 77 insertions, 0 deletions
diff --git a/tools/Makefile.am b/tools/Makefile.am
index b7835b125c..50b7c62dae 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -97,6 +97,7 @@ EXTRA_DIST = \
idl2wrs.sh \
idl2wrs.sh.in \
lex.py \
+ list_protos_in_cap.sh \
Makefile.nmake \
make-dissector-reg \
make-dissector-reg.py \
diff --git a/tools/list_protos_in_cap.sh b/tools/list_protos_in_cap.sh
new file mode 100755
index 0000000000..76cabb7c21
--- /dev/null
+++ b/tools/list_protos_in_cap.sh
@@ -0,0 +1,76 @@
+#!/bin/bash
+#
+# $Id$
+#
+# List the protocols (dissectors) used in capture file(s)
+#
+# This script extracts the protocol names contained in a given capture file.
+# This is useful for generating a "database" (flat file :-)) of in what file
+# a given protocol can be found.
+#
+# Output consists of the file name followed by the protocols, for example:
+# /path/to/the/file.pcap eth ip sctp
+
+# Directory containing binaries. Default current directory.
+BIN_DIR=_build
+
+# Tweak the following to your liking. Editcap must support "-E".
+TSHARK="$BIN_DIR/tshark"
+CAPINFOS="$BIN_DIR/capinfos"
+
+if [ "$BIN_DIR" = "." ]; then
+ export WIRESHARK_RUN_FROM_BUILD_DIRECTORY=
+fi
+
+NOTFOUND=0
+for i in "$TSHARK" "$CAPINFOS"
+do
+ if [ ! -x $i ]
+ then
+ echo "Couldn't find $i"
+ NOTFOUND=1
+ fi
+done
+if [ $NOTFOUND -eq 1 ]
+then
+ exit 1
+fi
+
+# Make sure we have at least one file
+FOUND=0
+for CF in "$@"
+do
+ if [ "$OSTYPE" == "cygwin" ]
+ then
+ CF=`cygpath --windows "$CF"`
+ fi
+ "$CAPINFOS" "$CF" > /dev/null 2>&1 && FOUND=1
+ if [ $FOUND -eq 1 ]
+ then
+ break
+ fi
+done
+
+if [ $FOUND -eq 0 ] ; then
+ cat <<FIN
+Error: No valid capture files found.
+
+Usage: `basename $0` capture file 1 [capture file 2]...
+FIN
+ exit 1
+fi
+
+for CF in "$@" ; do
+ "$CAPINFOS" "$CF" > /dev/null
+ if [ "$OSTYPE" == "cygwin" ] ; then
+ CF=`cygpath --windows "$CF"`
+ fi
+ printf "$CF "
+
+ # Extract the protocol names.
+ $TSHARK -T fields -eframe.protocols -nr "$CF" 2>/dev/null | sed 's/:/\n/g' \
+ | sort -u | tr '\n' ' '
+
+ printf "\n"
+done
+