Commit Graph

166 Commits

Author SHA1 Message Date
Jakub Zawadzki 01e08ae582 wiretap: start using <wsutil/pint.h>
svn path=/trunk/; revision=53764
2013-12-03 20:35:50 +00:00
Jakub Zawadzki 288efa5128 Expand macros: htoles(), htolel(), htolell()
svn path=/trunk/; revision=53651
2013-11-29 18:44:00 +00:00
Guy Harris 853da2eb9b The "file types" we have are actually combinations of types and
subtypes, e.g. Network Monitor version 1 and Network Monitor version 2
are separate "file types", even though they both come from Network
Monitor.

Rename various functions, #defines, and variables appropriately.

svn path=/trunk/; revision=53166
2013-11-08 09:53:01 +00:00
Guy Harris 421e9ad4a0 The new frame-based tvbuff code found that the DOS Sniffer code for
compressed sniffer files failed if the very first read involves seeking
past the first blob; fix that.

svn path=/trunk/; revision=50679
2013-07-16 20:59:02 +00:00
Guy Harris 8c9edf1280 Have the seek-read routines take a Buffer rather than a guint8 pointer
as the "where to put the packet data" argument.

This lets more of the libwiretap code be common between the read and
seek-read code paths, and also allows for more flexibility in the "fill
in the data" path - we can expand the buffer as needed in both cases.

svn path=/trunk/; revision=49949
2013-06-16 00:20:00 +00:00
Guy Harris e4d65e993f file_skip() only needs to return a Boolean; if anybody cares what the
seek offset is after calling it, they can use file_tell().  (Some
routines were already assuming it returned a gboolean.)

svn path=/trunk/; revision=49733
2013-06-03 23:07:42 +00:00
Alexis La Goutte 261ed08fc5 Fix some Dead Store (Dead assignement/Dead increment) Warning found by Clang
svn path=/trunk/; revision=46979
2013-01-06 19:41:55 +00:00
Pascal Quantin deb4f08cb2 Fix https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8105 :
Allow use of huges values for localtime / ctime / gmtime with MSVC 2008 or later

svn path=/trunk/; revision=46930
2013-01-04 14:56:27 +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
Guy Harris 4e3f76bebd Add a bunch of #defines for converting between tm_year/tm_mon/tm_mday to
a DOS date.

Use them - which fixes a bug, bug 7998, wherein we were doing the wrong
check to see whether tm_year would fit in a DOS date or not.

svn path=/trunk/; revision=46387
2012-12-05 08:29:22 +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
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 cd7c20c9d9 Try to squelch warnings
svn path=/trunk/; revision=43000
2012-06-02 15:32:34 +00:00
Anders Broman 19507efa88 Try to squelch warnings
svn path=/trunk/; revision=42999
2012-06-02 14:56:18 +00:00
Guy Harris 9bad4b330d ng_file_seek_rand() is supposed to return a Boolean; make it do so.
svn path=/trunk/; revision=42424
2012-05-04 17:18:15 +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 76652d9d4a Some more details about REC_HEADER1 and REC_V2DESC; REC_HEADER1 doesn't
appear to contain anything of use to us - too random - but REC_V2DESC
might be worth converting into a comment.

svn path=/trunk/; revision=41215
2012-02-28 01:11:11 +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 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 eacdf1d46f Put back the check for dates that can be represented in DOS format the
way it was *supposed* to be done, rather than backwards.

svn path=/trunk/; revision=39895
2011-11-17 02:29:26 +00:00
Chris Maynard 6f2dc712b9 Revert part of r39883 to avoid dereferencing a NULL pointer. Thanks Clang.
svn path=/trunk/; revision=39894
2011-11-17 02:17:57 +00:00
Guy Harris 163edbb507 Another place where we have to protect against MSVC's time-conversion
routines blowing up if handed a too-large time_t.

While we're at it, also check for dates that can't be represented in DOS
format (pre-1980 dates).

svn path=/trunk/; revision=39883
2011-11-16 17:08:00 +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 2ca5312b64 file_read() can return -1; don't just blindly add it to a previous
file_read() return value.  Use wtap_file_read_expected_bytes() in a
number of places.

svn path=/trunk/; revision=37053
2011-05-10 20:17:31 +00:00
Bill Meier 856254da59 From Yaniv Kaul: some 'set but not used' compilation fixes;
From me:
 - #include <stdlib.h> not needed;
 - Use consistent indentation;
 - use #if 0/#endif to comment out code rather than /* */

svn path=/trunk/; revision=36884
2011-04-27 03:45:19 +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 44462adc0f Change ng_file_read() to take only one size argument - and make it an
unsigned int - to match file_read().  Shrink some arguments, variables,
and structure members appropriately.

Fix an incorrect sizeof - sizeof a pointer is the size of the pointer,
not the size of what it points to.

svn path=/trunk/; revision=36515
2011-04-08 01:57:02 +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
Jeff Morriss ce392b5764 Don't put a 65536 byte variable on the stack: instead, malloc/free it.
Coverity 791-794.

Also, some white space/indentation cleanup.

svn path=/trunk/; revision=36394
2011-03-29 14:05:28 +00:00
Guy Harris 965ecf3056 Return an error value for the new error return; it "can't happen" (but
either the VC++ analyzer can't determine that or it *can*, in fact,
happen).  Pick an error code that's not too far off.

svn path=/trunk/; revision=35957
2011-02-16 02:21:31 +00:00
Gerald Combs 8af7080001 Fix errors found by the Visual C++ analyzer.
svn path=/trunk/; revision=35954
2011-02-16 00:44:12 +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
Guy Harris dde6d97f63 Define the private data structures for some particular capture file
types in the modules for those capture file types, not in wtap-int.h, so
wtap-int.h doesn't have to change when the code to handle that
particular capture type changes, or a new capture file type is added.
(Ultimately, we should do this for all the private data structures.)

svn path=/trunk/; revision=31974
2010-02-24 07:21:17 +00:00
Bill Meier 72ef03e60a [Trivial] Constify a few things
svn path=/trunk/; revision=28144
2009-04-24 12:16:01 +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 51cf696142 Another iteration of 64-bit-support-by-successive-approximation.
svn path=/trunk/; revision=27690
2009-03-10 17:38:24 +00:00
Gerald Combs 0b7885e04d ng_file_read and SnifferDecompress need to be able to return negative
values, so adjust accordingly.

svn path=/trunk/; revision=27688
2009-03-10 16:33:38 +00:00
Gerald Combs 2236109a82 More 64-bit fixes.
svn path=/trunk/; revision=27685
2009-03-09 22:37:55 +00:00
Gerald Combs 40f5a17d46 Convert a bunch of ints to size_t in ngsniffer.c, and make sure file_read
can accept size_t's.

svn path=/trunk/; revision=27684
2009-03-09 22:28:05 +00:00
Stig Bjørlykke e3c7039015 Add a cast.
svn path=/trunk/; revision=24307
2008-02-12 00:24:49 +00:00
Guy Harris c1e833bdef Do the time calculations with 64-bit integers, rather than in floating
point, so we don't have issues with numbers not being exactly
representable; that makes it less likely that the change described below
will change a time stamp if it's not fixing the time stamp (i.e., if
time_day is 0).

The Sniffer manual "Expert Sniffer(R) Network Analyzer Operations,
Release 5.50" says that a frame2_rec has a time stamp with an 8-bit
time_high field and an 8-bit time_day field.  Interpreting the time
stamp that way fixes the time stamps in at least some captures; see, for
example, bug 2251.

Fix/update some comments (for example, the Sniffer documentation is no
longer at that URL).

svn path=/trunk/; revision=24296
2008-02-10 18:29:05 +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
Gerald Combs d910d8491b Fix a possible NULL dereference (Coverity CID 33).
svn path=/trunk/; revision=17556
2006-03-09 20:48:17 +00:00
Guy Harris 67d94f37a4 Update URL for Sniffer manual, and expand a comment a bit.
svn path=/trunk/; revision=16285
2005-10-22 04:09:37 +00:00
Guy Harris 097f75dd7a Add #defines for the DOS Sniffer network types and for various frame
status field bits".

Check for "Internetwork analyzer" captures by checking the Sniffer
network type, and save that type rather than just an "ATM or not" flag
in the private data.

svn path=/trunk/; revision=16283
2005-10-22 03:49:23 +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