]> The Tcpdump Group git mirrors - libpcap/blob - pcap-common.c
Linux USB: fix incorrect values for the packet length.
[libpcap] / pcap-common.c
1 /*
2 * Copyright (c) 1993, 1994, 1995, 1996, 1997
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and
9 * this paragraph in its entirety in the documentation or other materials
10 * provided with the distribution, and (3) all advertising materials mentioning
11 * features or use of this software display the following acknowledgement:
12 * ``This product includes software developed by the University of California,
13 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14 * the University nor the names of its contributors may be used to endorse
15 * or promote products derived from this software without specific prior
16 * written permission.
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 *
21 * pcap-common.c - common code for pcap and pcapng files
22 */
23
24 #ifdef HAVE_CONFIG_H
25 #include <config.h>
26 #endif
27
28 #include <pcap-types.h>
29
30 #include "pcap-int.h"
31 #include "extract.h"
32 #include "pcap/sll.h"
33 #include "pcap/usb.h"
34 #include "pcap/nflog.h"
35 #include "pcap/can_socketcan.h"
36
37 #include "pflog.h"
38
39 #include "pcap-usb-linux-common.h"
40
41 #include "pcap-common.h"
42
43 /*
44 * We don't write DLT_* values to capture files, because they're not the
45 * same on all platforms.
46 *
47 * Unfortunately, the various flavors of BSD have not always used the same
48 * numerical values for the same data types, and various patches to
49 * libpcap for non-BSD OSes have added their own DLT_* codes for link
50 * layer encapsulation types seen on those OSes, and those codes have had,
51 * in some cases, values that were also used, on other platforms, for other
52 * link layer encapsulation types.
53 *
54 * This means that capture files of a type whose numerical DLT_* code
55 * means different things on different BSDs, or with different versions
56 * of libpcap, can't always be read on systems other than those like
57 * the one running on the machine on which the capture was made.
58 *
59 * Instead, we define here a set of LINKTYPE_* codes, and map DLT_* codes
60 * to LINKTYPE_* codes when writing a savefile header, and map LINKTYPE_*
61 * codes to DLT_* codes when reading a savefile header.
62 *
63 * For those DLT_* codes that have, as far as we know, the same values on
64 * all platforms (DLT_NULL through DLT_FDDI), we define LINKTYPE_xxx as
65 * DLT_xxx; that way, captures of those types can still be read by
66 * versions of libpcap that map LINKTYPE_* values to DLT_* values, and
67 * captures of those types written by versions of libpcap that map DLT_
68 * values to LINKTYPE_ values can still be read by older versions
69 * of libpcap.
70 *
71 * The other LINKTYPE_* codes are given values starting at 100, in the
72 * hopes that no DLT_* code will be given one of those values.
73 *
74 * In order to ensure that a given LINKTYPE_* code's value will refer to
75 * the same encapsulation type on all platforms, you should not allocate
76 * a new LINKTYPE_* value without consulting
77 * "tcpdump-workers@lists.tcpdump.org". The tcpdump developers will
78 * allocate a value for you, and will not subsequently allocate it to
79 * anybody else; that value will be added to the "pcap.h" in the
80 * tcpdump.org Git repository, so that a future libpcap release will
81 * include it.
82 *
83 * You should, if possible, also contribute patches to libpcap and tcpdump
84 * to handle the new encapsulation type, so that they can also be checked
85 * into the tcpdump.org Git repository and so that they will appear in
86 * future libpcap and tcpdump releases.
87 *
88 * Do *NOT* assume that any values after the largest value in this file
89 * are available; you might not have the most up-to-date version of this
90 * file, and new values after that one might have been assigned. Also,
91 * do *NOT* use any values below 100 - those might already have been
92 * taken by one (or more!) organizations.
93 *
94 * Any platform that defines additional DLT_* codes should:
95 *
96 * request a LINKTYPE_* code and value from tcpdump.org,
97 * as per the above;
98 *
99 * add, in their version of libpcap, an entry to map
100 * those DLT_* codes to the corresponding LINKTYPE_*
101 * code;
102 *
103 * redefine, in their "net/bpf.h", any DLT_* values
104 * that collide with the values used by their additional
105 * DLT_* codes, to remove those collisions (but without
106 * making them collide with any of the LINKTYPE_*
107 * values equal to 50 or above; they should also avoid
108 * defining DLT_* values that collide with those
109 * LINKTYPE_* values, either).
110 */
111 #define LINKTYPE_NULL DLT_NULL
112 #define LINKTYPE_ETHERNET DLT_EN10MB /* also for 100Mb and up */
113 #define LINKTYPE_EXP_ETHERNET DLT_EN3MB /* 3Mb experimental Ethernet */
114 #define LINKTYPE_AX25 DLT_AX25
115 #define LINKTYPE_PRONET DLT_PRONET
116 #define LINKTYPE_CHAOS DLT_CHAOS
117 #define LINKTYPE_IEEE802_5 DLT_IEEE802 /* DLT_IEEE802 is used for 802.5 Token Ring */
118 #define LINKTYPE_ARCNET_BSD DLT_ARCNET /* BSD-style headers */
119 #define LINKTYPE_SLIP DLT_SLIP
120 #define LINKTYPE_PPP DLT_PPP
121 #define LINKTYPE_FDDI DLT_FDDI
122
123 /*
124 * LINKTYPE_PPP is for use when there might, or might not, be an RFC 1662
125 * PPP in HDLC-like framing header (with 0xff 0x03 before the PPP protocol
126 * field) at the beginning of the packet.
127 *
128 * This is for use when there is always such a header; the address field
129 * might be 0xff, for regular PPP, or it might be an address field for Cisco
130 * point-to-point with HDLC framing as per section 4.3.1 of RFC 1547 ("Cisco
131 * HDLC"). This is, for example, what you get with NetBSD's DLT_PPP_SERIAL.
132 *
133 * We give it the same value as NetBSD's DLT_PPP_SERIAL, in the hopes that
134 * nobody else will choose a DLT_ value of 50, and so that DLT_PPP_SERIAL
135 * captures will be written out with a link type that NetBSD's tcpdump
136 * can read.
137 */
138 #define LINKTYPE_PPP_HDLC 50 /* PPP in HDLC-like framing */
139
140 #define LINKTYPE_PPP_ETHER 51 /* NetBSD PPP-over-Ethernet */
141
142 #define LINKTYPE_SYMANTEC_FIREWALL 99 /* Symantec Enterprise Firewall */
143
144 /*
145 * These correspond to DLT_s that have different values on different
146 * platforms; we map between these values in capture files and
147 * the DLT_ values as returned by pcap_datalink() and passed to
148 * pcap_open_dead().
149 */
150 #define LINKTYPE_ATM_RFC1483 100 /* LLC/SNAP-encapsulated ATM */
151 #define LINKTYPE_RAW 101 /* raw IP */
152 #define LINKTYPE_SLIP_BSDOS 102 /* BSD/OS SLIP BPF header */
153 #define LINKTYPE_PPP_BSDOS 103 /* BSD/OS PPP BPF header */
154
155 /*
156 * Values starting with 104 are used for newly-assigned link-layer
157 * header type values; for those link-layer header types, the DLT_
158 * value returned by pcap_datalink() and passed to pcap_open_dead(),
159 * and the LINKTYPE_ value that appears in capture files, are the
160 * same.
161 *
162 * LINKTYPE_MATCHING_MIN is the lowest such value; LINKTYPE_MATCHING_MAX
163 * is the highest such value.
164 */
165 #define LINKTYPE_MATCHING_MIN 104 /* lowest value in the "matching" range */
166
167 #define LINKTYPE_C_HDLC 104 /* Cisco HDLC */
168 #define LINKTYPE_IEEE802_11 105 /* IEEE 802.11 (wireless) */
169 #define LINKTYPE_ATM_CLIP 106 /* Linux Classical IP over ATM */
170 #define LINKTYPE_FRELAY 107 /* Frame Relay */
171 #define LINKTYPE_LOOP 108 /* OpenBSD loopback */
172 #define LINKTYPE_ENC 109 /* OpenBSD IPSEC enc */
173
174 /*
175 * These two types are reserved for future use.
176 */
177 #define LINKTYPE_LANE8023 110 /* ATM LANE + 802.3 */
178 #define LINKTYPE_HIPPI 111 /* NetBSD HIPPI */
179
180 /*
181 * Used for NetBSD DLT_HDLC; from looking at the one driver in NetBSD
182 * that uses it, it's Cisco HDLC, so it's the same as DLT_C_HDLC/
183 * LINKTYPE_C_HDLC, but we define a separate value to avoid some
184 * compatibility issues with programs on NetBSD.
185 *
186 * All code should treat LINKTYPE_NETBSD_HDLC and LINKTYPE_C_HDLC the same.
187 */
188 #define LINKTYPE_NETBSD_HDLC 112 /* NetBSD HDLC framing */
189
190 #define LINKTYPE_LINUX_SLL 113 /* Linux cooked socket capture */
191 #define LINKTYPE_LTALK 114 /* Apple LocalTalk hardware */
192 #define LINKTYPE_ECONET 115 /* Acorn Econet */
193
194 /*
195 * Reserved for use with OpenBSD ipfilter.
196 */
197 #define LINKTYPE_IPFILTER 116
198
199 #define LINKTYPE_PFLOG 117 /* OpenBSD DLT_PFLOG */
200 #define LINKTYPE_CISCO_IOS 118 /* For Cisco-internal use */
201 #define LINKTYPE_IEEE802_11_PRISM 119 /* 802.11 plus Prism II monitor mode radio metadata header */
202 #define LINKTYPE_IEEE802_11_AIRONET 120 /* 802.11 plus FreeBSD Aironet driver radio metadata header */
203
204 /*
205 * Reserved for Siemens HiPath HDLC.
206 */
207 #define LINKTYPE_HHDLC 121
208
209 #define LINKTYPE_IP_OVER_FC 122 /* RFC 2625 IP-over-Fibre Channel */
210 #define LINKTYPE_SUNATM 123 /* Solaris+SunATM */
211
212 /*
213 * Reserved as per request from Kent Dahlgren <kent@praesum.com>
214 * for private use.
215 */
216 #define LINKTYPE_RIO 124 /* RapidIO */
217 #define LINKTYPE_PCI_EXP 125 /* PCI Express */
218 #define LINKTYPE_AURORA 126 /* Xilinx Aurora link layer */
219
220 #define LINKTYPE_IEEE802_11_RADIOTAP 127 /* 802.11 plus radiotap radio metadata header */
221
222 /*
223 * Reserved for the TZSP encapsulation, as per request from
224 * Chris Waters <chris.waters@networkchemistry.com>
225 * TZSP is a generic encapsulation for any other link type,
226 * which includes a means to include meta-information
227 * with the packet, e.g. signal strength and channel
228 * for 802.11 packets.
229 */
230 #define LINKTYPE_TZSP 128 /* Tazmen Sniffer Protocol */
231
232 #define LINKTYPE_ARCNET_LINUX 129 /* Linux-style headers */
233
234 /*
235 * Juniper-private data link types, as per request from
236 * Hannes Gredler <hannes@juniper.net>. The corresponding
237 * DLT_s are used for passing on chassis-internal
238 * metainformation such as QOS profiles, etc..
239 */
240 #define LINKTYPE_JUNIPER_MLPPP 130
241 #define LINKTYPE_JUNIPER_MLFR 131
242 #define LINKTYPE_JUNIPER_ES 132
243 #define LINKTYPE_JUNIPER_GGSN 133
244 #define LINKTYPE_JUNIPER_MFR 134
245 #define LINKTYPE_JUNIPER_ATM2 135
246 #define LINKTYPE_JUNIPER_SERVICES 136
247 #define LINKTYPE_JUNIPER_ATM1 137
248
249 #define LINKTYPE_APPLE_IP_OVER_IEEE1394 138 /* Apple IP-over-IEEE 1394 cooked header */
250
251 #define LINKTYPE_MTP2_WITH_PHDR 139
252 #define LINKTYPE_MTP2 140
253 #define LINKTYPE_MTP3 141
254 #define LINKTYPE_SCCP 142
255
256 #define LINKTYPE_DOCSIS 143 /* DOCSIS MAC frames */
257
258 #define LINKTYPE_LINUX_IRDA 144 /* Linux-IrDA */
259
260 /*
261 * Reserved for IBM SP switch and IBM Next Federation switch.
262 */
263 #define LINKTYPE_IBM_SP 145
264 #define LINKTYPE_IBM_SN 146
265
266 /*
267 * Reserved for private use. If you have some link-layer header type
268 * that you want to use within your organization, with the capture files
269 * using that link-layer header type not ever be sent outside your
270 * organization, you can use these values.
271 *
272 * No libpcap release will use these for any purpose, nor will any
273 * tcpdump release use them, either.
274 *
275 * Do *NOT* use these in capture files that you expect anybody not using
276 * your private versions of capture-file-reading tools to read; in
277 * particular, do *NOT* use them in products, otherwise you may find that
278 * people won't be able to use tcpdump, or snort, or Ethereal, or... to
279 * read capture files from your firewall/intrusion detection/traffic
280 * monitoring/etc. appliance, or whatever product uses that LINKTYPE_ value,
281 * and you may also find that the developers of those applications will
282 * not accept patches to let them read those files.
283 *
284 * Also, do not use them if somebody might send you a capture using them
285 * for *their* private type and tools using them for *your* private type
286 * would have to read them.
287 *
288 * Instead, in those cases, ask "tcpdump-workers@lists.tcpdump.org" for a
289 * new DLT_ and LINKTYPE_ value, as per the comment in pcap/bpf.h, and use
290 * the type you're given.
291 */
292 #define LINKTYPE_USER0 147
293 #define LINKTYPE_USER1 148
294 #define LINKTYPE_USER2 149
295 #define LINKTYPE_USER3 150
296 #define LINKTYPE_USER4 151
297 #define LINKTYPE_USER5 152
298 #define LINKTYPE_USER6 153
299 #define LINKTYPE_USER7 154
300 #define LINKTYPE_USER8 155
301 #define LINKTYPE_USER9 156
302 #define LINKTYPE_USER10 157
303 #define LINKTYPE_USER11 158
304 #define LINKTYPE_USER12 159
305 #define LINKTYPE_USER13 160
306 #define LINKTYPE_USER14 161
307 #define LINKTYPE_USER15 162
308
309 /*
310 * For future use with 802.11 captures - defined by AbsoluteValue
311 * Systems to store a number of bits of link-layer information
312 * including radio information:
313 *
314 * http://www.shaftnet.org/~pizza/software/capturefrm.txt
315 */
316 #define LINKTYPE_IEEE802_11_AVS 163 /* 802.11 plus AVS radio metadata header */
317
318 /*
319 * Juniper-private data link type, as per request from
320 * Hannes Gredler <hannes@juniper.net>. The corresponding
321 * DLT_s are used for passing on chassis-internal
322 * metainformation such as QOS profiles, etc..
323 */
324 #define LINKTYPE_JUNIPER_MONITOR 164
325
326 /*
327 * BACnet MS/TP frames.
328 */
329 #define LINKTYPE_BACNET_MS_TP 165
330
331 /*
332 * Another PPP variant as per request from Karsten Keil <kkeil@suse.de>.
333 *
334 * This is used in some OSes to allow a kernel socket filter to distinguish
335 * between incoming and outgoing packets, on a socket intended to
336 * supply pppd with outgoing packets so it can do dial-on-demand and
337 * hangup-on-lack-of-demand; incoming packets are filtered out so they
338 * don't cause pppd to hold the connection up (you don't want random
339 * input packets such as port scans, packets from old lost connections,
340 * etc. to force the connection to stay up).
341 *
342 * The first byte of the PPP header (0xff03) is modified to accommodate
343 * the direction - 0x00 = IN, 0x01 = OUT.
344 */
345 #define LINKTYPE_PPP_PPPD 166
346
347 /*
348 * Juniper-private data link type, as per request from
349 * Hannes Gredler <hannes@juniper.net>. The DLT_s are used
350 * for passing on chassis-internal metainformation such as
351 * QOS profiles, cookies, etc..
352 */
353 #define LINKTYPE_JUNIPER_PPPOE 167
354 #define LINKTYPE_JUNIPER_PPPOE_ATM 168
355
356 #define LINKTYPE_GPRS_LLC 169 /* GPRS LLC */
357 #define LINKTYPE_GPF_T 170 /* GPF-T (ITU-T G.7041/Y.1303) */
358 #define LINKTYPE_GPF_F 171 /* GPF-F (ITU-T G.7041/Y.1303) */
359
360 /*
361 * Requested by Oolan Zimmer <oz@gcom.com> for use in Gcom's T1/E1 line
362 * monitoring equipment.
363 */
364 #define LINKTYPE_GCOM_T1E1 172
365 #define LINKTYPE_GCOM_SERIAL 173
366
367 /*
368 * Juniper-private data link type, as per request from
369 * Hannes Gredler <hannes@juniper.net>. The DLT_ is used
370 * for internal communication to Physical Interface Cards (PIC)
371 */
372 #define LINKTYPE_JUNIPER_PIC_PEER 174
373
374 /*
375 * Link types requested by Gregor Maier <gregor@endace.com> of Endace
376 * Measurement Systems. They add an ERF header (see
377 * https://www.endace.com/support/EndaceRecordFormat.pdf) in front of
378 * the link-layer header.
379 */
380 #define LINKTYPE_ERF_ETH 175 /* Ethernet */
381 #define LINKTYPE_ERF_POS 176 /* Packet-over-SONET */
382
383 /*
384 * Requested by Daniele Orlandi <daniele@orlandi.com> for raw LAPD
385 * for vISDN (http://www.orlandi.com/visdn/). Its link-layer header
386 * includes additional information before the LAPD header, so it's
387 * not necessarily a generic LAPD header.
388 */
389 #define LINKTYPE_LINUX_LAPD 177
390
391 /*
392 * Juniper-private data link type, as per request from
393 * Hannes Gredler <hannes@juniper.net>.
394 * The Link Types are used for prepending meta-information
395 * like interface index, interface name
396 * before standard Ethernet, PPP, Frelay & C-HDLC Frames
397 */
398 #define LINKTYPE_JUNIPER_ETHER 178
399 #define LINKTYPE_JUNIPER_PPP 179
400 #define LINKTYPE_JUNIPER_FRELAY 180
401 #define LINKTYPE_JUNIPER_CHDLC 181
402
403 /*
404 * Multi Link Frame Relay (FRF.16)
405 */
406 #define LINKTYPE_MFR 182
407
408 /*
409 * Juniper-private data link type, as per request from
410 * Hannes Gredler <hannes@juniper.net>.
411 * The DLT_ is used for internal communication with a
412 * voice Adapter Card (PIC)
413 */
414 #define LINKTYPE_JUNIPER_VP 183
415
416 /*
417 * Arinc 429 frames.
418 * DLT_ requested by Gianluca Varenni <gianluca.varenni@cacetech.com>.
419 * Every frame contains a 32bit A429 label.
420 * More documentation on Arinc 429 can be found at
421 * http://www.condoreng.com/support/downloads/tutorials/ARINCTutorial.pdf
422 */
423 #define LINKTYPE_A429 184
424
425 /*
426 * Arinc 653 Interpartition Communication messages.
427 * DLT_ requested by Gianluca Varenni <gianluca.varenni@cacetech.com>.
428 * Please refer to the A653-1 standard for more information.
429 */
430 #define LINKTYPE_A653_ICM 185
431
432 /*
433 * This used to be "USB packets, beginning with a USB setup header;
434 * requested by Paolo Abeni <paolo.abeni@email.it>."
435 *
436 * However, that header didn't work all that well - it left out some
437 * useful information - and was abandoned in favor of the DLT_USB_LINUX
438 * header.
439 *
440 * This is now used by FreeBSD for its BPF taps for USB; that has its
441 * own headers. So it is written, so it is done.
442 */
443 #define LINKTYPE_USB_FREEBSD 186
444
445 /*
446 * Bluetooth HCI UART transport layer (part H:4); requested by
447 * Paolo Abeni.
448 */
449 #define LINKTYPE_BLUETOOTH_HCI_H4 187
450
451 /*
452 * IEEE 802.16 MAC Common Part Sublayer; requested by Maria Cruz
453 * <cruz_petagay@bah.com>.
454 */
455 #define LINKTYPE_IEEE802_16_MAC_CPS 188
456
457 /*
458 * USB packets, beginning with a Linux USB header; requested by
459 * Paolo Abeni <paolo.abeni@email.it>.
460 */
461 #define LINKTYPE_USB_LINUX 189
462
463 /*
464 * Controller Area Network (CAN) v. 2.0B packets.
465 * DLT_ requested by Gianluca Varenni <gianluca.varenni@cacetech.com>.
466 * Used to dump CAN packets coming from a CAN Vector board.
467 * More documentation on the CAN v2.0B frames can be found at
468 * http://www.can-cia.org/downloads/?269
469 */
470 #define LINKTYPE_CAN20B 190
471
472 /*
473 * IEEE 802.15.4, with address fields padded, as is done by Linux
474 * drivers; requested by Juergen Schimmer.
475 */
476 #define LINKTYPE_IEEE802_15_4_LINUX 191
477
478 /*
479 * Per Packet Information encapsulated packets.
480 * LINKTYPE_ requested by Gianluca Varenni <gianluca.varenni@cacetech.com>.
481 */
482 #define LINKTYPE_PPI 192
483
484 /*
485 * Header for 802.16 MAC Common Part Sublayer plus a radiotap radio header;
486 * requested by Charles Clancy.
487 */
488 #define LINKTYPE_IEEE802_16_MAC_CPS_RADIO 193
489
490 /*
491 * Juniper-private data link type, as per request from
492 * Hannes Gredler <hannes@juniper.net>.
493 * The DLT_ is used for internal communication with a
494 * integrated service module (ISM).
495 */
496 #define LINKTYPE_JUNIPER_ISM 194
497
498 /*
499 * IEEE 802.15.4, exactly as it appears in the spec (no padding, no
500 * nothing), and with the FCS at the end of the frame; requested by
501 * Mikko Saarnivala <mikko.saarnivala@sensinode.com>.
502 *
503 * This should only be used if the FCS is present at the end of the
504 * frame; if the frame has no FCS, DLT_IEEE802_15_4_NOFCS should be
505 * used.
506 */
507 #define LINKTYPE_IEEE802_15_4_WITHFCS 195
508
509 /*
510 * Various link-layer types, with a pseudo-header, for SITA
511 * (https://www.sita.aero/); requested by Fulko Hew (fulko.hew@gmail.com).
512 */
513 #define LINKTYPE_SITA 196
514
515 /*
516 * Various link-layer types, with a pseudo-header, for Endace DAG cards;
517 * encapsulates Endace ERF records. Requested by Stephen Donnelly
518 * <stephen@endace.com>.
519 */
520 #define LINKTYPE_ERF 197
521
522 /*
523 * Special header prepended to Ethernet packets when capturing from a
524 * u10 Networks board. Requested by Phil Mulholland
525 * <phil@u10networks.com>.
526 */
527 #define LINKTYPE_RAIF1 198
528
529 /*
530 * IPMB packet for IPMI, beginning with a 2-byte header, followed by
531 * the I2C slave address, followed by the netFn and LUN, etc..
532 * Requested by Chanthy Toeung <chanthy.toeung@ca.kontron.com>.
533 *
534 * XXX - its DLT_ value used to be called DLT_IPMB, back when we got the
535 * impression from the email thread requesting it that the packet
536 * had no extra 2-byte header. We've renamed it; if anybody used
537 * DLT_IPMB and assumed no 2-byte header, this will cause the compile
538 * to fail, at which point we'll have to figure out what to do about
539 * the two header types using the same DLT_/LINKTYPE_ value. If that
540 * doesn't happen, we'll assume nobody used it and that the redefinition
541 * is safe.
542 */
543 #define LINKTYPE_IPMB_KONTRON 199
544
545 /*
546 * Juniper-private data link type, as per request from
547 * Hannes Gredler <hannes@juniper.net>.
548 * The DLT_ is used for capturing data on a secure tunnel interface.
549 */
550 #define LINKTYPE_JUNIPER_ST 200
551
552 /*
553 * Bluetooth HCI UART transport layer (part H:4), with pseudo-header
554 * that includes direction information; requested by Paolo Abeni.
555 */
556 #define LINKTYPE_BLUETOOTH_HCI_H4_WITH_PHDR 201
557
558 /*
559 * AX.25 packet with a 1-byte KISS header; see
560 *
561 * http://www.ax25.net/kiss.htm
562 *
563 * as per Richard Stearn <richard@rns-stearn.demon.co.uk>.
564 */
565 #define LINKTYPE_AX25_KISS 202
566
567 /*
568 * LAPD packets from an ISDN channel, starting with the address field,
569 * with no pseudo-header.
570 * Requested by Varuna De Silva <varunax@gmail.com>.
571 */
572 #define LINKTYPE_LAPD 203
573
574 /*
575 * PPP, with a one-byte direction pseudo-header prepended - zero means
576 * "received by this host", non-zero (any non-zero value) means "sent by
577 * this host" - as per Will Barker <w.barker@zen.co.uk>.
578 */
579 #define LINKTYPE_PPP_WITH_DIR 204 /* Don't confuse with LINKTYPE_PPP_PPPD */
580
581 /*
582 * Cisco HDLC, with a one-byte direction pseudo-header prepended - zero
583 * means "received by this host", non-zero (any non-zero value) means
584 * "sent by this host" - as per Will Barker <w.barker@zen.co.uk>.
585 */
586 #define LINKTYPE_C_HDLC_WITH_DIR 205 /* Cisco HDLC */
587
588 /*
589 * Frame Relay, with a one-byte direction pseudo-header prepended - zero
590 * means "received by this host" (DCE -> DTE), non-zero (any non-zero
591 * value) means "sent by this host" (DTE -> DCE) - as per Will Barker
592 * <w.barker@zen.co.uk>.
593 */
594 #define LINKTYPE_FRELAY_WITH_DIR 206 /* Frame Relay */
595
596 /*
597 * LAPB, with a one-byte direction pseudo-header prepended - zero means
598 * "received by this host" (DCE -> DTE), non-zero (any non-zero value)
599 * means "sent by this host" (DTE -> DCE)- as per Will Barker
600 * <w.barker@zen.co.uk>.
601 */
602 #define LINKTYPE_LAPB_WITH_DIR 207 /* LAPB */
603
604 /*
605 * 208 is reserved for an as-yet-unspecified proprietary link-layer
606 * type, as requested by Will Barker.
607 */
608
609 /*
610 * IPMB with a Linux-specific pseudo-header; as requested by Alexey Neyman
611 * <avn@pigeonpoint.com>.
612 */
613 #define LINKTYPE_IPMB_LINUX 209
614
615 /*
616 * FlexRay automotive bus - http://www.flexray.com/ - as requested
617 * by Hannes Kaelber <hannes.kaelber@x2e.de>.
618 */
619 #define LINKTYPE_FLEXRAY 210
620
621 /*
622 * Media Oriented Systems Transport (MOST) bus for multimedia
623 * transport - https://www.mostcooperation.com/ - as requested
624 * by Hannes Kaelber <hannes.kaelber@x2e.de>.
625 */
626 #define LINKTYPE_MOST 211
627
628 /*
629 * Local Interconnect Network (LIN) bus for vehicle networks -
630 * http://www.lin-subbus.org/ - as requested by Hannes Kaelber
631 * <hannes.kaelber@x2e.de>.
632 */
633 #define LINKTYPE_LIN 212
634
635 /*
636 * X2E-private data link type used for serial line capture,
637 * as requested by Hannes Kaelber <hannes.kaelber@x2e.de>.
638 */
639 #define LINKTYPE_X2E_SERIAL 213
640
641 /*
642 * X2E-private data link type used for the Xoraya data logger
643 * family, as requested by Hannes Kaelber <hannes.kaelber@x2e.de>.
644 */
645 #define LINKTYPE_X2E_XORAYA 214
646
647 /*
648 * IEEE 802.15.4, exactly as it appears in the spec (no padding, no
649 * nothing), but with the PHY-level data for non-ASK PHYs (4 octets
650 * of 0 as preamble, one octet of SFD, one octet of frame length+
651 * reserved bit, and then the MAC-layer data, starting with the
652 * frame control field).
653 *
654 * Requested by Max Filippov <jcmvbkbc@gmail.com>.
655 */
656 #define LINKTYPE_IEEE802_15_4_NONASK_PHY 215
657
658 /*
659 * David Gibson <david@gibson.dropbear.id.au> requested this for
660 * captures from the Linux kernel /dev/input/eventN devices. This
661 * is used to communicate keystrokes and mouse movements from the
662 * Linux kernel to display systems, such as Xorg.
663 */
664 #define LINKTYPE_LINUX_EVDEV 216
665
666 /*
667 * GSM Um and Abis interfaces, preceded by a "gsmtap" header.
668 *
669 * Requested by Harald Welte <laforge@gnumonks.org>.
670 */
671 #define LINKTYPE_GSMTAP_UM 217
672 #define LINKTYPE_GSMTAP_ABIS 218
673
674 /*
675 * MPLS, with an MPLS label as the link-layer header.
676 * Requested by Michele Marchetto <michele@openbsd.org> on behalf
677 * of OpenBSD.
678 */
679 #define LINKTYPE_MPLS 219
680
681 /*
682 * USB packets, beginning with a Linux USB header, with the USB header
683 * padded to 64 bytes; required for memory-mapped access.
684 */
685 #define LINKTYPE_USB_LINUX_MMAPPED 220
686
687 /*
688 * DECT packets, with a pseudo-header; requested by
689 * Matthias Wenzel <tcpdump@mazzoo.de>.
690 */
691 #define LINKTYPE_DECT 221
692
693 /*
694 * From: "Lidwa, Eric (GSFC-582.0)[SGT INC]" <eric.lidwa-1@nasa.gov>
695 * Date: Mon, 11 May 2009 11:18:30 -0500
696 *
697 * DLT_AOS. We need it for AOS Space Data Link Protocol.
698 * I have already written dissectors for but need an OK from
699 * legal before I can submit a patch.
700 *
701 */
702 #define LINKTYPE_AOS 222
703
704 /*
705 * Wireless HART (Highway Addressable Remote Transducer)
706 * From the HART Communication Foundation
707 * IES/PAS 62591
708 *
709 * Requested by Sam Roberts <vieuxtech@gmail.com>.
710 */
711 #define LINKTYPE_WIHART 223
712
713 /*
714 * Fibre Channel FC-2 frames, beginning with a Frame_Header.
715 * Requested by Kahou Lei <kahou82@gmail.com>.
716 */
717 #define LINKTYPE_FC_2 224
718
719 /*
720 * Fibre Channel FC-2 frames, beginning with an encoding of the
721 * SOF, and ending with an encoding of the EOF.
722 *
723 * The encodings represent the frame delimiters as 4-byte sequences
724 * representing the corresponding ordered sets, with K28.5
725 * represented as 0xBC, and the D symbols as the corresponding
726 * byte values; for example, SOFi2, which is K28.5 - D21.5 - D1.2 - D21.2,
727 * is represented as 0xBC 0xB5 0x55 0x55.
728 *
729 * Requested by Kahou Lei <kahou82@gmail.com>.
730 */
731 #define LINKTYPE_FC_2_WITH_FRAME_DELIMS 225
732
733 /*
734 * Solaris ipnet pseudo-header; requested by Darren Reed <Darren.Reed@Sun.COM>.
735 *
736 * The pseudo-header starts with a one-byte version number; for version 2,
737 * the pseudo-header is:
738 *
739 * struct dl_ipnetinfo {
740 * uint8_t dli_version;
741 * uint8_t dli_family;
742 * uint16_t dli_htype;
743 * uint32_t dli_pktlen;
744 * uint32_t dli_ifindex;
745 * uint32_t dli_grifindex;
746 * uint32_t dli_zsrc;
747 * uint32_t dli_zdst;
748 * };
749 *
750 * dli_version is 2 for the current version of the pseudo-header.
751 *
752 * dli_family is a Solaris address family value, so it's 2 for IPv4
753 * and 26 for IPv6.
754 *
755 * dli_htype is a "hook type" - 0 for incoming packets, 1 for outgoing
756 * packets, and 2 for packets arriving from another zone on the same
757 * machine.
758 *
759 * dli_pktlen is the length of the packet data following the pseudo-header
760 * (so the captured length minus dli_pktlen is the length of the
761 * pseudo-header, assuming the entire pseudo-header was captured).
762 *
763 * dli_ifindex is the interface index of the interface on which the
764 * packet arrived.
765 *
766 * dli_grifindex is the group interface index number (for IPMP interfaces).
767 *
768 * dli_zsrc is the zone identifier for the source of the packet.
769 *
770 * dli_zdst is the zone identifier for the destination of the packet.
771 *
772 * A zone number of 0 is the global zone; a zone number of 0xffffffff
773 * means that the packet arrived from another host on the network, not
774 * from another zone on the same machine.
775 *
776 * An IPv4 or IPv6 datagram follows the pseudo-header; dli_family indicates
777 * which of those it is.
778 */
779 #define LINKTYPE_IPNET 226
780
781 /*
782 * CAN (Controller Area Network) frames, with a pseudo-header as supplied
783 * by Linux SocketCAN, and with multi-byte numerical fields in that header
784 * in big-endian byte order.
785 *
786 * See Documentation/networking/can.txt in the Linux source.
787 *
788 * Requested by Felix Obenhuber <felix@obenhuber.de>.
789 */
790 #define LINKTYPE_CAN_SOCKETCAN 227
791
792 /*
793 * Raw IPv4/IPv6; different from DLT_RAW in that the DLT_ value specifies
794 * whether it's v4 or v6. Requested by Darren Reed <Darren.Reed@Sun.COM>.
795 */
796 #define LINKTYPE_IPV4 228
797 #define LINKTYPE_IPV6 229
798
799 /*
800 * IEEE 802.15.4, exactly as it appears in the spec (no padding, no
801 * nothing), and with no FCS at the end of the frame; requested by
802 * Jon Smirl <jonsmirl@gmail.com>.
803 */
804 #define LINKTYPE_IEEE802_15_4_NOFCS 230
805
806 /*
807 * Raw D-Bus:
808 *
809 * https://www.freedesktop.org/wiki/Software/dbus
810 *
811 * messages:
812 *
813 * https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-messages
814 *
815 * starting with the endianness flag, followed by the message type, etc.,
816 * but without the authentication handshake before the message sequence:
817 *
818 * https://dbus.freedesktop.org/doc/dbus-specification.html#auth-protocol
819 *
820 * Requested by Martin Vidner <martin@vidner.net>.
821 */
822 #define LINKTYPE_DBUS 231
823
824 /*
825 * Juniper-private data link type, as per request from
826 * Hannes Gredler <hannes@juniper.net>.
827 */
828 #define LINKTYPE_JUNIPER_VS 232
829 #define LINKTYPE_JUNIPER_SRX_E2E 233
830 #define LINKTYPE_JUNIPER_FIBRECHANNEL 234
831
832 /*
833 * DVB-CI (DVB Common Interface for communication between a PC Card
834 * module and a DVB receiver). See
835 *
836 * https://www.kaiser.cx/pcap-dvbci.html
837 *
838 * for the specification.
839 *
840 * Requested by Martin Kaiser <martin@kaiser.cx>.
841 */
842 #define LINKTYPE_DVB_CI 235
843
844 /*
845 * Variant of 3GPP TS 27.010 multiplexing protocol. Requested
846 * by Hans-Christoph Schemmel <hans-christoph.schemmel@cinterion.com>.
847 */
848 #define LINKTYPE_MUX27010 236
849
850 /*
851 * STANAG 5066 D_PDUs. Requested by M. Baris Demiray
852 * <barisdemiray@gmail.com>.
853 */
854 #define LINKTYPE_STANAG_5066_D_PDU 237
855
856 /*
857 * Juniper-private data link type, as per request from
858 * Hannes Gredler <hannes@juniper.net>.
859 */
860 #define LINKTYPE_JUNIPER_ATM_CEMIC 238
861
862 /*
863 * NetFilter LOG messages
864 * (payload of netlink NFNL_SUBSYS_ULOG/NFULNL_MSG_PACKET packets)
865 *
866 * Requested by Jakub Zawadzki <darkjames-ws@darkjames.pl>
867 */
868 #define LINKTYPE_NFLOG 239
869
870 /*
871 * Hilscher Gesellschaft fuer Systemautomation mbH link-layer type
872 * for Ethernet packets with a 4-byte pseudo-header and always
873 * with the payload including the FCS, as supplied by their
874 * netANALYZER hardware and software.
875 *
876 * Requested by Holger P. Frommer <HPfrommer@hilscher.com>
877 */
878 #define LINKTYPE_NETANALYZER 240
879
880 /*
881 * Hilscher Gesellschaft fuer Systemautomation mbH link-layer type
882 * for Ethernet packets with a 4-byte pseudo-header and FCS and
883 * 1 byte of SFD, as supplied by their netANALYZER hardware and
884 * software.
885 *
886 * Requested by Holger P. Frommer <HPfrommer@hilscher.com>
887 */
888 #define LINKTYPE_NETANALYZER_TRANSPARENT 241
889
890 /*
891 * IP-over-InfiniBand, as specified by RFC 4391.
892 *
893 * Requested by Petr Sumbera <petr.sumbera@oracle.com>.
894 */
895 #define LINKTYPE_IPOIB 242
896
897 /*
898 * MPEG-2 transport stream (ISO 13818-1/ITU-T H.222.0).
899 *
900 * Requested by Guy Martin <gmsoft@tuxicoman.be>.
901 */
902 #define LINKTYPE_MPEG_2_TS 243
903
904 /*
905 * ng4T GmbH's UMTS Iub/Iur-over-ATM and Iub/Iur-over-IP format as
906 * used by their ng40 protocol tester.
907 *
908 * Requested by Jens Grimmer <jens.grimmer@ng4t.com>.
909 */
910 #define LINKTYPE_NG40 244
911
912 /*
913 * Pseudo-header giving adapter number and flags, followed by an NFC
914 * (Near-Field Communications) Logical Link Control Protocol (LLCP) PDU,
915 * as specified by NFC Forum Logical Link Control Protocol Technical
916 * Specification LLCP 1.1.
917 *
918 * Requested by Mike Wakerly <mikey@google.com>.
919 */
920 #define LINKTYPE_NFC_LLCP 245
921
922 /*
923 * pfsync output; DLT_PFSYNC is 18, which collides with DLT_CIP in
924 * SuSE 6.3, on OpenBSD, NetBSD, DragonFly BSD, and macOS, and
925 * is 121, which collides with DLT_HHDLC, in FreeBSD. We pick a
926 * shiny new link-layer header type value that doesn't collide with
927 * anything, in the hopes that future pfsync savefiles, if any,
928 * won't require special hacks to distinguish from other savefiles.
929 *
930 */
931 #define LINKTYPE_PFSYNC 246
932
933 /*
934 * Raw InfiniBand packets, starting with the Local Routing Header.
935 *
936 * Requested by Oren Kladnitsky <orenk@mellanox.com>.
937 */
938 #define LINKTYPE_INFINIBAND 247
939
940 /*
941 * SCTP, with no lower-level protocols (i.e., no IPv4 or IPv6).
942 *
943 * Requested by Michael Tuexen <Michael.Tuexen@lurchi.franken.de>.
944 */
945 #define LINKTYPE_SCTP 248
946
947 /*
948 * USB packets, beginning with a USBPcap header.
949 *
950 * Requested by Tomasz Mon <desowin@gmail.com>
951 */
952 #define LINKTYPE_USBPCAP 249
953
954 /*
955 * Schweitzer Engineering Laboratories "RTAC" product serial-line
956 * packets.
957 *
958 * Requested by Chris Bontje <chris_bontje@selinc.com>.
959 */
960 #define LINKTYPE_RTAC_SERIAL 250
961
962 /*
963 * Bluetooth Low Energy air interface link-layer packets.
964 *
965 * Requested by Mike Kershaw <dragorn@kismetwireless.net>.
966 */
967 #define LINKTYPE_BLUETOOTH_LE_LL 251
968
969 /*
970 * Link-layer header type for upper-protocol layer PDU saves from wireshark.
971 *
972 * the actual contents are determined by two TAGs stored with each
973 * packet:
974 * EXP_PDU_TAG_LINKTYPE the link type (LINKTYPE_ value) of the
975 * original packet.
976 *
977 * EXP_PDU_TAG_PROTO_NAME the name of the wireshark dissector
978 * that can make sense of the data stored.
979 */
980 #define LINKTYPE_WIRESHARK_UPPER_PDU 252
981
982 /*
983 * Link-layer header type for the netlink protocol (nlmon devices).
984 */
985 #define LINKTYPE_NETLINK 253
986
987 /*
988 * Bluetooth Linux Monitor headers for the BlueZ stack.
989 */
990 #define LINKTYPE_BLUETOOTH_LINUX_MONITOR 254
991
992 /*
993 * Bluetooth Basic Rate/Enhanced Data Rate baseband packets, as
994 * captured by Ubertooth.
995 */
996 #define LINKTYPE_BLUETOOTH_BREDR_BB 255
997
998 /*
999 * Bluetooth Low Energy link layer packets, as captured by Ubertooth.
1000 */
1001 #define LINKTYPE_BLUETOOTH_LE_LL_WITH_PHDR 256
1002
1003 /*
1004 * PROFIBUS data link layer.
1005 */
1006 #define LINKTYPE_PROFIBUS_DL 257
1007
1008 /*
1009 * Apple's DLT_PKTAP headers.
1010 *
1011 * Sadly, the folks at Apple either had no clue that the DLT_USERn values
1012 * are for internal use within an organization and partners only, and
1013 * didn't know that the right way to get a link-layer header type is to
1014 * ask tcpdump.org for one, or knew and didn't care, so they just
1015 * used DLT_USER2, which causes problems for everything except for
1016 * their version of tcpdump.
1017 *
1018 * So I'll just give them one; hopefully this will show up in a
1019 * libpcap release in time for them to get this into 10.10 Big Sur
1020 * or whatever Mavericks' successor is called. LINKTYPE_PKTAP
1021 * will be 258 *even on macOS*; that is *intentional*, so that
1022 * PKTAP files look the same on *all* OSes (different OSes can have
1023 * different numerical values for a given DLT_, but *MUST NOT* have
1024 * different values for what goes in a file, as files can be moved
1025 * between OSes!).
1026 */
1027 #define LINKTYPE_PKTAP 258
1028
1029 /*
1030 * Ethernet packets preceded by a header giving the last 6 octets
1031 * of the preamble specified by 802.3-2012 Clause 65, section
1032 * 65.1.3.2 "Transmit".
1033 */
1034 #define LINKTYPE_EPON 259
1035
1036 /*
1037 * IPMI trace packets, as specified by Table 3-20 "Trace Data Block Format"
1038 * in the PICMG HPM.2 specification.
1039 */
1040 #define LINKTYPE_IPMI_HPM_2 260
1041
1042 /*
1043 * per Joshua Wright <jwright@hasborg.com>, formats for Zwave captures.
1044 */
1045 #define LINKTYPE_ZWAVE_R1_R2 261
1046 #define LINKTYPE_ZWAVE_R3 262
1047
1048 /*
1049 * per Steve Karg <skarg@users.sourceforge.net>, formats for Wattstopper
1050 * Digital Lighting Management room bus serial protocol captures.
1051 */
1052 #define LINKTYPE_WATTSTOPPER_DLM 263
1053
1054 /*
1055 * ISO 14443 contactless smart card messages.
1056 */
1057 #define LINKTYPE_ISO_14443 264
1058
1059 /*
1060 * Radio data system (RDS) groups. IEC 62106.
1061 * Per Jonathan Brucker <jonathan.brucke@gmail.com>.
1062 */
1063 #define LINKTYPE_RDS 265
1064
1065 /*
1066 * USB packets, beginning with a Darwin (macOS, etc.) header.
1067 */
1068 #define LINKTYPE_USB_DARWIN 266
1069
1070 /*
1071 * OpenBSD DLT_OPENFLOW.
1072 */
1073 #define LINKTYPE_OPENFLOW 267
1074
1075 /*
1076 * SDLC frames containing SNA PDUs.
1077 */
1078 #define LINKTYPE_SDLC 268
1079
1080 /*
1081 * per "Selvig, Bjorn" <b.selvig@ti.com> used for
1082 * TI protocol sniffer.
1083 */
1084 #define LINKTYPE_TI_LLN_SNIFFER 269
1085
1086 /*
1087 * per: Erik de Jong <erikdejong at gmail.com> for
1088 * https://github.com/eriknl/LoRaTap/releases/tag/v0.1
1089 */
1090 #define LINKTYPE_LORATAP 270
1091
1092 /*
1093 * per: Stefanha at gmail.com for
1094 * https://lists.sandelman.ca/pipermail/tcpdump-workers/2017-May/000772.html
1095 * and: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/vsockmon.h
1096 * for: https://qemu-project.org/Features/VirtioVsock
1097 */
1098 #define LINKTYPE_VSOCK 271
1099
1100 /*
1101 * Nordic Semiconductor Bluetooth LE sniffer.
1102 */
1103 #define LINKTYPE_NORDIC_BLE 272
1104
1105 /*
1106 * Excentis DOCSIS 3.1 RF sniffer (XRA-31)
1107 * per: bruno.verstuyft at excentis.com
1108 * https://www.xra31.com/xra-header
1109 */
1110 #define LINKTYPE_DOCSIS31_XRA31 273
1111
1112 /*
1113 * mPackets, as specified by IEEE 802.3br Figure 99-4, starting
1114 * with the preamble and always ending with a CRC field.
1115 */
1116 #define LINKTYPE_ETHERNET_MPACKET 274
1117
1118 /*
1119 * DisplayPort AUX channel monitoring data as specified by VESA
1120 * DisplayPort(DP) Standard preceded by a pseudo-header.
1121 * per dirk.eibach at gdsys.cc
1122 */
1123 #define LINKTYPE_DISPLAYPORT_AUX 275
1124
1125 /*
1126 * Linux cooked sockets v2.
1127 */
1128 #define LINKTYPE_LINUX_SLL2 276
1129
1130 /*
1131 * Sercos Monitor, per Manuel Jacob <manuel.jacob at steinbeis-stg.de>
1132 */
1133 #define LINKTYPE_SERCOS_MONITOR 277
1134
1135 /*
1136 * OpenVizsla http://openvizsla.org is open source USB analyzer hardware.
1137 * It consists of FPGA with attached USB phy and FTDI chip for streaming
1138 * the data to the host PC.
1139 *
1140 * Current OpenVizsla data encapsulation format is described here:
1141 * https://github.com/matwey/libopenvizsla/wiki/OpenVizsla-protocol-description
1142 *
1143 */
1144 #define LINKTYPE_OPENVIZSLA 278
1145
1146 /*
1147 * The Elektrobit High Speed Capture and Replay (EBHSCR) protocol is produced
1148 * by a PCIe Card for interfacing high speed automotive interfaces.
1149 *
1150 * The specification for this frame format can be found at:
1151 * https://www.elektrobit.com/ebhscr
1152 *
1153 * for Guenter.Ebermann at elektrobit.com
1154 *
1155 */
1156 #define LINKTYPE_EBHSCR 279
1157
1158 /*
1159 * The https://fd.io vpp graph dispatch tracer produces pcap trace files
1160 * in the format documented here:
1161 * https://fdio-vpp.readthedocs.io/en/latest/gettingstarted/developers/vnet.html#graph-dispatcher-pcap-tracing
1162 */
1163 #define LINKTYPE_VPP_DISPATCH 280
1164
1165 /*
1166 * Broadcom Ethernet switches (ROBO switch) 4 bytes proprietary tagging format.
1167 */
1168 #define LINKTYPE_DSA_TAG_BRCM 281
1169 #define LINKTYPE_DSA_TAG_BRCM_PREPEND 282
1170
1171 /*
1172 * IEEE 802.15.4 with pseudo-header and optional meta-data TLVs, PHY payload
1173 * exactly as it appears in the spec (no padding, no nothing), and FCS if
1174 * specified by FCS Type TLV; requested by James Ko <jck@exegin.com>.
1175 * Specification at https://github.com/jkcko/ieee802.15.4-tap
1176 */
1177 #define LINKTYPE_IEEE802_15_4_TAP 283
1178
1179 /*
1180 * Marvell (Ethertype) Distributed Switch Architecture proprietary tagging format.
1181 */
1182 #define LINKTYPE_DSA_TAG_DSA 284
1183 #define LINKTYPE_DSA_TAG_EDSA 285
1184
1185 /*
1186 * Payload of lawful intercept packets using the ELEE protocol;
1187 * https://socket.hr/draft-dfranusic-opsawg-elee-00.xml
1188 * https://xml2rfc.tools.ietf.org/cgi-bin/xml2rfc.cgi?url=https://socket.hr/draft-dfranusic-opsawg-elee-00.xml&modeAsFormat=html/ascii
1189 */
1190 #define LINKTYPE_ELEE 286
1191
1192 /*
1193 * Serial frames transmitted between a host and a Z-Wave chip.
1194 */
1195 #define LINKTYPE_Z_WAVE_SERIAL 287
1196
1197 /*
1198 * USB 2.0, 1.1, and 1.0 packets as transmitted over the cable.
1199 */
1200 #define LINKTYPE_USB_2_0 288
1201
1202 /*
1203 * ATSC Link-Layer Protocol (A/330) packets.
1204 */
1205 #define LINKTYPE_ATSC_ALP 289
1206
1207 #define LINKTYPE_MATCHING_MAX 289 /* highest value in the "matching" range */
1208
1209 /*
1210 * The DLT_ and LINKTYPE_ values in the "matching" range should be the
1211 * same, so DLT_MATCHING_MAX and LINKTYPE_MATCHING_MAX should be the
1212 * same.
1213 */
1214 #if LINKTYPE_MATCHING_MAX != DLT_MATCHING_MAX
1215 #error The LINKTYPE_ matching range does not match the DLT_ matching range
1216 #endif
1217
1218 static struct linktype_map {
1219 int dlt;
1220 int linktype;
1221 } map[] = {
1222 /*
1223 * These DLT_* codes have LINKTYPE_* codes with values identical
1224 * to the values of the corresponding DLT_* code.
1225 */
1226 { DLT_NULL, LINKTYPE_NULL },
1227 { DLT_EN10MB, LINKTYPE_ETHERNET },
1228 { DLT_EN3MB, LINKTYPE_EXP_ETHERNET },
1229 { DLT_AX25, LINKTYPE_AX25 },
1230 { DLT_PRONET, LINKTYPE_PRONET },
1231 { DLT_CHAOS, LINKTYPE_CHAOS },
1232 { DLT_IEEE802, LINKTYPE_IEEE802_5 },
1233 { DLT_ARCNET, LINKTYPE_ARCNET_BSD },
1234 { DLT_SLIP, LINKTYPE_SLIP },
1235 { DLT_PPP, LINKTYPE_PPP },
1236 { DLT_FDDI, LINKTYPE_FDDI },
1237 { DLT_SYMANTEC_FIREWALL, LINKTYPE_SYMANTEC_FIREWALL },
1238
1239 /*
1240 * These DLT_* codes have different values on different
1241 * platforms; we map them to LINKTYPE_* codes that
1242 * have values that should never be equal to any DLT_*
1243 * code.
1244 */
1245 #ifdef DLT_FR
1246 /* BSD/OS Frame Relay */
1247 { DLT_FR, LINKTYPE_FRELAY },
1248 #endif
1249
1250 { DLT_ATM_RFC1483, LINKTYPE_ATM_RFC1483 },
1251 { DLT_RAW, LINKTYPE_RAW },
1252 { DLT_SLIP_BSDOS, LINKTYPE_SLIP_BSDOS },
1253 { DLT_PPP_BSDOS, LINKTYPE_PPP_BSDOS },
1254 { DLT_HDLC, LINKTYPE_NETBSD_HDLC },
1255
1256 /* BSD/OS Cisco HDLC */
1257 { DLT_C_HDLC, LINKTYPE_C_HDLC },
1258
1259 /*
1260 * These DLT_* codes are not on all platforms, but, so far,
1261 * there don't appear to be any platforms that define
1262 * other codes with those values; we map them to
1263 * different LINKTYPE_* values anyway, just in case.
1264 */
1265
1266 /* Linux ATM Classical IP */
1267 { DLT_ATM_CLIP, LINKTYPE_ATM_CLIP },
1268
1269 /* NetBSD sync/async serial PPP (or Cisco HDLC) */
1270 { DLT_PPP_SERIAL, LINKTYPE_PPP_HDLC },
1271
1272 /* NetBSD PPP over Ethernet */
1273 { DLT_PPP_ETHER, LINKTYPE_PPP_ETHER },
1274
1275 /*
1276 * All LINKTYPE_ values between LINKTYPE_MATCHING_MIN
1277 * and LINKTYPE_MATCHING_MAX are mapped to identical
1278 * DLT_ values.
1279 */
1280
1281 { -1, -1 }
1282 };
1283
1284 int
1285 dlt_to_linktype(int dlt)
1286 {
1287 int i;
1288
1289 /*
1290 * DLTs that, on some platforms, have values in the matching range
1291 * but that *don't* have the same value as the corresponding
1292 * LINKTYPE because, for some reason, not all OSes have the
1293 * same value for that DLT (note that the DLT's value might be
1294 * outside the matching range on some of those OSes).
1295 */
1296 if (dlt == DLT_PFSYNC)
1297 return (LINKTYPE_PFSYNC);
1298 if (dlt == DLT_PKTAP)
1299 return (LINKTYPE_PKTAP);
1300
1301 /*
1302 * For all other values in the matching range, the DLT
1303 * value is the same as the LINKTYPE value.
1304 */
1305 if (dlt >= DLT_MATCHING_MIN && dlt <= DLT_MATCHING_MAX)
1306 return (dlt);
1307
1308 /*
1309 * Map the values outside that range.
1310 */
1311 for (i = 0; map[i].dlt != -1; i++) {
1312 if (map[i].dlt == dlt)
1313 return (map[i].linktype);
1314 }
1315
1316 /*
1317 * If we don't have a mapping for this DLT, return an
1318 * error; that means that this is a value with no corresponding
1319 * LINKTYPE, and we need to assign one.
1320 */
1321 return (-1);
1322 }
1323
1324 int
1325 linktype_to_dlt(int linktype)
1326 {
1327 int i;
1328
1329 /*
1330 * LINKTYPEs in the matching range that *don't*
1331 * have the same value as the corresponding DLTs
1332 * because, for some reason, not all OSes have the
1333 * same value for that DLT.
1334 */
1335 if (linktype == LINKTYPE_PFSYNC)
1336 return (DLT_PFSYNC);
1337 if (linktype == LINKTYPE_PKTAP)
1338 return (DLT_PKTAP);
1339
1340 /*
1341 * For all other values in the matching range, except for
1342 * LINKTYPE_ATM_CLIP, the LINKTYPE value is the same as
1343 * the DLT value.
1344 *
1345 * LINKTYPE_ATM_CLIP is a special case. DLT_ATM_CLIP is
1346 * not on all platforms, but, so far, there don't appear
1347 * to be any platforms that define it as anything other
1348 * than 19; we define LINKTYPE_ATM_CLIP as something
1349 * other than 19, just in case. That value is in the
1350 * matching range, so we have to check for it.
1351 */
1352 if (linktype >= LINKTYPE_MATCHING_MIN &&
1353 linktype <= LINKTYPE_MATCHING_MAX &&
1354 linktype != LINKTYPE_ATM_CLIP)
1355 return (linktype);
1356
1357 /*
1358 * Map the values outside that range.
1359 */
1360 for (i = 0; map[i].linktype != -1; i++) {
1361 if (map[i].linktype == linktype)
1362 return (map[i].dlt);
1363 }
1364
1365 /*
1366 * If we don't have an entry for this LINKTYPE, return
1367 * the link type value; it may be a DLT from an newer
1368 * version of libpcap.
1369 */
1370 return linktype;
1371 }
1372
1373 /*
1374 * Return the maximum snapshot length for a given DLT_ value.
1375 *
1376 * For most link-layer types, we use MAXIMUM_SNAPLEN.
1377 *
1378 * For DLT_DBUS, the maximum is 128MiB, as per
1379 *
1380 * https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-messages
1381 *
1382 * For DLT_EBHSCR, the maximum is 8MiB, as per
1383 *
1384 * https://www.elektrobit.com/ebhscr
1385 *
1386 * For DLT_USBPCAP, the maximum is 1MiB, as per
1387 *
1388 * https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=15985
1389 */
1390 u_int
1391 max_snaplen_for_dlt(int dlt)
1392 {
1393 switch (dlt) {
1394
1395 case DLT_DBUS:
1396 return 128*1024*1024;
1397
1398 case DLT_EBHSCR:
1399 return 8*1024*1024;
1400
1401 case DLT_USBPCAP:
1402 return 1024*1024;
1403
1404 default:
1405 return MAXIMUM_SNAPLEN;
1406 }
1407 }
1408
1409 /*
1410 * Most versions of the DLT_PFLOG pseudo-header have UID and PID fields
1411 * that are saved in host byte order.
1412 *
1413 * When reading a DLT_PFLOG packet, we need to convert those fields from
1414 * the byte order of the host that wrote the file to this host's byte
1415 * order.
1416 */
1417 static void
1418 swap_pflog_header(const struct pcap_pkthdr *hdr, u_char *buf)
1419 {
1420 u_int caplen = hdr->caplen;
1421 u_int length = hdr->len;
1422 u_int pfloghdr_length;
1423 struct pfloghdr *pflhdr = (struct pfloghdr *)buf;
1424
1425 if (caplen < (u_int) (offsetof(struct pfloghdr, uid) + sizeof pflhdr->uid) ||
1426 length < (u_int) (offsetof(struct pfloghdr, uid) + sizeof pflhdr->uid)) {
1427 /* Not enough data to have the uid field */
1428 return;
1429 }
1430
1431 pfloghdr_length = pflhdr->length;
1432
1433 if (pfloghdr_length < (u_int) (offsetof(struct pfloghdr, uid) + sizeof pflhdr->uid)) {
1434 /* Header doesn't include uid field */
1435 return;
1436 }
1437 pflhdr->uid = SWAPLONG(pflhdr->uid);
1438
1439 if (caplen < (u_int) (offsetof(struct pfloghdr, pid) + sizeof pflhdr->pid) ||
1440 length < (u_int) (offsetof(struct pfloghdr, pid) + sizeof pflhdr->pid)) {
1441 /* Not enough data to have the pid field */
1442 return;
1443 }
1444 if (pfloghdr_length < (u_int) (offsetof(struct pfloghdr, pid) + sizeof pflhdr->pid)) {
1445 /* Header doesn't include pid field */
1446 return;
1447 }
1448 pflhdr->pid = SWAPLONG(pflhdr->pid);
1449
1450 if (caplen < (u_int) (offsetof(struct pfloghdr, rule_uid) + sizeof pflhdr->rule_uid) ||
1451 length < (u_int) (offsetof(struct pfloghdr, rule_uid) + sizeof pflhdr->rule_uid)) {
1452 /* Not enough data to have the rule_uid field */
1453 return;
1454 }
1455 if (pfloghdr_length < (u_int) (offsetof(struct pfloghdr, rule_uid) + sizeof pflhdr->rule_uid)) {
1456 /* Header doesn't include rule_uid field */
1457 return;
1458 }
1459 pflhdr->rule_uid = SWAPLONG(pflhdr->rule_uid);
1460
1461 if (caplen < (u_int) (offsetof(struct pfloghdr, rule_pid) + sizeof pflhdr->rule_pid) ||
1462 length < (u_int) (offsetof(struct pfloghdr, rule_pid) + sizeof pflhdr->rule_pid)) {
1463 /* Not enough data to have the rule_pid field */
1464 return;
1465 }
1466 if (pfloghdr_length < (u_int) (offsetof(struct pfloghdr, rule_pid) + sizeof pflhdr->rule_pid)) {
1467 /* Header doesn't include rule_pid field */
1468 return;
1469 }
1470 pflhdr->rule_pid = SWAPLONG(pflhdr->rule_pid);
1471 }
1472
1473 /*
1474 * DLT_LINUX_SLL packets with a protocol type of LINUX_SLL_P_CAN or
1475 * LINUX_SLL_P_CANFD have SocketCAN headers in front of the payload,
1476 * with the CAN ID being in host byte order.
1477 *
1478 * When reading a DLT_LINUX_SLL packet, we need to check for those
1479 * packets and convert the CAN ID from the byte order of the host that
1480 * wrote the file to this host's byte order.
1481 */
1482 static void
1483 swap_linux_sll_header(const struct pcap_pkthdr *hdr, u_char *buf)
1484 {
1485 u_int caplen = hdr->caplen;
1486 u_int length = hdr->len;
1487 struct sll_header *shdr = (struct sll_header *)buf;
1488 uint16_t protocol;
1489 pcap_can_socketcan_hdr *chdr;
1490
1491 if (caplen < (u_int) sizeof(struct sll_header) ||
1492 length < (u_int) sizeof(struct sll_header)) {
1493 /* Not enough data to have the protocol field */
1494 return;
1495 }
1496
1497 protocol = EXTRACT_BE_U_2(&shdr->sll_protocol);
1498 if (protocol != LINUX_SLL_P_CAN && protocol != LINUX_SLL_P_CANFD)
1499 return;
1500
1501 /*
1502 * SocketCAN packet; fix up the packet's header.
1503 */
1504 chdr = (pcap_can_socketcan_hdr *)(buf + sizeof(struct sll_header));
1505 if (caplen < (u_int) sizeof(struct sll_header) + sizeof(chdr->can_id) ||
1506 length < (u_int) sizeof(struct sll_header) + sizeof(chdr->can_id)) {
1507 /* Not enough data to have the CAN ID */
1508 return;
1509 }
1510 chdr->can_id = SWAPLONG(chdr->can_id);
1511 }
1512
1513 /*
1514 * The same applies for DLT_LINUX_SLL2.
1515 */
1516 static void
1517 swap_linux_sll2_header(const struct pcap_pkthdr *hdr, u_char *buf)
1518 {
1519 u_int caplen = hdr->caplen;
1520 u_int length = hdr->len;
1521 struct sll2_header *shdr = (struct sll2_header *)buf;
1522 uint16_t protocol;
1523 pcap_can_socketcan_hdr *chdr;
1524
1525 if (caplen < (u_int) sizeof(struct sll2_header) ||
1526 length < (u_int) sizeof(struct sll2_header)) {
1527 /* Not enough data to have the protocol field */
1528 return;
1529 }
1530
1531 protocol = EXTRACT_BE_U_2(&shdr->sll2_protocol);
1532 if (protocol != LINUX_SLL_P_CAN && protocol != LINUX_SLL_P_CANFD)
1533 return;
1534
1535 /*
1536 * SocketCAN packet; fix up the packet's header.
1537 */
1538 chdr = (pcap_can_socketcan_hdr *)(buf + sizeof(struct sll2_header));
1539 if (caplen < (u_int) sizeof(struct sll2_header) + sizeof(chdr->can_id) ||
1540 length < (u_int) sizeof(struct sll2_header) + sizeof(chdr->can_id)) {
1541 /* Not enough data to have the CAN ID */
1542 return;
1543 }
1544 chdr->can_id = SWAPLONG(chdr->can_id);
1545 }
1546
1547 /*
1548 * The DLT_USB_LINUX and DLT_USB_LINUX_MMAPPED headers are in host
1549 * byte order when capturing (it's supplied directly from a
1550 * memory-mapped buffer shared by the kernel).
1551 *
1552 * When reading a DLT_USB_LINUX or DLT_USB_LINUX_MMAPPED packet, we
1553 * need to convert it from the byte order of the host that wrote the
1554 * file to this host's byte order.
1555 */
1556 static void
1557 swap_linux_usb_header(const struct pcap_pkthdr *hdr, u_char *buf,
1558 int header_len_64_bytes)
1559 {
1560 pcap_usb_header_mmapped *uhdr = (pcap_usb_header_mmapped *)buf;
1561 bpf_u_int32 offset = 0;
1562
1563 /*
1564 * "offset" is the offset *past* the field we're swapping;
1565 * we skip the field *before* checking to make sure
1566 * the captured data length includes the entire field.
1567 */
1568
1569 /*
1570 * The URB id is a totally opaque value; do we really need to
1571 * convert it to the reading host's byte order???
1572 */
1573 offset += 8; /* skip past id */
1574 if (hdr->caplen < offset)
1575 return;
1576 uhdr->id = SWAPLL(uhdr->id);
1577
1578 offset += 4; /* skip past various 1-byte fields */
1579
1580 offset += 2; /* skip past bus_id */
1581 if (hdr->caplen < offset)
1582 return;
1583 uhdr->bus_id = SWAPSHORT(uhdr->bus_id);
1584
1585 offset += 2; /* skip past various 1-byte fields */
1586
1587 offset += 8; /* skip past ts_sec */
1588 if (hdr->caplen < offset)
1589 return;
1590 uhdr->ts_sec = SWAPLL(uhdr->ts_sec);
1591
1592 offset += 4; /* skip past ts_usec */
1593 if (hdr->caplen < offset)
1594 return;
1595 uhdr->ts_usec = SWAPLONG(uhdr->ts_usec);
1596
1597 offset += 4; /* skip past status */
1598 if (hdr->caplen < offset)
1599 return;
1600 uhdr->status = SWAPLONG(uhdr->status);
1601
1602 offset += 4; /* skip past urb_len */
1603 if (hdr->caplen < offset)
1604 return;
1605 uhdr->urb_len = SWAPLONG(uhdr->urb_len);
1606
1607 offset += 4; /* skip past data_len */
1608 if (hdr->caplen < offset)
1609 return;
1610 uhdr->data_len = SWAPLONG(uhdr->data_len);
1611
1612 if (uhdr->transfer_type == URB_ISOCHRONOUS) {
1613 offset += 4; /* skip past s.iso.error_count */
1614 if (hdr->caplen < offset)
1615 return;
1616 uhdr->s.iso.error_count = SWAPLONG(uhdr->s.iso.error_count);
1617
1618 offset += 4; /* skip past s.iso.numdesc */
1619 if (hdr->caplen < offset)
1620 return;
1621 uhdr->s.iso.numdesc = SWAPLONG(uhdr->s.iso.numdesc);
1622 } else
1623 offset += 8; /* skip USB setup header */
1624
1625 /*
1626 * With the old header, there are no isochronous descriptors
1627 * after the header.
1628 *
1629 * With the new header, the actual number of descriptors in
1630 * the header is not s.iso.numdesc, it's ndesc - only the
1631 * first N descriptors, for some value of N, are put into
1632 * the header, and ndesc is set to the actual number copied.
1633 * In addition, if s.iso.numdesc is negative, no descriptors
1634 * are captured, and ndesc is set to 0.
1635 */
1636 if (header_len_64_bytes) {
1637 /*
1638 * This is either the "version 1" header, with
1639 * 16 bytes of additional fields at the end, or
1640 * a "version 0" header from a memory-mapped
1641 * capture, with 16 bytes of zeroed-out padding
1642 * at the end. Byte swap them as if this were
1643 * a "version 1" header.
1644 */
1645 offset += 4; /* skip past interval */
1646 if (hdr->caplen < offset)
1647 return;
1648 uhdr->interval = SWAPLONG(uhdr->interval);
1649
1650 offset += 4; /* skip past start_frame */
1651 if (hdr->caplen < offset)
1652 return;
1653 uhdr->start_frame = SWAPLONG(uhdr->start_frame);
1654
1655 offset += 4; /* skip past xfer_flags */
1656 if (hdr->caplen < offset)
1657 return;
1658 uhdr->xfer_flags = SWAPLONG(uhdr->xfer_flags);
1659
1660 offset += 4; /* skip past ndesc */
1661 if (hdr->caplen < offset)
1662 return;
1663 uhdr->ndesc = SWAPLONG(uhdr->ndesc);
1664
1665 if (uhdr->transfer_type == URB_ISOCHRONOUS) {
1666 /* swap the values in struct linux_usb_isodesc */
1667 usb_isodesc *pisodesc;
1668 uint32_t i;
1669
1670 pisodesc = (usb_isodesc *)(void *)(buf+offset);
1671 for (i = 0; i < uhdr->ndesc; i++) {
1672 offset += 4; /* skip past status */
1673 if (hdr->caplen < offset)
1674 return;
1675 pisodesc->status = SWAPLONG(pisodesc->status);
1676
1677 offset += 4; /* skip past offset */
1678 if (hdr->caplen < offset)
1679 return;
1680 pisodesc->offset = SWAPLONG(pisodesc->offset);
1681
1682 offset += 4; /* skip past len */
1683 if (hdr->caplen < offset)
1684 return;
1685 pisodesc->len = SWAPLONG(pisodesc->len);
1686
1687 offset += 4; /* skip past padding */
1688
1689 pisodesc++;
1690 }
1691 }
1692 }
1693 }
1694
1695 /*
1696 * The DLT_NFLOG "packets" have a mixture of big-endian and host-byte-order
1697 * data. They begin with a fixed-length header with big-endian fields,
1698 * followed by a set of TLVs, where the type and length are in host
1699 * byte order but the values are either big-endian or are a raw byte
1700 * sequence that's the same regardless of the host's byte order.
1701 *
1702 * When reading a DLT_NFLOG packet, we need to convert the type and
1703 * length values from the byte order of the host that wrote the file
1704 * to the byte order of this host.
1705 */
1706 static void
1707 swap_nflog_header(const struct pcap_pkthdr *hdr, u_char *buf)
1708 {
1709 u_char *p = buf;
1710 nflog_hdr_t *nfhdr = (nflog_hdr_t *)buf;
1711 nflog_tlv_t *tlv;
1712 u_int caplen = hdr->caplen;
1713 u_int length = hdr->len;
1714 uint16_t size;
1715
1716 if (caplen < (u_int) sizeof(nflog_hdr_t) ||
1717 length < (u_int) sizeof(nflog_hdr_t)) {
1718 /* Not enough data to have any TLVs. */
1719 return;
1720 }
1721
1722 if (nfhdr->nflog_version != 0) {
1723 /* Unknown NFLOG version */
1724 return;
1725 }
1726
1727 length -= sizeof(nflog_hdr_t);
1728 caplen -= sizeof(nflog_hdr_t);
1729 p += sizeof(nflog_hdr_t);
1730
1731 while (caplen >= sizeof(nflog_tlv_t)) {
1732 tlv = (nflog_tlv_t *) p;
1733
1734 /* Swap the type and length. */
1735 tlv->tlv_type = SWAPSHORT(tlv->tlv_type);
1736 tlv->tlv_length = SWAPSHORT(tlv->tlv_length);
1737
1738 /* Get the length of the TLV. */
1739 size = tlv->tlv_length;
1740 if (size % 4 != 0)
1741 size += 4 - size % 4;
1742
1743 /* Is the TLV's length less than the minimum? */
1744 if (size < sizeof(nflog_tlv_t)) {
1745 /* Yes. Give up now. */
1746 return;
1747 }
1748
1749 /* Do we have enough data for the full TLV? */
1750 if (caplen < size || length < size) {
1751 /* No. */
1752 return;
1753 }
1754
1755 /* Skip over the TLV. */
1756 length -= size;
1757 caplen -= size;
1758 p += size;
1759 }
1760 }
1761
1762 void
1763 swap_pseudo_headers(int linktype, struct pcap_pkthdr *hdr, u_char *data)
1764 {
1765 /*
1766 * Convert pseudo-headers from the byte order of
1767 * the host on which the file was saved to our
1768 * byte order, as necessary.
1769 */
1770 switch (linktype) {
1771
1772 case DLT_PFLOG:
1773 swap_pflog_header(hdr, data);
1774 break;
1775
1776 case DLT_LINUX_SLL:
1777 swap_linux_sll_header(hdr, data);
1778 break;
1779
1780 case DLT_LINUX_SLL2:
1781 swap_linux_sll2_header(hdr, data);
1782 break;
1783
1784 case DLT_USB_LINUX:
1785 swap_linux_usb_header(hdr, data, 0);
1786 break;
1787
1788 case DLT_USB_LINUX_MMAPPED:
1789 swap_linux_usb_header(hdr, data, 1);
1790 break;
1791
1792 case DLT_NFLOG:
1793 swap_nflog_header(hdr, data);
1794 break;
1795 }
1796 }
1797
1798 void
1799 fixup_pcap_pkthdr(int linktype, struct pcap_pkthdr *hdr, u_char *data)
1800 {
1801 if (linktype == DLT_USB_LINUX_MMAPPED) {
1802 /*
1803 * In older versions of libpcap, in memory-mapped captures,
1804 * the "on-the-bus length" for isochronous transfers was
1805 * miscalculated; it needed to be calculated based on the
1806 * offsets and lengths in the descriptors, not on the raw
1807 * URB length, but it wasn't. Recalculate it from the
1808 * packet data.
1809 */
1810 set_linux_usb_mmapped_length(hdr, data);
1811 }
1812 }