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>
18 # Wireshark - Network traffic analyzer
19 # By Gerald Combs <gerald@wireshark.org>
20 # Copyright 1998 Gerald Combs
22 # This program is free software; you can redistribute it and/or
23 # modify it under the terms of the GNU General Public License
24 # as published by the Free Software Foundation; either version 2
25 # of the License, or (at your option) any later version.
27 # This program is distributed in the hope that it will be useful,
28 # but WITHOUT ANY WARRANTY; without even the implied warranty of
29 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 # GNU General Public License for more details.
32 # You should have received a copy of the GNU General Public License
33 # along with this program; if not, write to the Free Software
34 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
36 # Directory containing binaries. Default current directory.
39 # Tweak the following to your liking. Editcap must support "-E".
40 TSHARK
="$BIN_DIR/tshark"
41 CAPINFOS
="$BIN_DIR/capinfos"
43 if [ "$BIN_DIR" = "." ]; then
44 export WIRESHARK_RUN_FROM_BUILD_DIRECTORY
=
48 for i
in "$TSHARK" "$CAPINFOS"
52 echo "Couldn't find $i" 1>&2
56 if [ $NOTFOUND -eq 1 ]
61 # Make sure we have at least one file
65 if [ "$OSTYPE" == "cygwin" ]
67 CF
=`cygpath --windows "$CF"`
69 "$CAPINFOS" "$CF" > /dev
/null
2>&1 && FOUND
=1
76 if [ $FOUND -eq 0 ] ; then
78 Error: No valid capture files found.
80 Usage: `basename $0` capture file 1 [capture file 2]...
86 if [ "$OSTYPE" == "cygwin" ] ; then
87 CF
=`cygpath --windows "$CF"`
90 if [ ! -f "$CF" ] ; then
91 echo "Doesn't exist or not a file: $CF" 1>&2
95 "$CAPINFOS" "$CF" > /dev
/null
97 if [ $RETVAL -ne 0 ] ; then
98 echo "Not a valid capture file (or some other problem)" 1>&2
104 # Extract the protocol names.
105 $TSHARK -T fields
-eframe.protocols
-nr "$CF" 2>/dev
/null |
tr ':\r' '\n' \
106 |
sort -u |
tr '\n\r' ' '