Commit Graph

75 Commits

Author SHA1 Message Date
Francois-Xavier Le Bail
bdf7eacfa1 IPFC: Update the link-layer dissector to a void function
Moreover:
Remove trailing "_if" from the protocol name.
2020-08-02 22:11:51 +02:00
Francois-Xavier Le Bail
941452b132 Token Ring: Update the link-layer dissector to a void function
Moreover:
Remove trailing "_if" from the protocol name.
2020-08-02 22:11:51 +02:00
Francois-Xavier Le Bail
8cda025aed SLL: Update the link-layer dissectors to void functions
Moreover:
Fix two probably copy & paste errors (s/SLL_HDR_LEN/SLL2_HDR_LEN/).
Remove trailing "_if" from the protocol name.
2020-08-02 22:10:04 +02:00
Francois-Xavier Le Bail
770b67da76 FDDI: Update the link-layer dissector to a void function
Moreover:
Remove trailing "_if" from the protocol name.
2020-08-02 12:03:39 +02:00
Francois-Xavier Le Bail
e2e1906cff CIP: Update the link-layer dissector to a void function
Moreover:
Remove trailing "_if" from the protocol name.
2020-08-02 11:50:46 +02:00
Francois-Xavier Le Bail
006004fdda IEEE 802.15.4: Update the link-layer dissectors to void functions 2020-08-02 11:24:45 +02:00
Francois-Xavier Le Bail
dc8a38c289 IEEE 802.11: Update the link-layer dissectors to void functions 2020-08-02 10:35:09 +02:00
Francois-Xavier Le Bail
cab4799ee5 PPPoE: Update the link-layer dissector to a void function
Moreover:
Add a length check.
Fix a return.
Use nd_print_trunc().
Remove trailing "_if" from the protocol name.
Style.
2020-07-31 20:40:07 +02:00
Francois-Xavier Le Bail
962de080b0 Juniper: Update the link-layer dissectors to void functions 2020-07-27 19:20:02 +02:00
Francois-Xavier Le Bail
692e9d44a5 vsock: Update the link-layer dissector to a void function
Moreover:
Rename some variables/parameters from 'len' to 'caplen' because
they store the capture length.
2020-07-27 09:06:59 +02:00
Francois-Xavier Le Bail
7b96701040 IPoIB: Update the link-layer dissector to a void function 2020-07-25 16:55:45 +02:00
Francois-Xavier Le Bail
81dbf4a0b0 Update more link-layer dissectors to void functions
brcm_tag_if_print()
brcm_tag_prepend_if_print()
dsa_if_print()
edsa_if_print()
ether_if_print()
netanalyzer_if_print()
netanalyzer_transparent_if_print()

Update ether_print(), ether_common_print() and ether_switch_tag_print()
to void functions.

Add a flag parameter to ether_print(), ether_common_print() and
ether_switch_tag_print() to increment the link-layer header length field
of the netdissect_options when needed.
The calls use TRUE when the return value of the funtions was used.
The calls with FALSE avoid increments when the calls are nested.

Moreover:
Remove trailing "_if" from some protocol names.
2020-07-15 09:18:35 +02:00
Francois-Xavier Le Bail
96c60029b3 Rename a field of the netdissect_options structure 2020-07-14 17:35:57 +02:00
Francois-Xavier Le Bail
25687e1a31 Print packets for unsupported link-layer protocols in hexadecimal/ASCII
This avoids to get only:
tcpdump: packet printing is not supported for link type XYZ: use -w

The default printing is like:
18:45:52.723872 UNSUPPORTED
        0x0000:  001f 0000 0540 6078 725d 586d 4d66 4671  .....@`xr]XmMfFq
        0x0010:  6d58 4d5c 7159 5f71 565c 556c 4e71 7171  mXM\qY_qV\UlNqqq
        0x0020:  7171 7171 7171 7171 7171 7171 7171 5180  qqqqqqqqqqqqqqQ.
        0x0030:  7f7f                                     ..
18:45:52.755995 UNSUPPORTED
        0x0000:  001f 0000 0540 6043 7851 807f 7f         .....@`CxQ...
        [...]
2020-05-10 11:05:59 +02:00
Francois-Xavier Le Bail
5b52e5fa19 NFLOG: Update the link-layer dissector to a void function
Moreover:
Remove trailing "_if" from protocol name.
2020-05-04 16:14:14 +02:00
Francois-Xavier Le Bail
a881efab39 SLIP: Update the link-layer dissectors to void functions
Moreover:
Update the protocol names (sl_if -> slip and sl_bsdos_if -> slip_bsdos).
Update the output of some tests accordingly.
2020-04-30 15:18:16 +02:00
Francois-Xavier Le Bail
ddefbd82c9 ARCNET: Update the link-layer dissectors to void functions 2020-03-28 20:56:02 +01:00
Francois-Xavier Le Bail
a0d6dc5065 PKTAP: Update the link-layer dissector to a void function
Moreover:
Remove trailing "_if" from protocol name.
Update the output of a test accordingly.
2020-03-28 10:44:30 +01:00
Francois-Xavier Le Bail
a80bcdd550 PPI: Update the link-layer dissector to a void function
Moreover:
Merge ppi_if_print() and ppi_print() in one function.
Remove two useless ND_TCHECK_ tests (GET_ used).
Remove a no longer used 'trunc' label.
2020-03-28 08:50:00 +01:00
Francois-Xavier Le Bail
59cad18b62 IPNET: Update the link-layer dissector to a void function
Moreover:
Remove trailing "_if" from protocol name.
Remove a useless ND_TCHECK_1 test (GET_U_1 is used).
Remove a no longer used 'trunc' label.
2020-02-08 10:50:49 +01:00
Francois-Xavier Le Bail
c3f8e04764 ENC: Update the link-layer dissector to a void function
Moreover:
Remove trailing "_if" from protocol name.
Remove a no longer used 'out' label.
2020-02-07 20:36:41 +01:00
Francois-Xavier Le Bail
717095ab66 NULL/LOOP: Update the link-layer dissector to a void function
Moreover:
Remove trailing "_if" from protocol name.
Remove a useless ND_TCHECK_4 test (GET_HE_U_4 used).
Remove a no longer used 'trunc' label.
Use uint32_t type for family in null_hdr_print().
2020-02-07 20:36:34 +01:00
Francois-Xavier Le Bail
92a263b1b3 Raw IP: Update the link-layer dissector to a void function
Moreover:
Remove trailing "_if" from protocol name.
2020-02-07 20:36:30 +01:00
Francois-Xavier Le Bail
5cea888d12 SunATM DLPI: Update the link-layer dissector to a void function
Moreover:
Remove trailing "_if" from protocol name.
2020-02-07 20:36:26 +01:00
Francois-Xavier Le Bail
65577c9619 USB: Update the link-layer dissector to a void function
Moreover:
Remove trailing "_if" from protocol names.
2020-02-07 20:36:20 +01:00
Francois-Xavier Le Bail
337875c269 Symantec: Update the link-layer dissector to a void function
Moreover:
Remove trailing "_if" from protocol name.
2020-02-07 20:36:15 +01:00
Francois-Xavier Le Bail
c688c129ea Bluetooth: Update the link-layer dissector to a void function
Moreover:
Remove a useless ND_TCHECK_4 test (caplen tested before).
Remove a no longer used 'trunc' label.
2020-02-06 20:41:36 +01:00
Francois-Xavier Le Bail
09dbb915c2 Apple IPoIEEE1394: Update the link-layer dissector to a void function 2020-02-03 12:53:48 +01:00
Francois-Xavier Le Bail
757e793ca5 Apply the first step of the new way to update the link-layer header length
Currently the return value of link-layer dissectors is supposed to be
the length of the link-layer header, so that it can be skipped for -x
and -X.

If a link-layer dissector or a called function throws an exception, it
returns no value, so that length isn't available.

The goal is to change all the link-layer dissectors to be void functions
and dissectors should update a new field of the netdissect_options
structure "link-layer header length" rather than returning it as a value.

In this transition process, the link-layer dissectors will be moved, when
updated, from the uint_printers[] array (named before printers[]) to the
void_printers[] array.

In this transition process, a new field of the netdissect_options
structure, ndo_void_printer (TRUE/FALSE), set in the updated function
lookup_printer(), will permit to choose between the old and new way to
update the link-layer header length.
2020-02-02 14:15:24 +01:00
Guy Harris
b7b72b7c63 Treat the length field in an Ethernet header as such.
If we have an Ethernet packet where the last 2 octets of the header are
a length rather than an Ethernet type, and it's less than the remaining
length of the packet, shorten the length and captured length, update the
snapshot end.

Turn the buffer stack into a "packet information" stack, so that, if we
*do* update the snapshot end, we push the old end onto the stack, and
pop it off as soon as we're done dissecting the Ethernet packet, in case
there's more data in the packet after the Ethernet packet.

Use the stack when we use the IPv4 and IPv6 length fields as well.
2019-04-22 23:49:02 -07:00
alexandr nedvedicky - Sun Microsystems - Prague Czech Republic
ed2c22b7b4 InfiniBand support for tcpdump.
InfiniBand support for tcpdump.
This is an in-house patch. Sent upstream for potential inclusion in future
versions of tcpdump.

(also adding print-ipoib.c to CMakeLists.txt, asked by @guyharris)

(s/u_int16_t/uint16_t asked by @guyharris)
2019-04-18 01:15:03 +02:00
Vivien Didelot
43b5720499 Add support for decoding Marvell (E)DSA tags
Similarly to commit 6eaebfe adding support for the Broadcom tagging
format supported by the DSA kernel subsystem, this commit adds support
for the Marvell DSA and Ethertype DSA (EDSA) tagging formats.

Marvell DSA is a 4-byte proprietary tag placed between the ether source
address and the ether length/type. It contains data such as the switch
device and port IDs from which a frame came from, or to which port
a frame is targetting. It also contains additional FPri and IEEE bits.

EDSA is a 8-byte variant including a programmable ethertype, two null
bytes and a standard DSA tag.
2019-04-16 12:19:38 -04:00
Gerard Garcia
cda9bf8c5f Add printing support for vsockmon devices.
Print Linux 4.12 vsockmon captures:

  # modprobe vsockmon
  # ip link add type vsockmon
  # ip link set vsockmon0 up
  # tcpdump -i vsockmon0
  16:25:24.987917 VIRTIO 3.1025 > 2.1234 CONNECT, length 76
  16:25:24.987963 VIRTIO 2.1234 > 3.1025 CONNECT, length 76
  16:25:26.568271 VIRTIO 3.1025 > 2.1234 PAYLOAD, length 82
  16:25:26.568512 VIRTIO 2.1234 > 3.1025 CONTROL, length 76
  16:25:28.411335 VIRTIO 3.1025 > 2.1234 DISCONNECT, length 76
  16:25:28.411628 VIRTIO 2.1234 > 3.1025 DISCONNECT, length 76

For more information about vsock see:
http://wiki.qemu.org/Features/VirtioVsock
2019-04-16 15:12:13 +01:00
Guy Harris
6da51b3ec9 Introduce a buffer stack, and use it for ESP decryption.
If a dissector has to process its input - decryption, decompression,
etc. - rather than dissect the raw input, it should push the processed
input onto the buffer stack.  As soon as the dissection is done, the
stack should be popped, to free the buffer into which the processing was
done, and restore the "pointer to packet data" and "pointer to end of
packet data" members of the netdissect_options structure, so the code
can go back to dissecting the original data.

The stack will get everything popped off it when dissection is done.

Use this mechanism in the ESP decryption code rather than scribbling on
top of the input packet data.
2019-03-30 19:26:06 -07:00
Francois-Xavier Le Bail
176e182416 Apply the first step of the new way to fetch data with bounds checking
Add GET_{BE|HE|LE}_, GET_U_1, GET_S_1, GET_IPV4_TO_HOST_ORDER,
GET_IPV4_TO_NETWORK_ORDER macros and
get_{be|he|le}_, get_u_1, get_s_1, get_ipv4_to_host_order,
get_ipv4_to_network_order inline functions,
with setjmp/longjmp logic to do better and easier data fetch with
bounds checking.

Based on Guy Harris's idea and code.
2019-03-26 21:06:06 +01:00
James Ko
5cf83c2fce Handle DLT_IEEE802_15_4_TAP.
https://github.com/jkcko/ieee802.15.4-tap
2019-02-20 09:08:03 -08:00
Florian Fainelli
6eaebfe992 Add support for decoding Broadcom Ethernet switches tags
This adds support for decoding the Broadcom Ethernet switches tags which
are are 4byte in length and are located between the Ethernet MAC SA and
the Type/Length field (DSA_TAG_BRCM) as well as the pre-pended Broadcom
tag (DSA_TAG_BRCM_PREPEND) which are located in front of the standard
Ethernet header.

This makes use of the recently introduced ether_print_hdr_len() to allow
specifying the non-standard Ethernet header length of 12 + 4 + 2 bytes.
2019-01-28 10:56:18 -08:00
Francois-Xavier Le Bail
8d316a9ae0 Fix style 2018-09-13 14:52:42 +02:00
Francois-Xavier Le Bail
46efa1bc47 Fix spaces 2018-09-03 15:18:19 +02:00
Francois-Xavier Le Bail
d77ac851c7 Fix local time printing
Using seconds offset from GMT to local time to compute local time give
errors when printing times outside the same daylight saving time period.

Use the localtime() function for default and -tttt cases.
Use the gmtime() function for -ttt and -ttttt cases.

Rename ts_hmsfrac_print() to ts_date_hmsfrac_print().
Remove some variables now useless.
Update some comments.
2018-08-07 17:37:36 +02:00
Guy Harris
b314392dfe Include pcap-missing.h, to get the declaration of pcap_datalink_val_to_name().
If we're building with an old version of libpcap that doesn't include
pcap_datalink_val_to_name(), we incorporate our own version, but we need
to have it declared before we use it.
2018-07-29 15:08:16 -07:00
Guy Harris
51c1da63e4 DLT_LINUX_SLL2 support. 2018-07-12 11:49:38 -07:00
Guy Harris
66384fa15b We no longer need pcap/nflog.h nor pcap/bluetooth.h. 2018-05-24 14:13:22 -07:00
Francois-Xavier Le Bail
56e6581c34 Remove useless comments 2018-03-19 15:16:32 +01:00
Francois-Xavier Le Bail
a53605c61b Add a malloc/free process with garbage collector
Use it in the PPP printer.
2018-03-14 13:59:26 +01:00
Francois-Xavier Le Bail
5ae22f41a8 Add a status exit code to the function ndo_error()
The status are defined in an enum in status-exit-codes.h.

Moreover:
Use ndo_error() instead of ndo_warning() for malloc() errors in print-esp.c.
2018-02-25 20:58:27 +01:00
Francois-Xavier Le Bail
f253e11009 Add a sanity check on packet header length
The packet length must be <= MAXIMUM_SNAPLEN.

Currently, there is no D-Bus printer, thus no need for a bigger length.

Now a pachet is valid if:
capture length != 0,
packet length != 0,
capture length <= MAXIMUM_SNAPLEN,
packet length <= MAXIMUM_SNAPLEN,
packet length >= capture length.

Moreover:
Fix the packet header lengths of some fuzzed pcap files:
If the lengths are > MAXIMUM_SNAPLEN, set them to MAXIMUM_SNAPLEN.
Thus they will be always usable with this new sanity check.
2018-02-07 18:48:49 +01:00
Francois-Xavier Le Bail
8d814082b7 Add a sanity check on packet header capture length
The capture length must be <= MAXIMUM_SNAPLEN.

Now a pachet is valid if:
packet length != 0,
capture length != 0,
capture length <= MAXIMUM_SNAPLEN,
packet length >= capture length.

Moreover:
Fix spaces, indentation.
2018-02-01 18:58:02 +01:00
Francois-Xavier Le Bail
bdeb75099d Add a comment about packet and capture lengths 2018-01-25 15:29:02 +01:00
Francois-Xavier Le Bail
a8c1b2a339 No more need for ndo_invalid_header in struct netdissect_options
Because we now stop decoding packet when header length(s) is/are invalid,
there is no more need to keep the invalid header flag out of
pretty_print_packet function.
2018-01-25 15:12:24 +01:00