Commit Graph

127 Commits

Author SHA1 Message Date
Guy Harris 1f5f63f8ef Generalize wtap_pkthdr into a structure for packet and non-packet records.
Separate the stuff that any record could have from the stuff that only
particular record types have; put the latter into a union, and put all
that into a wtap_rec structure.

Add some record-type checks as necessary.

Change-Id: Id6b3486858f826fce4b096c59231f463e44bfaa2
Reviewed-on: https://code.wireshark.org/review/25696
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-02-09 00:29:51 +00:00
Dario Lombardo 8cd389e161 replace SPDX identifier GPL-2.0+ with GPL-2.0-or-later.
The first is deprecated, as per https://spdx.org/licenses/.

Change-Id: I8e21e1d32d09b8b94b93a2dc9fbdde5ffeba6bed
Reviewed-on: https://code.wireshark.org/review/25661
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-02-08 14:57:36 +00:00
Dario Lombardo c440a24b1b wiretap: use SPDX identifiers (partial work).
Change-Id: I28436e003ce7fe31d53e6663f3cc7aca00845e4b
Reviewed-on: https://code.wireshark.org/review/25392
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-01-20 17:23:08 +00:00
Guy Harris d0865fd619 Allow bigger snapshot lengths for D-Bus captures.
Use WTAP_MAX_PACKET_SIZE_STANDARD, set to 256KB, for everything except
for D-Bus captures.  Use WTAP_MAX_PACKET_SIZE_DBUS, set to 128MB, for
them, because that's the largest possible D-Bus message size.  See

	https://bugs.freedesktop.org/show_bug.cgi?id=100220

for an example of the problems caused by limiting the snapshot length to
256KB for D-Bus.

Have a snapshot length of 0 in a capture_file structure mean "there is
no snapshot length for the file"; we don't need the has_snap field in
that case, a value of 0 mean "no, we don't have a snapshot length".

In dumpcap, start out with a pipe buffer size of 2KB, and grow it as
necessary.  When checking for a too-big packet from a pipe, check
against the appropriate maximum - 128MB for DLT_DBUS, 256KB for
everything else.

Change-Id: Ib2ce7a0cf37b971fbc0318024fd011e18add8b20
Reviewed-on: https://code.wireshark.org/review/21952
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-06-05 05:28:26 +00:00
Guy Harris 6b0f846ac3 Fix problem found by Coverity.
The loop was using bytes_read, but wasn't setting it.  Go back to
something similar to the previous loop condition, but don't lose the
error tests.

Fixes Coverity CID 1403388.

Change-Id: I557cbfa6e9ad81491af4fc90e85ce87c71fec8aa
Reviewed-on: https://code.wireshark.org/review/20776
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-03-29 02:31:07 +00:00
Michael Mann 687f7f9773 netscaler.c: use dynamic memory for temporary buffer in nstrace_read_v30.
Makes Windows vscodeanalysis a little happier.

Change-Id: Ie744e91ab3f2a9744ae21c932ab6ea25467ad2fa
Reviewed-on: https://code.wireshark.org/review/20724
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-03-27 03:14:27 +00:00
Guy Harris 16c8bff15a Catch read errors and zero-length records, as opposed to short reads/EOF.
Also, if we return WTAP_OPEN_ERROR from an open routine after we've set
our close routine, that routine is called, which frees up our private
data structures; don't free them ourselves before returning
WTAP_OPEN_ERROR.

Change-Id: I03eebe1a1677e2161fdacec8de14668093cf03a3
Reviewed-on: https://code.wireshark.org/review/20522
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-03-12 18:48:19 +00:00
Michael Mann 845f82e5cd netscaler: Sanity check record size
Bug: 13478
Change-Id: I6be2972979ff7cabf27e70d236c581d539d6ddac
Reviewed-on: https://code.wireshark.org/review/20515
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-03-12 16:36:18 +00:00
Guy Harris c2e74c5fc2 Don't cast to a too-large size.
The maximum record length is 255*128 + 127 = 32767; that fits in a
guint32, which is large enough to support the biggest packet we'd ever
support without stretching several size values to 64 bits.

It's not a size of an object in memory, so it doesn't have to be a
size_t, and a size_t could be too large to fit in the record sizes we're
using.

Just cast to guint32.

Change-Id: Ie664fda3ce9945893fd992bbb9a81a5d632a3fcb
Reviewed-on: https://code.wireshark.org/review/20479
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-03-10 04:21:05 +00:00
Anil Kumar 3a63f8dc61 nstrace: fix size of vmnames
When vmnames are included in the header of a netscaler packet trace,
number of bytes equal to the size of vmnames is omitted from the packet,
by the dissector.


Bug: 13459
Change-Id: I0f907e9c2e08c1cbebd47f7e50d8284a6aaade59
Reviewed-on: https://code.wireshark.org/review/20446
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-03-10 02:46:22 +00:00
Guy Harris b98bb5188c Make sure nspr_getv20recordsize() returns an unsigned value.
The record size fields are guint8, but NSPR_V20RECORDSIZE_2BYTES was
0x80, which has type int, promoting the result to int.  Make it 0x80U,
which means everything is unsigned.

This squelches a compiler warning.

Change-Id: I1c63e485352a90c7f675ab0dacaaeba794235b35
Reviewed-on: https://code.wireshark.org/review/20344
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-03-02 22:53:10 +00:00
Guy Harris e4dfeed2ca Do more record length checks.
Do the check early in the process of processing the record, and do it
for all record types.

Bug: 13429
Change-Id: Id7f4d12415c6740241850d8f873cff52909e7110
Reviewed-on: https://code.wireshark.org/review/20330
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-03-02 09:01:13 +00:00
Guy Harris 19c51d27b9 Don't go past the end of a page in a NetScaler file.
Records in a properly formatted NetScaler file shouldn't go past the end
of a page, but nothing guarantees that a NetScaler file will be properly
formatted.

NetScaler 3.x files allow record bodies to go past the end of a page,
but 1.x and 2.x files don't, so treat record headers that go past the
end of a page, and record bodies in 1.x and 2.x files that go past the
end of a page, as errors.

Clean up some stuff while we're at it.

Bug: 13430
Change-Id: I3b1d56086e3bb14b246406f306e3d730df337561
Reviewed-on: https://code.wireshark.org/review/20326
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-03-02 03:54:04 +00:00
Guy Harris c34cf306ab Note some cases where we don't need to check the packet length.
These file formats have 16-bit packet lengths, so, even with some extra
metadata added, the packet data length will never be bigger than
WTAP_MAX_PACKET_SIZE.  (No, we won't ever reduce WTAP_MAX_PACKET_SIZE.)

Change-Id: I9e1b1d90971f91cc6e5d66d0aa93841445b2bc22
Reviewed-on: https://code.wireshark.org/review/15186
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-04-30 02:04:50 +00:00
Guy Harris 73ce3407a9 Fix indentation.
Change-Id: I78fd1d8e91443fa878e6c4ae05839d8a49849830
Reviewed-on: https://code.wireshark.org/review/14367
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-03-06 18:38:27 +00:00
anilkumar911 875d95ea60 nstrace: Allow opening of files that are not multiples of 16kB
in size.

Wireshark/Tshark hangs when netscaler trace file smaller than 16KB is opened. 
It also hangs when a gzipped trace file is opened. With this fix, 
Files with sizes that are not multiple of 16KB and gzipped files can be opened.

Bug: 12083
Change-Id: I26b2fc406edafcb2f1f6161d69064ba5662ddf29
Reviewed-on: https://code.wireshark.org/review/13721
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-02-11 19:55:13 +00:00
Stig Bjørlykke e1ed7598ee Removed local definitions of offsetof().
The offsetof() macro is an ANSI C library feature.

Change-Id: I2ac91b0b4c94c6f6baf14133b076fdc5ed2e182b
Reviewed-on: https://code.wireshark.org/review/12707
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-12-18 05:49:45 +00:00
anilkumar911 4490d5eb49 Netscaler: Fix issue where packets were lost when selected packets were exported
Only this issue with a netscaler trace file

Bug: 11248
Change-Id: I2bc2cae5c988eeff7bdd08471bf421faafcd4e73
Reviewed-on: https://code.wireshark.org/review/8672
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2015-06-03 13:32:16 +00:00
anilkumar911 62a70e8a0b Support for new netscaler 3.5 trace format.
Change-Id: Ica74f3f9239a96486967cf248feb4313bc390734
Reviewed-on: https://code.wireshark.org/review/7751
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-04-13 14:27:46 +00:00
Guy Harris 0f3ae32290 Call TIMEDEFVn macros in all PACKET_DESCRIBE() macros.
Create TIMEDEFV10() and, for it and for V20, V21, and V22, undefine the
ones used for the read routine and define dummy ones for the read-seek
routines (as those record formats have relative, not absolute, times).

Have all of them set presence_flags.

That way:

1) if we *can* set the time stamps in the seek-read routine, we do;

2) we always set presence_flags in read and seek-read routines.

Change-Id: I837507245e8a0cbc68c7c5fd8365f474d085488e
Reviewed-on: https://code.wireshark.org/review/7445
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-03-01 03:04:06 +00:00
Guy Harris 0692d75455 Make the V10 path a bit more like the other paths.
Provide {FULL,PART}SIZEDEFV10 macros, similar to what's provided for the
other versions, containing the code to set the packet length and
captured data length, and use the TRACE_V10_REC_LEN_OFF() macro directly
after that to set the various length and offset values in the
pseudo-header.

Change-Id: I3513371057601b44821d89ebaa7565ab370a67f5
Reviewed-on: https://code.wireshark.org/review/7393
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-02-25 21:05:26 +00:00
Guy Harris 9dfade3494 Make the _offset values static constants.
No need to export them outside this file, and making them constants
might convince the compiler not to bother fetching their values from
memory when referring to them.

Change-Id: Ib8605bf0bb9091721a51827c45fe75d19a15ba26
Reviewed-on: https://code.wireshark.org/review/7378
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-02-25 08:12:28 +00:00
Guy Harris 6b6c11c3c3 Have a PACKET_DESCRIBE() for V30's seek-read routine.
That way it'll set the captured length and reported length the same way
it's done in the read routine.

Change-Id: I8b1f2d0d8fa688f44b6f61f16dc2e21b5648fc12
Reviewed-on: https://code.wireshark.org/review/7376
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-02-25 06:12:23 +00:00
Guy Harris 98e8d527c9 Make the V10 PACKET_DESCRIBE() macro a little more like the others.
Rename the V10 PACKET_DESCRIBE()'s "fpp" argument to "type", and have it
declare the pointer variable.

Change-Id: I3ac52ebdef0aec7bc95052277537185132886b57
Reviewed-on: https://code.wireshark.org/review/7374
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-02-25 05:23:56 +00:00
Guy Harris 0856de5b5f Rename the "type" argument to V10's PACKET_DESCRIBE() to "ver".
Move it in the argument list, and use it instead of a hard-coded 10
(even though it's always passed as 10), to match the other
PACKET_DESCRIBE() macros.

Change-Id: Idd0a23a58cc6bb0d2de799b039db776d279cc03e
Reviewed-on: https://code.wireshark.org/review/7372
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-02-25 04:25:43 +00:00
Guy Harris 825a833763 Call the version-number argument to GENERATE_CASE_xxx() "ver".
The name "type" is thrown around to mean both a version number and a
part of a structure member, and some other macros use "ver" for the
version number; try to make things a little less inconsistent.

Change-Id: I61405cf41cca43fe607154af7498944c5ec0ef11
Reviewed-on: https://code.wireshark.org/review/7370
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-02-25 04:16:17 +00:00
Guy Harris fc6df642be Use FULL/PART as an argument to all PACKET_DESCRIBE() macros.
Makes the various flavors of that macro more similar.

Change-Id: Ie95ee8db0b226458146b055b54b7d61835f1e508
Reviewed-on: https://code.wireshark.org/review/7368
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-02-25 03:13:02 +00:00
Guy Harris 22b4b6321b Get rid of an unused argument to PACKET_DESCRIBE().
Change-Id: Ic2037f5bf7eb43f93ba39f91bca3fc267c8fb850
Reviewed-on: https://code.wireshark.org/review/7366
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-02-25 03:00:39 +00:00
Guy Harris 04b6b56228 Give all PACKET_DESCRIBE() macros a HEADERVER argument.
A bit of regularization.

Change-Id: I60e0bd50891e1ba3e9c40f8d1d14d63534e08138
Reviewed-on: https://code.wireshark.org/review/7364
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-02-25 00:15:54 +00:00
Guy Harris 08c85ecc3c Call header version arguments HEADERVER.
Use that rather than TYPE or acttype (to indicate that it's a header
version number to use as the "xxx" in NSPR_HEADER_VERSIONxxx, and to use
the same name throughout).

Change-Id: I14cfc819e44ce4388c27d521a1256dec8d80df2e
Reviewed-on: https://code.wireshark.org/review/7361
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-02-25 00:07:15 +00:00
Guy Harris c4b76a94ef More indentation cleanups.
Change-Id: Ia448727e6340723800d92097f0ef7f3582ef6340
Reviewed-on: https://code.wireshark.org/review/7359
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-02-24 22:32:46 +00:00
Guy Harris 0dc5edfe95 Clean up indentation.
Change-Id: I80f8c5c642ebc1fe0169e39c1af9584cfbb89d1a
Reviewed-on: https://code.wireshark.org/review/7357
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-02-24 22:30:14 +00:00
Guy Harris 37c09e35b0 Pull more into PACKET_DESCRIBE() for the V10 seek-read routine.
Just like the read routine.

Change-Id: If6bd98bea15f1c8dc7454a5dac0ea57920bddc8c
Reviewed-on: https://code.wireshark.org/review/7355
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-02-24 22:22:42 +00:00
Guy Harris 592ee9e83b Swallow up more V10 stuff into PACKET_DESCRIBE().
That makes it even more like V2x and V3x and slightly less unclear.

Change-Id: I798ead123ba6418be0252067773a951390e26ce8
Reviewed-on: https://code.wireshark.org/review/7353
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-02-24 21:56:56 +00:00
Guy Harris 2a31311f81 Have PACKET_DESCRIBE() for V10.
Have it set the record type and initialize the presence bits.

That makes it a bit more like V2x and V3x, and makes the code slightly
less unclear.

Change-Id: Ibfbe2143b24a68c3fa3f576616fde81918b01feb
Reviewed-on: https://code.wireshark.org/review/7351
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-02-24 21:22:51 +00:00
Guy Harris fe5aea7c62 Move the setting of rec_type.
This makes the code slightly less unclear.  (You are in a maze of twisty
little C macros, all different.)

Change-Id: I9f1bcc7a9a1a7afe87ede8b1ba513e3d8e53845c
Reviewed-on: https://code.wireshark.org/review/7349
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-02-24 21:02:54 +00:00
ranushekhar c466d401d9 NS Trace (NetScaler Trace) file format is not able to export specified packets
Bug: 10998
Change-Id: Ic2c5ad5b01be3e0c39b1e93badcc4f2246c420fe
Reviewed-on: https://code.wireshark.org/review/7327
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-02-24 06:37:10 +00:00
Martin Mathieson a190c936d7 Remove unnecessary includes from wiretap folder
Change-Id: I10d3057801673bc1c8ea78f144215869cc4b1851
Reviewed-on: https://code.wireshark.org/review/6217
Petri-Dish: Martin Mathieson <martin.r.mathieson@googlemail.com>
Reviewed-by: Martin Mathieson <martin.r.mathieson@googlemail.com>
2015-01-03 21:06:36 +00:00
Bill Meier 454fd6e9eb Add "Editor modelines"; Adjust whitespace as needed.
Change-Id: Ic5a5acb0f36d3aa144edbfb1ae71097b18426db4
Reviewed-on: https://code.wireshark.org/review/6216
Reviewed-by: Bill Meier <wmeier@newsguy.com>
2015-01-02 00:49:09 +00:00
Guy Harris 51e58698d2 Get rid of packet data members of header structures.
Instead, have a special macro using the size of the header structure to
find the offset of the packet data.

This means that:

	1) you don't have to throw "-{size of data member}" into the
	   macros that calculate the sizes of the header structures;

	2) you don't have a bunch of randomly-chosen data field sizes;

	3) you don't have sizes of 0, which cause problems with
	   compilers that don't support zero-length arrays;

	4) you don't have some apparently-incorrect "-{size of data
	   member}" values (if they're correct, please fix the structure
	   definitions).

Change-Id: Iea368b83fa2d184bd6df453d51756e4749714e2c
Reviewed-on: https://code.wireshark.org/review/6082
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-12-27 20:56:42 +00:00
Guy Harris aa27e665b1 Rename WTAP_ERR_REC_TYPE_UNSUPPORTED to WTAP_ERR_UNWRITABLE_REC_TYPE.
That indicates that it's a problem specific to *writing* capture files;
we've already converted some errors to that style, and added a new one
in that style.

Change-Id: I8268316fd8b1a9e301bf09ae970b4b1fbcb35c9d
Reviewed-on: https://code.wireshark.org/review/5826
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-12-18 00:32:14 +00:00
Guy Harris 51522b3372 Handle "I can't map this for that file format" better.
For cases where record (meta)data is something that can't be written out
in a particular file format, return WTAP_ERR_UNWRITABLE_REC_DATA along
with an err_info string.

Report (and free) that err_info string in cases where
WTAP_ERR_UNWRITABLE_REC_DATA is returned.

Clean up some other error reporting cases, and flag with an XXX some
cases where we aren't reporting errors at all, while we're at it.

Change-Id: I91d02093af0d42c24ec4634c2c773b30f3d39ab3
Reviewed-on: https://code.wireshark.org/review/5823
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-12-18 00:03:26 +00:00
Guy Harris ddcc2aee3d Rename WTAP_ERR_UNSUPPORTED_FILE_TYPE to WTAP_ERR_UNWRITABLE_FILE_TYPE.
That makes it clearer what the problem is, and that it should only be
returned by the dump code path, not by the read code path.

Change-Id: I22d407efe3ae9fba7aa25f08f050317549866442
Reviewed-on: https://code.wireshark.org/review/5798
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-12-17 08:31:49 +00:00
Guy Harris dbdcae80ba Rename WTAP_ERR_UNSUPPORTED_ENCAP to WTAP_ERR_UNWRITABLE_ENCAP.
That makes it clearer what the problem is, and that it should only be
returned by the dump code path, not by the read code path.

Change-Id: Icc5c9cff43be6c073f0467607555fa7138c5d074
Reviewed-on: https://code.wireshark.org/review/5797
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-12-17 06:41:45 +00:00
Guy Harris 685d3034d5 Version 3 has only absolute timestamps; don't set nsg_creltime.
Version 3's time stamps are all absolute, so we can directly use the
value in the file; we don't need to keep track of the time in the
private data structure, and some compilers issue warnings due to setting
it and then not using the value to which we set it.

Change some names and indentation to match other file versions while
we're at it.

Change-Id: I97698d933b87a8ad58d9e88ceedd75004797df69
Reviewed-on: https://code.wireshark.org/review/4596
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-10-10 18:41:00 +00:00
Guy Harris 45e462985d Use an enum for the open-routine return value, as per Evan Huus's suggestion.
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-09 23:45:30 +00:00
Guy Harris a566f617d8 No need for WTAP_ERR_CANT_READ.
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-07 23:19:56 +00:00
Guy Harris ffd48cefa6 Whitespace cleanups.
Change-Id: I92f983b2e04defab30eb31c14c484b9f0f582413
Reviewed-on: https://code.wireshark.org/review/4513
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-10-07 05:01:39 +00:00
Guy Harris 670ebda4a6 Add some higher-level file-read APIs and use them.
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-10-07 01:01:59 +00:00
Guy Harris 54b733ce9a Make the time stamp resolution per-packet.
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-28 18:38:18 +00:00