From 8958bab6dee184310e4393e33591eb0cef1f7de1 Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Wed, 31 May 2006 17:38:42 +0000 Subject: Tethereal/tethereal -> TShark/tshark. svn path=/trunk/; revision=18268 --- FAQ | 18 +- INSTALL | 12 +- Makefile.am | 58 +- Makefile.common | 18 +- Makefile.nmake | 22 +- README.bsd | 2 +- README.hpux | 2 +- README.linux | 2 +- README.macos | 2 +- README.win32 | 10 +- capture-wpcap.c | 2 +- capture_info.c | 14 +- capture_loop.c | 6 +- capture_loop.h | 4 +- capture_opts.c | 2 +- capture_wpcap_packet.c | 2 +- clopts_common.c | 2 +- clopts_common.h | 2 +- configure.in | 24 +- debian/rules | 2 +- debian/tethereal.files | 6 - debian/tethereal.manpages | 3 - debian/tshark.files | 6 + debian/tshark.manpages | 3 + doc/Makefile.am | 18 +- doc/Makefile.nmake | 24 +- doc/README.developer | 6 +- doc/README.regression | 16 +- doc/README.stats_tree | 4 +- doc/README.tapping | 4 +- doc/README.xml-output | 16 +- doc/capinfos.pod | 2 +- doc/dumpcap.pod | 2 +- doc/ethereal-filter.pod.template | 14 +- doc/ethereal.pod | 2 +- doc/tethereal.pod | 874 ------- doc/tshark.pod | 874 +++++++ docbook/edg_src/EDG_chapter_userinterface.xml | 2 +- docbook/release-notes.xml | 2 +- docbook/wsug_src/WSUG_app_tools.xml | 10 +- docbook/wsug_src/WSUG_chapter_build_install.xml | 4 +- docbook/wsug_src/WSUG_chapter_customize.xml | 2 +- epan/addr_resolv.h | 2 +- epan/dissectors/packet-http.c | 2 +- epan/dissectors/packet-mdshdr.c | 2 +- epan/dissectors/packet-smb-sidsnooping.c | 4 +- epan/emem.c | 4 +- epan/filesystem.c | 2 +- epan/privileges.c | 2 +- epan/stats_tree.c | 2 +- gtk/dcerpc_stat.c | 2 +- gtk/help_dlg.c | 4 +- gtk/help_dlg.h | 2 +- gtk/main.c | 2 +- gtk/menu.c | 2 +- gtk/rpc_progs.c | 2 +- help/capturing.txt | 2 +- help/faq.txt | 18 +- image/Makefile.nmake | 6 +- image/README.image | 2 +- image/tethereal.rc.in | 36 - image/tshark.rc.in | 36 + packaging/nsis/Makefile.nmake | 4 +- packaging/nsis/wireshark.nsi | 20 +- plugins/asn1/packet-asn1.c | 2 +- plugins/lua/elua_gui.c | 2 +- plugins/lua/elua_tap.c | 2 +- tap-afpstat.c | 2 +- tap-bootpstat.c | 2 +- tap-dcerpcstat.c | 10 +- tap-h225counter.c | 2 +- tap-h225rassrt.c | 2 +- tap-httpstat.c | 2 +- tap-iostat.c | 20 +- tap-iousers.c | 4 +- tap-mgcpstat.c | 2 +- tap-protocolinfo.c | 10 +- tap-protohierstat.c | 6 +- tap-rpcprogs.c | 6 +- tap-rpcstat.c | 22 +- tap-sctpchunkstat.c | 2 +- tap-sipstat.c | 2 +- tap-smbsids.c | 4 +- tap-smbstat.c | 2 +- tap-stats_tree.c | 2 +- tap-wspstat.c | 14 +- test/README.test | 2 +- test/config.sh | 2 +- test/suite-capture.sh | 20 +- test/suite-clopts.sh | 24 +- test/suite-io.sh | 18 +- test/test.sh | 8 +- tethereal.c | 3067 ----------------------- tools/EtherealXML.py | 2 +- tools/dfilter-test.py | 28 +- tools/ftsanity.py | 14 +- tools/fuzz-test.sh | 18 +- tools/msnchat | 22 +- tools/pkt-from-core.py | 4 +- tshark.c | 3067 +++++++++++++++++++++++ wiretap/nettl.c | 2 +- 101 files changed, 4339 insertions(+), 4339 deletions(-) delete mode 100644 debian/tethereal.files delete mode 100644 debian/tethereal.manpages create mode 100644 debian/tshark.files create mode 100644 debian/tshark.manpages delete mode 100644 doc/tethereal.pod create mode 100644 doc/tshark.pod delete mode 100644 image/tethereal.rc.in create mode 100644 image/tshark.rc.in delete mode 100644 tethereal.c create mode 100644 tshark.c diff --git a/FAQ b/FAQ index 9b9af11da9..1a93aa2df7 100644 --- a/FAQ +++ b/FAQ @@ -41,7 +41,7 @@ 3. Installing Ethereal: - 3.1 I installed an Ethereal RPM; why did it install Tethereal but not + 3.1 I installed an Ethereal RPM; why did it install TShark but not Ethereal? 4. Building Ethereal: @@ -70,7 +70,7 @@ 5.1 Why does Ethereal crash with a Bus Error when I try to run it on Solaris 8? - 5.2 When I run Tethereal with the "-x" option, why does it crash with an + 5.2 When I run TShark with the "-x" option, why does it crash with an error "** ERROR **: file print.c: line 691 (print_line): should not be reached. @@ -1169,7 +1169,7 @@ cies 3. Installing Ethereal - Q 3.1: I installed an Ethereal RPM; why did it install Tethereal but not + Q 3.1: I installed an Ethereal RPM; why did it install TShark but not Ethereal? A: Older versions of the Red Hat RPMs for Wireshark put only the non-GUI @@ -1270,7 +1270,7 @@ cies Similar problems may exist with older versions of GTK+ for earlier versions of Solaris. - Q 5.2: When I run Tethereal with the "-x" option, why does it crash with an + Q 5.2: When I run TShark with the "-x" option, why does it crash with an error "** ERROR **: file print.c: line 691 (print_line): should not be reached. @@ -1440,7 +1440,7 @@ cies supply to the host all network packets they see. Ethereal will try to put the interface on which it's capturing into promiscuous mode unless the "Capture packets in promiscuous mode" option is turned off in the "Capture - Options" dialog box, and Tethereal will try to put the interface on which + Options" dialog box, and TShark will try to put the interface on which it's capturing into promiscuous mode unless the -p option was specified. However, some network interfaces don't support promiscuous mode, and some OSes might not allow interfaces to be put into promiscuous mode. @@ -1537,7 +1537,7 @@ cies Q 7.6: How do I put an interface into promiscuous mode? - A: By not disabling promiscuous mode when running Ethereal or Tethereal. + A: By not disabling promiscuous mode when running Ethereal or TShark. Note, however, that: * the form of promiscuous mode that libpcap (the library that programs @@ -1768,7 +1768,7 @@ cies A: If you are running Ethereal on Windows NT 4.0, Windows 2000, Windows XP, or Windows Server 2003, and this is the first time you have run a - WinPcap-based program (such as Ethereal, or Tethereal, or WinDump, or + WinPcap-based program (such as Ethereal, or TShark, or WinDump, or Analyzer, or...) since the machine was rebooted, you need to run that program from an account with administrator privileges; once you have run such a program, you will not need administrator privileges to run any such @@ -2137,7 +2137,7 @@ cies passively capture packets. This means that you should disable name resolution when capturing in monitor - mode; otherwise, when Ethereal (or Tethereal, or tcpdump) tries to display + mode; otherwise, when Ethereal (or TShark, or tcpdump) tries to display IP addresses as host names, it will probably block for a long time trying to resolve the name because it will not be able to communicate with any DNS or NIS servers. @@ -2179,7 +2179,7 @@ cies possible" option, clicking "Save" if you want to save that setting in your preference file, and clicking "OK". - It can also be set on the Wireshark or Tethereal command line with a -o + It can also be set on the Wireshark or TShark command line with a -o tcp.check_checksum:false command-line flag, or manually set in your preferences file by adding a tcp.check_checksum:false line. diff --git a/INSTALL b/INSTALL index 35a4ac9e44..0a9b951780 100644 --- a/INSTALL +++ b/INSTALL @@ -33,7 +33,7 @@ README.win32 for those instructions. GLib 2.x; you need to configure with --disable-gtk2 to use GTK+ 1.2[.x]. -2. If you wish to build Tethereal, the line-mode version of Ethereal, +2. If you wish to build TShark, the line-mode version of Ethereal, make sure you have GLIB installed. See note #1 above for instructions on checking if you have GLIB installed. You can download GLIB from the same site as GTK. @@ -83,8 +83,8 @@ README.win32 for those instructions. --disable-gtk2 Build Glib/Gtk+ 1.2[.x]-based ethereal. - --disable-tethereal - By default the line-mode packet analyzer, Tethereal, is built. + --disable-tshark + By default the line-mode packet analyzer, TShark, is built. Use this switch to avoid building it. --disable-editcap @@ -128,7 +128,7 @@ README.win32 for those instructions. By default, if 'configure' finds zlib (a.k.a, libz), the wiretap library will be built so that it can read compressed capture files. If you have zlib but do not wish to build - it into the wiretap library, used by Wireshark, Tethereal, and + it into the wiretap library, used by Wireshark, TShark, and the capture-file utilities that come in this package, use this switch. @@ -144,7 +144,7 @@ README.win32 for those instructions. --enable-setuid-install Use this switch to install the packet analyzers as setuid. - Installating Ethereal and Tethereal as setuid 'root' is + Installating Ethereal and TShark as setuid 'root' is dangerous. Repeat: IT'S DANGEROUS. Don't do it. --with-ssl=DIR @@ -195,7 +195,7 @@ README.win32 for those instructions. 6. Run 'make'. Hopefully, you won't run into any problems. -7. Run './ethereal' or './tethereal', and make sure things are working. +7. Run './ethereal' or './tshark', and make sure things are working. You must have root privileges in order to capture live data. 8. Run 'make install'. If you wish to install the man page, run diff --git a/Makefile.am b/Makefile.am index 3f8640e4e6..fbb7f92e28 100644 --- a/Makefile.am +++ b/Makefile.am @@ -60,13 +60,13 @@ ACLOCAL_AMFLAGS = `./aclocal-flags` # automake will arrange that the Makefile define it as the union of all # the "man{section}_MANS" variables. # -bin_PROGRAMS = @ethereal_bin@ @capinfos_bin@ @editcap_bin@ @mergecap_bin@ @tethereal_bin@ @dftest_bin@ @randpkt_bin@ @text2pcap_bin@ @dumpcap_bin@ +bin_PROGRAMS = @ethereal_bin@ @capinfos_bin@ @editcap_bin@ @mergecap_bin@ @tshark_bin@ @dftest_bin@ @randpkt_bin@ @text2pcap_bin@ @dumpcap_bin@ bin_SCRIPTS = @idl2wrs_bin@ -man1_MANS = @ethereal_man@ @capinfos_man@ @editcap_man@ @mergecap_man@ @tethereal_man@ @text2pcap_man@ @dumpcap_man@ @idl2wrs_man@ +man1_MANS = @ethereal_man@ @capinfos_man@ @editcap_man@ @mergecap_man@ @tshark_man@ @text2pcap_man@ @dumpcap_man@ @idl2wrs_man@ man4_MANS = @etherealfilter_man@ man_MANS = -EXTRA_PROGRAMS = ethereal tethereal capinfos editcap mergecap dftest \ +EXTRA_PROGRAMS = ethereal tshark capinfos editcap mergecap dftest \ randpkt text2pcap dumpcap EXTRA_SCRIPTS = idl2wrs @@ -77,7 +77,7 @@ idl2wrs: tools/idl2wrs.sh Makefile # # Ethereal configuration files are put in $(pkgdatadir). # -pkgdata_DATA = AUTHORS-SHORT manuf ethereal.html tethereal.html \ +pkgdata_DATA = AUTHORS-SHORT manuf ethereal.html tshark.html \ ethereal-filter.html capinfos.html editcap.html \ idl2wrs.html mergecap.html text2pcap.html dumpcap.html \ cfilters colorfilters dfilters @@ -266,11 +266,11 @@ endif # HAVE_PLUGINS # Optional objects that I know how to build. These will be # linked into the ethereal executable. -# They will also be linked into the tethereal executable; if this +# They will also be linked into the tshark executable; if this # list ever grows to include something that can't be linked with -# tethereal, or if tethereal needs something that wireshark doesn't, +# tshark, or if tshark needs something that wireshark doesn't, # we should probably split this into stuff needed both -# by wireshark and tethereal and stuff needed only by one or the +# by wireshark and tshark and stuff needed only by one or the # other. ethereal_optional_objects = @GETOPT_O@ @SNPRINTF_O@ @STRERROR_O@ \ @STRCASECMP_O@ @STRNCASECMP_O@ @MKSTEMP_O@ @STRPTIME_O@ @@ -312,21 +312,21 @@ ethereal_LDADD = \ @LIBGNUTLS_LIBS@ # Additional libs that I know how to build. These will be -# linked into the tethereal executable. -tethereal_additional_libs = \ +# linked into the tshark executable. +tshark_additional_libs = \ wiretap/libwiretap.la \ epan/libwireshark.la # This is the automake dependency variable for the executable -tethereal_DEPENDENCIES = \ +tshark_DEPENDENCIES = \ $(ethereal_optional_objects) \ - $(tethereal_additional_libs) \ + $(tshark_additional_libs) \ $(plugin_libs) # This automake variable adds to the link-line for the executable -tethereal_LDADD = \ +tshark_LDADD = \ $(ethereal_optional_objects) \ - $(tethereal_additional_libs) \ + $(tshark_additional_libs) \ @SNMP_LIBS@ @SSL_LIBS@ \ $(plugin_ldadd) \ @PCRE_LIBS@ \ @@ -335,9 +335,9 @@ tethereal_LDADD = \ @LIBGNUTLS_LIBS@ if ENABLE_STATIC -tethereal_LDFLAGS = -Wl,-static -all-static +tshark_LDFLAGS = -Wl,-static -all-static else -tethereal_LDFLAGS = -export-dynamic +tshark_LDFLAGS = -export-dynamic endif # Optional objects that I know how to build, and that are needed by @@ -398,9 +398,9 @@ SUFFIXES = .sh $(editsh) $< > $@.tmp && chmod +x $@.tmp && mv $@.tmp $@ # -# Build "tethereal-tap-register.c", which contains a function +# Build "tshark-tap-register.c", which contains a function # "register_all_tap_listeners()" -# that calls the register routines for all tethereal tap listeners. +# that calls the register routines for all tshark tap listeners. # # We do this by grepping through sources. # @@ -411,9 +411,9 @@ SUFFIXES = .sh # The first argument is the directory in which the source files live. # All subsequent arguments are the files to scan. # -tethereal-tap-register.c: $(TETHEREAL_TAP_SRC) $(srcdir)/make-tapreg-dotc - @echo Making tethereal-tap-register.c - @$(srcdir)/make-tapreg-dotc tethereal-tap-register.c $(srcdir) $(TETHEREAL_TAP_SRC) +tshark-tap-register.c: $(TSHARK_TAP_SRC) $(srcdir)/make-tapreg-dotc + @echo Making tshark-tap-register.c + @$(srcdir)/make-tapreg-dotc tshark-tap-register.c $(srcdir) $(TSHARK_TAP_SRC) ps.c: print.ps rdps ./rdps $(srcdir)/print.ps ps.c @@ -557,7 +557,7 @@ EXTRA_DIST = \ doc/idl2wrs.pod \ doc/mergecap.pod \ doc/randpkt.txt \ - doc/tethereal.pod \ + doc/tshark.pod \ doc/text2pcap.pod \ doc/dumpcap.pod \ docbook/Makefile.auto.am \ @@ -608,7 +608,7 @@ EXTRA_DIST = \ image/stock_dialog_question_48.xpm \ image/stock_dialog_info_48.xpm \ image/stock_dialog_stop_48.xpm \ - image/tethereal.rc.in \ + image/tshark.rc.in \ image/text2pcap.rc.in \ image/toolbar/autoscroll_24.xpm \ image/toolbar/capture_filter_24.xpm \ @@ -688,7 +688,7 @@ EXTRA_DIST = \ if SETUID_INSTALL install-exec-hook: -chmod +s $(DESTDIR)$(bindir)/dumpcap - -chmod +s $(DESTDIR)$(bindir)/tethereal + -chmod +s $(DESTDIR)$(bindir)/tshark else install-exec-hook: endif @@ -705,11 +705,11 @@ ethereal.1: doc/ethereal.pod AUTHORS-SHORT-FORMAT (cd doc ; \ $(MAKE) ../ethereal.1 ) -tethereal.1: doc/tethereal.pod +tshark.1: doc/tshark.pod (cd doc ; \ - $(MAKE) ../tethereal.1 ) + $(MAKE) ../tshark.1 ) -ethereal-filter.4: tethereal doc/ethereal-filter.pod.template +ethereal-filter.4: tshark doc/ethereal-filter.pod.template (cd doc ; \ $(MAKE) ../ethereal-filter.4 ) @@ -741,11 +741,11 @@ ethereal.html: doc/ethereal.pod AUTHORS-SHORT-FORMAT (cd doc ; \ $(MAKE) ../ethereal.html ) -tethereal.html: doc/tethereal.pod +tshark.html: doc/tshark.pod (cd doc ; \ - $(MAKE) ../tethereal.html ) + $(MAKE) ../tshark.html ) -ethereal-filter.html: tethereal doc/ethereal-filter.pod.template +ethereal-filter.html: tshark doc/ethereal-filter.pod.template (cd doc ; \ $(MAKE) ../ethereal-filter.html ) diff --git a/Makefile.common b/Makefile.common index c8615a6dc5..9cb087ec4f 100644 --- a/Makefile.common +++ b/Makefile.common @@ -39,12 +39,12 @@ GENERATED_HEADER_FILES = \ # C source files generated from source files. GENERATED_C_FILES = \ $(BUILT_C_FILES) \ - tethereal-tap-register.c + tshark-tap-register.c # All the generated files. GENERATED_FILES = $(GENERATED_C_FILES) $(GENERATED_HEADER_FILES) -# sources common for ethereal and tethereal +# sources common for ethereal and tshark ETHEREAL_COMMON_SRC = \ $(PLATFORM_SRC) \ capture_errs.c \ @@ -92,8 +92,8 @@ ETHEREAL_COMMON_INCLUDES = \ util.h \ version_info.h -# sources for Tethereal taps -TETHEREAL_TAP_SRC = \ +# sources for TShark taps +TSHARK_TAP_SRC = \ tap-afpstat.c \ tap-ansi_astat.c \ tap-bootpstat.c \ @@ -181,15 +181,15 @@ ethereal_INCLUDES = \ tap_dfilter_dlg.h \ ui_util.h -# tethereal specifics -tethereal_SOURCES = \ +# tshark specifics +tshark_SOURCES = \ $(ETHEREAL_COMMON_SRC) \ - $(TETHEREAL_TAP_SRC) \ + $(TSHARK_TAP_SRC) \ capture_opts.c \ capture_loop.c \ tempfile.c \ - tethereal-tap-register.c \ - tethereal.c + tshark-tap-register.c \ + tshark.c # text2pcap specifics text2pcap_SOURCES = \ diff --git a/Makefile.nmake b/Makefile.nmake index 8be8320c07..2d558c680f 100644 --- a/Makefile.nmake +++ b/Makefile.nmake @@ -29,7 +29,7 @@ PLATFORM_SRC = capture-wpcap.c capture_wpcap_packet.c include Makefile.common ethereal_OBJECTS = $(ethereal_SOURCES:.c=.obj) -tethereal_OBJECTS = $(tethereal_SOURCES:.c=.obj) +tshark_OBJECTS = $(tshark_SOURCES:.c=.obj) dftest_OBJECTS = $(dftest_SOURCES:.c=.obj) dumpcap_OBJECTS = $(dumpcap_SOURCES:.c=.obj) @@ -65,7 +65,7 @@ ethereal_LIBS= wiretap\wiretap-$(WTAP_VERSION).lib \ !ENDIF # $(PCAP_DIR)\lib\wpcap.lib -tethereal_LIBS= wiretap\wiretap-$(WTAP_VERSION).lib \ +tshark_LIBS= wiretap\wiretap-$(WTAP_VERSION).lib \ wsock32.lib user32.lib \ $(GLIB_LIBS) \ $(NET_SNMP_DIR)\win32\lib\release\netsnmp.lib \ @@ -118,10 +118,10 @@ randpkt_LIBS= wiretap\wiretap-$(WTAP_VERSION).lib \ $(GLIB_LIBS) \ $(NET_SNMP_DIR)\win32\lib\release\netsnmp.lib -EXECUTABLES=ethereal.exe ethereal-gtk2.exe tethereal.exe \ +EXECUTABLES=ethereal.exe ethereal-gtk2.exe tshark.exe \ capinfos.exe editcap.exe mergecap.exe text2pcap.exe randpkt.exe dumpcap.exe -RESOURCES=image\ethereal.res image\libwireshark.res image\tethereal.res \ +RESOURCES=image\ethereal.res image\libwireshark.res image\tshark.res \ image\capinfos.res image\editcap.res image\mergecap.res \ image\text2pcap.res image\wiretap.res image\dumpcap.res @@ -170,10 +170,10 @@ ethereal-gtk2.exe : config.h svnversion.h $(ethereal_OBJECTS) $(command_line_OBJ << !ENDIF -tethereal.exe : config.h svnversion.h $(tethereal_OBJECTS) $(command_line_OBJECTS) epan image\tethereal.res wiretap\wiretap-$(WTAP_VERSION).lib plugins +tshark.exe : config.h svnversion.h $(tshark_OBJECTS) $(command_line_OBJECTS) epan image\tshark.res wiretap\wiretap-$(WTAP_VERSION).lib plugins @echo Linking $@ $(LINK) @<< - /OUT:tethereal.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:console $(tethereal_LIBS) $(tethereal_OBJECTS) $(command_line_OBJECTS) image\tethereal.res + /OUT:tshark.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:console $(tshark_LIBS) $(tshark_OBJECTS) $(command_line_OBJECTS) image\tshark.res << capinfos.exe : config.h capinfos.obj getopt.obj $(command_line_OBJECTS) wiretap\wiretap-$(WTAP_VERSION).lib image\capinfos.res @@ -261,7 +261,7 @@ AUTHORS-SHORT-FORMAT: AUTHORS-SHORT make-authors-format.pl $(PERL) perlnoutf.pl make-authors-format.pl < AUTHORS-SHORT > AUTHORS-SHORT-FORMAT # -# Build "tethereal-tap-register.c", which contains a function +# Build "tshark-tap-register.c", which contains a function # "register_all_tap_listeners()" # that calls the register routines for all tehtereal tap listeners. # @@ -275,9 +275,9 @@ AUTHORS-SHORT-FORMAT: AUTHORS-SHORT make-authors-format.pl # The second argument is the directory in which the source files live. # All subsequent arguments are the files to scan. # -tethereal-tap-register.c: $(TETHEREAL_TAP_SRC) make-tapreg-dotc - @echo Making tethereal-tap-register.c - @$(SH) make-tapreg-dotc tethereal-tap-register.c . $(TETHEREAL_TAP_SRC) +tshark-tap-register.c: $(TSHARK_TAP_SRC) make-tapreg-dotc + @echo Making tshark-tap-register.c + @$(SH) make-tapreg-dotc tshark-tap-register.c . $(TSHARK_TAP_SRC) text2pcap-scanner.c : text2pcap-scanner.l $(LEX) -otext2pcap-scanner.c text2pcap-scanner.l @@ -287,7 +287,7 @@ gtk2_distclean: if exist gtk2.tmp rmdir gtk2.tmp clean: gtk2_distclean - rm -f $(ethereal_OBJECTS) $(tethereal_OBJECTS) $(EXTRA_OBJECTS) \ + rm -f $(ethereal_OBJECTS) $(tshark_OBJECTS) $(EXTRA_OBJECTS) \ $(EXECUTABLES) $(PDB_FILE) \ capinfos.obj editcap.obj mergecap.obj text2pcap.obj getopt.obj\ text2pcap-scanner.obj text2pcap-scanner.c rdps.obj \ diff --git a/README.bsd b/README.bsd index c8098e10bb..e92293af79 100644 --- a/README.bsd +++ b/README.bsd @@ -1,6 +1,6 @@ $Id$ -In order to capture packets (with Ethereal/Tethereal, tcpdump, or any +In order to capture packets (with Ethereal/TShark, tcpdump, or any other packet capture program) on a BSD system, your kernel must have the Berkeley packet Filter mechanism enabled. On some BSDs (recent versions of FreeBSD, for example), it's enabled by default in the diff --git a/README.hpux b/README.hpux index c81b9c9e66..c22026a568 100644 --- a/README.hpux +++ b/README.hpux @@ -99,7 +99,7 @@ as a shared library. 5 - HP-UX patches to fix packet capture problems -Note that packet-capture programs such as Ethereal/Tethereal or tcpdump +Note that packet-capture programs such as Ethereal/TShark or tcpdump may, on HP-UX, not be able to see packets sent from the machine on which they're running. Make sure you have a recent "LAN Cummulative/DLPI" patch installed. diff --git a/README.linux b/README.linux index b683a1c8a6..ad27953bbf 100644 --- a/README.linux +++ b/README.linux @@ -1,6 +1,6 @@ $Id$ -In order to capture packets (with Ethereal/Tethereal, tcpdump, or any +In order to capture packets (with Ethereal/TShark, tcpdump, or any other libpcap-based packet capture program) on a Linux system, the "packet" protocol must be supported by your kernel. If it is not, you may get error messages such as diff --git a/README.macos b/README.macos index 5b9d03d331..2feb37b9ac 100644 --- a/README.macos +++ b/README.macos @@ -5,7 +5,7 @@ not work on earlier versions of Mac OS). In order to build Ethereal, you must have X11 and the X11 developer headers and libraries installed; otherwise, you will not be able to -build or install GTK+, and will only be able to build Tethereal. The +build or install GTK+, and will only be able to build TShark. The X11 and X11 SDK that come with Mac OS X 10.3[.x] are sufficient to build and run Ethereal. diff --git a/README.win32 b/README.win32 index bd3ee6bb44..84dc93720a 100644 --- a/README.win32 +++ b/README.win32 @@ -1,6 +1,6 @@ $Id$ -Installing Ethereal, Tethereal, and Editcap on Win32 +Installing Ethereal, TShark, and Editcap on Win32 ==================================================== These are the instructions for installing Ethereal from the installation executable that is provided on @@ -13,7 +13,7 @@ and any of its mirrors. The installation package allows you to install: o Ethereal - the GUI version - o Tethereal - the console, line-mode version + o TShark - the console, line-mode version o Editcap - a console, line-mode utility to convert capture files from one format to another. (The same functions are available in Wireshark) @@ -24,7 +24,7 @@ The installation package allows you to install: Additionally, the installation package contains a "plugins" option, which installs some additional dissector plugins -for use with Ethereal and Tethereal. +for use with Ethereal and TShark. All binaries in Wireshark package are now built with debugging information embedded. If you are experiencing a crash when running @@ -364,7 +364,7 @@ Source Output Tool config.h.win32 config.h sed epan/config.h.win32 epan/config.h sed image/ethereal.rc.in image/ethereal.rc sed -image/tethereal.rc.in image/tethereal.rc sed +image/tshark.rc.in image/tshark.rc sed image/editcap.rc.in image/editcap.rc sed image/mergecap.rc.in image/mergecap.rc sed image/text2pcap.rc.in image/text2pcap.rc sed @@ -379,7 +379,7 @@ make-reg-dotc, packet*.c register.c Bash + grep + sed or make-reg-dotc.py, packet*.c register.c Python -make-tapreg-dotc, tap-*.c tethereal-tap-register.c +make-tapreg-dotc, tap-*.c tshark-tap-register.c Bash + grep + sed make-tapreg-dotc, tap files gtk/ethereal-tap-register.c in the gtk subdirectory Bash + grep + sed diff --git a/capture-wpcap.c b/capture-wpcap.c index 643cf5d575..297261be08 100644 --- a/capture-wpcap.c +++ b/capture-wpcap.c @@ -1,6 +1,6 @@ /* capture-wpcap.c * WinPcap-specific interfaces for capturing. We load WinPcap at run - * time, so that we only need one Wireshark binary and one Twireshark binary + * time, so that we only need one Wireshark binary and one TShark binary * for Windows, regardless of whether WinPcap is installed or not. * * $Id$ diff --git a/capture_info.c b/capture_info.c index 5206230676..e9bc1d9316 100644 --- a/capture_info.c +++ b/capture_info.c @@ -113,13 +113,13 @@ cf_open_error_message(int err, gchar *err_info, gboolean for_writing, case WTAP_ERR_FILE_UNKNOWN_FORMAT: /* Seen only when opening a capture file for reading. */ - errmsg = "The file \"%s\" isn't a capture file in a format Twireshark understands."; + errmsg = "The file \"%s\" isn't a capture file in a format TShark understands."; break; case WTAP_ERR_UNSUPPORTED: /* Seen only when opening a capture file for reading. */ g_snprintf(errmsg_errno, sizeof(errmsg_errno), - "The file \"%%s\" isn't a capture file in a format Twireshark understands.\n" + "The file \"%%s\" isn't a capture file in a format TShark understands.\n" "(%s)", err_info); g_free(err_info); errmsg = errmsg_errno; @@ -135,15 +135,15 @@ cf_open_error_message(int err, gchar *err_info, gboolean for_writing, case WTAP_ERR_UNSUPPORTED_FILE_TYPE: /* Seen only when opening a capture file for writing. */ - errmsg = "Twireshark doesn't support writing capture files in that format."; + errmsg = "TShark doesn't support writing capture files in that format."; break; case WTAP_ERR_UNSUPPORTED_ENCAP: if (for_writing) - errmsg = "Twireshark can't save this capture in that format."; + errmsg = "TShark can't save this capture in that format."; else { g_snprintf(errmsg_errno, sizeof(errmsg_errno), - "The file \"%%s\" is a capture for a network type that Twireshark doesn't support.\n" + "The file \"%%s\" is a capture for a network type that TShark doesn't support.\n" "(%s)", err_info); g_free(err_info); errmsg = errmsg_errno; @@ -152,9 +152,9 @@ cf_open_error_message(int err, gchar *err_info, gboolean for_writing, case WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED: if (for_writing) - errmsg = "Twireshark can't save this capture in that format."; + errmsg = "TShark can't save this capture in that format."; else - errmsg = "The file \"%s\" is a capture for a network type that Twireshark doesn't support."; + errmsg = "The file \"%s\" is a capture for a network type that TShark doesn't support."; break; case WTAP_ERR_BAD_RECORD: diff --git a/capture_loop.c b/capture_loop.c index 92b626353b..d4fb0d3c82 100644 --- a/capture_loop.c +++ b/capture_loop.c @@ -458,7 +458,7 @@ capture_loop_open_input(capture_options *capture_opts, loop_data *ld, g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, "capture_loop_open_input : %s", capture_opts->iface); -/* XXX - opening Winsock on twireshark? */ +/* XXX - opening Winsock on tshark? */ /* Initialize Windows Socket if we are in a WIN32 OS This needs to be done before querying the interface for network/netmask */ @@ -628,7 +628,7 @@ capture_loop_open_input(capture_options *capture_opts, loop_data *ld, #endif } -/* XXX - will this work for twireshark? */ +/* XXX - will this work for tshark? */ #ifdef MUST_DO_SELECT if (!ld->from_cap_pipe) { #ifdef HAVE_PCAP_GET_SELECTABLE_FD @@ -753,7 +753,7 @@ gboolean capture_loop_init_output(capture_options *capture_opts, int save_file_f if (ld->pdh == NULL) { /* We couldn't set up to write to the capture file. */ - /* XXX - use cf_open_error_message from twireshark instead? */ + /* XXX - use cf_open_error_message from tshark instead? */ switch (err) { case WTAP_ERR_CANT_OPEN: diff --git a/capture_loop.h b/capture_loop.h index 83b6b7e055..69e9c78ae5 100644 --- a/capture_loop.h +++ b/capture_loop.h @@ -98,9 +98,9 @@ extern void capture_loop_stop(void); typedef void (*capture_packet_cb_fct)(u_char *, const struct pcap_pkthdr *, const u_char *); -/* moved from capture_loop.c here, so we can combine it (and the related functions) with twireshark */ +/* moved from capture_loop.c here, so we can combine it (and the related functions) with tshark */ /* XXX - should be moved back to capture_loop.c */ -/* E: capture_loop.c only (Wireshark/dumpcap) T: twireshark only */ +/* E: capture_loop.c only (Wireshark/dumpcap) T: tshark only */ typedef struct _loop_data { /* common */ gboolean go; /* TRUE as long as we're supposed to keep capturing */ diff --git a/capture_opts.c b/capture_opts.c index 3056af800e..ed7339c845 100644 --- a/capture_opts.c +++ b/capture_opts.c @@ -244,7 +244,7 @@ capture_opts_add_iface_opt(capture_options *capture_opts, const char *optarg) /* * If the argument is a number, treat it as an index into the list - * of adapters, as printed by "twireshark -D". + * of adapters, as printed by "tshark -D". * * This should be OK on UNIX systems, as interfaces shouldn't have * names that begin with digits. It can be useful on Windows, where diff --git a/capture_wpcap_packet.c b/capture_wpcap_packet.c index 7034b5d9e2..62623ca06b 100644 --- a/capture_wpcap_packet.c +++ b/capture_wpcap_packet.c @@ -1,7 +1,7 @@ /* capture_wpcap_packet.c * WinPcap-specific interfaces for low-level information (packet.dll). * We load WinPcap at run - * time, so that we only need one Wireshark binary and one Twireshark binary + * time, so that we only need one Wireshark binary and one TShark binary * for Windows, regardless of whether WinPcap is installed or not. * * $Id$ diff --git a/clopts_common.c b/clopts_common.c index ef756574a7..1c7cea9b16 100644 --- a/clopts_common.c +++ b/clopts_common.c @@ -1,5 +1,5 @@ /* clopts_common.c - * Handle command-line arguments common to Wireshark and Twireshark + * Handle command-line arguments common to Wireshark and TShark * * $Id$ * diff --git a/clopts_common.h b/clopts_common.h index 584ddc2cbc..3341fd0519 100644 --- a/clopts_common.h +++ b/clopts_common.h @@ -1,5 +1,5 @@ /* clopts_common.h - * Handle command-line arguments common to Wireshark and Twireshark + * Handle command-line arguments common to Wireshark and TShark * * $Id$ * diff --git a/configure.in b/configure.in index a28b1bc93b..bb1b84c393 100644 --- a/configure.in +++ b/configure.in @@ -337,7 +337,7 @@ if test "$HAVE_GNU_SED" = no ; then esac fi -# Enable/disable tethereal +# Enable/disable tshark AC_ARG_ENABLE(ethereal, [ --enable-ethereal build GTK+-based ethereal. [default=yes]],enable_ethereal=$enableval,enable_ethereal=yes) @@ -524,21 +524,21 @@ rdps_bin="rdps\$(EXEEXT)" AC_SUBST(rdps_bin) -# Enable/disable tethereal +# Enable/disable tshark -AC_ARG_ENABLE(tethereal, -[ --enable-tethereal build tethereal. [default=yes]],tethereal=$enableval,enable_tethereal=yes) +AC_ARG_ENABLE(tshark, +[ --enable-tshark build tshark. [default=yes]],tshark=$enableval,enable_tshark=yes) -if test "x$enable_tethereal" = "xyes" ; then - tethereal_bin="tethereal\$(EXEEXT)" - tethereal_man="tethereal.1" +if test "x$enable_tshark" = "xyes" ; then + tshark_bin="tshark\$(EXEEXT)" + tshark_man="tshark.1" etherealfilter_man="ethereal-filter.4" else - tethereal_bin="" - tethereal_man="" + tshark_bin="" + tshark_man="" fi -AC_SUBST(tethereal_bin) -AC_SUBST(tethereal_man) +AC_SUBST(tshark_bin) +AC_SUBST(tshark_man) AC_SUBST(etherealfilter_man) @@ -1402,7 +1402,7 @@ fi echo "" echo "The Ethereal package has been configured with the following options." echo " Build ethereal : $enable_ethereal" -echo " Build tethereal : $enable_tethereal" +echo " Build tshark : $enable_tshark" echo " Build capinfos : $enable_capinfos" echo " Build editcap : $enable_editcap" echo " Build dumpcap : $enable_dumpcap" diff --git a/debian/rules b/debian/rules index 6bff4c45d8..d3ea39cc21 100755 --- a/debian/rules +++ b/debian/rules @@ -62,7 +62,7 @@ clean: unpatch-stamp cp /usr/share/misc/config.guess /usr/share/misc/config.sub . -$(MAKE) distclean - rm -f rdps ethereal.1 tethereal.1 idl2deb.1 ethereal-filter.4 asn2deb.1 + rm -f rdps ethereal.1 tshark.1 idl2deb.1 ethereal-filter.4 asn2deb.1 rm -f conftest conftest.c rm -f config.guess config.sub config.log diff --git a/debian/tethereal.files b/debian/tethereal.files deleted file mode 100644 index 29deea87d1..0000000000 --- a/debian/tethereal.files +++ /dev/null @@ -1,6 +0,0 @@ -/usr/bin/tethereal - -/usr/bin/tethereal - -/usr/bin/tethereal - diff --git a/debian/tethereal.manpages b/debian/tethereal.manpages deleted file mode 100644 index 48f577e22e..0000000000 --- a/debian/tethereal.manpages +++ /dev/null @@ -1,3 +0,0 @@ -tethereal.1 -tethereal.1 -tethereal.1 diff --git a/debian/tshark.files b/debian/tshark.files new file mode 100644 index 0000000000..d8af18f278 --- /dev/null +++ b/debian/tshark.files @@ -0,0 +1,6 @@ +/usr/bin/tshark + +/usr/bin/tshark + +/usr/bin/tshark + diff --git a/debian/tshark.manpages b/debian/tshark.manpages new file mode 100644 index 0000000000..7feb60f651 --- /dev/null +++ b/debian/tshark.manpages @@ -0,0 +1,3 @@ +tshark.1 +tshark.1 +tshark.1 diff --git a/doc/Makefile.am b/doc/Makefile.am index 1cfe9b83ae..bc44daac65 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -39,17 +39,17 @@ ethereal-tmp.pod: $(srcdir)/ethereal.pod $(top_builddir)/AUTHORS-SHORT-FORMAT --noindex \ ethereal-tmp.pod > ../ethereal.html -../tethereal.1: tethereal.pod ../config.h +../tshark.1: tshark.pod ../config.h $(POD2MAN) \ --center="The Wireshark Network Analyzer" \ --release=$(VERSION) \ - $(srcdir)/tethereal.pod > ../tethereal.1 + $(srcdir)/tshark.pod > ../tshark.1 -../tethereal.html: tethereal.pod ../config.h +../tshark.html: tshark.pod ../config.h $(POD2HTML) \ - --title="tethereal - The Wireshark Network Analyzer $(VERSION)" \ + --title="tshark - The Wireshark Network Analyzer $(VERSION)" \ --noindex \ - $(srcdir)/tethereal.pod > ../tethereal.html + $(srcdir)/tshark.pod > ../tshark.html ../ethereal-filter.4: ethereal-filter.pod ../config.h $(POD2MAN) \ @@ -64,8 +64,8 @@ ethereal-tmp.pod: $(srcdir)/ethereal.pod $(top_builddir)/AUTHORS-SHORT-FORMAT --noindex \ ethereal-filter.pod > ../ethereal-filter.html -ethereal-filter.pod: ethereal-filter.pod.template ../tethereal - ../tethereal -G fields | $(PERL) $(srcdir)/dfilter2pod.pl $(srcdir)/ethereal-filter.pod.template > ethereal-filter.pod +ethereal-filter.pod: ethereal-filter.pod.template ../tshark + ../tshark -G fields | $(PERL) $(srcdir)/dfilter2pod.pl $(srcdir)/ethereal-filter.pod.template > ethereal-filter.pod ../capinfos.1: capinfos.pod ../config.h $(POD2MAN) \ @@ -152,8 +152,8 @@ CLEANFILES = \ ../editcap.html \ ../mergecap.1 \ ../mergecap.html \ - ../tethereal.1 \ - ../tethereal.html \ + ../tshark.1 \ + ../tshark.html \ ../text2pcap.1 \ ../text2pcap.html \ ../dumpcap.1 \ diff --git a/doc/Makefile.nmake b/doc/Makefile.nmake index a58101bc6c..fc86a8bab9 100644 --- a/doc/Makefile.nmake +++ b/doc/Makefile.nmake @@ -26,10 +26,10 @@ include ../config.nmake -doc: ethereal.html tethereal.html ethereal-filter.html capinfos.html \ +doc: ethereal.html tshark.html ethereal-filter.html capinfos.html \ editcap.html idl2wrs.html mergecap.html text2pcap.html dumpcap.html -man: ethereal.1 tethereal.1 ethereal-filter.4 capinfos.1 editcap.1 \ +man: ethereal.1 tshark.1 ethereal-filter.4 capinfos.1 editcap.1 \ idl2wrs.1 mergecap.1 text2pcap.1 dumpcap.1 ethereal-tmp.pod: ethereal.pod ../AUTHORS-SHORT-FORMAT @@ -52,22 +52,22 @@ ethereal.html: ethereal-tmp.pod ../config.h --noindex \ ethereal-tmp.pod > ethereal.html -../tethereal.exe: +../tshark.exe: cd .. - $(MAKE) -f makefile.nmake tethereal.exe + $(MAKE) -f makefile.nmake tshark.exe cd doc -tethereal.1: tethereal.pod ../config.h +tshark.1: tshark.pod ../config.h $(POD2MAN) \ --center="The Wireshark Network Analyzer" \ --release=$(VERSION) \ - tethereal.pod > tethereal.1 + tshark.pod > tshark.1 -tethereal.html: tethereal.pod ../config.h +tshark.html: tshark.pod ../config.h $(POD2HTML) \ - --title="tethereal - The Wireshark Network Analyzer $(VERSION)" \ + --title="tshark - The Wireshark Network Analyzer $(VERSION)" \ --noindex \ - tethereal.pod > tethereal.html + tshark.pod > tshark.html ethereal-filter.4: ethereal-filter.pod ../config.h $(POD2MAN) \ @@ -81,10 +81,10 @@ ethereal-filter.html: ethereal-filter.pod ../config.h --noindex \ ethereal-filter.pod > ethereal-filter.html -ethereal-filter.pod: ethereal-filter.pod.template ../tethereal.exe +ethereal-filter.pod: ethereal-filter.pod.template ../tshark.exe cd .. $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake install-deps - tethereal.exe -G | $(PERL) doc\dfilter2pod.pl doc\ethereal-filter.pod.template > doc\ethereal-filter.pod + tshark.exe -G | $(PERL) doc\dfilter2pod.pl doc\ethereal-filter.pod.template > doc\ethereal-filter.pod $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean-deps cd doc @@ -163,7 +163,7 @@ dumpcap.html: dumpcap.pod ../config.h clean: rm -f ethereal.html ethereal.1 ethereal-tmp.pod - rm -f tethereal.html tethereal.1 + rm -f tshark.html tshark.1 rm -f ethereal-filter.html ethereal-filter.4 ethereal-filter.pod rm -f capinfos.html capinfos.1 rm -f editcap.html editcap.1 diff --git a/doc/README.developer b/doc/README.developer index 1e14507622..fa7696d99a 100644 --- a/doc/README.developer +++ b/doc/README.developer @@ -497,17 +497,17 @@ much better to use the g_snprintf() function declared by instead. You should test your dissector against incorrectly-formed packets. This can be done using the randpkt and editcap utilities that come with the Ethereal distribution. Testing using randpkt can be done by generating -output at the same layer as your protocol, and forcing Ethereal/Tethereal +output at the same layer as your protocol, and forcing Ethereal/TShark to decode it as your protocol, e.g. if your protocol sits on top of UDP: randpkt -c 50000 -t dns randpkt.pcap - tethereal -nVr randpkt.pcap -d udp.port==53, + tshark -nVr randpkt.pcap -d udp.port==53, Testing using editcap can be done using preexisting capture files and the "-E" flag, which introduces errors in a capture file. E.g.: editcap -E 0.03 infile.pcap outfile.pcap - tethereal -nVr outfile.pcap + tshark -nVr outfile.pcap 1.1.4 Name convention. diff --git a/doc/README.regression b/doc/README.regression index 04f06bc0ab..e21365f60d 100644 --- a/doc/README.regression +++ b/doc/README.regression @@ -1,27 +1,27 @@ # -# Ethereal/Tethereal Regression Testing +# Ethereal/TShark Regression Testing # # $Id$ # # This is a sample Makefile for regression testing of the -# Ethereal engine. These tests use that uses 'tethereal -V' to analyze all +# Ethereal engine. These tests use that uses 'tshark -V' to analyze all # the frames of a capture file. # # You should probably rename this file as 'Makefile' in a separate directory # set aside for the sole purpose of regression testing. Two text files will # be created for each capture file you test, so expect to have lots of files. # -# Set TETHEREAL, CAPTURE_DIR, and CAPTURE_FILES to values appropriate for +# Set TSHARK, CAPTURE_DIR, and CAPTURE_FILES to values appropriate for # your system. Run 'make' to create the initial datasets. Type 'make accept' # to accept those files as the reference set. # -# After you make changes to Tethereal, run 'make regress'. This will re-run +# After you make changes to TShark, run 'make regress'. This will re-run # the tests and compare them against the accepted reference set of data. # The comparison, which is just an invocation of 'diff -u' for the output # of each trace file, will be put into a file called 'regress'. Examine # this file for any changes that you did or did not expect. # -# If you have introduced a change to Tethereal that shows up in the tests, but +# If you have introduced a change to TShark that shows up in the tests, but # it is a valid change, run 'make accept' to accept those new data as your # reference set. # @@ -33,7 +33,7 @@ # 'make accept' Accept current tests; make them the reference test results # 'make clean' Cleans any tests (but not references!) -TETHEREAL=/home/gram/prj/ethereal/debug/linux-ix86/tethereal +TSHARK=/home/gram/prj/ethereal/debug/linux-ix86/tshark CAPTURE_DIR=/home/gram/prj/sniff @@ -59,8 +59,8 @@ all: $(TESTS) clean: rm -f $(TESTS) -%.tether : $(CAPTURE_DIR)/% $(TETHEREAL) - $(TETHEREAL) -V -n -r $< > $@ +%.tether : $(CAPTURE_DIR)/% $(TSHARK) + $(TSHARK) -V -n -r $< > $@ accept: $(REFERENCES) diff --git a/doc/README.stats_tree b/doc/README.stats_tree index a8e3b668fe..e834b08046 100644 --- a/doc/README.stats_tree +++ b/doc/README.stats_tree @@ -4,9 +4,9 @@ tapping with stats_tree Let's suppose that you want to write a tap only to keep counters, and you don't want to get involved with GUI programming or maybe you'd like to make it a plugin. A stats_tree might be the way to go. The stats_tree module takes -care of the representation (GUI for ethereal and text for tethereal) of the +care of the representation (GUI for ethereal and text for tshark) of the tap data. So there's very little code to write to make a tap listener usable -from both ethereal and tethereal. +from both ethereal and tshark. First, you should add the TAP to the dissector in question as described in README.tapping . diff --git a/doc/README.tapping b/doc/README.tapping index 2347716dbb..6db72ef576 100644 --- a/doc/README.tapping +++ b/doc/README.tapping @@ -6,11 +6,11 @@ In order to use the tapping system, very little knowledge of ethereal internals are required. As examples on how to use the tap system see the implementation of -tap-rpcstat.c (tethereal version) +tap-rpcstat.c (tshark version) gtk/gtk-rpcstat.c (gtk-ethereal version) If all you need is to keep some counters, there's the stats_tree API, -which offers a simple way to make a GUI and tethereal tap-listener; see +which offers a simple way to make a GUI and tshark tap-listener; see README.stats_tree. However, keep reading, as you'll need much of what's in this document. diff --git a/doc/README.xml-output b/doc/README.xml-output index 25facda09d..787311ce33 100644 --- a/doc/README.xml-output +++ b/doc/README.xml-output @@ -5,7 +5,7 @@ Copyright (c) 2003 by Gilbert Ramirez Ethereal has the ability to export its protocol dissection in an -XML format, tethereal has similar functionality by using the "-Tpdml" +XML format, tshark has similar functionality by using the "-Tpdml" option. The XML that wireshark produces follows the Packet Details Markup @@ -18,10 +18,10 @@ A related XML format, the Packet Summary Markup Language (PSML), is also defined by the Analyzer group to provide packet summary information. The PSML format is not documented in a publicly-available HTML document, but its format is simple. Ethereal can export this format too. Some day it -may be added to tethereal so that "-Tpsml" would produce PSML. +may be added to tshark so that "-Tpsml" would produce PSML. One wonders if the "-T" option should read "-Txml" instead of "-Tpdml" -(and in the future, "-Tpsml"), but if tethereal was required to produce +(and in the future, "-Tpsml"), but if tshark was required to produce another XML-based format of its protocol dissection, then "-Txml" would be ambiguous. @@ -53,7 +53,7 @@ Example: The creator is "ethereal" (i.e., the "ethereal" engine. It will always say -"ethereal", not "tethereal") version 0.9.17. +"ethereal", not "tshark") version 0.9.17. The "" tag @@ -192,13 +192,13 @@ a protocol or a field: General Notes ============= Generally, parsing XML is slow. If you're writing a script to parse -the PDML output of tethereal, pass a read filter with "-R" to tethereal to -try to reduce as much as possible the number of packets coming out of tethereal. +the PDML output of tshark, pass a read filter with "-R" to tshark to +try to reduce as much as possible the number of packets coming out of tshark. The less your script has to process, the faster it will be. 'tools/msnchat' is a sample Python program that uses EtherealXML to parse PDML. -Given one or more capture files, it runs tethereal on each of them, providing -a read filter to reduce tethereal's output. It finds MSN Chat conversations +Given one or more capture files, it runs tshark on each of them, providing +a read filter to reduce tshark's output. It finds MSN Chat conversations in the capture file and produces nice HTML showing the conversations. It has only been tested with capture files containing non-simultaneous chat sessions, but was written to more-or-less handle any number of simultanous chat diff --git a/doc/capinfos.pod b/doc/capinfos.pod index 740462c71b..27c67e9bcf 100644 --- a/doc/capinfos.pod +++ b/doc/capinfos.pod @@ -106,7 +106,7 @@ Prints the help listing and exits. =head1 SEE ALSO -I, I, I, I, I, I +I, I, I, I, I, I =head1 NOTES diff --git a/doc/dumpcap.pod b/doc/dumpcap.pod index 216f7fdefa..19fd7aa4df 100644 --- a/doc/dumpcap.pod +++ b/doc/dumpcap.pod @@ -198,7 +198,7 @@ See the manual page of I. =head1 SEE ALSO -I, I, I, I, I +I, I, I, I, I =head1 NOTES diff --git a/doc/ethereal-filter.pod.template b/doc/ethereal-filter.pod.template index b560a8b3e4..01caa5b599 100644 --- a/doc/ethereal-filter.pod.template +++ b/doc/ethereal-filter.pod.template @@ -7,12 +7,12 @@ ethereal-filter - Ethereal filter syntax and reference B [other options] S<[ B<-R> "filter expression" ]> -B [other options] +B [other options] S<[ B<-R> "filter expression" ]> =head1 DESCRIPTION -B and B share a powerful filter engine that helps remove +B and B share a powerful filter engine that helps remove the noise from a packet trace and lets you see only the packets that interest you. If a packet meets the requirements expressed in your filter, then it is displayed in the list of packets. Display filters let you compare the @@ -37,7 +37,7 @@ Think of a protocol or field in a filter as implicitly having the "exists" operator. Note: all protocol and field names that are available in B and -B filters are listed in the comprehensive B filters are listed in the comprehensive B (see below). =head2 Comparison operators @@ -85,11 +85,11 @@ a case-insensitive pattern match. More information on PCRE can be found in the pcrepattern(3) man page (Perl Regular Expressions are explained in B). -Note: the "matches" operator is only available if B or B +Note: the "matches" operator is only available if B or B have been compiled with the PCRE library. This can be checked by running: ethereal -v - tethereal -v + tshark -v or selecting the "About Ethereal" item from the "Help" menu in B. @@ -221,7 +221,7 @@ Another example is: You can use the slice operator on a protocol name, too. The "frame" protocol can be useful, encompassing all the data captured -by B or B. +by B or B. token[0:5] ne 0.0.0.1.1 llc[0] eq aa @@ -393,7 +393,7 @@ in B. =head1 SEE ALSO -I, I, I, I, I +I, I, I, I, I =head1 AUTHORS diff --git a/doc/ethereal.pod b/doc/ethereal.pod index 261b514892..3ab44eb7f2 100644 --- a/doc/ethereal.pod +++ b/doc/ethereal.pod @@ -2199,7 +2199,7 @@ See above in the description of the About:Plugins page. =head1 SEE ALSO -I I, I, I, I +I I, I, I, I =head1 NOTES diff --git a/doc/tethereal.pod b/doc/tethereal.pod deleted file mode 100644 index b5bfb8188e..0000000000 --- a/doc/tethereal.pod +++ /dev/null @@ -1,874 +0,0 @@ - -=head1 NAME - -tethereal - Dump and analyze network traffic - -=head1 SYNOPSYS - -B -S<[ B<-a> Ecapture autostop conditionE ] ...> -S<[ B<-b> Ecapture ring buffer optionE] ...> -S<[ B<-B> Ecapture buffer size (Win32 only)E ] > -S<[ B<-c> Ecapture packet countE ]> -S<[ B<-d> Elayer typeE==EselectorE,Edecode-as protocolE ]> -S<[ B<-D> ]> -S<[ B<-f> Ecapture filterE ]> -S<[ B<-F> Efile formatE ]> -S<[ B<-h> ]> -S<[ B<-i> Ecapture interfaceE|- ]> -S<[ B<-l> ]> -S<[ B<-L> ]> -S<[ B<-n> ]> -S<[ B<-N> Ename resolving flagsE ]> -S<[ B<-o> Epreference settingE ] ...> -S<[ B<-p> ]> -S<[ B<-q> ]> -S<[ B<-r> EinfileE ]> -S<[ B<-R> Eread (display) filterE ]> -S<[ B<-s> Ecapture snaplenE ]> -S<[ B<-S> ]> -S<[ B<-t> ad|a|r|d ]> -S<[ B<-T> pdml|psml|ps|text ]> -S<[ B<-v> ]> -S<[ B<-V> ]> -S<[ B<-w> EoutfileE|- ]> -S<[ B<-x> ]> -S<[ B<-X> EeXtension optionE]> -S<[ B<-y> Ecapture link typeE ]> -S<[ B<-z> EstatisticsE ]> - -=head1 DESCRIPTION - -B is a network protocol analyzer. It lets you capture packet -data from a live network, or read packets from a previously saved -capture file, either printing a decoded form of those packets to the -standard output or writing the packets to a file. B's native -capture file format is B format, which is also the format used -by B and various other tools. - -Without any options set, B will work much like B. It will -use the pcap library to capture traffic from the first available network -interface and displays a summary line on stdout for each received packet. - -B is able to detect, read and write the same capture files that -are supported by B. -The input file doesn't need a specific filename extension, the file -format and an optional gzip compression will be automatically detected. -The I section of I or -I -provides a detailed description. - -Compressed file support uses (and therefore requires) the zlib library. -If the zlib library is not present, B will compile, but will -be unable to read compressed files. - -If the B<-w> option is not specified, B writes to the standard -output the text of a decoded form of the packets it captures or reads. -If the B<-w> option is specified, B writes to the file -specified by that option the raw data of the packets, along with the -packets' time stamps. - -When writing a decoded form of packets, B writes, by -default, a summary line containing the fields specified by the -preferences file (which are also the fields displayed in the packet list -pane in B), although if it's writing packets as it captures -them, rather than writting packets from a saved capture file, it won't -show the "frame number" field. If the B<-V> option is specified, it -writes instead a view of the details of the packet, showing all the -fields of all protocols in the packet. - -If you want to write the decoded form of packets to a file, run -B without the B<-w> option, and redirect its standard output to -the file (do I use the B<-w> option). - -When writing packets to a file, B, by default, writes the -file in B format, and writes all of the packets it sees to the -output file. The B<-F> option can be used to specify the format in which -to write the file. This list of available file formats is displayed by -the B<-h> flag. - -Read filters in B, which allow you to select which packets -are to be decoded or written to a file, are very powerful; more fields -are filterable in B than in other protocol analyzers, and the -syntax you can use to create your filters is richer. As B -progresses, expect more and more protocol fields to be allowed in read -filters. - -Packet capturing is performed with the pcap library. The capture filter -syntax follows the rules of the pcap library. This syntax is different -from the read filter syntax. A read filter can also be specified when -capturing, and only packets that pass the read filter will be displayed -or saved to the output file; note, however, that capture filters are much -more efficient than read filters, and it may be more difficult for -B to keep up with a busy network if a read filter is -specified for a live capture. - -A capture or read filter can either be specified with the B<-f> or B<-R> -option, respectively, in which case the entire filter expression must be -specified as a single argument (which means that if it contains spaces, -it must be quoted), or can be specified with command-line arguments -after the option arguments, in which case all the arguments after the -filter arguments are treated as a filter expression. Capture filters -are supported only when doing a live capture; read filters are supported -when doing a live capture and when reading a capture file, but require -Tethereal to do more work when filtering, so you might be more likely to -lose packets under heavy load if you're using a read filter. If the -filter is specified with command-line arguments after the option -arguments, it's a capture filter if a capture is being done (i.e., if no -B<-r> option was specified) and a read filter if a capture file is being -read (i.e., if a B<-r> option was specified). - -=head1 OPTIONS - -=over 4 - -=item -a Ecapture autostop conditionE - -Specify a criterion that specifies when B is to stop writing -to a capture file. The criterion is of the form IB<:>I, -where I is one of: - -B:I Stop writing to a capture file after I seconds have elapsed. - -B:I Stop writing to a capture file after it reaches a size of I -kilobytes (where a kilobyte is 1024 bytes). If this option -is used together with the -b option, Ethereal will stop writing to the -current capture file and switch to the next one if filesize is reached. - -B:I Stop writing to capture files after I number of files were written. - -=item -b Ecapture ring buffer optionE - -Cause B to run in "multiple files" mode. In "multiple files" mode, -B will write to several capture files. When the first capture file -fills up, B will switch writing to the next file and so on. - -The created filenames are based on the filename given with the B<-w> option, the number of -the file and on the creation date and time, -e.g. outfile_00001_20050604120117.pcap, outfile_00001_20050604120523.pcap, ... - -With the I option it's also possible to form a "ring buffer". -This will fill up new files until the number of files specified, -at which point B will discard the data in the first file and start -writing to that file and so on. If the I option is not set, -new files filled up until one of the capture stop conditions match (or -until the disk if full). - -The criterion is of the form IB<:>I, -where I is one of: - -B:I switch to the next file after I seconds have -elapsed, even if the current file is not completely filled up. - -B:I switch to the next file after it reaches a size of -I kilobytes (where a kilobyte is 1024 bytes). - -B:I begin again with the first file after I number of -files were written (form a ring buffer). - -=item -B Ecapture buffer size (Win32 only)E - -Win32 only: set capture buffer size (in MB, default is 1MB). This is used by the -the capture driver to buffer packet data until that data can be written to -disk. If you encounter packet drops while capturing, try to increase this size. - -=item -c Ecapture packet countE - -Set the maximum number of packets to read when capturing live -data. - -=item -d Elayer typeE==EselectorE,Edecode-as protocolE - -Specify that if the layer type in question (for example, B or -B for a TCP or UDP port number) has the specified selector -value, packets should be dissected as the specified protocol. - -Example: B<-d tcp.port==8888,http> will decode any traffic running over -TCP port 8888 as HTTP. - -=item -D - -Print a list of the interfaces on which B can capture, and -exit. For each network interface, a number and an -interface name, possibly followed by a text description of the -interface, is printed. The interface name or the number can be supplied -to the B<-i> option to specify an interface on which to capture. - -This can be useful on systems that don't have a command to list them -(e.g., Windows systems, or UNIX systems lacking B); -the number can be useful on Windows 2000 and later systems, where the -interface name is a somewhat complex string. - -Note that "can capture" means that B was able to open -that device to do a live capture. Depending on your system you may need to run tethereal from an account -with special privileges (for example, as root) to be able to capture -network traffic. -If B is not run from such an account, it will not list -any interfaces. - -=item -f Ecapture filterE - -Set the capture filter expression. - -=item -F Efile formatE - -Set the file format of the output capture file written using the B<-w> -option. The output written with the B<-w> option is raw packet data, not -text, so there is no B<-F> option to request text output. - -=item -h - -Print the version and options and exits. - -=item -i Ecapture interfaceE|- - -Set the name of the network interface or pipe to use for live packet -capture. - -Network interface names should match one of the names listed in -"B" (described above); a number, as reported by -"B", can also be used. If you're using UNIX, "B" or "B" might also work to list interface names, -although not all versions of UNIX support the B<-a> option to B. - -If no interface is specified, B searches the list of -interfaces, choosing the first non-loopback interface if there are any -non-loopback interfaces, and choosing the first loopback interface if -there are no non-loopback interfaces. If there are no interfaces at all, -B reports an error and doesn't start the capture. - -Pipe names should be either the name of a FIFO (named pipe) or ``-'' to -read data from the standard input. Data read from pipes must be in -standard libpcap format. - -Note: the Win32 version of B doesn't support capturing from -pipes or stdin! - -=item -l - -Flush the standard output after the information for each packet is -printed. (This is not, strictly speaking, line-buffered if B<-V> -was specified; however, it is the same as line-buffered if B<-V> wasn't -specified, as only one line is printed for each packet, and, as B<-l> is -normally used when piping a live capture to a program or script, so that -output for a packet shows up as soon as the packet is seen and -dissected, it should work just as well as true line-buffering. We do -this as a workaround for a deficiency in the Microsoft Visual C++ C -library.) - -This may be useful when piping the output of B to another -program, as it means that the program to which the output is piped will -see the dissected data for a packet as soon as B sees the -packet and generates that output, rather than seeing it only when the -standard output buffer containing that data fills up. - -=item -L - -List the data link types supported by the interface and exit. The reported -link types can be used for the B<-y> option. - -=item -n - -Disable network object name resolution (such as hostname, TCP and UDP port -names), the B<-N> flag might override this one. - -=item -N Ename resolving flagsE - -Turn on name resolving only for particular types of addresses and port -numbers, with name resolving for other types of addresses and port -numbers turned off. This flag overrides B<-n> if both B<-N> and B<-n> are -present. If both B<-N> and B<-n> flags are not present, all name resolutions are -turned on. - -The argument is a string that may contain the letters: - -B to enable MAC address resolution - -B to enable network address resolution - -B to enable transport-layer port number resolution - -B to enable concurrent (asynchronous) DNS lookups - -=item -o EpreferenceE:EvalueE - -Set a preference value, overriding the default value and any value read -from a preference file. The argument to the option is a string of the -form IB<:>I, where I is the name of the -preference (which is the same name that would appear in the preference -file), and I is the value to which it should be set. - -=item -p - -I put the interface into promiscuous mode. Note that the -interface might be in promiscuous mode for some other reason; hence, -B<-p> cannot be used to ensure that the only traffic that is captured is -traffic sent to or from the machine on which B is running, -broadcast traffic, and multicast traffic to addresses received by that -machine. - -=item -q - -When capturing packets, don't display the continuous count of packets -captured that is normally shown when saving a capture to a file; -instead, just display, at the end of the capture, a count of packets -captured. On systems that support the SIGINFO signal, such as various -BSDs, you can cause the current count to be displayed by typing your -"status" character (typically control-T, although it -might be set to "disabled" by default on at least some BSDs, so you'd -have to explicitly set it to use it). - -When reading a capture file, or when capturing and not saving to a file, -don't print packet information; this is useful if you're using a B<-z> -option to calculate statistics and don't want the packet information -printed, just the statistics. - -=item -r EinfileE - -Read packet data from I, can be any supported capture file format -(including gzipped files). It's B possible to use named pipes -or stdin here! - -=item -R Eread (display) filterE - -Cause the specified filter (which uses the syntax of read/display filters, -rather than that of capture filters) to be applied before printing a -decoded form of packets or writing packets to a file; packets not -matching the filter are discarded rather than being printed or written. - -=item -s Ecapture snaplenE - -Set the default snapshot length to use when capturing live data. -No more than I bytes of each network packet will be read into -memory, or saved to disk. - -=item -S - -Decode and display packets even while writing raw packet data using the -B<-w> option. - -=item -t ad|a|r|d - -Set the format of the packet timestamp printed in summary lines, the default -is relative. The format can be one of: - -B absolute with date: The absolute date and time is the actual time and -date the packet was captured - -B absolute: The absolute time is the actual time the packet was captured, -with no date displayed - -B relative: The relative time is the time elapsed between the first packet -and the current packet - -B delta: The delta time is the time since the previous packet was -captured - -=item -T pdml|psml|ps|text - -Set the format of the output when viewing decoded packet data. The -options are one of: - -B Packet Details Markup Language, an XML-based format for the details of -a decoded packet. This information is equivalent to the packet details -printed with the B<-V> flag. - -B Packet Summary Markup Language, an XML-based format for the summary -information of a decoded packet. This information is equivalent to the -information shown in the one-line summary printed by default. - -B PostScript for a human-readable one-line summary of each of the packets, -or a multi-line view of the details of each of the packets, depending on -whether the B<-V> flag was specified. - -B Text of a human-readable one-line summary of each of the packets, or a -multi-line view of the details of each of the packets, depending on -whether the B<-V> flag was specified. This is the default. - -=item -v - -Print the version and exit. - -=item -V - -Cause B to print a view of the packet details rather -than a one-line summary of the packet. - -=item -w EoutfileE|- - -Write raw packet data to I or to the standard output if -I is '-'. - -NOTE: -w provides raw packet data, not text. If you want text output -you need to redirect stdout (e.g. using '>'), don't use the B<-w> -option for this. - -=item -x - -Cause B to print a hex and ASCII dump of the packet data -after printing the summary or details. - - -=item -X EeXtension optionsE - -Specify an option to be passed to a B module. The eXtension option -is in the form IB<:>I, where I can be: - -B:I tells B to load the given script in addition to the -default Lua scripts. - - -=item -y Ecapture link typeE - -Set the data link type to use while capturing packets. The values -reported by B<-L> are the values that can be used. - -=item -z EstatisticsE - -Get B to collect various types of statistics and display the result -after finishing reading the capture file. Use the B<-q> flag if you're -reading a capture file and only want the statistics printed, not any -per-packet information. - -Note that the B<-z proto> option is different - it doesn't cause -statistics to be gathered and printed when the capture is complete, it -modifies the regular packet summary output to include the values of -fields specified with the option. Therefore you must not use the B<-q> -option, as that option would suppress the printing of the regular packet -summary output, and must also not use the B<-V> option, as that would -cause packet detail information rather than packet summary information -to be printed. - -Currently implemented statistics are: - -B<-z> dcerpc,rtt,I,I.I[,I] - -Collect call/reply RTT data for DCERPC interface I, -version I.I. -Data collected is number of calls for each procedure, MinRTT, MaxRTT -and AvgRTT. -Example: use B<-z dcerpc,rtt,12345778-1234-abcd-ef00-0123456789ac,1.0> to collect data for CIFS SAMR Interface. -This option can be used multiple times on the command line. - -If the optional filterstring is provided, the stats will only be calculated -on those calls that match that filter. -Example: use B<-z dcerpc,rtt,12345778-1234-abcd-ef00-0123456789ac,1.0,ip.addr==1.2.3.4> to collect SAMR -RTT statistics for a specific host. - - -B<-z> io,phs[,I] - -Create Protocol Hierarchy Statistics listing both number of packets and bytes. -If no I is specified the statistics will be calculated for all packets. -If a I is specified statistics will be only calculated for those -packets that match the filter. - -This option can be used multiple times on the command line. - - -B<-z> io,stat,I[,I][,I][,I]... - -Collect packet/bytes statistics for the capture in intervals of -I seconds. I can be specified either as whole or -fractional seconds. Interval can be specified in ms resolution. - -If no I is specified the statistics will be calculated for all packets. -If one or more I are specified statistics will be calculated for -all filters and presented with one column of statistics for each filter. - -This option can be used multiple times on the command line. - - -Example: B<-z io,stat,1,ip.addr==1.2.3.4> to generate 1 second -statistics for all traffic to/from host 1.2.3.4. - -Example: B<-z "io,stat,0.001,smb&&ip.addr==1.2.3.4"> to generate 1ms -statistics for all SMB packets to/from host 1.2.3.4. - -The examples above all use the standard syntax for generating statistics -which only calculates the number of packets and bytes in each interval. - -B can also do much more statistics and calculate COUNT(), SUM(), -MIN(), MAX(), and AVG() using a slightly different filter syntax: - - [COUNT|SUM|MIN|MAX|AVG]() - -One important thing to note here is that the field that the calculation is -based on MUST also be part of the filter string or else the calculation will -fail. - -So: B<-z io,stat,0.010,AVG(smb.time)> does not work. Use B<-z -io,stat,0.010,AVG(smb.time)smb.time> instead. Also be aware that a field -can exist multiple times inside the same packet and will then be counted -multiple times in those packets. - - -COUNT() can be used on any type which has a display filter name. -It will count how many times this particular field is encountered in the -filtered packet list. - -Example: B<-z io,stat,0.010,COUNT(smb.sid)smb.sid> -This will count the total number of SIDs seen in each 10ms interval. - -SUM() can only be used on named fields of integer type. -This will sum together every occurence of this fields value for each interval. - -Example: B<-z io,stat,0.010,SUM(frame.pkt_len)frame.pkt_len> -This will report the total number of bytes seen in all the packets within -an interval. - -MIN/MAX/AVG() can only be used on named fields that are either -integers or relative time fields. This will calculate maximum/minimum -or average seen in each interval. If the field is a relative time field -the output will be presented in seconds and three digits after the -decimal point. The resolution for time calculations is 1ms and anything -smaller will be truncated. - -Example: B<-z "io,stat,0.010,smb.time&&ip.addr==1.1.1.1,MIN(smb.time)smb.time&&ip.addr==1.1.1.1,MAX(smb.time)smb.time&&ip.addr==1.1.1.1,MAX(smb.time)smb.time&&ip.addr==1.1.1.1"> - -This will calculate statistics for all smb response times we see to/from -host 1.1.1.1 in 10ms intervals. The output will be displayed in 4 -columns; number of packets/bytes, minimum response time, maximum response -time and average response time. - - - -B<-z> conv,I[,I] - -Create a table that lists all conversations that could be seen in the capture. -I specifies which type of conversation we want to generate the -statistics for; currently the supported ones are - - "eth" Ethernet - "fc" Fibre Channel - "fddi" FDDI - "ip" IP addresses - "ipx" IPX addresses - "tcp" TCP/IP socket pairs Both IPv4 and IPv6 are supported - "tr" Token Ring - "udp" UDP/IP socket pairs Both IPv4 and IPv6 are supported - -If the optional filter string is specified, only those packets that match the -filter will be used in the calculations. - -The table is presented with one line for each conversation and displays -number of packets/bytes in each direction as well as total number of -packets/bytes. -The table is sorted according to total number of bytes. - - -B<-z> proto,colinfo,I,I - -Append all I values for the packet to the Info column of the -one-line summary output. -This feature can be used to append arbitrary fields to the Info column -in addition to the normal content of that column. -I is the display-filter name of a field which value should be placed -in the Info column. -I is a filter string that controls for which packets the field value -will be presented in the info column. I will only be presented in the -Info column for the packets which match I. - -NOTE: In order for B to be able to extract the I value -from the packet, I MUST be part of the I string. If not, -B will not be able to extract its value. - -For a simple example to add the "nfs.fh.hash" field to the Info column -for all packets containing the "nfs.fh.hash" field, use - -B<-z proto,colinfo,nfs.fh.hash,nfs.fh.hash> - - -To put "nfs.fh.hash" in the Info column but only for packets coming from -host 1.2.3.4 use: - -B<-z "proto,colinfo,nfs.fh.hash && ip.src==1.2.3.4,nfs.fh.hash"> - -This option can be used multiple times on the command line. - - -B<-z> rpc,rtt,I,I[,I] - -Collect call/reply RTT data for I/I. Data collected -is number of calls for each procedure, MinRTT, MaxRTT and AvgRTT. -Example: use B<-z rpc,rtt,100003,3> to collect data for NFS v3. This -option can be used multiple times on the command line. - -If the optional filterstring is provided, the stats will only be calculated -on those calls that match that filter. -Example: use B<-z rpc,rtt,100003,3,nfs.fh.hash==0x12345678> to collect NFS v3 -RTT statistics for a specific file. - - -B<-z> rpc,programs - -Collect call/reply RTT data for all known ONC-RPC programs/versions. -Data collected is number of calls for each protocol/version, MinRTT, -MaxRTT and AvgRTT. -This option can only be used once on the command line. - -B<-z> smb,rtt[,I] - -Collect call/reply RTT data for SMB. Data collected -is number of calls for each SMB command, MinRTT, MaxRTT and AvgRTT. -Example: use B<-z smb,rtt>. -The data will be presented as separate tables for all normal SMB commands, -all Transaction2 commands and all NT Transaction commands. -Only those commands that are seen in the capture will have its stats -displayed. -Only the first command in a xAndX command chain will be used in the -calculation. So for common SessionSetupAndX + TreeConnectAndX chains, -only the SessionSetupAndX call will be used in the statistics. -This is a flaw that might be fixed in the future. - -This option can be used multiple times on the command line. - -If the optional filterstring is provided, the stats will only be calculated -on those calls that match that filter. -Example: use B<-z "smb,rtt,ip.addr==1.2.3.4"> to only collect stats for -SMB packets echanged by the host at IP address 1.2.3.4 . - -B<-z> smb,sids - -When this feature is used B will print a report with all the -discovered SID and account name mappings. Only those SIDs where the -account name is known will be presented in the table. - -For this feature to work you will need to either to enable -"Edit/Preferences/Protocols/SMB/Snoop SID to name mappings" in the -preferences or you can override the preferences by specifying -B<-o "smb.sid_name_snooping:TRUE"> on the B command line. - -The current methods used by B to find the SID->name mapping -is relatively restricted but is hoped to be expanded in the future. - -B<-z> mgcp,rtd[I<,filter>] - -Collect requests/response RTD (Response Time Delay) data for MGCP. -This is similar to B<-z smb,rtt>). Data collected is number of calls -for each known MGCP Type, MinRTD, MaxRTD and AvgRTD. -Additionally you get the number of duplicate requests/responses, -unresponded requests, responses ,which don't match with -any request. -Example: use B<-z mgcp,rtd>. - -This option can be used multiple times on the command line. - -If the optional filterstring is provided, the stats will only be calculated -on those calls that match that filter. -Example: use B<-z "mgcp,rtd,ip.addr==1.2.3.4"> to only collect stats for -MGCP packets exchanged by the host at IP address 1.2.3.4 . - -B<-z> h225,counter[I<,filter>] - -Count ITU-T H.225 messages and their reasons. In the first column you get a -list of H.225 messages and H.225 message reasons, which occur in the current -capture file. The number of occurences of each message or reason is displayed -in the second column. - -Example: use B<-z h225,counter>. - -This option can be used multiple times on the command line. - -If the optional filterstring is provided, the stats will only be calculated -on those calls that match that filter. -Example: use B<-z "h225,counter,ip.addr==1.2.3.4"> to only collect stats for -H.225 packets exchanged by the host at IP address 1.2.3.4 . - -B<-z> h225,srt[I<,filter>] - -Collect requests/response SRT (Service Response Time) data for ITU-T H.225 RAS. -Data collected is number of calls of each ITU-T H.225 RAS Message Type, -Minimum SRT, Maximum SRT, Average SRT, Minimum in Frame, and Maximum in Frame. -You will also get the number of Open Requests (Unresponded Requests), -Discarded Responses (Responses without matching request) and Duplicate Messages. -Example: use B<-z h225,srt>. - -This option can be used multiple times on the command line. - -If the optional filterstring is provided, the stats will only be calculated -on those calls that match that filter. -Example: use B<-z "h225,srt,ip.addr==1.2.3.4"> to only collect stats for -ITU-T H.225 RAS packets exchanged by the host at IP address 1.2.3.4 . - -B<-z> sip,stat[I<,filter>] - -This option will activate a counter for SIP messages. You will get the number -of occurences of each SIP Method and of each SIP Status-Code. Additionally you -also get the number of resent SIP Messages (only for SIP over UDP). - -Example: use B<-z sip,stat>. - -This option can be used multiple times on the command line. - -If the optional filter string is provided, the stats will only be calculated -on those calls that match that filter. -Example: use B<-z "sip,stat,ip.addr==1.2.3.4"> to only collect stats for -SIP packets exchanged by the host at IP address 1.2.3.4 . - -=back - -=head1 CAPTURE FILTER SYNTAX - -See the manual page of I. - -=head1 READ FILTER SYNTAX - -For a complete table of protocol and protocol fields that are filterable -in B see the I manual page. - -=head1 FILES - -These files contains various B configuration values. - -=over 4 - -=item Preferences - -The F files contain global (system-wide) and personal -preference settings. If the system-wide preference file exists, it is -read first, overriding the default settings. If the personal preferences -file exists, it is read next, overriding any previous values. Note: If -the command line option B<-o> is used (possibly more than once), it will -in turn override values from the preferences files. - -The preferences settings are in the form IB<:>I, -one per line, -where I is the name of the preference -and I is the value to -which it should be set; white space is allowed between B<:> and -I. A preference setting can be continued on subsequent lines by -indenting the continuation lines with white space. A B<#> character -starts a comment that runs to the end of the line: - - # Capture in promiscuous mode? - # TRUE or FALSE (case-insensitive). - capture.prom_mode: TRUE - -The global preferences file is looked for in the F directory -under the F subdirectory of the main installation directory (for -example, F) on UNIX-compatible -systems, and in the main installation directory (for example, -F) on Windows systems. - -The personal preferences file is looked for in -F<$HOME/.ethereal/preferences> on -UNIX-compatible systems and F<%APPDATA%\Ethereal\preferences> (or, if -%APPDATA% isn't defined, F<%USERPROFILE%\Application -Data\Ethereal\preferences>) on Windows systems. - -=item Disabled (Enabled) Protocols - -The F files contain system-wide and personal lists of -protocols that have been disabled, so that their dissectors are never -called. The files contain protocol names, one per line, where the -protocol name is the same name that would be used in a display filter -for the protocol: - - http - tcp # a comment - -The global F file uses the same directory as the global -preferences file. - -The personal F file uses the same directory as the -personal preferences file. - -=item Name Resolution (hosts) - -If the personal F file exists, it is -used to resolve IPv4 and IPv6 addresses before any other -attempts are made to resolve them. The file has the standard F -file syntax; each line contains one IP address and name, separated by -whitespace. The same directory as for the personal preferences file is -used. - -=item Name Resolution (ethers) - -The F files are consulted to correlate 6-byte hardware addresses to -names. First the personal F file is tried and if an address is not -found there the global F file is tried next. - -Each line contains one hardware address and name, separated by -whitespace. The digits of the hardware address are separated by colons -(:), dashes (-) or periods (.). The same separator character must be -used consistently in an address. The following three lines are valid -lines of an F file: - - ff:ff:ff:ff:ff:ff Broadcast - c0-00-ff-ff-ff-ff TR_broadcast - 00.00.00.00.00.00 Zero_broadcast - -The global F file is looked for in the F directory on -UNIX-compatible systems, and in the main installation directory (for -example, F) on Windows systems. - -The personal F file is looked for in the same directory as the personal -preferences file. - -=item Name Resolution (manuf) - -The F file is used to match the 3-byte vendor portion of a 6-byte -hardware address with the manufacturer's name; it can also contain well-known -MAC addresses and address ranges specified with a netmask. The format of the -file is the same as the F files, except that entries of the form: - - 00:00:0C Cisco - -can be provided, with the 3-byte OUI and the name for a vendor, and -entries such as: - - 00-00-0C-07-AC/40 All-HSRP-routers - -can be specified, with a MAC address and a mask indicating how many bits -of the address must match. The above entry, for example, has 40 -significant bits, or 5 bytes, and would match addresses from -00-00-0C-07-AC-00 through 00-00-0C-07-AC-FF. The mask need not be a -multiple of 8. - -The F file is looked for in the same directory as the global -preferences file. - -=item Name Resolution (ipxnets) - -The F files are used to correlate 4-byte IPX network numbers to -names. First the global F file is tried and if that address is not -found there the personal one is tried next. - -The format is the same as the F -file, except that each address is four bytes instead of six. -Additionally, the address can be represented as a single hexadecimal -number, as is more common in the IPX world, rather than four hex octets. -For example, these four lines are valid lines of an F file: - - C0.A8.2C.00 HR - c0-a8-1c-00 CEO - 00:00:BE:EF IT_Server1 - 110f FileServer3 - -The global F file is looked for in the F directory on -UNIX-compatible systems, and in the main installation directory (for -example, F) on Windows systems. - -The personal F file is looked for in the same directory as the -personal preferences file. - -=back - -=head1 SEE ALSO - -I I, I, I, I - -=head1 NOTES - -B is part of the B distribution. The latest version -of B can be found at B. - -HTML versions of the Wireshark project man pages are available at: -http://www.ethereal.com/docs/man-pages - -=head1 AUTHORS - -B uses the same packet dissection code that B does, -as well as using many other modules from B; see the list of -authors in the B man page for a list of authors of that code. diff --git a/doc/tshark.pod b/doc/tshark.pod new file mode 100644 index 0000000000..19193af20a --- /dev/null +++ b/doc/tshark.pod @@ -0,0 +1,874 @@ + +=head1 NAME + +tshark - Dump and analyze network traffic + +=head1 SYNOPSYS + +B +S<[ B<-a> Ecapture autostop conditionE ] ...> +S<[ B<-b> Ecapture ring buffer optionE] ...> +S<[ B<-B> Ecapture buffer size (Win32 only)E ] > +S<[ B<-c> Ecapture packet countE ]> +S<[ B<-d> Elayer typeE==EselectorE,Edecode-as protocolE ]> +S<[ B<-D> ]> +S<[ B<-f> Ecapture filterE ]> +S<[ B<-F> Efile formatE ]> +S<[ B<-h> ]> +S<[ B<-i> Ecapture interfaceE|- ]> +S<[ B<-l> ]> +S<[ B<-L> ]> +S<[ B<-n> ]> +S<[ B<-N> Ename resolving flagsE ]> +S<[ B<-o> Epreference settingE ] ...> +S<[ B<-p> ]> +S<[ B<-q> ]> +S<[ B<-r> EinfileE ]> +S<[ B<-R> Eread (display) filterE ]> +S<[ B<-s> Ecapture snaplenE ]> +S<[ B<-S> ]> +S<[ B<-t> ad|a|r|d ]> +S<[ B<-T> pdml|psml|ps|text ]> +S<[ B<-v> ]> +S<[ B<-V> ]> +S<[ B<-w> EoutfileE|- ]> +S<[ B<-x> ]> +S<[ B<-X> EeXtension optionE]> +S<[ B<-y> Ecapture link typeE ]> +S<[ B<-z> EstatisticsE ]> + +=head1 DESCRIPTION + +B is a network protocol analyzer. It lets you capture packet +data from a live network, or read packets from a previously saved +capture file, either printing a decoded form of those packets to the +standard output or writing the packets to a file. B's native +capture file format is B format, which is also the format used +by B and various other tools. + +Without any options set, B will work much like B. It will +use the pcap library to capture traffic from the first available network +interface and displays a summary line on stdout for each received packet. + +B is able to detect, read and write the same capture files that +are supported by B. +The input file doesn't need a specific filename extension, the file +format and an optional gzip compression will be automatically detected. +The I section of I or +I +provides a detailed description. + +Compressed file support uses (and therefore requires) the zlib library. +If the zlib library is not present, B will compile, but will +be unable to read compressed files. + +If the B<-w> option is not specified, B writes to the standard +output the text of a decoded form of the packets it captures or reads. +If the B<-w> option is specified, B writes to the file +specified by that option the raw data of the packets, along with the +packets' time stamps. + +When writing a decoded form of packets, B writes, by +default, a summary line containing the fields specified by the +preferences file (which are also the fields displayed in the packet list +pane in B), although if it's writing packets as it captures +them, rather than writting packets from a saved capture file, it won't +show the "frame number" field. If the B<-V> option is specified, it +writes instead a view of the details of the packet, showing all the +fields of all protocols in the packet. + +If you want to write the decoded form of packets to a file, run +B without the B<-w> option, and redirect its standard output to +the file (do I use the B<-w> option). + +When writing packets to a file, B, by default, writes the +file in B format, and writes all of the packets it sees to the +output file. The B<-F> option can be used to specify the format in which +to write the file. This list of available file formats is displayed by +the B<-h> flag. + +Read filters in B, which allow you to select which packets +are to be decoded or written to a file, are very powerful; more fields +are filterable in B than in other protocol analyzers, and the +syntax you can use to create your filters is richer. As B +progresses, expect more and more protocol fields to be allowed in read +filters. + +Packet capturing is performed with the pcap library. The capture filter +syntax follows the rules of the pcap library. This syntax is different +from the read filter syntax. A read filter can also be specified when +capturing, and only packets that pass the read filter will be displayed +or saved to the output file; note, however, that capture filters are much +more efficient than read filters, and it may be more difficult for +B to keep up with a busy network if a read filter is +specified for a live capture. + +A capture or read filter can either be specified with the B<-f> or B<-R> +option, respectively, in which case the entire filter expression must be +specified as a single argument (which means that if it contains spaces, +it must be quoted), or can be specified with command-line arguments +after the option arguments, in which case all the arguments after the +filter arguments are treated as a filter expression. Capture filters +are supported only when doing a live capture; read filters are supported +when doing a live capture and when reading a capture file, but require +TShark to do more work when filtering, so you might be more likely to +lose packets under heavy load if you're using a read filter. If the +filter is specified with command-line arguments after the option +arguments, it's a capture filter if a capture is being done (i.e., if no +B<-r> option was specified) and a read filter if a capture file is being +read (i.e., if a B<-r> option was specified). + +=head1 OPTIONS + +=over 4 + +=item -a Ecapture autostop conditionE + +Specify a criterion that specifies when B is to stop writing +to a capture file. The criterion is of the form IB<:>I, +where I is one of: + +B:I Stop writing to a capture file after I seconds have elapsed. + +B:I Stop writing to a capture file after it reaches a size of I +kilobytes (where a kilobyte is 1024 bytes). If this option +is used together with the -b option, Ethereal will stop writing to the +current capture file and switch to the next one if filesize is reached. + +B:I Stop writing to capture files after I number of files were written. + +=item -b Ecapture ring buffer optionE + +Cause B to run in "multiple files" mode. In "multiple files" mode, +B will write to several capture files. When the first capture file +fills up, B will switch writing to the next file and so on. + +The created filenames are based on the filename given with the B<-w> option, the number of +the file and on the creation date and time, +e.g. outfile_00001_20050604120117.pcap, outfile_00001_20050604120523.pcap, ... + +With the I option it's also possible to form a "ring buffer". +This will fill up new files until the number of files specified, +at which point B will discard the data in the first file and start +writing to that file and so on. If the I option is not set, +new files filled up until one of the capture stop conditions match (or +until the disk if full). + +The criterion is of the form IB<:>I, +where I is one of: + +B:I switch to the next file after I seconds have +elapsed, even if the current file is not completely filled up. + +B:I switch to the next file after it reaches a size of +I kilobytes (where a kilobyte is 1024 bytes). + +B:I begin again with the first file after I number of +files were written (form a ring buffer). + +=item -B Ecapture buffer size (Win32 only)E + +Win32 only: set capture buffer size (in MB, default is 1MB). This is used by the +the capture driver to buffer packet data until that data can be written to +disk. If you encounter packet drops while capturing, try to increase this size. + +=item -c Ecapture packet countE + +Set the maximum number of packets to read when capturing live +data. + +=item -d Elayer typeE==EselectorE,Edecode-as protocolE + +Specify that if the layer type in question (for example, B or +B for a TCP or UDP port number) has the specified selector +value, packets should be dissected as the specified protocol. + +Example: B<-d tcp.port==8888,http> will decode any traffic running over +TCP port 8888 as HTTP. + +=item -D + +Print a list of the interfaces on which B can capture, and +exit. For each network interface, a number and an +interface name, possibly followed by a text description of the +interface, is printed. The interface name or the number can be supplied +to the B<-i> option to specify an interface on which to capture. + +This can be useful on systems that don't have a command to list them +(e.g., Windows systems, or UNIX systems lacking B); +the number can be useful on Windows 2000 and later systems, where the +interface name is a somewhat complex string. + +Note that "can capture" means that B was able to open +that device to do a live capture. Depending on your system you may need to run tshark from an account +with special privileges (for example, as root) to be able to capture +network traffic. +If B is not run from such an account, it will not list +any interfaces. + +=item -f Ecapture filterE + +Set the capture filter expression. + +=item -F Efile formatE + +Set the file format of the output capture file written using the B<-w> +option. The output written with the B<-w> option is raw packet data, not +text, so there is no B<-F> option to request text output. + +=item -h + +Print the version and options and exits. + +=item -i Ecapture interfaceE|- + +Set the name of the network interface or pipe to use for live packet +capture. + +Network interface names should match one of the names listed in +"B" (described above); a number, as reported by +"B", can also be used. If you're using UNIX, "B" or "B" might also work to list interface names, +although not all versions of UNIX support the B<-a> option to B. + +If no interface is specified, B searches the list of +interfaces, choosing the first non-loopback interface if there are any +non-loopback interfaces, and choosing the first loopback interface if +there are no non-loopback interfaces. If there are no interfaces at all, +B reports an error and doesn't start the capture. + +Pipe names should be either the name of a FIFO (named pipe) or ``-'' to +read data from the standard input. Data read from pipes must be in +standard libpcap format. + +Note: the Win32 version of B doesn't support capturing from +pipes or stdin! + +=item -l + +Flush the standard output after the information for each packet is +printed. (This is not, strictly speaking, line-buffered if B<-V> +was specified; however, it is the same as line-buffered if B<-V> wasn't +specified, as only one line is printed for each packet, and, as B<-l> is +normally used when piping a live capture to a program or script, so that +output for a packet shows up as soon as the packet is seen and +dissected, it should work just as well as true line-buffering. We do +this as a workaround for a deficiency in the Microsoft Visual C++ C +library.) + +This may be useful when piping the output of B to another +program, as it means that the program to which the output is piped will +see the dissected data for a packet as soon as B sees the +packet and generates that output, rather than seeing it only when the +standard output buffer containing that data fills up. + +=item -L + +List the data link types supported by the interface and exit. The reported +link types can be used for the B<-y> option. + +=item -n + +Disable network object name resolution (such as hostname, TCP and UDP port +names), the B<-N> flag might override this one. + +=item -N Ename resolving flagsE + +Turn on name resolving only for particular types of addresses and port +numbers, with name resolving for other types of addresses and port +numbers turned off. This flag overrides B<-n> if both B<-N> and B<-n> are +present. If both B<-N> and B<-n> flags are not present, all name resolutions are +turned on. + +The argument is a string that may contain the letters: + +B to enable MAC address resolution + +B to enable network address resolution + +B to enable transport-layer port number resolution + +B to enable concurrent (asynchronous) DNS lookups + +=item -o EpreferenceE:EvalueE + +Set a preference value, overriding the default value and any value read +from a preference file. The argument to the option is a string of the +form IB<:>I, where I is the name of the +preference (which is the same name that would appear in the preference +file), and I is the value to which it should be set. + +=item -p + +I put the interface into promiscuous mode. Note that the +interface might be in promiscuous mode for some other reason; hence, +B<-p> cannot be used to ensure that the only traffic that is captured is +traffic sent to or from the machine on which B is running, +broadcast traffic, and multicast traffic to addresses received by that +machine. + +=item -q + +When capturing packets, don't display the continuous count of packets +captured that is normally shown when saving a capture to a file; +instead, just display, at the end of the capture, a count of packets +captured. On systems that support the SIGINFO signal, such as various +BSDs, you can cause the current count to be displayed by typing your +"status" character (typically control-T, although it +might be set to "disabled" by default on at least some BSDs, so you'd +have to explicitly set it to use it). + +When reading a capture file, or when capturing and not saving to a file, +don't print packet information; this is useful if you're using a B<-z> +option to calculate statistics and don't want the packet information +printed, just the statistics. + +=item -r EinfileE + +Read packet data from I, can be any supported capture file format +(including gzipped files). It's B possible to use named pipes +or stdin here! + +=item -R Eread (display) filterE + +Cause the specified filter (which uses the syntax of read/display filters, +rather than that of capture filters) to be applied before printing a +decoded form of packets or writing packets to a file; packets not +matching the filter are discarded rather than being printed or written. + +=item -s Ecapture snaplenE + +Set the default snapshot length to use when capturing live data. +No more than I bytes of each network packet will be read into +memory, or saved to disk. + +=item -S + +Decode and display packets even while writing raw packet data using the +B<-w> option. + +=item -t ad|a|r|d + +Set the format of the packet timestamp printed in summary lines, the default +is relative. The format can be one of: + +B absolute with date: The absolute date and time is the actual time and +date the packet was captured + +B absolute: The absolute time is the actual time the packet was captured, +with no date displayed + +B relative: The relative time is the time elapsed between the first packet +and the current packet + +B delta: The delta time is the time since the previous packet was +captured + +=item -T pdml|psml|ps|text + +Set the format of the output when viewing decoded packet data. The +options are one of: + +B Packet Details Markup Language, an XML-based format for the details of +a decoded packet. This information is equivalent to the packet details +printed with the B<-V> flag. + +B Packet Summary Markup Language, an XML-based format for the summary +information of a decoded packet. This information is equivalent to the +information shown in the one-line summary printed by default. + +B PostScript for a human-readable one-line summary of each of the packets, +or a multi-line view of the details of each of the packets, depending on +whether the B<-V> flag was specified. + +B Text of a human-readable one-line summary of each of the packets, or a +multi-line view of the details of each of the packets, depending on +whether the B<-V> flag was specified. This is the default. + +=item -v + +Print the version and exit. + +=item -V + +Cause B to print a view of the packet details rather +than a one-line summary of the packet. + +=item -w EoutfileE|- + +Write raw packet data to I or to the standard output if +I is '-'. + +NOTE: -w provides raw packet data, not text. If you want text output +you need to redirect stdout (e.g. using '>'), don't use the B<-w> +option for this. + +=item -x + +Cause B to print a hex and ASCII dump of the packet data +after printing the summary or details. + + +=item -X EeXtension optionsE + +Specify an option to be passed to a B module. The eXtension option +is in the form IB<:>I, where I can be: + +B:I tells B to load the given script in addition to the +default Lua scripts. + + +=item -y Ecapture link typeE + +Set the data link type to use while capturing packets. The values +reported by B<-L> are the values that can be used. + +=item -z EstatisticsE + +Get B to collect various types of statistics and display the result +after finishing reading the capture file. Use the B<-q> flag if you're +reading a capture file and only want the statistics printed, not any +per-packet information. + +Note that the B<-z proto> option is different - it doesn't cause +statistics to be gathered and printed when the capture is complete, it +modifies the regular packet summary output to include the values of +fields specified with the option. Therefore you must not use the B<-q> +option, as that option would suppress the printing of the regular packet +summary output, and must also not use the B<-V> option, as that would +cause packet detail information rather than packet summary information +to be printed. + +Currently implemented statistics are: + +B<-z> dcerpc,rtt,I,I.I[,I] + +Collect call/reply RTT data for DCERPC interface I, +version I.I. +Data collected is number of calls for each procedure, MinRTT, MaxRTT +and AvgRTT. +Example: use B<-z dcerpc,rtt,12345778-1234-abcd-ef00-0123456789ac,1.0> to collect data for CIFS SAMR Interface. +This option can be used multiple times on the command line. + +If the optional filterstring is provided, the stats will only be calculated +on those calls that match that filter. +Example: use B<-z dcerpc,rtt,12345778-1234-abcd-ef00-0123456789ac,1.0,ip.addr==1.2.3.4> to collect SAMR +RTT statistics for a specific host. + + +B<-z> io,phs[,I] + +Create Protocol Hierarchy Statistics listing both number of packets and bytes. +If no I is specified the statistics will be calculated for all packets. +If a I is specified statistics will be only calculated for those +packets that match the filter. + +This option can be used multiple times on the command line. + + +B<-z> io,stat,I[,I][,I][,I]... + +Collect packet/bytes statistics for the capture in intervals of +I seconds. I can be specified either as whole or +fractional seconds. Interval can be specified in ms resolution. + +If no I is specified the statistics will be calculated for all packets. +If one or more I are specified statistics will be calculated for +all filters and presented with one column of statistics for each filter. + +This option can be used multiple times on the command line. + + +Example: B<-z io,stat,1,ip.addr==1.2.3.4> to generate 1 second +statistics for all traffic to/from host 1.2.3.4. + +Example: B<-z "io,stat,0.001,smb&&ip.addr==1.2.3.4"> to generate 1ms +statistics for all SMB packets to/from host 1.2.3.4. + +The examples above all use the standard syntax for generating statistics +which only calculates the number of packets and bytes in each interval. + +B can also do much more statistics and calculate COUNT(), SUM(), +MIN(), MAX(), and AVG() using a slightly different filter syntax: + + [COUNT|SUM|MIN|MAX|AVG]() + +One important thing to note here is that the field that the calculation is +based on MUST also be part of the filter string or else the calculation will +fail. + +So: B<-z io,stat,0.010,AVG(smb.time)> does not work. Use B<-z +io,stat,0.010,AVG(smb.time)smb.time> instead. Also be aware that a field +can exist multiple times inside the same packet and will then be counted +multiple times in those packets. + + +COUNT() can be used on any type which has a display filter name. +It will count how many times this particular field is encountered in the +filtered packet list. + +Example: B<-z io,stat,0.010,COUNT(smb.sid)smb.sid> +This will count the total number of SIDs seen in each 10ms interval. + +SUM() can only be used on named fields of integer type. +This will sum together every occurence of this fields value for each interval. + +Example: B<-z io,stat,0.010,SUM(frame.pkt_len)frame.pkt_len> +This will report the total number of bytes seen in all the packets within +an interval. + +MIN/MAX/AVG() can only be used on named fields that are either +integers or relative time fields. This will calculate maximum/minimum +or average seen in each interval. If the field is a relative time field +the output will be presented in seconds and three digits after the +decimal point. The resolution for time calculations is 1ms and anything +smaller will be truncated. + +Example: B<-z "io,stat,0.010,smb.time&&ip.addr==1.1.1.1,MIN(smb.time)smb.time&&ip.addr==1.1.1.1,MAX(smb.time)smb.time&&ip.addr==1.1.1.1,MAX(smb.time)smb.time&&ip.addr==1.1.1.1"> + +This will calculate statistics for all smb response times we see to/from +host 1.1.1.1 in 10ms intervals. The output will be displayed in 4 +columns; number of packets/bytes, minimum response time, maximum response +time and average response time. + + + +B<-z> conv,I[,I] + +Create a table that lists all conversations that could be seen in the capture. +I specifies which type of conversation we want to generate the +statistics for; currently the supported ones are + + "eth" Ethernet + "fc" Fibre Channel + "fddi" FDDI + "ip" IP addresses + "ipx" IPX addresses + "tcp" TCP/IP socket pairs Both IPv4 and IPv6 are supported + "tr" Token Ring + "udp" UDP/IP socket pairs Both IPv4 and IPv6 are supported + +If the optional filter string is specified, only those packets that match the +filter will be used in the calculations. + +The table is presented with one line for each conversation and displays +number of packets/bytes in each direction as well as total number of +packets/bytes. +The table is sorted according to total number of bytes. + + +B<-z> proto,colinfo,I,I + +Append all I values for the packet to the Info column of the +one-line summary output. +This feature can be used to append arbitrary fields to the Info column +in addition to the normal content of that column. +I is the display-filter name of a field which value should be placed +in the Info column. +I is a filter string that controls for which packets the field value +will be presented in the info column. I will only be presented in the +Info column for the packets which match I. + +NOTE: In order for B to be able to extract the I value +from the packet, I MUST be part of the I string. If not, +B will not be able to extract its value. + +For a simple example to add the "nfs.fh.hash" field to the Info column +for all packets containing the "nfs.fh.hash" field, use + +B<-z proto,colinfo,nfs.fh.hash,nfs.fh.hash> + + +To put "nfs.fh.hash" in the Info column but only for packets coming from +host 1.2.3.4 use: + +B<-z "proto,colinfo,nfs.fh.hash && ip.src==1.2.3.4,nfs.fh.hash"> + +This option can be used multiple times on the command line. + + +B<-z> rpc,rtt,I,I[,I] + +Collect call/reply RTT data for I/I. Data collected +is number of calls for each procedure, MinRTT, MaxRTT and AvgRTT. +Example: use B<-z rpc,rtt,100003,3> to collect data for NFS v3. This +option can be used multiple times on the command line. + +If the optional filterstring is provided, the stats will only be calculated +on those calls that match that filter. +Example: use B<-z rpc,rtt,100003,3,nfs.fh.hash==0x12345678> to collect NFS v3 +RTT statistics for a specific file. + + +B<-z> rpc,programs + +Collect call/reply RTT data for all known ONC-RPC programs/versions. +Data collected is number of calls for each protocol/version, MinRTT, +MaxRTT and AvgRTT. +This option can only be used once on the command line. + +B<-z> smb,rtt[,I] + +Collect call/reply RTT data for SMB. Data collected +is number of calls for each SMB command, MinRTT, MaxRTT and AvgRTT. +Example: use B<-z smb,rtt>. +The data will be presented as separate tables for all normal SMB commands, +all Transaction2 commands and all NT Transaction commands. +Only those commands that are seen in the capture will have its stats +displayed. +Only the first command in a xAndX command chain will be used in the +calculation. So for common SessionSetupAndX + TreeConnectAndX chains, +only the SessionSetupAndX call will be used in the statistics. +This is a flaw that might be fixed in the future. + +This option can be used multiple times on the command line. + +If the optional filterstring is provided, the stats will only be calculated +on those calls that match that filter. +Example: use B<-z "smb,rtt,ip.addr==1.2.3.4"> to only collect stats for +SMB packets echanged by the host at IP address 1.2.3.4 . + +B<-z> smb,sids + +When this feature is used B will print a report with all the +discovered SID and account name mappings. Only those SIDs where the +account name is known will be presented in the table. + +For this feature to work you will need to either to enable +"Edit/Preferences/Protocols/SMB/Snoop SID to name mappings" in the +preferences or you can override the preferences by specifying +B<-o "smb.sid_name_snooping:TRUE"> on the B command line. + +The current methods used by B to find the SID->name mapping +is relatively restricted but is hoped to be expanded in the future. + +B<-z> mgcp,rtd[I<,filter>] + +Collect requests/response RTD (Response Time Delay) data for MGCP. +This is similar to B<-z smb,rtt>). Data collected is number of calls +for each known MGCP Type, MinRTD, MaxRTD and AvgRTD. +Additionally you get the number of duplicate requests/responses, +unresponded requests, responses ,which don't match with +any request. +Example: use B<-z mgcp,rtd>. + +This option can be used multiple times on the command line. + +If the optional filterstring is provided, the stats will only be calculated +on those calls that match that filter. +Example: use B<-z "mgcp,rtd,ip.addr==1.2.3.4"> to only collect stats for +MGCP packets exchanged by the host at IP address 1.2.3.4 . + +B<-z> h225,counter[I<,filter>] + +Count ITU-T H.225 messages and their reasons. In the first column you get a +list of H.225 messages and H.225 message reasons, which occur in the current +capture file. The number of occurences of each message or reason is displayed +in the second column. + +Example: use B<-z h225,counter>. + +This option can be used multiple times on the command line. + +If the optional filterstring is provided, the stats will only be calculated +on those calls that match that filter. +Example: use B<-z "h225,counter,ip.addr==1.2.3.4"> to only collect stats for +H.225 packets exchanged by the host at IP address 1.2.3.4 . + +B<-z> h225,srt[I<,filter>] + +Collect requests/response SRT (Service Response Time) data for ITU-T H.225 RAS. +Data collected is number of calls of each ITU-T H.225 RAS Message Type, +Minimum SRT, Maximum SRT, Average SRT, Minimum in Frame, and Maximum in Frame. +You will also get the number of Open Requests (Unresponded Requests), +Discarded Responses (Responses without matching request) and Duplicate Messages. +Example: use B<-z h225,srt>. + +This option can be used multiple times on the command line. + +If the optional filterstring is provided, the stats will only be calculated +on those calls that match that filter. +Example: use B<-z "h225,srt,ip.addr==1.2.3.4"> to only collect stats for +ITU-T H.225 RAS packets exchanged by the host at IP address 1.2.3.4 . + +B<-z> sip,stat[I<,filter>] + +This option will activate a counter for SIP messages. You will get the number +of occurences of each SIP Method and of each SIP Status-Code. Additionally you +also get the number of resent SIP Messages (only for SIP over UDP). + +Example: use B<-z sip,stat>. + +This option can be used multiple times on the command line. + +If the optional filter string is provided, the stats will only be calculated +on those calls that match that filter. +Example: use B<-z "sip,stat,ip.addr==1.2.3.4"> to only collect stats for +SIP packets exchanged by the host at IP address 1.2.3.4 . + +=back + +=head1 CAPTURE FILTER SYNTAX + +See the manual page of I. + +=head1 READ FILTER SYNTAX + +For a complete table of protocol and protocol fields that are filterable +in B see the I manual page. + +=head1 FILES + +These files contains various B configuration values. + +=over 4 + +=item Preferences + +The F files contain global (system-wide) and personal +preference settings. If the system-wide preference file exists, it is +read first, overriding the default settings. If the personal preferences +file exists, it is read next, overriding any previous values. Note: If +the command line option B<-o> is used (possibly more than once), it will +in turn override values from the preferences files. + +The preferences settings are in the form IB<:>I, +one per line, +where I is the name of the preference +and I is the value to +which it should be set; white space is allowed between B<:> and +I. A preference setting can be continued on subsequent lines by +indenting the continuation lines with white space. A B<#> character +starts a comment that runs to the end of the line: + + # Capture in promiscuous mode? + # TRUE or FALSE (case-insensitive). + capture.prom_mode: TRUE + +The global preferences file is looked for in the F directory +under the F subdirectory of the main installation directory (for +example, F) on UNIX-compatible +systems, and in the main installation directory (for example, +F) on Windows systems. + +The personal preferences file is looked for in +F<$HOME/.ethereal/preferences> on +UNIX-compatible systems and F<%APPDATA%\Ethereal\preferences> (or, if +%APPDATA% isn't defined, F<%USERPROFILE%\Application +Data\Ethereal\preferences>) on Windows systems. + +=item Disabled (Enabled) Protocols + +The F files contain system-wide and personal lists of +protocols that have been disabled, so that their dissectors are never +called. The files contain protocol names, one per line, where the +protocol name is the same name that would be used in a display filter +for the protocol: + + http + tcp # a comment + +The global F file uses the same directory as the global +preferences file. + +The personal F file uses the same directory as the +personal preferences file. + +=item Name Resolution (hosts) + +If the personal F file exists, it is +used to resolve IPv4 and IPv6 addresses before any other +attempts are made to resolve them. The file has the standard F +file syntax; each line contains one IP address and name, separated by +whitespace. The same directory as for the personal preferences file is +used. + +=item Name Resolution (ethers) + +The F files are consulted to correlate 6-byte hardware addresses to +names. First the personal F file is tried and if an address is not +found there the global F file is tried next. + +Each line contains one hardware address and name, separated by +whitespace. The digits of the hardware address are separated by colons +(:), dashes (-) or periods (.). The same separator character must be +used consistently in an address. The following three lines are valid +lines of an F file: + + ff:ff:ff:ff:ff:ff Broadcast + c0-00-ff-ff-ff-ff TR_broadcast + 00.00.00.00.00.00 Zero_broadcast + +The global F file is looked for in the F directory on +UNIX-compatible systems, and in the main installation directory (for +example, F) on Windows systems. + +The personal F file is looked for in the same directory as the personal +preferences file. + +=item Name Resolution (manuf) + +The F file is used to match the 3-byte vendor portion of a 6-byte +hardware address with the manufacturer's name; it can also contain well-known +MAC addresses and address ranges specified with a netmask. The format of the +file is the same as the F files, except that entries of the form: + + 00:00:0C Cisco + +can be provided, with the 3-byte OUI and the name for a vendor, and +entries such as: + + 00-00-0C-07-AC/40 All-HSRP-routers + +can be specified, with a MAC address and a mask indicating how many bits +of the address must match. The above entry, for example, has 40 +significant bits, or 5 bytes, and would match addresses from +00-00-0C-07-AC-00 through 00-00-0C-07-AC-FF. The mask need not be a +multiple of 8. + +The F file is looked for in the same directory as the global +preferences file. + +=item Name Resolution (ipxnets) + +The F files are used to correlate 4-byte IPX network numbers to +names. First the global F file is tried and if that address is not +found there the personal one is tried next. + +The format is the same as the F +file, except that each address is four bytes instead of six. +Additionally, the address can be represented as a single hexadecimal +number, as is more common in the IPX world, rather than four hex octets. +For example, these four lines are valid lines of an F file: + + C0.A8.2C.00 HR + c0-a8-1c-00 CEO + 00:00:BE:EF IT_Server1 + 110f FileServer3 + +The global F file is looked for in the F directory on +UNIX-compatible systems, and in the main installation directory (for +example, F) on Windows systems. + +The personal F file is looked for in the same directory as the +personal preferences file. + +=back + +=head1 SEE ALSO + +I I, I, I, I + +=head1 NOTES + +B is part of the B distribution. The latest version +of B can be found at B. + +HTML versions of the Wireshark project man pages are available at: +http://www.ethereal.com/docs/man-pages + +=head1 AUTHORS + +B uses the same packet dissection code that B does, +as well as using many other modules from B; see the list of +authors in the B man page for a list of authors of that code. diff --git a/docbook/edg_src/EDG_chapter_userinterface.xml b/docbook/edg_src/EDG_chapter_userinterface.xml index ec70457f18..4994d02e81 100644 --- a/docbook/edg_src/EDG_chapter_userinterface.xml +++ b/docbook/edg_src/EDG_chapter_userinterface.xml @@ -24,7 +24,7 @@ Ethereal, GTK 2.x based - Tethereal, console based + TShark, console based There are other Ethereal frontends existing, not developped nor diff --git a/docbook/release-notes.xml b/docbook/release-notes.xml index 6dfdd794e1..eb12804d40 100644 --- a/docbook/release-notes.xml +++ b/docbook/release-notes.xml @@ -146,7 +146,7 @@ Ethereal Info
File Locations - Ethereal and Tethereal look in several different locations for + Ethereal and TShark look in several different locations for preference files, plugins, SNMP MIBS, and RADIUS dictionaries. These locations vary from platform to platform. You can use About->Folders to find the default locations on your system. diff --git a/docbook/wsug_src/WSUG_app_tools.xml b/docbook/wsug_src/WSUG_app_tools.xml index b71602aa85..0026b074fb 100644 --- a/docbook/wsug_src/WSUG_app_tools.xml +++ b/docbook/wsug_src/WSUG_app_tools.xml @@ -49,15 +49,15 @@ tcpdump -i <interface> -s 1500 -w <some-file>
-
- <command>tethereal</command>: Terminal-based Wireshark +
+ <command>tshark</command>: Terminal-based Wireshark - Tethereal is a terminal oriented version + TShark is a terminal oriented version of ethereal designed for capturing and displaying packets when an interactive user interface isn't necessary or available. It supports the same options as ethereal. For more - information on tethereal, see the manual pages - (man tethereal). + information on tshark, see the manual pages + (man tshark).
diff --git a/docbook/wsug_src/WSUG_chapter_build_install.xml b/docbook/wsug_src/WSUG_chapter_build_install.xml index 0be221e450..924552d445 100644 --- a/docbook/wsug_src/WSUG_chapter_build_install.xml +++ b/docbook/wsug_src/WSUG_chapter_build_install.xml @@ -554,11 +554,11 @@ ethereal-setup-0.10.13.exe /NCRC /S /desktopicon=yes /quicklaunchicon=no /D=C:\P (native Win32 look and feel, recommended). - Tethereal - Tethereal is a command-line based network + TShark - TShark is a command-line based network protocol analyzer. - The dissection extensions for Wireshark and Tethereal: + The dissection extensions for Wireshark and TShark: Dissector Plugins - Plugins with some extended dissections. diff --git a/docbook/wsug_src/WSUG_chapter_customize.xml b/docbook/wsug_src/WSUG_chapter_customize.xml index f97821be7a..23c333365b 100644 --- a/docbook/wsug_src/WSUG_chapter_customize.xml +++ b/docbook/wsug_src/WSUG_chapter_customize.xml @@ -467,7 +467,7 @@ standard libpcap format. -X <eXtension option> - Specify an option to be passed to a Tethereal module. The eXtension + Specify an option to be passed to a TShark module. The eXtension option is in the form extension_key:value, where extension_key can be: diff --git a/epan/addr_resolv.h b/epan/addr_resolv.h index 859aa5d156..89eca39498 100644 --- a/epan/addr_resolv.h +++ b/epan/addr_resolv.h @@ -120,7 +120,7 @@ void get_addr_name_buf(address *addr, gchar *buf, guint size); extern void host_name_lookup_init(void); /* host_name_lookup_process does ADNS processing in GTK+ timeouts in Wireshark, - and before processing each packet in Twireshark, if we're using ADNS */ + and before processing each packet in TShark, if we're using ADNS */ extern gint host_name_lookup_process(gpointer data); /* host_name_lookup_cleanup cleans up an ADNS socket if we're using ADNS */ diff --git a/epan/dissectors/packet-http.c b/epan/dissectors/packet-http.c index c49cf2a913..9985e37aad 100644 --- a/epan/dissectors/packet-http.c +++ b/epan/dissectors/packet-http.c @@ -1342,7 +1342,7 @@ chunked_encoding_dissector(tvbuff_t **tvb_ptr, packet_info *pinfo, if (chunk_size > 0) { /* * XXX - just use "proto_tree_add_text()"? - * This means that, in Twireshark, you get + * This means that, in TShark, you get * the entire chunk dumped out in hex, * in addition to whatever dissection is * done on the reassembled data. diff --git a/epan/dissectors/packet-mdshdr.c b/epan/dissectors/packet-mdshdr.c index f7068acf7e..e3e44f4520 100644 --- a/epan/dissectors/packet-mdshdr.c +++ b/epan/dissectors/packet-mdshdr.c @@ -343,7 +343,7 @@ proto_reg_handoff_mdshdr(void) if (!mdshdr_prefs_initialized) { /* * This is the first time this has been called (i.e., - * Wireshark/Tethereal is starting up), so create a handle for + * Wireshark/TShark is starting up), so create a handle for * the MDS Header dissector, register the dissector for * ethertype ETHERTYPE_FCFT, and fetch the data and Fibre * Channel handles. diff --git a/epan/dissectors/packet-smb-sidsnooping.c b/epan/dissectors/packet-smb-sidsnooping.c index ed0ccaae65..32e2d25a5c 100644 --- a/epan/dissectors/packet-smb-sidsnooping.c +++ b/epan/dissectors/packet-smb-sidsnooping.c @@ -404,7 +404,7 @@ sid_snooping_init(void) if(error_string){ /* error, we failed to attach to the tap. clean up */ - fprintf(stderr, "twireshark: Couldn't register proto_reg_handoff_smb_sidsnooping()/lsa_policy_information tap: %s\n", + fprintf(stderr, "tshark: Couldn't register proto_reg_handoff_smb_sidsnooping()/lsa_policy_information tap: %s\n", error_string->str); g_string_free(error_string, TRUE); exit(1); @@ -415,7 +415,7 @@ sid_snooping_init(void) if(error_string){ /* error, we failed to attach to the tap. clean up */ - fprintf(stderr, "twireshark: Couldn't register proto_reg_handoff_smb_sidsnooping()/samr_query_dispinfo tap: %s\n", + fprintf(stderr, "tshark: Couldn't register proto_reg_handoff_smb_sidsnooping()/samr_query_dispinfo tap: %s\n", error_string->str); g_string_free(error_string, TRUE); exit(1); diff --git a/epan/emem.c b/epan/emem.c index 0cf3501d31..40f5f58611 100644 --- a/epan/emem.c +++ b/epan/emem.c @@ -185,7 +185,7 @@ emem_canary_pad (size_t allocation) { /* Initialize the packet-lifetime memory allocation pool. - * This function should be called only once when Wireshark or Twireshark starts + * This function should be called only once when Wireshark or TShark starts * up. */ void @@ -223,7 +223,7 @@ ep_init_chunk(void) } /* Initialize the capture-lifetime memory allocation pool. - * This function should be called only once when Wireshark or Twireshark starts + * This function should be called only once when Wireshark or TShark starts * up. */ void diff --git a/epan/filesystem.c b/epan/filesystem.c index 463ef30f5c..a3ca0cfdc3 100644 --- a/epan/filesystem.c +++ b/epan/filesystem.c @@ -479,7 +479,7 @@ get_progfile_dir(void) * stored. * * XXX - if we ever make libwireshark a real library, used by multiple - * applications (more than just Twireshark and versions of Wireshark with + * applications (more than just TShark and versions of Wireshark with * various UIs), should the configuration files belong to the library * (and be shared by all those applications) or to the applications? * diff --git a/epan/privileges.c b/epan/privileges.c index bc5f19a938..f4e740b692 100644 --- a/epan/privileges.c +++ b/epan/privileges.c @@ -45,7 +45,7 @@ get_credential_info(void) * For now, we say the program wasn't started with special privileges. * There are ways of running programs with credentials other than those * for the session in which it's run, but I don't know whether that'd be - * done with Wireshark/Twireshark or not. + * done with Wireshark/TShark or not. */ gboolean started_with_special_privs(void) diff --git a/epan/stats_tree.c b/epan/stats_tree.c index c0dfe3863d..e70cde665c 100644 --- a/epan/stats_tree.c +++ b/epan/stats_tree.c @@ -510,7 +510,7 @@ extern int stats_tree_manip_node(manip_node_mode mode, stats_tree* st, const gui extern guint8* stats_tree_get_abbr(const guint8* optarg) { guint i; - /* XXX: this fails when twireshark is given any options + /* XXX: this fails when tshark is given any options after the -z */ g_assert(optarg != NULL); diff --git a/gtk/dcerpc_stat.c b/gtk/dcerpc_stat.c index 93ef8fdaa7..f4aa3c6ddb 100644 --- a/gtk/dcerpc_stat.c +++ b/gtk/dcerpc_stat.c @@ -24,7 +24,7 @@ /* This module provides rpc call/reply SRT statistics to Wireshark, * and displays them graphically. - * It is only used by Wireshark and not twireshark + * It is only used by Wireshark and not tshark * * It serves as an example on how to use the tap api. */ diff --git a/gtk/help_dlg.c b/gtk/help_dlg.c index 76b9f7ee67..1c2e1e6322 100644 --- a/gtk/help_dlg.c +++ b/gtk/help_dlg.c @@ -363,8 +363,8 @@ topic_action(topic_action_e action) case(LOCALPAGE_MAN_WIRESHARK_FILTER): browser_open_data_file("wireshark-filter.html"); break; - case(LOCALPAGE_MAN_TWIRESHARK): - browser_open_data_file("twireshark.html"); + case(LOCALPAGE_MAN_TSHARK): + browser_open_data_file("tshark.html"); break; case(LOCALPAGE_MAN_DUMPCAP): browser_open_data_file("dumpcap.html"); diff --git a/gtk/help_dlg.h b/gtk/help_dlg.h index 49edae2fb2..79063893ae 100644 --- a/gtk/help_dlg.h +++ b/gtk/help_dlg.h @@ -44,7 +44,7 @@ typedef enum { /* local manual pages */ LOCALPAGE_MAN_WIRESHARK = 100, LOCALPAGE_MAN_WIRESHARK_FILTER, - LOCALPAGE_MAN_TWIRESHARK, + LOCALPAGE_MAN_TSHARK, LOCALPAGE_MAN_DUMPCAP, LOCALPAGE_MAN_MERGECAP, LOCALPAGE_MAN_EDITCAP, diff --git a/gtk/main.c b/gtk/main.c index ff59a123be..e97e6d0c92 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -2478,7 +2478,7 @@ main(int argc, char *argv[]) * Input file name not specified with "-r", and a command-line argument * was specified; treat it as the input file name. * - * Yes, this is different from twireshark, where non-flag command-line + * Yes, this is different from tshark, where non-flag command-line * arguments are a filter, but this works better on GUI desktops * where a command can be specified to be run to open a particular * file - yes, you could have "-r" as the last part of the command, diff --git a/gtk/menu.c b/gtk/menu.c index 8c3d94ba89..4ee9154497 100644 --- a/gtk/menu.c +++ b/gtk/menu.c @@ -398,7 +398,7 @@ static GtkItemFactoryEntry menu_items[] = ITEM_FACTORY_ENTRY("/Help/Manual Pages/Wireshark", NULL, topic_menu_cb, LOCALPAGE_MAN_WIRESHARK, NULL, NULL), ITEM_FACTORY_ENTRY("/Help/Manual Pages/Wireshark Filter", NULL, topic_menu_cb, LOCALPAGE_MAN_WIRESHARK_FILTER, NULL, NULL), ITEM_FACTORY_ENTRY("/Help/Manual Pages/", NULL, NULL, 0, "", NULL), - ITEM_FACTORY_ENTRY("/Help/Manual Pages/Twireshark", NULL, topic_menu_cb, LOCALPAGE_MAN_TWIRESHARK, NULL, NULL), + ITEM_FACTORY_ENTRY("/Help/Manual Pages/TShark", NULL, topic_menu_cb, LOCALPAGE_MAN_TSHARK, NULL, NULL), ITEM_FACTORY_ENTRY("/Help/Manual Pages/Dumpcap", NULL, topic_menu_cb, LOCALPAGE_MAN_DUMPCAP, NULL, NULL), ITEM_FACTORY_ENTRY("/Help/Manual Pages/Mergecap", NULL, topic_menu_cb, LOCALPAGE_MAN_MERGECAP, NULL, NULL), ITEM_FACTORY_ENTRY("/Help/Manual Pages/Editcap", NULL, topic_menu_cb, LOCALPAGE_MAN_EDITCAP, NULL, NULL), diff --git a/gtk/rpc_progs.c b/gtk/rpc_progs.c index c5cc0034f7..53e21bd72f 100644 --- a/gtk/rpc_progs.c +++ b/gtk/rpc_progs.c @@ -23,7 +23,7 @@ */ /* This module provides rpc call/reply SRT statistics to Wireshark. - * It is only used by Wireshark and not TWireshark + * It is only used by Wireshark and not TShark * * It serves as an example on how to use the tap api. */ diff --git a/help/capturing.txt b/help/capturing.txt index 335bb57a30..7dab4eb190 100644 --- a/help/capturing.txt +++ b/help/capturing.txt @@ -64,7 +64,7 @@ As a rule of thumb: if you want to see most of the packets and only filter a sma d) If you still get packet drops, it might be an idea to use a tool dedicated to packet capturing and only use Ethereal for displaying and analyzing the packets. -Have a look at tethereal, the command line variant of ethereal, which is included in this package. +Have a look at tshark, the command line variant of ethereal, which is included in this package. XXX: add a list of possibly useful standalone capture programs. diff --git a/help/faq.txt b/help/faq.txt index 9b9af11da9..1a93aa2df7 100644 --- a/help/faq.txt +++ b/help/faq.txt @@ -41,7 +41,7 @@ 3. Installing Ethereal: - 3.1 I installed an Ethereal RPM; why did it install Tethereal but not + 3.1 I installed an Ethereal RPM; why did it install TShark but not Ethereal? 4. Building Ethereal: @@ -70,7 +70,7 @@ 5.1 Why does Ethereal crash with a Bus Error when I try to run it on Solaris 8? - 5.2 When I run Tethereal with the "-x" option, why does it crash with an + 5.2 When I run TShark with the "-x" option, why does it crash with an error "** ERROR **: file print.c: line 691 (print_line): should not be reached. @@ -1169,7 +1169,7 @@ cies 3. Installing Ethereal - Q 3.1: I installed an Ethereal RPM; why did it install Tethereal but not + Q 3.1: I installed an Ethereal RPM; why did it install TShark but not Ethereal? A: Older versions of the Red Hat RPMs for Wireshark put only the non-GUI @@ -1270,7 +1270,7 @@ cies Similar problems may exist with older versions of GTK+ for earlier versions of Solaris. - Q 5.2: When I run Tethereal with the "-x" option, why does it crash with an + Q 5.2: When I run TShark with the "-x" option, why does it crash with an error "** ERROR **: file print.c: line 691 (print_line): should not be reached. @@ -1440,7 +1440,7 @@ cies supply to the host all network packets they see. Ethereal will try to put the interface on which it's capturing into promiscuous mode unless the "Capture packets in promiscuous mode" option is turned off in the "Capture - Options" dialog box, and Tethereal will try to put the interface on which + Options" dialog box, and TShark will try to put the interface on which it's capturing into promiscuous mode unless the -p option was specified. However, some network interfaces don't support promiscuous mode, and some OSes might not allow interfaces to be put into promiscuous mode. @@ -1537,7 +1537,7 @@ cies Q 7.6: How do I put an interface into promiscuous mode? - A: By not disabling promiscuous mode when running Ethereal or Tethereal. + A: By not disabling promiscuous mode when running Ethereal or TShark. Note, however, that: * the form of promiscuous mode that libpcap (the library that programs @@ -1768,7 +1768,7 @@ cies A: If you are running Ethereal on Windows NT 4.0, Windows 2000, Windows XP, or Windows Server 2003, and this is the first time you have run a - WinPcap-based program (such as Ethereal, or Tethereal, or WinDump, or + WinPcap-based program (such as Ethereal, or TShark, or WinDump, or Analyzer, or...) since the machine was rebooted, you need to run that program from an account with administrator privileges; once you have run such a program, you will not need administrator privileges to run any such @@ -2137,7 +2137,7 @@ cies passively capture packets. This means that you should disable name resolution when capturing in monitor - mode; otherwise, when Ethereal (or Tethereal, or tcpdump) tries to display + mode; otherwise, when Ethereal (or TShark, or tcpdump) tries to display IP addresses as host names, it will probably block for a long time trying to resolve the name because it will not be able to communicate with any DNS or NIS servers. @@ -2179,7 +2179,7 @@ cies possible" option, clicking "Save" if you want to save that setting in your preference file, and clicking "OK". - It can also be set on the Wireshark or Tethereal command line with a -o + It can also be set on the Wireshark or TShark command line with a -o tcp.check_checksum:false command-line flag, or manually set in your preferences file by adding a tcp.check_checksum:false line. diff --git a/image/Makefile.nmake b/image/Makefile.nmake index bcddd20e1e..59ee7c4c72 100644 --- a/image/Makefile.nmake +++ b/image/Makefile.nmake @@ -4,7 +4,7 @@ include ..\config.nmake -ALL_RC=ethereal.rc libwireshark.rc tethereal.rc capinfos.rc editcap.rc text2pcap.rc mergecap.rc wiretap.rc dumpcap.rc wireshark.exe.manifest +ALL_RC=ethereal.rc libwireshark.rc tshark.rc capinfos.rc editcap.rc text2pcap.rc mergecap.rc wiretap.rc dumpcap.rc wireshark.exe.manifest all : $(ALL_RC) wireshark.exe.manifest: ethereal.exe.manifest.in ..\config.nmake @@ -23,10 +23,10 @@ libwireshark.rc: libwireshark.rc.in ..\config.nmake -e s/@RC_VERSION@/$(RC_VERSION)/ \ < libwireshark.rc.in > $@ -tethereal.rc : tethereal.rc.in ..\config.nmake +tshark.rc : tshark.rc.in ..\config.nmake sed -e s/@VERSION@/$(VERSION)/ \ -e s/@RC_VERSION@/$(RC_VERSION)/ \ - < tethereal.rc.in > $@ + < tshark.rc.in > $@ capinfos.rc : capinfos.rc.in ..\config.nmake sed -e s/@VERSION@/$(VERSION)/ \ diff --git a/image/README.image b/image/README.image index bef5a7e9f1..8ff9945d71 100644 --- a/image/README.image +++ b/image/README.image @@ -47,7 +47,7 @@ icon-excl.xpm informational dialogs ethereal.rc.in MSVC++ resource templates editcap.rc.in mergecap.rc.in -tethereal.rc.in +tshark.rc.in text2pcap.rc.in stock_dialog_error_48.xpm GTK2 default icons for simple_dialog, from: diff --git a/image/tethereal.rc.in b/image/tethereal.rc.in deleted file mode 100644 index 2595fc477f..0000000000 --- a/image/tethereal.rc.in +++ /dev/null @@ -1,36 +0,0 @@ -#include "winver.h" - -WIRESHARK_ICON ICON "wireshark.ico" - -VS_VERSION_INFO VERSIONINFO - FILEVERSION @RC_VERSION@,0 - PRODUCTVERSION @RC_VERSION@,0 - FILEFLAGSMASK 0x0L -#ifdef _DEBUG - FILEFLAGS 0x3L -#else - FILEFLAGS 0x2L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "CompanyName", "The Wireshark developer community\0" - VALUE "FileDescription", "Tethereal\0" - VALUE "FileVersion", "@VERSION@\0" - VALUE "InternalName", "Tethereal @VERSION@\0" - VALUE "LegalCopyright", "Copyright © 2000 Gerald Combs , Gilbert Ramirez and others\0" - VALUE "OriginalFilename", "Tethereal.exe\0" - VALUE "ProductName", "Tethereal\0" - VALUE "ProductVersion", "@VERSION@\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END diff --git a/image/tshark.rc.in b/image/tshark.rc.in new file mode 100644 index 0000000000..51b1034ff3 --- /dev/null +++ b/image/tshark.rc.in @@ -0,0 +1,36 @@ +#include "winver.h" + +WIRESHARK_ICON ICON "wireshark.ico" + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @RC_VERSION@,0 + PRODUCTVERSION @RC_VERSION@,0 + FILEFLAGSMASK 0x0L +#ifdef _DEBUG + FILEFLAGS 0x3L +#else + FILEFLAGS 0x2L +#endif + FILEOS 0x4L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", "The Wireshark developer community\0" + VALUE "FileDescription", "TShark\0" + VALUE "FileVersion", "@VERSION@\0" + VALUE "InternalName", "TShark @VERSION@\0" + VALUE "LegalCopyright", "Copyright © 2000 Gerald Combs , Gilbert Ramirez and others\0" + VALUE "OriginalFilename", "TShark.exe\0" + VALUE "ProductName", "TShark\0" + VALUE "ProductVersion", "@VERSION@\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END diff --git a/packaging/nsis/Makefile.nmake b/packaging/nsis/Makefile.nmake index ef63336beb..bd741f9afd 100644 --- a/packaging/nsis/Makefile.nmake +++ b/packaging/nsis/Makefile.nmake @@ -35,7 +35,7 @@ DEST=wireshark-gtk2 DEST=wireshark !ENDIF -EXE=../../tethereal.exe ../../editcap.exe \ +EXE=../../tshark.exe ../../editcap.exe \ !IFDEF GTK1_DIR ../../ethereal.exe \ !ENDIF @@ -45,7 +45,7 @@ EXE=../../tethereal.exe ../../editcap.exe \ ../../text2pcap.exe ../../mergecap.exe ../../capinfos.exe WinPcap_3_1.exe DLL=../../wiretap/wiretap-$(WTAP_VERSION).dll DOC=../../doc/ethereal.html \ - ../../doc/tethereal.html \ + ../../doc/tshark.html \ ../../doc/ethereal-filter.html \ ../../doc/editcap.html \ ../../doc/text2pcap.html \ diff --git a/packaging/nsis/wireshark.nsi b/packaging/nsis/wireshark.nsi index 13533f5c97..bcd3c08afc 100644 --- a/packaging/nsis/wireshark.nsi +++ b/packaging/nsis/wireshark.nsi @@ -661,14 +661,14 @@ SectionEnd SectionGroupEnd ; "Wireshark" -Section "Tethereal" SecTethereal +Section "TShark" SecTShark ;------------------------------------------- !ifdef GTK1_DIR & GTK2_DIR SectionIn 1 2 !endif SetOutPath $INSTDIR -File "..\..\tethereal.exe" -File "..\..\doc\tethereal.html" +File "..\..\tshark.exe" +File "..\..\doc\tshark.html" SectionEnd SectionGroup "Plugins / Extensions" SecPluginsGroup @@ -807,11 +807,11 @@ Section "Uninstall" un.SecUinstall SectionIn 1 2 SetShellVarContext all -Delete "$INSTDIR\tethereal.exe" -IfErrors 0 NoTetherealErrorMsg - MessageBox MB_OK "Please note: tethereal.exe could not be removed, it's probably in use!" IDOK 0 ;skipped if tethereal.exe removed - Abort "Please note: tethereal.exe could not be removed, it's probably in use! Abort uninstall process!" -NoTetherealErrorMsg: +Delete "$INSTDIR\tshark.exe" +IfErrors 0 NoTSharkErrorMsg + MessageBox MB_OK "Please note: tshark.exe could not be removed, it's probably in use!" IDOK 0 ;skipped if tshark.exe removed + Abort "Please note: tshark.exe could not be removed, it's probably in use! Abort uninstall process!" +NoTSharkErrorMsg: Delete "$INSTDIR\wireshark.exe" IfErrors 0 NoWiresharkErrorMsg @@ -1003,8 +1003,8 @@ SectionEnd !insertmacro MUI_DESCRIPTION_TEXT ${SecGTKWimp} "GTK-Wimp is the GTK2 windows impersonator (native Win32 look and feel, for Win2000 and up)." !endif !endif - !insertmacro MUI_DESCRIPTION_TEXT ${SecTethereal} "Tethereal is a text based network protocol analyzer." - !insertmacro MUI_DESCRIPTION_TEXT ${SecPluginsGroup} "Some plugins and extensions for both Wireshark and Tethereal." + !insertmacro MUI_DESCRIPTION_TEXT ${SecTShark} "TShark is a text based network protocol analyzer." + !insertmacro MUI_DESCRIPTION_TEXT ${SecPluginsGroup} "Some plugins and extensions for both Wireshark and TShark." !insertmacro MUI_DESCRIPTION_TEXT ${SecPlugins} "Plugins with some extended dissections." !insertmacro MUI_DESCRIPTION_TEXT ${SecStatsTree} "Plugin for some extended statistics." !insertmacro MUI_DESCRIPTION_TEXT ${SecMate} "Plugin - Meta Analysis and Tracing Engine (Experimental)." diff --git a/plugins/asn1/packet-asn1.c b/plugins/asn1/packet-asn1.c index 2155495453..fe8aadadb3 100644 --- a/plugins/asn1/packet-asn1.c +++ b/plugins/asn1/packet-asn1.c @@ -3506,7 +3506,7 @@ build_pdu_tree(const char *pduname) #ifdef DISSECTOR_WITH_GUI -/* This cannot work in twireshark.... don't include for now */ +/* This cannot work in tshark.... don't include for now */ #if GTK_MAJOR_VERSION >= 2 #define SHOWPDU /* this needs GTK2 */ #endif diff --git a/plugins/lua/elua_gui.c b/plugins/lua/elua_gui.c index 79c03e9274..c058ac05f2 100644 --- a/plugins/lua/elua_gui.c +++ b/plugins/lua/elua_gui.c @@ -499,7 +499,7 @@ ELUA_FUNCTION elua_retap_packets(lua_State* L) { if ( ops->retap_packets ) { ops->retap_packets(); } else { - ELUA_ERROR(elua_retap_packets, "does not work on tWireshark"); + ELUA_ERROR(elua_retap_packets, "does not work on TShark"); } return 0; diff --git a/plugins/lua/elua_tap.c b/plugins/lua/elua_tap.c index 451ec6867e..185661504d 100644 --- a/plugins/lua/elua_tap.c +++ b/plugins/lua/elua_tap.c @@ -272,7 +272,7 @@ static int Tap_newindex(lua_State* L) { function tap.packet(pinfo,tvb,userdata) ... end */ /* ELUA_ATTRIBUTE Tap_draw WO A function that will be called once every few seconds to redraw the gui objects - in twireshark this funtion is called oly at the very end of the capture file. + in tshark this funtion is called oly at the very end of the capture file. function tap.draw(userdata) ... end */ diff --git a/tap-afpstat.c b/tap-afpstat.c index d41e3782c6..003243b844 100644 --- a/tap-afpstat.c +++ b/tap-afpstat.c @@ -157,7 +157,7 @@ afpstat_init(const char *optarg, void* userdata _U_) g_free(ss->filter); g_free(ss); - fprintf(stderr, "twireshark: Couldn't register afp,rtt tap: %s\n", + fprintf(stderr, "tshark: Couldn't register afp,rtt tap: %s\n", error_string->str); g_string_free(error_string, TRUE); exit(1); diff --git a/tap-bootpstat.c b/tap-bootpstat.c index bbb450d18a..83d304091a 100644 --- a/tap-bootpstat.c +++ b/tap-bootpstat.c @@ -170,7 +170,7 @@ dhcpstat_init(const char *optarg, void* userdata _U_) /* error, we failed to attach to the tap. clean up */ g_free(sp->filter); g_free(sp); - fprintf(stderr, "twireshark: Couldn't register dhcp,stat tap: %s\n", + fprintf(stderr, "tshark: Couldn't register dhcp,stat tap: %s\n", error_string->str); g_string_free(error_string, TRUE); exit(1); diff --git a/tap-dcerpcstat.c b/tap-dcerpcstat.c index a15f18209d..99767166c8 100644 --- a/tap-dcerpcstat.c +++ b/tap-dcerpcstat.c @@ -229,15 +229,15 @@ dcerpcstat_init(const char *optarg, void* userdata _U_) filter=NULL; } } else { - fprintf(stderr, "twireshark: invalid \"-z dcerpc,rtt,,.[,]\" argument\n"); + fprintf(stderr, "tshark: invalid \"-z dcerpc,rtt,,.[,]\" argument\n"); exit(1); } if (major < 0 || major > 65535) { - fprintf(stderr,"twireshark: dcerpcstat_init() Major version number %d is invalid - must be positive and <= 65535\n", major); + fprintf(stderr,"tshark: dcerpcstat_init() Major version number %d is invalid - must be positive and <= 65535\n", major); exit(1); } if (minor < 0 || minor > 65535) { - fprintf(stderr,"twireshark: dcerpcstat_init() Minor version number %d is invalid - must be positive and <= 65535\n", minor); + fprintf(stderr,"tshark: dcerpcstat_init() Minor version number %d is invalid - must be positive and <= 65535\n", minor); exit(1); } ver = major; @@ -246,7 +246,7 @@ dcerpcstat_init(const char *optarg, void* userdata _U_) rs->prog=dcerpc_get_proto_name(&uuid, ver); if(!rs->prog){ g_free(rs); - fprintf(stderr,"twireshark: dcerpcstat_init() Protocol with uuid:%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x v%u not supported\n",uuid.Data1,uuid.Data2,uuid.Data3,uuid.Data4[0],uuid.Data4[1],uuid.Data4[2],uuid.Data4[3],uuid.Data4[4],uuid.Data4[5],uuid.Data4[6],uuid.Data4[7],ver); + fprintf(stderr,"tshark: dcerpcstat_init() Protocol with uuid:%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x v%u not supported\n",uuid.Data1,uuid.Data2,uuid.Data3,uuid.Data4[0],uuid.Data4[1],uuid.Data4[2],uuid.Data4[3],uuid.Data4[4],uuid.Data4[5],uuid.Data4[6],uuid.Data4[7],ver); exit(1); } procs=dcerpc_get_proto_sub_dissector(&uuid, ver); @@ -291,7 +291,7 @@ dcerpcstat_init(const char *optarg, void* userdata _U_) g_free(rs->filter); g_free(rs); - fprintf(stderr, "twireshark: Couldn't register dcerpc,rtt tap: %s\n", + fprintf(stderr, "tshark: Couldn't register dcerpc,rtt tap: %s\n", error_string->str); g_string_free(error_string, TRUE); exit(1); diff --git a/tap-h225counter.c b/tap-h225counter.c index d518913972..29afbdacec 100644 --- a/tap-h225counter.c +++ b/tap-h225counter.c @@ -412,7 +412,7 @@ h225counter_init(const char *optarg, void* userdata _U_) g_free(hs->filter); g_free(hs); - fprintf(stderr, "twireshark: Couldn't register h225,counter tap: %s\n", + fprintf(stderr, "tshark: Couldn't register h225,counter tap: %s\n", error_string->str); g_string_free(error_string, TRUE); exit(1); diff --git a/tap-h225rassrt.c b/tap-h225rassrt.c index 7158a72692..d9db4141a6 100644 --- a/tap-h225rassrt.c +++ b/tap-h225rassrt.c @@ -236,7 +236,7 @@ h225rassrt_init(const char *optarg, void* userdata _U_) g_free(hs->filter); g_free(hs); - fprintf(stderr, "twireshark: Couldn't register h225,srt tap: %s\n", + fprintf(stderr, "tshark: Couldn't register h225,srt tap: %s\n", error_string->str); g_string_free(error_string, TRUE); exit(1); diff --git a/tap-httpstat.c b/tap-httpstat.c index fc2a168681..073a35d925 100644 --- a/tap-httpstat.c +++ b/tap-httpstat.c @@ -314,7 +314,7 @@ gtk_httpstat_init(const char *optarg,void* userdata _U_) /* error, we failed to attach to the tap. clean up */ g_free(sp->filter); g_free(sp); - fprintf (stderr, "twireshark: Couldn't register http,stat tap: %s\n", + fprintf (stderr, "tshark: Couldn't register http,stat tap: %s\n", error_string->str); g_string_free(error_string, TRUE); exit(1); diff --git a/tap-iostat.c b/tap-iostat.c index 8ad4a3c2e1..1ed2019628 100644 --- a/tap-iostat.c +++ b/tap-iostat.c @@ -479,18 +479,18 @@ register_io_tap(io_stat_t *io, int i, const char *filter) p=filter+namelen+1; parenp=strchr(p, ')'); if(!parenp){ - fprintf(stderr, "twireshark: Closing parenthesis missing from calculated expression.\n"); + fprintf(stderr, "tshark: Closing parenthesis missing from calculated expression.\n"); exit(10); } /* bail out if there was no field specified */ if(parenp==p){ - fprintf(stderr, "twireshark: You didn't specify a field name for %s(*).\n", + fprintf(stderr, "tshark: You didn't specify a field name for %s(*).\n", calc_type_table[j].func_name); exit(10); } field=malloc(parenp-p+1); if(!field){ - fprintf(stderr, "twireshark: Out of memory.\n"); + fprintf(stderr, "tshark: Out of memory.\n"); exit(10); } memcpy(field, p, parenp-p); @@ -499,7 +499,7 @@ register_io_tap(io_stat_t *io, int i, const char *filter) hfi=proto_registrar_get_byname(field); if(!hfi){ - fprintf(stderr, "twireshark: There is no field named '%s'.\n", + fprintf(stderr, "tshark: There is no field named '%s'.\n", field); free(field); exit(10); @@ -533,7 +533,7 @@ register_io_tap(io_stat_t *io, int i, const char *filter) break; default: fprintf(stderr, - "twireshark: %s is a relative-time field, so %s(*) calculations are not supported on it.", + "tshark: %s is a relative-time field, so %s(*) calculations are not supported on it.", field, calc_type_table[j].func_name); exit(10); @@ -547,7 +547,7 @@ register_io_tap(io_stat_t *io, int i, const char *filter) */ if(io->items[i].calc_type!=CALC_TYPE_COUNT){ fprintf(stderr, - "twireshark: %s is a 64-bit integer, so %s(*) calculations are not supported on it.", + "tshark: %s is a 64-bit integer, so %s(*) calculations are not supported on it.", field, calc_type_table[j].func_name); exit(10); @@ -560,7 +560,7 @@ register_io_tap(io_stat_t *io, int i, const char *filter) */ if(io->items[i].calc_type!=CALC_TYPE_COUNT){ fprintf(stderr, - "twireshark: %s doesn't have integral values, so %s(*) calculations are not supported on it.\n", + "tshark: %s doesn't have integral values, so %s(*) calculations are not supported on it.\n", field, calc_type_table[j].func_name); exit(10); @@ -581,7 +581,7 @@ CALC_TYPE_AVG 5 if(error_string){ g_free(io->items); g_free(io); - fprintf(stderr, "twireshark: Couldn't register io,stat tap: %s\n", + fprintf(stderr, "tshark: Couldn't register io,stat tap: %s\n", error_string->str); g_string_free(error_string, TRUE); exit(1); @@ -604,7 +604,7 @@ iostat_init(const char *optarg, void* userdata _U_) filter=NULL; } } else { - fprintf(stderr, "twireshark: invalid \"-z io,stat,[,]\" argument\n"); + fprintf(stderr, "tshark: invalid \"-z io,stat,[,]\" argument\n"); exit(1); } @@ -612,7 +612,7 @@ iostat_init(const char *optarg, void* userdata _U_) /* make interval be number of ms */ interval=(gint32)(interval_float*1000.0+0.9); if(interval<1){ - fprintf(stderr, "twireshark: \"-z\" interval must be >=0.001 seconds.\n"); + fprintf(stderr, "tshark: \"-z\" interval must be >=0.001 seconds.\n"); exit(10); } diff --git a/tap-iousers.c b/tap-iousers.c index 029a7ec737..9444e05c85 100644 --- a/tap-iousers.c +++ b/tap-iousers.c @@ -671,7 +671,7 @@ iousers_init(const char *optarg, void* userdata _U_) tap_type_name="SCTP"; packet_func=iousers_sctp_packet; } else { - fprintf(stderr, "twireshark: invalid \"-z conv,[,]\" argument\n"); + fprintf(stderr, "tshark: invalid \"-z conv,[,]\" argument\n"); fprintf(stderr," must be one of\n"); fprintf(stderr," \"eth\"\n"); fprintf(stderr," \"fc\"\n"); @@ -701,7 +701,7 @@ iousers_init(const char *optarg, void* userdata _U_) g_free(iu->items); } g_free(iu); - fprintf(stderr, "twireshark: Couldn't register conversations tap: %s\n", + fprintf(stderr, "tshark: Couldn't register conversations tap: %s\n", error_string->str); g_string_free(error_string, TRUE); exit(1); diff --git a/tap-mgcpstat.c b/tap-mgcpstat.c index 080113daa3..f163983115 100644 --- a/tap-mgcpstat.c +++ b/tap-mgcpstat.c @@ -217,7 +217,7 @@ mgcpstat_init(const char *optarg, void* userdata _U_) g_free(ms->filter); g_free(ms); - fprintf(stderr, "twireshark: Couldn't register mgcp,rtd tap: %s\n", + fprintf(stderr, "tshark: Couldn't register mgcp,rtd tap: %s\n", error_string->str); g_string_free(error_string, TRUE); exit(1); diff --git a/tap-protocolinfo.c b/tap-protocolinfo.c index 3f4cc3108b..484df80905 100644 --- a/tap-protocolinfo.c +++ b/tap-protocolinfo.c @@ -22,7 +22,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* This module provides Protocol Column Info tap for twireshark */ +/* This module provides Protocol Column Info tap for tshark */ #ifdef HAVE_CONFIG_H # include "config.h" @@ -67,7 +67,7 @@ protocolinfo_packet(void *prs, packet_info *pinfo, epan_dissect_t *edt, const vo * and, if so, we report that error and exit. */ if (pinfo->cinfo == NULL) { - fprintf(stderr, "twireshark: the proto,colinfo tap doesn't work if the columns aren't being printed.\n"); + fprintf(stderr, "tshark: the proto,colinfo tap doesn't work if the columns aren't being printed.\n"); exit(1); } gp=proto_get_finfo_ptr_array(edt->tree, rs->hf_index); @@ -103,13 +103,13 @@ protocolinfo_init(const char *optarg, void* userdata _U_) } } if(!field){ - fprintf(stderr, "twireshark: invalid \"-z proto,colinfo,,\" argument\n"); + fprintf(stderr, "tshark: invalid \"-z proto,colinfo,,\" argument\n"); exit(1); } hfi=proto_registrar_get_byname(field); if(!hfi){ - fprintf(stderr, "twireshark: Field \"%s\" doesn't exist.\n", field); + fprintf(stderr, "tshark: Field \"%s\" doesn't exist.\n", field); exit(1); } @@ -126,7 +126,7 @@ protocolinfo_init(const char *optarg, void* userdata _U_) error_string=register_tap_listener("frame", rs, rs->filter, NULL, protocolinfo_packet, NULL); if(error_string){ /* error, we failed to attach to the tap. complain and clean up */ - fprintf(stderr, "twireshark: Couldn't register proto,colinfo tap: %s\n", + fprintf(stderr, "tshark: Couldn't register proto,colinfo tap: %s\n", error_string->str); g_string_free(error_string, TRUE); if(rs->filter){ diff --git a/tap-protohierstat.c b/tap-protohierstat.c index 19615cb5cc..49526b7f78 100644 --- a/tap-protohierstat.c +++ b/tap-protohierstat.c @@ -22,7 +22,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* This module provides ProtocolHierarchyStatistics for twireshark */ +/* This module provides ProtocolHierarchyStatistics for tshark */ #ifdef HAVE_CONFIG_H # include "config.h" @@ -193,7 +193,7 @@ protohierstat_init(const char *optarg, void* userdata _U_) filter="frame"; } } else { - fprintf(stderr, "twireshark: invalid \"-z io,phs[,]\" argument\n"); + fprintf(stderr, "tshark: invalid \"-z io,phs[,]\" argument\n"); exit(1); } @@ -212,7 +212,7 @@ protohierstat_init(const char *optarg, void* userdata _U_) g_free(rs->filter); g_free(rs); - fprintf(stderr, "twireshark: Couldn't register io,phs tap: %s\n", + fprintf(stderr, "tshark: Couldn't register io,phs tap: %s\n", error_string->str); g_string_free(error_string, TRUE); exit(1); diff --git a/tap-rpcprogs.c b/tap-rpcprogs.c index 15517517fb..fcad0f54f9 100644 --- a/tap-rpcprogs.c +++ b/tap-rpcprogs.c @@ -22,8 +22,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* This module provides rpc call/reply SRT statistics to twireshark. - * It is only used by twireshark and not wireshark +/* This module provides rpc call/reply SRT statistics to tshark. + * It is only used by tshark and not wireshark */ #ifdef HAVE_CONFIG_H @@ -227,7 +227,7 @@ rpcprogs_init(const char *optarg _U_, void* userdata _U_) error_string=register_tap_listener("rpc", NULL, NULL, NULL, rpcprogs_packet, rpcprogs_draw); if(error_string){ - fprintf(stderr,"twireshark: Couldn't register rpc,programs tap: %s\n", + fprintf(stderr,"tshark: Couldn't register rpc,programs tap: %s\n", error_string->str); g_string_free(error_string, TRUE); exit(1); diff --git a/tap-rpcstat.c b/tap-rpcstat.c index d9799803cc..5ba75043a0 100644 --- a/tap-rpcstat.c +++ b/tap-rpcstat.c @@ -22,8 +22,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* This module provides rpc call/reply RTT statistics to twireshark. - * It is only used by twireshark and not wireshark +/* This module provides rpc call/reply RTT statistics to tshark. + * It is only used by tshark and not wireshark * * It serves as an example on how to use the tap api. */ @@ -66,7 +66,7 @@ typedef struct _rpcstat_t { -/* This callback is never used by twireshark but it is here for completeness. +/* This callback is never used by tshark but it is here for completeness. * When registering below, we could just have left this function as NULL. * * When used by wireshark, this function will be called whenever we would need @@ -186,10 +186,10 @@ rpcstat_packet(void *prs, packet_info *pinfo, epan_dissect_t *edt _U_, const voi return 1; } -/* This callback is used when twireshark wants us to draw/update our - * data to the output device. Since this is twireshark only output is +/* This callback is used when tshark wants us to draw/update our + * data to the output device. Since this is tshark only output is * stdout. - * Twireshark will only call this callback once, which is when twireshark has + * TShark will only call this callback once, which is when tshark has * finished reading all packets and exists. * If used with wireshark this may be called any time, perhaps once every 3 * seconds or so. @@ -268,7 +268,7 @@ rpcstat_find_procs(gpointer *key, gpointer *value _U_, gpointer *user_data _U_) /* When called, this function will create a new instance of rpcstat. * program and version are whick onc-rpc program/version we want to * collect statistics for. - * This function is called from twireshark when it parses the -z rpc, arguments + * This function is called from tshark when it parses the -z rpc, arguments * and it creates a new instance to store statistics in and registers this * new instance for the rpc tap. */ @@ -289,7 +289,7 @@ rpcstat_init(const char *optarg, void* userdata _U_) filter=NULL; } } else { - fprintf(stderr, "twireshark: invalid \"-z rpc,rtt,,[,]\" argument\n"); + fprintf(stderr, "tshark: invalid \"-z rpc,rtt,,[,]\" argument\n"); exit(1); } @@ -309,8 +309,8 @@ rpcstat_init(const char *optarg, void* userdata _U_) rpc_max_proc=-1; g_hash_table_foreach(rpc_procs, (GHFunc)rpcstat_find_procs, NULL); if(rpc_min_proc==-1){ - fprintf(stderr,"twireshark: Invalid -z rpc,rrt,%d,%d\n",rpc_program,rpc_version); - fprintf(stderr," Program:%d version:%d isn't supported by twireshark.\n", rpc_program, rpc_version); + fprintf(stderr,"tshark: Invalid -z rpc,rrt,%d,%d\n",rpc_program,rpc_version); + fprintf(stderr," Program:%d version:%d isn't supported by tshark.\n", rpc_program, rpc_version); exit(1); } @@ -345,7 +345,7 @@ rpcstat_init(const char *optarg, void* userdata _U_) g_free(rs->filter); g_free(rs); - fprintf(stderr, "twireshark: Couldn't register rpc,rtt tap: %s\n", + fprintf(stderr, "tshark: Couldn't register rpc,rtt tap: %s\n", error_string->str); g_string_free(error_string, TRUE); exit(1); diff --git a/tap-sctpchunkstat.c b/tap-sctpchunkstat.c index 305e2a08aa..de060d53fd 100644 --- a/tap-sctpchunkstat.c +++ b/tap-sctpchunkstat.c @@ -246,7 +246,7 @@ sctpstat_init(const char *optarg, void* userdata _U_) g_free(hs->filter); g_free(hs); - fprintf(stderr, "twireshark: Couldn't register sctp,stat tap: %s\n", + fprintf(stderr, "tshark: Couldn't register sctp,stat tap: %s\n", error_string->str); g_string_free(error_string, TRUE); exit(1); diff --git a/tap-sipstat.c b/tap-sipstat.c index 0203a977cd..872eac28f5 100644 --- a/tap-sipstat.c +++ b/tap-sipstat.c @@ -378,7 +378,7 @@ sipstat_init(const char *optarg, void* userdata _U_) /* error, we failed to attach to the tap. clean up */ g_free(sp->filter); g_free(sp); - fprintf (stderr, "twireshark: Couldn't register sip,stat tap: %s\n", + fprintf (stderr, "tshark: Couldn't register sip,stat tap: %s\n", error_string->str); g_string_free(error_string, TRUE); exit(1); diff --git a/tap-smbsids.c b/tap-smbsids.c index 6e39ec38e9..21eb5f1a67 100644 --- a/tap-smbsids.c +++ b/tap-smbsids.c @@ -78,14 +78,14 @@ smbsids_init(const char *optarg _U_, void* userdata _U_) fprintf(stderr,"Either enable Edit/Preferences/Protocols/SMB/Snoop SID name mappings in wireshark\n"); fprintf(stderr,"or override the preference file by specifying\n"); fprintf(stderr," -o \"smb.sid_name_snooping=TRUE\"\n"); - fprintf(stderr,"on the twireshark command line.\n"); + fprintf(stderr,"on the tshark command line.\n"); exit(1); } error_string=register_tap_listener("smb", NULL, NULL, NULL, smbsids_packet, smbsids_draw); if(error_string){ - fprintf(stderr, "twireshark: Couldn't register smb,sids tap:%s\n", + fprintf(stderr, "tshark: Couldn't register smb,sids tap:%s\n", error_string->str); g_string_free(error_string, TRUE); exit(1); diff --git a/tap-smbstat.c b/tap-smbstat.c index 8f6dc23289..c551546412 100644 --- a/tap-smbstat.c +++ b/tap-smbstat.c @@ -265,7 +265,7 @@ smbstat_init(const char *optarg,void* userdata _U_) g_free(ss->filter); g_free(ss); - fprintf(stderr, "twireshark: Couldn't register smb,rtt tap: %s\n", + fprintf(stderr, "tshark: Couldn't register smb,rtt tap: %s\n", error_string->str); g_string_free(error_string, TRUE); exit(1); diff --git a/tap-stats_tree.c b/tap-stats_tree.c index 7c60799e58..8a04b7adba 100644 --- a/tap-stats_tree.c +++ b/tap-stats_tree.c @@ -1,5 +1,5 @@ /* tap-stats_tree.c - * twireshark's tap implememntation of stats_tree + * tshark's tap implememntation of stats_tree * 2005, Luis E. G. Ontanon * * $Id$ diff --git a/tap-wspstat.c b/tap-wspstat.c index b99061dc01..8080560b9f 100644 --- a/tap-wspstat.c +++ b/tap-wspstat.c @@ -22,8 +22,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* This module provides WSP statistics to twireshark. - * It is only used by twireshark and not wireshark +/* This module provides WSP statistics to tshark. + * It is only used by tshark and not wireshark * */ @@ -168,10 +168,10 @@ wspstat_packet(void *psp, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const } -/* This callback is used when twireshark wants us to draw/update our - * data to the output device. Since this is twireshark only output is +/* This callback is used when tshark wants us to draw/update our + * data to the output device. Since this is tshark only output is * stdout. - * Twireshark will only call this callback once, which is when twireshark has + * TShark will only call this callback once, which is when tshark has * finished reading all packets and exists. * If used with wireshark this may be called any time, perhaps once every 3 * seconds or so. @@ -209,7 +209,7 @@ wspstat_draw(void *psp) /* When called, this function will create a new instance of wspstat. * program and version are whick onc-rpc program/version we want to * collect statistics for. - * This function is called from twireshark when it parses the -z wsp, arguments + * This function is called from tshark when it parses the -z wsp, arguments * and it creates a new instance to store statistics in and registers this * new instance for the wsp tap. */ @@ -272,7 +272,7 @@ wspstat_init(const char *optarg, void* userdata _U_) g_free(sp); g_hash_table_foreach( sp->hash, (GHFunc) wsp_free_hash_table, NULL ) ; g_hash_table_destroy( sp->hash ); - fprintf(stderr, "twireshark: Couldn't register wsp,stat tap: %s\n", + fprintf(stderr, "tshark: Couldn't register wsp,stat tap: %s\n", error_string->str); g_string_free(error_string, TRUE); exit(1); diff --git a/test/README.test b/test/README.test index 7734036256..4dfcf2b81f 100644 --- a/test/README.test +++ b/test/README.test @@ -7,7 +7,7 @@ What is it? This is basically a collection of bash scripts to test the command line options of: - Ethereal - - Tethereal + - TShark - Dumpcap Motivation diff --git a/test/config.sh b/test/config.sh index f35f882d0f..7a6dfa2896 100644 --- a/test/config.sh +++ b/test/config.sh @@ -28,7 +28,7 @@ ETH_BIN_PATH=../Debug_GTK2 # Tweak the following to your liking. ETHEREAL=$ETH_BIN_PATH/ethereal -TETHEREAL=$ETH_BIN_PATH/tethereal +TSHARK=$ETH_BIN_PATH/tshark CAPINFOS=$ETH_BIN_PATH/capinfos DUMPCAP=$ETH_BIN_PATH/dumpcap diff --git a/test/suite-capture.sh b/test/suite-capture.sh index a6349f5168..4315737ba2 100644 --- a/test/suite-capture.sh +++ b/test/suite-capture.sh @@ -38,7 +38,7 @@ capture_step_10packets() { test_step_failed "exit status of $DUT: $RETURNVALUE" # part of the Prerequisite checks # probably wrong interface, output the possible interfaces - $TETHEREAL -D + $TSHARK -D return fi @@ -58,7 +58,7 @@ capture_step_10packets() { cat ./testout.txt # part of the Prerequisite checks # probably wrong interface, output the possible interfaces - $TETHEREAL -D + $TSHARK -D test_step_failed "No or not enough traffic captured. Probably the wrong interface: $TRAFFIC_CAPTURE_IFACE!" fi } @@ -69,7 +69,7 @@ capture_step_10packets_stdout() { RETURNVALUE=$? if [ ! $RETURNVALUE -eq $EXIT_OK ]; then test_step_failed "exit status of $DUT: $RETURNVALUE" - $TETHEREAL -D + $TSHARK -D return fi @@ -88,7 +88,7 @@ capture_step_10packets_stdout() { echo cat ./testout.txt cat ./testout2.txt - $TETHEREAL -D + $TSHARK -D test_step_failed "No or not enough traffic captured. Probably the wrong interface: $TRAFFIC_CAPTURE_IFACE!" fi } @@ -101,7 +101,7 @@ capture_step_2multi_10packets() { test_step_failed "exit status of $DUT: $RETURNVALUE" # part of the Prerequisite checks # probably wrong interface, output the possible interfaces - $TETHEREAL -D + $TSHARK -D return fi @@ -169,8 +169,8 @@ capture_step_snapshot() { return fi - # use tethereal to filter out all packets, which are larger than 68 bytes - $TETHEREAL -r ./testout.pcap -w ./testout2.pcap -R 'frame.cap_len>68' > ./testout.txt 2>&1 + # use tshark to filter out all packets, which are larger than 68 bytes + $TSHARK -r ./testout.pcap -w ./testout2.pcap -R 'frame.cap_len>68' > ./testout.txt 2>&1 # ok, we got a capture file, does it contain exactly 0 packets? $CAPINFOS ./testout2.pcap > ./testout.txt @@ -196,8 +196,8 @@ ethereal_capture_suite() { test_step_add "Capture snapshot length 68 bytes (${TRAFFIC_CAPTURE_DURATION}s)" capture_step_snapshot } -tethereal_capture_suite() { - DUT=$TETHEREAL +tshark_capture_suite() { + DUT=$TSHARK test_step_add "Capture 10 packets" capture_step_10packets test_step_add "Capture 10 packets using stdout: -w -" capture_step_10packets_stdout test_step_add "Capture read filter (${TRAFFIC_CAPTURE_DURATION}s)" capture_step_read_filter @@ -225,7 +225,7 @@ capture_suite() { test_step_set_pre capture_cleanup_step test_step_set_post capture_cleanup_step test_remark_add "Capture - need some traffic on interface: \"$TRAFFIC_CAPTURE_IFACE\"" - test_suite_add "Tethereal capture" tethereal_capture_suite + test_suite_add "TShark capture" tshark_capture_suite test_suite_add "Ethereal capture" ethereal_capture_suite test_suite_add "Dumpcap capture" dumpcap_capture_suite } diff --git a/test/suite-clopts.sh b/test/suite-clopts.sh index be718d49d7..f02a073aa3 100644 --- a/test/suite-clopts.sh +++ b/test/suite-clopts.sh @@ -30,7 +30,7 @@ EXIT_ERROR=2 # generic: check against a specific exit status with a single char option -# $1 command: tethereal +# $1 command: tshark # $2 option: a # $3 expected exit status: 0 test_single_char_options() @@ -49,7 +49,7 @@ test_single_char_options() # check exit status when reading an existing file clopts_step_existing_file() { - $TETHEREAL -r $CAPFILE > ./testout.txt 2>&1 + $TSHARK -r $CAPFILE > ./testout.txt 2>&1 RETURNVALUE=$? if [ ! $RETURNVALUE -eq $EXIT_OK ]; then test_step_failed "exit status: $RETURNVALUE" @@ -62,7 +62,7 @@ clopts_step_existing_file() { # check exit status when reading a none existing file clopts_step_nonexisting_file() { - $TETHEREAL -r ThisFileDontExist.pcap > ./testout.txt 2>&1 + $TSHARK -r ThisFileDontExist.pcap > ./testout.txt 2>&1 RETURNVALUE=$? if [ ! $RETURNVALUE -eq $EXIT_ERROR ]; then test_step_failed "exit status: $RETURNVALUE" @@ -74,10 +74,10 @@ clopts_step_nonexisting_file() { # check exit status of all single char option being invalid -clopts_suite_tethereal_invalid_chars() { +clopts_suite_tshark_invalid_chars() { for index in A B C E F H I J K M N O P Q R T U W X Y Z a b c d e f g i j k m o r s t u w y z do - test_step_add "Invalid Tethereal parameter -$index, exit status must be $EXIT_COMMAND_LINE" "test_single_char_options $TETHEREAL $index $EXIT_COMMAND_LINE" + test_step_add "Invalid TShark parameter -$index, exit status must be $EXIT_COMMAND_LINE" "test_single_char_options $TSHARK $index $EXIT_COMMAND_LINE" done } @@ -86,7 +86,7 @@ clopts_suite_tethereal_invalid_chars() { clopts_suite_valid_chars() { for index in D G L h v do - test_step_add "Valid Tethereal parameter -$index, exit status must be $EXIT_OK" "test_single_char_options $TETHEREAL $index $EXIT_OK" + test_step_add "Valid TShark parameter -$index, exit status must be $EXIT_OK" "test_single_char_options $TSHARK $index $EXIT_OK" done } @@ -95,7 +95,7 @@ clopts_suite_valid_chars() { # check exit status and grep output string of an invalid capture filter clopts_step_invalid_capfilter() { - $TETHEREAL -f 'jkghg' -w './testout.pcap' > ./testout.txt 2>&1 + $TSHARK -f 'jkghg' -w './testout.pcap' > ./testout.txt 2>&1 RETURNVALUE=$? if [ ! $RETURNVALUE -eq $EXIT_OK ]; then test_step_failed "exit status: $RETURNVALUE" @@ -112,7 +112,7 @@ clopts_step_invalid_capfilter() { # check exit status and grep output string of an invalid interface clopts_step_invalid_interface() { - $TETHEREAL -i invalid_interface -w './testout.pcap' > ./testout.txt 2>&1 + $TSHARK -i invalid_interface -w './testout.pcap' > ./testout.txt 2>&1 RETURNVALUE=$? if [ ! $RETURNVALUE -eq $EXIT_OK ]; then test_step_failed "exit status: $RETURNVALUE" @@ -130,7 +130,7 @@ clopts_step_invalid_interface() { # check exit status and grep output string of an invalid interface index # (valid interface indexes start with 1) clopts_step_invalid_interface_index() { - $TETHEREAL -i 0 -w './testout.pcap' > ./testout.txt 2>&1 + $TSHARK -i 0 -w './testout.pcap' > ./testout.txt 2>&1 RETURNVALUE=$? if [ ! $RETURNVALUE -eq $EXIT_COMMAND_LINE ]; then test_step_failed "exit status: $RETURNVALUE" @@ -148,7 +148,7 @@ clopts_step_invalid_interface_index() { # check exit status and grep output string of an invalid capture filter # XXX - how to efficiently test the *invalid* flags? clopts_step_valid_name_resolving() { - $TETHEREAL -N mntC -a duration:1 > ./testout.txt 2>&1 + $TSHARK -N mntC -a duration:1 > ./testout.txt 2>&1 RETURNVALUE=$? if [ ! $RETURNVALUE -eq $EXIT_OK ]; then test_step_failed "exit status: $RETURNVALUE" @@ -171,8 +171,8 @@ clopts_post_step() { clopt_suite() { test_step_set_post clopts_post_step test_suite_add "Basic tests" clopts_suite_basic - test_suite_add "Invalid Tethereal single char options" clopts_suite_tethereal_invalid_chars - test_suite_add "Valid Tethereal single char options" clopts_suite_valid_chars + test_suite_add "Invalid TShark single char options" clopts_suite_tshark_invalid_chars + test_suite_add "Valid TShark single char options" clopts_suite_valid_chars test_step_add "Invalid capture filter -f" clopts_step_invalid_capfilter test_step_add "Invalid capture interface -i" clopts_step_invalid_interface test_step_add "Invalid capture interface index 0" clopts_step_invalid_interface_index diff --git a/test/suite-io.sh b/test/suite-io.sh index f3f87adf9d..ebcfdedfd7 100644 --- a/test/suite-io.sh +++ b/test/suite-io.sh @@ -38,7 +38,7 @@ io_step_input_file() { test_step_failed "exit status of $DUT: $RETURNVALUE" # part of the Prerequisite checks # probably wrong interface, output the possible interfaces - $TETHEREAL -D + $TSHARK -D return fi @@ -58,7 +58,7 @@ io_step_input_file() { cat ./testout.txt # part of the Prerequisite checks # probably wrong interface, output the possible interfaces - $TETHEREAL -D + $TSHARK -D test_step_failed "No or not enough traffic captured. Probably the wrong interface: $TRAFFIC_CAPTURE_IFACE!" fi } @@ -69,7 +69,7 @@ io_step_output_piping() { RETURNVALUE=$? if [ ! $RETURNVALUE -eq $EXIT_OK ]; then test_step_failed "exit status of $DUT: $RETURNVALUE" - $TETHEREAL -D + $TSHARK -D return fi @@ -88,7 +88,7 @@ io_step_output_piping() { echo cat ./testout.txt cat ./testout2.txt - $TETHEREAL -D + $TSHARK -D test_step_failed "No or not enough traffic captured. Probably the wrong interface: $TRAFFIC_CAPTURE_IFACE!" fi } @@ -98,7 +98,7 @@ io_step_input_piping() { cat -B dhcp.pcap | $DUT -r - -w ./testout.pcap 2>./testout.txt RETURNVALUE=$? if [ ! $RETURNVALUE -eq $EXIT_OK ]; then - $TETHEREAL -D + $TSHARK -D echo cat ./testout.txt test_step_failed "exit status of $DUT: $RETURNVALUE" @@ -120,7 +120,7 @@ io_step_input_piping() { echo cat ./testout.txt cat ./testout2.txt - $TETHEREAL -D + $TSHARK -D test_step_failed "No or not enough traffic captured. Probably the wrong interface: $TRAFFIC_CAPTURE_IFACE!" fi } @@ -131,8 +131,8 @@ ethereal_io_suite() { test_step_add "Input file" io_step_input_file } -tethereal_io_suite() { - DUT=$TETHEREAL +tshark_io_suite() { + DUT=$TSHARK test_step_add "Input file" io_step_input_file test_step_add "Output piping" io_step_output_piping #test_step_add "Piping" io_step_input_piping @@ -155,7 +155,7 @@ io_cleanup_step() { io_suite() { test_step_set_pre io_cleanup_step test_step_set_post io_cleanup_step - test_suite_add "Tethereal file I/O" tethereal_io_suite + test_suite_add "TShark file I/O" tshark_io_suite #test_suite_add "Ethereal file I/O" ethereal_io_suite #test_suite_add "Dumpcap file I/O" dumpcap_io_suite } diff --git a/test/test.sh b/test/test.sh index 368a84fe1f..d60408e46b 100644 --- a/test/test.sh +++ b/test/test.sh @@ -39,7 +39,7 @@ source suite-capture.sh test_step_prerequisites() { NOTFOUND=0 - for i in "$ETHEREAL" "$TETHEREAL" "$CAPINFOS" "$DUMPCAP" ; do + for i in "$ETHEREAL" "$TSHARK" "$CAPINFOS" "$DUMPCAP" ; do if [ ! -x $i ]; then echo "Couldn't find $i" NOTFOUND=1 @@ -71,8 +71,8 @@ test_suite() { test_set_output VERBOSE -#test_suite_run "Tethereal command line options" clopt_suite -#test_suite_run "Tethereal capture" capture_suite +#test_suite_run "TShark command line options" clopt_suite +#test_suite_run "TShark capture" capture_suite # all @@ -171,4 +171,4 @@ done ;; esac -done \ No newline at end of file +done diff --git a/tethereal.c b/tethereal.c deleted file mode 100644 index e4a274241d..0000000000 --- a/tethereal.c +++ /dev/null @@ -1,3067 +0,0 @@ -/* twireshark.c - * - * $Id$ - * - * Wireshark - Network traffic analyzer - * By Gerald Combs - * Copyright 1998 Gerald Combs - * - * Text-mode variant, by Gilbert Ramirez - * and Guy Harris . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include -#include -#include -#include -#include -#include - -#ifdef HAVE_UNISTD_H -#include -#endif - -#include - -#ifdef HAVE_FCNTL_H -#include -#endif - -#include - -#ifdef HAVE_SYS_STAT_H -# include -#endif - -#ifdef NEED_STRERROR_H -#include "strerror.h" -#endif - -#ifdef NEED_GETOPT_H -#include "getopt.h" -#endif - -#include -#include -#include -#include -#include - -#include "globals.h" -#include -#include -#include "file.h" -#include "disabled_protos.h" -#include -#include -#include "print.h" -#include -#include "util.h" -#include "clopts_common.h" -#include "cmdarg_err.h" -#include "version_info.h" -#include -#include -#include "register.h" -#include "conditions.h" -#include "capture_stop_conditions.h" -#include "ringbuffer.h" -#include "capture_ui_utils.h" -#include -#include -#include -#include -#include - -#ifdef HAVE_LIBPCAP -#include -#include -#include "capture-pcap-util.h" -#include "pcapio.h" -#include -#ifdef _WIN32 -#include "capture-wpcap.h" -#include "capture_errs.h" -#endif /* _WIN32 */ -#include "capture.h" -#include "capture_loop.h" -#include "capture_sync.h" -#endif /* HAVE_LIBPCAP */ -#include "epan/emem.h" -#include "log.h" -#include - -/* - * This is the template for the decode as option; it is shared between the - * various functions that output the usage for this parameter. - */ -static const gchar decode_as_arg_template[] = "==,"; - -static nstime_t first_ts; -static nstime_t prev_ts; -static GString *comp_info_str, *runtime_info_str; - -static gboolean print_packet_info; /* TRUE if we're to print packet information */ -/* - * The way the packet decode is to be written. - */ -typedef enum { - WRITE_TEXT, /* summary or detail text */ - WRITE_XML /* PDML or PSML */ - /* Add CSV and the like here */ -} output_action_e; -static output_action_e output_action; -static gboolean do_dissection; /* TRUE if we have to dissect each packet */ -static gboolean verbose; -static gboolean print_hex; -static gboolean line_buffered; -static guint32 cum_bytes = 0; -static print_format_e print_format = PR_FMT_TEXT; -static print_stream_t *print_stream; - -/* - * Standard secondary message for unexpected errors. - */ -static const char please_report[] = - "Please report this to the Wireshark developers"; - -#ifdef HAVE_LIBPCAP -/* - * TRUE if we're to print packet counts to keep track of captured packets. - */ -static gboolean print_packet_counts; - - -static loop_data ld; - -#ifdef HAVE_LIBPCAP -static capture_options capture_opts; - - -#ifdef SIGINFO -static gboolean infodelay; /* if TRUE, don't print capture info in SIGINFO handler */ -static gboolean infoprint; /* if TRUE, print capture info after clearing infodelay */ -#endif /* SIGINFO */ -#endif /* HAVE_LIBPCAP */ - - -static int capture(void); -static void capture_pcap_cb(u_char *, const struct pcap_pkthdr *, - const u_char *); -static void report_counts(void); -#ifdef _WIN32 -static BOOL WINAPI capture_cleanup(DWORD); -#else /* _WIN32 */ -static void capture_cleanup(int); -#ifdef SIGINFO -static void report_counts_siginfo(int); -#endif /* SIGINFO */ -#endif /* _WIN32 */ -#endif /* HAVE_LIBPCAP */ - -static int load_cap_file(capture_file *, char *, int); -static gboolean process_packet(capture_file *cf, long offset, - const struct wtap_pkthdr *whdr, union wtap_pseudo_header *pseudo_header, - const guchar *pd); -static void show_capture_file_io_error(const char *, int, gboolean); -static void show_print_file_io_error(int err); -static gboolean write_preamble(capture_file *cf); -static gboolean print_packet(capture_file *cf, epan_dissect_t *edt); -static gboolean write_finale(void); -static const char *cf_open_error_message(int err, gchar *err_info, - gboolean for_writing, int file_type); - -static void open_failure_message(const char *filename, int err, - gboolean for_writing); -static void failure_message(const char *msg_format, va_list ap); -static void read_failure_message(const char *filename, int err); - -capture_file cfile; - - -static void list_capture_types(void) { - int i; - - fprintf(stderr, "editcap: The available capture file types for \"F\":\n"); - for (i = 0; i < WTAP_NUM_FILE_TYPES; i++) { - if (wtap_dump_can_open(i)) - fprintf(stderr, " %s - %s\n", - wtap_file_type_short_string(i), wtap_file_type_string(i)); - } -} - -static void -print_usage(gboolean print_ver) -{ - FILE *output; - - if (print_ver) { - output = stdout; - fprintf(output, - "Twireshark " VERSION "%s\n" - "Dump and analyze network traffic.\n" - "See http://www.wireshark.com for more information.\n" - "\n" - "%s", - svnversion, get_copyright_info()); - } else { - output = stderr; - } - fprintf(output, "\n"); - fprintf(output, "Usage: twireshark [options] ...\n"); - fprintf(output, "\n"); - -#ifdef HAVE_LIBPCAP - fprintf(output, "Capture interface:\n"); - fprintf(output, " -i name or idx of interface (def: first none loopback)\n"); - fprintf(output, " -f packet filter in libpcap filter syntax\n"); - fprintf(output, " -s packet snapshot length (def: 65535)\n"); - fprintf(output, " -p don't capture in promiscuous mode\n"); -#ifdef _WIN32 - fprintf(output, " -B size of kernel buffer (def: 1MB)\n"); -#endif - fprintf(output, " -y link layer type (def: first appropriate)\n"); - fprintf(output, " -D print list of interfaces and exit\n"); - fprintf(output, " -L print list of link-layer types of iface and exit\n"); - fprintf(output, "\n"); - fprintf(output, "Capture stop conditions:\n"); - fprintf(output, " -c stop after n packets (def: infinite)\n"); - fprintf(output, " -a ... duration:NUM - stop after NUM seconds\n"); - fprintf(output, " filesize:NUM - stop this file after NUM KB\n"); - fprintf(output, " files:NUM - stop after NUM files\n"); - /*fprintf(output, "\n");*/ - fprintf(output, "Capture output:\n"); - fprintf(output, " -b ... duration:NUM - switch to next file after NUM secs\n"); - fprintf(output, " filesize:NUM - switch to next file after NUM KB\n"); - fprintf(output, " files:NUM - ringbuffer: replace after NUM files\n"); -#endif /* HAVE_LIBPCAP */ - - /*fprintf(output, "\n");*/ - fprintf(output, "Input file:\n"); - fprintf(output, " -r set the filename to read from (no pipes or stdin!)\n"); - - fprintf(output, "\n"); - fprintf(output, "Processing:\n"); - fprintf(output, " -R packet filter in Wireshark display filter syntax\n"); - fprintf(output, " -n disable all name resolutions (def: all enabled)\n"); - fprintf(output, " -N enable specific name resolution(s): \"mntC\"\n"); - fprintf(output, " -d %s ...\n", decode_as_arg_template); - fprintf(output, " \"Decode As\", see the man page for details\n"); - fprintf(output, " Example: tcp.port==8888,http\n"); - - /*fprintf(output, "\n");*/ - fprintf(output, "Output:\n"); - fprintf(stderr, " -w set the output filename (or '-' for stdout)\n"); - fprintf(stderr, " -F set the output file type, default is libpcap\n"); - fprintf(stderr, " an empty \"-F\" option will list the file types\n"); - fprintf(output, " -V add output of packet tree (Packet Details)\n"); - fprintf(output, " -x add output of hex and ASCII dump (Packet Bytes)\n"); - fprintf(output, " -T pdml|ps|psml|text output format of text output (def: text)\n"); - fprintf(output, " -t ad|a|r|d output format of time stamps (def: r: rel. to first)\n"); - fprintf(output, " -l flush output after each packet\n"); - fprintf(output, " -q be more quiet on stdout (e.g. when using statistics)\n"); - fprintf(output, " -X : eXtension options, see the man page for details\n"); - fprintf(output, " -z various statistics, see the man page for details\n"); - - fprintf(output, "\n"); - fprintf(stderr, "Miscellaneous:\n"); - fprintf(stderr, " -h display this help and exit\n"); - fprintf(stderr, " -v display version info and exit\n"); - fprintf(output, " -o : ... override preference setting\n"); -} - -/* - * For a dissector table, print on the stream described by output, - * its short name (which is what's used in the "-d" option) and its - * descriptive name. - */ -static void -display_dissector_table_names(char *table_name, const char *ui_name, - gpointer output) -{ - fprintf((FILE *)output, "\t%s (%s)\n", table_name, ui_name); -} - -/* - * For a dissector handle, print on the stream described by output, - * the filter name (which is what's used in the "-d" option) and the full - * name for the protocol that corresponds to this handle. - */ -static void -display_dissector_names(const gchar *table _U_, gpointer handle, gpointer output) -{ - int proto_id; - const gchar* proto_filter_name; - const gchar* proto_ui_name; - - proto_id = dissector_handle_get_protocol_index((dissector_handle_t)handle); - - if (proto_id != -1) { - proto_filter_name = proto_get_protocol_filter_name(proto_id); - proto_ui_name = proto_get_protocol_name(proto_id); - g_assert(proto_filter_name != NULL); - g_assert(proto_ui_name != NULL); - - fprintf((FILE *)output, "\t%s (%s)\n", - proto_filter_name, - proto_ui_name); - } -} - -/* - * The protocol_name_search structure is used by find_protocol_name_func() - * to pass parameters and store results - */ -struct protocol_name_search{ - gchar *searched_name; /* Protocol filter name we are looking for */ - dissector_handle_t matched_handle; /* Handle for a dissector whose protocol has the specified filter name */ - guint nb_match; /* How many dissectors matched searched_name */ -}; -typedef struct protocol_name_search *protocol_name_search_t; - -/* - * This function parses all dissectors associated with a table to find the - * one whose protocol has the specified filter name. It is called - * as a reference function in a call to dissector_table_foreach_handle. - * The name we are looking for, as well as the results, are stored in the - * protocol_name_search struct pointed to by user_data. - * If called using dissector_table_foreach_handle, we actually parse the - * whole list of dissectors. - */ -static void -find_protocol_name_func(const gchar *table _U_, gpointer handle, gpointer user_data) - -{ - int proto_id; - const gchar *protocol_filter_name; - protocol_name_search_t search_info; - - g_assert(handle); - - search_info = (protocol_name_search_t)user_data; - - proto_id = dissector_handle_get_protocol_index((dissector_handle_t)handle); - if (proto_id != -1) { - protocol_filter_name = proto_get_protocol_filter_name(proto_id); - g_assert(protocol_filter_name != NULL); - if (strcmp(protocol_filter_name, search_info->searched_name) == 0) { - /* Found a match */ - if (search_info->nb_match == 0) { - /* Record this handle only if this is the first match */ - search_info->matched_handle = (dissector_handle_t)handle; /* Record the handle for this matching dissector */ - } - search_info->nb_match++; - } - } -} - -/* - * Print all layer type names supported. - * We send the output to the stream described by the handle output. - */ - -static void -fprint_all_layer_types(FILE *output) - -{ - dissector_all_tables_foreach_table(display_dissector_table_names, (gpointer)output); -} - -/* - * Print all protocol names supported for a specific layer type. - * table_name contains the layer type name in which the search is performed. - * We send the output to the stream described by the handle output. - */ - -static void -fprint_all_protocols_for_layer_types(FILE *output, gchar *table_name) - -{ - dissector_table_foreach_handle(table_name, - display_dissector_names, - (gpointer)output); -} - -/* - * The function below parses the command-line parameters for the decode as - * feature (a string pointer by cl_param). - * It checks the format of the command-line, searches for a matching table - * and dissector. If a table/dissector match is not found, we display a - * summary of the available tables/dissectors (on stderr) and return FALSE. - * If everything is fine, we get the "Decode as" preference activated, - * then we return TRUE. - */ -static gboolean -add_decode_as(const gchar *cl_param) -{ - gchar *table_name; - guint32 selector; - gchar *decoded_param; - gchar *remaining_param; - gchar *selector_str; - gchar *dissector_str; - dissector_handle_t dissector_matching; - dissector_table_t table_matching; - ftenum_t dissector_table_selector_type; - struct protocol_name_search user_protocol_name; - -/* The following code will allocate and copy the command-line options in a string pointed by decoded_param */ - - g_assert(cl_param); - decoded_param = g_malloc( sizeof(gchar) * (strlen(cl_param) + 1) ); /* Allocate enough space to have a working copy of the command-line parameter */ - g_assert(decoded_param); - strcpy(decoded_param, cl_param); - - - /* The lines below will parse this string (modifying it) to extract all - necessary information. Note that decoded_param is still needed since - strings are not copied - we just save pointers. */ - - /* This section extracts a layer type (table_name) from decoded_param */ - table_name = decoded_param; /* Layer type string starts from beginning */ - - remaining_param = strchr(table_name, '='); - if (remaining_param == NULL) { - cmdarg_err("Parameter \"%s\" doesn't follow the template \"%s\"", cl_param, decode_as_arg_template); - /* If the argument does not follow the template, carry on anyway to check - if the table name is at least correct. If remaining_param is NULL, - we'll exit anyway further down */ - } - else { - *remaining_param = '\0'; /* Terminate the layer type string (table_name) where '=' was detected */ - } - - /* Remove leading and trailing spaces from the table name */ - while ( table_name[0] == ' ' ) - table_name++; - while ( table_name[strlen(table_name) - 1] == ' ' ) - table_name[strlen(table_name) - 1] = '\0'; /* Note: if empty string, while loop will eventually exit */ - -/* The following part searches a table matching with the layer type specified */ - table_matching = NULL; - -/* Look for the requested table */ - if ( !(*(table_name)) ) { /* Is the table name empty, if so, don't even search for anything, display a message */ - cmdarg_err("No layer type specified"); /* Note, we don't exit here, but table_matching will remain NULL, so we exit below */ - } - else { - table_matching = find_dissector_table(table_name); - if (!table_matching) { - cmdarg_err("Unknown layer type -- %s", table_name); /* Note, we don't exit here, but table_matching will remain NULL, so we exit below */ - } - } - - if (!table_matching) { - /* Display a list of supported layer types to help the user, if the - specified layer type was not found */ - cmdarg_err("Valid layer types are:"); - fprint_all_layer_types(stderr); - } - if (remaining_param == NULL || !table_matching) { - /* Exit if the layer type was not found, or if no '=' separator was found - (see above) */ - g_free(decoded_param); - return FALSE; - } - - if (*(remaining_param + 1) != '=') { /* Check for "==" and not only '=' */ - cmdarg_err("WARNING: -d requires \"==\" instead of \"=\". Option will be treated as \"%s==%s\"", table_name, remaining_param + 1); - } - else { - remaining_param++; /* Move to the second '=' */ - *remaining_param = '\0'; /* Remove the second '=' */ - } - remaining_param++; /* Position after the layer type string */ - - /* This section extracts a selector value (selector_str) from decoded_param */ - - selector_str = remaining_param; /* Next part starts with the selector number */ - - remaining_param = strchr(selector_str, ','); - if (remaining_param == NULL) { - cmdarg_err("Parameter \"%s\" doesn't follow the template \"%s\"", cl_param, decode_as_arg_template); - /* If the argument does not follow the template, carry on anyway to check - if the selector value is at least correct. If remaining_param is NULL, - we'll exit anyway further down */ - } - else { - *remaining_param = '\0'; /* Terminate the selector number string (selector_str) where ',' was detected */ - } - - dissector_table_selector_type = get_dissector_table_selector_type(table_name); - - switch (dissector_table_selector_type) { - - case FT_UINT8: - case FT_UINT16: - case FT_UINT24: - case FT_UINT32: - /* The selector for this table is an unsigned number. Parse it as such. - There's no need to remove leading and trailing spaces from the - selector number string, because sscanf will do that for us. */ - if ( sscanf(selector_str, "%u", &selector) != 1 ) { - cmdarg_err("Invalid selector number \"%s\"", selector_str); - g_free(decoded_param); - return FALSE; - } - break; - - case FT_STRING: - case FT_STRINGZ: - /* The selector for this table is a string. */ - break; - - default: - /* There are currently no dissector tables with any types other - than the ones listed above. */ - g_assert_not_reached(); - } - - if (remaining_param == NULL) { - /* Exit if no ',' separator was found (see above) */ - cmdarg_err("Valid protocols for layer type \"%s\" are:", table_name); - fprint_all_protocols_for_layer_types(stderr, table_name); - g_free(decoded_param); - return FALSE; - } - - remaining_param++; /* Position after the selector number string */ - - /* This section extracts a protocol filter name (dissector_str) from decoded_param */ - - dissector_str = remaining_param; /* All the rest of the string is the dissector (decode as protocol) name */ - - /* Remove leading and trailing spaces from the dissector name */ - while ( dissector_str[0] == ' ' ) - dissector_str++; - while ( dissector_str[strlen(dissector_str) - 1] == ' ' ) - dissector_str[strlen(dissector_str) - 1] = '\0'; /* Note: if empty string, while loop will eventually exit */ - - dissector_matching = NULL; - - /* We now have a pointer to the handle for the requested table inside the variable table_matching */ - if ( ! (*dissector_str) ) { /* Is the dissector name empty, if so, don't even search for a matching dissector and display all dissectors found for the selected table */ - cmdarg_err("No protocol name specified"); /* Note, we don't exit here, but dissector_matching will remain NULL, so we exit below */ - } - else { - user_protocol_name.nb_match = 0; - user_protocol_name.searched_name = dissector_str; - user_protocol_name.matched_handle = NULL; - - dissector_table_foreach_handle(table_name, find_protocol_name_func, &user_protocol_name); /* Go and perform the search for this dissector in the this table's dissectors' names and shortnames */ - - if (user_protocol_name.nb_match != 0) { - dissector_matching = user_protocol_name.matched_handle; - if (user_protocol_name.nb_match > 1) { - cmdarg_err("WARNING: Protocol \"%s\" matched %u dissectors, first one will be used", dissector_str, user_protocol_name.nb_match); - } - } - else { - /* OK, check whether the problem is that there isn't any such - protocol, or that there is but it's not specified as a protocol - that's valid for that dissector table. - Note, we don't exit here, but dissector_matching will remain NULL, - so we exit below */ - if (proto_get_id_by_filter_name(dissector_str) == -1) { - /* No such protocol */ - cmdarg_err("Unknown protocol -- \"%s\"", dissector_str); - } else { - cmdarg_err("Protocol \"%s\" isn't valid for layer type \"%s\"", - dissector_str, table_name); - } - } - } - - if (!dissector_matching) { - cmdarg_err("Valid protocols for layer type \"%s\" are:", table_name); - fprint_all_protocols_for_layer_types(stderr, table_name); - g_free(decoded_param); - return FALSE; - } - -/* This is the end of the code that parses the command-line options. - All information is now stored in the variables: - table_name - selector - dissector_matching - The above variables that are strings are still pointing to areas within - decoded_parm. decoded_parm thus still needs to be kept allocated in - until we stop needing these variables - decoded_param will be deallocated at each exit point of this function */ - - - /* We now have a pointer to the handle for the requested dissector - (requested protocol) inside the variable dissector_matching */ - switch (dissector_table_selector_type) { - - case FT_UINT8: - case FT_UINT16: - case FT_UINT24: - case FT_UINT32: - /* The selector for this table is an unsigned number. */ - dissector_change(table_name, selector, dissector_matching); - break; - - case FT_STRING: - case FT_STRINGZ: - /* The selector for this table is a string. */ - dissector_change_string(table_name, selector_str, dissector_matching); - break; - - default: - /* There are currently no dissector tables with any types other - than the ones listed above. */ - g_assert_not_reached(); - } - g_free(decoded_param); /* "Decode As" rule has been succesfully added */ - return TRUE; -} - -static void -log_func_ignore (const gchar *log_domain _U_, GLogLevelFlags log_level _U_, - const gchar *message _U_, gpointer user_data _U_) -{ -} - -static char * -output_file_description(const char *fname) -{ - char *save_file_string; - - /* Get a string that describes what we're writing to */ - if (strcmp(fname, "-") == 0) { - /* We're writing to the standard output */ - save_file_string = g_strdup("standard output"); - } else { - /* We're writing to a file with the name in save_file */ - save_file_string = g_strdup_printf("file \"%s\"", fname); - } - return save_file_string; -} - -int -main(int argc, char *argv[]) -{ - int opt, i; - extern char *optarg; - gboolean arg_error = FALSE; - -#ifdef _WIN32 - WSADATA wsaData; -#endif /* _WIN32 */ - - char *gpf_path, *pf_path; - char *gdp_path, *dp_path; - int gpf_open_errno, gpf_read_errno; - int pf_open_errno, pf_read_errno; - int gdp_open_errno, gdp_read_errno; - int dp_open_errno, dp_read_errno; - int err; -#ifdef HAVE_LIBPCAP - gboolean capture_filter_specified = FALSE; - gboolean list_link_layer_types = FALSE; - gboolean start_capture = FALSE; -#else - gboolean capture_option_specified = FALSE; -#endif - gboolean quiet = FALSE; - int out_file_type = WTAP_FILE_PCAP; - gchar *cf_name = NULL, *rfilter = NULL; -#ifdef HAVE_PCAP_OPEN_DEAD - struct bpf_program fcode; -#endif - dfilter_t *rfcode = NULL; - e_prefs *prefs; - char badopt; - GLogLevelFlags log_flags; - int status; - -#define OPTSTRING_INIT "a:b:c:d:Df:F:hi:lLnN:o:pqr:R:s:St:T:vVw:xX:y:z:" -#ifdef HAVE_LIBPCAP -#ifdef _WIN32 -#define OPTSTRING_WIN32 "B:" -#else -#define OPTSTRING_WIN32 "" -#endif /* _WIN32 */ -#else -#define OPTSTRING_WIN32 "" -#endif /* HAVE_LIBPCAP */ - - static const char optstring[] = OPTSTRING_INIT OPTSTRING_WIN32; - - /* - * Get credential information for later use. - */ - get_credential_info(); - - /* nothing more than the standard GLib handler, but without a warning */ - log_flags = - G_LOG_LEVEL_ERROR| - G_LOG_LEVEL_CRITICAL| - G_LOG_LEVEL_WARNING| - G_LOG_LEVEL_MESSAGE| - G_LOG_LEVEL_INFO| - G_LOG_LEVEL_DEBUG| - G_LOG_FLAG_FATAL|G_LOG_FLAG_RECURSION; - - g_log_set_handler(NULL, - log_flags, - log_func_ignore, NULL /* user_data */); - g_log_set_handler(LOG_DOMAIN_CAPTURE_CHILD, - log_flags, - log_func_ignore, NULL /* user_data */); - - /* initialize memory allocation subsystem */ - ep_init_chunk(); - se_init_chunk(); - - initialize_funnel_ops(); - -#ifdef HAVE_LIBPCAP - capture_opts_init(&capture_opts, NULL /* cfile */); -#endif - - timestamp_set_type(TS_RELATIVE); - timestamp_set_precision(TS_PREC_AUTO); - - /* Register all dissectors; we must do this before checking for the - "-G" flag, as the "-G" flag dumps information registered by the - dissectors, and we must do it before we read the preferences, in - case any dissectors register preferences. */ - epan_init(PLUGIN_DIR,register_all_protocols,register_all_protocol_handoffs, - failure_message,open_failure_message,read_failure_message); - - /* Register all tap listeners; we do this before we parse the arguments, - as the "-z" argument can specify a registered tap. */ - - /* we register the plugin taps before the other taps because - stats_tree taps plugins will be registered as tap listeners - by stats_tree_stat.c and need to registered before that */ -#ifdef HAVE_PLUGINS - register_all_plugin_tap_listeners(); -#endif - register_all_tap_listeners(); - - /* Now register the preferences for any non-dissector modules. - We must do that before we read the preferences as well. */ - prefs_register_modules(); - - /* If invoked with the "-G" flag, we dump out information based on - the argument to the "-G" flag; if no argument is specified, - for backwards compatibility we dump out a glossary of display - filter symbols. - - XXX - we do this here, for now, to support "-G" with no arguments. - If none of our build or other processes uses "-G" with no arguments, - we can just process it with the other arguments. */ - if (argc >= 2 && strcmp(argv[1], "-G") == 0) { - if (argc == 2) - proto_registrar_dump_fields(1); - else { - if (strcmp(argv[2], "fields") == 0) - proto_registrar_dump_fields(1); - else if (strcmp(argv[2], "fields2") == 0) - proto_registrar_dump_fields(2); - else if (strcmp(argv[2], "fields3") == 0) - proto_registrar_dump_fields(3); - else if (strcmp(argv[2], "protocols") == 0) - proto_registrar_dump_protocols(); - else if (strcmp(argv[2], "values") == 0) - proto_registrar_dump_values(); - else if (strcmp(argv[2], "decodes") == 0) - dissector_dump_decodes(); - else if (strcmp(argv[2], "defaultprefs") == 0) - write_prefs(NULL); - else if (strcmp(argv[2], "currentprefs") == 0) { - read_prefs(&gpf_open_errno, &gpf_read_errno, &gpf_path, - &pf_open_errno, &pf_read_errno, &pf_path); - write_prefs(NULL); - } else { - cmdarg_err("Invalid \"%s\" option for -G flag", argv[2]); - exit(1); - } - } - exit(0); - } - - /* Set the C-language locale to the native environment. */ - setlocale(LC_ALL, ""); - - prefs = read_prefs(&gpf_open_errno, &gpf_read_errno, &gpf_path, - &pf_open_errno, &pf_read_errno, &pf_path); - if (gpf_path != NULL) { - if (gpf_open_errno != 0) { - cmdarg_err("Can't open global preferences file \"%s\": %s.", - pf_path, strerror(gpf_open_errno)); - } - if (gpf_read_errno != 0) { - cmdarg_err("I/O error reading global preferences file \"%s\": %s.", - pf_path, strerror(gpf_read_errno)); - } - } - if (pf_path != NULL) { - if (pf_open_errno != 0) { - cmdarg_err("Can't open your preferences file \"%s\": %s.", pf_path, - strerror(pf_open_errno)); - } - if (pf_read_errno != 0) { - cmdarg_err("I/O error reading your preferences file \"%s\": %s.", - pf_path, strerror(pf_read_errno)); - } - g_free(pf_path); - pf_path = NULL; - } - - /* Set the name resolution code's flags from the preferences. */ - g_resolv_flags = prefs->name_resolve; - - /* Read the disabled protocols file. */ - read_disabled_protos_list(&gdp_path, &gdp_open_errno, &gdp_read_errno, - &dp_path, &dp_open_errno, &dp_read_errno); - if (gdp_path != NULL) { - if (gdp_open_errno != 0) { - cmdarg_err("Could not open global disabled protocols file\n\"%s\": %s.", - gdp_path, strerror(gdp_open_errno)); - } - if (gdp_read_errno != 0) { - cmdarg_err("I/O error reading global disabled protocols file\n\"%s\": %s.", - gdp_path, strerror(gdp_read_errno)); - } - g_free(gdp_path); - } - if (dp_path != NULL) { - if (dp_open_errno != 0) { - cmdarg_err( - "Could not open your disabled protocols file\n\"%s\": %s.", dp_path, - strerror(dp_open_errno)); - } - if (dp_read_errno != 0) { - cmdarg_err( - "I/O error reading your disabled protocols file\n\"%s\": %s.", dp_path, - strerror(dp_read_errno)); - } - g_free(dp_path); - } - -#ifdef _WIN32 - /* Load Wpcap, if possible */ - load_wpcap(); -#endif - - init_cap_file(&cfile); - - /* Assemble the compile-time version information string */ - comp_info_str = g_string_new("Compiled "); - get_compiled_version_info(comp_info_str); - - /* Assemble the run-time version information string */ - runtime_info_str = g_string_new("Running "); - get_runtime_version_info(runtime_info_str); - - /* Print format defaults to this. */ - print_format = PR_FMT_TEXT; - - /* Now get our args */ - while ((opt = getopt(argc, argv, optstring)) != -1) { - switch (opt) { - case 'a': /* autostop criteria */ - case 'b': /* Ringbuffer option */ - case 'c': /* Capture xxx packets */ - case 'f': /* capture filter */ - case 'i': /* Use interface xxx */ - case 'p': /* Don't capture in promiscuous mode */ - case 's': /* Set the snapshot (capture) length */ - case 'w': /* Write to capture file xxx */ - case 'y': /* Set the pcap data link type */ -#ifdef _WIN32 - case 'B': /* Buffer size */ -#endif /* _WIN32 */ -#ifdef HAVE_LIBPCAP - status = capture_opts_add_opt(&capture_opts, opt, optarg, &start_capture); - if(status != 0) { - exit(status); - } -#else - capture_option_specified = TRUE; - arg_error = TRUE; -#endif - break; - case 'd': /* Decode as rule */ - if (!add_decode_as(optarg)) - exit(1); - break; - case 'D': /* Print a list of capture devices and exit */ -#ifdef HAVE_LIBPCAP - status = capture_opts_list_interfaces(); - exit(status); -#else - capture_option_specified = TRUE; - arg_error = TRUE; -#endif - break; - case 'F': - out_file_type = wtap_short_string_to_file_type(optarg); - if (out_file_type < 0) { - cmdarg_err("\"%s\" isn't a valid capture file type", optarg); - list_capture_types(); - exit(1); - } - break; - case 'h': /* Print help and exit */ - print_usage(TRUE); - exit(0); - break; - case 'l': /* "Line-buffer" standard output */ - /* This isn't line-buffering, strictly speaking, it's just - flushing the standard output after the information for - each packet is printed; however, that should be good - enough for all the purposes to which "-l" is put (and - is probably actually better for "-V", as it does fewer - writes). - - See the comment in "process_packet()" for an explanation of - why we do that, and why we don't just use "setvbuf()" to - make the standard output line-buffered (short version: in - Windows, "line-buffered" is the same as "fully-buffered", - and the output buffer is only flushed when it fills up). */ - line_buffered = TRUE; - break; - case 'L': /* Print list of link-layer types and exit */ -#ifdef HAVE_LIBPCAP - list_link_layer_types = TRUE; - break; -#else - capture_option_specified = TRUE; - arg_error = TRUE; -#endif - break; - case 'n': /* No name resolution */ - g_resolv_flags = RESOLV_NONE; - break; - case 'N': /* Select what types of addresses/port #s to resolve */ - if (g_resolv_flags == RESOLV_ALL) - g_resolv_flags = RESOLV_NONE; - badopt = string_to_name_resolve(optarg, &g_resolv_flags); - if (badopt != '\0') { - cmdarg_err("-N specifies unknown resolving option '%c'; valid options are 'm', 'n', and 't'", - badopt); - exit(1); - } - break; - case 'o': /* Override preference from command line */ - switch (prefs_set_pref(optarg)) { - - case PREFS_SET_SYNTAX_ERR: - cmdarg_err("Invalid -o flag \"%s\"", optarg); - exit(1); - break; - - case PREFS_SET_NO_SUCH_PREF: - case PREFS_SET_OBSOLETE: - cmdarg_err("-o flag \"%s\" specifies unknown preference", optarg); - exit(1); - break; - } - break; - case 'q': /* Quiet */ - quiet = TRUE; - break; - case 'r': /* Read capture file xxx */ - cf_name = g_strdup(optarg); - break; - case 'R': /* Read file filter */ - rfilter = optarg; - break; - case 'S': /* show packets in real time */ - print_packet_info = TRUE; - break; - case 't': /* Time stamp type */ - if (strcmp(optarg, "r") == 0) - timestamp_set_type(TS_RELATIVE); - else if (strcmp(optarg, "a") == 0) - timestamp_set_type(TS_ABSOLUTE); - else if (strcmp(optarg, "ad") == 0) - timestamp_set_type(TS_ABSOLUTE_WITH_DATE); - else if (strcmp(optarg, "d") == 0) - timestamp_set_type(TS_DELTA); - else { - cmdarg_err("Invalid time stamp type \"%s\"", - optarg); - cmdarg_err_cont("It must be \"r\" for relative, \"a\" for absolute,"); - cmdarg_err_cont("\"ad\" for absolute with date, or \"d\" for delta."); - exit(1); - } - break; - case 'T': /* printing Type */ - if (strcmp(optarg, "text") == 0) { - output_action = WRITE_TEXT; - print_format = PR_FMT_TEXT; - } else if (strcmp(optarg, "ps") == 0) { - output_action = WRITE_TEXT; - print_format = PR_FMT_PS; - } else if (strcmp(optarg, "pdml") == 0) { - output_action = WRITE_XML; - verbose = TRUE; - } else if (strcmp(optarg, "psml") == 0) { - output_action = WRITE_XML; - verbose = FALSE; - } else { - cmdarg_err("Invalid -T parameter."); - cmdarg_err_cont("It must be \"ps\", \"text\", \"pdml\", or \"psml\"."); - exit(1); - } - break; - case 'v': /* Show version and exit */ - printf("Twireshark " VERSION "%s\n" - "\n" - "%s" - "\n" - "%s" - "\n" - "%s", - svnversion, get_copyright_info(), comp_info_str->str, - runtime_info_str->str); - exit(0); - break; - case 'V': /* Verbose */ - verbose = TRUE; - break; - case 'x': /* Print packet data in hex (and ASCII) */ - print_hex = TRUE; - break; - case 'X': - ex_opt_add(optarg); - break; - case 'z': - /* We won't call the init function for the stat this soon - as it would disallow MATE's fields (which are registered - by the preferences set callback) from being used as - part of a tap filter. Instead, we just add the argument - to a list of stat arguments. */ - if (!process_stat_cmd_arg(optarg)) { - cmdarg_err("invalid -z argument."); - cmdarg_err_cont(" -z argument must be one of :"); - list_stat_cmd_args(); - exit(1); - } - break; - default: - case '?': /* Bad flag - print usage message */ - switch(optopt) { - case'F': - list_capture_types(); - break; - default: - print_usage(TRUE); - } - exit(1); - break; - } - } - - /* If no capture filter or read filter has been specified, and there are - still command-line arguments, treat them as the tokens of a capture - filter (if no "-r" flag was specified) or a read filter (if a "-r" - flag was specified. */ - if (optind < argc) { - if (cf_name != NULL) { - if (rfilter != NULL) { - cmdarg_err("Read filters were specified both with \"-R\" " - "and with additional command-line arguments"); - exit(1); - } - rfilter = get_args_as_string(argc, argv, optind); - } else { -#ifdef HAVE_LIBPCAP - if (capture_filter_specified) { - cmdarg_err("Capture filters were specified both with \"-f\"" - " and with additional command-line arguments"); - exit(1); - } - capture_opts.cfilter = get_args_as_string(argc, argv, optind); -#else - capture_option_specified = TRUE; -#endif - } - } - - if (!capture_opts.saving_to_file) { - /* We're not saving the capture to a file; if "-q" wasn't specified, - we should print packet information */ - if (!quiet) - print_packet_info = TRUE; - } else { - /* We're saving to a file; if we're writing to the standard output. - and we'll also be writing dissected packets to the standard - output, reject the request. At best, we could redirect that - to the standard error; we *can't* write both to the standard - output and have either of them be useful. */ - if (strcmp(capture_opts.save_file, "-") == 0 && print_packet_info) { - cmdarg_err("You can't write both raw packet data and dissected packets" - " to the standard output."); - exit(1); - } - } - -#ifndef HAVE_LIBPCAP - if (capture_option_specified) - cmdarg_err("This version of Twireshark was not built with support for capturing packets."); -#endif - if (arg_error) { - print_usage(FALSE); - exit(1); - } - - /* We don't support capture filters when reading from a capture file - (the BPF compiler doesn't support all link-layer types that we - support in capture files we read). */ -#ifdef HAVE_LIBPCAP - if (cf_name != NULL) { - if (capture_filter_specified) { - cmdarg_err("Only read filters, not capture filters, " - "can be specified when reading a capture file."); - exit(1); - } - } -#endif - - if (print_hex) { - if (output_action != WRITE_TEXT) { - cmdarg_err("Raw packet hex data can only be printed as text or PostScript"); - exit(1); - } - } - -#ifdef HAVE_LIBPCAP - if (list_link_layer_types) { - /* We're supposed to list the link-layer types for an interface; - did the user also specify a capture file to be read? */ - if (cf_name) { - /* Yes - that's bogus. */ - cmdarg_err("You can't specify -L and a capture file to be read."); - exit(1); - } - /* No - did they specify a ring buffer option? */ - if (capture_opts.multi_files_on) { - cmdarg_err("Ring buffer requested, but a capture isn't being done."); - exit(1); - } - } else { - /* If they didn't specify a "-w" flag, but specified a maximum capture - file size, tell them that this doesn't work, and exit. */ - if (capture_opts.has_autostop_filesize && capture_opts.save_file == NULL) { - cmdarg_err("Maximum capture file size specified, but " - "capture isn't being saved to a file."); - exit(1); - } - - if (cf_name) { - /* - * "-r" was specified, so we're reading a capture file. - * Capture options don't apply here. - */ - if (capture_opts.multi_files_on) { - cmdarg_err("Multiple capture files requested, but " - "a capture isn't being done."); - exit(1); - } - if (capture_opts.has_file_duration) { - cmdarg_err("Switching capture files after a time interval was specified, but " - "a capture isn't being done."); - exit(1); - } - if (capture_opts.has_ring_num_files) { - cmdarg_err("A ring buffer of capture files was specified, but " - "a capture isn't being done."); - exit(1); - } - if (capture_opts.has_autostop_files) { - cmdarg_err("A maximum number of capture files was specified, but " - "a capture isn't being done."); - exit(1); - } - if (capture_opts.has_autostop_packets) { - cmdarg_err("A maximum number of captured packets was specified, but " - "a capture isn't being done."); - exit(1); - } - if (capture_opts.has_autostop_filesize) { - cmdarg_err("A maximum capture file size was specified, but " - "a capture isn't being done."); - exit(1); - } - if (capture_opts.has_autostop_duration) { - cmdarg_err("A maximum capture time was specified, but " - "a capture isn't being done."); - exit(1); - } - } else { - /* - * "-r" wasn't specified, so we're doing a live capture. - */ - if (capture_opts.saving_to_file) { - /* They specified a "-w" flag, so we'll be saving to a capture file. */ - - /* When capturing, we only support writing libpcap format. */ - if (out_file_type != WTAP_FILE_PCAP) { - cmdarg_err("Live captures can only be saved in libpcap format."); - exit(1); - } - if (capture_opts.multi_files_on) { - /* Multiple-file mode works only under certain conditions: - a) it doesn't work if you're writing to the standard output; - b) it doesn't work if you're writing to a pipe; - c) it makes no sense if the maximum file size is set to "infinite" - (XXX - shouldn't that be "if there is no stop criterion", - as you might want to switch files based on a packet count - or a time). */ - if (strcmp(capture_opts.save_file, "-") == 0) { - cmdarg_err("Multiple capture files requested, but " - "the capture is being written to the standard output."); - exit(1); - } - if (capture_opts.output_to_pipe) { - cmdarg_err("Multiple capture files requested, but " - "the capture file is a pipe."); - exit(1); - } - if (!capture_opts.has_autostop_filesize) { - cmdarg_err("Multiple capture files requested, but " - "no maximum capture file size was specified."); - exit(1); - } - } - } else { - /* They didn't specify a "-w" flag, so we won't be saving to a - capture file. Check for options that only make sense if - we're saving to a file. */ - if (capture_opts.has_autostop_filesize) { - cmdarg_err("Maximum capture file size specified, but " - "capture isn't being saved to a file."); - exit(1); - } - if (capture_opts.multi_files_on) { - cmdarg_err("Multiple capture files requested, but " - "the capture isn't being saved to a file."); - exit(1); - } - } - } - } -#endif - -#ifdef _WIN32 - /* Start windows sockets */ - WSAStartup( MAKEWORD( 1, 1 ), &wsaData ); -#endif /* _WIN32 */ - - /* Notify all registered modules that have had any of their preferences - changed either from one of the preferences file or from the command - line that their preferences have changed. */ - prefs_apply_all(); - - /* At this point MATE will have registered its field array so we can - have a tap filter with one of MATE's late-registered fields as part - of the filter. We can now process all the "-z" arguments. */ - start_requested_stats(); - - /* disabled protocols as per configuration file */ - if (gdp_path == NULL && dp_path == NULL) { - set_disabled_protos_list(); - } - - /* Build the column format array */ - col_setup(&cfile.cinfo, prefs->num_cols); - for (i = 0; i < cfile.cinfo.num_cols; i++) { - cfile.cinfo.col_fmt[i] = get_column_format(i); - cfile.cinfo.col_title[i] = g_strdup(get_column_title(i)); - cfile.cinfo.fmt_matx[i] = (gboolean *) g_malloc0(sizeof(gboolean) * - NUM_COL_FMTS); - get_column_format_matches(cfile.cinfo.fmt_matx[i], cfile.cinfo.col_fmt[i]); - cfile.cinfo.col_data[i] = NULL; - if (cfile.cinfo.col_fmt[i] == COL_INFO) - cfile.cinfo.col_buf[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_INFO_LEN); - else - cfile.cinfo.col_buf[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN); - cfile.cinfo.col_fence[i] = 0; - cfile.cinfo.col_expr[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN); - cfile.cinfo.col_expr_val[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN); - } - - for (i = 0; i < cfile.cinfo.num_cols; i++) { - int j; - - for (j = 0; j < NUM_COL_FMTS; j++) { - if (!cfile.cinfo.fmt_matx[i][j]) - continue; - - if (cfile.cinfo.col_first[j] == -1) - cfile.cinfo.col_first[j] = i; - cfile.cinfo.col_last[j] = i; - } - } - -#ifdef HAVE_LIBPCAP - capture_opts_trim_snaplen(&capture_opts, MIN_PACKET_SIZE); - capture_opts_trim_ring_num_files(&capture_opts); -#endif - - if (rfilter != NULL) { - if (!dfilter_compile(rfilter, &rfcode)) { - cmdarg_err("%s", dfilter_error_msg); - epan_cleanup(); -#ifdef HAVE_PCAP_OPEN_DEAD - { - pcap_t *pc; - - pc = pcap_open_dead(DLT_EN10MB, MIN_PACKET_SIZE); - if (pc != NULL) { - if (pcap_compile(pc, &fcode, rfilter, 0, 0) != -1) { - cmdarg_err_cont( - " Note: That display filter code looks like a valid capture filter;"); - cmdarg_err_cont( - " maybe you mixed them up?"); - } - pcap_close(pc); - } - } -#endif - exit(2); - } - } - cfile.rfcode = rfcode; - - if (print_packet_info) { - /* If we're printing as text or PostScript, we have - to create a print stream. */ - if (output_action == WRITE_TEXT) { - switch (print_format) { - - case PR_FMT_TEXT: - print_stream = print_stream_text_stdio_new(stdout); - break; - - case PR_FMT_PS: - print_stream = print_stream_ps_stdio_new(stdout); - break; - - default: - g_assert_not_reached(); - } - } - } - - /* We have to dissect each packet if: - - we're printing information about each packet; - - we're using a read filter on the packets; - - we're using any taps. */ - do_dissection = print_packet_info || rfcode || have_tap_listeners(); - - if (cf_name) { - /* - * We're reading a capture file. - */ - - /* - * Immediately relinquish any special privileges we have; we must not - * be allowed to read any capture files the user running Twireshark - * can't open. - */ - relinquish_special_privs_perm(); - - if (cf_open(&cfile, cf_name, FALSE, &err) != CF_OK) { - epan_cleanup(); - exit(2); - } - - /* Set timestamp precision; there should arguably be a command-line - option to let the user set this. */ - switch(wtap_file_tsprecision(cfile.wth)) { - case(WTAP_FILE_TSPREC_SEC): - timestamp_set_precision(TS_PREC_AUTO_SEC); - break; - case(WTAP_FILE_TSPREC_DSEC): - timestamp_set_precision(TS_PREC_AUTO_DSEC); - break; - case(WTAP_FILE_TSPREC_CSEC): - timestamp_set_precision(TS_PREC_AUTO_CSEC); - break; - case(WTAP_FILE_TSPREC_MSEC): - timestamp_set_precision(TS_PREC_AUTO_MSEC); - break; - case(WTAP_FILE_TSPREC_USEC): - timestamp_set_precision(TS_PREC_AUTO_USEC); - break; - case(WTAP_FILE_TSPREC_NSEC): - timestamp_set_precision(TS_PREC_AUTO_NSEC); - break; - default: - g_assert_not_reached(); - } - - /* Process the packets in the file */ - err = load_cap_file(&cfile, capture_opts.save_file, out_file_type); - if (err != 0) { - epan_cleanup(); - exit(2); - } - cf_name[0] = '\0'; - } else { - /* No capture file specified, so we're supposed to do a live capture - (or get a list of link-layer types for a live capture device); - do we have support for live captures? */ -#ifdef HAVE_LIBPCAP - -#ifdef _WIN32 - if (!has_wpcap) { - char *detailed_err; - - cmdarg_err("WinPcap couldn't be found."); - detailed_err = cant_load_winpcap_err("Twireshark"); - cmdarg_err_cont("%s", detailed_err); - g_free(detailed_err); - exit(2); - } -#endif - - /* trim the interface name and exit if that failed */ - if (!capture_opts_trim_iface(&capture_opts, - (prefs->capture_device) ? get_if_name(prefs->capture_device) : NULL)) { - exit(2); - } - - /* if requested, list the link layer types and exit */ - if (list_link_layer_types) { - status = capture_opts_list_link_layer_types(&capture_opts); - exit(status); - } - - if (!print_packet_info && !quiet) { - /* - * We're not printing information for each packet, and the user - * didn't ask us not to print a count of packets as they arrive, - * so print that count so the user knows that packets are arriving. - * - * XXX - what if the user wants to do a live capture, doesn't want - * to save it to a file, doesn't want information printed for each - * packet, does want some "-z" statistic, and wants packet counts - * so they know whether they're seeing any packets? - */ - print_packet_counts = TRUE; - } - - /* For now, assume libpcap gives microsecond precision. */ - timestamp_set_precision(TS_PREC_AUTO_USEC); - - capture(); - - if (capture_opts.multi_files_on) { - ringbuf_free(); - } -#else - /* No - complain. */ - cmdarg_err("This version of Twireshark was not built with support for capturing packets."); - exit(2); -#endif - } - - draw_tap_listeners(TRUE); - funnel_dump_all_text_windows(); - epan_cleanup(); - - return 0; -} - -#ifdef HAVE_LIBPCAP -/* Do the low-level work of a capture. - Returns TRUE if it succeeds, FALSE otherwise. */ - -static condition *volatile cnd_file_duration = NULL; /* this must be visible in process_packet */ - -static int -capture(void) -{ - int err = 0; - int volatile volatile_err = 0; - int volatile inpkts = 0; - int pcap_cnt; - condition *volatile cnd_autostop_size = NULL; - condition *volatile cnd_autostop_duration = NULL; - char *descr; -#ifndef _WIN32 - void (*oldhandler)(int); - guchar pcap_data[WTAP_MAX_PACKET_SIZE]; -#endif - struct pcap_stat stats; - gboolean write_ok; - gboolean close_ok; - gboolean cfilter_error = FALSE; - char errmsg[1024+1]; - char secondary_errmsg[4096+1]; - int save_file_fd; - - /* Initialize all data structures used for dissection. */ - init_dissection(); - - ld.wtap_linktype = WTAP_ENCAP_UNKNOWN; - ld.pdh = NULL; - ld.packet_cb = capture_pcap_cb; - - - /* open the "input file" from network interface or capture pipe */ - if (!capture_loop_open_input(&capture_opts, &ld, errmsg, sizeof(errmsg), - secondary_errmsg, sizeof(secondary_errmsg))) { - goto error; - } - - /* - * We've opened the capture device, so we shouldn't need any special - * privileges any more; relinquish those privileges. - * - * XXX - if we have saved set-user-ID support, we should give up those - * privileges immediately, and then reclaim them long enough to get - * a list of network interfaces and to open one, and then give them - * up again, so that stuff we do while processing the argument list, - * reading the user's preferences, loading and starting plugins - * (especially *user* plugins), etc. is done with the user's privileges, - * not special privileges. - */ - relinquish_special_privs_perm(); - - /* init the input filter from the network interface (capture pipe will do nothing) */ - switch (capture_loop_init_filter(ld.pcap_h, ld.from_cap_pipe, capture_opts.iface, capture_opts.cfilter)) { - - case INITFILTER_NO_ERROR: - break; - - case INITFILTER_BAD_FILTER: - cfilter_error = TRUE; - g_snprintf(errmsg, sizeof(errmsg), "%s", pcap_geterr(ld.pcap_h)); - *secondary_errmsg = '\0'; - goto error; - - case INITFILTER_OTHER_ERROR: - g_snprintf(errmsg, sizeof(errmsg), "Can't install filter (%s).", - pcap_geterr(ld.pcap_h)); - g_snprintf(secondary_errmsg, sizeof(secondary_errmsg), "%s", please_report); - goto error; - } - - if (capture_opts.saving_to_file) { - /* open the output file (temporary/specified name/ringbuffer/named pipe/stdout) */ - if (!capture_loop_open_output(&capture_opts, &save_file_fd, errmsg, sizeof(errmsg))) { - *secondary_errmsg = '\0'; - goto error; - } - - /* set up to write to the already-opened capture output file/files */ - if(!capture_loop_init_output(&capture_opts, save_file_fd, &ld, errmsg, sizeof errmsg)) { - *secondary_errmsg = '\0'; - goto error; - } - - /* Save the capture file name. */ - ld.save_file = capture_opts.save_file; - } - - ld.wtap_linktype = wtap_pcap_encap_to_wtap_encap(ld.linktype); - -#ifdef _WIN32 - /* Catch a CTRL+C event and, if we get it, clean up and exit. */ - SetConsoleCtrlHandler(capture_cleanup, TRUE); -#else /* _WIN32 */ - /* Catch SIGINT and SIGTERM and, if we get either of them, clean up - and exit. - XXX - deal with signal semantics on various UNIX platforms. Or just - use "sigaction()" and be done with it? */ - signal(SIGTERM, capture_cleanup); - signal(SIGINT, capture_cleanup); - if ((oldhandler = signal(SIGHUP, capture_cleanup)) != SIG_DFL) - signal(SIGHUP, oldhandler); - -#ifdef SIGINFO - /* Catch SIGINFO and, if we get it and we're capturing to a file in - quiet mode, report the number of packets we've captured. */ - signal(SIGINFO, report_counts_siginfo); -#endif /* SIGINFO */ -#endif /* _WIN32 */ - - /* Let the user know what interface was chosen. */ - descr = get_interface_descriptive_name(capture_opts.iface); - fprintf(stderr, "Capturing on %s\n", descr); - g_free(descr); - - /* initialize capture stop conditions */ - init_capture_stop_conditions(); - /* create stop conditions */ - if (capture_opts.has_autostop_filesize) - cnd_autostop_size = cnd_new((const char*)CND_CLASS_CAPTURESIZE, - (long)capture_opts.autostop_filesize * 1024); - if (capture_opts.has_autostop_duration) - cnd_autostop_duration = cnd_new((const char*)CND_CLASS_TIMEOUT, - (gint32)capture_opts.autostop_duration); - - if (capture_opts.multi_files_on && capture_opts.has_file_duration) - cnd_file_duration = cnd_new(CND_CLASS_TIMEOUT, capture_opts.file_duration); - - if (!setjmp(ld.stopenv)) { - ld.go = TRUE; - ld.packet_count = 0; - } else - ld.go = FALSE; - - while (ld.go) { - /* We need to be careful with automatic variables defined in the - outer scope which are changed inside the loop. Most compilers - don't try to roll them back to their original values after the - longjmp which causes the loop to finish, but all that the - standards say is that their values are indeterminate. If we - don't want them to be rolled back, we should define them with the - volatile attribute (paraphrasing W. Richard Stevens, Advanced - Programming in the UNIX Environment, p. 178). - - The "err" variable causes a particular problem. If we give it - the volatile attribute, then when we pass a reference to it (as - in "&err") to a function, GCC warns: "passing arg of - discards qualifiers from pointer target type". - Therefore within the loop and just beyond we don't use "err". - Within the loop we define "loop_err", and assign its value to - "volatile_err", which is in the outer scope and is checked when - the loop finishes. - - We also define "packet_count_prev" here to keep things tidy, - since it's used only inside the loop. If it were defined in the - outer scope, GCC would give a warning (unnecessary in this case) - that it might be clobbered, and we'd need to give it the volatile - attribute to suppress the warning. */ - - int loop_err = 0; - int packet_count_prev = 0; - - if (cnd_autostop_size == NULL && cnd_autostop_duration == NULL) { - /* We're not stopping at a particular capture file size, and we're - not stopping after some particular amount of time has expired, - so either we have no stop condition or the only stop condition - is a maximum packet count. - - If there's no maximum packet count, pass it -1, meaning "until - you run out of packets in the bufferful you read". Otherwise, - pass it the number of packets we have left to capture. - - We don't call "pcap_loop()" as, if we're saving to a file that's - a FIFO, we want to flush the FIFO after we're done processing - this libpcap bufferful of packets, so that the program - reading the FIFO sees the packets immediately and doesn't get - any partial packet, forcing it to block in the middle of reading - that packet. */ - if (capture_opts.autostop_packets == 0) - pcap_cnt = -1; - else { - if (ld.packet_count >= capture_opts.autostop_packets) { - /* XXX do we need this test here? */ - /* It appears there's nothing more to capture. */ - break; - } - pcap_cnt = capture_opts.autostop_packets - ld.packet_count; - } - } else { - /* We need to check the capture file size or the timeout after - each packet. */ - pcap_cnt = 1; - } -#ifndef _WIN32 - if (ld.from_cap_pipe) { - inpkts = cap_pipe_dispatch(&ld, pcap_data, errmsg, sizeof errmsg); - } else -#endif - inpkts = pcap_dispatch(ld.pcap_h, pcap_cnt, ld.packet_cb, (u_char *) &ld); - if (inpkts < 0) { - /* Error from "pcap_dispatch()", or error or "no more packets" from - "cap_pipe_dispatch(). */ - ld.go = FALSE; - } else if (cnd_autostop_duration != NULL && cnd_eval(cnd_autostop_duration)) { - /* The specified capture time has elapsed; stop the capture. */ - ld.go = FALSE; - } else if (inpkts > 0) { - if (capture_opts.autostop_packets != 0 && - ld.packet_count >= capture_opts.autostop_packets) { - /* The specified number of packets have been captured and have - passed both any capture filter in effect and any read filter - in effect. */ - ld.go = FALSE; - } else if (cnd_autostop_size != NULL && - cnd_eval(cnd_autostop_size, (guint32)ld.bytes_written)) { - /* We're saving the capture to a file, and the capture file reached - its maximum size. */ - if (capture_opts.multi_files_on) { - /* Switch to the next ringbuffer file */ - if (ringbuf_switch_file(&ld.pdh, &capture_opts.save_file, - &save_file_fd, &ld.bytes_written, - &loop_err)) { - /* File switch succeeded: reset the condition */ - cnd_reset(cnd_autostop_size); - if (cnd_file_duration) { - cnd_reset(cnd_file_duration); - } - } else { - /* File switch failed: stop here */ - volatile_err = loop_err; - ld.go = FALSE; - } - } else { - /* No ringbuffer - just stop. */ - ld.go = FALSE; - } - } - if (capture_opts.output_to_pipe) { - if (ld.packet_count > packet_count_prev) { - libpcap_dump_flush(ld.pdh, NULL); - packet_count_prev = ld.packet_count; - } - } - } /* inpkts > 0 */ - } /* while (ld.go) */ - - /* delete stop conditions */ - if (cnd_autostop_size != NULL) - cnd_delete(cnd_autostop_size); - if (cnd_autostop_duration != NULL) - cnd_delete(cnd_autostop_duration); - if (cnd_file_duration != NULL) - cnd_delete(cnd_file_duration); - - if (print_packet_counts) { - /* We're printing packet counts to stderr. - Send a newline so that we move to the line after the packet count. */ - fprintf(stderr, "\n"); - } - - /* If we got an error while capturing, report it. */ - if (inpkts < 0) { -#ifndef _WIN32 - if (ld.from_cap_pipe) { - if (ld.cap_pipe_err == PIPERR) { - cmdarg_err("Error while capturing packets: %s", errmsg); - } - } else -#endif - { - cmdarg_err("Error while capturing packets: %s", pcap_geterr(ld.pcap_h)); - } - } - - if (volatile_err == 0) - write_ok = TRUE; - else { - show_capture_file_io_error(capture_opts.save_file, volatile_err, FALSE); - write_ok = FALSE; - } - - if (capture_opts.save_file != NULL) { - /* We're saving to a file or files; close all files. */ - close_ok = capture_loop_close_output(&capture_opts, &ld, &err); - - /* If we've displayed a message about a write error, there's no point - in displaying another message about an error on close. */ - if (!close_ok && write_ok) - show_capture_file_io_error(capture_opts.save_file, err, TRUE); - } - -#ifndef _WIN32 - if (ld.from_cap_pipe && ld.cap_pipe_fd >= 0) - eth_close(ld.cap_pipe_fd); - else -#endif - { - /* Get the capture statistics, and, if any packets were dropped, report - that. */ - if (pcap_stats(ld.pcap_h, &stats) >= 0) { - if (stats.ps_drop != 0) { - fprintf(stderr, "%u packets dropped\n", stats.ps_drop); - } - } else { - cmdarg_err("Can't get packet-drop statistics: %s", pcap_geterr(ld.pcap_h)); - } - pcap_close(ld.pcap_h); - } - - /* Report the number of captured packets if not reported during capture - and we are saving to a file. */ - report_counts(); - - return TRUE; - -error: - if (capture_opts.multi_files_on) { - ringbuf_error_cleanup(); - } - g_free(capture_opts.save_file); - capture_opts.save_file = NULL; - if (cfilter_error) { - dfilter_t *rfcode = NULL; - if (dfilter_compile(capture_opts.cfilter, &rfcode) && rfcode != NULL) { - cmdarg_err( - "Invalid capture filter: \"%s\"!\n" - "\n" - "That string looks like a valid display filter; however, it isn't a valid\n" - "capture filter (%s).\n" - "\n" - "Note that display filters and capture filters don't have the same syntax,\n" - "so you can't use most display filter expressions as capture filters.\n" - "\n" - "See the User's Guide for a description of the capture filter syntax.", - capture_opts.cfilter, errmsg); - dfilter_free(rfcode); - } else { - cmdarg_err( - "Invalid capture filter: \"%s\"!\n" - "\n" - "That string isn't a valid capture filter (%s).\n" - "See the User's Guide for a description of the capture filter syntax.", - capture_opts.cfilter, errmsg); - } - } else { - cmdarg_err("%s", errmsg); - if (*secondary_errmsg != '\0') { - fprintf(stderr, "\n"); - cmdarg_err_cont("%s", secondary_errmsg); - } - } -#ifndef _WIN32 - if (ld.from_cap_pipe) { - if (ld.cap_pipe_fd >= 0) - eth_close(ld.cap_pipe_fd); - } else -#endif - { - if (ld.pcap_h != NULL) - pcap_close(ld.pcap_h); - } - - return FALSE; -} - -static void -capture_pcap_cb(u_char *user, const struct pcap_pkthdr *phdr, - const u_char *pd) -{ - struct wtap_pkthdr whdr; - union wtap_pseudo_header pseudo_header; - const guchar *wtap_pd; - loop_data *ld = (loop_data *) user; - int loop_err; - int err; - int save_file_fd; - gboolean packet_accepted; - -#ifdef SIGINFO - /* - * Prevent a SIGINFO handler from writing to stdout while we're - * doing so; instead, have it just set a flag telling us to print - * that information when we're done. - */ - infodelay = TRUE; -#endif /* SIGINFO */ - - /* The current packet may have arrived after a very long silence, - * way past the time to switch files. In order not to have - * the first packet of a new series of events as the last - * [or only] packet in the file, switch before writing! - */ - if (cnd_file_duration != NULL && cnd_eval(cnd_file_duration)) { - /* time elapsed for this ring file, switch to the next */ - if (ringbuf_switch_file(&ld->pdh, &ld->save_file, &save_file_fd, - &ld->bytes_written, &loop_err)) { - /* File switch succeeded: reset the condition */ - cnd_reset(cnd_file_duration); - } else { - /* File switch failed: stop here */ - /* XXX - we should do something with "loop_err" */ - ld->go = FALSE; - } - } - - if (do_dissection) { - /* We're goint to print packet information, run a read filter, or - process taps. Use process_packet() to handle that; in order - to do that, we need to convert from libpcap to Wiretap format. - If that fails, ignore the packet (wtap_process_pcap_packet has - written an error message). */ - wtap_pd = wtap_process_pcap_packet(ld->wtap_linktype, phdr, pd, - &pseudo_header, &whdr, &err); - if (wtap_pd == NULL) - return; - - packet_accepted = process_packet(&cfile, 0, &whdr, &pseudo_header, wtap_pd); - } else { - /* We're just writing out packets. */ - packet_accepted = TRUE; - } - - if (packet_accepted) { - /* Count this packet. */ -#ifdef HAVE_LIBPCAP - ld->packet_count++; -#endif - - if (ld->pdh != NULL) { - if (!libpcap_write_packet(ld->pdh, phdr, pd, &ld->bytes_written, &err)) { - /* Error writing to a capture file */ - if (print_packet_counts) { - /* We're printing counts of packets captured; move to the line after - the count. */ - fprintf(stderr, "\n"); - } - show_capture_file_io_error(ld->save_file, err, FALSE); - pcap_close(ld->pcap_h); - libpcap_dump_close(ld->pdh, &err); - exit(2); - } - } - if (print_packet_counts) { - /* We're printing packet counts. */ - if (ld->packet_count != 0) { - fprintf(stderr, "\r%u ", ld->packet_count); - /* stderr could be line buffered */ - fflush(stderr); - } - } - } - -#ifdef SIGINFO - /* - * Allow SIGINFO handlers to write. - */ - infodelay = FALSE; - - /* - * If a SIGINFO handler asked us to write out capture counts, do so. - */ - if (infoprint) - report_counts(); -#endif /* SIGINFO */ -} - -#ifdef _WIN32 -static BOOL WINAPI -capture_cleanup(DWORD ctrltype _U_) -{ - /* CTRL_C_EVENT is sort of like SIGINT, CTRL_BREAK_EVENT is unique to - Windows, CTRL_CLOSE_EVENT is sort of like SIGHUP, CTRL_LOGOFF_EVENT - is also sort of like SIGHUP, and CTRL_SHUTDOWN_EVENT is sort of - like SIGTERM at least when the machine's shutting down. - - For now, we handle them all as indications that we should clean up - and quit, just as we handle SIGINT, SIGHUP, and SIGTERM in that - way on UNIX. - - However, as handlers run in a new thread, we can't just longjmp - out; we have to set "ld.go" to FALSE, and must return TRUE so that - no other handler - such as one that would terminate the process - - gets called. - - XXX - for some reason, typing ^C to Twireshark, if you run this in - a Cygwin console window in at least some versions of Cygwin, - causes Twireshark to terminate immediately; this routine gets - called, but the main loop doesn't get a chance to run and - exit cleanly, at least if this is compiled with Microsoft Visual - C++ (i.e., it's a property of the Cygwin console window or Bash; - it happens if Twireshark is not built with Cygwin - for all I know, - building it with Cygwin may make the problem go away). */ - ld.go = FALSE; - return TRUE; -} -#else -static void -capture_cleanup(int signum _U_) -{ - /* Longjmp back to the starting point; "pcap_dispatch()", on many - UNIX platforms, just keeps looping if it gets EINTR, so if we set - "ld.go" to FALSE and return, we won't break out of it and quit - capturing. */ - longjmp(ld.stopenv, 1); -} -#endif /* _WIN32 */ - -static void -report_counts(void) -{ -#ifdef SIGINFO - /* XXX - if we use sigaction, this doesn't have to be done. - (Yes, this isn't necessary on BSD, but just in case a system - where "signal()" has AT&T semantics adopts SIGINFO....) */ - signal(SIGINFO, report_counts_siginfo); -#endif /* SIGINFO */ - - if (!print_packet_counts) { - /* Report the count only if we aren't printing a packet count - as packets arrive. */ - fprintf(stderr, "%u packets captured\n", ld.packet_count); - } -#ifdef SIGINFO - infoprint = FALSE; /* we just reported it */ -#endif /* SIGINFO */ -} - -#ifdef SIGINFO -static void -report_counts_siginfo(int signum _U_) -{ - int sav_errno = errno; - /* If we've been told to delay printing, just set a flag asking - that we print counts (if we're supposed to), otherwise print - the count of packets captured (if we're supposed to). */ - if (infodelay) - infoprint = TRUE; - else - report_counts(); - errno = sav_errno; -} -#endif /* SIGINFO */ -#endif /* HAVE_LIBPCAP */ - -static int -load_cap_file(capture_file *cf, char *save_file, int out_file_type) -{ - gint linktype; - int snapshot_length; - wtap_dumper *pdh; - int err; - gchar *err_info; - long data_offset; - char *save_file_string = NULL; - - linktype = wtap_file_encap(cf->wth); - if (save_file != NULL) { - /* Get a string that describes what we're writing to */ - save_file_string = output_file_description(save_file); - - /* Set up to write to the capture file. */ - snapshot_length = wtap_snapshot_length(cf->wth); - if (snapshot_length == 0) { - /* Snapshot length of input file not known. */ - snapshot_length = WTAP_MAX_PACKET_SIZE; - } - pdh = wtap_dump_open(save_file, out_file_type, linktype, snapshot_length, - FALSE /* compressed */, &err); - - if (pdh == NULL) { - /* We couldn't set up to write to the capture file. */ - switch (err) { - - case WTAP_ERR_UNSUPPORTED_FILE_TYPE: - cmdarg_err("Capture files can't be written in that format."); - break; - - case WTAP_ERR_UNSUPPORTED_ENCAP: - case WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED: - cmdarg_err("The capture file being read can't be written in " - "that format."); - break; - - case WTAP_ERR_CANT_OPEN: - cmdarg_err("The %s couldn't be created for some " - "unknown reason.", save_file_string); - break; - - case WTAP_ERR_SHORT_WRITE: - cmdarg_err("A full header couldn't be written to the %s.", - save_file_string); - break; - - default: - cmdarg_err("The %s could not be created: %s.", save_file_string, - wtap_strerror(err)); - break; - } - goto out; - } - } else { - if (print_packet_info) { - if (!write_preamble(cf)) { - err = errno; - show_print_file_io_error(err); - goto out; - } - } - pdh = NULL; - } - while (wtap_read(cf->wth, &err, &err_info, &data_offset)) { - if (process_packet(cf, data_offset, wtap_phdr(cf->wth), - wtap_pseudoheader(cf->wth), wtap_buf_ptr(cf->wth))) { - /* Either there's no read filtering or this packet passed the - filter, so, if we're writing to a capture file, write - this packet out. */ - if (pdh != NULL) { - if (!wtap_dump(pdh, wtap_phdr(cf->wth), - wtap_pseudoheader(cf->wth), wtap_buf_ptr(cf->wth), - &err)) { - /* Error writing to a capture file */ - show_capture_file_io_error(save_file, err, FALSE); - wtap_dump_close(pdh, &err); - exit(2); - } - } - } - } - if (err != 0) { - /* Print a message noting that the read failed somewhere along the line. */ - switch (err) { - - case WTAP_ERR_UNSUPPORTED_ENCAP: - cmdarg_err("\"%s\" has a packet with a network type that Twireshark doesn't support.\n(%s)", - cf->filename, err_info); - break; - - case WTAP_ERR_CANT_READ: - cmdarg_err("An attempt to read from \"%s\" failed for some unknown reason.", - cf->filename); - break; - - case WTAP_ERR_SHORT_READ: - cmdarg_err("\"%s\" appears to have been cut short in the middle of a packet.", - cf->filename); - break; - - case WTAP_ERR_BAD_RECORD: - cmdarg_err("\"%s\" appears to be damaged or corrupt.\n(%s)", - cf->filename, err_info); - break; - - default: - cmdarg_err("An error occurred while reading \"%s\": %s.", - cf->filename, wtap_strerror(err)); - break; - } - if (save_file != NULL) { - /* Now close the capture file. */ - if (!wtap_dump_close(pdh, &err)) - show_capture_file_io_error(save_file, err, TRUE); - } - } else { - if (save_file != NULL) { - /* Now close the capture file. */ - if (!wtap_dump_close(pdh, &err)) - show_capture_file_io_error(save_file, err, TRUE); - } else { - if (print_packet_info) { - if (!write_finale()) { - err = errno; - show_print_file_io_error(err); - } - } - } - } - -out: - wtap_close(cf->wth); - cf->wth = NULL; - - if (save_file_string != NULL) - g_free(save_file_string); - - return err; -} - -static void -fill_in_fdata(frame_data *fdata, capture_file *cf, - const struct wtap_pkthdr *phdr, long offset) -{ - fdata->next = NULL; - fdata->prev = NULL; - fdata->pfd = NULL; - fdata->num = cf->count; - fdata->pkt_len = phdr->len; - cum_bytes += phdr->len; - fdata->cum_bytes = cum_bytes; - fdata->cap_len = phdr->caplen; - fdata->file_off = offset; - fdata->lnk_t = phdr->pkt_encap; - fdata->abs_ts = *((nstime_t *) &phdr->ts); - fdata->flags.passed_dfilter = 0; - fdata->flags.encoding = CHAR_ASCII; - fdata->flags.visited = 0; - fdata->flags.marked = 0; - fdata->flags.ref_time = 0; - fdata->color_filter = NULL; - - /* If we don't have the time stamp of the first packet in the - capture, it's because this is the first packet. Save the time - stamp of this packet as the time stamp of the first packet. */ - if (nstime_is_zero(&first_ts)) { - first_ts = fdata->abs_ts; - } - - /* If we don't have the time stamp of the previous displayed packet, - it's because this is the first displayed packet. Save the time - stamp of this packet as the time stamp of the previous displayed - packet. */ - if (nstime_is_zero(&prev_ts)) { - prev_ts = fdata->abs_ts; - } - - /* Get the time elapsed between the first packet and this packet. */ - nstime_delta(&fdata->rel_ts, &fdata->abs_ts, &first_ts); - - /* If it's greater than the current elapsed time, set the elapsed time - to it (we check for "greater than" so as not to be confused by - time moving backwards). */ - if ((gint32)cf->elapsed_time.secs < fdata->rel_ts.secs - || ((gint32)cf->elapsed_time.secs == fdata->rel_ts.secs && (gint32)cf->elapsed_time.nsecs < fdata->rel_ts.nsecs)) { - cf->elapsed_time = fdata->rel_ts; - } - - /* Get the time elapsed between the previous displayed packet and - this packet. */ - nstime_delta(&fdata->del_ts, &fdata->abs_ts, &prev_ts); - prev_ts = fdata->abs_ts; -} - -/* Free up all data attached to a "frame_data" structure. */ -static void -clear_fdata(frame_data *fdata) -{ - if (fdata->pfd) - g_slist_free(fdata->pfd); -} - -static gboolean -process_packet(capture_file *cf, long offset, const struct wtap_pkthdr *whdr, - union wtap_pseudo_header *pseudo_header, const guchar *pd) -{ - frame_data fdata; - gboolean create_proto_tree; - epan_dissect_t *edt; - gboolean passed; - - /* Count this packet. */ - cf->count++; - - /* If we're going to print packet information, or we're going to - run a read filter, or we're going to process taps, set up to - do a dissection and do so. */ - if (do_dissection) { - fill_in_fdata(&fdata, cf, whdr, offset); - - if (print_packet_info) { - /* Grab any resolved addresses */ - - if (g_resolv_flags) { - host_name_lookup_process(NULL); - } - } - - passed = TRUE; - if (cf->rfcode || verbose || num_tap_filters!=0) - create_proto_tree = TRUE; - else - create_proto_tree = FALSE; - /* The protocol tree will be "visible", i.e., printed, only if we're - printing packet details, which is true if we're printing stuff - ("print_packet_info" is true) and we're in verbose mode ("verbose" - is true). */ - edt = epan_dissect_new(create_proto_tree, print_packet_info && verbose); - - /* If we're running a read filter, prime the epan_dissect_t with that - filter. */ - if (cf->rfcode) - epan_dissect_prime_dfilter(edt, cf->rfcode); - - tap_queue_init(edt); - - /* We only need the columns if we're printing packet info but we're - *not* verbose; in verbose mode, we print the protocol tree, not - the protocol summary. */ - epan_dissect_run(edt, pseudo_header, pd, &fdata, - (print_packet_info && !verbose) ? &cf->cinfo : NULL); - - tap_push_tapped_queue(edt); - - /* Run the read filter if we have one. */ - if (cf->rfcode) - passed = dfilter_apply_edt(cf->rfcode, edt); - else - passed = TRUE; - } else { - /* We're not running a display filter and we're not printing any - packet information, so we don't need to do a dissection, and all - packets are processed. */ - edt = NULL; - passed = TRUE; - } - - if (passed) { - /* Process this packet. */ - if (print_packet_info) { - /* We're printing packet information; print the information for - this packet. */ - print_packet(cf, edt); - - /* The ANSI C standard does not appear to *require* that a line-buffered - stream be flushed to the host environment whenever a newline is - written, it just says that, on such a stream, characters "are - intended to be transmitted to or from the host environment as a - block when a new-line character is encountered". - - The Visual C++ 6.0 C implementation doesn't do what is intended; - even if you set a stream to be line-buffered, it still doesn't - flush the buffer at the end of every line. - - So, if the "-l" flag was specified, we flush the standard output - at the end of a packet. This will do the right thing if we're - printing packet summary lines, and, as we print the entire protocol - tree for a single packet without waiting for anything to happen, - it should be as good as line-buffered mode if we're printing - protocol trees. (The whole reason for the "-l" flag in either - tcpdump or Twireshark is to allow the output of a live capture to - be piped to a program or script and to have that script see the - information for the packet as soon as it's printed, rather than - having to wait until a standard I/O buffer fills up. */ - if (line_buffered) - fflush(stdout); - - if (ferror(stdout)) { - show_print_file_io_error(errno); - exit(2); - } - } - } - - if (do_dissection) { - epan_dissect_free(edt); - clear_fdata(&fdata); - } - return passed; -} - -static void -show_capture_file_io_error(const char *fname, int err, gboolean is_close) -{ - char *save_file_string; - - save_file_string = output_file_description(fname); - - switch (err) { - - case ENOSPC: - cmdarg_err("Not all the packets could be written to the %s because there is " - "no space left on the file system.", - save_file_string); - break; - -#ifdef EDQUOT - case EDQUOT: - cmdarg_err("Not all the packets could be written to the %s because you are " - "too close to, or over your disk quota.", - save_file_string); - break; -#endif - - case WTAP_ERR_CANT_CLOSE: - cmdarg_err("The %s couldn't be closed for some unknown reason.", - save_file_string); - break; - - case WTAP_ERR_SHORT_WRITE: - cmdarg_err("Not all the packets could be written to the %s.", - save_file_string); - break; - - default: - if (is_close) { - cmdarg_err("The %s could not be closed: %s.", save_file_string, - wtap_strerror(err)); - } else { - cmdarg_err("An error occurred while writing to the %s: %s.", - save_file_string, wtap_strerror(err)); - } - break; - } - g_free(save_file_string); -} - -static gboolean -write_preamble(capture_file *cf) -{ - switch (output_action) { - - case WRITE_TEXT: - return print_preamble(print_stream, cf->filename); - break; - - case WRITE_XML: - if (verbose) - write_pdml_preamble(stdout); - else - write_psml_preamble(stdout); - return !ferror(stdout); - - default: - g_assert_not_reached(); - return FALSE; - } -} - -static char * -get_line_buf(size_t len) -{ - static char *line_bufp = NULL; - static size_t line_buf_len = 256; - size_t new_line_buf_len; - - for (new_line_buf_len = line_buf_len; len > new_line_buf_len; - new_line_buf_len *= 2) - ; - if (line_bufp == NULL) { - line_buf_len = new_line_buf_len; - line_bufp = g_malloc(line_buf_len + 1); - } else { - if (new_line_buf_len > line_buf_len) { - line_buf_len = new_line_buf_len; - line_bufp = g_realloc(line_bufp, line_buf_len + 1); - } - } - return line_bufp; -} - -static gboolean -print_columns(capture_file *cf) -{ - char *line_bufp; - int i; - size_t buf_offset; - size_t column_len; - - line_bufp = get_line_buf(256); - buf_offset = 0; - *line_bufp = '\0'; - for (i = 0; i < cf->cinfo.num_cols; i++) { - switch (cf->cinfo.col_fmt[i]) { - case COL_NUMBER: -#ifdef HAVE_LIBPCAP - /* - * Don't print this if we're doing a live capture from a network - * interface - if we're doing a live capture, you won't be - * able to look at the capture in the future (it's not being - * saved anywhere), so the frame numbers are unlikely to be - * useful. - * - * (XXX - it might be nice to be able to save and print at - * the same time, sort of like an "Update list of packets - * in real time" capture in Wireshark.) - */ - if (capture_opts.iface != NULL) - continue; -#endif - column_len = strlen(cf->cinfo.col_data[i]); - if (column_len < 3) - column_len = 3; - line_bufp = get_line_buf(buf_offset + column_len); - sprintf(line_bufp + buf_offset, "%3s", cf->cinfo.col_data[i]); - break; - - case COL_CLS_TIME: - case COL_REL_TIME: - case COL_ABS_TIME: - case COL_ABS_DATE_TIME: /* XXX - wider */ - column_len = strlen(cf->cinfo.col_data[i]); - if (column_len < 10) - column_len = 10; - line_bufp = get_line_buf(buf_offset + column_len); - sprintf(line_bufp + buf_offset, "%10s", cf->cinfo.col_data[i]); - break; - - case COL_DEF_SRC: - case COL_RES_SRC: - case COL_UNRES_SRC: - case COL_DEF_DL_SRC: - case COL_RES_DL_SRC: - case COL_UNRES_DL_SRC: - case COL_DEF_NET_SRC: - case COL_RES_NET_SRC: - case COL_UNRES_NET_SRC: - column_len = strlen(cf->cinfo.col_data[i]); - if (column_len < 12) - column_len = 12; - line_bufp = get_line_buf(buf_offset + column_len); - sprintf(line_bufp + buf_offset, "%12s", cf->cinfo.col_data[i]); - break; - - case COL_DEF_DST: - case COL_RES_DST: - case COL_UNRES_DST: - case COL_DEF_DL_DST: - case COL_RES_DL_DST: - case COL_UNRES_DL_DST: - case COL_DEF_NET_DST: - case COL_RES_NET_DST: - case COL_UNRES_NET_DST: - column_len = strlen(cf->cinfo.col_data[i]); - if (column_len < 12) - column_len = 12; - line_bufp = get_line_buf(buf_offset + column_len); - sprintf(line_bufp + buf_offset, "%-12s", cf->cinfo.col_data[i]); - break; - - default: - column_len = strlen(cf->cinfo.col_data[i]); - line_bufp = get_line_buf(buf_offset + column_len); - strcat(line_bufp + buf_offset, cf->cinfo.col_data[i]); - break; - } - buf_offset += column_len; - if (i != cf->cinfo.num_cols - 1) { - /* - * This isn't the last column, so we need to print a - * separator between this column and the next. - * - * If we printed a network source and are printing a - * network destination of the same type next, separate - * them with "->"; if we printed a network destination - * and are printing a network source of the same type - * next, separate them with "<-"; otherwise separate them - * with a space. - * - * We add enough space to the buffer for " <- " or " -> ", - * even if we're only adding " ". - */ - line_bufp = get_line_buf(buf_offset + 4); - switch (cf->cinfo.col_fmt[i]) { - - case COL_DEF_SRC: - case COL_RES_SRC: - case COL_UNRES_SRC: - switch (cf->cinfo.col_fmt[i + 1]) { - - case COL_DEF_DST: - case COL_RES_DST: - case COL_UNRES_DST: - strcat(line_bufp + buf_offset, " -> "); - buf_offset += 4; - break; - - default: - strcat(line_bufp + buf_offset, " "); - buf_offset += 1; - break; - } - break; - - case COL_DEF_DL_SRC: - case COL_RES_DL_SRC: - case COL_UNRES_DL_SRC: - switch (cf->cinfo.col_fmt[i + 1]) { - - case COL_DEF_DL_DST: - case COL_RES_DL_DST: - case COL_UNRES_DL_DST: - strcat(line_bufp + buf_offset, " -> "); - buf_offset += 4; - break; - - default: - strcat(line_bufp + buf_offset, " "); - buf_offset += 1; - break; - } - break; - - case COL_DEF_NET_SRC: - case COL_RES_NET_SRC: - case COL_UNRES_NET_SRC: - switch (cf->cinfo.col_fmt[i + 1]) { - - case COL_DEF_NET_DST: - case COL_RES_NET_DST: - case COL_UNRES_NET_DST: - strcat(line_bufp + buf_offset, " -> "); - buf_offset += 4; - break; - - default: - strcat(line_bufp + buf_offset, " "); - buf_offset += 1; - break; - } - break; - - case COL_DEF_DST: - case COL_RES_DST: - case COL_UNRES_DST: - switch (cf->cinfo.col_fmt[i + 1]) { - - case COL_DEF_SRC: - case COL_RES_SRC: - case COL_UNRES_SRC: - strcat(line_bufp + buf_offset, " <- "); - buf_offset += 4; - break; - - default: - strcat(line_bufp + buf_offset, " "); - buf_offset += 1; - break; - } - break; - - case COL_DEF_DL_DST: - case COL_RES_DL_DST: - case COL_UNRES_DL_DST: - switch (cf->cinfo.col_fmt[i + 1]) { - - case COL_DEF_DL_SRC: - case COL_RES_DL_SRC: - case COL_UNRES_DL_SRC: - strcat(line_bufp + buf_offset, " <- "); - buf_offset += 4; - break; - - default: - strcat(line_bufp + buf_offset, " "); - buf_offset += 1; - break; - } - break; - - case COL_DEF_NET_DST: - case COL_RES_NET_DST: - case COL_UNRES_NET_DST: - switch (cf->cinfo.col_fmt[i + 1]) { - - case COL_DEF_NET_SRC: - case COL_RES_NET_SRC: - case COL_UNRES_NET_SRC: - strcat(line_bufp + buf_offset, " <- "); - buf_offset += 4; - break; - - default: - strcat(line_bufp + buf_offset, " "); - buf_offset += 1; - break; - } - break; - - default: - strcat(line_bufp + buf_offset, " "); - buf_offset += 1; - break; - } - } - } - return print_line(print_stream, 0, line_bufp); -} - -static gboolean -print_packet(capture_file *cf, epan_dissect_t *edt) -{ - print_args_t print_args; - - if (verbose) { - /* Print the information in the protocol tree. */ - switch (output_action) { - - case WRITE_TEXT: - print_args.to_file = TRUE; - print_args.format = print_format; - print_args.print_summary = !verbose; - print_args.print_hex = verbose && print_hex; - print_args.print_formfeed = FALSE; - print_args.print_dissections = verbose ? print_dissections_expanded : print_dissections_none; - - /* init the packet range */ - packet_range_init(&print_args.range); - - if (!proto_tree_print(&print_args, edt, print_stream)) - return FALSE; - if (!print_hex) { - /* "print_hex_data()" will put out a leading blank line, as well - as a trailing one; print one here, to separate the packets, - only if "print_hex_data()" won't be called. */ - if (!print_line(print_stream, 0, "")) - return FALSE; - } - break; - - case WRITE_XML: - proto_tree_write_pdml(edt, stdout); - printf("\n"); - return !ferror(stdout); - } - } else { - /* Just fill in the columns. */ - epan_dissect_fill_in_columns(edt); - - /* Now print them. */ - switch (output_action) { - - case WRITE_TEXT: - if (!print_columns(cf)) - return FALSE; - break; - - case WRITE_XML: - proto_tree_write_psml(edt, stdout); - return !ferror(stdout); - } - } - if (print_hex) { - if (!print_hex_data(print_stream, edt)) - return FALSE; - if (!print_line(print_stream, 0, "")) - return FALSE; - } - return TRUE; -} - -static gboolean -write_finale(void) -{ - switch (output_action) { - - case WRITE_TEXT: - return print_finale(print_stream); - break; - - case WRITE_XML: - if (verbose) - write_pdml_finale(stdout); - else - write_psml_finale(stdout); - return !ferror(stdout); - - default: - g_assert_not_reached(); - return FALSE; - } -} - -static void -show_print_file_io_error(int err) -{ - switch (err) { - - case ENOSPC: - cmdarg_err("Not all the packets could be printed because there is " -"no space left on the file system."); - break; - -#ifdef EDQUOT - case EDQUOT: - cmdarg_err("Not all the packets could be printed because you are " -"too close to, or over your disk quota."); - break; -#endif - - default: - cmdarg_err("An error occurred while printing packets: %s.", - strerror(err)); - break; - } -} - -static const char * -cf_open_error_message(int err, gchar *err_info, gboolean for_writing, - int file_type) -{ - const char *errmsg; - static char errmsg_errno[1024+1]; - - if (err < 0) { - /* Wiretap error. */ - switch (err) { - - case WTAP_ERR_NOT_REGULAR_FILE: - errmsg = "The file \"%s\" is a \"special file\" or socket or other non-regular file."; - break; - - case WTAP_ERR_FILE_UNKNOWN_FORMAT: - /* Seen only when opening a capture file for reading. */ - errmsg = "The file \"%s\" isn't a capture file in a format Twireshark understands."; - break; - - case WTAP_ERR_UNSUPPORTED: - /* Seen only when opening a capture file for reading. */ - g_snprintf(errmsg_errno, sizeof(errmsg_errno), - "The file \"%%s\" isn't a capture file in a format Twireshark understands.\n" - "(%s)", err_info); - g_free(err_info); - errmsg = errmsg_errno; - break; - - case WTAP_ERR_CANT_WRITE_TO_PIPE: - /* Seen only when opening a capture file for writing. */ - g_snprintf(errmsg_errno, sizeof(errmsg_errno), - "The file \"%%s\" is a pipe, and %s capture files can't be " - "written to a pipe.", wtap_file_type_string(file_type)); - errmsg = errmsg_errno; - break; - - case WTAP_ERR_UNSUPPORTED_FILE_TYPE: - /* Seen only when opening a capture file for writing. */ - errmsg = "Twireshark doesn't support writing capture files in that format."; - break; - - case WTAP_ERR_UNSUPPORTED_ENCAP: - if (for_writing) - errmsg = "Twireshark can't save this capture in that format."; - else { - g_snprintf(errmsg_errno, sizeof(errmsg_errno), - "The file \"%%s\" is a capture for a network type that Twireshark doesn't support.\n" - "(%s)", err_info); - g_free(err_info); - errmsg = errmsg_errno; - } - break; - - case WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED: - if (for_writing) - errmsg = "Twireshark can't save this capture in that format."; - else - errmsg = "The file \"%s\" is a capture for a network type that Twireshark doesn't support."; - break; - - case WTAP_ERR_BAD_RECORD: - /* Seen only when opening a capture file for reading. */ - g_snprintf(errmsg_errno, sizeof(errmsg_errno), - "The file \"%%s\" appears to be damaged or corrupt.\n" - "(%s)", err_info); - g_free(err_info); - errmsg = errmsg_errno; - break; - - case WTAP_ERR_CANT_OPEN: - if (for_writing) - errmsg = "The file \"%s\" could not be created for some unknown reason."; - else - errmsg = "The file \"%s\" could not be opened for some unknown reason."; - break; - - case WTAP_ERR_SHORT_READ: - errmsg = "The file \"%s\" appears to have been cut short" - " in the middle of a packet or other data."; - break; - - case WTAP_ERR_SHORT_WRITE: - errmsg = "A full header couldn't be written to the file \"%s\"."; - break; - - default: - g_snprintf(errmsg_errno, sizeof(errmsg_errno), - "The file \"%%s\" could not be %s: %s.", - for_writing ? "created" : "opened", - wtap_strerror(err)); - errmsg = errmsg_errno; - break; - } - } else - errmsg = file_open_error_message(err, for_writing); - return errmsg; -} - -/* - * Open/create errors are reported with an console message in Twireshark. - */ -static void -open_failure_message(const char *filename, int err, gboolean for_writing) -{ - fprintf(stderr, "twireshark: "); - fprintf(stderr, file_open_error_message(err, for_writing), filename); - fprintf(stderr, "\n"); -} - -cf_status_t -cf_open(capture_file *cf, const char *fname, gboolean is_tempfile, int *err) -{ - wtap *wth; - gchar *err_info; - char err_msg[2048+1]; - - wth = wtap_open_offline(fname, err, &err_info, FALSE); - if (wth == NULL) - goto fail; - - /* The open succeeded. Fill in the information for this file. */ - - /* Initialize all data structures used for dissection. */ - init_dissection(); - - cf->wth = wth; - cf->f_datalen = 0; /* not used, but set it anyway */ - - /* Set the file name because we need it to set the follow stream filter. - XXX - is that still true? We need it for other reasons, though, - in any case. */ - cf->filename = g_strdup(fname); - - /* Indicate whether it's a permanent or temporary file. */ - cf->is_tempfile = is_tempfile; - - /* If it's a temporary capture buffer file, mark it as not saved. */ - cf->user_saved = !is_tempfile; - - cf->cd_t = wtap_file_type(cf->wth); - cf->count = 0; - cf->drops_known = FALSE; - cf->drops = 0; - cf->snap = wtap_snapshot_length(cf->wth); - if (cf->snap == 0) { - /* Snapshot length not known. */ - cf->has_snap = FALSE; - cf->snap = WTAP_MAX_PACKET_SIZE; - } else - cf->has_snap = TRUE; - nstime_set_zero(&cf->elapsed_time); - nstime_set_zero(&first_ts); - nstime_set_zero(&prev_ts); - - return CF_OK; - -fail: - g_snprintf(err_msg, sizeof err_msg, - cf_open_error_message(*err, err_info, FALSE, cf->cd_t), fname); - cmdarg_err("%s", err_msg); - return CF_ERROR; -} - - -/* - * General errors are reported with an console message in Twireshark. - */ -static void -failure_message(const char *msg_format, va_list ap) -{ - fprintf(stderr, "twireshark: "); - vfprintf(stderr, msg_format, ap); - fprintf(stderr, "\n"); -} - -/* - * Read errors are reported with an console message in Twireshark. - */ -static void -read_failure_message(const char *filename, int err) -{ - cmdarg_err("An error occurred while reading from the file \"%s\": %s.", - filename, strerror(err)); -} - -/* - * Report an error in command-line arguments. - */ -void -cmdarg_err(const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - fprintf(stderr, "twireshark: "); - vfprintf(stderr, fmt, ap); - fprintf(stderr, "\n"); - va_end(ap); -} - -/* - * Report additional information for an error in command-line arguments. - */ -void -cmdarg_err_cont(const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - vfprintf(stderr, fmt, ap); - fprintf(stderr, "\n"); - va_end(ap); -} - - -/****************************************************************************************************************/ -/* indication report "dummies", needed for capture_loop.c */ - -#ifdef HAVE_LIBPCAP - -/** Report a new capture file having been opened. */ -void -report_new_capture_file(const char *filename) -{ - /* shouldn't happen */ - g_assert_not_reached(); -} - -/** Report a number of new packets captured. */ -void -report_packet_count(int packet_count) -{ - /* shouldn't happen */ - g_assert_not_reached(); -} - -/** Report the packet drops once the capture finishes. */ -void -report_packet_drops(int drops) -{ - /* shouldn't happen */ - g_assert_not_reached(); -} - -/** Report an error in the capture. */ -void -report_capture_error(const char *errmsg, const char *secondary_error_msg) -{ - cmdarg_err(errmsg); - cmdarg_err_cont(secondary_error_msg); -} - -/** Report an error with a capture filter. */ -void -report_cfilter_error(const char *cfilter, const char *errmsg) -{ - - cmdarg_err( - "Invalid capture filter: \"%s\"!\n" - "\n" - "That string isn't a valid capture filter (%s).\n" - "See the User's Guide for a description of the capture filter syntax.", - cfilter, errmsg); -} - -#endif /* HAVE_LIBPCAP */ - - -/****************************************************************************************************************/ -/* signal pipe "dummies", needed for capture_loop.c */ - -#ifdef HAVE_LIBPCAP - -#ifdef _WIN32 -gboolean -signal_pipe_check_running(void) -{ - /* currently, no check required */ - return TRUE; -} -#endif /* _WIN32 */ - -#endif /* HAVE_LIBPCAP */ diff --git a/tools/EtherealXML.py b/tools/EtherealXML.py index 4611e45979..51e8ca0e9f 100644 --- a/tools/EtherealXML.py +++ b/tools/EtherealXML.py @@ -1,5 +1,5 @@ """ -Baseclass for reading PDML produced from Tethereal. +Baseclass for reading PDML produced from TShark. Copyright (c) 2003 by Gilbert Ramirez diff --git a/tools/dfilter-test.py b/tools/dfilter-test.py index 8af7907869..4b4440fc4c 100755 --- a/tools/dfilter-test.py +++ b/tools/dfilter-test.py @@ -34,7 +34,7 @@ import getopt REMOVE_TEMP_FILES = 1 VERBOSE = 0 TEXT2PCAP = os.path.join(".", "text2pcap") -TETHEREAL = os.path.join(".", "tethereal") +TSHARK = os.path.join(".", "tshark") # Some DLT values. Add more from if you need to. @@ -191,26 +191,26 @@ class Test: def DFilterCount(self, packet, dfilter, num_lines_expected): """Run a dfilter on a packet file and expect a certain number of output lines. If num_lines_expected - is None, then the tethereal command is expected to fail + is None, then the tshark command is expected to fail with a non-zero return value.""" packet_file = packet.Filename() - cmd = (TETHEREAL, "-n -r", packet_file, "-R '", dfilter, "'") + cmd = (TSHARK, "-n -r", packet_file, "-R '", dfilter, "'") - tethereal_failed = 0 + tshark_failed = 0 try: (output, retval) = run_cmd(cmd) except RunCommandError: - tethereal_failed = 1 + tshark_failed = 1 # print "GOT", len(output), "lines:", output, retval if retval: - tethereal_failed = 1 + tshark_failed = 1 - if tethereal_failed: + if tshark_failed: if num_lines_expected == None: if VERBOSE: print "\nGot:", output @@ -1325,8 +1325,8 @@ all_tests = [ def usage(): print "usage: %s [OPTS] [TEST ...]" % (sys.argv[0],) - print "\t-p PATH : path to find both tethereal and text2pcap (DEFAULT: . )" - print "\t-t FILE : location of tethereal binary" + print "\t-p PATH : path to find both tshark and text2pcap (DEFAULT: . )" + print "\t-t FILE : location of tshark binary" print "\t-x FILE : location of text2pcap binary" print "\t-k : keep temporary files" print "\t-v : verbose" @@ -1339,7 +1339,7 @@ def usage(): def main(): - global TETHEREAL + global TSHARK global TEXT2PCAP global VERBOSE global REMOVE_TEMP_FILES @@ -1355,14 +1355,14 @@ def main(): for opt, arg in opts: if opt == "-t": - TETHEREAL = arg + TSHARK = arg elif opt == "-x": TEXT2PCAP = arg elif opt == "-v": VERBOSE = 1 elif opt == "-p": TEXT2PCAP = os.path.join(arg, "text2pcap") - TETHEREAL = os.path.join(arg, "tethereal") + TSHARK = os.path.join(arg, "tshark") elif opt == "-k": REMOVE_TEMP_FILES = 0 else: @@ -1370,8 +1370,8 @@ def main(): usage() # Sanity test - if not os.path.exists(TETHEREAL): - sys.exit("tethereal program '%s' does not exist." % (TETHEREAL,)) + if not os.path.exists(TSHARK): + sys.exit("tshark program '%s' does not exist." % (TSHARK,)) if not os.path.exists(TEXT2PCAP): sys.exit("text2pcap program '%s' does not exist." % (TEXT2PCAP,)) diff --git a/tools/ftsanity.py b/tools/ftsanity.py index 855f68db7b..39ff6fbd89 100755 --- a/tools/ftsanity.py +++ b/tools/ftsanity.py @@ -42,9 +42,9 @@ class Field: -def gather_data(tethereal): - """Calls tethereal and gathers data.""" - cmd = "%s -G fields3" % (tethereal,) +def gather_data(tshark): + """Calls tshark and gathers data.""" + cmd = "%s -G fields3" % (tshark,) (status, output) = commands.getstatusoutput(cmd) if status != 0: @@ -69,10 +69,10 @@ def check_fields(fields): (field.abbrev, field.bitmask, field.ftype) errors += 1 -def run(tethereal): +def run(tshark): """Run the tests.""" global errors - protos, fields = gather_data(tethereal) + protos, fields = gather_data(tshark) check_fields(fields) @@ -83,13 +83,13 @@ def run(tethereal): def main(): """Parse the command-line.""" - usage = "%prog tethereal" + usage = "%prog tshark" parser = OptionParser(usage=usage) (options, args) = parser.parse_args() if len(args) != 1: - parser.error("Need location of tethereal.") + parser.error("Need location of tshark.") run(args[0]) diff --git a/tools/fuzz-test.sh b/tools/fuzz-test.sh index c1a5ddb078..fa47fe4366 100755 --- a/tools/fuzz-test.sh +++ b/tools/fuzz-test.sh @@ -2,15 +2,15 @@ # # $Id$ -# Fuzz-testing script for Tethereal +# Fuzz-testing script for TShark # # This script uses Editcap to add random errors ("fuzz") to a set of -# capture files specified on the command line. It runs Tethereal on +# capture files specified on the command line. It runs TShark on # each fuzzed file and checks for errors. The files are processed # repeatedly until an error is found. # Tweak the following to your liking. Editcap must support "-E". -TETHEREAL=./tethereal +TSHARK=./tshark EDITCAP=./editcap CAPINFOS=./capinfos @@ -41,15 +41,15 @@ ulimit -c unlimited ### usually you won't have to change anything below this line ### -# Tethereal arguments (you won't have to change these) +# TShark arguments (you won't have to change these) # n Disable network object name resolution # V Print a view of the details of the packet rather than a one-line summary of the packet -# x Cause Tethereal to print a hex and ASCII dump of the packet data after printing the summary or details +# x Cause TShark to print a hex and ASCII dump of the packet data after printing the summary or details # r Read packet data from the following infile -TETHEREAL_ARGS="-nVxr" +TSHARK_ARGS="-nVxr" NOTFOUND=0 -for i in "$TETHEREAL" "$EDITCAP" "$CAPINFOS" "$DATE" "$TMP_DIR" ; do +for i in "$TSHARK" "$EDITCAP" "$CAPINFOS" "$DATE" "$TMP_DIR" ; do if [ ! -x $i ]; then echo "Couldn't find $i" NOTFOUND=1 @@ -75,7 +75,7 @@ FIN exit 1 fi -echo "Running $TETHEREAL with args: $TETHEREAL_ARGS" +echo "Running $TSHARK with args: $TSHARK_ARGS" echo "" # Not yet - properly handle empty filenames @@ -108,7 +108,7 @@ while [ 1 ] ; do fi fi - "$TETHEREAL" $TETHEREAL_ARGS $TMP_DIR/$TMP_FILE \ + "$TSHARK" $TSHARK_ARGS $TMP_DIR/$TMP_FILE \ > /dev/null 2> $TMP_DIR/$ERR_FILE RETVAL=$? grep -i "dissector bug" $TMP_DIR/$ERR_FILE \ diff --git a/tools/msnchat b/tools/msnchat index bc641f5edc..24ec5855ba 100755 --- a/tools/msnchat +++ b/tools/msnchat @@ -208,13 +208,13 @@ class CaptureFile: """Parses a single a capture file and keeps track of all chat sessions in the file.""" - def __init__(self, capture_filename, tethereal): - """Run tethereal on the capture file and parse + def __init__(self, capture_filename, tshark): + """Run tshark on the capture file and parse the data.""" self.conversations = [] self.conversations_map = {} - pipe = os.popen(tethereal + " -Tpdml -n -R " + pipe = os.popen(tshark + " -Tpdml -n -R " "'msnms contains \"X-MMS-IM-Format\"' " "-r " + capture_filename, "r") @@ -253,14 +253,14 @@ class CaptureFile: conv.CreateHTML(default_user) -def run_filename(filename, default_user, tethereal): +def run_filename(filename, default_user, tshark): """Process one capture file.""" - capture = CaptureFile(filename, tethereal) + capture = CaptureFile(filename, tshark) capture.CreateHTML(default_user) -def run(filenames, default_user, tethereal): +def run(filenames, default_user, tshark): # HTML Header print >> out_fh, """ MSN Conversation @@ -268,7 +268,7 @@ def run(filenames, default_user, tethereal): """ for filename in filenames: - run_filename(filename, default_user, tethereal) + run_filename(filename, default_user, tshark) # HTML Footer print >> out_fh, """ @@ -281,13 +281,13 @@ def run(filenames, default_user, tethereal): def usage(): print >> sys.stderr, "msnchat [OPTIONS] CAPTURE_FILE [...]" print >> sys.stderr, " -o FILE name of output file" - print >> sys.stderr, " -t TETHEREAL location of tethereal binary" + print >> sys.stderr, " -t TSHARK location of tshark binary" print >> sys.stderr, " -u USER name for unknown user" sys.exit(1) def main(): default_user = "Unknown" - tethereal = "tethereal" + tshark = "tshark" optstring = "ho:t:u:" longopts = ["help"] @@ -313,12 +313,12 @@ def main(): default_user = arg elif opt == "-t": - tethereal = arg + tshark = arg else: sys.exit("Unhandled command-line option: " + opt) - run(args, default_user, tethereal) + run(args, default_user, tshark) if __name__ == '__main__': main() diff --git a/tools/pkt-from-core.py b/tools/pkt-from-core.py index 03bc244667..7810645915 100755 --- a/tools/pkt-from-core.py +++ b/tools/pkt-from-core.py @@ -1,6 +1,6 @@ #!/usr/bin/env python """ -Retrieve a packet from a ethereal/tethereal core file +Retrieve a packet from a ethereal/tshark core file and save it in a packet-capture file. """ @@ -415,7 +415,7 @@ def usage(): print "" print "\tGiven an executable file and a core file, this tool" print "\tuses gdb to retrieve the packet that was being dissected" - print "\tat the time ethereal/tethereal stopped running. The packet" + print "\tat the time ethereal/tshark stopped running. The packet" print "\tis saved in the capture_file specified by the -w option." print "" print "\t-v : verbose" diff --git a/tshark.c b/tshark.c new file mode 100644 index 0000000000..fe1d24f910 --- /dev/null +++ b/tshark.c @@ -0,0 +1,3067 @@ +/* tshark.c + * + * $Id$ + * + * Wireshark - Network traffic analyzer + * By Gerald Combs + * Copyright 1998 Gerald Combs + * + * Text-mode variant, by Gilbert Ramirez + * and Guy Harris . + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include +#include +#include +#include +#include + +#ifdef HAVE_UNISTD_H +#include +#endif + +#include + +#ifdef HAVE_FCNTL_H +#include +#endif + +#include + +#ifdef HAVE_SYS_STAT_H +# include +#endif + +#ifdef NEED_STRERROR_H +#include "strerror.h" +#endif + +#ifdef NEED_GETOPT_H +#include "getopt.h" +#endif + +#include +#include +#include +#include +#include + +#include "globals.h" +#include +#include +#include "file.h" +#include "disabled_protos.h" +#include +#include +#include "print.h" +#include +#include "util.h" +#include "clopts_common.h" +#include "cmdarg_err.h" +#include "version_info.h" +#include +#include +#include "register.h" +#include "conditions.h" +#include "capture_stop_conditions.h" +#include "ringbuffer.h" +#include "capture_ui_utils.h" +#include +#include +#include +#include +#include + +#ifdef HAVE_LIBPCAP +#include +#include +#include "capture-pcap-util.h" +#include "pcapio.h" +#include +#ifdef _WIN32 +#include "capture-wpcap.h" +#include "capture_errs.h" +#endif /* _WIN32 */ +#include "capture.h" +#include "capture_loop.h" +#include "capture_sync.h" +#endif /* HAVE_LIBPCAP */ +#include "epan/emem.h" +#include "log.h" +#include + +/* + * This is the template for the decode as option; it is shared between the + * various functions that output the usage for this parameter. + */ +static const gchar decode_as_arg_template[] = "==,"; + +static nstime_t first_ts; +static nstime_t prev_ts; +static GString *comp_info_str, *runtime_info_str; + +static gboolean print_packet_info; /* TRUE if we're to print packet information */ +/* + * The way the packet decode is to be written. + */ +typedef enum { + WRITE_TEXT, /* summary or detail text */ + WRITE_XML /* PDML or PSML */ + /* Add CSV and the like here */ +} output_action_e; +static output_action_e output_action; +static gboolean do_dissection; /* TRUE if we have to dissect each packet */ +static gboolean verbose; +static gboolean print_hex; +static gboolean line_buffered; +static guint32 cum_bytes = 0; +static print_format_e print_format = PR_FMT_TEXT; +static print_stream_t *print_stream; + +/* + * Standard secondary message for unexpected errors. + */ +static const char please_report[] = + "Please report this to the Wireshark developers"; + +#ifdef HAVE_LIBPCAP +/* + * TRUE if we're to print packet counts to keep track of captured packets. + */ +static gboolean print_packet_counts; + + +static loop_data ld; + +#ifdef HAVE_LIBPCAP +static capture_options capture_opts; + + +#ifdef SIGINFO +static gboolean infodelay; /* if TRUE, don't print capture info in SIGINFO handler */ +static gboolean infoprint; /* if TRUE, print capture info after clearing infodelay */ +#endif /* SIGINFO */ +#endif /* HAVE_LIBPCAP */ + + +static int capture(void); +static void capture_pcap_cb(u_char *, const struct pcap_pkthdr *, + const u_char *); +static void report_counts(void); +#ifdef _WIN32 +static BOOL WINAPI capture_cleanup(DWORD); +#else /* _WIN32 */ +static void capture_cleanup(int); +#ifdef SIGINFO +static void report_counts_siginfo(int); +#endif /* SIGINFO */ +#endif /* _WIN32 */ +#endif /* HAVE_LIBPCAP */ + +static int load_cap_file(capture_file *, char *, int); +static gboolean process_packet(capture_file *cf, long offset, + const struct wtap_pkthdr *whdr, union wtap_pseudo_header *pseudo_header, + const guchar *pd); +static void show_capture_file_io_error(const char *, int, gboolean); +static void show_print_file_io_error(int err); +static gboolean write_preamble(capture_file *cf); +static gboolean print_packet(capture_file *cf, epan_dissect_t *edt); +static gboolean write_finale(void); +static const char *cf_open_error_message(int err, gchar *err_info, + gboolean for_writing, int file_type); + +static void open_failure_message(const char *filename, int err, + gboolean for_writing); +static void failure_message(const char *msg_format, va_list ap); +static void read_failure_message(const char *filename, int err); + +capture_file cfile; + + +static void list_capture_types(void) { + int i; + + fprintf(stderr, "editcap: The available capture file types for \"F\":\n"); + for (i = 0; i < WTAP_NUM_FILE_TYPES; i++) { + if (wtap_dump_can_open(i)) + fprintf(stderr, " %s - %s\n", + wtap_file_type_short_string(i), wtap_file_type_string(i)); + } +} + +static void +print_usage(gboolean print_ver) +{ + FILE *output; + + if (print_ver) { + output = stdout; + fprintf(output, + "TShark " VERSION "%s\n" + "Dump and analyze network traffic.\n" + "See http://www.wireshark.com for more information.\n" + "\n" + "%s", + svnversion, get_copyright_info()); + } else { + output = stderr; + } + fprintf(output, "\n"); + fprintf(output, "Usage: tshark [options] ...\n"); + fprintf(output, "\n"); + +#ifdef HAVE_LIBPCAP + fprintf(output, "Capture interface:\n"); + fprintf(output, " -i name or idx of interface (def: first none loopback)\n"); + fprintf(output, " -f packet filter in libpcap filter syntax\n"); + fprintf(output, " -s packet snapshot length (def: 65535)\n"); + fprintf(output, " -p don't capture in promiscuous mode\n"); +#ifdef _WIN32 + fprintf(output, " -B size of kernel buffer (def: 1MB)\n"); +#endif + fprintf(output, " -y link layer type (def: first appropriate)\n"); + fprintf(output, " -D print list of interfaces and exit\n"); + fprintf(output, " -L print list of link-layer types of iface and exit\n"); + fprintf(output, "\n"); + fprintf(output, "Capture stop conditions:\n"); + fprintf(output, " -c stop after n packets (def: infinite)\n"); + fprintf(output, " -a ... duration:NUM - stop after NUM seconds\n"); + fprintf(output, " filesize:NUM - stop this file after NUM KB\n"); + fprintf(output, " files:NUM - stop after NUM files\n"); + /*fprintf(output, "\n");*/ + fprintf(output, "Capture output:\n"); + fprintf(output, " -b ... duration:NUM - switch to next file after NUM secs\n"); + fprintf(output, " filesize:NUM - switch to next file after NUM KB\n"); + fprintf(output, " files:NUM - ringbuffer: replace after NUM files\n"); +#endif /* HAVE_LIBPCAP */ + + /*fprintf(output, "\n");*/ + fprintf(output, "Input file:\n"); + fprintf(output, " -r set the filename to read from (no pipes or stdin!)\n"); + + fprintf(output, "\n"); + fprintf(output, "Processing:\n"); + fprintf(output, " -R packet filter in Wireshark display filter syntax\n"); + fprintf(output, " -n disable all name resolutions (def: all enabled)\n"); + fprintf(output, " -N enable specific name resolution(s): \"mntC\"\n"); + fprintf(output, " -d %s ...\n", decode_as_arg_template); + fprintf(output, " \"Decode As\", see the man page for details\n"); + fprintf(output, " Example: tcp.port==8888,http\n"); + + /*fprintf(output, "\n");*/ + fprintf(output, "Output:\n"); + fprintf(stderr, " -w set the output filename (or '-' for stdout)\n"); + fprintf(stderr, " -F set the output file type, default is libpcap\n"); + fprintf(stderr, " an empty \"-F\" option will list the file types\n"); + fprintf(output, " -V add output of packet tree (Packet Details)\n"); + fprintf(output, " -x add output of hex and ASCII dump (Packet Bytes)\n"); + fprintf(output, " -T pdml|ps|psml|text output format of text output (def: text)\n"); + fprintf(output, " -t ad|a|r|d output format of time stamps (def: r: rel. to first)\n"); + fprintf(output, " -l flush output after each packet\n"); + fprintf(output, " -q be more quiet on stdout (e.g. when using statistics)\n"); + fprintf(output, " -X : eXtension options, see the man page for details\n"); + fprintf(output, " -z various statistics, see the man page for details\n"); + + fprintf(output, "\n"); + fprintf(stderr, "Miscellaneous:\n"); + fprintf(stderr, " -h display this help and exit\n"); + fprintf(stderr, " -v display version info and exit\n"); + fprintf(output, " -o : ... override preference setting\n"); +} + +/* + * For a dissector table, print on the stream described by output, + * its short name (which is what's used in the "-d" option) and its + * descriptive name. + */ +static void +display_dissector_table_names(char *table_name, const char *ui_name, + gpointer output) +{ + fprintf((FILE *)output, "\t%s (%s)\n", table_name, ui_name); +} + +/* + * For a dissector handle, print on the stream described by output, + * the filter name (which is what's used in the "-d" option) and the full + * name for the protocol that corresponds to this handle. + */ +static void +display_dissector_names(const gchar *table _U_, gpointer handle, gpointer output) +{ + int proto_id; + const gchar* proto_filter_name; + const gchar* proto_ui_name; + + proto_id = dissector_handle_get_protocol_index((dissector_handle_t)handle); + + if (proto_id != -1) { + proto_filter_name = proto_get_protocol_filter_name(proto_id); + proto_ui_name = proto_get_protocol_name(proto_id); + g_assert(proto_filter_name != NULL); + g_assert(proto_ui_name != NULL); + + fprintf((FILE *)output, "\t%s (%s)\n", + proto_filter_name, + proto_ui_name); + } +} + +/* + * The protocol_name_search structure is used by find_protocol_name_func() + * to pass parameters and store results + */ +struct protocol_name_search{ + gchar *searched_name; /* Protocol filter name we are looking for */ + dissector_handle_t matched_handle; /* Handle for a dissector whose protocol has the specified filter name */ + guint nb_match; /* How many dissectors matched searched_name */ +}; +typedef struct protocol_name_search *protocol_name_search_t; + +/* + * This function parses all dissectors associated with a table to find the + * one whose protocol has the specified filter name. It is called + * as a reference function in a call to dissector_table_foreach_handle. + * The name we are looking for, as well as the results, are stored in the + * protocol_name_search struct pointed to by user_data. + * If called using dissector_table_foreach_handle, we actually parse the + * whole list of dissectors. + */ +static void +find_protocol_name_func(const gchar *table _U_, gpointer handle, gpointer user_data) + +{ + int proto_id; + const gchar *protocol_filter_name; + protocol_name_search_t search_info; + + g_assert(handle); + + search_info = (protocol_name_search_t)user_data; + + proto_id = dissector_handle_get_protocol_index((dissector_handle_t)handle); + if (proto_id != -1) { + protocol_filter_name = proto_get_protocol_filter_name(proto_id); + g_assert(protocol_filter_name != NULL); + if (strcmp(protocol_filter_name, search_info->searched_name) == 0) { + /* Found a match */ + if (search_info->nb_match == 0) { + /* Record this handle only if this is the first match */ + search_info->matched_handle = (dissector_handle_t)handle; /* Record the handle for this matching dissector */ + } + search_info->nb_match++; + } + } +} + +/* + * Print all layer type names supported. + * We send the output to the stream described by the handle output. + */ + +static void +fprint_all_layer_types(FILE *output) + +{ + dissector_all_tables_foreach_table(display_dissector_table_names, (gpointer)output); +} + +/* + * Print all protocol names supported for a specific layer type. + * table_name contains the layer type name in which the search is performed. + * We send the output to the stream described by the handle output. + */ + +static void +fprint_all_protocols_for_layer_types(FILE *output, gchar *table_name) + +{ + dissector_table_foreach_handle(table_name, + display_dissector_names, + (gpointer)output); +} + +/* + * The function below parses the command-line parameters for the decode as + * feature (a string pointer by cl_param). + * It checks the format of the command-line, searches for a matching table + * and dissector. If a table/dissector match is not found, we display a + * summary of the available tables/dissectors (on stderr) and return FALSE. + * If everything is fine, we get the "Decode as" preference activated, + * then we return TRUE. + */ +static gboolean +add_decode_as(const gchar *cl_param) +{ + gchar *table_name; + guint32 selector; + gchar *decoded_param; + gchar *remaining_param; + gchar *selector_str; + gchar *dissector_str; + dissector_handle_t dissector_matching; + dissector_table_t table_matching; + ftenum_t dissector_table_selector_type; + struct protocol_name_search user_protocol_name; + +/* The following code will allocate and copy the command-line options in a string pointed by decoded_param */ + + g_assert(cl_param); + decoded_param = g_malloc( sizeof(gchar) * (strlen(cl_param) + 1) ); /* Allocate enough space to have a working copy of the command-line parameter */ + g_assert(decoded_param); + strcpy(decoded_param, cl_param); + + + /* The lines below will parse this string (modifying it) to extract all + necessary information. Note that decoded_param is still needed since + strings are not copied - we just save pointers. */ + + /* This section extracts a layer type (table_name) from decoded_param */ + table_name = decoded_param; /* Layer type string starts from beginning */ + + remaining_param = strchr(table_name, '='); + if (remaining_param == NULL) { + cmdarg_err("Parameter \"%s\" doesn't follow the template \"%s\"", cl_param, decode_as_arg_template); + /* If the argument does not follow the template, carry on anyway to check + if the table name is at least correct. If remaining_param is NULL, + we'll exit anyway further down */ + } + else { + *remaining_param = '\0'; /* Terminate the layer type string (table_name) where '=' was detected */ + } + + /* Remove leading and trailing spaces from the table name */ + while ( table_name[0] == ' ' ) + table_name++; + while ( table_name[strlen(table_name) - 1] == ' ' ) + table_name[strlen(table_name) - 1] = '\0'; /* Note: if empty string, while loop will eventually exit */ + +/* The following part searches a table matching with the layer type specified */ + table_matching = NULL; + +/* Look for the requested table */ + if ( !(*(table_name)) ) { /* Is the table name empty, if so, don't even search for anything, display a message */ + cmdarg_err("No layer type specified"); /* Note, we don't exit here, but table_matching will remain NULL, so we exit below */ + } + else { + table_matching = find_dissector_table(table_name); + if (!table_matching) { + cmdarg_err("Unknown layer type -- %s", table_name); /* Note, we don't exit here, but table_matching will remain NULL, so we exit below */ + } + } + + if (!table_matching) { + /* Display a list of supported layer types to help the user, if the + specified layer type was not found */ + cmdarg_err("Valid layer types are:"); + fprint_all_layer_types(stderr); + } + if (remaining_param == NULL || !table_matching) { + /* Exit if the layer type was not found, or if no '=' separator was found + (see above) */ + g_free(decoded_param); + return FALSE; + } + + if (*(remaining_param + 1) != '=') { /* Check for "==" and not only '=' */ + cmdarg_err("WARNING: -d requires \"==\" instead of \"=\". Option will be treated as \"%s==%s\"", table_name, remaining_param + 1); + } + else { + remaining_param++; /* Move to the second '=' */ + *remaining_param = '\0'; /* Remove the second '=' */ + } + remaining_param++; /* Position after the layer type string */ + + /* This section extracts a selector value (selector_str) from decoded_param */ + + selector_str = remaining_param; /* Next part starts with the selector number */ + + remaining_param = strchr(selector_str, ','); + if (remaining_param == NULL) { + cmdarg_err("Parameter \"%s\" doesn't follow the template \"%s\"", cl_param, decode_as_arg_template); + /* If the argument does not follow the template, carry on anyway to check + if the selector value is at least correct. If remaining_param is NULL, + we'll exit anyway further down */ + } + else { + *remaining_param = '\0'; /* Terminate the selector number string (selector_str) where ',' was detected */ + } + + dissector_table_selector_type = get_dissector_table_selector_type(table_name); + + switch (dissector_table_selector_type) { + + case FT_UINT8: + case FT_UINT16: + case FT_UINT24: + case FT_UINT32: + /* The selector for this table is an unsigned number. Parse it as such. + There's no need to remove leading and trailing spaces from the + selector number string, because sscanf will do that for us. */ + if ( sscanf(selector_str, "%u", &selector) != 1 ) { + cmdarg_err("Invalid selector number \"%s\"", selector_str); + g_free(decoded_param); + return FALSE; + } + break; + + case FT_STRING: + case FT_STRINGZ: + /* The selector for this table is a string. */ + break; + + default: + /* There are currently no dissector tables with any types other + than the ones listed above. */ + g_assert_not_reached(); + } + + if (remaining_param == NULL) { + /* Exit if no ',' separator was found (see above) */ + cmdarg_err("Valid protocols for layer type \"%s\" are:", table_name); + fprint_all_protocols_for_layer_types(stderr, table_name); + g_free(decoded_param); + return FALSE; + } + + remaining_param++; /* Position after the selector number string */ + + /* This section extracts a protocol filter name (dissector_str) from decoded_param */ + + dissector_str = remaining_param; /* All the rest of the string is the dissector (decode as protocol) name */ + + /* Remove leading and trailing spaces from the dissector name */ + while ( dissector_str[0] == ' ' ) + dissector_str++; + while ( dissector_str[strlen(dissector_str) - 1] == ' ' ) + dissector_str[strlen(dissector_str) - 1] = '\0'; /* Note: if empty string, while loop will eventually exit */ + + dissector_matching = NULL; + + /* We now have a pointer to the handle for the requested table inside the variable table_matching */ + if ( ! (*dissector_str) ) { /* Is the dissector name empty, if so, don't even search for a matching dissector and display all dissectors found for the selected table */ + cmdarg_err("No protocol name specified"); /* Note, we don't exit here, but dissector_matching will remain NULL, so we exit below */ + } + else { + user_protocol_name.nb_match = 0; + user_protocol_name.searched_name = dissector_str; + user_protocol_name.matched_handle = NULL; + + dissector_table_foreach_handle(table_name, find_protocol_name_func, &user_protocol_name); /* Go and perform the search for this dissector in the this table's dissectors' names and shortnames */ + + if (user_protocol_name.nb_match != 0) { + dissector_matching = user_protocol_name.matched_handle; + if (user_protocol_name.nb_match > 1) { + cmdarg_err("WARNING: Protocol \"%s\" matched %u dissectors, first one will be used", dissector_str, user_protocol_name.nb_match); + } + } + else { + /* OK, check whether the problem is that there isn't any such + protocol, or that there is but it's not specified as a protocol + that's valid for that dissector table. + Note, we don't exit here, but dissector_matching will remain NULL, + so we exit below */ + if (proto_get_id_by_filter_name(dissector_str) == -1) { + /* No such protocol */ + cmdarg_err("Unknown protocol -- \"%s\"", dissector_str); + } else { + cmdarg_err("Protocol \"%s\" isn't valid for layer type \"%s\"", + dissector_str, table_name); + } + } + } + + if (!dissector_matching) { + cmdarg_err("Valid protocols for layer type \"%s\" are:", table_name); + fprint_all_protocols_for_layer_types(stderr, table_name); + g_free(decoded_param); + return FALSE; + } + +/* This is the end of the code that parses the command-line options. + All information is now stored in the variables: + table_name + selector + dissector_matching + The above variables that are strings are still pointing to areas within + decoded_parm. decoded_parm thus still needs to be kept allocated in + until we stop needing these variables + decoded_param will be deallocated at each exit point of this function */ + + + /* We now have a pointer to the handle for the requested dissector + (requested protocol) inside the variable dissector_matching */ + switch (dissector_table_selector_type) { + + case FT_UINT8: + case FT_UINT16: + case FT_UINT24: + case FT_UINT32: + /* The selector for this table is an unsigned number. */ + dissector_change(table_name, selector, dissector_matching); + break; + + case FT_STRING: + case FT_STRINGZ: + /* The selector for this table is a string. */ + dissector_change_string(table_name, selector_str, dissector_matching); + break; + + default: + /* There are currently no dissector tables with any types other + than the ones listed above. */ + g_assert_not_reached(); + } + g_free(decoded_param); /* "Decode As" rule has been succesfully added */ + return TRUE; +} + +static void +log_func_ignore (const gchar *log_domain _U_, GLogLevelFlags log_level _U_, + const gchar *message _U_, gpointer user_data _U_) +{ +} + +static char * +output_file_description(const char *fname) +{ + char *save_file_string; + + /* Get a string that describes what we're writing to */ + if (strcmp(fname, "-") == 0) { + /* We're writing to the standard output */ + save_file_string = g_strdup("standard output"); + } else { + /* We're writing to a file with the name in save_file */ + save_file_string = g_strdup_printf("file \"%s\"", fname); + } + return save_file_string; +} + +int +main(int argc, char *argv[]) +{ + int opt, i; + extern char *optarg; + gboolean arg_error = FALSE; + +#ifdef _WIN32 + WSADATA wsaData; +#endif /* _WIN32 */ + + char *gpf_path, *pf_path; + char *gdp_path, *dp_path; + int gpf_open_errno, gpf_read_errno; + int pf_open_errno, pf_read_errno; + int gdp_open_errno, gdp_read_errno; + int dp_open_errno, dp_read_errno; + int err; +#ifdef HAVE_LIBPCAP + gboolean capture_filter_specified = FALSE; + gboolean list_link_layer_types = FALSE; + gboolean start_capture = FALSE; +#else + gboolean capture_option_specified = FALSE; +#endif + gboolean quiet = FALSE; + int out_file_type = WTAP_FILE_PCAP; + gchar *cf_name = NULL, *rfilter = NULL; +#ifdef HAVE_PCAP_OPEN_DEAD + struct bpf_program fcode; +#endif + dfilter_t *rfcode = NULL; + e_prefs *prefs; + char badopt; + GLogLevelFlags log_flags; + int status; + +#define OPTSTRING_INIT "a:b:c:d:Df:F:hi:lLnN:o:pqr:R:s:St:T:vVw:xX:y:z:" +#ifdef HAVE_LIBPCAP +#ifdef _WIN32 +#define OPTSTRING_WIN32 "B:" +#else +#define OPTSTRING_WIN32 "" +#endif /* _WIN32 */ +#else +#define OPTSTRING_WIN32 "" +#endif /* HAVE_LIBPCAP */ + + static const char optstring[] = OPTSTRING_INIT OPTSTRING_WIN32; + + /* + * Get credential information for later use. + */ + get_credential_info(); + + /* nothing more than the standard GLib handler, but without a warning */ + log_flags = + G_LOG_LEVEL_ERROR| + G_LOG_LEVEL_CRITICAL| + G_LOG_LEVEL_WARNING| + G_LOG_LEVEL_MESSAGE| + G_LOG_LEVEL_INFO| + G_LOG_LEVEL_DEBUG| + G_LOG_FLAG_FATAL|G_LOG_FLAG_RECURSION; + + g_log_set_handler(NULL, + log_flags, + log_func_ignore, NULL /* user_data */); + g_log_set_handler(LOG_DOMAIN_CAPTURE_CHILD, + log_flags, + log_func_ignore, NULL /* user_data */); + + /* initialize memory allocation subsystem */ + ep_init_chunk(); + se_init_chunk(); + + initialize_funnel_ops(); + +#ifdef HAVE_LIBPCAP + capture_opts_init(&capture_opts, NULL /* cfile */); +#endif + + timestamp_set_type(TS_RELATIVE); + timestamp_set_precision(TS_PREC_AUTO); + + /* Register all dissectors; we must do this before checking for the + "-G" flag, as the "-G" flag dumps information registered by the + dissectors, and we must do it before we read the preferences, in + case any dissectors register preferences. */ + epan_init(PLUGIN_DIR,register_all_protocols,register_all_protocol_handoffs, + failure_message,open_failure_message,read_failure_message); + + /* Register all tap listeners; we do this before we parse the arguments, + as the "-z" argument can specify a registered tap. */ + + /* we register the plugin taps before the other taps because + stats_tree taps plugins will be registered as tap listeners + by stats_tree_stat.c and need to registered before that */ +#ifdef HAVE_PLUGINS + register_all_plugin_tap_listeners(); +#endif + register_all_tap_listeners(); + + /* Now register the preferences for any non-dissector modules. + We must do that before we read the preferences as well. */ + prefs_register_modules(); + + /* If invoked with the "-G" flag, we dump out information based on + the argument to the "-G" flag; if no argument is specified, + for backwards compatibility we dump out a glossary of display + filter symbols. + + XXX - we do this here, for now, to support "-G" with no arguments. + If none of our build or other processes uses "-G" with no arguments, + we can just process it with the other arguments. */ + if (argc >= 2 && strcmp(argv[1], "-G") == 0) { + if (argc == 2) + proto_registrar_dump_fields(1); + else { + if (strcmp(argv[2], "fields") == 0) + proto_registrar_dump_fields(1); + else if (strcmp(argv[2], "fields2") == 0) + proto_registrar_dump_fields(2); + else if (strcmp(argv[2], "fields3") == 0) + proto_registrar_dump_fields(3); + else if (strcmp(argv[2], "protocols") == 0) + proto_registrar_dump_protocols(); + else if (strcmp(argv[2], "values") == 0) + proto_registrar_dump_values(); + else if (strcmp(argv[2], "decodes") == 0) + dissector_dump_decodes(); + else if (strcmp(argv[2], "defaultprefs") == 0) + write_prefs(NULL); + else if (strcmp(argv[2], "currentprefs") == 0) { + read_prefs(&gpf_open_errno, &gpf_read_errno, &gpf_path, + &pf_open_errno, &pf_read_errno, &pf_path); + write_prefs(NULL); + } else { + cmdarg_err("Invalid \"%s\" option for -G flag", argv[2]); + exit(1); + } + } + exit(0); + } + + /* Set the C-language locale to the native environment. */ + setlocale(LC_ALL, ""); + + prefs = read_prefs(&gpf_open_errno, &gpf_read_errno, &gpf_path, + &pf_open_errno, &pf_read_errno, &pf_path); + if (gpf_path != NULL) { + if (gpf_open_errno != 0) { + cmdarg_err("Can't open global preferences file \"%s\": %s.", + pf_path, strerror(gpf_open_errno)); + } + if (gpf_read_errno != 0) { + cmdarg_err("I/O error reading global preferences file \"%s\": %s.", + pf_path, strerror(gpf_read_errno)); + } + } + if (pf_path != NULL) { + if (pf_open_errno != 0) { + cmdarg_err("Can't open your preferences file \"%s\": %s.", pf_path, + strerror(pf_open_errno)); + } + if (pf_read_errno != 0) { + cmdarg_err("I/O error reading your preferences file \"%s\": %s.", + pf_path, strerror(pf_read_errno)); + } + g_free(pf_path); + pf_path = NULL; + } + + /* Set the name resolution code's flags from the preferences. */ + g_resolv_flags = prefs->name_resolve; + + /* Read the disabled protocols file. */ + read_disabled_protos_list(&gdp_path, &gdp_open_errno, &gdp_read_errno, + &dp_path, &dp_open_errno, &dp_read_errno); + if (gdp_path != NULL) { + if (gdp_open_errno != 0) { + cmdarg_err("Could not open global disabled protocols file\n\"%s\": %s.", + gdp_path, strerror(gdp_open_errno)); + } + if (gdp_read_errno != 0) { + cmdarg_err("I/O error reading global disabled protocols file\n\"%s\": %s.", + gdp_path, strerror(gdp_read_errno)); + } + g_free(gdp_path); + } + if (dp_path != NULL) { + if (dp_open_errno != 0) { + cmdarg_err( + "Could not open your disabled protocols file\n\"%s\": %s.", dp_path, + strerror(dp_open_errno)); + } + if (dp_read_errno != 0) { + cmdarg_err( + "I/O error reading your disabled protocols file\n\"%s\": %s.", dp_path, + strerror(dp_read_errno)); + } + g_free(dp_path); + } + +#ifdef _WIN32 + /* Load Wpcap, if possible */ + load_wpcap(); +#endif + + init_cap_file(&cfile); + + /* Assemble the compile-time version information string */ + comp_info_str = g_string_new("Compiled "); + get_compiled_version_info(comp_info_str); + + /* Assemble the run-time version information string */ + runtime_info_str = g_string_new("Running "); + get_runtime_version_info(runtime_info_str); + + /* Print format defaults to this. */ + print_format = PR_FMT_TEXT; + + /* Now get our args */ + while ((opt = getopt(argc, argv, optstring)) != -1) { + switch (opt) { + case 'a': /* autostop criteria */ + case 'b': /* Ringbuffer option */ + case 'c': /* Capture xxx packets */ + case 'f': /* capture filter */ + case 'i': /* Use interface xxx */ + case 'p': /* Don't capture in promiscuous mode */ + case 's': /* Set the snapshot (capture) length */ + case 'w': /* Write to capture file xxx */ + case 'y': /* Set the pcap data link type */ +#ifdef _WIN32 + case 'B': /* Buffer size */ +#endif /* _WIN32 */ +#ifdef HAVE_LIBPCAP + status = capture_opts_add_opt(&capture_opts, opt, optarg, &start_capture); + if(status != 0) { + exit(status); + } +#else + capture_option_specified = TRUE; + arg_error = TRUE; +#endif + break; + case 'd': /* Decode as rule */ + if (!add_decode_as(optarg)) + exit(1); + break; + case 'D': /* Print a list of capture devices and exit */ +#ifdef HAVE_LIBPCAP + status = capture_opts_list_interfaces(); + exit(status); +#else + capture_option_specified = TRUE; + arg_error = TRUE; +#endif + break; + case 'F': + out_file_type = wtap_short_string_to_file_type(optarg); + if (out_file_type < 0) { + cmdarg_err("\"%s\" isn't a valid capture file type", optarg); + list_capture_types(); + exit(1); + } + break; + case 'h': /* Print help and exit */ + print_usage(TRUE); + exit(0); + break; + case 'l': /* "Line-buffer" standard output */ + /* This isn't line-buffering, strictly speaking, it's just + flushing the standard output after the information for + each packet is printed; however, that should be good + enough for all the purposes to which "-l" is put (and + is probably actually better for "-V", as it does fewer + writes). + + See the comment in "process_packet()" for an explanation of + why we do that, and why we don't just use "setvbuf()" to + make the standard output line-buffered (short version: in + Windows, "line-buffered" is the same as "fully-buffered", + and the output buffer is only flushed when it fills up). */ + line_buffered = TRUE; + break; + case 'L': /* Print list of link-layer types and exit */ +#ifdef HAVE_LIBPCAP + list_link_layer_types = TRUE; + break; +#else + capture_option_specified = TRUE; + arg_error = TRUE; +#endif + break; + case 'n': /* No name resolution */ + g_resolv_flags = RESOLV_NONE; + break; + case 'N': /* Select what types of addresses/port #s to resolve */ + if (g_resolv_flags == RESOLV_ALL) + g_resolv_flags = RESOLV_NONE; + badopt = string_to_name_resolve(optarg, &g_resolv_flags); + if (badopt != '\0') { + cmdarg_err("-N specifies unknown resolving option '%c'; valid options are 'm', 'n', and 't'", + badopt); + exit(1); + } + break; + case 'o': /* Override preference from command line */ + switch (prefs_set_pref(optarg)) { + + case PREFS_SET_SYNTAX_ERR: + cmdarg_err("Invalid -o flag \"%s\"", optarg); + exit(1); + break; + + case PREFS_SET_NO_SUCH_PREF: + case PREFS_SET_OBSOLETE: + cmdarg_err("-o flag \"%s\" specifies unknown preference", optarg); + exit(1); + break; + } + break; + case 'q': /* Quiet */ + quiet = TRUE; + break; + case 'r': /* Read capture file xxx */ + cf_name = g_strdup(optarg); + break; + case 'R': /* Read file filter */ + rfilter = optarg; + break; + case 'S': /* show packets in real time */ + print_packet_info = TRUE; + break; + case 't': /* Time stamp type */ + if (strcmp(optarg, "r") == 0) + timestamp_set_type(TS_RELATIVE); + else if (strcmp(optarg, "a") == 0) + timestamp_set_type(TS_ABSOLUTE); + else if (strcmp(optarg, "ad") == 0) + timestamp_set_type(TS_ABSOLUTE_WITH_DATE); + else if (strcmp(optarg, "d") == 0) + timestamp_set_type(TS_DELTA); + else { + cmdarg_err("Invalid time stamp type \"%s\"", + optarg); + cmdarg_err_cont("It must be \"r\" for relative, \"a\" for absolute,"); + cmdarg_err_cont("\"ad\" for absolute with date, or \"d\" for delta."); + exit(1); + } + break; + case 'T': /* printing Type */ + if (strcmp(optarg, "text") == 0) { + output_action = WRITE_TEXT; + print_format = PR_FMT_TEXT; + } else if (strcmp(optarg, "ps") == 0) { + output_action = WRITE_TEXT; + print_format = PR_FMT_PS; + } else if (strcmp(optarg, "pdml") == 0) { + output_action = WRITE_XML; + verbose = TRUE; + } else if (strcmp(optarg, "psml") == 0) { + output_action = WRITE_XML; + verbose = FALSE; + } else { + cmdarg_err("Invalid -T parameter."); + cmdarg_err_cont("It must be \"ps\", \"text\", \"pdml\", or \"psml\"."); + exit(1); + } + break; + case 'v': /* Show version and exit */ + printf("TShark " VERSION "%s\n" + "\n" + "%s" + "\n" + "%s" + "\n" + "%s", + svnversion, get_copyright_info(), comp_info_str->str, + runtime_info_str->str); + exit(0); + break; + case 'V': /* Verbose */ + verbose = TRUE; + break; + case 'x': /* Print packet data in hex (and ASCII) */ + print_hex = TRUE; + break; + case 'X': + ex_opt_add(optarg); + break; + case 'z': + /* We won't call the init function for the stat this soon + as it would disallow MATE's fields (which are registered + by the preferences set callback) from being used as + part of a tap filter. Instead, we just add the argument + to a list of stat arguments. */ + if (!process_stat_cmd_arg(optarg)) { + cmdarg_err("invalid -z argument."); + cmdarg_err_cont(" -z argument must be one of :"); + list_stat_cmd_args(); + exit(1); + } + break; + default: + case '?': /* Bad flag - print usage message */ + switch(optopt) { + case'F': + list_capture_types(); + break; + default: + print_usage(TRUE); + } + exit(1); + break; + } + } + + /* If no capture filter or read filter has been specified, and there are + still command-line arguments, treat them as the tokens of a capture + filter (if no "-r" flag was specified) or a read filter (if a "-r" + flag was specified. */ + if (optind < argc) { + if (cf_name != NULL) { + if (rfilter != NULL) { + cmdarg_err("Read filters were specified both with \"-R\" " + "and with additional command-line arguments"); + exit(1); + } + rfilter = get_args_as_string(argc, argv, optind); + } else { +#ifdef HAVE_LIBPCAP + if (capture_filter_specified) { + cmdarg_err("Capture filters were specified both with \"-f\"" + " and with additional command-line arguments"); + exit(1); + } + capture_opts.cfilter = get_args_as_string(argc, argv, optind); +#else + capture_option_specified = TRUE; +#endif + } + } + + if (!capture_opts.saving_to_file) { + /* We're not saving the capture to a file; if "-q" wasn't specified, + we should print packet information */ + if (!quiet) + print_packet_info = TRUE; + } else { + /* We're saving to a file; if we're writing to the standard output. + and we'll also be writing dissected packets to the standard + output, reject the request. At best, we could redirect that + to the standard error; we *can't* write both to the standard + output and have either of them be useful. */ + if (strcmp(capture_opts.save_file, "-") == 0 && print_packet_info) { + cmdarg_err("You can't write both raw packet data and dissected packets" + " to the standard output."); + exit(1); + } + } + +#ifndef HAVE_LIBPCAP + if (capture_option_specified) + cmdarg_err("This version of TShark was not built with support for capturing packets."); +#endif + if (arg_error) { + print_usage(FALSE); + exit(1); + } + + /* We don't support capture filters when reading from a capture file + (the BPF compiler doesn't support all link-layer types that we + support in capture files we read). */ +#ifdef HAVE_LIBPCAP + if (cf_name != NULL) { + if (capture_filter_specified) { + cmdarg_err("Only read filters, not capture filters, " + "can be specified when reading a capture file."); + exit(1); + } + } +#endif + + if (print_hex) { + if (output_action != WRITE_TEXT) { + cmdarg_err("Raw packet hex data can only be printed as text or PostScript"); + exit(1); + } + } + +#ifdef HAVE_LIBPCAP + if (list_link_layer_types) { + /* We're supposed to list the link-layer types for an interface; + did the user also specify a capture file to be read? */ + if (cf_name) { + /* Yes - that's bogus. */ + cmdarg_err("You can't specify -L and a capture file to be read."); + exit(1); + } + /* No - did they specify a ring buffer option? */ + if (capture_opts.multi_files_on) { + cmdarg_err("Ring buffer requested, but a capture isn't being done."); + exit(1); + } + } else { + /* If they didn't specify a "-w" flag, but specified a maximum capture + file size, tell them that this doesn't work, and exit. */ + if (capture_opts.has_autostop_filesize && capture_opts.save_file == NULL) { + cmdarg_err("Maximum capture file size specified, but " + "capture isn't being saved to a file."); + exit(1); + } + + if (cf_name) { + /* + * "-r" was specified, so we're reading a capture file. + * Capture options don't apply here. + */ + if (capture_opts.multi_files_on) { + cmdarg_err("Multiple capture files requested, but " + "a capture isn't being done."); + exit(1); + } + if (capture_opts.has_file_duration) { + cmdarg_err("Switching capture files after a time interval was specified, but " + "a capture isn't being done."); + exit(1); + } + if (capture_opts.has_ring_num_files) { + cmdarg_err("A ring buffer of capture files was specified, but " + "a capture isn't being done."); + exit(1); + } + if (capture_opts.has_autostop_files) { + cmdarg_err("A maximum number of capture files was specified, but " + "a capture isn't being done."); + exit(1); + } + if (capture_opts.has_autostop_packets) { + cmdarg_err("A maximum number of captured packets was specified, but " + "a capture isn't being done."); + exit(1); + } + if (capture_opts.has_autostop_filesize) { + cmdarg_err("A maximum capture file size was specified, but " + "a capture isn't being done."); + exit(1); + } + if (capture_opts.has_autostop_duration) { + cmdarg_err("A maximum capture time was specified, but " + "a capture isn't being done."); + exit(1); + } + } else { + /* + * "-r" wasn't specified, so we're doing a live capture. + */ + if (capture_opts.saving_to_file) { + /* They specified a "-w" flag, so we'll be saving to a capture file. */ + + /* When capturing, we only support writing libpcap format. */ + if (out_file_type != WTAP_FILE_PCAP) { + cmdarg_err("Live captures can only be saved in libpcap format."); + exit(1); + } + if (capture_opts.multi_files_on) { + /* Multiple-file mode works only under certain conditions: + a) it doesn't work if you're writing to the standard output; + b) it doesn't work if you're writing to a pipe; + c) it makes no sense if the maximum file size is set to "infinite" + (XXX - shouldn't that be "if there is no stop criterion", + as you might want to switch files based on a packet count + or a time). */ + if (strcmp(capture_opts.save_file, "-") == 0) { + cmdarg_err("Multiple capture files requested, but " + "the capture is being written to the standard output."); + exit(1); + } + if (capture_opts.output_to_pipe) { + cmdarg_err("Multiple capture files requested, but " + "the capture file is a pipe."); + exit(1); + } + if (!capture_opts.has_autostop_filesize) { + cmdarg_err("Multiple capture files requested, but " + "no maximum capture file size was specified."); + exit(1); + } + } + } else { + /* They didn't specify a "-w" flag, so we won't be saving to a + capture file. Check for options that only make sense if + we're saving to a file. */ + if (capture_opts.has_autostop_filesize) { + cmdarg_err("Maximum capture file size specified, but " + "capture isn't being saved to a file."); + exit(1); + } + if (capture_opts.multi_files_on) { + cmdarg_err("Multiple capture files requested, but " + "the capture isn't being saved to a file."); + exit(1); + } + } + } + } +#endif + +#ifdef _WIN32 + /* Start windows sockets */ + WSAStartup( MAKEWORD( 1, 1 ), &wsaData ); +#endif /* _WIN32 */ + + /* Notify all registered modules that have had any of their preferences + changed either from one of the preferences file or from the command + line that their preferences have changed. */ + prefs_apply_all(); + + /* At this point MATE will have registered its field array so we can + have a tap filter with one of MATE's late-registered fields as part + of the filter. We can now process all the "-z" arguments. */ + start_requested_stats(); + + /* disabled protocols as per configuration file */ + if (gdp_path == NULL && dp_path == NULL) { + set_disabled_protos_list(); + } + + /* Build the column format array */ + col_setup(&cfile.cinfo, prefs->num_cols); + for (i = 0; i < cfile.cinfo.num_cols; i++) { + cfile.cinfo.col_fmt[i] = get_column_format(i); + cfile.cinfo.col_title[i] = g_strdup(get_column_title(i)); + cfile.cinfo.fmt_matx[i] = (gboolean *) g_malloc0(sizeof(gboolean) * + NUM_COL_FMTS); + get_column_format_matches(cfile.cinfo.fmt_matx[i], cfile.cinfo.col_fmt[i]); + cfile.cinfo.col_data[i] = NULL; + if (cfile.cinfo.col_fmt[i] == COL_INFO) + cfile.cinfo.col_buf[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_INFO_LEN); + else + cfile.cinfo.col_buf[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN); + cfile.cinfo.col_fence[i] = 0; + cfile.cinfo.col_expr[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN); + cfile.cinfo.col_expr_val[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN); + } + + for (i = 0; i < cfile.cinfo.num_cols; i++) { + int j; + + for (j = 0; j < NUM_COL_FMTS; j++) { + if (!cfile.cinfo.fmt_matx[i][j]) + continue; + + if (cfile.cinfo.col_first[j] == -1) + cfile.cinfo.col_first[j] = i; + cfile.cinfo.col_last[j] = i; + } + } + +#ifdef HAVE_LIBPCAP + capture_opts_trim_snaplen(&capture_opts, MIN_PACKET_SIZE); + capture_opts_trim_ring_num_files(&capture_opts); +#endif + + if (rfilter != NULL) { + if (!dfilter_compile(rfilter, &rfcode)) { + cmdarg_err("%s", dfilter_error_msg); + epan_cleanup(); +#ifdef HAVE_PCAP_OPEN_DEAD + { + pcap_t *pc; + + pc = pcap_open_dead(DLT_EN10MB, MIN_PACKET_SIZE); + if (pc != NULL) { + if (pcap_compile(pc, &fcode, rfilter, 0, 0) != -1) { + cmdarg_err_cont( + " Note: That display filter code looks like a valid capture filter;"); + cmdarg_err_cont( + " maybe you mixed them up?"); + } + pcap_close(pc); + } + } +#endif + exit(2); + } + } + cfile.rfcode = rfcode; + + if (print_packet_info) { + /* If we're printing as text or PostScript, we have + to create a print stream. */ + if (output_action == WRITE_TEXT) { + switch (print_format) { + + case PR_FMT_TEXT: + print_stream = print_stream_text_stdio_new(stdout); + break; + + case PR_FMT_PS: + print_stream = print_stream_ps_stdio_new(stdout); + break; + + default: + g_assert_not_reached(); + } + } + } + + /* We have to dissect each packet if: + + we're printing information about each packet; + + we're using a read filter on the packets; + + we're using any taps. */ + do_dissection = print_packet_info || rfcode || have_tap_listeners(); + + if (cf_name) { + /* + * We're reading a capture file. + */ + + /* + * Immediately relinquish any special privileges we have; we must not + * be allowed to read any capture files the user running TShark + * can't open. + */ + relinquish_special_privs_perm(); + + if (cf_open(&cfile, cf_name, FALSE, &err) != CF_OK) { + epan_cleanup(); + exit(2); + } + + /* Set timestamp precision; there should arguably be a command-line + option to let the user set this. */ + switch(wtap_file_tsprecision(cfile.wth)) { + case(WTAP_FILE_TSPREC_SEC): + timestamp_set_precision(TS_PREC_AUTO_SEC); + break; + case(WTAP_FILE_TSPREC_DSEC): + timestamp_set_precision(TS_PREC_AUTO_DSEC); + break; + case(WTAP_FILE_TSPREC_CSEC): + timestamp_set_precision(TS_PREC_AUTO_CSEC); + break; + case(WTAP_FILE_TSPREC_MSEC): + timestamp_set_precision(TS_PREC_AUTO_MSEC); + break; + case(WTAP_FILE_TSPREC_USEC): + timestamp_set_precision(TS_PREC_AUTO_USEC); + break; + case(WTAP_FILE_TSPREC_NSEC): + timestamp_set_precision(TS_PREC_AUTO_NSEC); + break; + default: + g_assert_not_reached(); + } + + /* Process the packets in the file */ + err = load_cap_file(&cfile, capture_opts.save_file, out_file_type); + if (err != 0) { + epan_cleanup(); + exit(2); + } + cf_name[0] = '\0'; + } else { + /* No capture file specified, so we're supposed to do a live capture + (or get a list of link-layer types for a live capture device); + do we have support for live captures? */ +#ifdef HAVE_LIBPCAP + +#ifdef _WIN32 + if (!has_wpcap) { + char *detailed_err; + + cmdarg_err("WinPcap couldn't be found."); + detailed_err = cant_load_winpcap_err("TShark"); + cmdarg_err_cont("%s", detailed_err); + g_free(detailed_err); + exit(2); + } +#endif + + /* trim the interface name and exit if that failed */ + if (!capture_opts_trim_iface(&capture_opts, + (prefs->capture_device) ? get_if_name(prefs->capture_device) : NULL)) { + exit(2); + } + + /* if requested, list the link layer types and exit */ + if (list_link_layer_types) { + status = capture_opts_list_link_layer_types(&capture_opts); + exit(status); + } + + if (!print_packet_info && !quiet) { + /* + * We're not printing information for each packet, and the user + * didn't ask us not to print a count of packets as they arrive, + * so print that count so the user knows that packets are arriving. + * + * XXX - what if the user wants to do a live capture, doesn't want + * to save it to a file, doesn't want information printed for each + * packet, does want some "-z" statistic, and wants packet counts + * so they know whether they're seeing any packets? + */ + print_packet_counts = TRUE; + } + + /* For now, assume libpcap gives microsecond precision. */ + timestamp_set_precision(TS_PREC_AUTO_USEC); + + capture(); + + if (capture_opts.multi_files_on) { + ringbuf_free(); + } +#else + /* No - complain. */ + cmdarg_err("This version of TShark was not built with support for capturing packets."); + exit(2); +#endif + } + + draw_tap_listeners(TRUE); + funnel_dump_all_text_windows(); + epan_cleanup(); + + return 0; +} + +#ifdef HAVE_LIBPCAP +/* Do the low-level work of a capture. + Returns TRUE if it succeeds, FALSE otherwise. */ + +static condition *volatile cnd_file_duration = NULL; /* this must be visible in process_packet */ + +static int +capture(void) +{ + int err = 0; + int volatile volatile_err = 0; + int volatile inpkts = 0; + int pcap_cnt; + condition *volatile cnd_autostop_size = NULL; + condition *volatile cnd_autostop_duration = NULL; + char *descr; +#ifndef _WIN32 + void (*oldhandler)(int); + guchar pcap_data[WTAP_MAX_PACKET_SIZE]; +#endif + struct pcap_stat stats; + gboolean write_ok; + gboolean close_ok; + gboolean cfilter_error = FALSE; + char errmsg[1024+1]; + char secondary_errmsg[4096+1]; + int save_file_fd; + + /* Initialize all data structures used for dissection. */ + init_dissection(); + + ld.wtap_linktype = WTAP_ENCAP_UNKNOWN; + ld.pdh = NULL; + ld.packet_cb = capture_pcap_cb; + + + /* open the "input file" from network interface or capture pipe */ + if (!capture_loop_open_input(&capture_opts, &ld, errmsg, sizeof(errmsg), + secondary_errmsg, sizeof(secondary_errmsg))) { + goto error; + } + + /* + * We've opened the capture device, so we shouldn't need any special + * privileges any more; relinquish those privileges. + * + * XXX - if we have saved set-user-ID support, we should give up those + * privileges immediately, and then reclaim them long enough to get + * a list of network interfaces and to open one, and then give them + * up again, so that stuff we do while processing the argument list, + * reading the user's preferences, loading and starting plugins + * (especially *user* plugins), etc. is done with the user's privileges, + * not special privileges. + */ + relinquish_special_privs_perm(); + + /* init the input filter from the network interface (capture pipe will do nothing) */ + switch (capture_loop_init_filter(ld.pcap_h, ld.from_cap_pipe, capture_opts.iface, capture_opts.cfilter)) { + + case INITFILTER_NO_ERROR: + break; + + case INITFILTER_BAD_FILTER: + cfilter_error = TRUE; + g_snprintf(errmsg, sizeof(errmsg), "%s", pcap_geterr(ld.pcap_h)); + *secondary_errmsg = '\0'; + goto error; + + case INITFILTER_OTHER_ERROR: + g_snprintf(errmsg, sizeof(errmsg), "Can't install filter (%s).", + pcap_geterr(ld.pcap_h)); + g_snprintf(secondary_errmsg, sizeof(secondary_errmsg), "%s", please_report); + goto error; + } + + if (capture_opts.saving_to_file) { + /* open the output file (temporary/specified name/ringbuffer/named pipe/stdout) */ + if (!capture_loop_open_output(&capture_opts, &save_file_fd, errmsg, sizeof(errmsg))) { + *secondary_errmsg = '\0'; + goto error; + } + + /* set up to write to the already-opened capture output file/files */ + if(!capture_loop_init_output(&capture_opts, save_file_fd, &ld, errmsg, sizeof errmsg)) { + *secondary_errmsg = '\0'; + goto error; + } + + /* Save the capture file name. */ + ld.save_file = capture_opts.save_file; + } + + ld.wtap_linktype = wtap_pcap_encap_to_wtap_encap(ld.linktype); + +#ifdef _WIN32 + /* Catch a CTRL+C event and, if we get it, clean up and exit. */ + SetConsoleCtrlHandler(capture_cleanup, TRUE); +#else /* _WIN32 */ + /* Catch SIGINT and SIGTERM and, if we get either of them, clean up + and exit. + XXX - deal with signal semantics on various UNIX platforms. Or just + use "sigaction()" and be done with it? */ + signal(SIGTERM, capture_cleanup); + signal(SIGINT, capture_cleanup); + if ((oldhandler = signal(SIGHUP, capture_cleanup)) != SIG_DFL) + signal(SIGHUP, oldhandler); + +#ifdef SIGINFO + /* Catch SIGINFO and, if we get it and we're capturing to a file in + quiet mode, report the number of packets we've captured. */ + signal(SIGINFO, report_counts_siginfo); +#endif /* SIGINFO */ +#endif /* _WIN32 */ + + /* Let the user know what interface was chosen. */ + descr = get_interface_descriptive_name(capture_opts.iface); + fprintf(stderr, "Capturing on %s\n", descr); + g_free(descr); + + /* initialize capture stop conditions */ + init_capture_stop_conditions(); + /* create stop conditions */ + if (capture_opts.has_autostop_filesize) + cnd_autostop_size = cnd_new((const char*)CND_CLASS_CAPTURESIZE, + (long)capture_opts.autostop_filesize * 1024); + if (capture_opts.has_autostop_duration) + cnd_autostop_duration = cnd_new((const char*)CND_CLASS_TIMEOUT, + (gint32)capture_opts.autostop_duration); + + if (capture_opts.multi_files_on && capture_opts.has_file_duration) + cnd_file_duration = cnd_new(CND_CLASS_TIMEOUT, capture_opts.file_duration); + + if (!setjmp(ld.stopenv)) { + ld.go = TRUE; + ld.packet_count = 0; + } else + ld.go = FALSE; + + while (ld.go) { + /* We need to be careful with automatic variables defined in the + outer scope which are changed inside the loop. Most compilers + don't try to roll them back to their original values after the + longjmp which causes the loop to finish, but all that the + standards say is that their values are indeterminate. If we + don't want them to be rolled back, we should define them with the + volatile attribute (paraphrasing W. Richard Stevens, Advanced + Programming in the UNIX Environment, p. 178). + + The "err" variable causes a particular problem. If we give it + the volatile attribute, then when we pass a reference to it (as + in "&err") to a function, GCC warns: "passing arg of + discards qualifiers from pointer target type". + Therefore within the loop and just beyond we don't use "err". + Within the loop we define "loop_err", and assign its value to + "volatile_err", which is in the outer scope and is checked when + the loop finishes. + + We also define "packet_count_prev" here to keep things tidy, + since it's used only inside the loop. If it were defined in the + outer scope, GCC would give a warning (unnecessary in this case) + that it might be clobbered, and we'd need to give it the volatile + attribute to suppress the warning. */ + + int loop_err = 0; + int packet_count_prev = 0; + + if (cnd_autostop_size == NULL && cnd_autostop_duration == NULL) { + /* We're not stopping at a particular capture file size, and we're + not stopping after some particular amount of time has expired, + so either we have no stop condition or the only stop condition + is a maximum packet count. + + If there's no maximum packet count, pass it -1, meaning "until + you run out of packets in the bufferful you read". Otherwise, + pass it the number of packets we have left to capture. + + We don't call "pcap_loop()" as, if we're saving to a file that's + a FIFO, we want to flush the FIFO after we're done processing + this libpcap bufferful of packets, so that the program + reading the FIFO sees the packets immediately and doesn't get + any partial packet, forcing it to block in the middle of reading + that packet. */ + if (capture_opts.autostop_packets == 0) + pcap_cnt = -1; + else { + if (ld.packet_count >= capture_opts.autostop_packets) { + /* XXX do we need this test here? */ + /* It appears there's nothing more to capture. */ + break; + } + pcap_cnt = capture_opts.autostop_packets - ld.packet_count; + } + } else { + /* We need to check the capture file size or the timeout after + each packet. */ + pcap_cnt = 1; + } +#ifndef _WIN32 + if (ld.from_cap_pipe) { + inpkts = cap_pipe_dispatch(&ld, pcap_data, errmsg, sizeof errmsg); + } else +#endif + inpkts = pcap_dispatch(ld.pcap_h, pcap_cnt, ld.packet_cb, (u_char *) &ld); + if (inpkts < 0) { + /* Error from "pcap_dispatch()", or error or "no more packets" from + "cap_pipe_dispatch(). */ + ld.go = FALSE; + } else if (cnd_autostop_duration != NULL && cnd_eval(cnd_autostop_duration)) { + /* The specified capture time has elapsed; stop the capture. */ + ld.go = FALSE; + } else if (inpkts > 0) { + if (capture_opts.autostop_packets != 0 && + ld.packet_count >= capture_opts.autostop_packets) { + /* The specified number of packets have been captured and have + passed both any capture filter in effect and any read filter + in effect. */ + ld.go = FALSE; + } else if (cnd_autostop_size != NULL && + cnd_eval(cnd_autostop_size, (guint32)ld.bytes_written)) { + /* We're saving the capture to a file, and the capture file reached + its maximum size. */ + if (capture_opts.multi_files_on) { + /* Switch to the next ringbuffer file */ + if (ringbuf_switch_file(&ld.pdh, &capture_opts.save_file, + &save_file_fd, &ld.bytes_written, + &loop_err)) { + /* File switch succeeded: reset the condition */ + cnd_reset(cnd_autostop_size); + if (cnd_file_duration) { + cnd_reset(cnd_file_duration); + } + } else { + /* File switch failed: stop here */ + volatile_err = loop_err; + ld.go = FALSE; + } + } else { + /* No ringbuffer - just stop. */ + ld.go = FALSE; + } + } + if (capture_opts.output_to_pipe) { + if (ld.packet_count > packet_count_prev) { + libpcap_dump_flush(ld.pdh, NULL); + packet_count_prev = ld.packet_count; + } + } + } /* inpkts > 0 */ + } /* while (ld.go) */ + + /* delete stop conditions */ + if (cnd_autostop_size != NULL) + cnd_delete(cnd_autostop_size); + if (cnd_autostop_duration != NULL) + cnd_delete(cnd_autostop_duration); + if (cnd_file_duration != NULL) + cnd_delete(cnd_file_duration); + + if (print_packet_counts) { + /* We're printing packet counts to stderr. + Send a newline so that we move to the line after the packet count. */ + fprintf(stderr, "\n"); + } + + /* If we got an error while capturing, report it. */ + if (inpkts < 0) { +#ifndef _WIN32 + if (ld.from_cap_pipe) { + if (ld.cap_pipe_err == PIPERR) { + cmdarg_err("Error while capturing packets: %s", errmsg); + } + } else +#endif + { + cmdarg_err("Error while capturing packets: %s", pcap_geterr(ld.pcap_h)); + } + } + + if (volatile_err == 0) + write_ok = TRUE; + else { + show_capture_file_io_error(capture_opts.save_file, volatile_err, FALSE); + write_ok = FALSE; + } + + if (capture_opts.save_file != NULL) { + /* We're saving to a file or files; close all files. */ + close_ok = capture_loop_close_output(&capture_opts, &ld, &err); + + /* If we've displayed a message about a write error, there's no point + in displaying another message about an error on close. */ + if (!close_ok && write_ok) + show_capture_file_io_error(capture_opts.save_file, err, TRUE); + } + +#ifndef _WIN32 + if (ld.from_cap_pipe && ld.cap_pipe_fd >= 0) + eth_close(ld.cap_pipe_fd); + else +#endif + { + /* Get the capture statistics, and, if any packets were dropped, report + that. */ + if (pcap_stats(ld.pcap_h, &stats) >= 0) { + if (stats.ps_drop != 0) { + fprintf(stderr, "%u packets dropped\n", stats.ps_drop); + } + } else { + cmdarg_err("Can't get packet-drop statistics: %s", pcap_geterr(ld.pcap_h)); + } + pcap_close(ld.pcap_h); + } + + /* Report the number of captured packets if not reported during capture + and we are saving to a file. */ + report_counts(); + + return TRUE; + +error: + if (capture_opts.multi_files_on) { + ringbuf_error_cleanup(); + } + g_free(capture_opts.save_file); + capture_opts.save_file = NULL; + if (cfilter_error) { + dfilter_t *rfcode = NULL; + if (dfilter_compile(capture_opts.cfilter, &rfcode) && rfcode != NULL) { + cmdarg_err( + "Invalid capture filter: \"%s\"!\n" + "\n" + "That string looks like a valid display filter; however, it isn't a valid\n" + "capture filter (%s).\n" + "\n" + "Note that display filters and capture filters don't have the same syntax,\n" + "so you can't use most display filter expressions as capture filters.\n" + "\n" + "See the User's Guide for a description of the capture filter syntax.", + capture_opts.cfilter, errmsg); + dfilter_free(rfcode); + } else { + cmdarg_err( + "Invalid capture filter: \"%s\"!\n" + "\n" + "That string isn't a valid capture filter (%s).\n" + "See the User's Guide for a description of the capture filter syntax.", + capture_opts.cfilter, errmsg); + } + } else { + cmdarg_err("%s", errmsg); + if (*secondary_errmsg != '\0') { + fprintf(stderr, "\n"); + cmdarg_err_cont("%s", secondary_errmsg); + } + } +#ifndef _WIN32 + if (ld.from_cap_pipe) { + if (ld.cap_pipe_fd >= 0) + eth_close(ld.cap_pipe_fd); + } else +#endif + { + if (ld.pcap_h != NULL) + pcap_close(ld.pcap_h); + } + + return FALSE; +} + +static void +capture_pcap_cb(u_char *user, const struct pcap_pkthdr *phdr, + const u_char *pd) +{ + struct wtap_pkthdr whdr; + union wtap_pseudo_header pseudo_header; + const guchar *wtap_pd; + loop_data *ld = (loop_data *) user; + int loop_err; + int err; + int save_file_fd; + gboolean packet_accepted; + +#ifdef SIGINFO + /* + * Prevent a SIGINFO handler from writing to stdout while we're + * doing so; instead, have it just set a flag telling us to print + * that information when we're done. + */ + infodelay = TRUE; +#endif /* SIGINFO */ + + /* The current packet may have arrived after a very long silence, + * way past the time to switch files. In order not to have + * the first packet of a new series of events as the last + * [or only] packet in the file, switch before writing! + */ + if (cnd_file_duration != NULL && cnd_eval(cnd_file_duration)) { + /* time elapsed for this ring file, switch to the next */ + if (ringbuf_switch_file(&ld->pdh, &ld->save_file, &save_file_fd, + &ld->bytes_written, &loop_err)) { + /* File switch succeeded: reset the condition */ + cnd_reset(cnd_file_duration); + } else { + /* File switch failed: stop here */ + /* XXX - we should do something with "loop_err" */ + ld->go = FALSE; + } + } + + if (do_dissection) { + /* We're goint to print packet information, run a read filter, or + process taps. Use process_packet() to handle that; in order + to do that, we need to convert from libpcap to Wiretap format. + If that fails, ignore the packet (wtap_process_pcap_packet has + written an error message). */ + wtap_pd = wtap_process_pcap_packet(ld->wtap_linktype, phdr, pd, + &pseudo_header, &whdr, &err); + if (wtap_pd == NULL) + return; + + packet_accepted = process_packet(&cfile, 0, &whdr, &pseudo_header, wtap_pd); + } else { + /* We're just writing out packets. */ + packet_accepted = TRUE; + } + + if (packet_accepted) { + /* Count this packet. */ +#ifdef HAVE_LIBPCAP + ld->packet_count++; +#endif + + if (ld->pdh != NULL) { + if (!libpcap_write_packet(ld->pdh, phdr, pd, &ld->bytes_written, &err)) { + /* Error writing to a capture file */ + if (print_packet_counts) { + /* We're printing counts of packets captured; move to the line after + the count. */ + fprintf(stderr, "\n"); + } + show_capture_file_io_error(ld->save_file, err, FALSE); + pcap_close(ld->pcap_h); + libpcap_dump_close(ld->pdh, &err); + exit(2); + } + } + if (print_packet_counts) { + /* We're printing packet counts. */ + if (ld->packet_count != 0) { + fprintf(stderr, "\r%u ", ld->packet_count); + /* stderr could be line buffered */ + fflush(stderr); + } + } + } + +#ifdef SIGINFO + /* + * Allow SIGINFO handlers to write. + */ + infodelay = FALSE; + + /* + * If a SIGINFO handler asked us to write out capture counts, do so. + */ + if (infoprint) + report_counts(); +#endif /* SIGINFO */ +} + +#ifdef _WIN32 +static BOOL WINAPI +capture_cleanup(DWORD ctrltype _U_) +{ + /* CTRL_C_EVENT is sort of like SIGINT, CTRL_BREAK_EVENT is unique to + Windows, CTRL_CLOSE_EVENT is sort of like SIGHUP, CTRL_LOGOFF_EVENT + is also sort of like SIGHUP, and CTRL_SHUTDOWN_EVENT is sort of + like SIGTERM at least when the machine's shutting down. + + For now, we handle them all as indications that we should clean up + and quit, just as we handle SIGINT, SIGHUP, and SIGTERM in that + way on UNIX. + + However, as handlers run in a new thread, we can't just longjmp + out; we have to set "ld.go" to FALSE, and must return TRUE so that + no other handler - such as one that would terminate the process - + gets called. + + XXX - for some reason, typing ^C to TShark, if you run this in + a Cygwin console window in at least some versions of Cygwin, + causes TShark to terminate immediately; this routine gets + called, but the main loop doesn't get a chance to run and + exit cleanly, at least if this is compiled with Microsoft Visual + C++ (i.e., it's a property of the Cygwin console window or Bash; + it happens if TShark is not built with Cygwin - for all I know, + building it with Cygwin may make the problem go away). */ + ld.go = FALSE; + return TRUE; +} +#else +static void +capture_cleanup(int signum _U_) +{ + /* Longjmp back to the starting point; "pcap_dispatch()", on many + UNIX platforms, just keeps looping if it gets EINTR, so if we set + "ld.go" to FALSE and return, we won't break out of it and quit + capturing. */ + longjmp(ld.stopenv, 1); +} +#endif /* _WIN32 */ + +static void +report_counts(void) +{ +#ifdef SIGINFO + /* XXX - if we use sigaction, this doesn't have to be done. + (Yes, this isn't necessary on BSD, but just in case a system + where "signal()" has AT&T semantics adopts SIGINFO....) */ + signal(SIGINFO, report_counts_siginfo); +#endif /* SIGINFO */ + + if (!print_packet_counts) { + /* Report the count only if we aren't printing a packet count + as packets arrive. */ + fprintf(stderr, "%u packets captured\n", ld.packet_count); + } +#ifdef SIGINFO + infoprint = FALSE; /* we just reported it */ +#endif /* SIGINFO */ +} + +#ifdef SIGINFO +static void +report_counts_siginfo(int signum _U_) +{ + int sav_errno = errno; + /* If we've been told to delay printing, just set a flag asking + that we print counts (if we're supposed to), otherwise print + the count of packets captured (if we're supposed to). */ + if (infodelay) + infoprint = TRUE; + else + report_counts(); + errno = sav_errno; +} +#endif /* SIGINFO */ +#endif /* HAVE_LIBPCAP */ + +static int +load_cap_file(capture_file *cf, char *save_file, int out_file_type) +{ + gint linktype; + int snapshot_length; + wtap_dumper *pdh; + int err; + gchar *err_info; + long data_offset; + char *save_file_string = NULL; + + linktype = wtap_file_encap(cf->wth); + if (save_file != NULL) { + /* Get a string that describes what we're writing to */ + save_file_string = output_file_description(save_file); + + /* Set up to write to the capture file. */ + snapshot_length = wtap_snapshot_length(cf->wth); + if (snapshot_length == 0) { + /* Snapshot length of input file not known. */ + snapshot_length = WTAP_MAX_PACKET_SIZE; + } + pdh = wtap_dump_open(save_file, out_file_type, linktype, snapshot_length, + FALSE /* compressed */, &err); + + if (pdh == NULL) { + /* We couldn't set up to write to the capture file. */ + switch (err) { + + case WTAP_ERR_UNSUPPORTED_FILE_TYPE: + cmdarg_err("Capture files can't be written in that format."); + break; + + case WTAP_ERR_UNSUPPORTED_ENCAP: + case WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED: + cmdarg_err("The capture file being read can't be written in " + "that format."); + break; + + case WTAP_ERR_CANT_OPEN: + cmdarg_err("The %s couldn't be created for some " + "unknown reason.", save_file_string); + break; + + case WTAP_ERR_SHORT_WRITE: + cmdarg_err("A full header couldn't be written to the %s.", + save_file_string); + break; + + default: + cmdarg_err("The %s could not be created: %s.", save_file_string, + wtap_strerror(err)); + break; + } + goto out; + } + } else { + if (print_packet_info) { + if (!write_preamble(cf)) { + err = errno; + show_print_file_io_error(err); + goto out; + } + } + pdh = NULL; + } + while (wtap_read(cf->wth, &err, &err_info, &data_offset)) { + if (process_packet(cf, data_offset, wtap_phdr(cf->wth), + wtap_pseudoheader(cf->wth), wtap_buf_ptr(cf->wth))) { + /* Either there's no read filtering or this packet passed the + filter, so, if we're writing to a capture file, write + this packet out. */ + if (pdh != NULL) { + if (!wtap_dump(pdh, wtap_phdr(cf->wth), + wtap_pseudoheader(cf->wth), wtap_buf_ptr(cf->wth), + &err)) { + /* Error writing to a capture file */ + show_capture_file_io_error(save_file, err, FALSE); + wtap_dump_close(pdh, &err); + exit(2); + } + } + } + } + if (err != 0) { + /* Print a message noting that the read failed somewhere along the line. */ + switch (err) { + + case WTAP_ERR_UNSUPPORTED_ENCAP: + cmdarg_err("\"%s\" has a packet with a network type that TShark doesn't support.\n(%s)", + cf->filename, err_info); + break; + + case WTAP_ERR_CANT_READ: + cmdarg_err("An attempt to read from \"%s\" failed for some unknown reason.", + cf->filename); + break; + + case WTAP_ERR_SHORT_READ: + cmdarg_err("\"%s\" appears to have been cut short in the middle of a packet.", + cf->filename); + break; + + case WTAP_ERR_BAD_RECORD: + cmdarg_err("\"%s\" appears to be damaged or corrupt.\n(%s)", + cf->filename, err_info); + break; + + default: + cmdarg_err("An error occurred while reading \"%s\": %s.", + cf->filename, wtap_strerror(err)); + break; + } + if (save_file != NULL) { + /* Now close the capture file. */ + if (!wtap_dump_close(pdh, &err)) + show_capture_file_io_error(save_file, err, TRUE); + } + } else { + if (save_file != NULL) { + /* Now close the capture file. */ + if (!wtap_dump_close(pdh, &err)) + show_capture_file_io_error(save_file, err, TRUE); + } else { + if (print_packet_info) { + if (!write_finale()) { + err = errno; + show_print_file_io_error(err); + } + } + } + } + +out: + wtap_close(cf->wth); + cf->wth = NULL; + + if (save_file_string != NULL) + g_free(save_file_string); + + return err; +} + +static void +fill_in_fdata(frame_data *fdata, capture_file *cf, + const struct wtap_pkthdr *phdr, long offset) +{ + fdata->next = NULL; + fdata->prev = NULL; + fdata->pfd = NULL; + fdata->num = cf->count; + fdata->pkt_len = phdr->len; + cum_bytes += phdr->len; + fdata->cum_bytes = cum_bytes; + fdata->cap_len = phdr->caplen; + fdata->file_off = offset; + fdata->lnk_t = phdr->pkt_encap; + fdata->abs_ts = *((nstime_t *) &phdr->ts); + fdata->flags.passed_dfilter = 0; + fdata->flags.encoding = CHAR_ASCII; + fdata->flags.visited = 0; + fdata->flags.marked = 0; + fdata->flags.ref_time = 0; + fdata->color_filter = NULL; + + /* If we don't have the time stamp of the first packet in the + capture, it's because this is the first packet. Save the time + stamp of this packet as the time stamp of the first packet. */ + if (nstime_is_zero(&first_ts)) { + first_ts = fdata->abs_ts; + } + + /* If we don't have the time stamp of the previous displayed packet, + it's because this is the first displayed packet. Save the time + stamp of this packet as the time stamp of the previous displayed + packet. */ + if (nstime_is_zero(&prev_ts)) { + prev_ts = fdata->abs_ts; + } + + /* Get the time elapsed between the first packet and this packet. */ + nstime_delta(&fdata->rel_ts, &fdata->abs_ts, &first_ts); + + /* If it's greater than the current elapsed time, set the elapsed time + to it (we check for "greater than" so as not to be confused by + time moving backwards). */ + if ((gint32)cf->elapsed_time.secs < fdata->rel_ts.secs + || ((gint32)cf->elapsed_time.secs == fdata->rel_ts.secs && (gint32)cf->elapsed_time.nsecs < fdata->rel_ts.nsecs)) { + cf->elapsed_time = fdata->rel_ts; + } + + /* Get the time elapsed between the previous displayed packet and + this packet. */ + nstime_delta(&fdata->del_ts, &fdata->abs_ts, &prev_ts); + prev_ts = fdata->abs_ts; +} + +/* Free up all data attached to a "frame_data" structure. */ +static void +clear_fdata(frame_data *fdata) +{ + if (fdata->pfd) + g_slist_free(fdata->pfd); +} + +static gboolean +process_packet(capture_file *cf, long offset, const struct wtap_pkthdr *whdr, + union wtap_pseudo_header *pseudo_header, const guchar *pd) +{ + frame_data fdata; + gboolean create_proto_tree; + epan_dissect_t *edt; + gboolean passed; + + /* Count this packet. */ + cf->count++; + + /* If we're going to print packet information, or we're going to + run a read filter, or we're going to process taps, set up to + do a dissection and do so. */ + if (do_dissection) { + fill_in_fdata(&fdata, cf, whdr, offset); + + if (print_packet_info) { + /* Grab any resolved addresses */ + + if (g_resolv_flags) { + host_name_lookup_process(NULL); + } + } + + passed = TRUE; + if (cf->rfcode || verbose || num_tap_filters!=0) + create_proto_tree = TRUE; + else + create_proto_tree = FALSE; + /* The protocol tree will be "visible", i.e., printed, only if we're + printing packet details, which is true if we're printing stuff + ("print_packet_info" is true) and we're in verbose mode ("verbose" + is true). */ + edt = epan_dissect_new(create_proto_tree, print_packet_info && verbose); + + /* If we're running a read filter, prime the epan_dissect_t with that + filter. */ + if (cf->rfcode) + epan_dissect_prime_dfilter(edt, cf->rfcode); + + tap_queue_init(edt); + + /* We only need the columns if we're printing packet info but we're + *not* verbose; in verbose mode, we print the protocol tree, not + the protocol summary. */ + epan_dissect_run(edt, pseudo_header, pd, &fdata, + (print_packet_info && !verbose) ? &cf->cinfo : NULL); + + tap_push_tapped_queue(edt); + + /* Run the read filter if we have one. */ + if (cf->rfcode) + passed = dfilter_apply_edt(cf->rfcode, edt); + else + passed = TRUE; + } else { + /* We're not running a display filter and we're not printing any + packet information, so we don't need to do a dissection, and all + packets are processed. */ + edt = NULL; + passed = TRUE; + } + + if (passed) { + /* Process this packet. */ + if (print_packet_info) { + /* We're printing packet information; print the information for + this packet. */ + print_packet(cf, edt); + + /* The ANSI C standard does not appear to *require* that a line-buffered + stream be flushed to the host environment whenever a newline is + written, it just says that, on such a stream, characters "are + intended to be transmitted to or from the host environment as a + block when a new-line character is encountered". + + The Visual C++ 6.0 C implementation doesn't do what is intended; + even if you set a stream to be line-buffered, it still doesn't + flush the buffer at the end of every line. + + So, if the "-l" flag was specified, we flush the standard output + at the end of a packet. This will do the right thing if we're + printing packet summary lines, and, as we print the entire protocol + tree for a single packet without waiting for anything to happen, + it should be as good as line-buffered mode if we're printing + protocol trees. (The whole reason for the "-l" flag in either + tcpdump or TShark is to allow the output of a live capture to + be piped to a program or script and to have that script see the + information for the packet as soon as it's printed, rather than + having to wait until a standard I/O buffer fills up. */ + if (line_buffered) + fflush(stdout); + + if (ferror(stdout)) { + show_print_file_io_error(errno); + exit(2); + } + } + } + + if (do_dissection) { + epan_dissect_free(edt); + clear_fdata(&fdata); + } + return passed; +} + +static void +show_capture_file_io_error(const char *fname, int err, gboolean is_close) +{ + char *save_file_string; + + save_file_string = output_file_description(fname); + + switch (err) { + + case ENOSPC: + cmdarg_err("Not all the packets could be written to the %s because there is " + "no space left on the file system.", + save_file_string); + break; + +#ifdef EDQUOT + case EDQUOT: + cmdarg_err("Not all the packets could be written to the %s because you are " + "too close to, or over your disk quota.", + save_file_string); + break; +#endif + + case WTAP_ERR_CANT_CLOSE: + cmdarg_err("The %s couldn't be closed for some unknown reason.", + save_file_string); + break; + + case WTAP_ERR_SHORT_WRITE: + cmdarg_err("Not all the packets could be written to the %s.", + save_file_string); + break; + + default: + if (is_close) { + cmdarg_err("The %s could not be closed: %s.", save_file_string, + wtap_strerror(err)); + } else { + cmdarg_err("An error occurred while writing to the %s: %s.", + save_file_string, wtap_strerror(err)); + } + break; + } + g_free(save_file_string); +} + +static gboolean +write_preamble(capture_file *cf) +{ + switch (output_action) { + + case WRITE_TEXT: + return print_preamble(print_stream, cf->filename); + break; + + case WRITE_XML: + if (verbose) + write_pdml_preamble(stdout); + else + write_psml_preamble(stdout); + return !ferror(stdout); + + default: + g_assert_not_reached(); + return FALSE; + } +} + +static char * +get_line_buf(size_t len) +{ + static char *line_bufp = NULL; + static size_t line_buf_len = 256; + size_t new_line_buf_len; + + for (new_line_buf_len = line_buf_len; len > new_line_buf_len; + new_line_buf_len *= 2) + ; + if (line_bufp == NULL) { + line_buf_len = new_line_buf_len; + line_bufp = g_malloc(line_buf_len + 1); + } else { + if (new_line_buf_len > line_buf_len) { + line_buf_len = new_line_buf_len; + line_bufp = g_realloc(line_bufp, line_buf_len + 1); + } + } + return line_bufp; +} + +static gboolean +print_columns(capture_file *cf) +{ + char *line_bufp; + int i; + size_t buf_offset; + size_t column_len; + + line_bufp = get_line_buf(256); + buf_offset = 0; + *line_bufp = '\0'; + for (i = 0; i < cf->cinfo.num_cols; i++) { + switch (cf->cinfo.col_fmt[i]) { + case COL_NUMBER: +#ifdef HAVE_LIBPCAP + /* + * Don't print this if we're doing a live capture from a network + * interface - if we're doing a live capture, you won't be + * able to look at the capture in the future (it's not being + * saved anywhere), so the frame numbers are unlikely to be + * useful. + * + * (XXX - it might be nice to be able to save and print at + * the same time, sort of like an "Update list of packets + * in real time" capture in Wireshark.) + */ + if (capture_opts.iface != NULL) + continue; +#endif + column_len = strlen(cf->cinfo.col_data[i]); + if (column_len < 3) + column_len = 3; + line_bufp = get_line_buf(buf_offset + column_len); + sprintf(line_bufp + buf_offset, "%3s", cf->cinfo.col_data[i]); + break; + + case COL_CLS_TIME: + case COL_REL_TIME: + case COL_ABS_TIME: + case COL_ABS_DATE_TIME: /* XXX - wider */ + column_len = strlen(cf->cinfo.col_data[i]); + if (column_len < 10) + column_len = 10; + line_bufp = get_line_buf(buf_offset + column_len); + sprintf(line_bufp + buf_offset, "%10s", cf->cinfo.col_data[i]); + break; + + case COL_DEF_SRC: + case COL_RES_SRC: + case COL_UNRES_SRC: + case COL_DEF_DL_SRC: + case COL_RES_DL_SRC: + case COL_UNRES_DL_SRC: + case COL_DEF_NET_SRC: + case COL_RES_NET_SRC: + case COL_UNRES_NET_SRC: + column_len = strlen(cf->cinfo.col_data[i]); + if (column_len < 12) + column_len = 12; + line_bufp = get_line_buf(buf_offset + column_len); + sprintf(line_bufp + buf_offset, "%12s", cf->cinfo.col_data[i]); + break; + + case COL_DEF_DST: + case COL_RES_DST: + case COL_UNRES_DST: + case COL_DEF_DL_DST: + case COL_RES_DL_DST: + case COL_UNRES_DL_DST: + case COL_DEF_NET_DST: + case COL_RES_NET_DST: + case COL_UNRES_NET_DST: + column_len = strlen(cf->cinfo.col_data[i]); + if (column_len < 12) + column_len = 12; + line_bufp = get_line_buf(buf_offset + column_len); + sprintf(line_bufp + buf_offset, "%-12s", cf->cinfo.col_data[i]); + break; + + default: + column_len = strlen(cf->cinfo.col_data[i]); + line_bufp = get_line_buf(buf_offset + column_len); + strcat(line_bufp + buf_offset, cf->cinfo.col_data[i]); + break; + } + buf_offset += column_len; + if (i != cf->cinfo.num_cols - 1) { + /* + * This isn't the last column, so we need to print a + * separator between this column and the next. + * + * If we printed a network source and are printing a + * network destination of the same type next, separate + * them with "->"; if we printed a network destination + * and are printing a network source of the same type + * next, separate them with "<-"; otherwise separate them + * with a space. + * + * We add enough space to the buffer for " <- " or " -> ", + * even if we're only adding " ". + */ + line_bufp = get_line_buf(buf_offset + 4); + switch (cf->cinfo.col_fmt[i]) { + + case COL_DEF_SRC: + case COL_RES_SRC: + case COL_UNRES_SRC: + switch (cf->cinfo.col_fmt[i + 1]) { + + case COL_DEF_DST: + case COL_RES_DST: + case COL_UNRES_DST: + strcat(line_bufp + buf_offset, " -> "); + buf_offset += 4; + break; + + default: + strcat(line_bufp + buf_offset, " "); + buf_offset += 1; + break; + } + break; + + case COL_DEF_DL_SRC: + case COL_RES_DL_SRC: + case COL_UNRES_DL_SRC: + switch (cf->cinfo.col_fmt[i + 1]) { + + case COL_DEF_DL_DST: + case COL_RES_DL_DST: + case COL_UNRES_DL_DST: + strcat(line_bufp + buf_offset, " -> "); + buf_offset += 4; + break; + + default: + strcat(line_bufp + buf_offset, " "); + buf_offset += 1; + break; + } + break; + + case COL_DEF_NET_SRC: + case COL_RES_NET_SRC: + case COL_UNRES_NET_SRC: + switch (cf->cinfo.col_fmt[i + 1]) { + + case COL_DEF_NET_DST: + case COL_RES_NET_DST: + case COL_UNRES_NET_DST: + strcat(line_bufp + buf_offset, " -> "); + buf_offset += 4; + break; + + default: + strcat(line_bufp + buf_offset, " "); + buf_offset += 1; + break; + } + break; + + case COL_DEF_DST: + case COL_RES_DST: + case COL_UNRES_DST: + switch (cf->cinfo.col_fmt[i + 1]) { + + case COL_DEF_SRC: + case COL_RES_SRC: + case COL_UNRES_SRC: + strcat(line_bufp + buf_offset, " <- "); + buf_offset += 4; + break; + + default: + strcat(line_bufp + buf_offset, " "); + buf_offset += 1; + break; + } + break; + + case COL_DEF_DL_DST: + case COL_RES_DL_DST: + case COL_UNRES_DL_DST: + switch (cf->cinfo.col_fmt[i + 1]) { + + case COL_DEF_DL_SRC: + case COL_RES_DL_SRC: + case COL_UNRES_DL_SRC: + strcat(line_bufp + buf_offset, " <- "); + buf_offset += 4; + break; + + default: + strcat(line_bufp + buf_offset, " "); + buf_offset += 1; + break; + } + break; + + case COL_DEF_NET_DST: + case COL_RES_NET_DST: + case COL_UNRES_NET_DST: + switch (cf->cinfo.col_fmt[i + 1]) { + + case COL_DEF_NET_SRC: + case COL_RES_NET_SRC: + case COL_UNRES_NET_SRC: + strcat(line_bufp + buf_offset, " <- "); + buf_offset += 4; + break; + + default: + strcat(line_bufp + buf_offset, " "); + buf_offset += 1; + break; + } + break; + + default: + strcat(line_bufp + buf_offset, " "); + buf_offset += 1; + break; + } + } + } + return print_line(print_stream, 0, line_bufp); +} + +static gboolean +print_packet(capture_file *cf, epan_dissect_t *edt) +{ + print_args_t print_args; + + if (verbose) { + /* Print the information in the protocol tree. */ + switch (output_action) { + + case WRITE_TEXT: + print_args.to_file = TRUE; + print_args.format = print_format; + print_args.print_summary = !verbose; + print_args.print_hex = verbose && print_hex; + print_args.print_formfeed = FALSE; + print_args.print_dissections = verbose ? print_dissections_expanded : print_dissections_none; + + /* init the packet range */ + packet_range_init(&print_args.range); + + if (!proto_tree_print(&print_args, edt, print_stream)) + return FALSE; + if (!print_hex) { + /* "print_hex_data()" will put out a leading blank line, as well + as a trailing one; print one here, to separate the packets, + only if "print_hex_data()" won't be called. */ + if (!print_line(print_stream, 0, "")) + return FALSE; + } + break; + + case WRITE_XML: + proto_tree_write_pdml(edt, stdout); + printf("\n"); + return !ferror(stdout); + } + } else { + /* Just fill in the columns. */ + epan_dissect_fill_in_columns(edt); + + /* Now print them. */ + switch (output_action) { + + case WRITE_TEXT: + if (!print_columns(cf)) + return FALSE; + break; + + case WRITE_XML: + proto_tree_write_psml(edt, stdout); + return !ferror(stdout); + } + } + if (print_hex) { + if (!print_hex_data(print_stream, edt)) + return FALSE; + if (!print_line(print_stream, 0, "")) + return FALSE; + } + return TRUE; +} + +static gboolean +write_finale(void) +{ + switch (output_action) { + + case WRITE_TEXT: + return print_finale(print_stream); + break; + + case WRITE_XML: + if (verbose) + write_pdml_finale(stdout); + else + write_psml_finale(stdout); + return !ferror(stdout); + + default: + g_assert_not_reached(); + return FALSE; + } +} + +static void +show_print_file_io_error(int err) +{ + switch (err) { + + case ENOSPC: + cmdarg_err("Not all the packets could be printed because there is " +"no space left on the file system."); + break; + +#ifdef EDQUOT + case EDQUOT: + cmdarg_err("Not all the packets could be printed because you are " +"too close to, or over your disk quota."); + break; +#endif + + default: + cmdarg_err("An error occurred while printing packets: %s.", + strerror(err)); + break; + } +} + +static const char * +cf_open_error_message(int err, gchar *err_info, gboolean for_writing, + int file_type) +{ + const char *errmsg; + static char errmsg_errno[1024+1]; + + if (err < 0) { + /* Wiretap error. */ + switch (err) { + + case WTAP_ERR_NOT_REGULAR_FILE: + errmsg = "The file \"%s\" is a \"special file\" or socket or other non-regular file."; + break; + + case WTAP_ERR_FILE_UNKNOWN_FORMAT: + /* Seen only when opening a capture file for reading. */ + errmsg = "The file \"%s\" isn't a capture file in a format TShark understands."; + break; + + case WTAP_ERR_UNSUPPORTED: + /* Seen only when opening a capture file for reading. */ + g_snprintf(errmsg_errno, sizeof(errmsg_errno), + "The file \"%%s\" isn't a capture file in a format TShark understands.\n" + "(%s)", err_info); + g_free(err_info); + errmsg = errmsg_errno; + break; + + case WTAP_ERR_CANT_WRITE_TO_PIPE: + /* Seen only when opening a capture file for writing. */ + g_snprintf(errmsg_errno, sizeof(errmsg_errno), + "The file \"%%s\" is a pipe, and %s capture files can't be " + "written to a pipe.", wtap_file_type_string(file_type)); + errmsg = errmsg_errno; + break; + + case WTAP_ERR_UNSUPPORTED_FILE_TYPE: + /* Seen only when opening a capture file for writing. */ + errmsg = "TShark doesn't support writing capture files in that format."; + break; + + case WTAP_ERR_UNSUPPORTED_ENCAP: + if (for_writing) + errmsg = "TShark can't save this capture in that format."; + else { + g_snprintf(errmsg_errno, sizeof(errmsg_errno), + "The file \"%%s\" is a capture for a network type that TShark doesn't support.\n" + "(%s)", err_info); + g_free(err_info); + errmsg = errmsg_errno; + } + break; + + case WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED: + if (for_writing) + errmsg = "TShark can't save this capture in that format."; + else + errmsg = "The file \"%s\" is a capture for a network type that TShark doesn't support."; + break; + + case WTAP_ERR_BAD_RECORD: + /* Seen only when opening a capture file for reading. */ + g_snprintf(errmsg_errno, sizeof(errmsg_errno), + "The file \"%%s\" appears to be damaged or corrupt.\n" + "(%s)", err_info); + g_free(err_info); + errmsg = errmsg_errno; + break; + + case WTAP_ERR_CANT_OPEN: + if (for_writing) + errmsg = "The file \"%s\" could not be created for some unknown reason."; + else + errmsg = "The file \"%s\" could not be opened for some unknown reason."; + break; + + case WTAP_ERR_SHORT_READ: + errmsg = "The file \"%s\" appears to have been cut short" + " in the middle of a packet or other data."; + break; + + case WTAP_ERR_SHORT_WRITE: + errmsg = "A full header couldn't be written to the file \"%s\"."; + break; + + default: + g_snprintf(errmsg_errno, sizeof(errmsg_errno), + "The file \"%%s\" could not be %s: %s.", + for_writing ? "created" : "opened", + wtap_strerror(err)); + errmsg = errmsg_errno; + break; + } + } else + errmsg = file_open_error_message(err, for_writing); + return errmsg; +} + +/* + * Open/create errors are reported with an console message in TShark. + */ +static void +open_failure_message(const char *filename, int err, gboolean for_writing) +{ + fprintf(stderr, "tshark: "); + fprintf(stderr, file_open_error_message(err, for_writing), filename); + fprintf(stderr, "\n"); +} + +cf_status_t +cf_open(capture_file *cf, const char *fname, gboolean is_tempfile, int *err) +{ + wtap *wth; + gchar *err_info; + char err_msg[2048+1]; + + wth = wtap_open_offline(fname, err, &err_info, FALSE); + if (wth == NULL) + goto fail; + + /* The open succeeded. Fill in the information for this file. */ + + /* Initialize all data structures used for dissection. */ + init_dissection(); + + cf->wth = wth; + cf->f_datalen = 0; /* not used, but set it anyway */ + + /* Set the file name because we need it to set the follow stream filter. + XXX - is that still true? We need it for other reasons, though, + in any case. */ + cf->filename = g_strdup(fname); + + /* Indicate whether it's a permanent or temporary file. */ + cf->is_tempfile = is_tempfile; + + /* If it's a temporary capture buffer file, mark it as not saved. */ + cf->user_saved = !is_tempfile; + + cf->cd_t = wtap_file_type(cf->wth); + cf->count = 0; + cf->drops_known = FALSE; + cf->drops = 0; + cf->snap = wtap_snapshot_length(cf->wth); + if (cf->snap == 0) { + /* Snapshot length not known. */ + cf->has_snap = FALSE; + cf->snap = WTAP_MAX_PACKET_SIZE; + } else + cf->has_snap = TRUE; + nstime_set_zero(&cf->elapsed_time); + nstime_set_zero(&first_ts); + nstime_set_zero(&prev_ts); + + return CF_OK; + +fail: + g_snprintf(err_msg, sizeof err_msg, + cf_open_error_message(*err, err_info, FALSE, cf->cd_t), fname); + cmdarg_err("%s", err_msg); + return CF_ERROR; +} + + +/* + * General errors are reported with an console message in TShark. + */ +static void +failure_message(const char *msg_format, va_list ap) +{ + fprintf(stderr, "tshark: "); + vfprintf(stderr, msg_format, ap); + fprintf(stderr, "\n"); +} + +/* + * Read errors are reported with an console message in TShark. + */ +static void +read_failure_message(const char *filename, int err) +{ + cmdarg_err("An error occurred while reading from the file \"%s\": %s.", + filename, strerror(err)); +} + +/* + * Report an error in command-line arguments. + */ +void +cmdarg_err(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + fprintf(stderr, "tshark: "); + vfprintf(stderr, fmt, ap); + fprintf(stderr, "\n"); + va_end(ap); +} + +/* + * Report additional information for an error in command-line arguments. + */ +void +cmdarg_err_cont(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + fprintf(stderr, "\n"); + va_end(ap); +} + + +/****************************************************************************************************************/ +/* indication report "dummies", needed for capture_loop.c */ + +#ifdef HAVE_LIBPCAP + +/** Report a new capture file having been opened. */ +void +report_new_capture_file(const char *filename) +{ + /* shouldn't happen */ + g_assert_not_reached(); +} + +/** Report a number of new packets captured. */ +void +report_packet_count(int packet_count) +{ + /* shouldn't happen */ + g_assert_not_reached(); +} + +/** Report the packet drops once the capture finishes. */ +void +report_packet_drops(int drops) +{ + /* shouldn't happen */ + g_assert_not_reached(); +} + +/** Report an error in the capture. */ +void +report_capture_error(const char *errmsg, const char *secondary_error_msg) +{ + cmdarg_err(errmsg); + cmdarg_err_cont(secondary_error_msg); +} + +/** Report an error with a capture filter. */ +void +report_cfilter_error(const char *cfilter, const char *errmsg) +{ + + cmdarg_err( + "Invalid capture filter: \"%s\"!\n" + "\n" + "That string isn't a valid capture filter (%s).\n" + "See the User's Guide for a description of the capture filter syntax.", + cfilter, errmsg); +} + +#endif /* HAVE_LIBPCAP */ + + +/****************************************************************************************************************/ +/* signal pipe "dummies", needed for capture_loop.c */ + +#ifdef HAVE_LIBPCAP + +#ifdef _WIN32 +gboolean +signal_pipe_check_running(void) +{ + /* currently, no check required */ + return TRUE; +} +#endif /* _WIN32 */ + +#endif /* HAVE_LIBPCAP */ diff --git a/wiretap/nettl.c b/wiretap/nettl.c index e24e30ec7f..9206d5e35f 100644 --- a/wiretap/nettl.c +++ b/wiretap/nettl.c @@ -661,7 +661,7 @@ static void nettl_close(wtap *wth) /* Returns 0 if we could write the specified encapsulation type, an error indication otherwise. nettl files are WTAP_ENCAP_UNKNOWN - when they are first opened, so we allow that for tethereal read/write. + when they are first opened, so we allow that for tshark read/write. */ int nettl_dump_can_write_encap(int encap) -- cgit v1.2.1