Commit Graph

43 Commits

Author SHA1 Message Date
Guy Harris e5951765d8 Dissector names are not protocol names.
A given protocol's packet format may depend, for example, on which
lower-level protocol is transporting the protocol in question.  For
example, protocols that run atop both byte-stream protocols such as TCP
and TLS, and packet-oriented protocols such as UDP or DTLS, might begin
the packet with a length when running atop a byte-stream protocol, to
indicate where this packet ends and the next packet begins in the byte
stream, but not do so when running atop a packet-oriented protocol.

Dissectors can handle this in various ways:

For example, the dissector could attempt to determine the protocol over
which the packet was transported.

Unfortunately, many of those mechanisms do so by fetching data from the
packet_info structure, and many items in that structure act as global
variables, so that, for example, if there are two two PDUs for protocol
A inside a TCP segment, and the first protocol for PDU A contains a PDU
for protocol B, and protocol B's dissector, or a dissector it calls,
modifies the information in the packet_info structure so that it no
longer indicates that the parent protocol is TCP, the second PDU for
protocol A might not be correctly dissected.

Another such mechanism is to query the previous element in the layers
structure of the packet_info structure, which is a list of protocol IDs.

Unfortunately, that is not a list of earlier protocols in the protocol
stack, it's a list of earlier protocols in the dissection, which means
that, in the above example, when the second PDU for protocol A is
dissected, the list is {...,TCP,A,B,...,A}, which means that the
previous element in the list is not TCP, so, again, the second PDU for
protocol A will not be correctly dissected.

An alternative is to have multiple dissectors for the same protocol,
with the part of the protocol that's independent of the protocol
transporting the PDU being dissected by common code.  Protocol B might
have an "over a byte-stream transport" dissector and an "over a packet
transport" dissector, with the first dissector being registered for use
over TCP and TLS and the other dissector being registered for use over
packet protocols.  This mechanism, unlike the other mechanisms, is not
dependent on information in the packet_info structure that might be
affected by dissectors other than the one for the protocol that
transports protocol B.

Furthermore, in a LINKTYPE_WIRESHARK_UPPER_PDU pcap or pcapng packet for
protocol B, there might not be any information to indicate the protocol
that transports protocol B, so there would have to be separate
dissectors for protocol B, with separate names, so that a tag giving the
protocol name would differ for B-over-byte-stream and B-over-packets.

So:

We rename EXP_PDU_TAG_PROTO_NAME and EXP_PDU_TAG_HEUR_PROTO_NAME to
EXP_PDU_TAG_DISSECTOR_NAME and EXP_PDU_TAG_HEUR_DISSECTOR_NAME, to
emphasize that they are *not* protocol names, they are dissector names
(which has always been the case - if there's a protocol with that name,
but no dissector with that name, Wireshark will not be able to handle
the packet, as it will try to look up a dissector given that name and
fail).

We fix that exported PDU dissector to refer to those tags as dissector
names, not protocol names.

We update documentation to refer to them as DISSECTOR_NAME tags, not
PROTO_NAME tags.  (If there is any documentation for this outside the
Wireshark source, it should be updated as well.)

We add comments for calls to dissector_handle_get_dissector_name() where
the dissector name is shown to the user, to indicate that it might be
that the protocol name should be used.

We update the TLS and DTLS dissectors to show the encapsulated protocol
as the string returned by dissector_handle_get_long_name(); as the
default is "Application Data", it appeaers that a descriptive name,
rather than a short API name, should be used.  (We continue to use the
dissector name in debugging messages, to indicate which dissector was
called.)
2022-09-10 22:37:11 -07:00
John Thacker cbf76ea22f Export PDU: Allow native encapsulations / strip headers
Allow export PDU taps to be registered with a wiretap encapsulation
instead of always using WTAP_ENCAP_WIRESHARK_UPPER_PDU. This allows
creating normal capture files that aren't tied to wireshark without
having to do a "editcap -C -L -T", as well as creating files in
formats other than pcapng and pcap with tshark.

Provide a couple sample implementations in Ethernet (WTAP_ENCAP_ETHERNET)
and IP (v4 and v6, WTAP_ENCAP_RAW_IP) that are the most common use cases.
(I can imagine a few others; WTAP_ENCAP_MPEG_2_TS could probably be
useful, for example.) Fixes #15141
2022-02-25 20:29:16 -05:00
Moshe Kaplan 1c3a9af869 Add files with WS_DLL_PUBLIC to Doxygen
Add @file markers for most files that
contain functions exported with
WS_DLL_PUBLIC so that Doxygen will
generate documentation for them.
2021-11-29 21:27:45 +00:00
Guy Harris 4e80643cc0 Move LINKTYPE_WIRESHARK_UPPER_PDU definitions to a separate header.
Have wsutil/exported_pdu_tlvs.h define the LINKTYPE_WIRESHARK_UPPER_PDU
TLV type and length values, as well as the port type values written to
files in EXP_PDU_TAG_PORT_TYPE TLVs.

Update the comment that describes the LINKTYPE_WIRESHARK_UPPER_PDU TLVs
to more completely and correctly reflect reality (it was moved from
epan/exported_pdu.h to wsutil/exported_pdu_tlvs.h).

Rename those port type values from OLD_PT_ to EXP_PDU_PT_; there is
nothing "old" about them - yes, they originally had the same numerical
values as the PT_ enum values in libwireshark, but that's no longer the
case, and the two are now defined independently.  Rename routines that
map between libwireshark PT_ values and EXP_PDU_PT_ values to remove
"old" from the name while we're at it.

Don't include epan/exported_pdu.h if we only need the
LINKTYPE_WIRESHARK_UPPER_PDU definitions - just include
wsutil/exported_pdu_tlvs.h.

In extcap/udpdump.c, include wsutil/exported_pdu_tlvs.h rather than
defining the TLV types ourselves.
2021-08-20 02:18:19 -07:00
John Thacker d648f74550 exported PDU: Fix comment
It's P2P_DIR_RECV not P2P_DIR_RCVD
2021-06-02 01:09:33 -04:00
Stig Bjørlykke 6f72d738de exported_pdu: Add a new TAG for p2p_dir
Add a new exported_pdu TAG to specify pinfo->p2p_dir.
2021-05-28 12:43:21 +00:00
Dario Lombardo 55c68ee69c epan: use SPDX indentifiers.
Skipping dissectors dir for now.

Change-Id: I717b66bfbc7cc81b83f8c2cbc011fcad643796aa
Reviewed-on: https://code.wireshark.org/review/25694
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-02-08 19:29:45 +00:00
Guy Harris 8aa14236f8 Have the frame_tvbuff.c routines not use the global cfile.
Have the routines that create them take a pointer to a struct
packet_provider_data, store that in the tvbuff data, and use it to get
the wtap from which packets are being read.

While we're at it, don't include globals.h in any header files, and
include it in source files iff the source file actually uses cfile.  Add
whatever includes that requires.

Change-Id: I9f1ee391f951dc427ff62c80f67aa4877a37c229
Reviewed-on: https://code.wireshark.org/review/24733
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-12-08 08:31:41 +00:00
Michael Mann 765a67b68a "Hardcode" the port types used by Export PDU functionality
The "internal" port type has been serialized by export PDU functionality
and nettrace_3gpp_32_423 wiretap.  To better support "endpoint" functionality
the port types will be removed/updated and that changes the implicit values
from the port_type enum.

Take a snapshot of the current port_type values and use those specific values
when reading/writing export PDU data and provide conversion functions that can
be modified when port_types are removed.  Do the same for nettrace_3gpp_32_423
wiretap.

Change-Id: I770bd0cab22e84f3cf49032fc86c5927bf85263f
Reviewed-on: https://code.wireshark.org/review/24169
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-10-29 19:55:24 +00:00
João Valverde d0a91b27f2 plugins: config.h must not be included by public headers
For a sane plugin build environment. Include config.h as the first
header in the .c file instead.

Fix by moving required compiler attribute macros to a new
"ws_attributes.h" API header.

Change-Id: I34f58a927f68c1a0e59686c14d214825149749e1
Reviewed-on: https://code.wireshark.org/review/23400
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>
2017-09-06 08:10:56 +00:00
Dario Lombardo baf2612d9e exported_pdu: add cleanup function.
Change-Id: Iafc9f1c4b2a0210d8098b37eefc095e740182258
Reviewed-on: https://code.wireshark.org/review/19648
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-01-17 03:26:04 +00:00
Michael Mann edcc2f019e Add OSI Layer 4 to exported PDU to handle TCP and UDP payloads.
This allows for much easier anonymized captures for protocols running
atop TCP/UDP.

Added support for "TCP dissector data" tag within export PDU (34) so that
the tcpinfo struct that TCP dissector normally passes to its subdissectors
can be saved.

Change-Id: Icd63c049162332e5bcb2720159e5cf8aac893788
Reviewed-on: https://code.wireshark.org/review/16285
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-08-01 15:19:59 +00:00
Alexis La Goutte f860e8de52 exported_pdu(.h): Fix warning: parameter 'tag_type.' not found in the function declaration [-Wdocumentation]
Change-Id: Ic93914a7f526b645bc21a5c9c5f2fa0bf988c27e
Reviewed-on: https://code.wireshark.org/review/16230
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>
2016-07-01 00:46:54 +00:00
Michael Mann be12a252dd Provide new interface for Export PDU.
Rather than have a bitmask for each desired field, have a dissector
provide a list of structures that represent data that goes into
the PDU.

Change-Id: I125190cbaee489ebffb7d9f5d8bc6f3be2d06353
Reviewed-on: https://code.wireshark.org/review/16122
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2016-06-29 18:53:46 +00:00
Michael Mann 04b82a7dc9 Convert AT_SS7PC to a "dissector address type"
The formatting of the address type is determined by a preference in
packet-mtp3.c, so just make MTP3 register the address type.
Use address_type_get_by_name in other dissectors (and export_pdu)
to use the address type.

Change-Id: Ifb32d7de27aeaa23cee8e803e25ffb3c905547b5
Reviewed-on: https://code.wireshark.org/review/15856
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-13 17:06:38 +00:00
AndersBroman 4b4c7a76c3 [Nettrace] Add parsing of some HSS records.
Change-Id: I7c2f6ebdb20f90533ee008e1b4557ef27d4672dc
Reviewed-on: https://code.wireshark.org/review/14708
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-03-31 10:59:06 +00:00
Pascal Quantin 2ce6559b2a Fix a typo
Change-Id: I206c3f8ec860e92dce3f43b05f6695347d15398a
Reviewed-on: https://code.wireshark.org/review/14706
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2016-03-30 14:33:01 +00:00
AndersBroman 7b406ea3ea [Exported PDU] Add the abillity to use dissector tables from the file.
Change-Id: I51ac8ce56641cf6eeda18c2a3f6d6952d3126415
Reviewed-on: https://code.wireshark.org/review/14693
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-03-29 21:25:39 +00:00
AndersBroman 6f6ab7be19 [Nettrace] Add parsing of IP addresses and ports.
Change-Id: I4e2988edd9b5f75f7b104c8daddd1510bf1fc722
Reviewed-on: https://code.wireshark.org/review/11209
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-10-23 07:14:18 +00:00
Pascal Quantin 79774329d7 Simply code for export of PDUs coming from heuristic dissectors
Let's use the newly introduced find_heur_dissector_by_unique_short_name() function

Change-Id: I5781b9b2f1ab679da07e97755b71840b4b3a9361
Reviewed-on: https://code.wireshark.org/review/9645
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>
2015-07-15 18:30:57 +00:00
Pascal Quantin cdc7d25004 Add ability to export PDUs for heuristic dissectors also
Change-Id: I1bf1aa9794f9b4f106edffd4986fc0b1014522fa
Reviewed-on: https://code.wireshark.org/review/9099
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2015-06-25 00:10:13 +00:00
Graham Bloice 2fde6ffc8f Fix out of tree builds
Stop out of tree builds picking up the in-tree version and config.h

Change-Id: Icadc46cab66db72af2d475eac31b28d0ca10df90
Reviewed-on: https://code.wireshark.org/review/8204
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>
2015-05-25 10:42:59 +00:00
Pascal Quantin bcff3c57cc Add the ability to dynamically add a new protocol to export PDU dialog box
Change-Id: I83012cc963d514982e40010e837e11a6fcf1bc3e
Reviewed-on: https://code.wireshark.org/review/2423
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-06-19 06:48:32 +00:00
Pascal Quantin ad33357e62 Exported PDU: add support for more than 32 tags
Change-Id: Idc9f105164919827a8a81c88b5a56de4fa25df0b
Reviewed-on: https://code.wireshark.org/review/1197
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-04-18 20:15:04 +00:00
Jeff Morriss 38b8d32083 Mark the exported_pdu tags as stable (before the next release).
These tag values have been pretty stable for a while now; mark them as
stable and insert a warning (copied directly from tcpdump.org) to ensure
that people don't start using tags without registering them.

Change-Id: I9d7b9cd0daaff7eded606506d540c2555d78c417
Reviewed-on: https://code.wireshark.org/review/1193
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-04-18 19:01:47 +00:00
Pascal Quantin 488f2a0974 Exported PDU: add support for data length on the wire
Change-Id: Iff14ec4d0297ec85f3597b33871fb0ab5256a597
Reviewed-on: https://code.wireshark.org/review/728
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-19 05:13:30 +00:00
Alexis La Goutte 296591399f Remove all $Id$ from top of file
(Using sed : sed -i '/^ \* \$Id\$/,+1 d')

Fix manually some typo (in export_object_dicom.c and crc16-plain.c)

Change-Id: I4c1ae68d1c4afeace8cb195b53c715cf9e1227a8
Reviewed-on: https://code.wireshark.org/review/497
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-04 14:27:33 +00:00
Bill Meier 11b5c15fdb Remove trailing whitespace
Change-Id: I8116f63ff88687c8db3fd6e8e23b22ab2f759af0
Reviewed-on: https://code.wireshark.org/review/385
Reviewed-by: Bill Meier <wmeier@newsguy.com>
Tested-by: Bill Meier <wmeier@newsguy.com>
2014-02-25 20:46:49 +00:00
Michal Labedzki ff0468f6d3 Add Logcat to Exported PDU
Logcat can be exported from ADB over USB or ADB over TCP where can occur
multiple Logcat PDUs in one frame.

Change-Id: I290fa131e5600c62357e5be4e76096ea5c35364b
Reviewed-on: https://code.wireshark.org/review/234
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2014-02-18 11:14:01 +00:00
Michael Mann eabaddaca9 Remove ethertype, mpls_label and ppids from packet_info structure.
The information was converted to "proto" data within their respective dissectors strictly for use in "Decode As".

svn path=/trunk/; revision=53489
2013-11-21 20:08:20 +00:00
Balint Reczey 49343d633c Fix ABI check error for libwireshark
svn path=/trunk/; revision=52630
2013-10-15 20:14:47 +00:00
Martin Kaiser 174fa28a31 support exporting decrypted DVB-CI/CI+ SAC messages
using the new export PDU mechanism

svn path=/trunk/; revision=51019
2013-07-29 20:38:20 +00:00
Pascal Quantin 014e2deec6 Add export of SS7 OPC/DPC
svn path=/trunk/; revision=50060
2013-06-19 21:49:12 +00:00
Pascal Quantin d09ffee44e Add ability to export decrypted IPsec PDUs
svn path=/trunk/; revision=50022
2013-06-18 23:01:46 +00:00
Pascal Quantin 24623bdff3 More PDU export work:
- add automatic export of port type when exporting a source / destination port
- add export of SCTP PPID (usefulness to be checked)
- fix some field size

svn path=/trunk/; revision=49989
2013-06-17 21:54:21 +00:00
Anders Broman 91c0a93914 Edit comments
svn path=/trunk/; revision=49569
2013-05-24 22:38:53 +00:00
Anders Broman 6a3a3c228c Make preparation to select which level tap is to be used.
svn path=/trunk/; revision=49446
2013-05-20 17:48:09 +00:00
Anders Broman 8e509279b8 Add a tag for original frame number.
svn path=/trunk/; revision=49298
2013-05-14 19:57:19 +00:00
Anders Broman ef13d981bb Add comments on the experimental state of this feature.
svn path=/trunk/; revision=49285
2013-05-14 06:07:26 +00:00
Pascal Quantin 914099a5a9 Fix a few bugs related to PDU export feature:
- tag length is wrong if proto name was a multiple of 4 bytes
- tag length is wrong in case no IP address is available in packet_info structwhile tag is requested
- endianness issue when dumping the port number
- overlapping tag IPv4 Dst address and IPv6 Src address
- do not call dissector when it is not found
- typo errors
Enhancements:
- add a subtree for tag content
- display IPv6 Src/Dst address

svn path=/trunk/; revision=49232
2013-05-10 13:13:50 +00:00
Anders Broman 05ed1f5199 Add missing files.
svn path=/trunk/; revision=49185
2013-05-06 16:31:29 +00:00
Anders Broman 6409756fb8 55:1: error: "/*" within comment
svn path=/trunk/; revision=49178
2013-05-05 19:49:50 +00:00
Anders Broman 44f48d0464 Add the abillity to export PDU:s to file using a USER_DLT adding meta data before the actual protocol PDU. Some meta tags makes it possible for the dissector of the user DLT to call the correct PDU dissector.
This is prof-of-concept needs a bit of cleanup.

svn path=/trunk/; revision=49176
2013-05-05 19:36:53 +00:00