Commit Graph

202 Commits

Author SHA1 Message Date
Guy Harris 1df4ee9109 Crank up the maximum frame table size to 512*2^20 packets, that being a
small amount bigger than the maximum possible number of packets in a
NetMon file.

svn path=/trunk/; revision=40174
2011-12-13 06:45:16 +00:00
Guy Harris 89303e99c4 Add an arbitrary limit on the maximum size of the frame table, so that
we don't crash.  Fixes bug 6669.

svn path=/trunk/; revision=40168
2011-12-13 01:49:27 +00:00
Guy Harris 9b9bd6d27b Add checks to make sure we don't overflow the maximum 32-bit file
offset.

svn path=/trunk/; revision=39915
2011-11-17 20:17:36 +00:00
Guy Harris 9dc26776e4 Add support for writing WTAP_ENCAP_PER_PACKET files; they are written
out in version 2.1 of the file format (the minimum version to support
that).

Change some data types to avoid having file offsets that are before the
beginning of the file.

Clean up some other data types and some comments.

svn path=/trunk/; revision=39898
2011-11-17 09:03:09 +00:00
Guy Harris 8281a7d28e Support nanosecond-resolution time for NetMon 2.x format (it's only
100-nanosecond resolution, but that's still better than microsecond
resolution).

For NetMon 1.x format, only claim to support millisecond resolution, as
that's all you get.

Fix handling of negative time deltas in NetMon 2.x format.

When writing a NetMon file, trim the time of the first packet to
millisecond precision to get the capture start time, so that the start
time written to the file (which has millisecond precision) is the same
as the start time used to calculate the deltas written to the packet
headers.

svn path=/trunk/; revision=39886
2011-11-16 17:54:44 +00:00
Guy Harris e9fc1b72aa Use guint8 rather than guchar for raw octets and pointers to arrays of
same.

Add to wiretap/pcap-common.c a routine to fill in the pseudo-header for
ATM (by looking at the VPI, VCI, and packet data, and guessing) and
Ethernet (setting the FCS length appropriately).  Use it for both pcap
and pcap-ng files.

svn path=/trunk/; revision=38840
2011-09-01 09:43:10 +00:00
Guy Harris 306711b634 Note what NetMon 3 actually uses various types for.
For the ones that are used for raw IP, use WTAP_ENCAP_RAW_IP.  (Yes,
NetMon checks for v4 vs. v6 for all of them.)

svn path=/trunk/; revision=36975
2011-05-03 09:14:56 +00:00
Guy Harris 99c6704109 Set the pseudo-header regardless of whether we have a trailer or not.
svn path=/trunk/; revision=36974
2011-05-03 08:49:41 +00:00
Guy Harris 59dc3f3141 It appears that, in NetMon 802.11 captures, management frames have an
FCS and data frames don't have an FCS; I don't know about control
frames.

svn path=/trunk/; revision=36973
2011-05-03 08:22:25 +00:00
Guy Harris 6cbf6ce16c Add a new WTAP_ERR_DECOMPRESS error, and use that for errors discovered
by the gunzipping code.  Have it also supply a err_info string, and
report it.  Have file_error() supply an err_info string.

Put "the file" - or, for WTAP_ERR_DECOMPRESS, "the compressed file", to
suggest a decompression error - into the rawshark and tshark errors,
along the lines of what other programs print.

Fix a case in the Netscaler code where we weren't fetching the error
code on a read failure.

svn path=/trunk/; revision=36748
2011-04-21 09:41:52 +00:00
Guy Harris 2b8ebd389b "This file format can't be written to a pipe" and "this file format
can't be saved in compress form" are both equivalent to "this file file
format requires seeking when writing it".  Change the "can compress"
Boolean in the file format table to "writing requires seeking", give all
the entries the proper value, and do the checks for attempting to write
a file format to a pipe or write it in compressed format to common code.

This means we don't need to pass the "can't seek" flag to the dump open
routines.

svn path=/trunk/; revision=36575
2011-04-12 00:44:44 +00:00
Guy Harris 4c93827e34 From Jakub Zawadzki:
file_read(buf, bsize, count, file) macro is compilant with fread
function and takes elements count+ size of each element, however to make
it compilant with gzread() it always returns number of bytes.

In wiretap file_read() this is not really used, file_read is called
either with bsize set to 1 or count to 1.

Attached patch remove bsize argument from macro.

svn path=/trunk/; revision=36491
2011-04-06 06:51:19 +00:00
Guy Harris c8fd1ca472 It is not guaranteed that the records in numerical (frame table) order
will be in sequential (byte offset) order in the file; don't treat the
record offset going backwards as an error.

svn path=/trunk/; revision=35291
2010-12-28 20:32:58 +00:00
Guy Harris 99a086051b At least in some NetMon 3.4 VPN captures, the per-packet link-layer type
is 0, but the packets have Ethernet headers.  We handle this by mapping
0 to WTAP_ENCAP_ETHERNET.

(XXX - should we, instead, use the per-file link-layer type?)

svn path=/trunk/; revision=33620
2010-07-23 10:11:44 +00:00
Guy Harris 1da49c2899 The 32-bit unsigned time offset in version 1.x files should be converted
to a gint64 (which won't sign-extend it) before multiplying by 1000, so
that the product is 64-bit and won't overflow.

svn path=/trunk/; revision=33609
2010-07-21 18:37:01 +00:00
Guy Harris 45c49c957f According to mail from Paul Long at Microsoft, in the 1.x NetMon file
format, the time offset from the start of the capture always had a
positive value, so it's an unsigned value.  (In newer versions of NetMon
3.x, the capture can start before the "capture start" time stamp is set,
so packets can have a *negative* offset from the capture start time
stamp.  Those captures are in the 2.x file format.)

svn path=/trunk/; revision=33607
2010-07-21 16:25:59 +00:00
Guy Harris d1751061c8 Initial support for Network Monitor 802.11 radio header.
svn path=/trunk/; revision=33583
2010-07-19 18:00:20 +00:00
Guy Harris 9903a7853c The time delta in a NetMon frame header is signed - it can be negative.
svn path=/trunk/; revision=33576
2010-07-18 20:47:48 +00:00
Guy Harris 770dc398a4 NetMon per-packet link-layer types with 0xE000 in the upper 4 bits are
converted pcap files; the LINKTYPE_ value is in the lower 12 bits.

svn path=/trunk/; revision=33574
2010-07-18 20:27:46 +00:00
Guy Harris 6cb47bde7a Initial support for the trailer information in versions 2.1 and later of
the NetMon file format.  Currently, we just use the network type field,
and we ignore all the special record types and don't try to handle any
of the other special network types.

We also catch bogus frame tables where the record is bigger than the
frame table says it is.

svn path=/trunk/; revision=33572
2010-07-18 19:41:11 +00:00
Guy Harris 194cfe2d2f Don't use fwrite directly when writing a dump file; call it through
wtap_dump_file_write().  Replace various wrappers around fwrite() with
wtap_dump_file_write(), or at least make the wrappers call
wtap_dump_file_write().

svn path=/trunk/; revision=33116
2010-06-06 22:19:30 +00:00
Guy Harris 17392a865a Move the definitions of all the private data structures out of
wtap-int.h, and change the unions of pointers to those private data
structures into just void *'s.

Have the generic wtap close routine free up the private data, rather
than the type-specific close routine, just as the wtap_dumper close
routine does for its private data.  Get rid of close routines that don't
do anything any more.

svn path=/trunk/; revision=32015
2010-02-26 07:59:54 +00:00
Stephen Fisher 233bb9cd25 When reading NetMon capture files version 2.1 and higher (the latest is 2.2 right
now), the capture file's header encapsulation type is set to 1 for Ethernet for
backwards compability only.  These files use per-packet encapsulation types
instead.  For now, set it to Unknown file encapsulation until we can find a
way to set it to WTAP_ENCAP_PER_PACKET without having to assert in wtap_read()
so the user can see that it is a per-packet encapulation in places such as
the capinfos program.


svn path=/trunk/; revision=31213
2009-12-09 03:27:12 +00:00
Guy Harris 0c95d973d3 No newlines in the additional-error-information string, please.
svn path=/trunk/; revision=28584
2009-06-02 07:18:18 +00:00
Guy Harris ad33ca6c2f Clean up some 64-bit issues.
svn path=/trunk/; revision=28117
2009-04-22 03:07:37 +00:00
Gerald Combs cc739fecb0 P64 fixes.
svn path=/trunk/; revision=27683
2009-03-09 21:18:55 +00:00
Guy Harris 35546bfcc8 Note the version numbers in NetMon 3.0 files.
svn path=/trunk/; revision=22050
2007-06-05 17:17:22 +00:00
Ulf Lamping 59d6c8ea33 change all file offsets from long to gint64 so we can - theoretically - handle files > 2GB correct.
Please distclean Win32 builds!

svn path=/trunk/; revision=19814
2006-11-05 22:46:44 +00:00
Ulf Lamping 723c80ea90 timestamp display precision:
- automatic adjustment depending on file format
- manual adjustment through menu items

save the setting in the recent file

svn path=/trunk/; revision=15534
2005-08-25 21:29:54 +00:00
Ulf Lamping 6f43fbb2f0 EVERYTHING IN THE BUILDBOT IS GOING TO BE RED!!! Sorry!
I've done more than a day to change the timestamp resolution from microseconds to nanoseconds. As I really don't want to loose those changes, I'm going to check in the changes I've done so far. Hopefully someone else will give me a helping hand with the things left ...

What's done: I've changed the timestamp resolution from usec to nsec in almost any place in the sources. I've changed parts of the implementation in nstime.s/.h and a lot of places elsewhere.

As I don't understand the editcap source (well, I'm maybe just too tired right now), hopefully someone else might be able to fix this soon.

Doing all those changes, we get native nanosecond timestamp resolution in Ethereal. After fixing all the remaining issues, I'll take a look how to display this in a convenient way...

As I've also changed the wiretap timestamp resolution from usec to nsec we might want to change the wiretap version number...

svn path=/trunk/; revision=15520
2005-08-24 21:31:56 +00:00
Guy Harris 7b9c1a62a7 Fix some more leaks in error returns from open routines (if the open can
fail after the private data is allocated, you have to free the private
data).

The file header in nettl files is 128 bytes - use a #define for it, and
also a #define for the magic number size.

svn path=/trunk/; revision=14553
2005-06-04 21:58:55 +00:00
Gerald Combs e25b530eb5 From Steve Grubb: Fix a memory leak. Fixes part of bug 217.
svn path=/trunk/; revision=14500
2005-05-30 21:08:16 +00:00
Guy Harris 8a8b883450 Set the svn:eol-style property on all text files to "native", so that
they have LF at the end of the line on UN*X and CR/LF on Windows;
hopefully this means that if a CR/LF version is checked in on Windows,
the CRs will be stripped so that they show up only when checked out on
Windows, not on UN*X.

svn path=/trunk/; revision=11400
2004-07-18 00:24:25 +00:00
Guy Harris ba72e955dc Have "wtap_read()" set "wth->phdr.pkt_encap" to "wth->file_encap",
rather than requiring individual capture file type handlers to do it
(unless they're doing per-packet encapsulation, in which case we check
to make sure they didn't *leave* it as WTAP_ENCAP_PER_PACKET).

svn path=/trunk/; revision=10290
2004-03-03 22:24:53 +00:00
Guy Harris d6cd61061e Have the Wiretap open, read, and seek-and-read routines return, in
addition to an error code, an error info string, for
WTAP_ERR_UNSUPPORTED, WTAP_ERR_UNSUPPORTED_ENCAP, and
WTAP_ERR_BAD_RECORD errors.  Replace the error messages logged with
"g_message()" for those errors with g_strdup()ed or g_strdup_printf()ed
strings returned as the error info string, and change the callers of
those routines to, for those errors, put the info string into the
printed message or alert box for the error.

Add messages for cases where those errors were returned without printing
an additional message.

Nobody uses the error code from "cf_read()" - "cf_read()" puts up the
alert box itself for failures; get rid of the error code, so it just
returns a success/failure indication.

Rename "file_read_error_message()" to "cf_read_error_message()", as it
handles read errors from Wiretap, and have it take an error info string
as an argument.  (That handles a lot of the work of putting the info
string into the error message.)

Make some variables in "ascend-grammar.y" static.

Check the return value of "erf_read_header()" in "erf_seek_read()".

Get rid of an unused #define in "i4btrace.c".

svn path=/trunk/; revision=9852
2004-01-25 21:55:17 +00:00
Ulf Lamping 467c05b3ea removed some MSVC warnings (conversions between double/float and int)
svn path=/trunk/; revision=9422
2003-12-23 00:16:46 +00:00
Guy Harris 0543fbd427 From Scott Emberley: support for writing Network Instruments Observer
files.

svn path=/trunk/; revision=8900
2003-11-06 22:45:28 +00:00
Guy Harris be2736adcf Have a pseudo-header for Ethernet packets, giving the size of the FCS -
0 means "there is no FCS in the packet data", 4 means "there is an FCS
in the packet data", -1 means "I don't know whether there's an FCS in
the packet data, guess based on the packet size".

Assume that Ethernet encapsulated inside other protocols has no FCS, by
having the "eth" dissector assume that (and not check for an Ethernet
pseudo-header).

Have "ethertype()" take an argument giving the FCS size; pass 0 when
appropriate.

Fix up Wiretap routines to set the pseudo-header.  This means we no
longer use the "generic" seek-and-read routine, so get rid of it.

svn path=/trunk/; revision=8574
2003-10-01 07:11:49 +00:00
Guy Harris 50e696df81 The Sniffer file formats include a file to identify raw cells; export
that flag in the ATM pseudo-header, and use it to determine whether a
frame is a raw cell or a reassembled frame, rather than using the AAL,
as you can have raw AAL5 cells in a capture.

svn path=/trunk/; revision=6889
2003-01-10 04:04:42 +00:00
Guy Harris db1246913e Cast "secs" to "double" before multiplying by 1000000, so that we don't
get an overflow if secs*1000000 doesn't fit in 31 bits.

svn path=/trunk/; revision=6858
2003-01-06 20:30:38 +00:00
Guy Harris 0a5be3f18b Rename WTAP_ENCAP_ATM_SNIFFER to WTAP_ENCAP_ATM_PDUS, as it's not just
used for the DOS-based ATM Sniffer.  (That's not a great name, but I
couldn't think of a better one.)

Add a new WTAP_ENCAP_ATM_PDUS_UNTRUNCATED encapsulation type for capture
files where reassembled frames don't have trailers, such as the AAL5
trailer, chopped off.  That's what at least some versions of the
Windows-based ATM Sniffer appear to have.

Map the ATM capture file type for NetXRay captures to
WTAP_ENCAP_ATM_PDUS_UNTRUNCATED, and put in stuff to fill in what we've
reverse-engineered, so far, for the pseudo-header; there's more that
needs to be done on it, e.g. getting the channel, AAL type, and traffic
type (or inferring them if they're not in the packet header).

svn path=/trunk/; revision=6840
2003-01-03 06:45:45 +00:00
Jörg Mayer 64b6acac6d Removed trailing whitespaces from .h and .c files using the
winapi_cleanup tool written by Patrik Stridvall for the wine
project.

svn path=/trunk/; revision=6115
2002-08-28 20:30:45 +00:00
Guy Harris 77bb2477ba Get rid of the "vpi" and "vci" arguments to "atm_guess_traffic_type()",
have it get that information from the pseudo-header instead, and set the
VPI and VCI fields in the pseudo-header before calling it.

Don't call it for non-ATM NetMon captures.

svn path=/trunk/; revision=5982
2002-08-13 03:32:57 +00:00
Guy Harris 8616a33765 Use "atm_guess_traffic_type()" to guess the ATM traffic type for ATM
NetMon captures.

svn path=/trunk/; revision=5981
2002-08-13 03:26:30 +00:00
Guy Harris 6e21561be8 From Joerg Mayer:
All files:
  - Replace types from sys/types.h by those from glib.h
  - Replace ntoh family of macros from netinet/in.h and winsock2.h
    by g_ntoh family from glib.h
  - Remove now unneeded includes of sys/types.h, netinet/in.h and
    winsock2.h
wtap.h
  Move includes to the top

svn path=/trunk/; revision=5909
2002-07-29 06:09:59 +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
Guy Harris 2aad75bb82 Graeme Hewson noted that zlib has a bug wherein "gzseek()" doesn't set
the internal z_err value for the stream if an "fseek()" call it makes
fails, so that if "gzerror()" is subsequently called, it returns Z_OK
rather than an error.

To work around this, we pass "file_seek()" an "int *err", and have the
with-zlib version of "file_seek()" check, if "gzseek()" fails, whether
the return value of "file_error()" is 0 and, if so, have it return
"errno" instead.

svn path=/trunk/; revision=5642
2002-06-07 07:27:35 +00:00
Guy Harris 15a5bdca30 The frame table isn't needed once we've made a sequential pass through
the packets, as the offsets of the frames have been saved by our caller
(because they need them to pass to the random-read routine); add a
sequential_close routine for Netmon files and free up the frame table in
that routine.

svn path=/trunk/; revision=5618
2002-06-04 21:55:38 +00:00
Guy Harris 82f364ab1a Fix capture-file-specific "close output" routines to check whether the
"err" argument is null and return an error code through that argument
only if it isn't, to match what "wtap_dump_close()", which calls those
routines, does.

Put the NetXRay dump routines in order by version number.

svn path=/trunk/; revision=5385
2002-05-04 10:00:18 +00:00
Guy Harris 329b59c858 Uniformly use "sizeof (struct netmon_atm_hdr)" for the size of Network
Monitor's ATM pseudo-header.

Fix a message.

svn path=/trunk/; revision=5303
2002-04-30 09:21:41 +00:00
Guy Harris ecb2a3939e Replace the "ngsniffer_atm" with an "atm" pseudo-header, which isn't
just an image of the ATM Sniffer data.  This means that Ethereal doesn't
have to know any ATM Sniffer-specific details (that's all hidden in
Wiretap), and allows us to add to that pseudo-header fields, traffic
types, etc. unknown to ATM Sniffers.

Have Wiretap map VPI 0/VCI 5 to the signalling AAL - for some capture
files, this might not be necessary, as they may mark all signalling
traffic as such, but, on other platforms, we don't know the AAL, so we
assume AAL5 except for 0/5 traffic.  Doing it in Wiretap lets us hide
those details from Ethereal (and lets Ethereal interpret 0/5 traffic as
non-signalling traffic, in case that happens to be what it is).

We may know that traffic is LANE, but not whether it's LE Control or
emulated 802.3/802.5; handle that case.

svn path=/trunk/; revision=5302
2002-04-30 08:48:27 +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 d54bd0bd6b Check for errors in seeks, "tell"s, and "stat()"s/"fstat()"s.
For file types where we allocate private data, add "close" routines
where they were missing, to free the private data.  Also fix up the code
to clean up after some errors by freeing private data where that wasn't
being done.

Get rid of unused arguments to "wtap_dump_open_finish()".

Fix indentation.

svn path=/trunk/; revision=4857
2002-03-04 00:25:35 +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 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 32b4f58cd7 From Motonori Shindo: protect include of <netinet/in.h> with #ifdef
HAVE_NETINET_IN_H.

svn path=/trunk/; revision=4610
2002-01-25 09:44:52 +00:00
Guy Harris 886b4994ec Add support for ATM captures (based on writing one out and handing it to
NetMon 2.0; I don't have any ATM captures *from* NetMon to try it on, so
I don't know what significance the "destination address" and "source
address" fields have, but we can at least read the captures we ourselves
write out, as can NetMon).

svn path=/trunk/; revision=4606
2002-01-24 23:02:56 +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 f14a6b8b91 Hopefully the last time I have to change my e-mail address.
svn path=/trunk/; revision=4199
2001-11-13 23:55:44 +00:00
Gilbert Ramirez a505b64912 Get rid of signed/unsigned comparison warnings in wiretap.
svn path=/trunk/; revision=4077
2001-10-25 20:29:24 +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 606d363a9b The return value from "fwrite()" is a "size_t"; make the variable into
which we store it a "size_t", and then fix up the bugs that were
revealed by the compiler warnings that produced - "fwrite()" returns 0,
not a negative number, on an I/O error.

Fix up some other items to have type "size_t", or to have various
unsigned types, while we're at it, to squelch compiler warnings.

svn path=/trunk/; revision=3867
2001-08-25 03:18:48 +00:00
Guy Harris b7255e108a Fixes, from Scott Renfro, for some calls to "localtime()" that didn't
check whether the call succeeded (it doesn't always do so on Windows,
for example).

svn path=/trunk/; revision=3722
2001-07-15 19:14:03 +00:00
Guy Harris f7b50ca754 From Joerg Mayer:
* gcc 3.0 warning fixes:
  - text2pcap.c: The number of characters to scan should probably not be 0
  - wiretap/csids.c: using preincrement on a variable used on both
    sides of an assignment might be undefined by the C99(?) standard
 * turn on additional warnings for epan and wiretap too
  - epan/configure.in
  - wiretap/configure.in
 * Fix some warnings (missing includes, signed/unsigned, missing
    initializers) found by turning on the warnings
  - all other files :-)

svn path=/trunk/; revision=3709
2001-07-13 00:55:58 +00:00
Guy Harris a251addb63 Obliging every capture file reader's "open()" routine to seek to the
beginning of the file before reading anything from the file is bogus -
do that in the loop that tries each of the open routines, instead.
(They may have to reset the seek pointer later if, for example, the
capture file begins with the first packet, and the "open()" routine
looks at that packet to try to guess whether the packet is in the file
format in question.)

Set "wth->data_offset" to 0 while you're at it, so capture file readers
don't have to do that, either.

svn path=/trunk/; revision=3123
2001-03-10 06:33:58 +00:00
Guy Harris f72f3b7861 Finish up support for writing NetMon 2.x capture files.
(We really need to put in some rudimentary 64-bit integer support, for
the benefit of platforms+compilers that don't support it; the
floating-point calculations we're doing now appear not to get exactly
the right answer, from an experiment at reading a NetMon 2.x file and
writing it back out as NetMon 2.x with editcap.)

svn path=/trunk/; revision=2939
2001-01-25 21:47:23 +00:00
Guy Harris 4933cc340f "wtap_read()" must *always* set "*err" when it returns FALSE - if it's
just an EOF, it should set "*err" to 0.  Fix up a bunch of read routines
for various capture file types to set "*err" appropriately.

svn path=/trunk/; revision=2667
2000-11-19 03:47:36 +00:00
Gilbert Ramirez c312f69abc Make sure to pass the sent/received direction from pppdump.c in
pseudo_header.
Use generic "p2p_phdr" instead of "lapd_phdr". Modify toshiba.c and
packet-lapd.c to take that into account.
Add frame.p2p_dir, a filterable field, 0=sent, 1=recvd
Make p2p_dir available in packe_info, as I think it will be needed
in VJ COMP and UNCOMP dissection.

Rename WTAP_ENCAP_TR to WTAP_ENCAP_TOKEN_RING.

Mention pppd-log support in man page.
Mention atmsnoop in README.

svn path=/trunk/; revision=2455
2000-09-21 04:41:37 +00:00
Gilbert Ramirez f52ffba407 Change wtap_read() API so that the data offset is set via a pointer, and
a "keep reading" boolean value is returned from the function.
This avoids having to hack around the fact that some file formats truly
do have records that start at offset 0. (i4btrace and csids have no
file header. Neither does the pppdump-style file that I'm looking at right now).

svn path=/trunk/; revision=2392
2000-09-07 05:34:23 +00:00
Gilbert Ramirez 4a3b77ba46 Move #include <time.h> into wtap-int.h instead of requiring it in
every C file. I noticed this because of a build break of csids.obj on
Win32.

svn path=/trunk/; revision=2378
2000-08-25 21:25:43 +00:00
Gilbert Ramirez d7e6e0e384 Add wtap-int.h. Move definitions relevant to the internal workins of wiretap
to that file, leave public definitions in wtap.h.

Rename "union pseudo_header" to "union wtap_pseudo_header".
Make the wtap_pseudo_header pointer available in packet_info struct.

svn path=/trunk/; revision=1989
2000-05-19 23:07:04 +00:00
Guy Harris f3d90d30a4 Remove the "union pseudo_header" from the "frame_data" structure;
there's no need to keep it around in memory - when the frame data is
read in when handing a frame, read in the information, if any, necessary
to reconstruct the frame header, and reconstruct it.  This saves some
memory.

This requires that the seek-and-read function be implemented inside
Wiretap, and that the Wiretap handle remain open even after we've
finished reading the file sequentially.

This also points out that we can't really do X.25-over-Ethernet
correctly, as we don't know where the direction (DTE->DCE or DCE->DTE)
flag is stored; it's not clear how the Ethernet type 0x0805 for X.25
Layer 3 is supposed to be handled in any case.  We eliminate
X.25-over-Ethernet support (until we find out what we're supposed to
do).

svn path=/trunk/; revision=1975
2000-05-18 09:09:50 +00:00
Guy Harris 0fdd93d1ce Rename the "private" member of a "wtap_dumper" structure to "dump", as
per the "capture" member of a "wtap" structure, so that it doesn't
collide with the C++ reserved word "private".

svn path=/trunk/; revision=1936
2000-05-10 22:16:31 +00:00
Guy Harris 0df6b59a91 Make the previous checkin actually compile on big-endian machines.
svn path=/trunk/; revision=1742
2000-03-22 23:47:28 +00:00
Guy Harris 1c07cd9b89 Byte-swap the frame table on big-endian machines.
Free it as soon as we're at the end of the sequential pass through the
file; that way, if we keep the capture file open with Wiretap even after
that's done (as I may do as part of some stuff I'm working on), we
at least aren't hanging on to the frame table memory after that point.

svn path=/trunk/; revision=1741
2000-03-22 09:52:21 +00:00
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 585268e3e1 Use WTAP_ERR_UNSUPPORTED_ENCAP for all attempts to open or read a
capture file for an unsupported link-layer encapsulation type (as the
nettl reader does), and report it correctly if it occurs on an open or
read attempt rather than a save attempt.

svn path=/trunk/; revision=1647
2000-02-19 08:00:08 +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 cc4e9f698b One field in the NetXRay header appears to be the number of frames in
the capture; set it to that when writing the capture.

Support Token Ring and FDDI captures (as per the network type in the
file header appearing to be either the NDIS network type, or the NDIS
network type minus 1 - I forget whether Ethernet has an NDIS type of 0
or 1).

Don't write the file header twice, keeping a static copy of it around,
as Wiretap code isn't supposed to keep any static data around; instead,
write it only when we're done writing out all the records (as we do on
Network Monitor captures).

Compute the time stamps when writing the file.

Give Windows Sniffer 1.1-format a short name, so "editcap" doesn't dump
core or print "(null)" in its usage message.

WTAP_ENCAP_NULL isn't supported by NetMon; don't write it.

svn path=/trunk/; revision=1336
1999-12-15 01:34:17 +00:00
Guy Harris 1eaa99a669 Fix some names.
svn path=/trunk/; revision=1203
1999-12-04 09:38:38 +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
Guy Harris f256c54f79 Include <string.h> to declare "memset()".
svn path=/trunk/; revision=1198
1999-12-04 06:21:45 +00:00
Guy Harris 4c37395f73 Add support to Wiretap for writing Network Monitor 1.x-format capture
files.

Make the return type of a number of routines that return 1 (for "true")
on success and 0 (for "false") on failure to "gboolean", and make the 1's
and 0's TRUEs and FALSEs.

svn path=/trunk/; revision=1194
1999-12-04 05:14:39 +00:00
Guy Harris f08f10c093 It appears that the first frame in a NetMon 2.0 capture file doesn't
necessarily start at an offset of 128 into the file; we have to read the
first entry in the frame table to find the offset in the file of the
first frame.  (That also works on NetMon 1.0.)

Keep the header size around, though, as we'll need it if we add code to
*write* NetMon files.

svn path=/trunk/; revision=1119
1999-11-26 22:50:51 +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 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 ae53260d02 Keep in the "wtap" structure the current offset into the file being
read, and maintain it ourselves as we read through the file, rather than
calling "ftell()" for every packet we read - "ftell()" may involve an
"lseek()" call, which could add a noticeable CPU overhead when reading a
large file.

svn path=/trunk/; revision=596
1999-08-28 01:19:45 +00:00
Guy Harris 678b5fd6ff Add a new Wiretap encapsulation type WTAP_ENCAP_FDDI_BITSWAPPED, meaning
"FDDI with the MAC addresses bit-swapped"; whether the MAC addresses are
bit-swapped is a property of the machine on which the capture was taken,
not of the machine on which the capture is being read - right now, none
of the capture file formats we read indicate whether FDDI MAC addresses
are bit-swapped, but this does let us treat non-"libpcap" captures as
being bit-swapped or not bit-swapped independent of the machine on which
they're being read (and of the machine on which they were captured, but
I have the impression they're bit-swapped on most platforms), and allows
us to, if, as, and when we implement packet capture in Wiretap, mark
packets in a capture file written in Wiretap-native format based on the
machine on which they are captured (assuming the rule "Ultrix, Alpha,
and BSD/OS are the only platforms that don't bit-swap", or some other
compile-time rule, gets the right answer, or that some platform has
drivers that can tell us whether the addresses are bit-swapped).

(NOTE: if, for any of the capture file formats used only on one
platform, FDDI MAC addresses aren't bit-swapped, the code to read that
capture file format should be fixed to flag them as not bit-swapped.)

Use the encapsulation type to decide whether to bit-swap addresses in
"dissect_fddi()".

svn path=/trunk/; revision=557
1999-08-24 03:19:34 +00:00
Guy Harris 4b9ab6d1fc Get rid of some cruft left in by previous checkins as placeholders.
Get rid of WTAP_ENCAP_NONE; replace it with WTAP_ENCAP_UNKNOWN, which
means "I can't handle that file, it's using an encapsulation I don't
support".

Check for encapsulations we don't support, and return an error (as is
already done in "libpcap.c").

Check for too-large packet sizes, and return an error (as is already
done in "libpcap.c").

Print unsigned quantities in Wiretap messages with "%u", not "%d".

svn path=/trunk/; revision=544
1999-08-22 02:29:40 +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
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
Guy Harris 6399732b86 Add support for Network Monitor 2.0 files, thanks to information
supplied by Tim Farley.

Tim also indicated that the Network Monitor network types may be NDIS
network types+1.  It also appears that NetXRay/Windows Sniffer network
types may be NDIS network types as well.

svn path=/trunk/; revision=284
1999-05-12 21:40:07 +00:00
Gilbert Ramirez 2b86d46d70 Jun-ichiro's IPv6 patch is merged in with ethereal and now uses the new
proto*() functions. The configure script tries to use ipv6 name resolution if
it knows the type of ipv6 stack the user has (this can be avoided with the
--disable-ipv6 switch) Additionally, the configure script now deals with wiretap
better. If the user doesn't want to compile wiretap, the wiretap is never
visited. A few unnecessary #includes were removed from some wiretap files, and
a CPP macro was moved from bpf.c to wtap.h.

svn path=/trunk/; revision=229
1999-03-28 18:32:03 +00:00
Gilbert Ramirez 2dbd008ea5 Added display filters to wiretap.
svn path=/trunk/; revision=198
1999-03-01 18:57:07 +00:00
Guy Harris 19d8e24ab0 Fix a typo in a comment, and make the "magic number" a "const" string.
svn path=/trunk/; revision=192
1999-02-20 06:46:33 +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 4e1c7318cb Added token-ring support to netmon.c
svn path=/trunk/; revision=176
1999-01-27 14:54:09 +00:00
Gilbert Ramirez 43a8b4b5a5 Added Guy's netmon.[ch] files to CVS for him. His firewall admins forgot
to add ssh to their firewall rules, so he's out of CVS for a few days.
This adds support for MS Network Monitor files to wiretap.

svn path=/trunk/; revision=172
1999-01-18 21:34:54 +00:00