Commit Graph

76 Commits

Author SHA1 Message Date
Guy Harris b467ecfc8b If the attempt to read the record header fails because we hit the EOF,
treat that as "this isn't a CommView file" rather than "this is a bad
file".

svn path=/trunk/; revision=46774
2012-12-26 12:01:14 +00:00
Jakub Zawadzki 6b5045dd7b Fill some phdr values also when doing random read
svn path=/trunk/; revision=45619
2012-10-17 20:28: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
Guy Harris a2c64e173e And that also means that we need to split the data rate from the
pseudo-header into two bytes and fill in both the rate and direction
fields when writing CommView NCF files out.

svn path=/trunk/; revision=45507
2012-10-12 20:59:08 +00:00
Guy Harris 10b89e0430 The "rate" field in the CommView NCF format is 1 byte long, not 2 bytes
long; that means we read only one byte into our structure, so make its
"rate" element one byte long, so we don't fill in half the "rate"
element with the read - and the *wrong* half on big-endian machines -
and leave the other half un-set and thus containing some random possibly
non-zero data.

In addition, that's not the full data rate for faster networks; for
Wi-Fi, the one-byte "direction" field is actually the upper 8 bits of
the data rate, so combine them when we fill in the data rate in the
pseudo-header.

#BACKPORT

svn path=/trunk/; revision=45504
2012-10-12 20:51:04 +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
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
Anders Broman be31ffaeb0 Get the Windows build going again. The Netxray "fix" cast to guint8 may not be OK.
svn path=/trunk/; revision=42125
2012-04-18 08:15:32 +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 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 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 f16a746c63 Set eth.fcs_len in the pseudo-header for Ethernet packets.
Set the pseudo-header when doing the sequential read as well as when
doing random reads.

When writing packets to a CommView file, use a slightly less contorted
way to get the year/month/day/hour/minute/second values.

commview_dump() uses the pseudo_header argument; don't mark it as
unused.

svn path=/trunk/; revision=38833
2011-09-01 04:14:54 +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
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
Stig Bjørlykke a39c0d9577 Added a missing break.
Coverity 492.

svn path=/trunk/; revision=36356
2011-03-27 13:15:14 +00:00
Stephen Fisher a7c89cdfd6 Fix bug #5509: CommView file format now uses reserved bytes and adds a
new use for the direction field per:

  http://www.tamos.com/htmlhelp/commview/logformat.htm

Add basic support for new fields and don't reject files that fit the new
format.


svn path=/trunk/; revision=35234
2010-12-20 23:34:14 +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
Stephen Fisher c4680240d9 Change my e-mail address
svn path=/trunk/; revision=28537
2009-05-31 05:55:15 +00:00
Jeff Morriss e801ff285c Fix for: https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=2926 :
provide a default case (returning an error) to prevent wiretap from asserting
out because we didn't set the packet encapsulation.

svn path=/trunk/; revision=26327
2008-10-01 13:57:41 +00:00
Stephen Fisher 9fbb31194c Add support for showing wireless LAN info (signal strength / rate / channel)
in Wireshark when reading CommView files.  Also write out these values when
coming from a file format with encapsulation type 802.11 with radio.


svn path=/trunk/; revision=23617
2007-11-27 05:43:29 +00:00
Stephen Fisher b19c9f164e Change %G to %Y for year in strftime() so it works on Windows also (%G is an extension found at least on OS X). Also change from 4 to 5 bytes in each strftime() to allow space for the NULL terminator with 4 character outputs.
svn path=/trunk/; revision=23595
2007-11-26 08:08:51 +00:00
Stephen Fisher 91cd7ec475 Add writing support for the CommView file format.
svn path=/trunk/; revision=23594
2007-11-26 05:34:07 +00:00
Stephen Fisher 8c0f4111ea Initial checkin of support to read TamoSoft's CommView packet capture files
per enhancement bug #1795.


svn path=/trunk/; revision=23558
2007-11-24 03:33:18 +00:00