Commit Graph

126 Commits

Author SHA1 Message Date
Anders Broman ddd69f4775 Use correct lenght when writing if_filter_str.
svn path=/trunk/; revision=41352
2012-03-05 09:32:21 +00:00
Anders Broman a20cfcc745 Fix calculation of pading for if_filter_str.
svn path=/trunk/; revision=41351
2012-03-05 09:21:36 +00:00
Guy Harris 732de9018d Squelch a can't-really-happen uninitialized reference warning.
svn path=/trunk/; revision=41342
2012-03-04 20:49:17 +00:00
Anders Broman 7348837ccd Use parentheses
svn path=/trunk/; revision=41341
2012-03-04 19:31:33 +00:00
Anders Broman 971cb84877 if_filter isn't a string per se,The first byte of the Option Data keeps a code of the filter used
svn path=/trunk/; revision=41339
2012-03-04 19:01:14 +00:00
Guy Harris aa974fda50 Make sure all names in NRB records are null-terminated; report an error
if they're not.  Also report an error for zero-length names.

Handle multiple names per IP address - the pcap-NG spec says "one or
more zero-terminated strings containing the DNS entries for that
address."

Use a Buffer to hold NRB records, so there's no maximum size (well,
there is a maximum size, because the record length is 16 bits, but let's
not allocate 64KiB on the stack if we don't have to).

svn path=/trunk/; revision=41332
2012-03-04 02:20:25 +00:00
Anders Broman ad6640344f From Jose Pedro Oliveira: Fix typos
svn path=/trunk/; revision=41330
2012-03-03 16:17:20 +00:00
Guy Harris b18a5f9805 Don't look at the interface_id field of the packet header if
WTAP_HAS_INTERFACE_ID isn't set in the presence flags.

svn path=/trunk/; revision=41327
2012-03-03 00:13:25 +00:00
Guy Harris 17dff5f3c4 Get rid of no-longer-needed argument to pcapng_write_section_header_block().
svn path=/trunk/; revision=41292
2012-03-02 09:38:43 +00:00
Guy Harris 10337e0ca4 Skip an intermediating wtapng_block_t in the code path to write
Interface Description Blocks.

Fix a typo (if_fcslen was meant rather than opt_comment when writing the
FCS length).

svn path=/trunk/; revision=41291
2012-03-02 09:30:10 +00:00
Guy Harris 334a807e14 Simplify the code path for writing pcap-NG packets, and remove some
no-longer-needed elements from the wtapng_packet_t structure.

svn path=/trunk/; revision=41289
2012-03-02 09:03:26 +00:00
Guy Harris 44528a6437 Fill in the wtap_pkthdr fields in pcap_read_packet_block() and
pcap_read_simple_packet_block(), not in pcap_read() - the way the fields
are filled in differs between simple and non-simple packet blocks.

Clean up white space.

svn path=/trunk/; revision=41284
2012-03-02 05:03:06 +00:00
Michael Tüxen 59dee69a95 Fix CID 1385.
svn path=/trunk/; revision=41264
2012-03-01 14:57:14 +00:00
Michael Tüxen 3bd0e0be10 Fix CID 354.
svn path=/trunk/; revision=41263
2012-03-01 14:51:26 +00:00
Anders Broman ffbba61fdf Read the complete NRB.
#Backport

svn path=/trunk/; revision=41259
2012-03-01 13:31:40 +00:00
Anders Broman cc9bcfb068 Add debuginfo
svn path=/trunk/; revision=41258
2012-03-01 10:13:02 +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
Anders Broman cacbe31797 Fix a typo and revert previous.
svn path=/trunk/; revision=41179
2012-02-24 15:57:56 +00:00
Anders Broman c14dbfc465 Fix a typo.
svn path=/trunk/; revision=41178
2012-02-24 15:53:00 +00:00
Michael Tüxen 525df25b7f No debug output, please.
svn path=/trunk/; revision=41165
2012-02-23 19:14:58 +00:00
Michael Tüxen 2b3cd82cb1 interface id is 32-bit, not 64-bit.
svn path=/trunk/; revision=41159
2012-02-23 11:55:24 +00:00
Guy Harris b6330fc765 Do a check of the block total length in pcapng_read_unknown_block().
That means we don't need to do the block length check in
pcapng_read_block(); each block type reader, including the one for
unknown block types, does a check that's as stringent as that block
length check or more stringent, which means any block whose length is
less than the minimum will fail with the same error in both cases.

Fix the message for a too-short NRB.

svn path=/trunk/; revision=41152
2012-02-23 10:03:16 +00:00
Guy Harris 4bf0c5bf5b Fix typo introduced by previous checkin.
svn path=/trunk/; revision=41145
2012-02-22 23:44:25 +00:00
Guy Harris 3b262a0621 Add sanity checks to make sure the claimed block size is big enough to:
1) contain the block length fields and block type field;

	2) contain that plus the fixed-length portion of the block;

	3) for blocks that have a variable-length portion other than the
	   options, contain that variable-length portion.

Fixes a crash we're seeing with a bad pcap-NG file in the Wireshark
menagerie (7799-lastPacketWithoutComment.pcapng - the last packet's
block length is 128, but it claims to have 98 bytes of packet data,
which requires a 132-byte block).

Clean up white space (use 8-space tabs).

svn path=/trunk/; revision=41143
2012-02-22 18:32:43 +00:00
Anders Broman ace4d65e47 Grr forgot debug flag - again.
svn path=/trunk/; revision=41140
2012-02-22 16:02:38 +00:00
Anders Broman 8fff390455 - Write ISB(s) at start and end of capture.
- Read all options.
- Prepare to write ISB.

svn path=/trunk/; revision=41137
2012-02-22 14:41:02 +00:00
Guy Harris 46cb65974b Handle the case where there are no IDBs before the first non-SHB/non-IDB
block, which could be the case even in a *valid* file (consider a file
with an SHB, an NRB, an IDB, and a packet block, in that order); even if
there's no IDB before the first packet block, that should be reported to
the user as "interface N not less than interface count M", to more
precisely indicate the problem.

(Yes, the loop should probably keep going until it finds a packet block,
not just a non-IDB block.)

svn path=/trunk/; revision=41132
2012-02-22 03:03:34 +00:00
Michael Tüxen b85f69ebde Fix bugs which resulted in the buildbot errors.
svn path=/trunk/; revision=41126
2012-02-21 20:37:22 +00:00
Michael Tüxen 4ea2838bdb Disable debug output...
svn path=/trunk/; revision=41119
2012-02-21 16:33:33 +00:00
Michael Tüxen 877edcc89d When writing an option in an IDB, also write an endofoption option.
Use (consistently) 0 as the default for the interface speed.
While there, do some whitespace cleanups.

svn path=/trunk/; revision=41118
2012-02-21 16:32:25 +00:00
Michael Tüxen 822782f7c4 Improve the error handling.
svn path=/trunk/; revision=41112
2012-02-21 15:36:08 +00:00
Michael Tüxen da14b5b8ec Improve peeking for IDBs.
While there, cleanup some whitespaces.

svn path=/trunk/; revision=41106
2012-02-21 12:24:42 +00:00
Guy Harris a0ccca53d9 Once we've read a valid SHB, we've concluded the file is a pcap-NG file,
so if we later get a short read, we have to return -1 and set *err to
WTAP_ERR_SHORT_READ.  Otherwise, we'll try other file types and, if none
of them match, we'll try to close the wtap structure, which crashes.

svn path=/trunk/; revision=41102
2012-02-21 08:27:41 +00:00
Anders Broman b15cea5c18 Declare opt_cont_buf_len
svn path=/trunk/; revision=41101
2012-02-21 07:25:22 +00:00
Anders Broman b301446753 Free the buffer
svn path=/trunk/; revision=41099
2012-02-21 06:57:14 +00:00
Anders Broman 311116da93 Change comment to Loop ower all IDB:s that appear before any packets sugested by Guy, there can be more IDBs in a cpture file
svn path=/trunk/; revision=41096
2012-02-21 05:58:40 +00:00
Anders Broman c7f1a431d2 Handle reading and writing of multiple IDB:s, write IDB options and use correct lengt for strings, handle more than 100 char comment
svn path=/trunk/; revision=41082
2012-02-20 20:15:51 +00:00
Guy Harris 55001ef198 With the WTAP_ERR_UNSUPPORTED error, Wiretap supplies a string giving
the details of what in particular is unsupported; report it in TShark
and Wireshark.

Handle WTAP_ERR_RANDOM_OPEN_PIPE in TShark.

Handle WTAP_ERR_COMPRESSION_NOT_SUPPORTED in TShark, and have its error
message in Wireshark not speak of gzip, in case we support compressed
output in other formats in the future.

If we see a second section header block in a pcap-NG file, don't report
it as "the file is corrupted", report it as "the file uses a feature we
don't support", as that's the case - and don't free up the interface
data array, as the file remains open, and Wireshark might still try to
access the packets we were able to read.

svn path=/trunk/; revision=41041
2012-02-16 18:58:40 +00:00
Guy Harris 5e8d2c79f6 Again, turn off the debug logging; it messes up the fuzz-testing bot.
svn path=/trunk/; revision=41034
2012-02-16 02:06:48 +00:00
Anders Broman 0b6b3937ab Make it possible to get inforamtion from the read SHB to the one to write out.
svn path=/trunk/; revision=41032
2012-02-15 19:44:16 +00:00
Michael Tüxen 68204c94a4 From Anders: Add support for options in the SHB.
From me: Some whitespace changes.

svn path=/trunk/; revision=41026
2012-02-14 17:07:52 +00:00
Anders Broman c7b1aeb5f5 Drop count is 64 bits
svn path=/trunk/; revision=41014
2012-02-13 17:34:15 +00:00
Michael Tüxen 13beca3bbf Fix debug output.
svn path=/trunk/; revision=41004
2012-02-12 21:56:00 +00:00
Anders Broman 74f2ef4f76 Store drop count if present.
svn path=/trunk/; revision=40974
2012-02-11 17:31:13 +00:00
Anders Broman 8aea738cda Add the abillity to read and write option comments unedited.
This is POC we may want to have more efficient use of the frame data
structure etc. But this allows for work to be done on the GUI to actually add comments.

svn path=/trunk/; revision=40969
2012-02-11 12:34:39 +00:00
Guy Harris 357a3e2837 Revert presumably-unintentional turning on of debug messages.
svn path=/trunk/; revision=40963
2012-02-11 02:41:04 +00:00
Anders Broman 7be6e75c13 Add pcapng variables to wtap_pkthdr.
svn path=/trunk/; revision=40947
2012-02-09 22:24:00 +00:00
Guy Harris ab910e4cff If stuff above the Wiretap library can't handle packet reported lengths
> WTAP_MAX_PACKET_SIZE, either that should be caught above the
per-file-type layer in Wiretap or should be handled by the caller.

We've recently fixed at least one problem with reported lengths > 2^31 -
1 (by clamping the length to 2^31 - 1), so let's just remove the check
from the pcap-NG reader, to squelch some complaints we're getting from
the buildbot (bug 6673 and its duplicates).

(The pcap reader uses it to cope with some of the botched libpcap
formats that changed the per-packet header without changing the magic
number; I'll look at trying to preserve those heuristics while still
allowing reported lengths > WTAP_MAX_PACKET_SIZE.)

svn path=/trunk/; revision=40207
2011-12-15 08:22:06 +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 680b3d3a86 Make sure pcap-ng supports a particular encapsulation type before
trying to write out an interface description block for an interface with
that type.

svn path=/trunk/; revision=39930
2011-11-18 07:13:33 +00:00