Commit Graph

285 Commits

Author SHA1 Message Date
Jörg Mayer 173fe5aef4 Replace the types from sys/types.h and netinet/in.h by their glib.h
equivalents for the toplevel directory. The removal of winsock2.h will
hopefully not cause any problems under MSVC++, as those files using
struct timeval still include wtap.h, which still includes winsock2.h.

svn path=/trunk/; revision=5932
2002-08-02 23:36:07 +00:00
Guy Harris e04fc7ebfd From Graeme Hewson:
Ethereal sometimes creates a progress dialog bar and then, if
	the processing is fast, quickly destroys it.  The resulting
	"flash" can be disconcerting.  This set of patches ensures a
	progress bar is either not created or is displayed for a minimum
	time.

svn path=/trunk/; revision=5916
2002-07-30 10:13:16 +00:00
Richard Sharpe b5fa2524e6 Fix the problems WRT overwriting a capture file. From Joerg Mayer.
svn path=/trunk/; revision=5898
2002-07-21 16:54:22 +00:00
Guy Harris 44d19627ef From Graeme Hewson:
Allow "-" as the output file name in Wiretap, referring to the
	standard error.

	Optimize the capture loop.

Fix some of the error-message printing code in Ethereal and Tethereal.

Have Wiretap check whether it can seek on a file descriptor, and pass
the results of that test to the file-type-specific "open for output"
routine.  Have the "open for output" routines for files where we need to
seek when writing the file return an error if seeks don't work.

svn path=/trunk/; revision=5884
2002-07-16 07:15:09 +00:00
Richard Sharpe eac7bf1188 This seems to fix the problem of trying to save over the top of an existing
capture on some occassions.

svn path=/trunk/; revision=5872
2002-07-15 05:14:26 +00:00
Guy Harris 7dc9756921 Have "print_line()" take an indentation argument, and do blank
padding when printing text and use "putline" when printing PostScript.
Eliminate "hexdump", as it's just a special case of "putline".

Have "proto_tree_print_node()" just call "print_line()".

Get rid of "print_ps_hex()" - the font used for the hex dump and the
protocol tree are the same, so there's no need to switch fonts.

svn path=/trunk/; revision=5798
2002-06-29 09:45:06 +00:00
Guy Harris bf2c26e0b9 Get rid of trailing newline in lines passed to "print_line()".
svn path=/trunk/; revision=5732
2002-06-22 01:52:27 +00:00
Guy Harris 567aac9787 Get rid of separate "print_hex_data_text()" and "print_hex_data_ps()"
routines; instead, rename "print_hex_data_common()" to
"print_hex_data_buffer()" as it prints a buffer in hex and ASCII (or
EBCDIC), and have it take the print format as an argument.

Have it use "print_line()" to print lines, and fix "print_line()" so
that it prints a buffer *without* a newline at the end, printing the
newline itself.

svn path=/trunk/; revision=5729
2002-06-22 01:24:23 +00:00
Guy Harris 1b72ef68e6 Add a new error for attempts to open a pipe or FIFO for random access.
Have "wtap_open_offline()", if asked to open a FIFO, return that error
if it was asked to open the file for random access.

svn path=/trunk/; revision=5643
2002-06-07 07:47:58 +00:00
Guy Harris 392a7dfc04 Get rid of the "data_src" member of the "frame_data" structure; put it
in the "packet_info" structure instead, as we don't need a pointer for
every single frame in the capture file, just for each frame for which we
currently have an open "epan_dissect_t".

svn path=/trunk/; revision=5614
2002-06-04 07:03:57 +00:00
Guy Harris a6a5ff53ea Clean up the file saving code a bit.
svn path=/trunk/; revision=5531
2002-05-23 10:27:12 +00:00
Guy Harris 15fe575899 Make "save_cap_file()" return a Boolean (TRUE on success, FALSE on
failure) - and don't use "err" to determine success or failure, as it's
not set in some failure cases.

svn path=/trunk/; revision=5528
2002-05-23 07:46:58 +00:00
Guy Harris a0b8690230 The "fname" argument to "save_cap_file()", and "cf->filename" - and thus
"from_filename" - are both null-terminated strings; compare them with
"strcmp", not "strncmp()".  ("cf->filename" is a "char *", so
"sizeof(cf->filename)" is not the right third argument to "strncmp()" in
any case, as it's the size of a pointer, which is probably either 4 or 8
bytes.)

Make the dialog box for "Can't save over current capture file" an
ESD_TYPE_CRIT dialog box, as it's a fatal error.

svn path=/trunk/; revision=5526
2002-05-23 06:10:56 +00:00
Guy Harris 71f8208bf9 From Didieer Gautheron:
Don't show progress bar for quick "Find Frame" searches
	Add "Find Next" and "Find Previous" to repeat searches

Add documentation for "Find Next" and "Find Previous".

svn path=/trunk/; revision=5378
2002-05-03 21:55:15 +00:00
Guy Harris 433e8801a1 Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
	to it, as it may save the filter string in the "capture_file"
	structure, and the caller of "filter_packets()" shouldn't have
	to worry about the string it passed to "filter_packets()" being
	stashed away somewhere so that it can't just free that string or
	change it;

	have callers of "filter_packets()" free up the string they
	handed to it, if the string was allocated and they're done with
	it;

	plug some memory leaks in "match_selected_cb_do()".

Check for an illegal "action" argument being passed to
"match_selected_cb_do()".

Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".

Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).

In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy.  Free that copy if
we didn't add the filter to the filter list.

Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself.  Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).

svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
Guy Harris c2b87a5d1e If the progress fraction when reading in a file becomes > 1, assume that
the file grew while we were reading it, and re-fetch the size and try
again; if it's still > 1, give up and clamp it at 1 so that the GTK+
progress bar code doesn't complain.

svn path=/trunk/; revision=5232
2002-04-24 05:48:43 +00:00
Richard Sharpe 84f440c3c9 Make sure that when we save a file, we don't overwrite our capture file
with an empty file.

svn path=/trunk/; revision=5225
2002-04-22 19:10:33 +00:00
Guy Harris 3cab99ea75 Don't prime the display filter unless we're re-applying it; otherwise,
we aren't building a protocol tree, and we can't prime the filter
against the tree.

svn path=/trunk/; revision=5206
2002-04-20 01:54:27 +00:00
Guy Harris 63e8447614 From Joerg Mayer: get rid of unused arguments, and mark those that can't
be eliminated (because the function is called through a pointer, and
other functions called through the same pointer *do* use the argument)
as unused.

svn path=/trunk/; revision=5050
2002-03-31 20:57:02 +00:00
Guy Harris b5e9cef2bf Make "wtap_seek_read()" return TRUE on success and FALSE on error, like
"wtap_read()".

Add some additional error checks to the Sniffer file reader.

svn path=/trunk/; revision=4875
2002-03-05 08:40:27 +00:00
Guy Harris e300f4db52 Have "wtap_seek_read()" return 0 on success and -1 on failure, and take
an "err" argument that points to an "int" into which to put an error
code if it fails.

Check for errors in one call to it, and note that we should do so in
other places.

In the "wtap_seek_read()" call in the TCP graphing code, don't overwrite
"cfile.pseudo_header", and make the buffer into which we read the data
WTAP_MAX_PACKET_SIZE bytes, as it should be.

In some of the file readers for text files, check for errors from the
"parse the record header" and "parse the hex dump" routines when reading
sequentially.

In "csids_seek_read()", fix some calls to "file_error()" to check the
error on the random stream (that being what we're reading).

svn path=/trunk/; revision=4874
2002-03-05 05:58:41 +00:00
Guy Harris cbf5c537c4 From Joerg Mayer: remove unused variables and declarations of
non-existent functions.

Remove the "filetype" argument from the "can_write_encap" functions for
particular capture file types - the argument value is implicit, in that
the routine being called is the routine for that particular file type.

svn path=/trunk/; revision=4823
2002-02-27 08:57:25 +00:00
Guy Harris ca8f79df3d Get rid of "init_all_protocols()"; instead, have a routine
"init_dissection()" which calls "epan_conversation_init()", does the
work that "init_all_protocols()" did, and then calls
"reassemble_init()", so that the standard sequence of dissection
initialization is done in one place, rather than having multiple places
call the same sequence of routines.

svn path=/trunk/; revision=4797
2002-02-24 06:45:14 +00:00
Guy Harris 642d7239dc Update a comment.
svn path=/trunk/; revision=4757
2002-02-19 03:43:43 +00:00
Guy Harris 6a21dc7e44 Don't give tvbuffs names; instead, give data sources names, where a
"data source" has a name and a top-level tvbuff, and frames can have a
list of data sources associated with them.

Use the tvbuff pointer to determine which data source is the data source
for a given field; this means we don't have to worry about multiple data
sources with the same name - the only thing the name does is label the
notebook tab for the display of the data source, and label the hex dump
of the data source in print/Tethereal output.

Clean up a bunch of things discovered in the process of doing the above.

svn path=/trunk/; revision=4749
2002-02-18 01:08:44 +00:00
Guy Harris 89a4acb438 Have Wiretap set the snapshot length to 0 if it can't be derived from
reading the capture file.  Have callers of "wtap_snapshot_length()"
treat a value of 0 as "unknown", and default to WTAP_MAX_PACKET_SIZE (so
that, when writing a capture file in a format that *does* store the
snapshot length, we can at least put *something* in the file).

If we don't know the snapshot length of the current capture file, don't
display a value in the summary window.

Don't use "cfile.snap" as the snapshot length option when capturing -
doing so causes Ethereal to default, when capturing, to the snapshot
length of the last capture file that you read in, rather than to the
snapshot length of the last capture you did (or the initial default of
"no snapshot length").

Redo the "Capture Options" dialog box to group options into sections
with frames around them, and add units to the snapshot length, maximum
file size, and capture duration options, as per a suggestion by Ulf
Lamping.  Also add units to the capture count option.

Make the snapshot length, capture count, maximum file size, and capture
duration options into a combination of a check box and a spin button.
If the check box is not checked, the limit in question is inactive
(snapshot length of 65535, no max packet count, no max file size, no max
capture duration); if it's checked, the spinbox specifies the limit.
Default all of the check boxes to "not checked" and all of the spin
boxes to small values.

Use "gtk_toggle_button_get_active()" rather than directly fetching the
state of a check box.

svn path=/trunk/; revision=4709
2002-02-08 10:07:41 +00:00
Guy Harris ee5ca25d31 Include files from the "epan" directory and subdirectories thereof with
"epan/..." pathnames, so as to avoid collisions with header files in any
of the directories in which we look (e.g., "proto.h", as some other
package has its own "proto.h" file which it installs in the top-level
include directory).

Don't add "-I" flags to search "epan", as that's no longer necessary
(and we want includes of "epan" headers to fail if the "epan/" is left
out, so that we don't re-introduce includes lacking "epan/").

svn path=/trunk/; revision=4586
2002-01-21 07:37:49 +00:00
Guy Harris b3f81eb30c Separate the promiscuous mode, "Update list of packets in real time",
and "Automatic scrolling in live capture" options from the preference
settings for them, so that the preference settings affect the initial
values of those options, but changing those values in a capture don't
affect the preferences, and don't automatically get saved when you save
the preferences.

If we're building without libpcap, don't have an "Automatic scrolling in
live capture" option anywhere.

svn path=/trunk/; revision=4514
2002-01-10 11:05:50 +00:00
Gilbert Ramirez 0b9b02c6ea Long NCP traces can easily have many packets whose "uniqueness"
variables wrap-around. Since the request/reply packets are related via
a hash based on these uniqueness variables, long NCP traces can
have mis-matches reqeust/reply records.

Thus, only do the hash-lookup for the reply packet during the first
sequential scan of the trace file. Once the pertinent info is found,
store it in the packet's private data area.

Since the memory allocated for the hash and for the structures that make
up the keys are no longer needed after the first sequential run through
the trace file, arrange to free that memory after the first sequential
run. Similar to the register_init_routine() that allows dissectors
to register callbacks for calling *before* a capture file is loaded,
set up a register_postseq_cleanup_routine() function that allows
dissectors to register callbacks for calling *after* the first
sequential run-through of the trace file is made. This is not
a *final* cleanup callback, since Ethereal will still have that trace file
open for random-access reading.

I didn't have tethereal call postseq_cleanup_all_protocols() since
tethereal doesn't keep the trace file open for random-access reading.
I could easily be swayed to make tethereal call that function, however.

svn path=/trunk/; revision=4484
2002-01-05 04:12:17 +00:00
Guy Harris ae760a4caa In "change_time_formats()" we can now check at the beginning whether
there are any columns whose time formats will change, and just return if
there aren't.

We also, however, need to set the "writable" flag on the columns before
doing that check, as "check_col()" checks whether the column in question
is writable; in this context, all columns are writable.

svn path=/trunk/; revision=4472
2002-01-03 22:27:44 +00:00
Gilbert Ramirez 791f5774d0 Provide for per-protocol-tree data in the proto_tree code.
Put a hash-table of "interesting" fields in the per-proto-tree data.
The dfilter code records which fields/protocols are "interesting" (by which
I mean, their value or existence is checked). Thus, the proto_tree routines
can create special arrays of field_info*'s that are ready for the dfilter
engine to use during a filter operation.

Also store the "proto_tree_is_visible" boolean, renamed "visible", in
the per-proto-tree data.

Move epan_dissect_t to its own header file to make #include dependencies
easier to handle.

Provide epan_dissect_fill_in_columns(), which accepts just the epan_dissect_t*
as an argument.

epan_dissect_new() needs to be followed by epan_dissect_run() for the
dissection to actually take place. Between those two calls,
epan_dissect_prime_dfilter() can be run 0, 1, or multiple times in order to
prime the empty proto_tree with the "intersesting" fields from the dfilter_t.

svn path=/trunk/; revision=4422
2001-12-18 19:09:08 +00:00
Guy Harris 794f0c04f4 Add an extra argument to "epan_dissect_new()" that indicates whether the
display representation should be put into protocol tree items if a
protocol tree is to be constructed; have it set "proto_tree_is_visible"
from that argument.

svn path=/trunk/; revision=4408
2001-12-16 22:16:14 +00:00
Guy Harris 3658c6ce7e Add some additional comments.
svn path=/trunk/; revision=4375
2001-12-10 03:25:58 +00:00
Guy Harris 23319ff023 Move the pointer to the "column_info" structure in the "frame_data"
structure to the "packet_info" structure; only stuff that's permanently
stored with each frame should be in the "frame_data" structure, and the
"column_info" structure is not guaranteed to hold the column values for
that frame at all times - it was only in the "frame_data" structure so
that it could be passed to dissectors, and, as all dissectors are now
passed a pointer to a "packet_info" structure, it could just as well be
put in the "packet_info" structure.

That saves memory, by shrinking the "frame_data" structure (there's one
of those per frame), and also lets us clean up the code a bit.

svn path=/trunk/; revision=4370
2001-12-10 00:26:21 +00:00
Gilbert Ramirez 6542c18172 Remove proto_tree from capture_file and PacketWinData, since they
already contain a pointer to an epan_dissect_t, which contains
the proto_tree.

Routines calling epan_dissect_new() do not create their own
proto_tree via proto_tree_create_root(); instead, they pass a boolean
to epan_dissect_new() telling it whether it should create the root
proto_tree.

svn path=/trunk/; revision=4343
2001-12-06 04:25:09 +00:00
Guy Harris a936b559df Make the "Save only marked frames" button in the "Save As..." dialog box
sensitive only if there *are* marked frames.

svn path=/trunk/; revision=4341
2001-12-06 02:21:26 +00:00
Guy Harris 2174f26cdc In the NetMon capture file reading code, if we get a short read when
trying to read the frame table, return -1 with "*err" set to
WTAP_ERR_SHORT_READ, don't return 0 - we've already decided that the
file is a NetMon file, so we shouldn't return a "this isn't a NetMon
file" indication, we should return a "this file is too short" error, as
that's what the problem is.

Fix up the error messages for WTAP_ERR_SHORT_READ to indicate that the
read might have gotten cut short in the middle of data other than a
packet.

svn path=/trunk/; revision=4331
2001-12-04 23:38:55 +00:00
Gilbert Ramirez 8743a4a8a7 Remove the global packet_info called "pi". Dissectors now only
access their own "pinfo". A packet_info is stored in epan_dissect_t,
which is created for the dissection of a single packet.

GUI functions which need to access the packet_info of the currently
selected packet used to use "pi"; now they use cfile.edt->pi. cfile's
"edt" member is the epan_dissect_t of the currently-selected packet.

The functionality of blank_packetinfo() was moved into
dissect_packet(), as that's the only place that called blank_packetinfo(),
after a spurious call to blank_packetinfo() was removed from
packet_list_select_cb().

svn path=/trunk/; revision=4246
2001-11-21 23:16:26 +00:00
Guy Harris 1c3f2e4cd5 Have a routine to add all the hex dump tabs to the hex dump notebook,
and call it both from "select_packet()" and "create_new_window()",
rather than having two similar loops in both places.

svn path=/trunk/; revision=4233
2001-11-20 10:37:16 +00:00
Gilbert Ramirez 6de396c4a8 Fix the rest of the signed/unsigned comparison warnings.
svn path=/trunk/; revision=4088
2001-10-26 18:28:17 +00:00
Guy Harris 3c9efdf478 Use longs as file offsets, so that on platforms with 64-bit "long" we
can handle capture files bigger than 2GB.

svn path=/trunk/; revision=3993
2001-10-04 08:30:36 +00:00
Guy Harris 9d601c6799 On Windows, use the directory in which the binary resides as the
directory in which global data files are stored.  If an installed binary
is being run, that's the correct directory for them; if a build-tree
binary is being run, the "manuf" file will be there, and you can put
other data files there as well, if necessary.

Do the same with plugins, except that, if there's no
"plugins\\{version}" subdirectory of that directory, fall back on the
default installation directory, so you at least have a place where you
can put plugins for use by build-tree binaries.  (Should we, instead,
have the Windows build procedure create a subdirectory of the "plugins"
source directory, with the plugin version number as its name, and copy
the plugins there, so you'd use the build-tree plugin binaries?)

Move "test_for_directory()" out of "util.c" and into
"epan/filesystem.c", with the other file system access portability
wrappers and convenience routines.  Fix "util.h" not to declare it - or
other routines moved to "epan/filesystem.c" a while ago.

svn path=/trunk/; revision=3858
2001-08-21 06:39:18 +00:00
Ed Warnicke add908fabd Added a "Suppress Unmarked" option to the print dialog to
allow you to suppress the printing of unmarked packets.
This allows a user to mark the packets they wish to print and
print ONLY those packets by suppressing all other unmarked packets.

This may seem like a bit of a convoluted way of expressing things,
as usually the desired behavior would be to print the marked packets.
However, we do NOT print marked packets that are not displayed under
the current filter.  To be maximally explicite I've expressed this
as suppressing unmarked frames.

svn path=/trunk/; revision=3736
2001-07-17 05:32:44 +00:00
Guy Harris 537d308abe "open_cap_file()" in Ethereal and Tethereal don't use the FILE_T they
get from calling "wtap_file()", so get rid of the call and the
(otherwise unused) variable to which its result gets assigned.

That lets us get rid of "wtap_file()" in Wiretap.

It also lets us get rid of the include of "zlib.h" in "file.h"; the
#defines of "file_open()", "filed_open()", and "file_close()" are also
unnecessary, so we get rid of those as well.

However, that means we need to include <zlib.h> in "gtk/main.c" and
"tethereal.c", so that the version number of libz is defined and can
show up in the version string.

svn path=/trunk/; revision=3652
2001-07-05 00:34:42 +00:00
Guy Harris 8c52d3db75 More signed vs. unsigned cleanups, and initialization cleanups, from
Joerg Mayer.

svn path=/trunk/; revision=3578
2001-06-19 23:08:57 +00:00
Guy Harris 2da9bb2696 When printing the contents of a raw-data field, don't use the raw data
of the current frame as the source, use the raw data of the tvbuff
that's the data source of that field.

svn path=/trunk/; revision=3531
2001-06-08 08:50:51 +00:00
Guy Harris c9da803a08 Move the fragment reassembly code into "reassemble.c" and
"reassemble.h", and remove IPv4 dependencies from it.

Use it for OSI CLNP segment reassembly as well.

svn path=/trunk/; revision=3525
2001-06-08 06:27:16 +00:00
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 e3a94e0342 Plug a memory leak (we weren't freeing the "epan_dissect_t" pointed to
by the "edt" member of a "capture_file" structure if we were selecting a
new frame, we were just overwriting that pointer).

Update Gerald's e-mail address.

svn path=/trunk/; revision=3470
2001-05-27 21:33:16 +00:00
Guy Harris bdb69627b2 "prefs.capture_real_time", not "prefs.capture_auto_scroll", should
control whether we have a child process do the capturing; a user might
want the packet list to be updated as packets arrive but *not* want it
to scroll so that the most recently arrived packets are shown.

"prefs.capture_auto_scroll", not "auto_scroll_live", should control
whether we scroll a real-time-update capture's packet list;
"auto_scroll_live" isn't set by the capture dialog box,
"prefs_capture_auto_scroll" is.

svn path=/trunk/; revision=3388
2001-05-01 00:18:48 +00:00