aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/vwr.c
AgeCommit message (Collapse)AuthorFilesLines
2014-10-09Use an enum for the open-routine return value, as per Evan Huus's suggestion.Guy Harris1-4/+4
Clean up some things we ran across while making those changes. Change-Id: Ic0d8943d36e6e120d7af0a6148fad98015d1e83e Reviewed-on: https://code.wireshark.org/review/4581 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-10-07No need for WTAP_ERR_CANT_READ.Guy Harris1-1/+0
Unlike the standard I/O routines, the code we introduced that supports fast random seeking on gzipped files will always supply some specific error code for read errors, so we don't need WTAP_ERR_CANT_READ. Add WTAP_ERR_CANT_WRITE for writing, as we're still using the standard I/O routines for that. Set errno to WTAP_ERR_CANT_WRITE before calling fwrite() in wtap_dump_file_write(), so that it's used if fwrite() fails without setting errno. Change-Id: I6bf066a6838284a532737aa65fd0c9bb3639ad63 Reviewed-on: https://code.wireshark.org/review/4540 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-10-07Add some higher-level file-read APIs and use them.Guy Harris1-19/+11
Add wtap_read_bytes(), which takes a FILE_T, a pointer, a byte count, an error number pointer, and an error string pointer as arguments, and that treats a short read of any sort, including a read that returns 0 bytes, as a WTAP_ERR_SHORT_READ error, and that returns the error number and string through its last two arguments. Add wtap_read_bytes_or_eof(), which is similar, but that treats a read that returns 0 bytes as an EOF, supplying an error number of 0 as an EOF indication. Use those in file readers; that simplifies the code and makes it less likely that somebody will fail to supply the error number and error string on a file read error. Change-Id: Ia5dba2a6f81151e87b614461349d611cffc16210 Reviewed-on: https://code.wireshark.org/review/4512 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-09-28Make the time stamp resolution per-packet.Guy Harris1-1/+1
Pcap-ng files don't have a per-file time stamp resolution, they have a per-interface time stamp resolution. Add new time stamp resolution types of "unknown" and "per-packet", add the time stamp resolution to struct wtap_pkthdr, have the libwiretap core initialize it to the per-file time stamp resolution, and have pcap-ng do the same thing with the resolution that it does with the packet encapsulation. Get rid of the TS_PREC_AUTO_XXX values; just have TS_PREC_AUTO, which means "use the packet's resolution to determine how many significant digits to display". Rename all the WTAP_FILE_TSPREC_XXX values to WTAP_TSPREC_XXX, as they're also used for per-packet values. Change-Id: If9fd8f799b19836a5104aaa0870a951498886c69 Reviewed-on: https://code.wireshark.org/review/4349 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-09-25Fix a record size check.Guy Harris1-7/+7
It was being checked against the wrong value, so some invalid records passed the check. Also, change one comparison (rec_size is in the range [0, 65535], even though it's in an int, so we can safely cast it to guint) and fix the metadata length value when reading Ethernet packets. Bug: 10495 Change-Id: I2ce5c93fe50d836ec0accfcdef31654ba6b5b7c7 Reviewed-on: https://code.wireshark.org/review/4278 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-08-05Fix whitespace/indentation to match editor modelines.Bill Meier1-68/+68
Change-Id: I3445ae22f10584582d465bf632942e016f5f70ca Reviewed-on: https://code.wireshark.org/review/3452 Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-08-02Rename buffer_ routines to ws_buffer_ to avoid name collisions.Guy Harris1-6/+6
In particular, epan/wslua/lrexlib.c has its own buffer_ routines, causing some linker warnings on some platforms, as reported in bug 10332. (Not to be backported to 1.12, as that would change the API and ABI of libwsutil and libwiretap. We should also make the buffer_ routines in epan/wslua/lrexlib.c static, which should also address this problem, but the name change avoids other potential namespace collisions.) Change-Id: I1d42c7d1778c7e4c019deb2608d476c52001ce28 Reviewed-on: https://code.wireshark.org/review/3351 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-07-15Only one buffer.c, please.Guy Harris1-1/+1
Otherwise, if you link with both libwiretap and libfiletap, it's anybody's guess which one you get. That means you're wasting memory with two copies of its routines if they're identical, and means surprising behavior if they're not (which showed up when I was debugging a double-free crash - fixing libwiretap's buffer_free() didn't fix the problem, because Wireshark happened to be calling libfiletap' unfixed buffer_free()). There's nothing *tap-specific about Buffers, anyway, so it really belongs in wsutil. Change-Id: I91537e46917e91277981f8f3365a2c0873152870 Reviewed-on: https://code.wireshark.org/review/3066 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-05-24Allow wtap_read() and wtap_seek_read() to return records other than packets.Guy Harris1-0/+3
Add a "record type" field to "struct wtap_pkthdr"; currently, it can be REC_TYPE_PACKET, for a record containing a packet, or REC_TYPE_FILE_TYPE_SPECIFIC, for records containing file-type-specific data. Modify code that reads packets to be able to handle non-packet records, even if that just means ignoring them. Rename some routines to indicate that they handle more than just packets. We don't yet have any libwiretap code that supplies records other than REC_TYPE_PACKET or that supporting writing records other than REC_TYPE_PACKET, or any code to support plugins for handling REC_TYPE_FILE_TYPE_SPECIFIC records; this is just the first step for bug 8590. Change-Id: Idb40b78f17c2c3aea72031bcd252abf9bc11c813 Reviewed-on: https://code.wireshark.org/review/1773 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-05-23Revert "Allow wtap_read() and wtap_seek_read() to return non-packet records."Guy Harris1-14/+11
This reverts commit c0c480d08c175eed4524ea9e73ec86298f468cf4. A better way to do this is to have the record type be part of struct wtap_pkthdr; that keeps the metadata for the record together and requires fewer API changes. That is in-progress. Change-Id: Ic558f163a48e2c6d0df7f55e81a35a5e24b53bc6 Reviewed-on: https://code.wireshark.org/review/1741 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-05-23Allow wtap_read() and wtap_seek_read() to return non-packet records.Guy Harris1-11/+14
This is the first step towards implementing the mechanisms requestd in bug 8590; currently, we don't return any records other than packet records from libwiretap, and just ignore non-packet records in the rest of Wireshark, but this at least gets the ball rolling. Change-Id: I34a45b54dd361f69fdad1a758d8ca4f42d67d574 Reviewed-on: https://code.wireshark.org/review/1736 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-05-09Revert "Refactor Wiretap"Guy Harris1-41/+38
This reverts commit 1abeb277f5e6bd27fbaebfecc8184e37ba9d008a. This isn't building, and looks as if it requires significant work to fix. Change-Id: I622b1bb243e353e874883a302ab419532b7601f2 Reviewed-on: https://code.wireshark.org/review/1568 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-05-09Refactor WiretapMichael Mann1-38/+41
Start of refactoring Wiretap and breaking structures down into "generally useful fields for dissection" and "capture specific". Since this in intended as a "base" for Wiretap and Filetap, the "wft" prefix is used for "common" functionality. The "architectural" changes can be found in cfile.h, wtap.h, wtap-int.h and (new file) wftap-int.h. Most of the other (painstaking) changes were really just the result of compiling those new architecture changes. bug:9607 Change-Id: Ife858a61760d7a8a03be073546c0e7e582cab2ae Reviewed-on: https://code.wireshark.org/review/1485 Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-03-29Hide unused variable.Guy Harris1-1/+4
Leave it there, but commented out, just in case it *should* be used. "#if 0" out the code that sets it. Change-Id: I8802fc416030106d9d8421b0d7b8612597794bab Reviewed-on: https://code.wireshark.org/review/867 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-03-29Add a pcorey48tohll() macro, and use #defines for some offsets.Guy Harris1-26/+25
The "48 bits, in a weird byte order" is a variant of 64-bit "Corey-endian", with the upper 16 bits of the result - which are in the *middle* of the bytes of the number - ignored. Define a pcorey48tohll() macro and use that, rather than the loop. There are a bunch of #defines for offsets in the headers; use them rather than magic constants. Change-Id: Idfdc8a741278d71a5db47c067914c97615c3e02d Reviewed-on: https://code.wireshark.org/review/864 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-03-16Add a #define for the stats block header length, and use it.Guy Harris1-14/+15
And rename to #define for the stats block trailer length to indicate that it's the length of the trailer, not the length of the stats block in its entirety. Change-Id: Iec82c971b32f2d3f4a604fe75a91633e1813ebd5 Reviewed-on: https://code.wireshark.org/review/701 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-03-16And another warning fix.Guy Harris1-1/+2
Change-Id: Ibbf3366d0075f7b367383a2950c9f0bc54ae194c Reviewed-on: https://code.wireshark.org/review/692 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-03-16Squelch some warnings by narrowing or widening some variables.Guy Harris1-6/+9
Change-Id: If3ad60532e8b7e74272683b254582d86653c777e Reviewed-on: https://code.wireshark.org/review/691 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-03-16Get rid of unused #defines and no-longer-used structures.Guy Harris1-56/+3
The #defines came from Radiotap, but this isn't Radiotap (I see no presence bits here), and Radiotap has to handle stuff that this code doesn't (such as, for example, Atheros Wi-Fi adapters that, annoyingly, pad the space between the 802.11 header and the 802.11 payload when in monitor mode, hence the "datapad" flag). Change-Id: I87ca3539e0f9254ab94cc8897bdf69e4574f0525 Reviewed-on: https://code.wireshark.org/review/690 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-03-16Reorganize the code.Guy Harris1-375/+448
Pull the packet data copying code into the routines that parse the rest of the record data. Have those routines directly fill in the metadata headers in the packet data, without bothering to fill in a structure first. As a result, those routines no longer can set phdr->caplen to a value different from phdr->len, so don't set WTAP_HAS_CAP_LEN. Have the existing sanity checking code cause the read to fail if the checks fail, and add some additional sanity checking. Use #defines for some offsets into the statistics header and trailer. Change-Id: Ie936683b96888961d6e2598131cc0eb6146b37e9 Reviewed-on: https://code.wireshark.org/review/689 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-03-15Clean up the setting of the len and caplen fields.Guy Harris1-48/+66
Always include the length of the metadata headers, as we're always copying them. Do a straightforward check to make sure the data length is >= 4 before subtracting out the FCS (which appears not to actually be an FCS; at least in the captures I've seen, it looks like random junk). Improve the comments for that code. Get rid of some tabs, in favor of spaces, while we're at it, and make the 3 sections of code where that's done more alike. Change-Id: Ica338cd492ac535833933a8b7cd5191217c5ab5b Reviewed-on: https://code.wireshark.org/review/685 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-03-15Use constants instead of vwr->STATS_LEN in some cases.Guy Harris1-10/+8
In some cases, we know, based on the FPGA code, what vwr->STATS_LEN is, so use that #define. While we're at it, replace some hardcoded numbers that represent the statistics trailer length with the appropriate #define. Also, combine two identical case arms for Ethernet into one. Change-Id: I0bdea8e5aab146094ad21fa7e67dca2913da688b Reviewed-on: https://code.wireshark.org/review/672 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-03-15Fix setting of STATS_LEN - it's what's in the file, not what we *generate*.Guy Harris1-2/+1
vwr->STATS_LEN is the length of the statistics trailer at the end of the packet, and it's the same for S2 and S3 versions of the WLAN card. It should *not* be set to the length of the metadata headers that we *generate and put in front of the packet data that we hand to our callers*. Get rid of a debugging message while we're at it. Change-Id: I465b5ba4dedb88f1f401d34439b44b16a4bb01cc Reviewed-on: https://code.wireshark.org/review/671 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-03-15Clean up naming and get rid of unused and duplicate definitions.Guy Harris1-197/+104
The so-called "radiotap headers" bear no resemblance to actual radiotap.org radiotap headers; there are no presence bits, for example. Get rid of the words "radiotap" and "radio tap", get rid of #defines that aren't used, get rid of duplicate definitions. Change-Id: I0bb6abda5d13bf20810dc865a567f4ec51a38056 Reviewed-on: https://code.wireshark.org/review/670 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-03-15Better document the offset of the MPDU in the packet data.Guy Harris1-9/+17
In the S1 FPGA code, copy the "MPDU starts at 4 or 6" comment. Get rid of misleading comment in the S2/S3 FPGA code; we're using the MPDU_OFF field from the private data structure, so we're not calculating *anything* at that point. Put in comments indicating what's being done at the point where those calculations are actually done. Change-Id: Ifda709a6b2aa7edad964f639086012c72c0a71fe Reviewed-on: https://code.wireshark.org/review/668 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-03-15Add a #define for the record header length, and use it.Guy Harris1-6/+21
Add a comment describing (some of) the record, while we're at it, and update another comment to reflect reality. Change-Id: Ia7f1432402b843b96983375c0e0842c030de0cee Reviewed-on: https://code.wireshark.org/review/667 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-03-15Some records have two statistics blocks; clarify that.Guy Harris1-4/+4
Change-Id: I139cd73f6fff84528e105f9246a4207aa48a68df Reviewed-on: https://code.wireshark.org/review/666 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-03-15More use of vwr->STATS_LEN to clarify what code is doing.Guy Harris1-4/+9
Change-Id: I9292f7b054f7b71727409deb062200a0301db5ee Reviewed-on: https://code.wireshark.org/review/665 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-03-15Get rid of duplicate code.Guy Harris1-5/+0
Change-Id: I39515c13f667a62445e3498cf90742dc271e390c Reviewed-on: https://code.wireshark.org/review/664 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-03-15Use vwr->STATS_LEN instead of numbers, and eliminate redundant checks.Guy Harris1-8/+2
Instead of throwing in 48 and 64 as numbers, use vwr->STATS_LEN to indicate what the lengths are. Yeah, it has to be fetched at run time, but big deal. That also shows that, as we've already rejected records whose size is less than vwr->STATS_LEN, we don't have to check for that, so eliminate those checks. Change-Id: Id4822b3e5a02abfffb2da96a50999e36548a4279 Reviewed-on: https://code.wireshark.org/review/663 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-03-14len and caplen are derived independently, so set WTAP_HAS_CAP_LEN.Guy Harris1-3/+3
Fix presumed typo while we're at it. Change-Id: Ic8ae6e6669e5c5fc618ec2516af98ba2390487ce Reviewed-on: https://code.wireshark.org/review/660 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-03-04Remove all $Id$ from top of fileAlexis La Goutte1-2/+0
(Using sed : sed -i '/^ \* \$Id\$/,+1 d') Fix manually some typo (in export_object_dicom.c and crc16-plain.c) Change-Id: I4c1ae68d1c4afeace8cb195b53c715cf9e1227a8 Reviewed-on: https://code.wireshark.org/review/497 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-02-25Remove trailing whitespaceBill Meier1-1/+1
Change-Id: I8116f63ff88687c8db3fd6e8e23b22ab2f759af0 Reviewed-on: https://code.wireshark.org/review/385 Reviewed-by: Bill Meier <wmeier@newsguy.com> Tested-by: Bill Meier <wmeier@newsguy.com>
2014-01-02No seek-read routines use the length argument, so eliminate it fromGuy Harris1-3/+2
wtap_seek_read(). svn path=/trunk/; revision=54570
2014-01-02Don't pass the wtap * to a routine if it's not needed.Guy Harris1-22/+17
svn path=/trunk/; revision=54565
2014-01-02Fill in the struct wtap_pkthdr in the seek-read routine.Guy Harris1-41/+56
svn path=/trunk/; revision=54564
2013-12-20Change G_GINT64_CONSTANT(xxxxU) to G_GUINT64_CONSTANT(xxxx)Jakub Zawadzki1-4/+4
svn path=/trunk/; revision=54314
2013-12-03wiretap: start using <wsutil/pint.h>Jakub Zawadzki1-25/+25
svn path=/trunk/; revision=53764
2013-11-21Get rid of C++ comments.Guy Harris1-1/+1
svn path=/trunk/; revision=53486
2013-11-21Cope with empty VWR files (bug 9428)Martin Mathieson1-2/+9
svn path=/trunk/; revision=53475
2013-11-08The "file types" we have are actually combinations of types andGuy Harris1-2/+2
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-10-16Fix various: whitespace, comments & etc.Bill Meier1-612/+624
Add editor modelines. svn path=/trunk/; revision=52639
2013-10-15Add another cast.Gerald Combs1-1/+1
svn path=/trunk/; revision=52622
2013-10-15Add casts to fix some shortening errors.Gerald Combs1-4/+4
svn path=/trunk/; revision=52621
2013-10-15limit the values written to phdr.(cap)len to guint32, not to guint16Martin Kaiser1-6/+6
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-15code review of parse_s1_W_stats()Martin Kaiser1-2/+16
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-14do some range checks when reading vwr filesMartin Kaiser1-14/+14
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-09-15From Tom Cook via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9147 ↵Alexis La Goutte1-3/+3
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-08-10Initialize float variables with float constants, not double constants,Guy Harris1-6/+6
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-10IxVeriwave 11ac patch (bug 8912) from Tom Cook.Martin Mathieson1-528/+516
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