Commit Graph

84 Commits

Author SHA1 Message Date
Guy Harris 2851b7ef76 Enable "Match Selected" only if there's a field selected *and* we can do
a "Match Selected" on it - we can't do a "Match Selected" if the field
has no value (e.g., FT_NULL) and has a length of 0.

If we unselect the current packet, we don't have a protocol tree, so we
don't have a currently selected field - clear the "Match Selected" menu
item and the display in the status line of information about the
currently selected field.

Move the low-level statusbar manipulation into "gtk/main.c", in routines
whose API doesn't expose anything GTK+-ish.

"close_cap_file()" calls one of those routines to clear out the status
bar, so it doesn't need to take a pointer to the statusbar widget as an
argument.

"clear_tree_and_hex_views()" is purely a display-manipulating routine;
move it to "gtk/proto_draw.c".

Extract from "tree_view_unselect_row_cb()" an "unselect_field()" routine
to do all the work that needs to be done if the currently selected
protocol tree row is unselected, and call it if the currently selected
packet list row is unselected (if it's unselected, there *is* no
protocol tree, so no row can be selected), as well as from
"tree_view_unselect_row_cb()".

Before pushing a new field-description message onto the statusbar, pop
the old one off.

Get rid of an unused variable (set, but not used).

svn path=/trunk/; revision=3513
2001-06-05 07:39:31 +00:00
Guy Harris 6ee04dad33 Support for "-N" flag enabling selected forms of name resolution, from
Joerg Meyer.

Support for saving to the preferences file the settings for all types of
name resolution.

Do a case-insensitive check for "true" and "false" in Boolean preference
settings.

svn path=/trunk/; revision=3489
2001-05-31 08:36:46 +00:00
Guy Harris 39710cd582 In ANSI C (and in pre-ANSI UNIX implementations), if you return from
"main()", the program exits, and exits with an exit status equal to the
return value of "main()", so "return 0;" is sufficient at the end of
"main()".

svn path=/trunk/; revision=3350
2001-04-20 21:50:06 +00:00
Gilbert Ramirez 950d194eb9 Add a "return 0;" at the end of main() to pacify MSVC 5 (and probably
other compilers, too.)

svn path=/trunk/; revision=3347
2001-04-20 19:41:42 +00:00
Guy Harris d2d999fb74 Check the validity of numbers specified in command-line options.
svn path=/trunk/; revision=3326
2001-04-18 05:45:58 +00:00
Guy Harris f8c9764894 There's no "enable name resolution in captures" preference in Ethereal,
and never was - there's only an Ethereal-wide "enable name resolution"
preference.  Name it just "name_resolve".

Replace all tests of "g_resolving_actif" with tests of
"prefs.name_resolv", and replace all code that sets "g_resolving_actif"
with code that sets "prefs.name_resolv", so that the setting of
"prefs.name_resolv" actually affects whether names are resolved or not.

svn path=/trunk/; revision=3300
2001-04-15 03:37:16 +00:00
Guy Harris 094dc29f19 The Software Porting And Archive Centre for HP-UX now has libpcap 0.6.2
binaries, so users only need to make sure they have that version
installed in order to have Ethereal (and tcpdump, and snort, and so on)
accept "lanN"-style names (i.e., names of the sort reported by lanscan
and handled by ifconfig), rather than "dlpiN".

Get rid of the patches to update libpcap, get rid of the discussion in
"README.hpux" of patching libpcap and just say "get 0.6.2", and make the
notes on HP-UX kernel patches to fix problems with capturing outgoing
packets a separate item in the list of items in "README.hpux".

Also update the error messages Ethereal and Tethereal display if they
can't open a device and the error is "can't find PPA for XXX" to say
"get 0.6.2" rather than "patch libpcap and recompile.

svn path=/trunk/; revision=3288
2001-04-11 05:24:08 +00:00
Guy Harris 7da2edcb2e Don't hand "fdata" to "clear_fdata()" if you haven't filled it in.
svn path=/trunk/; revision=3266
2001-04-07 06:58:17 +00:00
Gilbert Ramirez 9fc1e0261b Win32 build fix, show "0.5.2 (WinPcap 2.1)" as the libpcap version
for Win32, and show a slightly more informative (i.e., geared to the
user) help message when trying to capture without having WinPcap installed.

svn path=/trunk/; revision=3261
2001-04-05 05:58:05 +00:00
Guy Harris b966192f5e Try to load WinPcap only on Windows.
svn path=/trunk/; revision=3251
2001-04-03 05:55:44 +00:00
Gilbert Ramirez a817e97015 Now that WinPcap is a DLL, I can load it at run-time rather than load-time.
That means that I no longer need to distribute capture and non-capture
versions of Ethereal for Win32; one version (compiled with WinPcap headers)
can run on systems with or without WinPcap.

For systems that don't have WinPcap, instead of disabling the Capture
menu, Capture|Start brings up a dialogue informing the user that wpcap.dll
was not loadable, and gives a URL to the WinPcap home page.

svn path=/trunk/; revision=3249
2001-04-03 05:26:27 +00:00
Ed Warnicke f5cf9c8dca Added two new arguments to epan_init() and proto_init() to
allow the passing of register_all_protocols() and
register_all_protocol_handoffs() through epan_init() to proto_init().
This allows the removal of the compile time dependence of proto.c
on register.h.  Modified dftest.c, tethereal.c, and gtk/main.c to
use the new style epan_init() and depend on register.h.

svn path=/trunk/; revision=3237
2001-04-02 00:38:36 +00:00
Guy Harris c58b7b49b5 Make "comp_info_str" static in Ethereal - there's no need for it outside
"gtk/main.c" in Ethereal.

Add the GLib version to it in Ethereal, and put in the GLib version
rather than the GTK+ version in Tethereal (which isn't linked with
GTK+...).

Make it a GString; this makes the code to construct it slightly less
ugly, especially now that we're putting the GLib version in.

Fix the code for the "-D" flag in Tethereal to compile in a no-libpcap
version (in a no-libpcap version, it just says that this version of
Tethereal wasn't compiled with capture support).

svn path=/trunk/; revision=3196
2001-03-27 06:48:12 +00:00
Guy Harris 40ba2e9e61 Give Tethereal a "-D" flag, inspired by WinPcap's "-D" flag, which
prints a list of all network interfaces it found on which it can capture
(the same list as the one that shows up in the "Interface" combo box in
Ethereal's "Capture Preferences" dialog).

svn path=/trunk/; revision=3194
2001-03-27 06:16:11 +00:00
Guy Harris d055130ad2 Clear "fdata->data_src" when initializing a "frame_data" structure.
When we're done with a "frame_data" structure, free all data attached to
it.

svn path=/trunk/; revision=3182
2001-03-24 09:24:41 +00:00
Jeff Foster 45cde0fc88 Added named data sources printing support, written by Guy Harris
svn path=/trunk/; revision=3167
2001-03-23 18:44:20 +00:00
Guy Harris fd6cd6f9bc In the MSVC++ 6.0 C library, "line-buffered" doesn't mean what one might
expect - it means "same as fully-buffered".  This means that the "-l"
flag is a no-op on Windows.

Instead of setting line-buffered mode with "setvbuf()", set a flag and,
if that flag is set, flush the standard output after the information for
ever packet is printed; this isn't "line-buffered", either, but, as the
reason for doing line-buffering is to allow the output of Tethereal to
be piped to a program and to have that program see the output for a
packet as soon as the packet is seen and dissected, it should be just as
good as line-buffered.

svn path=/trunk/; revision=3047
2001-02-18 03:38:44 +00:00
Guy Harris 35a14714c0 Report failures of "pcap_stats()", as tcpdump does.
Print the "Capturing on <interface>" message, the running count of
packets captured, and error messages to the standard error in Tethereal,
so that you can pipe the output of a live capture that's printing
packets to a program or script without that script having to worry about
parsing stuff other than dissected packet summaries or details (tcpdump
does the same).

svn path=/trunk/; revision=3017
2001-02-11 21:29:03 +00:00
Guy Harris bf0a3a32d1 In Ethereal, attempt to get the packet statistics from libpcap when
capturing; if we succeed, display the packet drops count as the "Drops"
value in the status line and as the "Dropped packets" statistics in the
summary dialog box, otherwise don't display it at all.

In Tethereal, attempt to get the packet statistics from libpcap when
capturing; if we succeed, and if there were any dropped packets, print
out the count of dropped packets when the capture finishes.

svn path=/trunk/; revision=3016
2001-02-11 09:28:17 +00:00
Guy Harris 261f3f1a6c Check for errors when writing a capture file.
Report errors when writing or closing a capture file.

Clean up some I/O error messages.

svn path=/trunk/; revision=3011
2001-02-10 09:08:14 +00:00
Gilbert Ramirez 8f1fff2e6a Create a more modular type system for the FT_* types. Put them
into epan/ftypes.

Re-write display filter routines using Lemon parser instead of yacc.
Besides using a different tool, the new grammar is much simpler, while
the display filter engine itself is more powerful and more easily extended.

Add dftest executable, to test display filter "bytecode" generation.
Add option to "configure" to build dftest or randpkt, both of which are not
built by default.

Implement Ed Warnicke's ideas about dranges in the new display filter and
ftype code.

Remove type FT_TEXT_ONLY in favor of FT_NONE, and have protocols registered
as FT_PROTOCOL. Thus, FT_NONE is used only for simple labels in the proto tree,
while FT_PROTOCOL is used for protocols. This was necessary for being
able to make byte slices (ranges) out of protocols, like "frame[0:3]"

Win32 Makefile.nmake's will be added tonight.

svn path=/trunk/; revision=2967
2001-02-01 20:21:25 +00:00
Guy Harris defc02babb There's no need for a member of a "capture_file" structure holding a
compiled capture filter program, so remove it, and remove the include of
<pcap.h> from "file.h"; instead, have local "struct bpf_program"
structures where needed, and have those files that need stuff from
<pcap.h> include it.

This cleans stuff up a bit, and should eliminate a pile of compile
warnings with Visual C++ due to <pcap.h> and some GTK+/GLib header file
(or files they include) both defining "inline".

svn path=/trunk/; revision=2955
2001-01-29 00:09:38 +00:00
Guy Harris 00fcdc0900 There's no need for a member of a "capture_file" structure holding a
compiled capture filter program, so remove it, and remove the include of
<pcap.h> from "file.h"; instead, have local "struct bpf_program"
structures where needed, and have those files that need stuff from
<pcap.h> include it.

This cleans stuff up a bit, and should eliminate a pile of compile
warnings with Visual C++ due to <pcap.h> and some GTK+/GLib header file
(or files they include) both defining "inline".

svn path=/trunk/; revision=2954
2001-01-28 23:56:29 +00:00
Guy Harris b443a9295a Don't define "promisc_mode" if we weren't built with libpcap support.
svn path=/trunk/; revision=2821
2001-01-04 00:16:43 +00:00
Guy Harris 35b1907af8 Pull the code to set the fields in the "cfile.cinfo" structure into a
common routine to initialize a "column_info()" structure, shared by
Ethereal and Tethereal.

svn path=/trunk/; revision=2739
2000-12-03 22:12:21 +00:00
Guy Harris f8d8ac9df6 Tethereal includes no GUI stuff, so it doesn't need to include
"ui_util.h".

svn path=/trunk/; revision=2691
2000-11-21 23:50:56 +00:00
Gilbert Ramirez ed396d1c03 Initialize winsock as we do in Ethereal.
svn path=/trunk/; revision=2680
2000-11-20 17:08:20 +00:00
Guy Harris 252d55d80f For each column, have both a buffer into which strings for that column
can be put, and a pointer to the string for the column, which might or
might not point to that buffer.

Add a routine "col_set_str()", which sets the string for the column to
the string passed to it as an argument; it should only be handed a
static string (a string constant would be ideal).  It doesn't do any
copying, so it's faster than "col_add_str()".

Make the routines that append to columns check whether the pointer to
the string for the column points to the buffer for the column and, if
not, copy the string for the column to the buffer for the column so that
you can append to it (so you can use "col_set_str()" and then use
"col_append_str()" or "col_append_fstr()").

Convert a bunch of "col_add_str()" calls that take a string constant as
an argument to "col_set_str()" calls.

Convert some "col_add_fstr()" calls that take a string constant as the
only argument - i.e., the format string doesn't have any "%" slots into
which to put strings for subsequent arguments to "col_set_str()" calls
(those calls are just like "col_add_str()" calls).

Replace an END_OF_FRAME reference in a tvbuffified dissector with a
"tvb_length(tvb)" call.

svn path=/trunk/; revision=2670
2000-11-19 08:54:37 +00:00
Guy Harris 718fe2b549 Move a "putchar('\n')" that caused an extra newline to be printed after
the protocol tree was printed.

svn path=/trunk/; revision=2586
2000-11-09 07:29:59 +00:00
Guy Harris 13a92d5410 In Tethereal, when printing summary lines, print the fields specified in
the preferences file, don't just print a wired-in list of fields.
Always print the time stamp.

svn path=/trunk/; revision=2573
2000-11-06 09:28:43 +00:00
Guy Harris 7d663fe7b0 Add a fourth choice of time format in the packet list display, which
shows the date (in YYYY-MM-DD format) as well as the time of day when
the packet arrived.

svn path=/trunk/; revision=2547
2000-11-01 08:31:36 +00:00
Guy Harris e023b751c0 Instead of failing if we can't find a netmask for the interface on which
we're capturing, just use a netmask of 0, and warn the user in Tethereal
(doing it in Ethereal would be more disruptive, and doing so only once
per interface in a session is a bit of work, as, in an "Update list of
packets in real time" capture the child process would have to tell the
parent that it couldn't get the netmask).

svn path=/trunk/; revision=2546
2000-11-01 07:38:54 +00:00
Guy Harris 7d67803a8e Get rid of a statement that should've been deleted when we started using
"compute_timestamp_diff()" to compute the difference betwen time stamps
but that wasn't deleted, causing the time difference between a frame and
the previous frame to be computed incorrectly in Tethereal.

svn path=/trunk/; revision=2543
2000-10-31 08:15:26 +00:00
Guy Harris cba377df3c Give libethereal its own configuration file, and have that configuration
file, rather than the top-level Ethereal configuration file, check for
"inet_aton()", "inet_pton()", and "inet_ntop()".  Then make its
Makefile.am include the appropriate object files if necessary.
Otherwise, they don't get built and put into libethereal, and therefore
attempts to link with anything in libethereal that uses them fail on
platforms that lack ethem, causing the build to fail.

That means a bunch of things need to be fixed to cope with libethereal
having its own "config.h" file; this means removing the include of
"config.h" from some libethereal header files.  Move the definitions of
the path names used only by "resolv.c" to "resolv.c" from "resolv.h" (so
"resolv.h" doesn't need "config.h", define HAVE_PLUGINS in the configure
script (so we don't have to include it in "plugins.h" to check whether
HAVE_DLFCN_H is defined).

Unfortunately, stuff outside libethereal needs to know PLUGIN_DIR; for
now, define that in the top-level configuration file, and have Ethereal
and Tethereal pass it as an argument to "epan_init()" - that should be
cleaned up at some point.

Remove from the top-level configure script checks for things used only
in libethereal.

svn path=/trunk/; revision=2498
2000-10-16 23:18:05 +00:00
Gerald Combs e61373a7c1 Change addresses from ethereal.zing.org to www.ethereal.com.
svn path=/trunk/; revision=2481
2000-10-08 17:16:29 +00:00
Gilbert Ramirez e69b5278aa Implement epan_dissect_new() and epan_dissect_free(). These are the
"top-level" dissectors that libepan-users call, instead of dissect_packet().
The epan_dissect_t holds the tvbuff after dissection so that the tvbuff's
memory is not cleared until after the proto_tree is freed. (I might stuff
the proto_tree into the epan_dissect_t, too).

What remains of dissect_packet() in packet.c handles the tvbuff initialiation.
The real meat of dissect_packet() is now in dissect_frame(), in packet-frame.c
This means that "packet.c" is no longer a dissector, os it is no longer
passed to make-reg-dotc.

Once dissect_fddi() gets two wrapper functions (dissect_fddi_swapped()
and dissect_fddi_nonswapped()), the a dissector handoff routine could
be used instead of the switch statement in dissect_frame(). I'd register
a field like "wtap.encap"

svn path=/trunk/; revision=2478
2000-10-06 10:11:40 +00:00
Gilbert Ramirez 83ec54675c First step in moving core Ethereal routines to libepan.
svn path=/trunk/; revision=2458
2000-09-27 04:55:05 +00:00
Guy Harris 2ef47f9ccb Give Tethereal a "-l" flag, as tcpdump has, to make the standard output
line-buffered.

svn path=/trunk/; revision=2451
2000-09-20 08:28:54 +00:00
Guy Harris 00b4224ee0 Add a "-p" command-line option, and a checkbox in the "Capture
Preferences" dialog box, to control whether to put the interface in
promiscuous mode or not; Debian bug #34376 asked for this.

svn path=/trunk/; revision=2439
2000-09-15 05:32:49 +00:00
Guy Harris 332d5715e8 Compute and display negative relative and delta time stamps correctly,
just in case time goes backwards (yes, it sometimes does happen in
captures).

svn path=/trunk/; revision=2407
2000-09-10 06:44:39 +00:00
Laurent Deniel fb3643b8d5 Remove the -D option.
svn path=/trunk/; revision=2349
2000-08-23 18:22:12 +00:00
Guy Harris faccb9665c Initialize all the fields of the "frame_data" structure, so that, for
example, "fdata->pfd" doesn't contain junk that upsets dissectors that
try to attach data to the frame (not that it does them much good in
Tethereal, as the frame is never revisited).

svn path=/trunk/; revision=2331
2000-08-22 03:33:41 +00:00
Laurent Deniel 8bc95e98e4 Fix potential buffer overflows.
svn path=/trunk/; revision=2298
2000-08-19 18:20:59 +00:00
Guy Harris 364ec7fa05 PPP/WAN captures work on Windows 9x, so speak of them not working only
on NT/2000.

Refer to Tethereal, not to Ethereal, in the long explanations of capture
problems in Tethereal.

svn path=/trunk/; revision=2270
2000-08-14 08:36:41 +00:00
Guy Harris 1c910d808a On Win32, if the attempt to open the capture device fails, don't talk
about checking permissions, as the capture devices are probably
available to all users, and talking about permissions will only confuse
the user.  Do, however, warn that Ethereal can't capture on Token Ring
or PPP/WAN interfaces.

On UNIX, if the attempt to open the capture device fails, and the error
message starts with "can't find PPA for ", they are probably running on
HP-UX with a version of libpcap not patched to properly look up PPAs for
network interfaces given the interface name; give them a detailed
warning about this, telling them that they'll have to fix libpcap and
build Ethereal from source, and pointing them at the "README.hpux" file.

svn path=/trunk/; revision=2265
2000-08-13 08:17:03 +00:00
Laurent Deniel 6a480953a9 Miscellaneous code cleaning
- add <stdarg.h> or <varargs.h> in snprintf.h
  and remove those inclusions in the other #ifdef NEED_SNPRINTF_H codes

- remove the check of multiple inclusions in source (.c)  code
  (there is a bit loss of _cpp_ performance, but I prefer the gain of
   code reading and maintenance; and nowadays, disk caches and VM are
   correctly optimized ;-).

- protect all (well almost) header files against multiple inclusions

- add header (i.e. GPL license) in some include files

- reorganize a bit the way header files are included:

  First:
  #include <system_include_files>
  #include <external_package_include_files (e.g. gtk, glib etc.)>
  Then
  #include "ethereal_include_files"

  with the correct HAVE_XXX or NEED_XXX protections.

- add some HAVE_XXX checks before including some system header files

- add the same HAVE_XXX in wiretap as in ethereal

Please forgive me, if I break something (I've only compiled and regression
tested on Linux).

svn path=/trunk/; revision=2254
2000-08-11 13:37:21 +00:00
Gilbert Ramirez a3e7190456 Add a "Save As" feature to the TCP Follow dialogue, to save the stream
file to a user-specified file.

Move the file-copy routine in save_cap_file() to an indepenent
function in file.c  (copy_binary_file()) so that follow_dlg.c can use it.

Remove #include "follow.h" from the C files that don't need it.

svn path=/trunk/; revision=2200
2000-08-03 12:44:40 +00:00
Gilbert Ramirez 2e0d26f22b Correct packet count displayed while capturing with -w option. (there was
an extra increment of cfile.count).

Print a newline to stdout at the end of a capture with "-w" so that the
final packet count isn't obliterated by the shell prompt.

svn path=/trunk/; revision=2156
2000-07-24 16:27:34 +00:00
Guy Harris e068b7dbe7 In Tethereal:
When capturing, report errors trying to create the output file
	with "file_open_error_message()".

	Make the "for_writing" argument to "file_open_error_message()" a
	"gboolean", as it's either TRUE (if the file is being opened for
	writing) or FALSE (if it's being opened for reading).

	Report EISDIR as "XXX is a directory (folder), not a file.".

When checking whether an "open()" of a capture file succeeded, check
whether "open()" returns a negative number, not whether it returns 0.

In "wtap_open_offline()", if the file to be opened is a directory,
return EISDIR, not WTAP_ERR_NOT_REGULAR_FILE, so that the error message
can say "that's a directory, not a file".

If "wtap_open_offline()" returns WTAP_ERR_NOT_REGULAR_FILE, don't just
say the file is "invalid", say it's a "special file" or socket or some
other weird type of file.

svn path=/trunk/; revision=2144
2000-07-20 09:39:43 +00:00
Guy Harris 0a71de8137 Turn the code of "colorize_packet()" into a static routine that is given
a word to use in the progress dialog, and a flag indicating whether the
display filter is to be reevaluated or not, and:

	have "colorize_packet()" call that routine with "Colorizing" and
	FALSE as those arguments;

	have the filtering code call that routine with "Filtering" and
	TRUE as those arguments;

	add an exported routine to call that routine with "Reprocessing"
	and TRUE as those arguments, to use to re-generate the packet
	list and to re-filter the packets if a protocol preference has
	been changed.

Keep track of whether preferences are changed from their initial value
by a preferences file or a command-line option, or from their previous
value by the "Preferences" dialog box; have "prefs_apply_all()" only
call the "apply" callback for a module if they have.

Call "prefs_apply_all()" after the command-line arguments have been
parsed and after "OK" has been clicked in the "Preferences" dialog box,
to notify modules of preference changes if they've registered a callback
for that.

After "OK" has been clicked in the "Preferences" dialog box, if any
preferences have changed, call the reprocessing routine, as the summary
line for some frames and/or the current display filter's value when
applied to some frames may have changed as a result of a preference
change.  Do the same after "OK" or "Apply" has been clicked in the
"Display Options" dialog box (as it controls a protocol preferences
item.

svn path=/trunk/; revision=2126
2000-07-09 03:29:42 +00:00