Commit Graph

147 Commits

Author SHA1 Message Date
Guy Harris e9730c89af Fill in the struct wtap_pkthdr in the seek-read routine.
svn path=/trunk/; revision=54564
2014-01-02 19:33:47 +00:00
Jakub Zawadzki 064082e68a Change G_GINT64_CONSTANT(xxxxU) to G_GUINT64_CONSTANT(xxxx)
svn path=/trunk/; revision=54314
2013-12-20 22:39:32 +00:00
Jakub Zawadzki 01e08ae582 wiretap: start using <wsutil/pint.h>
svn path=/trunk/; revision=53764
2013-12-03 20:35:50 +00:00
Guy Harris a36046c784 Get rid of C++ comments.
svn path=/trunk/; revision=53486
2013-11-21 18:50:44 +00:00
Martin Mathieson d5433fd9b6 Cope with empty VWR files (bug 9428)
svn path=/trunk/; revision=53475
2013-11-21 15:42:22 +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
Bill Meier 55f3af2174 Fix various: whitespace, comments & etc.
Add editor modelines.

svn path=/trunk/; revision=52639
2013-10-16 02:39:09 +00:00
Gerald Combs 821e1a7c34 Add another cast.
svn path=/trunk/; revision=52622
2013-10-15 16:40:19 +00:00
Gerald Combs c70baa2037 Add casts to fix some shortening errors.
svn path=/trunk/; revision=52621
2013-10-15 16:29:38 +00:00
Martin Kaiser 156659e308 limit the values written to phdr.(cap)len to guint32, not to guint16
We read a two-byte length field and add a constant number of header
bytes to this length, so we could in theory be larger than guint16.

svn path=/trunk/; revision=52619
2013-10-15 15:15:59 +00:00
Martin Kaiser ef33b36768 code review of parse_s1_W_stats()
range check for array index
   don't assign the result of pntohs() to a gint16
   range check for the values stored in phdr.(cap)len

svn path=/trunk/; revision=52618
2013-10-15 15:11:40 +00:00
Martin Kaiser 1eb36c1119 do some range checks when reading vwr files
don't assign the output of pntoh24() to a gint16

unfortunately, vwr detection does not work reliably and many pdf files
are recognized as vwr - this commit should prevent wireshark from
crashing when it tries to load the USB 2.0 spec as pdf ;-)


svn path=/trunk/; revision=52599
2013-10-14 15:03:28 +00:00
Alexis La Goutte cbf315b8ed From Tom Cook via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9147 Long / short guard interval not properly read from IxVeriWave vwr files
The short / long guard interval is located in a different spot than the current vwr reader looks.

svn path=/trunk/; revision=52047
2013-09-15 06:58:41 +00:00
Guy Harris 84239c0c06 Initialize float variables with float constants, not double constants,
and assign float constants, not double constants, to float variables. 
Floating-point constants are double by default; you have to add "f" to
the end to make them float.

This squelches 64-bit-to-32-bit warnings.

svn path=/trunk/; revision=51289
2013-08-10 21:34:15 +00:00
Martin Mathieson 1abc2eb191 IxVeriwave 11ac patch (bug 8912) from Tom Cook.
This was the 4th patch, but also:
- use gmalloc0() to allocate vwr struct.  Otherwise, valgrind says that
  many of fields were still uninitialised when parse_s1_W_stats later
read them
- whitespace tidyup, got rid of remaining tabs and trailing whitespace

Did a fair bit of fuzz-testing without seeing any problems.

svn path=/trunk/; revision=51248
2013-08-10 20:57:46 +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
Jeff Morriss d8558f06fd Fix an unintialized-value-used warning that Valgrind detected in the capture
file attached to https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8760 :

When searching for a signature, don't search past the end of the record.

svn path=/trunk/; revision=49742
2013-06-04 01:31:56 +00:00
Jeff Morriss 9f95423783 Get rid of trailing white space and a few tabs.
svn path=/trunk/; revision=49741
2013-06-04 00:58:40 +00:00
Jeff Morriss 0eecced808 Fix the wiretap fuzz failure reported in https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8760 :
Check that the record length we got out of the file is at least as big as
stats block trailer; if not, declare the file bad.

svn path=/trunk/; revision=49739
2013-06-04 00:50:05 +00:00
Guy Harris c3c6f93f5c Pass the read_rec_data routines a wtap_pkthdr pointer, and have them
fill in that structure, so that it's filled in by both the read and
seek-read routines.

svn path=/trunk/; revision=49703
2013-06-02 23:32:17 +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 5996b49c53 Squelch implicit 64-bit-to-32-bit conversion warnings.
svn path=/trunk/; revision=46650
2012-12-21 03:32:16 +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
Evan Huus 25103896f9 Remove unused variable caught by cppcheck.
svn path=/trunk/; revision=45344
2012-10-06 15:39:21 +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
Michael Tüxen f4e855f1fc It seems that the length should unsigned, not signed.
This fixes part of
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7533
which deals with Crash in vwr.c while reading the capture file.

svn path=/trunk/; revision=44075
2012-07-27 18:59:29 +00:00
Anders Broman 1ae38887b6 From Evan Huus:
Grab-bag of unused variables.

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

svn path=/trunk/; revision=43616
2012-07-09 01:49:02 +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
Guy Harris bd5060b836 vwr_read_rec_header()'s return value is used only to distinguish success
(read a record header) from failure (got an EOF or an error).  Make it
just return a Boolean.

If it fails in vwr_read(), don't overwrite *err_info (yes,
vwr_read_rec_header() might have set *err_info, so don't lose - and
leak! - the value it returned) - trust vwr_read_rec_header(), or the
routines it calls, to have set it.  (If there's a code path where that
doesn't happen, that code path needs to be fixed; the setting of
*err_info in vwr_read() should *not* be restored.)

Thanks to Evan Huus for finding a useless variable with cppcheck, and
reporting it in bug 7295, provoking me to look at this.

svn path=/trunk/; revision=42865
2012-05-27 20:40:09 +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 7ed15c8deb Remove unnecessary null-pointer check.
svn path=/trunk/; revision=42376
2012-05-01 22:29:08 +00:00
Chris Maynard 73f3d23999 Fix 2 redundant redeclaration warnings and a bug where logical AND (&&) was incorrectly used where bit-wise AND (&) was meant.
svn path=/trunk/; revision=42373
2012-05-01 02:47:52 +00:00
Guy Harris 3684bb31a0 Remove _U_ from arguments that are actually used.
Fix a comment.

svn path=/trunk/; revision=42311
2012-04-28 16:05:18 +00:00
Guy Harris d6e5b20bf2 Get rid of some unnecessary assignments, to remove warnings from the
Clang static analyzer.

svn path=/trunk/; revision=42304
2012-04-28 02:01:40 +00:00
Guy Harris 781891bd7b Remove duplicate comment.
svn path=/trunk/; revision=42270
2012-04-26 16:30:33 +00:00
Guy Harris c0cdd900fc Add a pcoreytohll() macro to extract "Corey-endian" 64-bit quantities,
and use it.

Fix some comments.

svn path=/trunk/; revision=42269
2012-04-26 16:27:03 +00:00
Guy Harris a3ce72529c Use the pletohXX macros when fetching little-endian values.
svn path=/trunk/; revision=42256
2012-04-26 08:57:33 +00:00
Guy Harris c7575ff095 Put the pseudo-header information for Veriwave packets into the buffer
in little-endian byte order, as that's what the dissector expects.  Add
a pletohl() macro for that purpose.

Fix comments (the Veriwave code is *not* writing data to a file!) and
clean up indentation.

svn path=/trunk/; revision=42255
2012-04-26 08:45:48 +00:00
Guy Harris d4d080e1a1 Use pntohs(), pntoh24(), and pntohl() to fetch big-endian data from the
headers.

Fix some indentation.

svn path=/trunk/; revision=42252
2012-04-26 05:07:53 +00:00
Guy Harris 1e6eaee16c Global variables considered harmful. Move all the per-capture-file
global variables into a structure that's attached to the wtap_t as
private data, and make all the per-*packet* global variables local
variables.

svn path=/trunk/; revision=42251
2012-04-26 04:26:03 +00:00
Guy Harris 51633791a9 If you get an I/O error when looking for the FPGA version, return -1, so
we know we had a real problem with the file.  If we just get a short
read, return 0, as it means the file is probably not a VWR file.

If we get an invalid message length when reading packets (rather than
when looking for the FPGA version), return WTAP_ERR_BAD_FILE and an
"Invalid message record length" indication, not a generic fallback
"can't read the file" error.

For file_tell() errors, fetch the error code with file_error().

For file_seek() errors, use the error file_seek returned.

svn path=/trunk/; revision=42249
2012-04-26 03:06:35 +00:00
Martin Mathieson e74d2fd9db Return 0 if doesn't match signature of vwr files.
Pointed out by Martin Kaiser in bug 7196.

svn path=/trunk/; revision=42248
2012-04-25 22:54:45 +00:00
Martin Mathieson 56add1934d Remove some unnecessary includes and fix some indentation.
svn path=/trunk/; revision=42227
2012-04-25 00:28:19 +00:00
Martin Mathieson dae0b453f0 Lose some more unused variables reported by clang.
svn path=/trunk/; revision=42173
2012-04-21 02:43:11 +00:00
Martin Mathieson 048833b933 Try to fix up some clang warnings. Will look at other modules I added
recently later.

svn path=/trunk/; revision=42167
2012-04-20 18:09:50 +00:00
Martin Mathieson d74383ed1c Add a couple of casts to try to make the Windows-7-x64 buildbot happy.
svn path=/trunk/; revision=42159
2012-04-20 12:44:19 +00:00
Martin Mathieson 45252c84e3 Patch for https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5048
From Tom Cook and Tom Alexander.

1. A VWR encapsulation that reads VeriWave capture files (*.vwr)
generated from
WaveTest test hardware
2. Dissectors that display the VeriWave tap headers (both 802.11 and
Ethernet)
3. A dissector for the WaveAgent protocol.  The WaveAgent dissector is
heuristic and parses the WaveAgent packet (a UDP payload).

The WaveAgent dissector has been Fuzz tested.

The VWR ENCAP and dissectors have been used extensively by VeriWave
customers in a special version of WireSark compiled by VeriWave.

svn path=/trunk/; revision=42155
2012-04-20 12:08:31 +00:00