Commit Graph

724 Commits

Author SHA1 Message Date
Gerald Combs 5c57f09423 Richard J�rgensen <ric@tbit.dk> pointed out that ICMP and IGMP checksums
were printed in the wrong byteorder.

svn path=/trunk/; revision=539
1999-08-21 21:06:11 +00:00
Guy Harris ad096839d3 Move the code to set "max_data" in "dissect_nbss()" earlier, so that
it's set before we dissect continuations.

svn path=/trunk/; revision=538
1999-08-21 17:59:36 +00:00
Guy Harris 9e251e660b Jochen Friedrich's patch to add IPv6 support for DLT_NULL.
svn path=/trunk/; revision=537
1999-08-21 17:56:06 +00:00
Richard Sharpe 0ccb231a56 This is the code in packet-nbns that handles continuation messages.
It checks to see if the packet we have in front of us does not start with
one of the four NetBIOS over TCP/IP message types, or if it is a data
message, then looks for \0377SMB in the first four bytes ...

It seems to work well on one large trace of Samba activity that I have.
`

svn path=/trunk/; revision=536
1999-08-21 08:45:09 +00:00
Guy Harris 3a41de3bbb The 16-bit and 32-bit fields in the "frame4" record header in ATM
Sniffer captures are little-endian; convert them as necessary.

svn path=/trunk/; revision=535
1999-08-20 23:11:05 +00:00
Guy Harris e0e54ddc1c Fix the e-mail address for Jeff Foster.
svn path=/trunk/; revision=534
1999-08-20 21:57:29 +00:00
Guy Harris a6a41e0b59 Call "init_mib()" in "proto_register_snmp()"; not doing so causes core
dumps (probably because the SNMP libraries expect it to have been
called).

svn path=/trunk/; revision=533
1999-08-20 21:26:37 +00:00
Gilbert Ramirez b85bb70925 Changed some symbols inside parser, fixed default error message in
dfilter_compile, and removed debug printf that I left in match_selected.

svn path=/trunk/; revision=532
1999-08-20 21:19:28 +00:00
Guy Harris 0a25d2df5b Include "snprintf.h" if necessary, to squelch some "gcc -Wall"
complaints.

svn path=/trunk/; revision=531
1999-08-20 20:45:14 +00:00
Gilbert Ramirez f0e5afe7a9 Enabled error reporting for bad ETHER values in display filters. A new
global variable, dfilter_error_msg is now available, being NULL when there
was no error, or pointing to a string when an error occurred. The three
places that dfilter_compile() is called now use this global variable to
report the error message to the user. A default error message is put
in that string if no context-specific error message is available (since
I only have one context-specifici error message, namely, ETHER values,
that will be most of the time).

svn path=/trunk/; revision=530
1999-08-20 20:37:47 +00:00
Gilbert Ramirez fa65ee1d1e Cleaned up the two routines besides the main display filter mechanism
that use display filters, TCP follow and Match Selected.

In Match Selected, I made it put the display filter that it creates
in the text entry widget. The code was already there, but it didn't work
because code was missing in the GUI initialization routine that runs
when Ethereal starts. The text entry widget pointer was not being passed
to the Match Selected menu item.

In TCP follow, I made it _not_ put the display filter that it creates
in the text entry widget. I find it annoying that a really long
display filter is left in the widget, and others have voiced their
opinion on this too. In addition, after applying the display filter
and retreiving the TCP data, the display filter (if any) that the user
had in place _before_ running TCP follow is put back and the packet
list is set back to the way it was before TCP follow is run. I think this
is more expected. The drawback is that display filtering is run twice,
once to retreive the TCP data and once to reset the display.

svn path=/trunk/; revision=529
1999-08-20 19:43:10 +00:00
Guy Harris b66b74efe7 Fix a comment.
svn path=/trunk/; revision=528
1999-08-20 08:00:24 +00:00
Guy Harris e8ba74cbf1 Add Olivier Abad to the list of Wiretap authors, as the code to read
RADCOM WAN/LAN Analyzer capture files is his.

svn path=/trunk/; revision=527
1999-08-20 07:58:50 +00:00
Guy Harris ac2418871b Note that we now have the ability to read Ethernet and X.25 captures
from RADCOM WAN/LAN Analyzers.

(BTW, the previous checkin also removed the comments about the hack
wherein we pretended that ATM Sniffer captures were really Ethernet,
Token-Ring, or RFC 1483 captures, given that said hack was itself
removed.)

svn path=/trunk/; revision=526
1999-08-20 07:55:49 +00:00
Guy Harris bcb5f49177 Remove the stuff about filters in Wiretap, as that capability was
removed when a more powerful display filtering mechanism was added to
Ethereal.

svn path=/trunk/; revision=525
1999-08-20 07:51:22 +00:00
Guy Harris 942470521a Get rid of an unused variable left stranded on the beach when a wave
washed out to sea the code that used to pretend that an ATM Sniffer
capture was an Ethernet or Token-Ring Sniffer capture.

svn path=/trunk/; revision=524
1999-08-20 07:38:30 +00:00
Guy Harris a033390918 Add support for reading Full Frontal ATM from an ATM Sniffer capture
file, instead of throwing out all but LANE or RFC 1483 data frames and
pretending that the former are just Ethernet or Token-Ring frames.

Add some level of decoding for ATM LANE, but not all of it; the rest,
including decoding non-LANE frames, is left as an exercise for somebody
who has captures they want to decode, an interest in decoding them, ATM
expertise, and time....

svn path=/trunk/; revision=523
1999-08-20 06:55:20 +00:00
Gilbert Ramirez 57198bc28f Made handling of byte strings in scanner and parser much simpler,
improving size of grammar and creating the possibility of dfilter_compile
reporting errors back to user. In this case, if an ETHER variable is
compared against a byte string that is not 6 bytes, an error condition is
flagged appropriately. I have not put in the code to conver that error flag
to a message to the user, but that's what I'm working on next.

Also, fixed sample debug session in README to show correct gdb prompt.

svn path=/trunk/; revision=522
1999-08-20 06:01:07 +00:00
Gilbert Ramirez a3c2258350 Made LanAlyzer smarter about reading trace files, thereby removing a
variable from lanalyzer_t (plus an additional variable which wasn't being
used). While I was in there I cleaned up some comments and renamed a couple
variables to make more sense.

svn path=/trunk/; revision=521
1999-08-20 04:49:18 +00:00
Guy Harris 4831e9eb0c "open_cap_file()" calls "close_cap_file()" if its attempt to open the
capture file succeeds, so that it cleans out any state in the
"capture_file" structure it was handed before filling it in with new
state for the new capture file.

This means it destroys any read filter associated with the
"capture_file" structure it was handed, so the "rfcode" field must be
set *after* calling "open_cap_file()" but *before* calling
"read_cap_file()".  Do so for the "capture file (and possibly read
filter) supplied on the command line" case.

svn path=/trunk/; revision=520
1999-08-20 04:41:31 +00:00
Gilbert Ramirez 49388049d3 Made iptrace wiretap module return error on partial packets, instead of
expecting it as normal. Added paragraph about iptrace oddities to README.
I also added a section to the README about how to report bugs.

svn path=/trunk/; revision=519
1999-08-20 04:07:09 +00:00
Guy Harris aae22bd227 Have the per-capture-file-type open routines "wtap_open_offline()" calls
return 1 on success, -1 if they got an error, and 0 if the file isn't of
the type that file is checking for, and supply an error code if they
return -1; have "wtap_open_offline()" use that error code.  Also, have
the per-capture-file-type open routines treat errors accessing the file
as errors, and return -1, rather than just returning 0 so that we try
another file type.

Have the per-capture-file-type read routines "wtap_loop()" calls return
-1 and supply an error code on error (and not, as they did in some
cases, call "g_error()" and abort), and have "wtap_loop()", if the read
routine returned an error, return FALSE (and pass an error-code-pointer
argument onto the read routines, so they fill it in), and return TRUE on
success.

Add some new error codes for them to return.

Now that "wtap_loop()" can return a success/failure indication and an
error code, in "read_cap_file()" put up a message box if we get an error
reading the file, and return the error code.

Handle the additional errors we can get when opening a capture file.

If the attempt to open a capture file succeeds, but the attempt to read
it fails, don't treat that as a complete failure - we may have managed
to read some of the capture file, and we should display what we managed
to read.

svn path=/trunk/; revision=518
1999-08-19 05:52:55 +00:00
Guy Harris 68f2dca6e7 Use "g_strdup()" rather than "strdup()".
svn path=/trunk/; revision=517
1999-08-19 05:42:22 +00:00
Guy Harris 137ba48d18 Have the per-capture-file-type open routines "wtap_open_offline()" calls
return 1 on success, -1 if they got an error, and 0 if the file isn't of
the type that file is checking for, and supply an error code if they
return -1; have "wtap_open_offline()" use that error code.  Also, have
the per-capture-file-type open routines treat errors accessing the file
as errors, and return -1, rather than just returning 0 so that we try
another file type.

Have the per-capture-file-type read routines "wtap_loop()" calls return
-1 and supply an error code on error (and not, as they did in some
cases, call "g_error()" and abort), and have "wtap_loop()", if the read
routine returned an error, return FALSE (and pass an error-code-pointer
argument onto the read routines, so they fill it in), and return TRUE on
success.

Add some new error codes for them to return.

Now that "wtap_loop()" can return a success/failure indication and an
error code, in "read_cap_file()" put up a message box if we get an error
reading the file, and return the error code.

Handle the additional errors we can get when opening a capture file.

If the attempt to open a capture file succeeds, but the attempt to read
it fails, don't treat that as a complete failure - we may have managed
to read some of the capture file, and we should display what we managed
to read.

svn path=/trunk/; revision=516
1999-08-19 05:31:38 +00:00
Gilbert Ramirez 7843c01d38 Changes to compile in win32.
svn path=/trunk/; revision=515
1999-08-18 22:49:48 +00:00
Guy Harris 0f62ffc5df In "wtap_dump_close()", don't shove the return value of "fclose()" into
the variable for the return value of "wtap_dump_close()", just check it
against EOF; shoving it into "ret" means it gets set to 0 on a
successful close, but a return value of 0 means "wtap_dump_close()"
failed.

svn path=/trunk/; revision=514
1999-08-18 17:49:34 +00:00
Guy Harris 31d104a9c5 "wtap_pcap_encap_to_wtap_encap()" shouldn't return a file type if it
can't translate the encapsulation type, it should return an
encapsulation type; we add a new one, WTAP_ENCAP_UNKNOWN. and have it
return that.

Have "capture()" handle "wtap_pcap_encap_to_wtap_encap()" returning that
encapsulation type (if it happens, we need to add a new Wiretap
encapsulation type to handle the new "libpcap" encapsulation type).

svn path=/trunk/; revision=513
1999-08-18 17:08:47 +00:00
Gilbert Ramirez c1adce9762 Re-arranged Ethereal's definitions of DLT_RAW et al. since capture.c
is the only file that uses them. I hope to avoid some compiler warnings
with this.

svn path=/trunk/; revision=512
1999-08-18 16:28:22 +00:00
Gilbert Ramirez 648ffa1435 Small change to create_tempfile, initializing static vars.
svn path=/trunk/; revision=511
1999-08-18 15:29:06 +00:00
Guy Harris 28809e2002 Make "wtap_dump()" and "wtap_dump_close()" return error codes, and check
for errors when closing a file to which we've written packets (we don't
bother checking if we're giving up on a capture).

Add some more error checks in Wiretap.

Make a single list of all Wiretap error codes, giving them all different
values (some can be returned by more than one routine, so they shouldn't
be per-routine).

svn path=/trunk/; revision=510
1999-08-18 04:41:20 +00:00
Guy Harris df490a7085 Add to Wiretap the ability to write capture files; for now, it can only
write them in "libpcap" format, but the mechanism can have other formats
added.

When creating the temporary file for a capture, use "create_tempfile()",
to close a security hole opened by the fact that "tempnam()" creates a
temporary file, but doesn't open it, and we open the file with the name
it gives us - somebody could remove the file and plant a link to some
file, and, if as may well be the case when Ethereal is capturing
packets, it's running as "root", that means we write a capture on top of
that file....  (The aforementioned changes to Wiretap let you open a
capture file for writing given an file descriptor, "fdopen()"-style,
which this change requires.)

svn path=/trunk/; revision=509
1999-08-18 04:17:38 +00:00
Guy Harris bc3c8c0641 Fix up the call to "reassemble_tcp()" to use "pi.len" and
"pi.captured_len" to compute the total amount of TCP payload and the
captured amount of TCP payload.

svn path=/trunk/; revision=508
1999-08-18 03:11:14 +00:00
Guy Harris fca713e47f Make a "create_tempfile()" routine that constructs the template to be
used by "mkstemp()" into a buffer supplied as an argument, trying
several directories for the tempfile, in the same fashion that the BSD
(and probably other) "tempnam()" routines do.

Have that routine cope with temporary-file directory names that don't
end with "/", as "P_tmpdir" doesn't necessarily end with "/" (and
doesn't, in GNU "libc" 2.x, at least on Linux); thanks to Gilbert
Ramirez for catching this one, and supplying the code to cope with that.

Have the code that creates the temporary file for the "Follow TCP
Stream" text use it.

svn path=/trunk/; revision=507
1999-08-18 02:59:05 +00:00
Guy Harris ac4f87218d Declare the "packet_info" structure "pi" in "packet.h", rather than in a
bunch of source files.

Replace the "payload" field of a "packet_info" structure with "len" and
"captured_len" fields, which contain the total packet length and total
captured packet length (including all headers) at the current protocol
layer (i.e., if a given layer has a length field, and that length field
says its shorter than the length we got from the capture, reduce the
"pi.len" and "pi.captured_len" values appropriately).  Those fields can
be used in the future if we add checks to make sure a field we're
extracting from a packet doesn't go past the end of the packet, or past
the captured part of the packet.

Get rid of the additional payload argument to some dissection functions;
use "pi.captured_len - offset" instead.

Have the END_OF_FRAME macro use "pi.captured_len" rather than
"fd->cap_len", so that "dissect the rest of the frame" becomes "dissect
the rest of the packet", and doesn't dissect end-of-frame padding such
as padding added to make an Ethernet frame 60 or more octets long.  (We
might want to rename it END_OF_PACKET; if we ever want to label the
end-of-frame padding for the benefit of people curious what that extra
gunk is, we could have a separate END_OF_FRAME macro that uses
"fd->cap_len".)

svn path=/trunk/; revision=506
1999-08-18 00:57:54 +00:00
Gilbert Ramirez d4331d4329 Converted more of the IP fields to filterable fields.
svn path=/trunk/; revision=505
1999-08-17 03:09:39 +00:00
Guy Harris b1e9d314f0 Fix a typo in a comment.
svn path=/trunk/; revision=504
1999-08-17 00:26:37 +00:00
Guy Harris ac4a2e40ef Expand some comments.
Check for errors reading the "Follow TCP Stream" temporary file.

Unlink the temporary file after attempting to open and read the file,
even if the attempt to open it failed.

svn path=/trunk/; revision=503
1999-08-17 00:10:22 +00:00
Guy Harris ce732a3267 Pick up a change from the OpenBSD ports collection, to use "mkstemp()"
to create the temporary file to which the "Follow TCP Stream" code
writes the contents of the TCP stream; this was presumably done to close
a potential security hole opened by the possibility of somebody
replacing the file referred to by the name generated by "tmpnam()"
before we open it.

(We may have to provide our own version of "mkstemp()" if there are any
platforms on which we run that lack it.  Note that Solaris 2.5.1 has it,
even though it's not documented and isn't declare in its "stdlib.h".)

Have the "Follow TCP Stream" code put up a dialog box, rather than
spitting a message out to the standard error, if the attempt to create
the temporary file fails.

Check also whether the attempt to open the "Follow TCP Stream" temporary
file for reading fails, and put up a dialog box for that as well.

svn path=/trunk/; revision=502
1999-08-16 23:58:30 +00:00
Guy Harris afe2eecfd7 Get rid of the comments saying "make ["decode_numeric_bitfield()"] shift
the value appropriately!" - a change from Olivier Abad did so.

svn path=/trunk/; revision=501
1999-08-16 05:54:32 +00:00
Gilbert Ramirez 49734a369e Fixed segfault with new gtk_tree_item deselection routine and -S option.
svn path=/trunk/; revision=500
1999-08-15 23:40:33 +00:00
Guy Harris 714eefd24e The "loop_data" structure is used only in "capture.c"; move its
definition from "capture.h" to "capture.c".

svn path=/trunk/; revision=499
1999-08-15 22:31:22 +00:00
Guy Harris 4df5d62d6e "open_cap_file()", if it succeeds, closes any capture file we had open;
that means it destroys any read filter we had, so we don't need to
destroy it in "capture()" after "open_cap_file()" succeeds.

svn path=/trunk/; revision=498
1999-08-15 22:16:59 +00:00
Guy Harris 0171508113 Don't preserve the read filter from file to file - you won't necessarily
want to read the next file with the same filter that you used on the
last file.

In the "File/Open" dialog box, parse the read filter before trying to
open the file, and if the parse fails, leave the dialog box up so the
user still has the filter and file name around and can try to fix the
problem.

Keep the compiled read filter attached to the "capture_file" structure,
so you don't have to reparse it on a "File/Reload".

svn path=/trunk/; revision=497
1999-08-15 19:18:46 +00:00
Gilbert Ramirez 77e429e1b9 Fixed the problem with an assert coming from gtkwidget.c:3196 when
selecting a field from more than one protocol tree. It turns out that
gtktree.c doesn't clear the tree-item selection list when you use
gtk_tree_clear_items() (which calls gtk_tree_remove_items() ). So the next
time a tree item is selected in a new protocol tree (which is our old
protocol tree, with everything removed, and new things added), gtk_tree
tries to _deselect_ our old selection. But that tree-item which is trying
to be deselected is long gone, resulting in the assert because widget == NULL.
A function needs to be added to gtk_tree to deselect the tree-item selection
for us. (or we need to go through the hassle of creating a new gtk_tree
instead of recycling tree_view over and over).

I stole some code from another section of gtktree.c which lets us clear
the selection in clear_tree_and_hex_views().

Also, I modified the argument to gtk_tree_set_view_mode. We were using
"TRUE", when really we should have used a member of the GtkTreeViewMode
enumeration, namely GTK_TREE_VIEW_ITEM ( which is 1, which is TRUE :-)

svn path=/trunk/; revision=496
1999-08-15 07:28:23 +00:00
Guy Harris 8f0acf3551 Have "wtap_open_offline()" return, on failure, an indication of the
reason for the failure, and have it do the checks to make sure the file
being opened is a plain file or a pipe.

Have "open_cap_file()" make use of that.

Don't automatically set "last_open_dir" if a "-r" flag was specified on
the command line - do so only if the file in question could actually be
opened.

svn path=/trunk/; revision=495
1999-08-15 06:59:13 +00:00
Guy Harris f452748340 "read_cap_file()" doesn't need to be passed a file name as an argument -
it's called after "open_cap_file()" has been called, and is always
passed the file name passed to "open_cap_file()", and that file name is
stored as "cf->filename", so "read_cap_file()" can just use
"cf->filename" as the pathname of the file.

svn path=/trunk/; revision=494
1999-08-15 01:02:26 +00:00
Guy Harris 8042652058 Oops, forgot to get rid of the "open_cap_file()" in "load_cap_file()"
when I turned the latter into "read_cap_file()".

svn path=/trunk/; revision=493
1999-08-15 00:55:22 +00:00
Guy Harris ea6a522b28 Split "load_cap_file()" into "open_cap_file()" and "read_cap_file()".
The former, which used to be called by "load_cap_file()", now just opens
the file and, if the open succeeds, closes any capture file we
previously had open, reinitializes any protocols that need
reinitialization, and saves information about the new capture file in
the "capture_file" structure to which it was passed a pointer.  The
latter reads the file already opened by "read_cap_file()".

For "File/Open", call "open_cap_file()" before dismissing the file
selection box; if it fails, "open_cap_file()" will have popped up a
message box complaining about it - just return, leaving the file
selection box open so the user can, after dismissing the message box,
either try again with a different file name, or dismiss the file
selection box.  (Other file selection boxes should be made to work the
same way.)  If "open_cap_file()" succeeds, dismiss the file selection
box, and read the capture file in.

svn path=/trunk/; revision=492
1999-08-15 00:26:11 +00:00
Guy Harris 9e58014e7f Add ICMP to the set of packet types counted in the window shown while a
capture is in progress.

svn path=/trunk/; revision=491
1999-08-14 23:47:20 +00:00
Gilbert Ramirez 499f907269 Fixed File|Save As (it was using wrong variable for source filename).
Ethereal now remembers the directory where it last opened a file, either
via the GUI File|Open or command-line '-r' option. The next time File|Open
is used, browsing starts from that directory.

svn path=/trunk/; revision=490
1999-08-14 19:53:31 +00:00