3 # List the protocols (dissectors) used in capture file(s)
5 # The Python script indexcap.py does the same thing.
7 # This script extracts the protocol names contained in a given capture file.
8 # This is useful for generating a "database" (flat file :-)) of in what file
9 # a given protocol can be found.
11 # Output consists of the file name followed by the protocols, for example:
12 # /path/to/the/file.pcap eth ip sctp
14 # Copyright 2012 Jeff Morriss <jeff.morriss.ws [AT] gmail.com>
16 # Wireshark - Network traffic analyzer
17 # By Gerald Combs <gerald@wireshark.org>
18 # Copyright 1998 Gerald Combs
20 # SPDX-License-Identifier: GPL-2.0-or-later
22 # Directory containing binaries. Default current directory.
23 WS_BIN_PATH
=${WS_BIN_PATH:-.}
25 # Tweak the following to your liking. Editcap must support "-E".
26 TSHARK
="$WS_BIN_PATH/tshark"
27 CAPINFOS
="$WS_BIN_PATH/capinfos"
29 if [ "$WS_BIN_PATH" = "." ]; then
30 export WIRESHARK_RUN_FROM_BUILD_DIRECTORY
=
34 for i
in "$TSHARK" "$CAPINFOS"
38 echo "Couldn't find $i" 1>&2
42 if [ $NOTFOUND -eq 1 ]
47 # Make sure we have at least one file
51 if [ "$OSTYPE" == "cygwin" ]
53 CF
=`cygpath --windows "$CF"`
55 "$CAPINFOS" "$CF" > /dev
/null
2>&1 && FOUND
=1
62 if [ $FOUND -eq 0 ] ; then
64 Error: No valid capture files found.
66 Usage: `basename $0` capture file 1 [capture file 2]...
72 if [ "$OSTYPE" == "cygwin" ] ; then
73 CF
=`cygpath --windows "$CF"`
76 if [ ! -f "$CF" ] ; then
77 echo "Doesn't exist or not a file: $CF" 1>&2
81 "$CAPINFOS" "$CF" > /dev
/null
83 if [ $RETVAL -ne 0 ] ; then
84 echo "Not a valid capture file (or some other problem)" 1>&2
90 # Extract the protocol names.
91 $TSHARK -T fields
-eframe.protocols
-nr "$CF" 2>/dev
/null | \
92 tr ':\r' '\n' |
sort -u |
tr '\n\r' ' '