Commit Graph

38 Commits

Author SHA1 Message Date
Guy Harris 005588b8b9 In a Network Monitor capture file, get the starting offsets of frames
from the frame table - Network Monitor 2.x, at least, doesn't always
write frame N+1 right after frame N.

To do that, we need to mallocate a big array to hold the frame table,
and free it when we close the capture file; this requires that we have
capture-file-type-specific close routines as well as
capture-file-type-specific read routines - we let it the pointer to that
routine be null if it's not needed.  Given that, we might as well get
rid of the switch statement in "wtap_close()", in favor of using
capture-file-type-specific close routines, as per the comment before
that switch statement.

svn path=/trunk/; revision=1740
2000-03-22 07:06:59 +00:00
Guy Harris 3e067b812c Fix files that had Gilbert's old e-mail address or that didn't have my
forwarding e-mail address.

svn path=/trunk/; revision=1522
2000-01-22 06:22:44 +00:00
Guy Harris 7a36bede0b We are obliged to define HAVE_UNISTD_H in "config.h"; to avoid the
hideous problem on FreeBSD 3.[23] (and perhaps other BSDs) if
HAVE_UNISTD_H is defined before "zlib.h" is included, turn "file_seek()"
into a subroutine defined in a file that *undefines* HAVE_UNISTD_H
before including "zlib.h", so that the *only* call to "gzseek()" is made
from a file that does not have HAVE_UNISTD_H defined when it includes
"zlib.h".

Move "file_error()" to that file while you're at it, so it holds all the
wrappers that hide the presence or absence of zlib from routines to read
capture files.

Turn "file.h", which declared those wrapper functions as well as wrapper
macros, into "file_wrapper.h" - it belongs with the "file_wrapper.c"
file that defines the wrapper functions, not with "file.c" which handles
higher-layer file access functions.

Remove the comment in "configure.in" that explained why defining
HAVE_UNISTD_H was a bad idea, as we're not obliged to define it and work
around the problem.  (The comment in "file_wrapper.c" explains the
workaround.)

svn path=/trunk/; revision=1463
2000-01-13 07:09:20 +00:00
Guy Harris e15761f1a5 Put the "." in "V.120".
svn path=/trunk/; revision=1305
1999-12-12 22:53:25 +00:00
Gilbert Ramirez 4a15f6582a Added Bert Driehuis <driehuis@playbeing.org>'s I4B wiretap module
and V.120 decoder.

svn path=/trunk/; revision=1304
1999-12-12 22:40:10 +00:00
Guy Harris 959e02e540 Provide a table of descriptive and short (command-line) names for
encapsulation types, and routines to translate encapsulation types to
names and short names to encapsulation types, for the benefit of
"editcap".

svn path=/trunk/; revision=1212
1999-12-05 01:24:54 +00:00
Guy Harris 3b93574402 Add some infrastructure for the use of Ethereal, so it can make a list
of all the file types in which a file can be saved.

Giving each dumpable file type a routine that checks whether a file of a
given file type and encapsulation can be written lets us hoist some
checks into common code from out of the open routines.

If the "dump close" routine for a dump stream is NULL, have that mean
that there's no action that needs to be taken on a close by the code to
handle that file type; some file types don't need that, as they can be
written purely sequentially.

svn path=/trunk/; revision=1200
1999-12-04 08:32:14 +00:00
Gilbert Ramirez 9b6369af4b Support for iptrace 1.0 traces (AIX 3). Thanks to Florian Lohoff
<flo@rfc822.org> for the sample traces.

It turns out that the iptrace 2.0 header is simply an extension to
the iptrace 1.0 header. It also appears that iptrace 1.0 has only tv_sec, but
not tv_usec, which explains why the fields are separated in the iptrace 2.0
header, but doesn't explain why the iptrace 2.0 header has tv_sec copied
in two places.

I changed iptrace.c to detect FDDI captures via if_type, even though I
don't have a trace to substantiate this. If *should* work, given that
loopback, ethernet, token-ring, and X.25 work. If it doesn't work, someone
will let me know.

svn path=/trunk/; revision=1117
1999-11-26 17:57:14 +00:00
Gilbert Ramirez 0bf0d908ae More small memleak fixes.
colors.c wasn't freeing path in one place
main.c wasn't freeing rc_file
the frame_buffer fix in wtap.c didn't clear everything.

svn path=/trunk/; revision=1001
1999-11-10 19:58:54 +00:00
Gilbert Ramirez 02a64faea7 Fixed small memory leak in wiretap (frame_buffer wasn't being freed),
and aligned g_malloc calls with g_free calls (i.e, we no longer mix-and-match
C-library malloc with GLIB g_free, and vice-versa).

svn path=/trunk/; revision=1000
1999-11-10 19:47:57 +00:00
Guy Harris d49b158b49 Add in a gross heuristic that attempts to detect files with the version
of the "libpcap" patch that changes the per-packet header but not the
magic number - it seems to work on at least one capture file I tried it
on.

Give the modified "libpcap" format a WTAP_FILE type of its own (so that,
in the future, we could support writing captures out in that format,
possibly).

svn path=/trunk/; revision=987
1999-11-06 10:31:47 +00:00
Gilbert Ramirez 558e714449 Add a module to wiretap to be able to read trace files from Toshiba's
line of ISDN routers. Much like the ascend reader, this module reads an
ASCII hex dump of trace data.

Rearranged the order in which wiretap tries trace files, to keep the
ASCII-readers (ascend and toshiba) at the end, and put the binary-readers
(everything else) at the front of the list. If a telnet session of
and ascend trace or toshiba trace were captured near the beginning of
another trace, wiretap might think the trace was ascend or toshiba if it
tried that module first.

Fixed the way wtap_seek_read() selects functions to call. It was using
the encap type instead of the file type. We got lucky because
WTAP_ENCAP_ASCEND == WTAP_FILE_ASCEND

svn path=/trunk/; revision=952
1999-10-31 17:46:11 +00:00
Guy Harris dbd1955d62 Olivier Abad's patches to add:
more display filters for X.25;

	no LCN in X.25 RESTART / DIAGNOSTIC / REGISTRATION packets;

	support for nettl file format (nettl is a trace tool for HP-UX).
	For now, it only supports traces for X.25 interfaces (tested
	with HP-UX 10.20).

svn path=/trunk/; revision=879
1999-10-18 01:51:34 +00:00
Guy Harris 0d43b16fdd Add "wtap_file_encap()", to return the encapsulation of packets in the
file (which could be WTAP_ENCAP_UNKNOWN, if we couldn't determine it, or
WTAP_ENCAP_PER_PACKET, if we could determine the encapsulation of
packets in the file, but they didn't all have the same encapsulation).
This may be useful in the future, if we allow files to be saved in
different capture file formats - we'd have to specify, when creating the
capture file, the per-file encapsulation, for those formats that don't
support per-packet encapsulations (we wouldn't be able to save a
multi-encapsulation capture in those formats).

Make the code to read "iptrace" files set the per-file packet
encapsulation - set it to the type of the first packet seen, and, if any
subsequent packets have a different encapsulation, set it to
WTAP_ENCAP_PER_PACKET.

svn path=/trunk/; revision=772
1999-10-06 03:29:36 +00:00
Guy Harris 66c411777b Make "wtap_strerror()" handle zlib errors *correctly*.
svn path=/trunk/; revision=770
1999-10-05 07:22:53 +00:00
Guy Harris 5f7868c7e0 Better handle errors from zlib:
Assign a range of Wiretap errors for zlib errors, and have
	"wtap_strerror()" use "zError()" to get an error message for
	them.

	Have the internal "file_error()" routine return 0 for no error
	and a Wiretap error code for an error.

svn path=/trunk/; revision=769
1999-10-05 07:06:08 +00:00
Guy Harris a9c36a4b69 Fix it so that it builds with "--disable-zlib".
The "fh" member of a "wtap" structure points to something constructed
from the "fd" member of that structure, so that closing the stream
referred to by "fh" also closes the underlying file descriptor; get rid
of an unnecessary close of "wth->fd".

svn path=/trunk/; revision=720
1999-09-24 05:49:53 +00:00
Ashok Narayanan 501b9b05e1 Adds progress bar functionality back for loading files (it was changed to
bounce bar for compressed file support). Note that the progress bar may
not grow smoothly for compressed files, but it should be reasonably accurate
for files which are large enough to matter.

svn path=/trunk/; revision=701
1999-09-23 04:39:01 +00:00
Ashok Narayanan 3dfa56c498 This commit contains support for reading capture files compressed using
gzip. The zLib library is used for this purpose. If zLib is not available
(or it's use is disabled by the --disable-zlib option to configure), you
can still compile Ethereal but it will be unable to read compressed capture
files.

IMPORTANT:

Now all file accesses to capture files should be done through special macros.
Specifically, for any use of the following functions on capture files, replace them.
The arguments for the right-side functions are exactly the same as for the
original stdio functions.

	fopen			file_open
	fdopen			filed_open
	fread			file_read
	fwrite			file_write
	fseek			file_seek
	fclose			file_close
	ferror			file_error

svn path=/trunk/; revision=695
1999-09-22 01:26:50 +00:00
Guy Harris de7081f8ff Include "ascend.h" to declare "ascend_seek_read()".
"wtap_seek_read()" should return the value of "ascend_seek_read()" or
"wtap_def_seek_read()".

svn path=/trunk/; revision=656
1999-09-11 06:48:33 +00:00
Gerald Combs 9386f23fee Added support for Lucent/Ascend packet traces. The MAX and Pipeline router
family has a set of debug commands that allow you to log the traffic on a
WAN or dialup connection as text, e.g.

RECV-iguana:241:(task: B04E12C0, time: 1975358.50) 15 octets @ 8003D634
  [0000]: FF 03 00 3D C0 06 C9 96 2D 04 C1 72 00 05 B8

Created wtap_seek_read() which parses the textual data for and Ascend
trace, and does a normal fseek() and fread() for any other file type.
The fseek()/fread() pairs in file.c were replaced with the new function.

svn path=/trunk/; revision=652
1999-09-11 04:50:44 +00:00
Guy Harris 5a2b4b7ad2 Fix the pcap-encapsulation-to-wiretap-encapsulation mapping table.
Have the code that opens "libpcap" files for writing check to make sure
that the Wiretap encapsulation can be written to a "libpcap" file, and
return -1 and supply a new WTAP_ERR_UNSUPPORTED_ENCAP error code if it
can't.

Handle that new error code in "wtap_strerror()".

svn path=/trunk/; revision=546
1999-08-22 03:50:31 +00:00
Guy Harris c82c5954f2 Add a "wtap_strerror()" routine, which takes as an argument an error
code supplied by a Wiretap routine (whether a positive UNIX "errno" code
or a negative Wiretap error code), and returns an error message
corresponding to it.

Use that to construct the message Ethereal put up in a message box for
those errors for which we don't have Ethereal put up a message of its
choice.

svn path=/trunk/; revision=545
1999-08-22 02:52:48 +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
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 582a64f482 Add to "wtap_close()" code to free up data structures allocated for
reading RADCOM WAN/LAN analyzer files and NetXRay/Windows Sniffer files.

svn path=/trunk/; revision=418
1999-08-02 02:35:57 +00:00
Guy Harris 79c2223425 Check in Olivier Abad's patch to add dissectors for LAP-B and X.25, and
wiretap support for RADCOM Ltd.'s WAN/LAN analyzers (see

	http://www.radcom-inc.com/

).  Note: as I remember, IEEE 802.2/ISO 8022 LLC has somewhat of an SDLC
flavor to it, just as I think LAP, LAPB, LAPD, and so on do, so we may
be able to combine some of the LLC dissection and the LAPB dissection
into common code that could, conceivably be used for other SDLC-flavored
protocols.

Make "S" a mnemonic for "Summary" in the "Tools" menu.

Move the routine, used for the "Tools/Summary" display, that turns a
wiretap file type into a descriptive string for it into the wiretap
library itself, expand on some of its descriptions, and add an entry for
files from a RADCOM analyzer.

Have "Tools/Summary" display the snapshot length for the capture.

svn path=/trunk/; revision=416
1999-08-02 02:04:38 +00:00
Laurent Deniel c42634dd82 Fix the -S option :
- read only the real number of packets that have been written
  by the child process. That's avoid incomplete packet read.
- special timeout handling no more necessary and the whole
  real time capture and display behavior is much more
  satisfying with this patch.
- wiretap modified to allow the reading of 'count' packets
  with wtap_loop.

svn path=/trunk/; revision=398
1999-07-28 20:17:24 +00:00
Gilbert Ramirez 601c52f0fb Added support for compiling on win32 with Visual C and 'nmake'. It compiles,
but does not link. Perhaps someone who understands the MS tools can help
out. I made it link a few months ago, but with different version of glib/gtk+.
I can't remember how I made it link.

Most of the compatibility issues were resolved with adding
#ifdef HAVE_UNISTD_H the the source code. Please be sure to add this to all
future code.

svn path=/trunk/; revision=359
1999-07-13 02:53:26 +00:00
Gilbert Ramirez 9f9d19f529 Removed old #include's.
svn path=/trunk/; revision=343
1999-07-07 22:58:37 +00:00
Gilbert Ramirez 07f42b5b31 Created a new protocol tree implementation and a new display filter
mechanism that is built into ethereal. Wiretap is now used to read all
file formats. Libpcap is used only for capturing.

svn path=/trunk/; revision=342
1999-07-07 22:52:57 +00:00
Gilbert Ramirez 2dbd008ea5 Added display filters to wiretap.
svn path=/trunk/; revision=198
1999-03-01 18:57:07 +00:00
Gilbert Ramirez bba66b6f0f Change to wtap.c switch() statement to allow compilation under IBM's C compiler.
It didn't like an empty default case. And <time.h> was forgotten in netmon.c

svn path=/trunk/; revision=188
1999-02-12 16:26:09 +00:00
Gilbert Ramirez a68f557e27 Use g_free instead of free so that I don't have to include <stdlib.h>
for just one function.

svn path=/trunk/; revision=165
1999-01-08 17:24:01 +00:00
Gilbert Ramirez 7757b2e72b I removed the per-file encapsulation type from wiretap, and make all filetypes
provide a per-packet encapsulation type. this required minor modifications to
ethereal.

svn path=/trunk/; revision=162
1999-01-07 16:15:37 +00:00
Guy Harris 86bf1fc851 Add support to wiretap for reading Sun "snoop" capture files.
That requires that, in the packet-reading loop, we pass to the callback
routine the offset in the file of a packet's data, because we can no
longer compute that offset by subtracting the size of the captured
packet data from the offset in the file after the data was read -
"snoop" may stick padding in after the packet data to align packet
headers on 4-byte boundaries.

Doing that required that we arrange that we do that for "libpcap"
capture files as well; the cleanest way to do that was to write our own
code for reading "libpcap" capture files, rather than using the
"libpcap" code to do it.

Make "wtap_dispatch_cb()" and "pcap_dispatch_cb()" static to "file.c",
as they're not used elsewhere.

If we're using wiretap, don't define in "file.h" stuff used only when
we're not using wiretap.

Update the wiretap README to reflect Gilbert's and my recent changes.

Clean up some memory leaks in "wiretap/lanalyzer.c" and
"wiretap/ngsniffer.c", where the capture-file-format-specific data
wasn't freed if the open failed.

svn path=/trunk/; revision=91
1998-11-15 05:29:17 +00:00
Gilbert Ramirez c0f191e9e0 I added the LANalzyer file format to wiretap. I cleaned up some code in the
wiretap functions to be more generic and therefore allow an easier integration
of more packet-capture file types. I also put in all the GPL copyrights in the
wiretap code.

svn path=/trunk/; revision=83
1998-11-12 06:01:27 +00:00
Gilbert Ramirez fcb4c78a6a A lengthy patch to add the wiretap library. Wiretap is not used by default
because it is still in its infancy, but it can be compiled in optionally.
The library exists in its own subdirectory ethereal/wiretap. This patch also
edits all the packet-*.c files to remove the #include <pcap.h> line which is
unnecessary in these files. In the ethereal code, file.c is the most heavily
modified with #ifdef WITH_WIRETAP lines for the optional library.

svn path=/trunk/; revision=82
1998-11-12 00:06:47 +00:00