Commit Graph

30 Commits

Author SHA1 Message Date
Guy Harris 32923b94a1 Don't crash if an IDB resolution value is too high.
When dissecting an if_tsresol option in an IDB, calculate the resolution
from the base and the offset.  If the result overflows, mark it as an
overflow; otherwise, mark it with the units for more values than 1
microsecond.  Store the calculated resolution, which we initialize to
the default of 1 microsecond.

When displaying time stamps in blocks, use the calculated resolution,
rather than re-calculating it.  If it's 0, it means the resolution is
too high, so don't calculate it and end up dividing by zero.

Bug: 14402
Change-Id: Idc34ededb4f7250b3604b14d4468c32f6592793f
Reviewed-on: https://code.wireshark.org/review/25673
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-02-07 22:08:32 +00:00
Jim Young 6d5fcb7378 MIME based pcapng dissector: Fixup apparent copy-and-pasteos.
The MIME based pcapng dissector incorrectly displayed the EPB
Flags option's link layer error bits.

Change-Id: Ia14eec39e2a9c4432e6b3d1c0cee718ad2da1cac
Reviewed-on: https://code.wireshark.org/review/23279
Petri-Dish: Jim Young <jim.young.ws@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-08-29 10:44:44 +00:00
Peter Wu d7f2a2b1e0 file-pcapng: fix capture filter dissection
The pcapng spec[1] suggests that the first octet marks the filter type,
but it is not clear whether this other types are implemented. Just skip
over the byte for now.

 [1]: https://github.com/pcapng/pcapng/blob/c0dd7a7391/draft-tuexen-opsawg-pcapng.xml#L1083

Change-Id: I272dac55ea9ca3798e1fea45ce92023f7aa82564
Reviewed-on: https://code.wireshark.org/review/22043
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2017-06-13 15:27:16 +00:00
Stig Bjørlykke 732d54e6e7 pcapng: Align code name and hf name.
Use common name for "Number of Received Packets".

Change-Id: Ib57b142e8fc5c85a03c5622c264ce1d7e113f795
Reviewed-on: https://code.wireshark.org/review/20795
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2017-03-30 09:10:34 +00:00
Jim Young f7724c319e file-pcapng: Undo some unnecessary changes.
In commit 35cf66d8bd four existing
objects were renamed for no good reason.  Restore original names.
Also remove unnessary Darwin options from packet block options
and remove leftover include.

Change-Id: I9dfa642639af13e73b519438b82b1b2a77546c7c
Reviewed-on: https://code.wireshark.org/review/20171
Petri-Dish: Jim Young <jim.young.ws@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Jim Young <jim.young.ws@gmail.com>
2017-02-18 23:15:42 +00:00
Guy Harris 19b97fbfb0 Why you only get 16 bytes of process name.
Change-Id: I719706e04668aa50ed0eb6184681943718b67f00
Reviewed-on: https://code.wireshark.org/review/20164
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-02-18 08:42:34 +00:00
Jim Young 35cf66d8bd file-pcapng: Add support for inspecting Apple's PKTAP enhanced pcapng files
This patch augments the MIME based file-pcapng dissector to allow one to
more easily examine pcapng blocks that contain Darwin Process Information.

With this patch one can dissect and inspect, albeit as a MIME object, the
Darwin process information elements contained within an Apple augmented
pcapng file:

$ wireshark -X read_format:'MIME Files Format' -r bug12587.pktap.pcapng

$ tshark -V -X read_format:'MIME Files Format' -r bug12587.pktap.pcapng | egrep '^    Block:|Darwin .* =' | less

Apple's macOS provides an enhanced tcpdump with a pktap interface option
that supports the collection, display and storing of Darwin process and/or
service class information related to each captured packet. Using Apple's
pktap interface during a live capture the process information may be
revealed using Apple's tcpdump -k [metadata] option.

Apple's tcpdump -k option augments tcpdump's standard report with an
additional parenthesized () set of information inserted after the packet
timestamp. If the capture file actually contains Darwin process
information, Apple's tcpdump -k could include the interface name (or
interface id), process id, process name, process_uuid, service, and/or
direction for each packet depending on the value of the -k's [metadata]
argument provided (if any).

If the Apple tcpdump trace is captured to disk, the Darwin based process
and service information is saved in pcapng format augmented with several
new Enhanced Packet Block options (32779, 32780, 32781) along with a new
block type (0x80000001) called here a Darwin Process Event Block (DPEB).
The Darwin Process Event Block is used in a manner similar to a pcapng
IDB in that it contains process event information that is referenced by
later EPB's via the EPB options Darwin DPEB ID (32769) and Darwin EDPEB
ID (32871). EPBs may also include the Darwin Service Class option (32770)
which includes a numeric value that maps to a mnemonic service class.

A PKTAP enhanced pcapng file can later be read back in with Apple's tcpdump
along and the help of its -k option to display the original Darwin Process
Information. Packets collected using Apple's remote virtual interface
(rvictl)[1] from iOS devices can also contain Darwin Process Information.

Note: This is a first step to help determine what will be necessary to
eventually display any available Darwin Process Information within
the Frame tree when an Apple PKTAP enhanced pcapng file is opened
naturally in Wireshark and not as a MIME object.

[1] https://developer.apple.com/library/content/qa/qa1176/_index.html

Ping-Bug: 13096
Ping-Bug: 12587
Change-Id: I180e661dab0b0096a711603b53270105390d05e2
Reviewed-on: https://code.wireshark.org/review/20157
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-02-18 07:13:23 +00:00
Guy Harris 7cd6906056 Rename tvb_new_subset() to tvb_new_subset_length_caplen().
This emphasizes that there is no such thing as *the* routine to
construct a subset tvbuff; you need to choose one of
tvb_new_subset_remaining() (if you want a new tvbuff that contains
everything past a certain point in an existing tvbuff),
tvb_new_subset_length() (if you want a subset that contains everything
past a certain point, for some number of bytes, in an existing tvbuff),
and tvb_new_subset_length_caplen() (for all other cases).

Many of the calls to tvb_new_subset_length_caplen() should really be
calling one of the other routines; that's the next step.  (This also
makes it easier to find the calls that need fixing.)

Change-Id: Ieb3d676d8cda535451c119487d7cd3b559221f2b
Reviewed-on: https://code.wireshark.org/review/19597
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-01-10 06:19:37 +00:00
Michael Mann 0600865a12 file-pcapng.c: Apply parenthesis to fix build warnings
Change-Id: I35d180e7aa040c94ca80a49e7d2132dd76e46aaf
Reviewed-on: https://code.wireshark.org/review/16393
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-07-12 18:30:43 +00:00
Michael Mann 2ab4155794 tvb_get_string_enc + proto_tree_add_item = proto_tree_add_item_ret_string
Also some other tricks to remove unnecessary tvb_get_string_enc calls.

Change-Id: I2f40d9175b6c0bb0b1364b4089bfaa287edf0914
Reviewed-on: https://code.wireshark.org/review/16158
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>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2016-06-27 15:20:06 +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
Michael Mann 9bcac48403 Manually add protocol dependencies derived from find_dissector.
Started by grepping call_dissector_with_data, call_dissector_only and call_dissector and traced the handles passed into them to a find_dissector within the dissector.  Then replaced find_dissector with find_dissector_add_dependency and added the protocol id from the dissector.
"data" dissector was not considered to be a dependency.

Change-Id: I15d0d77301306587ef8e7af5876e74231816890d
Reviewed-on: https://code.wireshark.org/review/14509
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-03-20 12:48:48 +00:00
Alexis La Goutte 91613a04db pcapng (dissector): fix 'pcapng.options.option.data.ipv4' exists multiple times with NOT compatible types: FT_IPv6 and FT_IPv4
Change-Id: I9f6e713a50e0c73d0ecc7a66b62dffe270d4a35f
Reviewed-on: https://code.wireshark.org/review/13678
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-02-03 13:03:50 +00:00
Guy Harris bc5a0374bf Add the packet number to the packet_info structure, and use it.
That removes most of the uses of the frame number field in the
frame_data structure.

Change-Id: Ie22e4533e87f8360d7c0a61ca6ffb796cc233f22
Reviewed-on: https://code.wireshark.org/review/13509
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-01-24 03:41:28 +00:00
Guy Harris 9141bd9700 Add more fields to packet_info structure and use them.
Add fields for the absolute time stamp (and another field for a presence
flag for the absolute time stamp) and the packet encapsulation for the
packet.

This lets us remove the field for the packet encapsulation in the
frame_data structure; do so.

Change-Id: Ifb910a9a192414e2a53086f3f7b97f39ed36aa39
Reviewed-on: https://code.wireshark.org/review/13499
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-01-23 03:50:58 +00:00
Guy Harris e406703c5f Fix handling of the byte order magic number.
Just treat it as an array of bytes.  When checking for whether it's a
pcapng file, also determine whether it's big-endian or little-endian.
Note that reading it in *host* byte order will tell you whether it's in
your byte order or byte-swapped; you have to know your byte order to
know whether that means little-endian or big-endian.

Have a #define for the byte-order magic number size, as all byte order
magic number values must be that size, and use that as the size of the
magic-number arrays.

Also use a #define for the SHB block type magic number.

Get rid of a now-unused expert info.  (If the magic number isn't
something we recognize, we don't treat the file as a pcap file, so it
can never be "unknown".)

Change-Id: Ic74cceac17d1490eb70a28f67cb4dbb512e031ac
Reviewed-on: https://code.wireshark.org/review/13494
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-01-23 01:15:54 +00:00
Michael Mann 31a54708f4 new_register_dissector -> register_dissector for dissector directory.
Change-Id: Ie39ef054a4a942687bd079f3a4d8c2cc55d5f22c
Reviewed-on: https://code.wireshark.org/review/12485
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-12-09 12:38:06 +00:00
Guy Harris 91f4e3b73d Have a separate dissector for pcap/pcapng-format packet data.
Put that dissector into its own file, and get handles for it from the
pcap and pcapng file dissectors.  Put the value_string of pcap/pcapng
LINKTYPE_ values there, and have the pcap and pcapng file dissectors
import it.

Expand that table to include all LINKTYPE_ values in the current
libpcap.

Change-Id: I9397035efa5711e8a18a26e056d3b54494fd3148
Reviewed-on: https://code.wireshark.org/review/12000
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-11-21 02:52:57 +00:00
Michal Labedzki fef4714e72 File-format: Add ISO_14443 linktype for PCAP/PCAPNG
Assign numbers for LinkTypes on webpage
http://www.tcpdump.org/linktypes.html were changed, so update
it for file dissector for PCAP/PCAPNG.

Change-Id: Icb52c2a8f19bd056723de155700b83497d5fded4
Reviewed-on: https://code.wireshark.org/review/11983
Petri-Dish: Michal Labedzki <michal.labedzki@tieto.com>
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michal Labedzki <michal.labedzki@tieto.com>
2015-11-20 16:02:43 +00:00
João Valverde 3df2333155 Remaining ADDRESS macro to address function conversions
Change-Id: I8bc9af431e70243b05f4f0ce8c2b8ee451383788
Reviewed-on: https://code.wireshark.org/review/11463
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>
2015-11-03 12:20:34 +00:00
Guy Harris 4ba522537a Point to GitHub for the pcapng specification.
Change-Id: I33faa41e8b0f36ee49d29fe391feafd94d0a7e80
Reviewed-on: https://code.wireshark.org/review/10245
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-08-25 01:47:26 +00:00
Pascal Quantin eeafab579e file-pcapng: always set pinfo->fd->num before calling next layer dissectors/file-pcapng
Also fix an off by 1 error for EPB case

Change-Id: I895d82a58ec02c577dcaa67a97d456b42460b947
Reviewed-on: https://code.wireshark.org/review/10149
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2015-08-21 08:34:28 +00:00
Pascal Quantin bc8b94d571 file-pcapng: differentiate captured length and reported length when calling next dissector and catch bound errors
Otherwise dissection will fail when analyzing a capture with a snap length set

Change-Id: If6714364efffdd1fbf88c947743929a71f75c663
Reviewed-on: https://code.wireshark.org/review/10135
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>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-08-20 11:43:56 +00:00
Pascal Quantin 2046368574 file-pcapng: fix dissection of options in blocks
- fix the loop logic
- flags in EPB include link-layer-dependent errors

Change-Id: Iae0b4869b556abbf3c14f3b865d0f23cee182c84
Reviewed-on: https://code.wireshark.org/review/10132
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2015-08-20 10:04:13 +00:00
Pascal Quantin d9dd323d4f file-pcapng: remove useless hf_pcapng_timestamp_data entry
Change-Id: I82b2d4e4b0be8179103b827e0d11a0d8b10e1374
Reviewed-on: https://code.wireshark.org/review/10133
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-08-19 21:00:37 +00:00
Alexis La Goutte 6ed3e080e9 pcapng(file): fix duplicate break
Change-Id: Ife7170c050402ab94d368acc6c233714be764824
Reviewed-on: https://code.wireshark.org/review/10114
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-08-18 19:20:03 +00:00
Guy Harris 4abec47c05 Clean up handling of time stamps.
Use common code for all time stamps, so it's handled the same for the
Packet Block, Enhanced Packet Block, and Interface Statistics Block.

Show the high and low parts of the time stamp as fields; file dissectors
should show the raw file details.  Mark the calculated time stamp as
generated, as it's not the raw file data.

Get the 64-bit time stamp by shifting the high part left 32 bits and
ORing in the low part; no need to play games with unions and byte order

Change-Id: I19b2c3227a3ca1e93ec653f279136aa18687581f
Reviewed-on: https://code.wireshark.org/review/10116
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-08-18 19:17:56 +00:00
Guy Harris ea7cf08368 Cast away 64 -> 32 narrowing complaints.
"secs" in an nstime_t is a time_t; cast the calculated seconds portion
to time_t.

Change-Id: Ieaad4c18bb21384a5781f50eadd3a537b414a369
Reviewed-on: https://code.wireshark.org/review/10113
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-08-18 18:52:01 +00:00
AndersBroman a3c175a823 Add casts to passify buildboot.
Change-Id: I8aa4695f1f8dfdfc5bfcd4fb4f36e1b332581d5a
Reviewed-on: https://code.wireshark.org/review/10106
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-08-18 14:50:58 +00:00
Michal Labedzki dd57c6bf38 File-format: Add PCAP and PCAPNG dissectors
They have educational values and can be used to debugging some issues.
Now Wireshark can open three files (BTSNOOP, PCAP, PCAPNG)
in two modes: Capture (Traditional) and File-Format.

Change-Id: I833b2464d11864f170923dc989a1925d3d217943
Reviewed-on: https://code.wireshark.org/review/10089
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-08-18 12:52:03 +00:00