Commit Graph

119 Commits

Author SHA1 Message Date
Guy Harris 6b4c30b69d When allocating the frame table for a NetMon file, use g_try_malloc(),
and fail with ENOMEM if that fails (and the frame table is not empty -
g_try_malloc() will return NULL if you ask it to allocate zero bytes).

Have an error message for ENOMEM on an open that attempts to tell the
user what the problem is without making their head explode.

svn path=/trunk/; revision=49673
2013-06-01 06:48:37 +00:00
Guy Harris 6e336d74a1 Move the record header processing code into a common routine, and read
that header in both the read and seek-read routines.

svn path=/trunk/; revision=49671
2013-06-01 02:58:58 +00:00
Evan Huus 202680971d Wiretap file open routines should not free wth->priv on error, since that
leads to a double-free in wtap_close. Fix all the instances I found via
manual code review, and add a brief comment to the list of open routines in
file_access.c

Fixes https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8518

svn path=/trunk/; revision=48552
2013-03-25 22:04:15 +00:00
Anders Broman 05a8c94ddf From beroset:
implemented wtap_dump_file_seek() and _tell()

implemented the previously declared but unimplemented wtap_dump_file_seek() and wtap_dump_file_tell() functions and used them in the seven files that had previously used a plain ftell or fseek and added error checking as appropriate.  I also added a new error WTAP_ERR_CANT_SEEK_COMPRESSED and put it next to WTAP_ERR_CANT_SEEK causing renumbering of two of the existing error codes.

https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8416

svn path=/trunk/; revision=48348
2013-03-17 09:20:13 +00:00
Guy Harris db0c2de004 OK, fine, how about 4 characters initializing a 4-character array?
svn path=/trunk/; revision=46804
2012-12-27 12:41:24 +00:00
Guy Harris 88e9d1c1e5 Do not call wtap_file_read_unknown_bytes() or
wtap_file_read_expected_bytes() from an open routine - open routines are
supposed to return -1 on error, 0 if the file doesn't appear to be a
file of the specified type, or 1 if the file does appear to be a file of
the specified type, but those macros will cause the caller to return
FALSE on errors (so that, even if there's an I/O error, it reports "the
file isn't a file of the specified type" rather than "we got an error
trying to read the file").

When doing reads in an open routine before we've concluded that the file
is probably of the right type, return 0, rather than -1, if we get
WTAP_ERR_SHORT_READ - if we don't have enough data to check whether a
file is of a given type, we should keep trying other types, not give up.
For reads done *after* we've concluded the file is probably of the right
type, if a read doesn't return the number of bytes we asked for, but
returns an error of 0, return WTAP_ERR_SHORT_READ - the file is
apparently cut short.

For NetMon and NetXRay/Windows Sniffer files, use a #define for the
magic number size, and use that for both magic numbers.

svn path=/trunk/; revision=46803
2012-12-27 12:19:25 +00:00
Jakub Zawadzki 78631020b8 Add wtap_pseudo_header union to wtap_pkthdr structure.
Use pkthdr instead of pseudo_header as argument for dissecting.

svn path=/trunk/; revision=45601
2012-10-16 21:50:57 +00:00
Jeff Morriss 3551a86c36 We always HAVE_CONFIG_H so don't bother checking whether we have it or not.
svn path=/trunk/; revision=45015
2012-09-20 01:29:52 +00:00
Guy Harris b459c468a3 Set the 802.11 "already decrypted" flag to FALSE for file formats other
than Network Instruments Observer files, as we don't know whether they
are already decrypted.

svn path=/trunk/; revision=43796
2012-07-18 22:48:18 +00:00
Jakub Zawadzki bf81b42e1e Update Free Software Foundation address.
(COPYING will be updated in next commit)

svn path=/trunk/; revision=43536
2012-06-28 22:56:06 +00:00
Anders Broman 2bc42dc547 Try to squelch warnings
svn path=/trunk/; revision=42998
2012-06-02 14:13:14 +00:00
Guy Harris 33bb54a945 file_seek() used to be a wrapper around fseek() or gzseek(), both of
which could use lseek() and were thus expensive due to system call
overhead.  To avoid making a system call for every packet on a
sequential read, we maintained a data_offset field in the wtap structure
for sequential reads.

It's now a routine that just returns information from the FILE_T data
structure, so it's cheap.  Use it, rather than maintaining the data_offset
field.

Readers for some file formats need to maintain file offset themselves;
have them do so in their private data structures.

svn path=/trunk/; revision=42423
2012-05-04 16:56:18 +00:00
Guy Harris 0275247b97 Use WTAP_ENCAP_IEEE_802_11_xxx for all the "802.11 plus radio header"
encapsulations.

For pre-V9 AiroPeek captures, leave the radio information in the packet
data, just as we do with the Prism, AVS, radiotap, and NetMon headers. 
Add a dissector for it.

svn path=/trunk/; revision=42379
2012-05-02 03:11:00 +00:00
Guy Harris b6ff142f60 Add a presence flag field to the packet information structure filled in
by Wiretap, to indicate whether certain fields in that structure
actually have data in them.

Use the "time stamp present" flag to omit showing time stamp information
for packets (and "packets") that don't have time stamps; don't bother
working very hard to "fake" a time stamp for data files.

Use the "interface ID present" flag to omit the interface ID for packets
that don't have an interface ID.

We don't use the "captured length, separate from packet length, present"
flag to omit the captured length; that flag might be present but equal
to the packet length, and if you want to know if a packet was cut short
by a snapshot length, comparing the values would be the way to do that.

More work is needed to have wiretap/pcapng.c properly report the flags,
e.g. reporting no time stamp being present for a Simple Packet Block.

svn path=/trunk/; revision=41185
2012-02-25 23:24:34 +00:00
Guy Harris 2db032c5d5 NetMon 1.x format does *not* support per-packet encapsulation.
svn path=/trunk/; revision=40495
2012-01-14 10:31:25 +00:00
Guy Harris 7962edcf56 The encapsulation following WTAP_ENCAP_ARCNET is
WTAP_ENCAP_ARCNET_LINUX; update various tables mapping Wiretap
encapsulations to file-type encapsulations.  Get rid of some trailing
"sorry, that's not supported" entries while we're at it.

svn path=/trunk/; revision=40274
2011-12-22 09:22:35 +00:00
Guy Harris d94bd07f99 Rename WTAP_ERR_BAD_RECORD to WTAP_ERR_BAD_FILE; it really reports any
form of corruption/bogosity in a file, including in a file header as
well as in records in the file.  Change the error message
wtap_strerror() returns for it to reflect that.

Use it for some file header problems for which it wasn't already being
used - WTAP_ERR_UNSUPPORTED shouldn't be used for that, it should only
be used for files that we have no reason to believe are invalid but that
have a version number we don't know about or some other
non-link-layer-encapsulation-type value we don't know about.

svn path=/trunk/; revision=40175
2011-12-13 09:53:50 +00:00
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