Commit Graph

3206 Commits

Author SHA1 Message Date
Guy Harris ef3b7a3394 err_info is used, so don't mark it unused.
Change-Id: Ibd89fcb8e9fc2aa7e368eb8723fb367db5e8d11e
Reviewed-on: https://code.wireshark.org/review/23245
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-08-27 20:49:31 +00:00
Stig Bjørlykke 9cd114fbe5 wiretap: Add WTAP_ENCAP_NORDIC_BLE
Use this for nordic_ble dissection.

Change-Id: I5323cbd8c244c4e3b645825c60d040e1ae8f3b81
Reviewed-on: https://code.wireshark.org/review/23219
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2017-08-26 09:22:48 +00:00
Guy Harris 6d025eff1b Do the meta-tag stuff the same way in all three cases.
Undo most of the changes, but turn the return at the end of the default
case into a break.

Change-Id: I022b62a85254ff188f19fd3d7c3fe40b0789b3d2
Reviewed-on: https://code.wireshark.org/review/22695
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-07-18 04:34:42 +00:00
Guy Harris 5fd255424f Revert "Don't byte-swap an 1-byte value."
This reverts commit 74a2ae4aba.

No, that's just Coverity not understanding macros *again*, and thinking a particular expanded instance of a macro is the result of some human being silly rather than of the arguments being such that some computations can be elided at compile time.

Change-Id: I40f2ad8bf018b0df02d90ed0e272505be68dae7e
Reviewed-on: https://code.wireshark.org/review/22693
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-07-18 04:28:20 +00:00
Guy Harris 30f8ceebba Remove unnecessary test.
The default case ends with return, so the pointer won't be null by the
time out exit the case statement - either a non-default case is
processed and tag_ptr hasn't been set to null, or the default case is
processed and you return before getting there.

That also means we don't need to set tag_ptr to null in that case.

Fixes CIDs 1415436.

Change-Id: I21ada7a308d888b4cbb8557197a2e30bda118f44
Reviewed-on: https://code.wireshark.org/review/22691
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-07-18 01:58:08 +00:00
Guy Harris 74a2ae4aba Don't byte-swap an 1-byte value.
Convert it to a 4-byte value and byte-swap *that*.

Fixes CID 1415438.

Change-Id: I5cf0b5905f5dd2086c5d8ed6b13b1921bdb69a84
Reviewed-on: https://code.wireshark.org/review/22689
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-07-18 01:44:42 +00:00
Guy Harris d35bb66516 Remove unnecessary test.
The default case ends with return, so the pointer won't be null by the
time out exit the case statement - either a non-default case is
processed and tag_ptr hasn't been set to null, or the default case is
processed and you return before getting there.

That also means we don't need to set tag_ptr to null in that case.

Fixes CID 1415439.

Change-Id: Id2609c0828561c560820f9cb5e6b5a0ae614aead
Reviewed-on: https://code.wireshark.org/review/22686
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-07-18 01:33:10 +00:00
Guy Harris 8dcb530de6 Copy no more than MAX_ERF_EHDR - 1 additional extension headers.
The array of headers has MAX_ERF_EHDR entries, and the additional
entries are appended after the first entry, so that leaves room for at
most MAX_ERF_EHDR - 1.

Fixes CID 1415440.

Change-Id: Iaa2c3577bbff429bcc1301e4cfdf1961f067be93
Reviewed-on: https://code.wireshark.org/review/22684
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-07-18 01:23:27 +00:00
Guy Harris 2ca2cc16b1 Use time_t for the seconds part of a time stamp.
A packet time stamp is an nstime_t, and the seconds part of an nstime_t
is a time_t.

Change-Id: Id2452ceb2f33f43e4a040436d7b3ea1a5c4a0be3
Reviewed-on: https://code.wireshark.org/review/22673
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-07-17 16:53:36 +00:00
Anthony Coddington f3181f706b ERF_TYPE_META write and comment support
Support per-packet comments in ERF_TYPE_META through a new Anchor ID
extension header with per-Host unique 48-bit Anchor ID which links an
ERF_TYPE_META record with a packet record. There may be more than one
Anchor ID associated with a packet, where they are grouped by Host ID
extension header in the extension header list. Like other ERF_TYPE_META
existing comments should not be overwritten and instead a new record
generated. See erf_write_anchor_meta_update_phdr() for detailed comments
on the extension header stack required.

As Wireshark only supports one comment currently, use the one one with
the latest metadata generation time (gen_time). Do this for capture
comment too.

Write various wtap metadata in periodic per-second ERF_TYPE_META records
if non-WTAP_ENCAP_ERF or we have an updated capture comment.
Refactor erf_dump to create fake ERF header first then follow common
pseudoheadr and payload write code rather than two separate code paths.
Support an ERF_HOST_ID environment variable to define Wireshark's Host
ID when writing. Defaults to 0 for now.

ERF dissector updates to support Anchor ID extension header with basic
frame linking.
Update ERF_TYPE_META naming and descriptions to official name
(Provenance)

Core changes:
Add has_comment_changed to wtap_pkthdr, TRUE when a packet
opt_comment has unsaved changes by the user.
Add needs_reload to wtap_dumper which forces a full reload of the file
on save, otherwise wireshark gets confused by additional packets being
written.

Change-Id: I0bb04411548c7bcd2d6ed82af689fbeed104546c
Ping-Bug: 12303
Reviewed-on: https://code.wireshark.org/review/21873
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Stephen Donnelly <stephen.donnelly@endace.com>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-07-17 02:08:52 +00:00
Stefan Hajnoczi 41415aa444 vsock: add WTAP_ENCAP_VSOCK constant
A linktype was recently assigned to Linux vsock in libpcap commit
cfdded36ddcf5d01e1ed9f5d4db596b744a6cda5 ("added DLT_VSOCK for
http://qemu-project.org/Features/VirtioVsock").

The Wireshark vsock dissector can now be automatically applied when
wtap_encap matches the new WTAP_ENCAP_VSOCK constant.

This patch makes Wireshark dissect vsock packet captures without
manually specifying the dissector.

Change-Id: If252071499a61554f624c9ce0ce45a0ccfa88d7a
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-on: https://code.wireshark.org/review/22611
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2017-07-14 12:54:08 +00:00
Guy Harris a9c2697714 Add WTAP_ENCAP_3MB_ETHERNET for Xerox 3MB Ethernet.
It needed to be done:

	https://github.com/shirriff/pup-wireshark

(And, yes, there really *is* a DLT_/LINKTYPE_ for it!  The original DLT_
values were ARP hardware types, and 3MB Ethernet was assigned an ARP
hardware type of 2.)

Change-Id: I60d96c28e67854adcb28c7e3579ae5dd1f07df4b
Reviewed-on: https://code.wireshark.org/review/22336
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-06-22 02:02:18 +00:00
Guy Harris e9e1b48162 Put the definition of BIT_SWAPPED_MAC_ADDRS in the file where it's used.
In change 18a3b0659c, I moved the table
that uses it, but not the actual definition, from libpcap.c to
pcap-common.c; they both should have been moved.  Make it so.

Change-Id: I266fce455df3848b873cdfadb12cecdbf9c8d4d3
Reviewed-on: https://code.wireshark.org/review/22216
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-06-19 02:55:47 +00:00
Guy Harris ee0dde474c Make the short names for USB encspsulation types more regular.
Have them all be "usb-XXX", where XXX indicates the type of header.

Change-Id: I7f1bfea7e264b17c57f94c484d64d1cce91b9b78
Reviewed-on: https://code.wireshark.org/review/22147
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-06-15 09:14:57 +00:00
Guy Harris 6f8bc61c33 Better names for various USB headers.
Change-Id: Iec2126fa1b71d9923ef0fb9ca2a027f7752d71f3
Reviewed-on: https://code.wireshark.org/review/22144
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-06-15 09:05:52 +00:00
Jaap Keuter 2a5cb8e32e Miscellaneous texual corrections and addition
Correct some symbolic references in source file comments
and add a note about the CMake configuration options.

Change-Id: Idb670a2c798c2a52cdce142340ce8fc5a2022508
Reviewed-on: https://code.wireshark.org/review/22138
Reviewed-by: Michael Mann <mmann78@netscape.net>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-06-15 04:23:29 +00:00
Guy Harris ed7e9c77db Add URL for link specifying D-Bus maximum message length.
Change-Id: I5797407a18fda674b2c9b2cc1c192c211c91c496
Reviewed-on: https://code.wireshark.org/review/22052
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-06-09 20:20:11 +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
Erik de Jong 94847961cb LoRaTap DLT and dissector
Add support for handling LoRaTap (https://github.com/eriknl/LoRaTap) DLT in
wiretap and add dissector for LoRaTap headers.

Exposes Syncword for subdissectors to dissect frame payload.

Change-Id: Ie4ba2189964376938f45eb3da93f2c3376042e85
Reviewed-on: https://code.wireshark.org/review/21915
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2017-06-03 20:19:15 +00:00
Guy Harris 30c86f8b34 Don't keep the pcap/pcapng link-layer header type as interface data.
Either 1) it can be determined from the libwiretap encapsulation type,
in which case it's redundant information or 2) there *is* no pcap/pcapng
link-layer header type for that encapsulation type, in which case you
need to check for the attempt to determine it failing and handle that
failure appropriately.

Change-Id: Ie9557b513365c1fc8c6df74b9c8239e29aad46bc
Reviewed-on: https://code.wireshark.org/review/21924
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-06-03 19:59:08 +00:00
Guy Harris 09209056ce Set nss and rate_mcs_index in more arms of the Series II PLCP switch.
For HT mixed, set it the same way it's set for HT greenfield.

For pre-HT, set it to 0.

Also, for the "unknown" case, set rate_mcs_index to 0.
This should obviate the need to initialize either of those variables,
don't initialize them, so that failing to set them in an arm of the
switch statement shows up as an error if the compiler's dataflow
analysis actually bothers to check this.

Change-Id: I92703770dd5000a579b53609fb93a2085fd9fca3
Reviewed-on: https://code.wireshark.org/review/21573
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-05-09 17:51:59 +00:00
Alexis La Goutte 666366e069 vwr (wiretap): fix Assigned value is garbage or undefined Warning found by Clang Analyzer
Change-Id: I45766c7e89a009176ae56fe9e9f5a8dd63b2995b
Reviewed-on: https://code.wireshark.org/review/21567
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>
2017-05-09 11:36:11 +00:00
Guy Harris ee37135c67 Note that the HT MCS index macros can't return all possible MCS values.
I don't know whether this is a bug in the software or a lack of support
in the hardware.

This at least notes the issue in CID 1405905.

Change-Id: I481454bc38842a0f877cb8b52b73e1156fd362b5
Reviewed-on: https://code.wireshark.org/review/21558
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-05-08 02:39:51 +00:00
Guy Harris 548e9762fb Fix handling of 20 MHz VHT with MCS = 9.
That's valid only for 3 or 6 spatial streams; return 0 as the bitrate
for all other values.  Also, handle the 6 spatial streams case.

Give the conversion tables explicit sizes, to make it clear what
subscripts are valid.

Return 0 for an MCS > 9, for consistency with the other error return,
and to mark it as clearly wrong.

Fixes CID 1405908.

Change-Id: Icbf655c63c0e88fd6cec7c66bae85fd887a3bd9c
Reviewed-on: https://code.wireshark.org/review/21557
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-05-07 21:19:15 +00:00
Guy Harris 1247aaef83 Set some variables in the "RF only" code path.
That should remove the need to initialize them, make it clearer what
values are being used in the "RF only" case, and catch any cases where
they don't get set in the "not just RF" case in the future.

Change-Id: I10c3ecef608ed2f481111fb7bc32bb8494b68d27
Reviewed-on: https://code.wireshark.org/review/21536
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-05-06 02:33:37 +00:00
Michael Mann 82c667b1a6 vwr.c: Initialize some local variables
Prevents some compiler warnings

Change-Id: I9d62d0f3e6b7794c5ed43f37d52f86d81344a33c
Reviewed-on: https://code.wireshark.org/review/21531
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-05-05 23:09:02 +00:00
Guy Harris 3ef57b9ea2 Small cleanups.
Add some parentheses to make an expression clearer to people who haven't
memorized the table of C operator precedences.

Don't fiddle the nss variable in place; explicitly combine it with the
IS_TX value when we put it in the header, to make it clearer what's in
that header byte.

Change-Id: I870b892fb9dab2bc210956f923e0183f4e147989
Reviewed-on: https://code.wireshark.org/review/21530
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-05-05 22:13:28 +00:00
Guy Harris c6d7759081 Assume the Series II does the same with NSS for VHT that the Series III does.
The packet-ixveriwave.c dissector appears to do so.

Change-Id: Ie02c4611ef18e83abcd3b625bbc40014080ffca1
Reviewed-on: https://code.wireshark.org/review/21525
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-05-05 21:14:09 +00:00
Guy Harris a1478413be NSS != (MCS / 8) + 1 for MCS >= 32.
Do the MCS -> NSS mapping for HT by a table lookup.

For VHT with Series II, do it the old way for now, under the assumption
that the MCS index and NSS are bit fields, but note that the MCS index
and NSS bit fields would overlap.

Change-Id: Ibc89590faf15900171b2a1b4ac1e50793ed70c32
Reviewed-on: https://code.wireshark.org/review/21523
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-05-05 20:06:55 +00:00
Guy Harris 1a5c6da9fe Series I only handles pre-HT, so rename and remove variables.
Change-Id: Id9f086983544647267854446932a3ffe2ec2cc55
Reviewed-on: https://code.wireshark.org/review/21522
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-05-05 18:43:22 +00:00
Guy Harris 8493630f0c Have separate routines for calculating pre-HT/HT/VHT data rates.
That maeks the code a little clearer.

It also makes it clearer that the "MCS index" is, for pre-HT, a rate
index, so rename some variables and macros.

Change-Id: I64b7bca073df0f837e5d968682345187000207fc
Reviewed-on: https://code.wireshark.org/review/21521
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-05-05 18:33:21 +00:00
Guy Harris cd79802063 Another comment explaining why a packet size check isn't necessary.
Change-Id: Id7494823f9af69c6185b41983ca78ead2dae24dd
Reviewed-on: https://code.wireshark.org/review/21492
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-05-04 07:21:18 +00:00
Guy Harris 4ca15be3eb Do packet length checks iff they're necessary.
They're not necessary for most hardware; remove the unnecessary checks,
and add comments indicating why they're not necessary (or fix the
"maximum value of actual_octets is" part of the comment).

They *are* necessary for Series III hardware; put in the check.

Change-Id: Idd64a74099d5cf7398a2ddb850442e53c9206724
Reviewed-on: https://code.wireshark.org/review/21491
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-05-04 07:12:47 +00:00
Guy Harris dead1b3817 Add a comment.
Change-Id: Ia60a0cdac3d70862aa5941487af142bd26ab2b80
Reviewed-on: https://code.wireshark.org/review/21489
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-05-04 04:51:44 +00:00
Guy Harris 0d5c98c4a6 Clean up whitespace and a #define.
Add some additional blank lines, remove some extra, blank lines, fix
indentation.

Make vVW510024_E_IS_VLAN 32-bits, to match the other flags.

Change-Id: Id1cd63ff2b75764907a44e9f8525b1537666fde1
Reviewed-on: https://code.wireshark.org/review/21488
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-05-04 03:29:09 +00:00
Guy Harris 0d69b9aef1 Update comments.
There's only a 17-byte PLCP header with the Series III hardware.

Change-Id: Ice8dfbbc5daa0578ee4eb6588fc8a8b597806d0d
Reviewed-on: https://code.wireshark.org/review/21487
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-05-04 02:56:12 +00:00
Guy Harris 7703d45803 Use a #define for the PLCP type.
That makes it clearer that the Series I hardware doesn't do HT or VHT.

Change-Id: Ibeccfcba997555bef06098828f01951dc32a6d2c
Reviewed-on: https://code.wireshark.org/review/21486
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-05-04 02:50:56 +00:00
Guy Harris 04e5d8d715 Remove an unnecessary comment, fix another comment.
Change-Id: Id20517c99663c624b6bfd58d7475284db450e003
Reviewed-on: https://code.wireshark.org/review/21485
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-05-04 02:12:37 +00:00
Guy Harris 1ac685f771 Remove trailing white space.
Change-Id: I8cdbde058c7ebb9aaaac4739e9a5c206e0d2c919
Reviewed-on: https://code.wireshark.org/review/21484
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-05-04 01:53:38 +00:00
Guy Harris 7c6bdc3ac9 More description of stats headers.
Change-Id: I21ee8b39b96dd58ea1dfeb502e8734b33aa298c1
Reviewed-on: https://code.wireshark.org/review/21483
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-05-04 01:45:56 +00:00
Guy Harris 6b7d99022b Fix some comments, shuffle some code, change a constant in an assignment.
Fix "VHTPPDU" to be "VHT PPDU".

Move the code that processes the RSSI values before the code that
processes the next two bytes of the header, so it's done in order; that
makes it a bit easier to see the layout of that header (although 2 bytes
of it are processed below).

Fix the comment describing what the first 16 bytes of the record data
after the stats are.  Don't use vVW510021_W_STATS_HEADER_LEN - that's
for the Series II hardware.

Fix some indentation.

Change-Id: If47c4a44fd5e72971a28daf6af88d5e19c53abbe
Reviewed-on: https://code.wireshark.org/review/21482
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-05-04 01:33:10 +00:00
Guy Harris cd12580de1 For S3, yes, the PLCP type can be vVW510021_W_PLCP_LEGACY.
(The dissector checks for it.)

Change-Id: Ic1456b263f3cbda2a630259a2b71b1f1015b5e3e
Reviewed-on: https://code.wireshark.org/review/21442
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-05-01 02:56:11 +00:00
Guy Harris 20d6b67bff Make the record-length checks take the RF information into account.
Include the RF information length if there's RF information.

While we're at it:

Rename the variable holding the offset of the stats information from "j"
to "stats_offset", to make it clearer what it is.

Clean up whitespace.

Get rid of comments that no longer apply.

Improve the comment explaining the MPDU_OFF value for Series III.

Change-Id: I49e2926a80aa8bb11f87d97fdc628bcc9f1220e0
Reviewed-on: https://code.wireshark.org/review/21439
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-05-01 00:10:44 +00:00
Guy Harris 30d674b241 Do all the command-type analysis of decode_msg() in the switch statement.
Add #defines for the remaining command types, based on some other

Get rid of the HEADER_IS_xxx #defines; they're the same for all
hardware, and the switch statement doesn't distinguish between different
hardware.

Set *IS_TX in the switch statement cases.  While we're at it, set v_size
and *v_type in the default case; add a VT_UNKNOWN value for that case.

Change-Id: Ib17d1e435c99fcb746144b4735c160a5f22b7544
Reviewed-on: https://code.wireshark.org/review/21438
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-30 19:45:27 +00:00
Guy Harris 9606d671f6 Use some #defines.
Change-Id: I9cafd3b745eb0fec39c0a9b5f529249584107971
Reviewed-on: https://code.wireshark.org/review/21435
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-30 18:10:18 +00:00
Guy Harris 2700055d3c Fix a comment to reflect reality.
There aren't any "4 Management bytes for OCTO version FPGA" in that
header.

Change-Id: I57f673dad5bc10b888fae22c2fb1a45af57ff493
Reviewed-on: https://code.wireshark.org/review/21434
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-30 17:45:02 +00:00
Simon Barber bb83fe4551 packet-ieee80211-radio.c: Minor refactor and whitespace cleanup
Change-Id: Idad8f7eeed968eeed9f553fef98d58453f328afb
Reviewed-on: https://code.wireshark.org/review/21421
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Tested-by: Michael Mann <mmann78@netscape.net>
2017-04-30 13:22:50 +00:00
Guy Harris 7f2c6e1300 Some cleanup.
Whitespace, remove now-irrelevant comments, add more comments, expand
some comments, make an if chain more straightforward.

Change-Id: I9772022247e2f0fdbfc676db9f0031bad7f8884d
Reviewed-on: https://code.wireshark.org/review/21423
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-30 03:52:11 +00:00
Guy Harris 9d49ab79a4 Boolean bitfields don't need a mask, just a bit.
You don't have to and the bitfield container with a mask and compare it
against the bit, you can just test the bit, which is a pretty standard C
idiom.

Change-Id: I87b3d84f802114199fb93357358412c623199ca2
Reviewed-on: https://code.wireshark.org/review/21422
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-30 03:39:24 +00:00
Guy Harris 5c1cf9d46a Series III packets appear to have an FCS at the end.
Change-Id: I9c4ba78cba4cb32a1473c6b8573880f2b56f1fde
Reviewed-on: https://code.wireshark.org/review/21417
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-30 02:43:04 +00:00
Guy Harris 113676bd95 Get rid of duplicate #defines, and shuffle some comments and #defines.
This makes stuff a bit clearer.

Also, add some comments, remove some redundant comments, fix some
comments, and use some #defines instead of hardcoded constants and
expressions.

And get rid of an unnecessary setting of *err to WTAP_ERR_SHORT_READ -
either it's a short read, in which case it was already set to
WTAP_ERR_SHORT_READ, or it's *not* a short read, in which case *err was
set to the appropriate error code, and we should leave it alone.

Change-Id: I657f505915854ac4a6b85e87b4021961b1a1c507
Reviewed-on: https://code.wireshark.org/review/21415
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-30 01:11:03 +00:00
Guy Harris a48997a174 Remove Series III code from vwr_read_s2_W_rec().
It's only called if vwr->FPGA_VERSION is S2_W_FPGA, so any code that's
run only if it's *not* S2_W_FPGA is dead code.  Remove it, for clarity.

While we're at it, add some new comments, fix some comments, and get rid
of an unused argument to vwr_read_s2_W_rec().

Change-Id: I3e4bd5d7a79f36d8354a0bbf875ee87eeaf60d43
Reviewed-on: https://code.wireshark.org/review/21414
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-30 00:38:24 +00:00
Guy Harris 2a3f1a4f67 Eliminate some double-frees.
The cfile_ error-reporting routines free err_info; the caller doesn't
have to and, in fact, mustn't do so themselves.

While we're at it, make sure wtap_seek_read() always zeroes out *err and
nulls out *err_info, so the latter either points to a freshly-allocated
string or is null.

Change-Id: Idfe05a3ba2fbf2647ba14e483187617ee53e3c69
Reviewed-on: https://code.wireshark.org/review/21407
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-29 11:29:34 +00:00
Michael Mann cc9b38a734 Improve ixveriwave dissector
Bug: 13652
Bug: 12535
Change-Id: Ie4c140acbe983a585776bc1430cf407cdcd6e07a
Reviewed-on: https://code.wireshark.org/review/21356
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-29 09:47:28 +00:00
Guy Harris 9f8c2296d0 Add/expand comments, add/shuffle #defines.
Attempt to make the various metadata headers, and the code that
constructs them, a bit clearer.

(Also, it's VeriWave; be consistent.)

Change-Id: I0bb7d70f547d492c4947ceb313888991f2d374f2
Reviewed-on: https://code.wireshark.org/review/21360
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-27 01:59:19 +00:00
Guy Harris 64ec2b2e5e Take the error message generation out of the merge_files routines.
Have them just return the information needed for the caller to produce
an error message, and have the callers use the new cfile_ routines for
reporting errors.

This requires that the "write failure alert box" routine take the
*input* file name as an argument, so that, on a merge, if the problem is
that a record from a given input file can't be written out to the type
of output file we're generating, the input file name can be given, along
with the record number in that file.

Change-Id: If5a5e00539e7e652008a523dec92c0b359a48e71
Reviewed-on: https://code.wireshark.org/review/21257
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-20 20:25:59 +00:00
Guy Harris c54afb89a2 No need to close a descriptor that didn't get duped-to in the first place.
Addresses CID 1398217.

Change-Id: I387c4a9f1df739724b80ccaad173de2d9095b101
Reviewed-on: https://code.wireshark.org/review/21179
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-18 05:58:59 +00:00
Guy Harris 613476fbaf More checks for localtime() failing.
Addresses CIDs 1398222 and 1398221.

Fix the previous fix while we're at it.

Change-Id: I6fe54e6ad115ac05154291b76de316426db72139
Reviewed-on: https://code.wireshark.org/review/21176
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-18 05:32:25 +00:00
Guy Harris 4ce54674b3 Just say "pcap" in the short names of all pcap variants.
That's more consistent.

Handle the "libpcap" names for backwards compatibility.

Change-Id: I819404d69bddd733b7ee38e23d3ddc71110c0faf
Reviewed-on: https://code.wireshark.org/review/21172
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-18 00:37:51 +00:00
Guy Harris ce6430e35e Eliminate an unneded member of a wtap_dumper.
The only place the time stamp precision is used is in the libpcap code,
where it determines whether to write out microsecond-precision or
nanosecond-precision time stamps; we can determine that by looking at
the type/subtype field, which is also part of that structure, so do
that.

We weren't setting it consistently - we were only setting it in libpcap
and a few other capture file writers, and not in other capture file
writers - and none of the writers other than libpcap used it.

Change-Id: If53779cf4823ca936b8bf3e8a7dbcfea5850e652
Reviewed-on: https://code.wireshark.org/review/21171
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-18 00:18:34 +00:00
Guy Harris 25382fd638 Don't assume gmtime() or localtime() succeed.
The chances that they won't, in this case, are slim to none, as the time
is after the Epoch, but this squelches CID 1398223.

We'll change the master branch to require an err_info string for
WTAP_ERR_INTERNAL and to display it in a future commit.

Change-Id: Ifb51076b25117efc53ba3ad8b434e36c71f7600f
Reviewed-on: https://code.wireshark.org/review/21169
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-17 18:03:46 +00:00
Guy Harris 357cfd3b03 A bunch of "{Mac} OS X" -> "macOS" changes.
Avoid anachronisms, however; there was no "macOS 10.0" or even "OS X
10.0", for example.  It was "Mac OS X" until 10.8 (although 10.7 was
sometimes called "OS X" and sometimes called "Mac OS X"), and it was "OS
X" from 10.8 to 10.11.

Change-Id: Ie4a848997dcc6c45c2245c1fb84ec526032375c3
Reviewed-on: https://code.wireshark.org/review/20933
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-05 19:16:22 +00:00
Scott Deandrea 62d78199ee Add packet capture support for Darwin USB
Change-Id: Iec9e4ac2362cf8e88a3cf6ae3483cefe938967e5
Reviewed-on: https://code.wireshark.org/review/20814
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
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-03-31 23:24:28 +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 60d2fda9c9 k12text.l: Move large data (WTAP_MAX_PACKET_SIZE) to the heap.
Change-Id: Ic291dbd5930978bbd0adc8b58d09b423de83b65b
Reviewed-on: https://code.wireshark.org/review/20754
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-03-28 01:08:56 +00:00
Michael Mann 26abd2a022 logcat_text.c: Move large data (WTAP_MAX_PACKET_SIZE) to the heap.
Change-Id: I3a391079a28aae7e41d926268f9f60152871bfa5
Reviewed-on: https://code.wireshark.org/review/20753
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-03-28 01:08:49 +00:00
Michael Mann 45df494f53 netscreen.c: Suppress compiler warnings on Windows
Change-Id: I6920b7ab5862db46c56a85198f97dced842f14d5
Reviewed-on: https://code.wireshark.org/review/20723
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-03-27 03:15:15 +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
Stig Bjørlykke b2ee646991 pcapng: Fix reading OPT_IDB_FCSLEN block
Changed to use correct option_id when reading IDB.

Change-Id: Id3a3b3cd95f9d7bcf51de001cfe246beb98590ad
Reviewed-on: https://code.wireshark.org/review/20663
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>
2017-03-22 09:55:13 +00:00
Guy Harris cfab7d55fd Handle LINKTYPE_SDLC.
Change-Id: I16a67f2d459cd6ebdbc7bdefd481fd95607af22a
Reviewed-on: https://code.wireshark.org/review/20662
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-03-22 02:11:23 +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 a9ec1e41b1 Squelch a warning from VS Code Analysis.
It warns that a 32-bit value is being shifted left and then converted to
a 64-bit type; presumably it means "this might overflow and not give you
the result you expect".  That's unlikely to be the case here, as few
UN*X file systems have a recommended I/O block size > 2^30, but we might
as well throw in a cast so the convert-to-a-64-bit-type is done first.

Change-Id: Id6ab11d750d5cf4cc03d060d63edc01b66cd179d
Reviewed-on: https://code.wireshark.org/review/20352
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-03-03 02:54:57 +00:00
Guy Harris 4bd3c4d44d Remove a cast that now causes rather than squelching warnings.
We're now comparing an unsigned with an expression made mostly of
unsigned, so there's no need to cast the expression to long to squelch
signed vs. unsigned warnings.

Change-Id: I3b8c6f6faf26a9c252eb55d9e69fb298a3ad4c3b
Reviewed-on: https://code.wireshark.org/review/20347
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-03-02 23:02:40 +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 b019c5931c Add more sanity checks.
Bug: 13431
Change-Id: I330cb087c6e89277120057019cb5155f005ed269
Reviewed-on: https://code.wireshark.org/review/20337
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-03-02 21:04:05 +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
Alexis La Goutte 841531bc85 wiretap (nettl/pppdump): fix this statement may fall through [-Werror=implicit-fallthrough=] found by gcc7
Change-Id: I8c339e7484d410460d499dd2923641630b482ebe
Reviewed-on: https://code.wireshark.org/review/20303
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-02-28 00:22:17 +00:00
Dario Lombardo 2de30dd18d wsutil: fix bugs in plugins_cleanup().
If plugin_list was NULL, plugin_types didn't get cleaned.
Add test and set of open_info_arr.

Change-Id: I7669e3ba86039fb2b26ff2da64f51896053c5e68
Reviewed-on: https://code.wireshark.org/review/20195
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-02-26 18:00:23 +00:00
Alexis La Goutte dfb05b9423 wtap_opttypes(.h): fix commas at the end of enumerator lists are a C++11 extension [-Wc++11-extensions]
Change-Id: Ie7f67510ea948fb72b57fe08d9f95d135c5855a5
Reviewed-on: https://code.wireshark.org/review/20194
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>
2017-02-20 18:30:10 +00:00
Michael Mann 0a4273f338 Only cleanup open_routines if not NULL
Change-Id: I76ea675625ef2812f51bad0c37f6c58060897f55
Reviewed-on: https://code.wireshark.org/review/20172
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-02-18 22:35:27 +00:00
Dario Lombardo 67d8830f2f wiretap: add open_routines cleanup function.
Change-Id: Id88fe84189b8baa597eaa69159395cdc4bc56195
Reviewed-on: https://code.wireshark.org/review/19951
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-02-18 01:17:41 +00:00
Guy Harris 6efc0f4ea6 Updated URL for STANAG 4607 documentation.
Change-Id: Ib25ab0ba5b9d613d55fc54c0f3ef84cb7698754f
Reviewed-on: https://code.wireshark.org/review/20136
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-02-16 08:31:38 +00:00
Guy Harris c7042bedbb Report an error for too-short packets.
The packet length field gives the length of the *entire* packet, so, by
definition, it must not be zero.  Make sure it's at least big enough for
the packet header itself plus one segment header.

Bug: 13416
Change-Id: I625bd5c0ce75ab1200b3becf12fc1c819fefcd63
Reviewed-on: https://code.wireshark.org/review/20133
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-02-16 08:19:04 +00:00
Guy Harris 724dc1cf5c "NULL" is not what you use for a null pointer.
It's a non-null pointer to a character string with the value "NULL".
You want just NULL, with no quotes.

Change-Id: I51bfb73a3002f46f13a8f513d07b1ddc009a14cb
Reviewed-on: https://code.wireshark.org/review/20123
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-02-16 00:47:05 +00:00
Pascal Quantin 6f18fed9ab wiretap: fix wtap_opttypes_cleanup() function
Change-Id: I475e2bc54af470e380e23e5dd98198885e189d6f
Reviewed-on: https://code.wireshark.org/review/20106
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2017-02-14 20:01:20 +00:00
Dario Lombardo 7c0c580c4b wiretap: add cleanup routine.
The cleanup routine has been added to exit section of the applications.
Those which required a exit restyle have been patched as well.

Change-Id: I3a8787f0718ac7fef00dc58176869c7510fda7b1
Reviewed-on: https://code.wireshark.org/review/19949
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2017-02-14 10:22:20 +00:00
Guy Harris 96f07a0f56 Fix typo.
Change-Id: I46be1220c8e789e1006cfbf7cff60e9556ff2caf
Reviewed-on: https://code.wireshark.org/review/19685
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-01-20 01:52:01 +00:00
Michael Mann d691b0ef7a Remove space character from ETHERWATCH magic key
V6.0 only has one space after "ETHERWATCH", not two so heuristics fail.
"ETHERWATCH " (one space) still seems like enough of a distinction.

Bug: 13093
Change-Id: Ib8786f6e2f5f595a4cab710b91cf78d175a6ab88
Reviewed-on: https://code.wireshark.org/review/19673
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Jaap Keuter <jaap.keuter@xs4all.nl>
2017-01-19 17:53:48 +00:00
Martin Kaiser 259989ac1a camins: improve the heuristics
The current mechanism that reads the first 20 blocks looking for a headerd
oesn't work in all cases. I was given sample files that consist of
data blocks only and have no header.

Use a new approach to detect a .camins file by searching for pairs of
size high + size low blocks, either read or write. Go through the
entire file. If we have significantly more pairs than single, non-matching
blocks, this is a camins file.

Change-Id: Ic91e7db7149b105e26896d1a89cad4a2a73d0f13
Reviewed-on: https://code.wireshark.org/review/19603
Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
Petri-Dish: Martin Kaiser <wireshark@kaiser.cx>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
2017-01-12 16:04:53 +00:00
Guy Harris 1afbab6995 Just use strncmp() to check the prefix of the file's first line.
Bug: 13246
Change-Id: I9df35596aa8dcb937f6a03cf60b5d0fbe9dce1ec
Reviewed-on: https://code.wireshark.org/review/19276
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-12-14 23:03:04 +00:00
Guy Harris 5fdbb7a5ac Don't assume we've read a line long enough to contain a magic number.
Check the length of the line first.

Bug: 13246
Change-Id: I906bb652594898061afb4b2cd4edb916af354161
Reviewed-on: https://code.wireshark.org/review/19273
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-12-14 22:43:46 +00:00
Guy Harris ab07f8e0f8 Have a routine to do all the work of initializing libwiretap.
Have programs that use libwiretap call that routine rather than
separately calling some or all of init_open_routines(),
wtap_register_plugin_types(), and wtap_opttypes_initialize().

Also don't have routines internal to libwiretap call those.  Yes, this
means doing some initialization work when it isn't necessary, but
scattering on-demand calls throughout the code is a great way to forget
to make those calls.

Change-Id: I5828e1c5591c9d94fbb3eb0a0e54591e8fc61710
Reviewed-on: https://code.wireshark.org/review/19069
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-12-04 21:42:44 +00:00
Guy Harris dd98856afc Have separate merge APIs for regular file/temporary file/standard output.
This is similar to what we have for opening a dump file - one API that
uses the file name as specified, one that creates a temporary file and
provides the file name, and one that uses the standard output.

All of those APIs handle closing the output file.

Change-Id: I56beea7be347402773460b9148ab31a8f8bc51e1
Reviewed-on: https://code.wireshark.org/review/19059
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-12-04 03:12:23 +00:00
Guy Harris b49e20c10a Remove unnecessary cast (gchar = char) that removes const.
Change-Id: I3924c2b4a525c0ae5ab57b7f9867296586d78509
Reviewed-on: https://code.wireshark.org/review/19061
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-12-04 03:00:12 +00:00
Guy Harris 99ca028ba5 Use ws_close(), rather than the UN*X-only close().
Change-Id: Iae29db90273191c10455e172bdd2aac00b12143c
Reviewed-on: https://code.wireshark.org/review/19058
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-12-03 23:16:22 +00:00
Guy Harris a63c5682bd Get rid of test printout.
Change-Id: I0db268b0f7010d23c938ae56674cc5cd6c0bd998
Reviewed-on: https://code.wireshark.org/review/19057
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-12-03 23:15:07 +00:00
Guy Harris 3309c08cd0 When opening the standard output for writing, dup it.
That way, we can close the resulting wtap_dumper the same way we close
any other wtap_dumper, including closing the FD, rather than trying to
do everything *except* closing the FD (which is tricky for a FILE *).

Change-Id: I8cb66e32784d73e598b2e8720a12f9bdab1c6205
Reviewed-on: https://code.wireshark.org/review/19054
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-12-03 22:17:41 +00:00
Guy Harris 6f37317539 Include config.h at the very beginning of all Flex scanners.
That way, if we #define anything for large file support, that's done
before we include any system header files that either depend on that
definition or that define it themselves if it's not already defined.

Change-Id: I9b07344151103be337899dead44d6960715d6813
Reviewed-on: https://code.wireshark.org/review/19035
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>
2016-12-02 21:02:10 +00:00
Anthony Coddington 7531318e05 ERF: Fix issues with Host ID mapping
packet-erf: Fix Host ID/Source ID showing for all extension header types.
Only show generated Host ID/Source ID when there is a Host ID extension header
or there was not one on the record.
Assumes there is only one Source ID if multiple Flow ID extension headers (unlikely)
and that it matches the one in the Host ID header. This is consistent with other tools.
Does support multiple Host ID extension headers though.

Fix dag_version tag short name. Was clashing with another tag due to typo.

ERF wiretap: Don't conflate Host ID 0 with implicit Host ID.

While the implicit Host ID defaults to 0, it is not the same thing as seeing
a packet with Host ID explicitly 0 in the extension header which means
explicitly unknown source.
Store the initial (unknown) implicit Host ID interface mapping in it's own
special mapping table entry rather than 0.

Noticed we can currently get duplicate interfaces in the unusual event of mixed
implicit and explicit Host ID packet extension headers for the same ID before
we discover that mapping.
Consistently abandon the implicit version for consistency with the dissector
linking behaviour and mark the interface as unmatched in the description. In
2 pass mode (including normal Wireshark file open) the abandoned interface ends
up with no packets. In the common cases (all Host ID or no Host ID on packet
records) this duplicate interface will not be created in the first place.

Change-Id: Ic5d0b2ce9aae973f1693a247cf240ef1324ff70a
Ping-Bug: 12303
Reviewed-on: https://code.wireshark.org/review/18704
Reviewed-by: Stephen Donnelly
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-11-08 12:09:39 +00:00
Pascal Quantin 1fae14257a merge.c: do not give a NULL pointer when saving SHB comment option
Bug: 13060
Change-Id: Ib3dd019f73305e4006b312d324502e4a138c6a16
Reviewed-on: https://code.wireshark.org/review/18514
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-10-27 21:50:18 +00:00
Guy Harris 10ca4c7527 More checks for localtime() and gmtime() returning NULL.
And some comments in the case where we're converting the result of
time() - if your machine's idea of time predates January 1, 1970,
00:00:00 UTC, it'll crash on Windows, but that's not a case where a
*file* can cause the problem due either to a bad file time stamp or bad
time stamps in the file.

Change-Id: I837a438e4b875dd8c4f3ec2137df7a16ee4e9498
Reviewed-on: https://code.wireshark.org/review/18369
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-10-22 02:27:32 +00:00
Balint Reczey f0cb70bd18 Exclude scanner-generated headers from ABI check
They break the check by not including header files for custom types
and they are not part of the API anyway.

Bug: 13018
Change-Id: Ia0f81f861251b5659af723b9da795daeb7454eb3
Reviewed-on: https://code.wireshark.org/review/18297
Reviewed-by: Balint Reczey <balint@balintreczey.hu>
Petri-Dish: Balint Reczey <balint@balintreczey.hu>
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-10-20 05:06:57 +00:00
Gerald Combs 13139a9853 dumpabi: Fix log paths.
Make sure the paths we pass to "cat" and "abi-compliance-checker
-log-path" match.

Change-Id: Ie68b445b9d92d85c0ed1eb508a78c0bcc960d061
Reviewed-on: https://code.wireshark.org/review/18156
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2016-10-11 21:48:45 +00:00
Guy Harris 37f37bb6b6 Some strings that appear in at least some .aps files.
Change-Id: I335a2db8ce6ebb424081a9a6156c6eb523720029
Reviewed-on: https://code.wireshark.org/review/18028
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-10-02 18:27:58 +00:00
Dario Lombardo 11c10244ef wsutil: split libjsmn.
The libjsmn was imported into the tree and enhanced with a new
function. This change splits it into the "original" libjsmn and
an addictional module wsjsmn that contains the new function.
This will make easier to port within the tree future versions
of the library.

Change-Id: I3f1caa91bee462e0767e5e18d0b6a10f0b1cad32
Reviewed-on: https://code.wireshark.org/review/17963
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2016-09-30 20:12:00 +00:00
Peter Wu 534787e402 cmake: make WERROR_COMMON_FLAGS a normal string
Instead of checking for the boolean "FALSE", just set an empty string.
This avoids the need to check for WERROR_COMMON_FLAGS before using it.

The transformation is the same for all files, remove
"if (WERROR_COMMON_FLAGS)" and "endif()", reindent and add quotes (since
we have a string here and not a list).

Modelines have been added where missing.

Change-Id: I0ab05ae507c51fa77336d49a99a226399cc81b92
Reviewed-on: https://code.wireshark.org/review/17997
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: João Valverde <j@v6e.pt>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Tested-by: Dario Lombardo <lomato@gmail.com>
2016-09-30 20:08:02 +00:00
Guy Harris e91af83c63 Replace some seeks forward with wtap_read_bytes() with a null buffer pointer.
If the seek forward is just skipping record content that's not
(currently) interesting, use wtap_read_bytes() with a null buffer
pointer; it catches short "reads" and requires less seeking, so it may
work better when reading from a pipe.

Change-Id: Ifb07d20e0391a8ed97da85149d971b4e9ef093a8
Reviewed-on: https://code.wireshark.org/review/17976
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-09-29 04:35:48 +00:00
Guy Harris 48a66835ee Use wtap_read_bytes() to skip over bytes when reading a record.
Allow file_read() to take a null pointer as a buffer argument; a null
argument means "do everything except copy the bytes from the file to the
user buffer".  That means that wtap_read_bytes() and
wtap_read_bytes_or_eof() also support a null pointer as a buffer
argument.

Use wtap_read_bytes() with a null buffer argument rather than
file_skip() to skip forward over data.

This fixes some places where files were mis-identified as ERF files, as
the ERF open heuristics now get a short "read" error if they try to skip
over more bytes than exist in the file.

Change-Id: I4f73499d877c1f582e2bcf9b045034880cb09622
Reviewed-on: https://code.wireshark.org/review/17974
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-09-28 23:45:58 +00:00
AndersBroman 4aca4dc319 file_access: Use g_slist_prepend.
Change-Id: I6ed0f384e130ec9181e43b6262bb21d91f944dfa
Reviewed-on: https://code.wireshark.org/review/17968
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-09-28 14:34:17 +00:00
Guy Harris 1158576622 Don't pick up junk from an unset error-number variable.
Keep the actual error code and pointer-to-error-string in the scanner
state, rather than pointers to the variables passed in to us.
Initialize them to 0 and NULL, respectively.

That way, when the actual scanner routine returns, we don't check for an
error by looking at the error variable pointed to by our argument, which
might not have been set by the scanner and might have stack junk in it,
we look at a structure member we set to 0 before the scan.

Change-Id: I81a4fd6d5cf5e56f5638fae1253c48dc50c9c36d
Reviewed-on: https://code.wireshark.org/review/17721
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-09-16 01:32:47 +00:00
Guy Harris 7a7d162a49 Don't pick up junk from an unset error-number variable.
Keep the actual error code and pointer-to-error-string in the scanner
state, rather than pointers to the variables passed in to us.
Initialize them to 0 and NULL, respectively.

That way, when the actual scanner routine returns, we don't check for an
error by looking at the error variable pointed to by our argument, which
might not have been set by the scanner and might have stack junk in it,
we look at a structure member we set to 0 before the scan.

Bug: 12903
Change-Id: I5a382da569a226e60c3c2a47f3a1515b0490c31d
Reviewed-on: https://code.wireshark.org/review/17716
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-09-15 22:21:17 +00:00
Dario Lombardo fcc56c2b7f iseries: rework the read routine.
Change the way a line is read in iseries. Instead of reading a string
then convert it with atoi, parse it as an integer and convert it to
nsecs.

Change-Id: Id8e8e9866dbcef3b1612a608f9647bc490263dae
Reviewed-on: https://code.wireshark.org/review/17558
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-09-15 00:33:11 +00:00
Peter Wu ba2a3b3626 wiretap: fix memory leak of interface_data for wtap_dumper
Mirrors the behavior of wtap_close.

Change-Id: I1a04878fdd0409fa74931737332f9b8a1ae77fb1
Reviewed-on: https://code.wireshark.org/review/17620
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2016-09-10 12:59:47 +00:00
Guy Harris 4a6dde12d6 Have "All Capture Files" match only capture files.
We support reading some types of files that aren't capture files, in
case we have a dissector for that file format (because, for example,
it's often transported over HTTP).  Don't include them in the set of
files "All Capture Files" matches; you can still look for them as they
have individual entries in the drop-down menu of file type patterns.

Ultimately, there should be Fileshark/TFileshark programs to read those
files - and other file types, and even capture files if the goal is to
look at the file structure rather than at the packets - and *that's* the
program that should offer the ability to load JPEGs and so on.

(No, this does not reduce the "All Capture Files" list down to a level
that makes the problem in bug 12837 go away.  The right way to fix
*that* is to arrange, somehow, that the "All Capture Files" entry not
actually list all the suffixes it matches.)

Change-Id: I705bff5fcd0694c6c6a11892621a195aa7cd0264
Reviewed-on: https://code.wireshark.org/review/17619
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-09-10 06:45:08 +00:00
Dario Lombardo faa04b1318 ipfix: use ws_strtoi function.
Change-Id: Icca32f714381166e505932958b87f9ffab62aa1d
Reviewed-on: https://code.wireshark.org/review/17557
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-09-09 08:38:30 +00:00
Dario Lombardo d5826f10bb erf: use ws_strtoi function.
Change-Id: I1d94deb547bd30076e0c171bf9e6b97aac98a545
Reviewed-on: https://code.wireshark.org/review/17556
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-09-09 08:37:39 +00:00
Guy Harris d62d867295 Get rid of trailing blank.
Change-Id: I3aa2f4a6e25f610e0e9236835bbcb588eeb15c08
Reviewed-on: https://code.wireshark.org/review/17602
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-09-09 08:31:56 +00:00
Guy Harris 216392975d Clean up error reporting.
Have xml_get_int() handle the setting of the two error reporting values
and give a better error message.  Have it check to make sure that there
isn't cruft after the digits.

Change-Id: Id590430eb52668ef76de8aa7096a27d8fc094208
Reviewed-on: https://code.wireshark.org/review/17601
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-09-09 08:30:42 +00:00
Guy Harris 381be238ad Add a comment.
Change-Id: Ia5bedaf8718985b325ed244a471cdc4e27f2928f
Reviewed-on: https://code.wireshark.org/review/17599
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-09-09 07:50:48 +00:00
Dario Lombardo 4312ec8996 dct3trace: use ws_strtoi function.
Change-Id: Iaa656dc4b939ac9649b87e88c9d27082d3e53f00
Reviewed-on: https://code.wireshark.org/review/17555
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-09-09 07:49:26 +00:00
Dario Lombardo 113c1ed24f catapult: use ws_strtou/i functions.
Change-Id: I0a9d3674c0cc2d0dba8c1fbeba2d739373cf8655
Reviewed-on: https://code.wireshark.org/review/17535
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-09-09 07:37:18 +00:00
Guy Harris c7fc280222 Make the ws_strto* routines more like the strto* routines.
Not all uses of atoi() or various strto* routines in Wireshark expect
the string to contain *only* a number, so not all uses should require
that the byte after the number be a '\0'.  Have the ws_strto* routines
take a "pointer a pointer set to point to the character after the
number" argument, and have the callers do the appropriate checks of the
character after that.

This fixes the VMS trace reading code so that it can read those files
again.

The get_ routines are handed command-line arguments, so they *do* expect
the string to contain only a number; have them check to make sure the
byte after the number is a '\0'.

Change-Id: I46fc1bea7912b9278e385fe38491a0a2ad60d697
Reviewed-on: https://code.wireshark.org/review/17560
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-09-07 20:41:53 +00:00
Guy Harris 7786a975af Further ws_strto* cleanups.
Make pkt_len unsigned.

Improve the error message for ws_strtou32() failure.

Change-Id: I080b4fc132c8e405bc1dbd87fc717c2b337517bc
Reviewed-on: https://code.wireshark.org/review/17547
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-09-07 04:49:36 +00:00
Dario Lombardo 4c39e19ff3 vms: use ws_strtoi function.
Change-Id: I30c32a6fc4200da5a150769b84f91b4d193f8f5d
Reviewed-on: https://code.wireshark.org/review/17536
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-09-07 04:26:32 +00:00
Peter Wu 14312835c6 pcapng: do not leak blocks
pcapng_open and pcapng_read have 'wblock' allocated on the stack, so if
they return, they do not have to set wblock.block to NULL.

pcapng_read_block always sets wblock->block to NULL and may initialize
it for SHB, IDB, NRB and ISB. Be sure to release the memory for IDB and
ISB. It is better to have more wtap_block_free calls on a NULL value
than missing them as this would be a memleak (on the other hand, do not
release memory that is stored elsewhere such as SHB and NRB).

Ping-Bug: 12790
Change-Id: I081f841addb36f16e3671095a919d357f4bc16c5
Reviewed-on: https://code.wireshark.org/review/17362
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2016-08-29 22:08:24 +00:00
Guy Harris 17f977ec56 Handle ETH_P_CANFD as well as ETH_P_CAN.
Both of them need to have the CAN ID/flags field of the header
byte-swapped as necessary to make sure it's in the *reading* host's byte
order, not the *writing* host's byte order, if the two are different.

Change-Id: Iac1589fdd9fe4d9ee6fbac8d821b48694d68919b
Reviewed-on: https://code.wireshark.org/review/17333
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-08-25 23:58:57 +00:00
Guy Harris 27372ca737 One more change for the removal of LINKTYPE_SOCKETCAN_HOSTENDIAN.
Change-Id: If1615e23efa30119fff5eb2935335c2cde34b89e
Reviewed-on: https://code.wireshark.org/review/17330
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-08-25 21:40:14 +00:00
Guy Harris c8157aa6b4 Go back to having only one SocketCAN LINKTYPE_ value.
Libpcap just backed out the "host-endian" SocketCAN LINKTYPE_ value; we
don't need it any more.

Change-Id: I33a7dc21207a0009e20b4abaefe1119eb649c39a
Reviewed-on: https://code.wireshark.org/review/17327
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-08-25 21:14:48 +00:00
João Valverde 640382c743 CMake: Allow setting per target compiler warnings
Setting our compiler warning flags in CMAKE_C_FLAGS does not allow
using different flags per target.

Allow for that possibility by setting the internal WS_WARNINGS_{C,CXX}_FLAGS
and using the COMPILE_OPTIONS property to set them.

This change is just setting mechanism and there should be no difference
in generated warnings.

The check_X_compiler_flag cmake test is changed to test each flag individually.
We need a list, not a space separated string, and the aggregate test is not
significant.

Change-Id: I59fc5cd7e130c7a5e001c598e3df3e13f83a6a25
Reviewed-on: https://code.wireshark.org/review/17150
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: João Valverde <j@v6e.pt>
2016-08-23 21:33:09 +00:00
Guy Harris 95c4c432c4 Handle the new LINKTYPE_CAN_SOCKETCAN_HOSTENDIAN.
Unfortunately, only one libpcap code path puts the CAN ID in the
SocketCAN header in network byte order; the others leave it in host byte
order.  Therefore, a new LINKTYPE_/DLT_ value was introduced, and
libpcap was changed to use that for the cases where the CAN ID is in
host byte order.  Support them both.

This means we need to, when reading pcap and pcapng files, fix up the
CAN ID if the host that wrote the file has a different byte order from
ours (as libpcap also now does).  This includes Linux "cooked" captures,
which can include CAN packets.

Change-Id: I75ff2d68d1fbdb42753ce85d18f04166f21736dd
Reviewed-on: https://code.wireshark.org/review/17155
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-08-19 01:42:06 +00:00
Guy Harris 45a8861b1e Don't distinguish between PARSED_NONRECORD and PARSE_FAILED.
If we got no bytes of data from a putative packet, the file isn't a
valid Ascend file, regardless of whether the parser failed or not.  Just
have parse_ascend() return a Boolean, TRUE if we got a packet and FALSE
if not, and, in the case where we got no data but the parser didn't
fail, provide "no data returned by parse" as the error string.

(We weren't actually distinguishing between them when we called
parse_ascend() - we were treating all non-PARSED_RECORD returns as an
error.)

Change-Id: I85a3e318015258f6a62c8d23ac2f906e28789982
Reviewed-on: https://code.wireshark.org/review/17130
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-08-18 02:04:48 +00:00
Guy Harris 85ebd88083 Make it a little clearer what ascend_open() is doing.
Expand comments, and merge two separate if checks.

Change-Id: If339ce632ccc91c425ba6db4a32296c3038253ac
Reviewed-on: https://code.wireshark.org/review/17128
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-08-18 01:42:23 +00:00
Guy Harris 3ba8a28f50 Just return the value of yyparse() from run_ascend_parser().
That's what we're doing already, but get rid of the variable to which we
assigned the return value.

Change-Id: I55e31664bc26bbfffe4a4ca764c917eefbb9a8f1
Reviewed-on: https://code.wireshark.org/review/17126
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-08-18 01:35:25 +00:00
Guy Harris 72a3195c86 The caplen for a packet is always "number of bytes seen".
Set wirelen to the length from the header, but don't set caplen; start
caplen out as 0 and count it up whenever we add a byte.

Bug: 12754
Change-Id: Ib4e45e947df6077f97a423157c152dac9f57734a
Reviewed-on: https://code.wireshark.org/review/17120
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-08-17 23:05:27 +00:00
Anthony Coddington 94cb86a0ca ERF: Add ERF_TYPE_META clock tags
Adds various clock configuration related tags.
Uses ptp_v2 value strings exported from packet-ptp.

Refactor out common ERF_TYPE_META bitfield code.
Also clean up field registration a bit.
Add flow_hash_mode enum, other minor wording cleanup.
Manually display relative timestamps as nanoseconds for <1ms.
Fix ns_host_* tag subtree summary field name duplication.

Ping-Bug: 12303
Change-Id: I76264d141f1c4a3590627637daa5dcd4fdfd2e93
Reviewed-on: https://code.wireshark.org/review/16782
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-07-31 13:26:33 +00:00
Guy Harris 93d5df468f If we don't get any OS information, remove the old OS information.
The old information is copied over from one of the input files; if we
don't have information about the OS on the machine writing the *output*
file, just throw the old information away.

(We need a better way to preserve information from the input files;
perhaps this:

   http://www.winpcap.org/pipermail/pcap-ng-format/2016-June/000362.html

might work.)

Change-Id: Ia25771736d267173f2b6949a91e81e217ee7d16f
Reviewed-on: https://code.wireshark.org/review/16730
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-07-27 21:32:09 +00:00
Pascal Quantin 4713ce4476 Ensure to have a valid string pointer when writing OS SHB option
Change-Id: Ib0b6dcdf1700e88383d30bf43739312fce10e1c7
Reviewed-on: https://code.wireshark.org/review/16696
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2016-07-26 13:48:40 +00:00
Michael Mann 907d49483d Fix some of the checkAPIs.pl warnings for g_warning.
1. Create ws_g_warning for legitimate uses of g_warning
2. Use proto_tree_add_debug_text
3. Comment some out

Change-Id: Ida044bf40286b955fdd529c4f9907c8e09b3d7c5
Reviewed-on: https://code.wireshark.org/review/16678
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-07-26 04:08:50 +00:00
Michael Mann 8505fb08c1 Fix shadow variable warnings.
Change-Id: I1e6bd722b3f04f171b462fc680ca080bb7ec03c7
Reviewed-on: https://code.wireshark.org/review/16625
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-07-24 15:16:14 +00:00
Guy Harris d2727ec8a2 Don't pass NULL to wtap_block_set_string_option_value().
To remove OPT_SHB_HARDWARE, use wtap_block_remove_option().

To get the string value from a GString, use g_string_free(string,
FALSE), not g_string_free(string, TRUE) - the latter will free the
string value and return NULL.

Change-Id: I0c5a9f818543f6752f455f04fb3c024208e23954
Reviewed-on: https://code.wireshark.org/review/16567
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-07-21 02:54:03 +00:00
Guy Harris 52323b20f5 Remove more string option value null checks.
Also, rename routines that write out an option write_wtap_XXb_option()
from write_wtap_XXb_block().

Change-Id: I4884a2f5275a5e2e32137b47255fac6995f311ef
Reviewed-on: https://code.wireshark.org/review/16566
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-07-21 00:45:56 +00:00
Guy Harris 3beab65515 No need to check for string option values being null.
A string option, if present, always has a value; it might be a null
*string*, but you won't get a null pointer (if the option isn't present,
it simply isn't present).

Fix some comments while we're at it.

Change-Id: I9c1420f56998a7d04de5c5cc2e92631b181f303a
Reviewed-on: https://code.wireshark.org/review/16564
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-07-21 00:28:18 +00:00
Guy Harris 6df8e83e57 block->options is never null; don't check for it.
A wtap_block_t always has an array of options, even if it's empty.

Fixes CID 1364135.

Change-Id: Ib1ba791ddcac078ec34def321d63d140c5576037
Reviewed-on: https://code.wireshark.org/review/16535
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-07-18 19:59:34 +00:00
Guy Harris d54f372c99 Remove wtap_block_num_options_of_type().
It's not used; currently, everything that accesses instances of a
multiple-instance-allowed option do so in a loop that iterates over
option instances by fetching values of the Nth option until the attempt
to fetch the option fails, making only one pass over the options.

Change-Id: Ife9583a5d246027dbfc133ab58027ef6641d65ef
Reviewed-on: https://code.wireshark.org/review/16534
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-07-18 19:47:35 +00:00
Guy Harris 16a01cfb01 Comment cleanups.
Change-Id: I995ba14cbd9bbe2c01b0770c16095084895498db
Reviewed-on: https://code.wireshark.org/review/16486
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-07-16 00:33:56 +00:00
Guy Harris ae598d1737 Add APIs to remove option instances from blocks.
That will allow deletion of comments, stripping of options when
sanitizing captures, etc..

Change-Id: I9667ba2ccf4e548ff3b7d500796b260a437bcea0
Reviewed-on: https://code.wireshark.org/review/16485
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-07-16 00:26:47 +00:00
Guy Harris 18d5bccede Use spaces rather than tabs for indentation.
Change-Id: I6028253f7c8c30804eaa4b23d2b09827aacb3c9d
Reviewed-on: https://code.wireshark.org/review/16481
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-07-15 21:01:04 +00:00
Guy Harris ea4a62df1f Update comments, give option numbers in decimal.
The pcapng spec gives option numbers in decimal, not hex.

Get rid of the "XXX if not available" comments - if an option isn't
present in a block, it's not present, and doesn't have *any* value.

Change-Id: I1bf0c9a5aaad7dfadf9248e22b67e172625bdd0d
Reviewed-on: https://code.wireshark.org/review/16480
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-07-15 20:58:07 +00:00
Guy Harris d0af229d1f Squelch a compiler warning.
Explicitly cst the results of g_memdup().

Change-Id: I20fd1f355e68735d7cc9bbeb41717a1c2a74de37
Reviewed-on: https://code.wireshark.org/review/16477
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-07-15 18:21:43 +00:00
Michael Mann b8ff743477 wtap_opttypes.c: Fix build error.
Change-Id: I3ee146d441e4d59701c72ed85dcb4efe97766df8
Reviewed-on: https://code.wireshark.org/review/16473
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-07-15 13:48:50 +00:00
Guy Harris 996dcc038d Do a deep copy in wtap_block_add_custom_option().
That way, we don't have to worry about multiple instances of an option
pointing to the same data. and having to worry about freeing data that's
pointed to by another instance.

Change-Id: I3470a9eebf346023713fd0d6ff2451d727c25089
Reviewed-on: https://code.wireshark.org/review/16471
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-07-15 08:31:55 +00:00
Guy Harris ced2071505 Fix the snapshot length part of the "same interface?" check.
Fix a typo - compare for unequal snapshot lengths, not equal snapshot
lengths.

Also, move the debug messages about checks right above the checks.

Change-Id: If6f5e125f05f3788b63e9f75d98f55e27830870b
Reviewed-on: https://code.wireshark.org/review/16470
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-07-15 07:31:03 +00:00
Guy Harris 8428d3a927 Squelch compiler warnings.
Cast some numerical values to wtap_block_type_t.

Change-Id: I56651c62045880638175c39174341feffb4b1068
Reviewed-on: https://code.wireshark.org/review/16451
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-07-15 01:33:18 +00:00
Guy Harris bb610ac57b Fix signature of wtap_opttype_block_register().
It gets passed a wtap_block_type_t value, so declare it as such.

Change-Id: I6980cab7e1885c9920b2a75e12f9d2d2a64d6f96
Reviewed-on: https://code.wireshark.org/review/16450
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-07-15 01:13:31 +00:00
Guy Harris 1f8999bb96 Redo the block options APIs.
A block can have zero or more instances of a given option.  We
distinguish between "one instance only" options, where a block can have
zero or one instance, and "multiple instances allowed" options, where a
block can have zero or more instances.

For "one instance only" options:

	"add" routines add an instance if there isn't one already
	and fail if there is;

	"set" routines add an instance if there isn't one already
	and change the value of the existing instance if there is one;

	"set nth" routines fail;

	"get" routines return the value of the instance if there is one
	and fail if there isn't;

	"get nth" routines fail.

For "multiple instances allowed" options:

	"add" routines add an instance;

	"set" routines fail;

	"set nth" routines set the value of the nth instance if there is
	one and fail otherwise;

	"get" routines fail;

	"get nth" routines get the value if the nth instance if there is
	one and fail otherwise.

Rename "optionblock" to just "block"; it describes the contents of a
block, including both mandatory items and options.

Add some support for NRB options, including IPv4 and IPv6 option types.

Change-Id: Iad184f668626c3d1498b2ed00c7f1672e4abf52e
Reviewed-on: https://code.wireshark.org/review/16444
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-07-14 23:02:39 +00:00
Michael Mann 335b2c0233 vwr.c Dynamically allocate large buffers
VS Code Analysis claims the arrays are too large and should be moved to help

Change-Id: I741ebe8cc73a108cb6e6d9ecbda37e2a4b6e1b4b
Reviewed-on: https://code.wireshark.org/review/16423
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-07-14 02:45:41 +00:00
Michael Mann fb0724981c pcapng.c: Use preprocessor directive to compare G_BYTE_ORDER with G_LITTLE_ENDIAN.
VS Code analysis considers them hardcoded values so the if statement is either
always true or always false.

Change-Id: Iabb8462b66f728195bf378ae26c79a783feddb03
Reviewed-on: https://code.wireshark.org/review/16422
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-07-14 02:45:20 +00:00
João Valverde a16d401b25 Remove Makefile.common files
Now that nmake build system has been removed they are not needed anymore.

Change-Id: I88075f955bb4349185859c1af4be22e53de5850f
Reviewed-on: https://code.wireshark.org/review/16050
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: João Valverde <j@v6e.pt>
2016-06-30 11:04:17 +00:00
Pascal Quantin 63027fce6e Windows: rename wiretap-${PROJECT_VERSION}.dll to libwiretap.dll
This aligns the name with what is done for other Wireshark shared libraries.
Moreover it allows to compile a wiretap plugin once per major release, without
the need to recompile it each time ${PROJECT_VERSION} changes (each nightly
build / official release).

Change-Id: I53c82277223a4f323079cf695168ac85c2fba523
Reviewed-on: https://code.wireshark.org/review/16058
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-06-22 23:57:01 +00:00
Anthony Coddington 57b6bc158d pcap: ERF per-Host ID/Source ID interface support
Add encap_priv pointer to libpcap_t.
Initialize erf_priv when ENCAP_ERF.
Use erf_populate_interface_from_header() to dynamically create interfaces.
Free encap_priv on pcap_close.

Ping-Bug: 12303
Change-Id: Ieda425ef3e50a124d9c38ee4538aa3644128ce60
Reviewed-on: https://code.wireshark.org/review/15362
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>
2016-06-21 10:40:18 +00:00
Rudra Rugge fa20f5cb5e Add support for Opencontrail virtual network
Change-Id: Ia6012e0f6425be069e222538eafb1191b398ec83
Reviewed-on: https://code.wireshark.org/review/15930
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>
2016-06-21 01:40:22 +00:00
Dario Lombardo b5a8c4f729 randpktdump: fix a crash.
Randpktdump requires the init the wtap opttypes.
Fixed making the init function public and calling it.

Bug: 12539
Change-Id: I02585c41012deacff1526b51ed09ab555cbfc8ce
Reviewed-on: https://code.wireshark.org/review/15951
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-06-16 03:05:37 +00:00
Rudra Rugge 38afb1d002 ip-over-ib description entry was missing
Description entry was missing in the list.

Change-Id: Ia8f8bd4608ee6800a352f4979752b5c45c4a5086
Reviewed-on: https://code.wireshark.org/review/15947
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-06-16 02:00:53 +00:00
Pascal Quantin 37c40bd7cf Export wtap_optionblock_copy_options() symbol
It can be useful for wiretap plugins

Change-Id: Ic56e4357ba3bfcef30d13615efc1361399c3133e
Reviewed-on: https://code.wireshark.org/review/15955
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2016-06-16 01:59:33 +00:00
Pascal Quantin 6baa1b544c Remove Nmake build system
Change-Id: I3bd474f3cda9667dec66426b5729449953df3e61
Reviewed-on: https://code.wireshark.org/review/15777
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Jörg Mayer <jmayer@loplof.de>
Reviewed-by: Balint Reczey <balint@balintreczey.hu>
2016-06-15 19:21:57 +00:00
Guy Harris 88bd50c592 Don't map the interface ID for records that don't pertain to an interface.
And revert to the previous behavior of map_phdr_interface_id(); that
change broke the mergecap tests when it was merging pcap files into a
pcapng file.

Change-Id: I2e079b0e87dce06e98faa9ab7615f9b9b2701b77
Reviewed-on: https://code.wireshark.org/review/15932
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-06-15 19:16:19 +00:00
Stig Bjørlykke ec5acbc33c wtap: Make default_filter static
Address of stack memory associated with local variable 'default_filter'
is still referred to by the global variable 'filter_option' upon returning
to the caller.  This will be a dangling reference.

Change-Id: I6160a37f05b8aea245b723ec50803e4062886738
Reviewed-on: https://code.wireshark.org/review/14427
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>
2016-06-15 17:56:21 +00:00
Gerald Combs d25a60c1c1 More Sysdig / system event support.
Add REC_TYPE_SYSCALL to wiretap and use it for Sysdig events. Call the
Sysdig event dissector from the frame dissector. Create a "syscall"
protocol for system calls, but add "frame" items to it for now.

Add the ability to write Sysdig events. This lets us merge packet
capture and syscall capture files.

Change-Id: I12774ec69c89d8e329b6130c67f29aade4e3d778
Reviewed-on: https://code.wireshark.org/review/15078
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-06-15 13:39:29 +00:00
Guy Harris b8779f9b59 More comment clarification.
That's not "the biggest record we're willing to write", it's "the
biggest record the pcapng format supports, as the record length is a
16-bit field".

Change-Id: Icbd5e0cc4ed8e2a3a0d474245a9b9ed2c999d520
Reviewed-on: https://code.wireshark.org/review/15818
Reviewed-by: Guy Harris <guy@alum.mit.edu>
(cherry picked from commit 09de28933f9a17d4472206e1ac4b7c92001e44f5)
Reviewed-on: https://code.wireshark.org/review/15820
2016-06-10 22:11:35 +00:00
Guy Harris 8626cefd11 Make the IPv4 NRB code's comments match the IPv6 NRB code's comments.
The IPv6 comments gave more details.

Change-Id: I4e4d865feadbabfd625cdf2b2b162b99c4f23efa
Reviewed-on: https://code.wireshark.org/review/15815
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-06-10 18:03:09 +00:00
Michael Mann 73286c417e Support reading in and storing multiple Section Header and Name Resolution blocks.
The data is not applied anywhere, just stored.  The first Section Header block
is still the only one that is used to read a pcapng file.

Change-Id: If9546401101d2fe79b2325bacbd597b92127e86e
Reviewed-on: https://code.wireshark.org/review/15705
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Jaap Keuter <jaap.keuter@xs4all.nl>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-06-08 03:39:49 +00:00
Anthony Coddington ad0e70f10c ERF: Make ERF wiretap forwards compatible.
Dissector has always been able to cope with unknown record types so pass them
through (and call the data dissector from the ERF dissector in this case).
Previously was stopping processing on the first unrecognized record which is
very unhelpful for otherwise valid files that have new types mixed in.

Remove ERF type check altogether from open heuristic as ERF type could be past
48 in future and with more extension headers bit any byte value could be valid.
Also allow setting ERF_RECORDS_TO_CHECK to 0 to force skipping the heuristic.

Change-Id: I8331eef30ba2e949564f418b3100bd73b8f58116
Reviewed-on: https://code.wireshark.org/review/15361
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-06-07 03:56:02 +00:00
João Valverde f1ff3208a0 Move ip6_to_str_buf() to to_str.c and make it take the buffer length.
Also make it use ws_inet_ntop6() (rather than implementing the string
conversion ourselves).

Remove ip6_to_str_buf_len().

Change-Id: I1eff3a8941e00987c2ff0c4dcfda13476af86191
Reviewed-on: https://code.wireshark.org/review/15692
Reviewed-by: João Valverde <j@v6e.pt>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-06-06 22:00:41 +00:00
Michael Mann 57ef06e242 *_stdup_printf -> strdup for "single string only" formatting.
Done for performance improvements.

This could probably be done in checkAPIs.pl, but this was just
a quick manual check with grepping.

Change-Id: I91ff102cb528bb00fa2f65489de53890e7e46f2d
Reviewed-on: https://code.wireshark.org/review/15751
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Jaap Keuter <jaap.keuter@xs4all.nl>
2016-06-06 06:03:58 +00:00
Guy Harris f9be95c4c8 Add a routine to get an array of all instances of a string option.
Use it for OPT_COMMENT in the SHB, as there may be ore than one instance
of OPT_COMMENT in an SHB.

Also, use wtap_optionblock_get_option_string for OPT_SHB_HARDWARE,
OPT_SHB_OS, and OPT_SHB_USERAPPL; they're specified as "only one
instance allowed".

Change-Id: I23ad87e41e40b7ae1155e96c0523a6f8caad5204
Reviewed-on: https://code.wireshark.org/review/15750
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-06-06 01:04:55 +00:00
Guy Harris adee685089 Directly use wtap_opttypes calls to fetch SHB options.
Don't put them in the summary structure; the summary routines should
calculate summary statistics, not dig up every bit of information that
*could* appear in a summary.

Instead, have the GUI code call wtap_file_get_shb() to get the SHB
information and call wtap_optionblock_get_option_string() to fetch the
option values.

Move the option code definitions into wtap_opttypes.h, as they're used
by the API.

Change-Id: Icef11f5fb30fdc3df1bb0208aae9ed0aebaf0182
Reviewed-on: https://code.wireshark.org/review/15748
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-06-06 00:22:21 +00:00
Michael Mann 614d09af13 Add data structures necessary to support multiple Name Resolution blocks.
This doesn't try to use any data from multiple Name Resolution blocks, it
just converts single Name Resolution block usage into a GArray, so the
potential is there to then use/support multiple Name Resolution blocks
within a file format (like pcapng)

Change-Id: Ib0b584af0bd263f183bd6d31ba18275ab0577d0c
Reviewed-on: https://code.wireshark.org/review/15684
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-06-01 22:58:06 +00:00
Michael Mann 6fa77a6acb Add data structures necessary to support multiple Section Header blocks.
This doesn't try to use any data from multiple Section Header blocks, it
just converts single Section Header block usage into a GArray, so the
potential is there to then use/support multiple Section Header blocks
within a file format (like pcapng)

Change-Id: I6ad1f7b8daf4b1ad7ba0eb1ecf2e170421505486
Reviewed-on: https://code.wireshark.org/review/15636
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-06-01 14:33:23 +00:00
Michael Mann acc018b8d1 Allow create_tempfile to support a suffix.
Ping-Bug: 10203
Change-Id: Ifa24870d711449b87e9839dd46af614e4aa28fde
Reviewed-on: https://code.wireshark.org/review/15608
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Martin Mathieson <martin.r.mathieson@googlemail.com>
2016-06-01 06:24:05 +00:00
Jeff Morriss 162edec9ad Register a few more file extensions as belonging to Wireshark.
Register Wireshark for PacketLogger, ERF, IPFIX, and VWR files on
freedesktop.org, OS X, and Windows (we were already registered for ERF and VWR
files on Windows).

Change-Id: I8105997cb15ea06e1c078489fd88763d4ce9e40c
Reviewed-on: https://code.wireshark.org/review/15635
Petri-Dish: Jeff Morriss <jeff.morriss.ws@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-06-01 04:30:19 +00:00
Jeff Morriss 56a095fe3c Suggest that file types should also be registered in the WiX installer.
Change-Id: If65ff14589ccd0b2d643256f3443dc26b3b71371
Reviewed-on: https://code.wireshark.org/review/15640
Reviewed-by: Jeff Morriss <jeff.morriss.ws@gmail.com>
2016-05-31 22:46:23 +00:00
Guy Harris 5b5ed7947d If routines return a wtap_opttype_return_val, declare them as doing so.
Also, improve the doxygen comments.

Change-Id: I57929dfba23d926fd806ac001a5a3924bb636ae0
Reviewed-on: https://code.wireshark.org/review/15634
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-05-30 22:23:59 +00:00
Michael Mann 47b58364dd Copy all options when creating SHB block for new file.
Change-Id: I666d4f546d9fdc026ccd7fac7750e80df7f9b697
Reviewed-on: https://code.wireshark.org/review/15611
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-05-30 04:18:41 +00:00
Guy Harris 448934152e Make wtap_optionblock_foreach_option public.
Change-Id: I99e448319669acfdb0ec3b96e8e1195ba4a1f4f9
Reviewed-on: https://code.wireshark.org/review/15594
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-05-28 01:32:43 +00:00
Michael Mann 7ca8e46ffb Remove write capabilities from wtap_optionblocks.
The write functionality was too PCAPNG-specific and the intention is to
keep the option blocks as generic as possible.

So moved the write functionality back to pcapng.c and added a
wtap_opttype API to loop through all options in the block
(wtap_optionblock_foreach_option)

Change-Id: Iaf49126a1a3e2ed60ae02c52878ca22671dac335
Reviewed-on: https://code.wireshark.org/review/15525
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-05-26 12:44:58 +00:00
Michael Mann 81d65ccec6 Add wtap_optionblock_set_option_string_format
Also add a length parameter to wtap_optionblock_set_option_string

Change-Id: I8c7bbc48aa96b5c2a91ab9a17980928d6894f1ee
Reviewed-on: https://code.wireshark.org/review/15505
Reviewed-by: Anthony Coddington <anthony.coddington@endace.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-05-22 23:39:14 +00:00
Anthony Coddington 546f5aa31b ERF: Fix and improve ERF_TYPE_META sanity checks
Fix sanity checking overflow in wiretap ERF_TYPE_META parsing segfault.
Fix final tag of exactly 4 bytes not being dissected.
Fix not setting bitfield tag subtree (was working due to proto.c internal behaviour).
Add dissector expertinfo for truncated tags. Dissect type and length on error.

Bug: 12352
Change-Id: I3fe6644f369e4d6f1f64270cb83c8d0f8a1f1a94
Reviewed-on: https://code.wireshark.org/review/15357
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-05-22 12:45:12 +00:00
Alexis La Goutte 2609d78fa3 wtap_opttypes: fix no previous prototype for function 'wtap_opttype_write_data_uint64_timestamp' [-Wmissing-prototypes]
Change-Id: I36244dee9cd5667d498ab0a4ba98b83e8fe84ac8
Reviewed-on: https://code.wireshark.org/review/15514
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-05-21 19:43:37 +00:00
Michael Mann 5078561b6a Add ability to add custom block types.
Change-Id: I2d23148c6f8d847aacec1d25cb694793ec9bb84e
Reviewed-on: https://code.wireshark.org/review/15504
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-05-21 03:29:15 +00:00
João Valverde d5508d2b3b autotools: Add automake silent rule for ln -s
Change-Id: Ic5b6fca04955384dc3d337ec74757f711216a372
Reviewed-on: https://code.wireshark.org/review/15468
Petri-Dish: Jeff Morriss <jeff.morriss.ws@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Jeff Morriss <jeff.morriss.ws@gmail.com>
2016-05-19 01:13:53 +00:00
Guy Harris 2262c06f41 Correctly write out the isb_startime and isb_endtime options.
They're not marshalled as a 64-bit integer in pcapng files, they're
marshelled as 2 32-bit integers, the first of which is the upper 64 bits
of the value and the second of which is the lower 64 bits of the value.

Bug: 12349
Change-Id: I2bde51ac11b2518ef2ddaecf43672c984f26081a
Reviewed-on: https://code.wireshark.org/review/15492
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-05-17 21:04:55 +00:00
Adam Goldman ba3f4f991c opa: Add dissectors for Intel’s Omni-Path Architecture (OPA)
Added dissectors for OPA Fabric Executive (FE) Header, OPA Snoop and
Capture (SnC) MetaData Header, OPA 9B Packets, and OPA MAD Packets.

Bug: 12114
Change-Id: I6acd3c9e266e4b638167abbdd275ec7c1d472b4f
Reviewed-on: https://code.wireshark.org/review/13473
Reviewed-by: Adam Goldman <adam.goldman@intel.com>
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-05-17 18:05:54 +00:00
Anthony Coddington c38f4e1391 pcap-common: Account for padding in ENCAP_ERF len and caplen
Set len and caplen in pcap_read_post_process to actual wlen/payload length like for native ERF.
This fixes padding incorrectly showing as an Ethernet trailer or equivalent as
well as packet length calculations being incorrect.

Fix up rlen when writing ENCAP_ERF so it isn't longer than the actual record
length. This differs from native ERF behaviour which pads the record instead
but there is currently no non-hackish way to do this for pcap/pcap-ng.

Note: This means records captured from a DAG card in Wireshark (or old
PCAP(-NG) files opened) will have padding stripped when saved as PCAP(-NG) and
thus cannot be transmitted when converted to native ERF without aligning first.
However, if the file is saved as native ERF originally the padding will be
preserved (and zeroed). Given that extension header write support was very
broken and transmission of PCAP(-NG) is not supported without conversion this
is not expected to have been common.

Ping-Bug: 3606
Change-Id: I49dce03984d7f07431b6eb7e16a993aeb571f288
Reviewed-on: https://code.wireshark.org/review/15359
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-05-15 01:53:21 +00:00
Martin Kaiser 2f1e956142 mp2t (CID 1355406): fix a potential integer overflow
cast one of the factors to uint64 to make sure that the calculation uses
uint64 and not uint32 which may overflow

Change-Id: Iec14f870a694008f5a734294d9154117b6c64b78
Reviewed-on: https://code.wireshark.org/review/15346
Petri-Dish: Jaap Keuter <jaap.keuter@xs4all.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
2016-05-14 09:45:54 +00:00
Anthony Coddington 5b61e9e484 pcap-common: Fix several serious ENCAP_ERF extension header writing issues
Write ERF subheader after extension headers, especially important for Ethernet
(other types predate extension headers for the most part).
Add missing ERF_TYPE_MC_AAL2 and ERF_TYPE_COLOR_HASH_ETH.

Truncate final ERF extension header when too many. Rlen is not currently
adjusted so may be incorrect (see followup patch). Existing tools generally
check against PCAP incl_len anyway as there are other scenarios where this can
happen like naive snapping or Wireshark ERF-to-PCAP.
Properly fixing this will involve getting rid of the ERF pseudoheader.
Consistent with the ERF wiretap (except for different padding behaviour).

Bug: 3606
Change-Id: I6086cbc3fef948586fbad6f585f648d99adfff4f
Reviewed-on: https://code.wireshark.org/review/15358
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-05-12 01:46:31 +00:00
Jeff Morriss d5031d5cf4 automake/nmake: don't run checkAPIs on lex and yacc files.
The lex files use malloc and friends which is prohibited; don't check them
(until checkAPIs becomes smart enough to realize this is OK).

This mirrors what is done in cmake.

Change-Id: Ie80ea7a9b7c0e25c70c8edf3671e80a493ea1b2f
Reviewed-on: https://code.wireshark.org/review/15377
Petri-Dish: Jeff Morriss <jeff.morriss.ws@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-05-11 18:20:57 +00:00
Pascal Quantin a6a8745bea wiretap: fix writing of 1 bytes long options in pcapng files
the option length should be 1 byte, not 4 bytes.

Change-Id: I1b356c7ce101f9bbdc9793fc280b6564e12f303f
Reviewed-on: https://code.wireshark.org/review/15265
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-05-04 21:04:27 +00:00
Graham Bloice 2e23b506c7 Add checkAPI calls to CMake.
This generates a top level target, checkAPI, that is
excluded from the ALL build target, so must be run separately.

On Windows using a Visual Studio generator, call
msbuild /p:Configuration=RelWithDebInfo checkAPI.vcxproj

Change-Id: I44a57c564dcfc75499463b942436f4b920a82478
Reviewed-on: https://code.wireshark.org/review/14873
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Graham Bloice <graham.bloice@trihedral.com>
2016-05-02 12:01:24 +00:00
Guy Harris 22a2821df2 Another "this is < WTAP_MAX_PACKET_SIZE so no checks are needed" note.
Change-Id: Ie46a141b1e41ee855defe60eba9137718770df9b
Reviewed-on: https://code.wireshark.org/review/15241
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-05-02 01:26:14 +00:00
Guy Harris f2353b2de1 Remove trailing blank.
Change-Id: I57017b3e574983dac9107712a0dd6b243b62bb80
Reviewed-on: https://code.wireshark.org/review/15240
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-05-02 01:00:39 +00:00
Guy Harris c7d67d8ff5 Add some more checks, clean up length handling.
Check for destination or source MAC addresses that aren't 12 characters
(hex dump of 6 octets) long and type/length fields that aren't 4
characters (hex dump of 2 octets) long.

The buffer into which we copy the hex dump characters doesn't need to be
null-terminated, so don't bother to null-terminate it.  Use the final
offset into the buffer as the buffer length, rather than using strlen().

Just memcpy the MAC addresses and type/length fields into the buffer;
the buffer is guaranteed to be big enough for all of them, and, as
noted, it doesn't need to be null-terminated.

Change-Id: I790e953542ae8443af01c81229a8deb877448ee3
Reviewed-on: https://code.wireshark.org/review/15239
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-05-02 00:59:19 +00:00
Guy Harris 6332c2f45e Don't assume packets will be no larger than ISERIES_MAX_PACKET_LEN.
We don't check against it.  Insteead, use phdr->caplen as the buffer
size; that's based on the number of hex digits we've found.

While we're at it, also get rid of ISERIES_PKT_ALLOC_SIZE - it makes it
less obvious that it's based on the packet length from the packet
header.

Change-Id: I8ad6306c62e7bc4cf896b335f39a5a77780fb2ea
Reviewed-on: https://code.wireshark.org/review/15236
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-05-02 00:53:16 +00:00
Guy Harris 7666361bf9 Make sure the packet length isn't > WTAP_MAX_PACKET_SIZE.
Change-Id: I65c1e87e2fcff93b3db998666ff51f19ecd71b55
Reviewed-on: https://code.wireshark.org/review/15233
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-05-02 00:08:32 +00:00
Guy Harris 3270dfac43 Don't treat the packet length as unsigned.
The scanf family of functions are as annoyingly bad at handling unsigned
numbers as strtoul() is - both of them are perfectly willing to accept a
value beginning with a negative sign as an unsigned value.  When using
strtoul(), you can compensate for this by explicitly checking for a '-'
as the first character of the string, but you can't do that with
sscanf().

So revert to having pkt_len be signed, and scanning it with %d, but
check for a negative value and fail if we see a negative value.

Bug: 12394
Change-Id: I4b19b95f2e1ffc96dac5c91bff6698c246f52007
Reviewed-on: https://code.wireshark.org/review/15230
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-05-01 23:31:51 +00:00
Guy Harris a66628e425 Don't treat the packet length as unsigned.
The scanf family of functions are as annoyingly bad at handling unsigned
numbers as strtoul() is - both of them are perfectly willing to accept a
value beginning with a negative sign as an unsigned value.  When using
strtoul(), you can compensate for this by explicitly checking for a '-'
as the first character of the string, but you can't do that with
sscanf().

So revert to having pkt_len be signed, and scanning it with %d, but
check for a negative value and fail if we see a negative value.

Bug: 12395
Change-Id: I43b458a73b0934e9a5c2c89d34eac5a8f21a7455
Reviewed-on: https://code.wireshark.org/review/15223
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-05-01 23:23:29 +00:00
Guy Harris 11edc83b98 Don't treat the packet length as unsigned.
The scanf family of functions are as annoyingly bad at handling unsigned
numbers as strtoul() is - both of them are perfectly willing to accept a
value beginning with a negative sign as an unsigned value.  When using
strtoul(), you can compensate for this by explicitly checking for a '-'
as the first character of the string, but you can't do that with
sscanf().

So revert to having pkt_len be signed, and scanning it with %d, but
check for a negative value and fail if we see a negative value.

Bug: 12396
Change-Id: I54fe8f61f42c32b5ef33da633ece51bbcda8c95f
Reviewed-on: https://code.wireshark.org/review/15220
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-05-01 23:14:25 +00:00
Guy Harris 29c78db2a8 Don't treat the packet length as unsigned.
The scanf family of functions are as annoyingly bad at handling unsigned
numbers as strtoul() is - both of them are perfectly willing to accept a
value beginning with a negative sign as an unsigned value.  When using
strtoul(), you can compensate for this by explicitly checking for a '-'
as the first character of the string, but you can't do that with
sscanf().

So revert to having pkt_len be signed, and scanning it with %d, but
check for a negative value and fail if we see a negative value.

Change-Id: I6450d468504e942df72342176a0e145e5ac3db5f
Reviewed-on: https://code.wireshark.org/review/15216
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-05-01 23:03:20 +00:00
Guy Harris deb687b376 Return the same error for too-large packets as we do for other files.
And note that our limit (which is what we use as the fixed buffer size)
is less than WTAP_MAX_PACKET_SIZE, so we don't have to check against
WTAP_MAX_PACKET_SIZE.

Change-Id: I28cd95c40fd2fba9994a5d64ef323f1d8c1c4478
Reviewed-on: https://code.wireshark.org/review/15204
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-04-30 23:38:56 +00:00
Guy Harris b39f0f32f9 Note that we don't have to worry about too-large packets.
Change-Id: If72fb1ed64686348fa24b441cba8534fadc0e707
Reviewed-on: https://code.wireshark.org/review/15203
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-04-30 23:11:43 +00:00
Guy Harris 0bffb1663e Clean up packet length handling.
Treat the packet length as unsigned - it shouldn't be negative in the
file.  If it is, that'll probably cause the sscanf to fail, so we'll
report the file as bad.

A normal packet should be Ethernet-sized; initially make the buffer big
enough for a maximum-sized Ethernet packet.

Once we know the payload length, check to make sure the packet length
won't be > WTAP_MAX_PACKET_SIZE and fail if it will.  Then boost the
buffer size to be large enough for the packet, even if it's bigger than
a maximum-sized Ethernet packet.

Change-Id: I75b2108dd68f5bc5cd436bf5b82990089a7116bf
Reviewed-on: https://code.wireshark.org/review/15200
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-04-30 18:30:57 +00:00
Guy Harris b83c39e029 Have daintree_sna_read_packet() do all the packet reading work.
Share more code between the read and seek-read routines.

Also note why that code doesn't have to check against
WTAP_MAX_PACKET_SIZE.

Change-Id: I09086fcd3c16883c2598fb0aeb172c66f480d315
Reviewed-on: https://code.wireshark.org/review/15193
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-04-30 09:06:00 +00:00
Guy Harris 43cf41a356 Check for packets bigger than WTAP_MAX_PACKET_SIZE.
Change-Id: Iaa4865393e711633312e44eaba4985c75668746a
Reviewed-on: https://code.wireshark.org/review/15190
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-04-30 02:35:50 +00:00
Guy Harris bc62c096d0 Check for packets bigger than WTAP_MAX_PACKET_SIZE.
Change-Id: Ia932f3e5aeaca7a566ea9f00ce1dca1a2071a1a4
Reviewed-on: https://code.wireshark.org/review/15187
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-04-30 02:10:42 +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 44f72a90ea Check for packets bigger than WTAP_MAX_PACKET_SIZE.
Change-Id: If7cd6ae60b805121c3f54dcaa48d730b6cd9b648
Reviewed-on: https://code.wireshark.org/review/15183
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-04-30 02:00:13 +00:00
Guy Harris 5635d9a02d Check for packets bigger than WTAP_MAX_PACKET_SIZE.
And note the cases where we don't have to check, as the length in the
file is 2 bytes long, and 65535 + the metadata length is <
WTAP_MAX_PACKET_SIZE.

Change-Id: I1e690eeee900b9aa7484dc0bd0c106dc38c77269
Reviewed-on: https://code.wireshark.org/review/15180
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-04-30 01:55:42 +00:00
Guy Harris 55cc5da8c8 Use WTAP_MAX_PACKET_SIZE as the maximum packet length.
And use the actual packet length, rather than a fixed value, as the
buffer size we need for the packet.

Change-Id: I3af6724210a85b50610839d1bdf97fcf5a152b2f
Reviewed-on: https://code.wireshark.org/review/15179
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-04-30 01:50:31 +00:00
Guy Harris 6a140eca7b Fix packet length handling.
Treat the packet length as unsigned - it shouldn't be negative in the
file.  If it is, that'll probably cause the sscanf to fail, so we'll
report the file as bad.

Check it against WTAP_MAX_PACKET_SIZE to make sure we don't try to
allocate a huge amount of memory, just as we do in other file readers.

Use the now-validated packet size as the length in
ws_buffer_assure_space(), so we are certain to have enough space, and
don't allocate too much space.

Merge the header and packet data parsing routines while we're at it.

Bug: 12396
Change-Id: I7f981f9cdcbea7ecdeb88bfff2f12d875de2244f
Reviewed-on: https://code.wireshark.org/review/15176
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-04-30 00:08:48 +00:00
Guy Harris f5ec0afb76 Fix packet length handling.
Treat the packet length as unsigned - it shouldn't be negative in the
file.  If it is, that'll probably cause the sscanf to fail, so we'll
report the file as bad.

Check it against WTAP_MAX_PACKET_SIZE to make sure we don't try to
allocate a huge amount of memory, just as we do in other file readers.

Use the now-validated packet size as the length in
ws_buffer_assure_space(), so we are certain to have enough space, and
don't allocate too much space.

Merge the header and packet data parsing routines while we're at it.

Bug: 12395
Change-Id: Ia70f33b71ff28451190fcf144c333fd1362646b2
Reviewed-on: https://code.wireshark.org/review/15172
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-04-29 22:51:41 +00:00
Guy Harris 5efb452316 Fix packet length handling.
Treat the packet length as unsigned - it shouldn't be negative in the
file.  If it is, that'll probably cause the sscanf to fail, so we'll
report the file as bad.

Check it against WTAP_MAX_PACKET_SIZE to make sure we don't try to
allocate a huge amount of memory, just as we do in other file readers.

Use the now-validated packet size as the length in
ws_buffer_assure_space(), so we are certain to have enough space, and
don't allocate too much space.

Bug: 12394
Change-Id: Ifa023ce70f7a2697bf151009b035a6e6cf8d5d90
Reviewed-on: https://code.wireshark.org/review/15169
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-04-29 22:20:26 +00:00
Jeff Morriss c954b1cefc Remind wiretap developers where else they need to register their file types.
Chances are they want to include the file extension in wiretap's list of
file extensions (for the File->Open dialog) as well as the various files
needed for integration with the various desktop environments that
Wireshark supports.

(I should have put this advice there years ago when creating the
freedesktop.org mime-package file.)

Add a comment to the mime-package file explaining its purpose, giving
a link to the specification, and talking about MIME types and the registration
thereof.

Change-Id: I60540bf88062b7a90653888534405f6aef4f657c
Reviewed-on: https://code.wireshark.org/review/15011
Reviewed-by: Jeff Morriss <jeff.morriss.ws@gmail.com>
2016-04-28 19:01:26 +00:00
Dominic Chen f90882fa2f mp2t: add frame limit to mp2t_find_next_pcr, and handle timeout correctly
Change-Id: I02fab252bed3c4d0b134c2e61ea6f3338e21637b
Reviewed-on: https://code.wireshark.org/review/15114
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-04-27 07:43:53 +00:00
Michael Mann dacdb0bde8 Fix nmake build after statically linking version code
Change-Id: I86a01bdd778f2242aa534a687275a85a2f329c02
Reviewed-on: https://code.wireshark.org/review/15071
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-04-25 12:11:39 +00:00
Alexis La Goutte cad076a820 mplog: fix 'err_info' was marked unused but was used [-Werror,-Wused-but-marked-unused]
Change-Id: Ifbbd9d264c7d75b6df754ca9834de5e415b97796
Reviewed-on: https://code.wireshark.org/review/15080
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-04-25 10:45:16 +00:00
João Valverde 5d1ee652ed Add CMake version.h dependency
Remove the need for version.h.in and bring CMake up to par with autotools.

Change-Id: I701b56c475f5fdec1f9a028536fff6992ce8eaca
Reviewed-on: https://code.wireshark.org/review/15031
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: João Valverde <j@v6e.pt>
2016-04-22 22:10:30 +00:00
Jeff Morriss bc820f0b3e Add mplog to the list of file extensions understood by Wireshark.
By putting it in this list the File->Open dialog will include an option for
*.mplog files.

Change-Id: Icf6480f7be1023650262fc1f3996a390e137cb88
Reviewed-on: https://code.wireshark.org/review/15048
Petri-Dish: Jeff Morriss <jeff.morriss.ws@gmail.com>
Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-04-22 04:48:17 +00:00
João Valverde 3db13a7fc9 Link version code statically again
This allows keeping the code-sharing with the static linking.

This "fixes" a hypothetical ABI mismatch with wsutil and avoids pulling more
external dependencies to wsutil than strictly necessary.

A nice side-effect is that libwsutil no longer depends on version.h.

Follow up to f95976eefc.

Change-Id: I8f0d6a557ab3f7ce6f0e2c269124c89f29d6ad23
Reviewed-on: https://code.wireshark.org/review/15002
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: João Valverde <j@v6e.pt>
2016-04-21 18:59:56 +00:00
Dario Lombardo c33274dafa wtap: fix leak in optionblock management.
Found by valgrind:

==14298==    at 0x4C2CE8E: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14298==    by 0xA66C6AE: g_realloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
==14298==    by 0xA63BB32: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
==14298==    by 0xA63BEB7: g_array_append_vals (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
==14298==    by 0xA193252: wtap_optionblock_add_option (wtap_opttypes.c:352)
==14298==    by 0xA19361C: shb_create (wtap_opttypes.c:607)
==14298==    by 0xA192F96: wtap_optionblock_create (wtap_opttypes.c:126)
==14298==    by 0xA168784: wtap_open_offline (file_access.c:824)
==14298==    by 0x11D47C: cf_open (tshark.c:4194)
==14298==    by 0x117852: main (tshark.c:2183)

et al.

Change-Id: Ic16595ed3c12b9ed6c2813852ceb594c29ece929
Reviewed-on: https://code.wireshark.org/review/15004
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Evan Huus <eapache@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-04-19 22:59:56 +00:00
Guy Harris 61677f9c3f Call the buffer for the magic number "magic".
It's not guaranteed to be a C string, so don't call it "str".

Change-Id: I614ccf4f87b9f6f58d9b72596827224006f1de30
Reviewed-on: https://code.wireshark.org/review/14998
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-04-19 01:31:03 +00:00
Guy Harris 378bdbfb3f Distinguish between read errors and short reads when opening.
Use wtap_read_bytes() which will return WTAP_ERR_SHORT_READ if we don't
get the specified number of bytes.  Treat all errors *other* than
WTAP_ERR_SHORT_READ as an I/O error.

Change-Id: If38b5ad1b142441f2f2dd356be196bf381058da4
Reviewed-on: https://code.wireshark.org/review/14997
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-04-19 01:28:17 +00:00
Guy Harris b13d9b6474 Open routines are called with the seek pointer at the beginning.
There's no need for an open routine to seek back to the beginning of the
file - the file open code has done that already.

Change-Id: I4053474e60e7c8e8f59a89503d4bb08499d9399e
Reviewed-on: https://code.wireshark.org/review/14996
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-04-19 01:23:20 +00:00
Guy Harris b6784594f5 Detect and handle EOFs in the middle of a packet.
And *any* EOFs in the seek-read routine.

Change-Id: I5742c7bbd782e59e9c64e4821f22c706ddbc5382
Reviewed-on: https://code.wireshark.org/review/14995
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-04-19 01:19:21 +00:00
Guy Harris c943afbdac Use memcmp() to check the magic number.
We just care whether the first 6 bytes of the file are "MPCSII";
memcmp() will do that, and we don't have to worry about NULs.

Change-Id: I03872c30e76eedce67577657270e36f0795e74bd
Reviewed-on: https://code.wireshark.org/review/14994
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-04-19 01:06:18 +00:00
Martin Kaiser fb39f102b9 wiretap: add support for the mplog capture file format
the mplog format is used by some commercial logging tools that capture
ISO 14443 traffic between a card reader and a contactless smartcard

Change-Id: If359b8f0f671eb2a7c6315e2b8960a5bd581a9e9
Reviewed-on: https://code.wireshark.org/review/14950
Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
2016-04-18 09:39:42 +00:00
Guy Harris b43108acb2 Fix "2nd byte of optional tags bitmap" flag values.
The presence bits field isn't made up of multiple bytes, it's a single
32-bit field, so move the bit values up 8 bits so they don't collide
with the values from the first byte.

Prevents a crash with at least one 32.423 file.

Change-Id: I804e76a5b8844f1f3894a43af7fd8bbe9fa7447c
Reviewed-on: https://code.wireshark.org/review/14943
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-04-17 00:52:43 +00:00
Gerald Combs cf6501eb45 Windows: Remove the need for _CRT_NONSTDC_NO_DEPRECATE.
Replace some function calls with their non-deprecated equivalents so
that we can remove _CRT_NONSTDC_NO_DEPRECATE from CMakeLists.txt and
config.nmake.

Leave _CRT_SECURE_NO_DEPRECATE in place. Removing it failed with 145
warnings and 72 errors.

Note that we could probably improve startup performance by using wmem
in diam_dict.*.

Change-Id: I6e130003de838aebedbdd1aa78c50de8a339ddcb
Reviewed-on: https://code.wireshark.org/review/14883
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-04-13 02:16:20 +00:00
Guy Harris 368e3b8bd7 Set the extra type the right way.
Use %option extra_type= rather than #defining YY_EXTRA_TYPE.

Change comments to reflect that the state structure is used both by the
lexical analyzer and the parser.

Change-Id: I19a81de61cbd6e86d71154f376ef0681cc6d42fb
Reviewed-on: https://code.wireshark.org/review/14826
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-04-05 23:32:18 +00:00
AndersBroman dae23a107f [ERF] g_list_free_full () is glib >= 2.28, g_hash_table_add is >= 2.32
change to supported functions.

Change-Id: Ic088b835d05dce4a1b9b7a102cab89be44da46d6
Reviewed-on: https://code.wireshark.org/review/14819
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-04-05 19:18:20 +00:00
João Valverde ecb4dc396e Include ws_diag_control.h in config.h
Change-Id: Ia394071710ecda3b0e6686a51fbca45a8ff20317
Reviewed-on: https://code.wireshark.org/review/14749
Petri-Dish: João Valverde <j@v6e.pt>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: João Valverde <j@v6e.pt>
2016-04-04 23:05:31 +00:00
João Valverde 6f98a0fac3 Rename "libz" to "zlib"
Change-Id: I12f92c983d587c2a4751428cdf299635090c9f0b
Reviewed-on: https://code.wireshark.org/review/14748
Reviewed-by: João Valverde <j@v6e.pt>
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-04-04 06:58:41 +00:00
Guy Harris 014d75116c Fix #defines.
Change-Id: I0fcd865d686d50ae9be17e97a4495daebc4bc4fc
Reviewed-on: https://code.wireshark.org/review/14801
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-04-03 22:43:04 +00:00
Guy Harris 59816ef00c Make the Flex scanners and YACC parser in libraries reentrant.
master-branch libpcap now generates a reentrant Flex scanner and
Bison/Berkeley YACC parser for capture filter expressions, so it
requires versions of Flex and Bison/Berkeley YACC that support that.

We might as well do the same.  For libwiretap, it means we could
actually have multiple K12 text or Ascend/Lucent text files open at the
same time.  For libwireshark, it might not be as useful, as we only read
configuration files at startup (which should only happen once, in one
thread) or on demand (in which case, if we ever support multiple threads
running libwireshark, we'd need a mutex to ensure that only one file
reads it), but it's still the right thing to do.

We also require a version of Flex that can write out a header file, so
we change the runlex script to generate the header file ourselves. This
means we require a version of Flex new enough to support --header-file.

Clean up some other stuff encountered in the process.

Change-Id: Id23078c6acea549a52fc687779bb55d715b55c16
Reviewed-on: https://code.wireshark.org/review/14719
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-04-03 22:21:29 +00:00
Guy Harris a952c7c6bd Include json.h with quotes, not angle brackets.
Change-Id: I9fdb38ca724ec1a76126a956c7f7b07fd4c1ddb0
Reviewed-on: https://code.wireshark.org/review/14798
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-04-03 17:29:56 +00:00
Guy Harris 8d9853bae7 Use quotes, not angle brackets, for wtap-int.h and file_wrappers.h.
This is consistent with what the rest of the files do, and doesn't
require that the compiler explicitly be told to treat the current
directory as an include directory.

Change-Id: Iefaedd2acc936f45d5095546f8dea7167d2e88c8
Reviewed-on: https://code.wireshark.org/review/14797
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-04-03 17:15:21 +00:00
Jaap Keuter ee9858f347 Don't deref before NULL check on pointer (CID-1358044)
When the state pointer is NULL it's defensively coded against by a
NULL pointer check. Variable initialization before should then not
dereference that pointer.

Change-Id: I0ed09e2f22be5651324f43fc3fd339d2f95684c0
Reviewed-on: https://code.wireshark.org/review/14776
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-04-03 16:23:44 +00:00
Guy Harris e63a3f5d81 Don't use <wtap.h> to refer to the main libwiretap header file.
Either use "wtap.h", if it's only for files in the wiretap directory, or
<wiretap/wtap.h>, if it's also a header that stuff outside libwiretap
can include.

Change-Id: If1c71b3dae9a3c0d64661ae1734f925319e447d1
Reviewed-on: https://code.wireshark.org/review/14788
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-04-03 14:29:25 +00:00