1a85e14b0SPeter Avalos /*
2a85e14b0SPeter Avalos * Copyright (c) 1993, 1994, 1995, 1996, 1997
3a85e14b0SPeter Avalos * The Regents of the University of California. All rights reserved.
4a85e14b0SPeter Avalos *
5a85e14b0SPeter Avalos * Redistribution and use in source and binary forms, with or without
6a85e14b0SPeter Avalos * modification, are permitted provided that: (1) source code distributions
7a85e14b0SPeter Avalos * retain the above copyright notice and this paragraph in its entirety, (2)
8a85e14b0SPeter Avalos * distributions including binary code include the above copyright notice and
9a85e14b0SPeter Avalos * this paragraph in its entirety in the documentation or other materials
10a85e14b0SPeter Avalos * provided with the distribution, and (3) all advertising materials mentioning
11a85e14b0SPeter Avalos * features or use of this software display the following acknowledgement:
12a85e14b0SPeter Avalos * ``This product includes software developed by the University of California,
13a85e14b0SPeter Avalos * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14a85e14b0SPeter Avalos * the University nor the names of its contributors may be used to endorse
15a85e14b0SPeter Avalos * or promote products derived from this software without specific prior
16a85e14b0SPeter Avalos * written permission.
17a85e14b0SPeter Avalos * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18a85e14b0SPeter Avalos * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19a85e14b0SPeter Avalos * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20a85e14b0SPeter Avalos *
213a289941SAaron LI * pcap-common.c - common code for pcap and pcapng files
22a85e14b0SPeter Avalos */
23a85e14b0SPeter Avalos
24a85e14b0SPeter Avalos #ifdef HAVE_CONFIG_H
253a289941SAaron LI #include <config.h>
26a85e14b0SPeter Avalos #endif
27a85e14b0SPeter Avalos
283a289941SAaron LI #include <pcap-types.h>
29a85e14b0SPeter Avalos
30a85e14b0SPeter Avalos #include "pcap-int.h"
3197a9217aSAntonio Huete Jimenez #include "extract.h"
3297a9217aSAntonio Huete Jimenez #include "pcap/sll.h"
33a85e14b0SPeter Avalos #include "pcap/usb.h"
3497a9217aSAntonio Huete Jimenez #include "pcap/nflog.h"
3597a9217aSAntonio Huete Jimenez #include "pcap/can_socketcan.h"
36a85e14b0SPeter Avalos
37a85e14b0SPeter Avalos #include "pcap-common.h"
38a85e14b0SPeter Avalos
39a85e14b0SPeter Avalos /*
40a85e14b0SPeter Avalos * We don't write DLT_* values to capture files, because they're not the
41a85e14b0SPeter Avalos * same on all platforms.
42a85e14b0SPeter Avalos *
43a85e14b0SPeter Avalos * Unfortunately, the various flavors of BSD have not always used the same
44a85e14b0SPeter Avalos * numerical values for the same data types, and various patches to
45a85e14b0SPeter Avalos * libpcap for non-BSD OSes have added their own DLT_* codes for link
46a85e14b0SPeter Avalos * layer encapsulation types seen on those OSes, and those codes have had,
47a85e14b0SPeter Avalos * in some cases, values that were also used, on other platforms, for other
48a85e14b0SPeter Avalos * link layer encapsulation types.
49a85e14b0SPeter Avalos *
50a85e14b0SPeter Avalos * This means that capture files of a type whose numerical DLT_* code
51a85e14b0SPeter Avalos * means different things on different BSDs, or with different versions
52a85e14b0SPeter Avalos * of libpcap, can't always be read on systems other than those like
53a85e14b0SPeter Avalos * the one running on the machine on which the capture was made.
54a85e14b0SPeter Avalos *
55a85e14b0SPeter Avalos * Instead, we define here a set of LINKTYPE_* codes, and map DLT_* codes
56a85e14b0SPeter Avalos * to LINKTYPE_* codes when writing a savefile header, and map LINKTYPE_*
57a85e14b0SPeter Avalos * codes to DLT_* codes when reading a savefile header.
58a85e14b0SPeter Avalos *
59a85e14b0SPeter Avalos * For those DLT_* codes that have, as far as we know, the same values on
60a85e14b0SPeter Avalos * all platforms (DLT_NULL through DLT_FDDI), we define LINKTYPE_xxx as
61a85e14b0SPeter Avalos * DLT_xxx; that way, captures of those types can still be read by
62a85e14b0SPeter Avalos * versions of libpcap that map LINKTYPE_* values to DLT_* values, and
63a85e14b0SPeter Avalos * captures of those types written by versions of libpcap that map DLT_
64a85e14b0SPeter Avalos * values to LINKTYPE_ values can still be read by older versions
65a85e14b0SPeter Avalos * of libpcap.
66a85e14b0SPeter Avalos *
67a85e14b0SPeter Avalos * The other LINKTYPE_* codes are given values starting at 100, in the
68a85e14b0SPeter Avalos * hopes that no DLT_* code will be given one of those values.
69a85e14b0SPeter Avalos *
70a85e14b0SPeter Avalos * In order to ensure that a given LINKTYPE_* code's value will refer to
71a85e14b0SPeter Avalos * the same encapsulation type on all platforms, you should not allocate
72a85e14b0SPeter Avalos * a new LINKTYPE_* value without consulting
73a85e14b0SPeter Avalos * "tcpdump-workers@lists.tcpdump.org". The tcpdump developers will
74a85e14b0SPeter Avalos * allocate a value for you, and will not subsequently allocate it to
75a85e14b0SPeter Avalos * anybody else; that value will be added to the "pcap.h" in the
76a85e14b0SPeter Avalos * tcpdump.org Git repository, so that a future libpcap release will
77a85e14b0SPeter Avalos * include it.
78a85e14b0SPeter Avalos *
79a85e14b0SPeter Avalos * You should, if possible, also contribute patches to libpcap and tcpdump
80a85e14b0SPeter Avalos * to handle the new encapsulation type, so that they can also be checked
81a85e14b0SPeter Avalos * into the tcpdump.org Git repository and so that they will appear in
82a85e14b0SPeter Avalos * future libpcap and tcpdump releases.
83a85e14b0SPeter Avalos *
84a85e14b0SPeter Avalos * Do *NOT* assume that any values after the largest value in this file
85a85e14b0SPeter Avalos * are available; you might not have the most up-to-date version of this
86a85e14b0SPeter Avalos * file, and new values after that one might have been assigned. Also,
87a85e14b0SPeter Avalos * do *NOT* use any values below 100 - those might already have been
88a85e14b0SPeter Avalos * taken by one (or more!) organizations.
89a85e14b0SPeter Avalos *
90a85e14b0SPeter Avalos * Any platform that defines additional DLT_* codes should:
91a85e14b0SPeter Avalos *
92a85e14b0SPeter Avalos * request a LINKTYPE_* code and value from tcpdump.org,
93a85e14b0SPeter Avalos * as per the above;
94a85e14b0SPeter Avalos *
95a85e14b0SPeter Avalos * add, in their version of libpcap, an entry to map
96a85e14b0SPeter Avalos * those DLT_* codes to the corresponding LINKTYPE_*
97a85e14b0SPeter Avalos * code;
98a85e14b0SPeter Avalos *
99a85e14b0SPeter Avalos * redefine, in their "net/bpf.h", any DLT_* values
100a85e14b0SPeter Avalos * that collide with the values used by their additional
101a85e14b0SPeter Avalos * DLT_* codes, to remove those collisions (but without
102a85e14b0SPeter Avalos * making them collide with any of the LINKTYPE_*
103a85e14b0SPeter Avalos * values equal to 50 or above; they should also avoid
104a85e14b0SPeter Avalos * defining DLT_* values that collide with those
105a85e14b0SPeter Avalos * LINKTYPE_* values, either).
106a85e14b0SPeter Avalos */
107a85e14b0SPeter Avalos #define LINKTYPE_NULL DLT_NULL
108a85e14b0SPeter Avalos #define LINKTYPE_ETHERNET DLT_EN10MB /* also for 100Mb and up */
109a85e14b0SPeter Avalos #define LINKTYPE_EXP_ETHERNET DLT_EN3MB /* 3Mb experimental Ethernet */
110a85e14b0SPeter Avalos #define LINKTYPE_AX25 DLT_AX25
111a85e14b0SPeter Avalos #define LINKTYPE_PRONET DLT_PRONET
112a85e14b0SPeter Avalos #define LINKTYPE_CHAOS DLT_CHAOS
1130e1eae1fSPeter Avalos #define LINKTYPE_IEEE802_5 DLT_IEEE802 /* DLT_IEEE802 is used for 802.5 Token Ring */
114a85e14b0SPeter Avalos #define LINKTYPE_ARCNET_BSD DLT_ARCNET /* BSD-style headers */
115a85e14b0SPeter Avalos #define LINKTYPE_SLIP DLT_SLIP
116a85e14b0SPeter Avalos #define LINKTYPE_PPP DLT_PPP
117a85e14b0SPeter Avalos #define LINKTYPE_FDDI DLT_FDDI
118a85e14b0SPeter Avalos
119a85e14b0SPeter Avalos /*
120a85e14b0SPeter Avalos * LINKTYPE_PPP is for use when there might, or might not, be an RFC 1662
121a85e14b0SPeter Avalos * PPP in HDLC-like framing header (with 0xff 0x03 before the PPP protocol
122a85e14b0SPeter Avalos * field) at the beginning of the packet.
123a85e14b0SPeter Avalos *
124a85e14b0SPeter Avalos * This is for use when there is always such a header; the address field
125a85e14b0SPeter Avalos * might be 0xff, for regular PPP, or it might be an address field for Cisco
126a85e14b0SPeter Avalos * point-to-point with HDLC framing as per section 4.3.1 of RFC 1547 ("Cisco
127a85e14b0SPeter Avalos * HDLC"). This is, for example, what you get with NetBSD's DLT_PPP_SERIAL.
128a85e14b0SPeter Avalos *
129a85e14b0SPeter Avalos * We give it the same value as NetBSD's DLT_PPP_SERIAL, in the hopes that
130a85e14b0SPeter Avalos * nobody else will choose a DLT_ value of 50, and so that DLT_PPP_SERIAL
131a85e14b0SPeter Avalos * captures will be written out with a link type that NetBSD's tcpdump
132a85e14b0SPeter Avalos * can read.
133a85e14b0SPeter Avalos */
134a85e14b0SPeter Avalos #define LINKTYPE_PPP_HDLC 50 /* PPP in HDLC-like framing */
135a85e14b0SPeter Avalos
136a85e14b0SPeter Avalos #define LINKTYPE_PPP_ETHER 51 /* NetBSD PPP-over-Ethernet */
137a85e14b0SPeter Avalos
138a85e14b0SPeter Avalos #define LINKTYPE_SYMANTEC_FIREWALL 99 /* Symantec Enterprise Firewall */
139a85e14b0SPeter Avalos
140a85e14b0SPeter Avalos /*
141a85e14b0SPeter Avalos * These correspond to DLT_s that have different values on different
142a85e14b0SPeter Avalos * platforms; we map between these values in capture files and
143a85e14b0SPeter Avalos * the DLT_ values as returned by pcap_datalink() and passed to
144a85e14b0SPeter Avalos * pcap_open_dead().
145a85e14b0SPeter Avalos */
146a85e14b0SPeter Avalos #define LINKTYPE_ATM_RFC1483 100 /* LLC/SNAP-encapsulated ATM */
147a85e14b0SPeter Avalos #define LINKTYPE_RAW 101 /* raw IP */
148a85e14b0SPeter Avalos #define LINKTYPE_SLIP_BSDOS 102 /* BSD/OS SLIP BPF header */
149a85e14b0SPeter Avalos #define LINKTYPE_PPP_BSDOS 103 /* BSD/OS PPP BPF header */
150a85e14b0SPeter Avalos
151a85e14b0SPeter Avalos /*
152a85e14b0SPeter Avalos * Values starting with 104 are used for newly-assigned link-layer
153a85e14b0SPeter Avalos * header type values; for those link-layer header types, the DLT_
154a85e14b0SPeter Avalos * value returned by pcap_datalink() and passed to pcap_open_dead(),
155a85e14b0SPeter Avalos * and the LINKTYPE_ value that appears in capture files, are the
156a85e14b0SPeter Avalos * same.
157a85e14b0SPeter Avalos *
158a85e14b0SPeter Avalos * LINKTYPE_MATCHING_MIN is the lowest such value; LINKTYPE_MATCHING_MAX
159a85e14b0SPeter Avalos * is the highest such value.
160a85e14b0SPeter Avalos */
161a85e14b0SPeter Avalos #define LINKTYPE_MATCHING_MIN 104 /* lowest value in the "matching" range */
162a85e14b0SPeter Avalos
163a85e14b0SPeter Avalos #define LINKTYPE_C_HDLC 104 /* Cisco HDLC */
164a85e14b0SPeter Avalos #define LINKTYPE_IEEE802_11 105 /* IEEE 802.11 (wireless) */
165a85e14b0SPeter Avalos #define LINKTYPE_ATM_CLIP 106 /* Linux Classical IP over ATM */
166a85e14b0SPeter Avalos #define LINKTYPE_FRELAY 107 /* Frame Relay */
167a85e14b0SPeter Avalos #define LINKTYPE_LOOP 108 /* OpenBSD loopback */
168a85e14b0SPeter Avalos #define LINKTYPE_ENC 109 /* OpenBSD IPSEC enc */
169a85e14b0SPeter Avalos
170a85e14b0SPeter Avalos /*
171a85e14b0SPeter Avalos * These three types are reserved for future use.
172a85e14b0SPeter Avalos */
173a85e14b0SPeter Avalos #define LINKTYPE_LANE8023 110 /* ATM LANE + 802.3 */
174a85e14b0SPeter Avalos #define LINKTYPE_HIPPI 111 /* NetBSD HIPPI */
175a85e14b0SPeter Avalos #define LINKTYPE_HDLC 112 /* NetBSD HDLC framing */
176a85e14b0SPeter Avalos
177a85e14b0SPeter Avalos #define LINKTYPE_LINUX_SLL 113 /* Linux cooked socket capture */
178a85e14b0SPeter Avalos #define LINKTYPE_LTALK 114 /* Apple LocalTalk hardware */
179a85e14b0SPeter Avalos #define LINKTYPE_ECONET 115 /* Acorn Econet */
180a85e14b0SPeter Avalos
181a85e14b0SPeter Avalos /*
182a85e14b0SPeter Avalos * Reserved for use with OpenBSD ipfilter.
183a85e14b0SPeter Avalos */
184a85e14b0SPeter Avalos #define LINKTYPE_IPFILTER 116
185a85e14b0SPeter Avalos
186a85e14b0SPeter Avalos #define LINKTYPE_PFLOG 117 /* OpenBSD DLT_PFLOG */
187a85e14b0SPeter Avalos #define LINKTYPE_CISCO_IOS 118 /* For Cisco-internal use */
1880e1eae1fSPeter Avalos #define LINKTYPE_IEEE802_11_PRISM 119 /* 802.11 plus Prism II monitor mode radio metadata header */
1890e1eae1fSPeter Avalos #define LINKTYPE_IEEE802_11_AIRONET 120 /* 802.11 plus FreeBSD Aironet driver radio metadata header */
190a85e14b0SPeter Avalos
191a85e14b0SPeter Avalos /*
192a85e14b0SPeter Avalos * Reserved for Siemens HiPath HDLC.
193a85e14b0SPeter Avalos */
194a85e14b0SPeter Avalos #define LINKTYPE_HHDLC 121
195a85e14b0SPeter Avalos
196a85e14b0SPeter Avalos #define LINKTYPE_IP_OVER_FC 122 /* RFC 2625 IP-over-Fibre Channel */
197a85e14b0SPeter Avalos #define LINKTYPE_SUNATM 123 /* Solaris+SunATM */
198a85e14b0SPeter Avalos
199a85e14b0SPeter Avalos /*
200a85e14b0SPeter Avalos * Reserved as per request from Kent Dahlgren <kent@praesum.com>
201a85e14b0SPeter Avalos * for private use.
202a85e14b0SPeter Avalos */
203a85e14b0SPeter Avalos #define LINKTYPE_RIO 124 /* RapidIO */
204a85e14b0SPeter Avalos #define LINKTYPE_PCI_EXP 125 /* PCI Express */
205a85e14b0SPeter Avalos #define LINKTYPE_AURORA 126 /* Xilinx Aurora link layer */
206a85e14b0SPeter Avalos
2070e1eae1fSPeter Avalos #define LINKTYPE_IEEE802_11_RADIOTAP 127 /* 802.11 plus radiotap radio metadata header */
208a85e14b0SPeter Avalos
209a85e14b0SPeter Avalos /*
210a85e14b0SPeter Avalos * Reserved for the TZSP encapsulation, as per request from
211a85e14b0SPeter Avalos * Chris Waters <chris.waters@networkchemistry.com>
212a85e14b0SPeter Avalos * TZSP is a generic encapsulation for any other link type,
213a85e14b0SPeter Avalos * which includes a means to include meta-information
214a85e14b0SPeter Avalos * with the packet, e.g. signal strength and channel
215a85e14b0SPeter Avalos * for 802.11 packets.
216a85e14b0SPeter Avalos */
217a85e14b0SPeter Avalos #define LINKTYPE_TZSP 128 /* Tazmen Sniffer Protocol */
218a85e14b0SPeter Avalos
219a85e14b0SPeter Avalos #define LINKTYPE_ARCNET_LINUX 129 /* Linux-style headers */
220a85e14b0SPeter Avalos
221a85e14b0SPeter Avalos /*
222a85e14b0SPeter Avalos * Juniper-private data link types, as per request from
223a85e14b0SPeter Avalos * Hannes Gredler <hannes@juniper.net>. The corresponding
224a85e14b0SPeter Avalos * DLT_s are used for passing on chassis-internal
225a85e14b0SPeter Avalos * metainformation such as QOS profiles, etc..
226a85e14b0SPeter Avalos */
227a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_MLPPP 130
228a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_MLFR 131
229a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_ES 132
230a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_GGSN 133
231a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_MFR 134
232a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_ATM2 135
233a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_SERVICES 136
234a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_ATM1 137
235a85e14b0SPeter Avalos
236a85e14b0SPeter Avalos #define LINKTYPE_APPLE_IP_OVER_IEEE1394 138 /* Apple IP-over-IEEE 1394 cooked header */
237a85e14b0SPeter Avalos
238a85e14b0SPeter Avalos #define LINKTYPE_MTP2_WITH_PHDR 139
239a85e14b0SPeter Avalos #define LINKTYPE_MTP2 140
240a85e14b0SPeter Avalos #define LINKTYPE_MTP3 141
241a85e14b0SPeter Avalos #define LINKTYPE_SCCP 142
242a85e14b0SPeter Avalos
243a85e14b0SPeter Avalos #define LINKTYPE_DOCSIS 143 /* DOCSIS MAC frames */
244a85e14b0SPeter Avalos
245a85e14b0SPeter Avalos #define LINKTYPE_LINUX_IRDA 144 /* Linux-IrDA */
246a85e14b0SPeter Avalos
247a85e14b0SPeter Avalos /*
248a85e14b0SPeter Avalos * Reserved for IBM SP switch and IBM Next Federation switch.
249a85e14b0SPeter Avalos */
250a85e14b0SPeter Avalos #define LINKTYPE_IBM_SP 145
251a85e14b0SPeter Avalos #define LINKTYPE_IBM_SN 146
252a85e14b0SPeter Avalos
253a85e14b0SPeter Avalos /*
254a85e14b0SPeter Avalos * Reserved for private use. If you have some link-layer header type
255a85e14b0SPeter Avalos * that you want to use within your organization, with the capture files
256a85e14b0SPeter Avalos * using that link-layer header type not ever be sent outside your
257a85e14b0SPeter Avalos * organization, you can use these values.
258a85e14b0SPeter Avalos *
259a85e14b0SPeter Avalos * No libpcap release will use these for any purpose, nor will any
260a85e14b0SPeter Avalos * tcpdump release use them, either.
261a85e14b0SPeter Avalos *
262a85e14b0SPeter Avalos * Do *NOT* use these in capture files that you expect anybody not using
263a85e14b0SPeter Avalos * your private versions of capture-file-reading tools to read; in
264a85e14b0SPeter Avalos * particular, do *NOT* use them in products, otherwise you may find that
265a85e14b0SPeter Avalos * people won't be able to use tcpdump, or snort, or Ethereal, or... to
266a85e14b0SPeter Avalos * read capture files from your firewall/intrusion detection/traffic
267a85e14b0SPeter Avalos * monitoring/etc. appliance, or whatever product uses that LINKTYPE_ value,
268a85e14b0SPeter Avalos * and you may also find that the developers of those applications will
269a85e14b0SPeter Avalos * not accept patches to let them read those files.
270a85e14b0SPeter Avalos *
271a85e14b0SPeter Avalos * Also, do not use them if somebody might send you a capture using them
272a85e14b0SPeter Avalos * for *their* private type and tools using them for *your* private type
273a85e14b0SPeter Avalos * would have to read them.
274a85e14b0SPeter Avalos *
275a85e14b0SPeter Avalos * Instead, in those cases, ask "tcpdump-workers@lists.tcpdump.org" for a
276a85e14b0SPeter Avalos * new DLT_ and LINKTYPE_ value, as per the comment in pcap/bpf.h, and use
277a85e14b0SPeter Avalos * the type you're given.
278a85e14b0SPeter Avalos */
279a85e14b0SPeter Avalos #define LINKTYPE_USER0 147
280a85e14b0SPeter Avalos #define LINKTYPE_USER1 148
281a85e14b0SPeter Avalos #define LINKTYPE_USER2 149
282a85e14b0SPeter Avalos #define LINKTYPE_USER3 150
283a85e14b0SPeter Avalos #define LINKTYPE_USER4 151
284a85e14b0SPeter Avalos #define LINKTYPE_USER5 152
285a85e14b0SPeter Avalos #define LINKTYPE_USER6 153
286a85e14b0SPeter Avalos #define LINKTYPE_USER7 154
287a85e14b0SPeter Avalos #define LINKTYPE_USER8 155
288a85e14b0SPeter Avalos #define LINKTYPE_USER9 156
289a85e14b0SPeter Avalos #define LINKTYPE_USER10 157
290a85e14b0SPeter Avalos #define LINKTYPE_USER11 158
291a85e14b0SPeter Avalos #define LINKTYPE_USER12 159
292a85e14b0SPeter Avalos #define LINKTYPE_USER13 160
293a85e14b0SPeter Avalos #define LINKTYPE_USER14 161
294a85e14b0SPeter Avalos #define LINKTYPE_USER15 162
295a85e14b0SPeter Avalos
296a85e14b0SPeter Avalos /*
297a85e14b0SPeter Avalos * For future use with 802.11 captures - defined by AbsoluteValue
298a85e14b0SPeter Avalos * Systems to store a number of bits of link-layer information
299a85e14b0SPeter Avalos * including radio information:
300a85e14b0SPeter Avalos *
301a85e14b0SPeter Avalos * http://www.shaftnet.org/~pizza/software/capturefrm.txt
302a85e14b0SPeter Avalos */
3030e1eae1fSPeter Avalos #define LINKTYPE_IEEE802_11_AVS 163 /* 802.11 plus AVS radio metadata header */
304a85e14b0SPeter Avalos
305a85e14b0SPeter Avalos /*
306a85e14b0SPeter Avalos * Juniper-private data link type, as per request from
307a85e14b0SPeter Avalos * Hannes Gredler <hannes@juniper.net>. The corresponding
308a85e14b0SPeter Avalos * DLT_s are used for passing on chassis-internal
309a85e14b0SPeter Avalos * metainformation such as QOS profiles, etc..
310a85e14b0SPeter Avalos */
311a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_MONITOR 164
312a85e14b0SPeter Avalos
313a85e14b0SPeter Avalos /*
3140e1eae1fSPeter Avalos * BACnet MS/TP frames.
315a85e14b0SPeter Avalos */
316a85e14b0SPeter Avalos #define LINKTYPE_BACNET_MS_TP 165
317a85e14b0SPeter Avalos
318a85e14b0SPeter Avalos /*
319a85e14b0SPeter Avalos * Another PPP variant as per request from Karsten Keil <kkeil@suse.de>.
320a85e14b0SPeter Avalos *
321a85e14b0SPeter Avalos * This is used in some OSes to allow a kernel socket filter to distinguish
322a85e14b0SPeter Avalos * between incoming and outgoing packets, on a socket intended to
323a85e14b0SPeter Avalos * supply pppd with outgoing packets so it can do dial-on-demand and
324a85e14b0SPeter Avalos * hangup-on-lack-of-demand; incoming packets are filtered out so they
325a85e14b0SPeter Avalos * don't cause pppd to hold the connection up (you don't want random
326a85e14b0SPeter Avalos * input packets such as port scans, packets from old lost connections,
327a85e14b0SPeter Avalos * etc. to force the connection to stay up).
328a85e14b0SPeter Avalos *
329*ea16f64eSAntonio Huete Jimenez * The first byte of the PPP header (0xff03) is modified to accommodate
330a85e14b0SPeter Avalos * the direction - 0x00 = IN, 0x01 = OUT.
331a85e14b0SPeter Avalos */
332a85e14b0SPeter Avalos #define LINKTYPE_PPP_PPPD 166
333a85e14b0SPeter Avalos
334a85e14b0SPeter Avalos /*
335a85e14b0SPeter Avalos * Juniper-private data link type, as per request from
336a85e14b0SPeter Avalos * Hannes Gredler <hannes@juniper.net>. The DLT_s are used
337a85e14b0SPeter Avalos * for passing on chassis-internal metainformation such as
338a85e14b0SPeter Avalos * QOS profiles, cookies, etc..
339a85e14b0SPeter Avalos */
340a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_PPPOE 167
341a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_PPPOE_ATM 168
342a85e14b0SPeter Avalos
343a85e14b0SPeter Avalos #define LINKTYPE_GPRS_LLC 169 /* GPRS LLC */
344a85e14b0SPeter Avalos #define LINKTYPE_GPF_T 170 /* GPF-T (ITU-T G.7041/Y.1303) */
34597a9217aSAntonio Huete Jimenez #define LINKTYPE_GPF_F 171 /* GPF-F (ITU-T G.7041/Y.1303) */
346a85e14b0SPeter Avalos
347a85e14b0SPeter Avalos /*
348a85e14b0SPeter Avalos * Requested by Oolan Zimmer <oz@gcom.com> for use in Gcom's T1/E1 line
349a85e14b0SPeter Avalos * monitoring equipment.
350a85e14b0SPeter Avalos */
351a85e14b0SPeter Avalos #define LINKTYPE_GCOM_T1E1 172
352a85e14b0SPeter Avalos #define LINKTYPE_GCOM_SERIAL 173
353a85e14b0SPeter Avalos
354a85e14b0SPeter Avalos /*
355a85e14b0SPeter Avalos * Juniper-private data link type, as per request from
356a85e14b0SPeter Avalos * Hannes Gredler <hannes@juniper.net>. The DLT_ is used
357a85e14b0SPeter Avalos * for internal communication to Physical Interface Cards (PIC)
358a85e14b0SPeter Avalos */
359a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_PIC_PEER 174
360a85e14b0SPeter Avalos
361a85e14b0SPeter Avalos /*
362a85e14b0SPeter Avalos * Link types requested by Gregor Maier <gregor@endace.com> of Endace
363a85e14b0SPeter Avalos * Measurement Systems. They add an ERF header (see
364*ea16f64eSAntonio Huete Jimenez * https://www.endace.com/support/EndaceRecordFormat.pdf) in front of
365a85e14b0SPeter Avalos * the link-layer header.
366a85e14b0SPeter Avalos */
367a85e14b0SPeter Avalos #define LINKTYPE_ERF_ETH 175 /* Ethernet */
368a85e14b0SPeter Avalos #define LINKTYPE_ERF_POS 176 /* Packet-over-SONET */
369a85e14b0SPeter Avalos
370a85e14b0SPeter Avalos /*
371a85e14b0SPeter Avalos * Requested by Daniele Orlandi <daniele@orlandi.com> for raw LAPD
372a85e14b0SPeter Avalos * for vISDN (http://www.orlandi.com/visdn/). Its link-layer header
373a85e14b0SPeter Avalos * includes additional information before the LAPD header, so it's
374a85e14b0SPeter Avalos * not necessarily a generic LAPD header.
375a85e14b0SPeter Avalos */
376a85e14b0SPeter Avalos #define LINKTYPE_LINUX_LAPD 177
377a85e14b0SPeter Avalos
378a85e14b0SPeter Avalos /*
379a85e14b0SPeter Avalos * Juniper-private data link type, as per request from
380a85e14b0SPeter Avalos * Hannes Gredler <hannes@juniper.net>.
381a85e14b0SPeter Avalos * The Link Types are used for prepending meta-information
382a85e14b0SPeter Avalos * like interface index, interface name
383a85e14b0SPeter Avalos * before standard Ethernet, PPP, Frelay & C-HDLC Frames
384a85e14b0SPeter Avalos */
385a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_ETHER 178
386a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_PPP 179
387a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_FRELAY 180
388a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_CHDLC 181
389a85e14b0SPeter Avalos
390a85e14b0SPeter Avalos /*
391a85e14b0SPeter Avalos * Multi Link Frame Relay (FRF.16)
392a85e14b0SPeter Avalos */
393a85e14b0SPeter Avalos #define LINKTYPE_MFR 182
394a85e14b0SPeter Avalos
395a85e14b0SPeter Avalos /*
396a85e14b0SPeter Avalos * Juniper-private data link type, as per request from
397a85e14b0SPeter Avalos * Hannes Gredler <hannes@juniper.net>.
398a85e14b0SPeter Avalos * The DLT_ is used for internal communication with a
399a85e14b0SPeter Avalos * voice Adapter Card (PIC)
400a85e14b0SPeter Avalos */
401a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_VP 183
402a85e14b0SPeter Avalos
403a85e14b0SPeter Avalos /*
404a85e14b0SPeter Avalos * Arinc 429 frames.
405a85e14b0SPeter Avalos * DLT_ requested by Gianluca Varenni <gianluca.varenni@cacetech.com>.
406a85e14b0SPeter Avalos * Every frame contains a 32bit A429 label.
407a85e14b0SPeter Avalos * More documentation on Arinc 429 can be found at
408a85e14b0SPeter Avalos * http://www.condoreng.com/support/downloads/tutorials/ARINCTutorial.pdf
409a85e14b0SPeter Avalos */
410a85e14b0SPeter Avalos #define LINKTYPE_A429 184
411a85e14b0SPeter Avalos
412a85e14b0SPeter Avalos /*
413a85e14b0SPeter Avalos * Arinc 653 Interpartition Communication messages.
414a85e14b0SPeter Avalos * DLT_ requested by Gianluca Varenni <gianluca.varenni@cacetech.com>.
415a85e14b0SPeter Avalos * Please refer to the A653-1 standard for more information.
416a85e14b0SPeter Avalos */
417a85e14b0SPeter Avalos #define LINKTYPE_A653_ICM 185
418a85e14b0SPeter Avalos
419a85e14b0SPeter Avalos /*
42097a9217aSAntonio Huete Jimenez * This used to be "USB packets, beginning with a USB setup header;
42197a9217aSAntonio Huete Jimenez * requested by Paolo Abeni <paolo.abeni@email.it>."
42297a9217aSAntonio Huete Jimenez *
42397a9217aSAntonio Huete Jimenez * However, that header didn't work all that well - it left out some
42497a9217aSAntonio Huete Jimenez * useful information - and was abandoned in favor of the DLT_USB_LINUX
42597a9217aSAntonio Huete Jimenez * header.
42697a9217aSAntonio Huete Jimenez *
42797a9217aSAntonio Huete Jimenez * This is now used by FreeBSD for its BPF taps for USB; that has its
42897a9217aSAntonio Huete Jimenez * own headers. So it is written, so it is done.
429a85e14b0SPeter Avalos */
43097a9217aSAntonio Huete Jimenez #define LINKTYPE_USB_FREEBSD 186
431a85e14b0SPeter Avalos
432a85e14b0SPeter Avalos /*
433a85e14b0SPeter Avalos * Bluetooth HCI UART transport layer (part H:4); requested by
434a85e14b0SPeter Avalos * Paolo Abeni.
435a85e14b0SPeter Avalos */
436a85e14b0SPeter Avalos #define LINKTYPE_BLUETOOTH_HCI_H4 187
437a85e14b0SPeter Avalos
438a85e14b0SPeter Avalos /*
439a85e14b0SPeter Avalos * IEEE 802.16 MAC Common Part Sublayer; requested by Maria Cruz
440a85e14b0SPeter Avalos * <cruz_petagay@bah.com>.
441a85e14b0SPeter Avalos */
442a85e14b0SPeter Avalos #define LINKTYPE_IEEE802_16_MAC_CPS 188
443a85e14b0SPeter Avalos
444a85e14b0SPeter Avalos /*
445a85e14b0SPeter Avalos * USB packets, beginning with a Linux USB header; requested by
446a85e14b0SPeter Avalos * Paolo Abeni <paolo.abeni@email.it>.
447a85e14b0SPeter Avalos */
448a85e14b0SPeter Avalos #define LINKTYPE_USB_LINUX 189
449a85e14b0SPeter Avalos
450a85e14b0SPeter Avalos /*
451a85e14b0SPeter Avalos * Controller Area Network (CAN) v. 2.0B packets.
452a85e14b0SPeter Avalos * DLT_ requested by Gianluca Varenni <gianluca.varenni@cacetech.com>.
453a85e14b0SPeter Avalos * Used to dump CAN packets coming from a CAN Vector board.
454a85e14b0SPeter Avalos * More documentation on the CAN v2.0B frames can be found at
455a85e14b0SPeter Avalos * http://www.can-cia.org/downloads/?269
456a85e14b0SPeter Avalos */
457a85e14b0SPeter Avalos #define LINKTYPE_CAN20B 190
458a85e14b0SPeter Avalos
459a85e14b0SPeter Avalos /*
460a85e14b0SPeter Avalos * IEEE 802.15.4, with address fields padded, as is done by Linux
461a85e14b0SPeter Avalos * drivers; requested by Juergen Schimmer.
462a85e14b0SPeter Avalos */
463a85e14b0SPeter Avalos #define LINKTYPE_IEEE802_15_4_LINUX 191
464a85e14b0SPeter Avalos
465a85e14b0SPeter Avalos /*
466a85e14b0SPeter Avalos * Per Packet Information encapsulated packets.
467a85e14b0SPeter Avalos * LINKTYPE_ requested by Gianluca Varenni <gianluca.varenni@cacetech.com>.
468a85e14b0SPeter Avalos */
469a85e14b0SPeter Avalos #define LINKTYPE_PPI 192
470a85e14b0SPeter Avalos
471a85e14b0SPeter Avalos /*
472a85e14b0SPeter Avalos * Header for 802.16 MAC Common Part Sublayer plus a radiotap radio header;
473a85e14b0SPeter Avalos * requested by Charles Clancy.
474a85e14b0SPeter Avalos */
475a85e14b0SPeter Avalos #define LINKTYPE_IEEE802_16_MAC_CPS_RADIO 193
476a85e14b0SPeter Avalos
477a85e14b0SPeter Avalos /*
478a85e14b0SPeter Avalos * Juniper-private data link type, as per request from
479a85e14b0SPeter Avalos * Hannes Gredler <hannes@juniper.net>.
480a85e14b0SPeter Avalos * The DLT_ is used for internal communication with a
481a85e14b0SPeter Avalos * integrated service module (ISM).
482a85e14b0SPeter Avalos */
483a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_ISM 194
484a85e14b0SPeter Avalos
485a85e14b0SPeter Avalos /*
486a85e14b0SPeter Avalos * IEEE 802.15.4, exactly as it appears in the spec (no padding, no
4873a289941SAaron LI * nothing), and with the FCS at the end of the frame; requested by
4883a289941SAaron LI * Mikko Saarnivala <mikko.saarnivala@sensinode.com>.
4893a289941SAaron LI *
4903a289941SAaron LI * This should only be used if the FCS is present at the end of the
4913a289941SAaron LI * frame; if the frame has no FCS, DLT_IEEE802_15_4_NOFCS should be
4923a289941SAaron LI * used.
493a85e14b0SPeter Avalos */
4943a289941SAaron LI #define LINKTYPE_IEEE802_15_4_WITHFCS 195
495a85e14b0SPeter Avalos
496a85e14b0SPeter Avalos /*
497a85e14b0SPeter Avalos * Various link-layer types, with a pseudo-header, for SITA
498*ea16f64eSAntonio Huete Jimenez * (https://www.sita.aero/); requested by Fulko Hew (fulko.hew@gmail.com).
499a85e14b0SPeter Avalos */
500a85e14b0SPeter Avalos #define LINKTYPE_SITA 196
501a85e14b0SPeter Avalos
502a85e14b0SPeter Avalos /*
503a85e14b0SPeter Avalos * Various link-layer types, with a pseudo-header, for Endace DAG cards;
504a85e14b0SPeter Avalos * encapsulates Endace ERF records. Requested by Stephen Donnelly
505a85e14b0SPeter Avalos * <stephen@endace.com>.
506a85e14b0SPeter Avalos */
507a85e14b0SPeter Avalos #define LINKTYPE_ERF 197
508a85e14b0SPeter Avalos
509a85e14b0SPeter Avalos /*
510a85e14b0SPeter Avalos * Special header prepended to Ethernet packets when capturing from a
511a85e14b0SPeter Avalos * u10 Networks board. Requested by Phil Mulholland
512a85e14b0SPeter Avalos * <phil@u10networks.com>.
513a85e14b0SPeter Avalos */
514a85e14b0SPeter Avalos #define LINKTYPE_RAIF1 198
515a85e14b0SPeter Avalos
516a85e14b0SPeter Avalos /*
5173a289941SAaron LI * IPMB packet for IPMI, beginning with a 2-byte header, followed by
5183a289941SAaron LI * the I2C slave address, followed by the netFn and LUN, etc..
5193a289941SAaron LI * Requested by Chanthy Toeung <chanthy.toeung@ca.kontron.com>.
5203a289941SAaron LI *
5213a289941SAaron LI * XXX - its DLT_ value used to be called DLT_IPMB, back when we got the
5223a289941SAaron LI * impression from the email thread requesting it that the packet
5233a289941SAaron LI * had no extra 2-byte header. We've renamed it; if anybody used
5243a289941SAaron LI * DLT_IPMB and assumed no 2-byte header, this will cause the compile
5253a289941SAaron LI * to fail, at which point we'll have to figure out what to do about
5263a289941SAaron LI * the two header types using the same DLT_/LINKTYPE_ value. If that
5273a289941SAaron LI * doesn't happen, we'll assume nobody used it and that the redefinition
5283a289941SAaron LI * is safe.
529a85e14b0SPeter Avalos */
5303a289941SAaron LI #define LINKTYPE_IPMB_KONTRON 199
531a85e14b0SPeter Avalos
532a85e14b0SPeter Avalos /*
533a85e14b0SPeter Avalos * Juniper-private data link type, as per request from
534a85e14b0SPeter Avalos * Hannes Gredler <hannes@juniper.net>.
535a85e14b0SPeter Avalos * The DLT_ is used for capturing data on a secure tunnel interface.
536a85e14b0SPeter Avalos */
537a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_ST 200
538a85e14b0SPeter Avalos
539a85e14b0SPeter Avalos /*
540a85e14b0SPeter Avalos * Bluetooth HCI UART transport layer (part H:4), with pseudo-header
541a85e14b0SPeter Avalos * that includes direction information; requested by Paolo Abeni.
542a85e14b0SPeter Avalos */
543a85e14b0SPeter Avalos #define LINKTYPE_BLUETOOTH_HCI_H4_WITH_PHDR 201
544a85e14b0SPeter Avalos
545a85e14b0SPeter Avalos /*
546a85e14b0SPeter Avalos * AX.25 packet with a 1-byte KISS header; see
547a85e14b0SPeter Avalos *
548a85e14b0SPeter Avalos * http://www.ax25.net/kiss.htm
549a85e14b0SPeter Avalos *
550a85e14b0SPeter Avalos * as per Richard Stearn <richard@rns-stearn.demon.co.uk>.
551a85e14b0SPeter Avalos */
552a85e14b0SPeter Avalos #define LINKTYPE_AX25_KISS 202
553a85e14b0SPeter Avalos
554a85e14b0SPeter Avalos /*
555a85e14b0SPeter Avalos * LAPD packets from an ISDN channel, starting with the address field,
556a85e14b0SPeter Avalos * with no pseudo-header.
557a85e14b0SPeter Avalos * Requested by Varuna De Silva <varunax@gmail.com>.
558a85e14b0SPeter Avalos */
559a85e14b0SPeter Avalos #define LINKTYPE_LAPD 203
560a85e14b0SPeter Avalos
561a85e14b0SPeter Avalos /*
5623a289941SAaron LI * PPP, with a one-byte direction pseudo-header prepended - zero means
5633a289941SAaron LI * "received by this host", non-zero (any non-zero value) means "sent by
5643a289941SAaron LI * this host" - as per Will Barker <w.barker@zen.co.uk>.
565a85e14b0SPeter Avalos */
5663a289941SAaron LI #define LINKTYPE_PPP_WITH_DIR 204 /* Don't confuse with LINKTYPE_PPP_PPPD */
5673a289941SAaron LI
5683a289941SAaron LI /*
5693a289941SAaron LI * Cisco HDLC, with a one-byte direction pseudo-header prepended - zero
5703a289941SAaron LI * means "received by this host", non-zero (any non-zero value) means
5713a289941SAaron LI * "sent by this host" - as per Will Barker <w.barker@zen.co.uk>.
5723a289941SAaron LI */
573a85e14b0SPeter Avalos #define LINKTYPE_C_HDLC_WITH_DIR 205 /* Cisco HDLC */
5743a289941SAaron LI
5753a289941SAaron LI /*
5763a289941SAaron LI * Frame Relay, with a one-byte direction pseudo-header prepended - zero
5773a289941SAaron LI * means "received by this host" (DCE -> DTE), non-zero (any non-zero
5783a289941SAaron LI * value) means "sent by this host" (DTE -> DCE) - as per Will Barker
5793a289941SAaron LI * <w.barker@zen.co.uk>.
5803a289941SAaron LI */
581a85e14b0SPeter Avalos #define LINKTYPE_FRELAY_WITH_DIR 206 /* Frame Relay */
5823a289941SAaron LI
5833a289941SAaron LI /*
5843a289941SAaron LI * LAPB, with a one-byte direction pseudo-header prepended - zero means
5853a289941SAaron LI * "received by this host" (DCE -> DTE), non-zero (any non-zero value)
5863a289941SAaron LI * means "sent by this host" (DTE -> DCE)- as per Will Barker
5873a289941SAaron LI * <w.barker@zen.co.uk>.
5883a289941SAaron LI */
589a85e14b0SPeter Avalos #define LINKTYPE_LAPB_WITH_DIR 207 /* LAPB */
590a85e14b0SPeter Avalos
591a85e14b0SPeter Avalos /*
592a85e14b0SPeter Avalos * 208 is reserved for an as-yet-unspecified proprietary link-layer
593a85e14b0SPeter Avalos * type, as requested by Will Barker.
594a85e14b0SPeter Avalos */
595a85e14b0SPeter Avalos
596a85e14b0SPeter Avalos /*
597a85e14b0SPeter Avalos * IPMB with a Linux-specific pseudo-header; as requested by Alexey Neyman
598a85e14b0SPeter Avalos * <avn@pigeonpoint.com>.
599a85e14b0SPeter Avalos */
600a85e14b0SPeter Avalos #define LINKTYPE_IPMB_LINUX 209
601a85e14b0SPeter Avalos
602a85e14b0SPeter Avalos /*
603a85e14b0SPeter Avalos * FlexRay automotive bus - http://www.flexray.com/ - as requested
604a85e14b0SPeter Avalos * by Hannes Kaelber <hannes.kaelber@x2e.de>.
605a85e14b0SPeter Avalos */
606a85e14b0SPeter Avalos #define LINKTYPE_FLEXRAY 210
607a85e14b0SPeter Avalos
608a85e14b0SPeter Avalos /*
609a85e14b0SPeter Avalos * Media Oriented Systems Transport (MOST) bus for multimedia
610*ea16f64eSAntonio Huete Jimenez * transport - https://www.mostcooperation.com/ - as requested
611a85e14b0SPeter Avalos * by Hannes Kaelber <hannes.kaelber@x2e.de>.
612a85e14b0SPeter Avalos */
613a85e14b0SPeter Avalos #define LINKTYPE_MOST 211
614a85e14b0SPeter Avalos
615a85e14b0SPeter Avalos /*
616a85e14b0SPeter Avalos * Local Interconnect Network (LIN) bus for vehicle networks -
617a85e14b0SPeter Avalos * http://www.lin-subbus.org/ - as requested by Hannes Kaelber
618a85e14b0SPeter Avalos * <hannes.kaelber@x2e.de>.
619a85e14b0SPeter Avalos */
620a85e14b0SPeter Avalos #define LINKTYPE_LIN 212
621a85e14b0SPeter Avalos
622a85e14b0SPeter Avalos /*
623a85e14b0SPeter Avalos * X2E-private data link type used for serial line capture,
624a85e14b0SPeter Avalos * as requested by Hannes Kaelber <hannes.kaelber@x2e.de>.
625a85e14b0SPeter Avalos */
626a85e14b0SPeter Avalos #define LINKTYPE_X2E_SERIAL 213
627a85e14b0SPeter Avalos
628a85e14b0SPeter Avalos /*
629a85e14b0SPeter Avalos * X2E-private data link type used for the Xoraya data logger
630a85e14b0SPeter Avalos * family, as requested by Hannes Kaelber <hannes.kaelber@x2e.de>.
631a85e14b0SPeter Avalos */
632a85e14b0SPeter Avalos #define LINKTYPE_X2E_XORAYA 214
633a85e14b0SPeter Avalos
634a85e14b0SPeter Avalos /*
635a85e14b0SPeter Avalos * IEEE 802.15.4, exactly as it appears in the spec (no padding, no
636a85e14b0SPeter Avalos * nothing), but with the PHY-level data for non-ASK PHYs (4 octets
637a85e14b0SPeter Avalos * of 0 as preamble, one octet of SFD, one octet of frame length+
638a85e14b0SPeter Avalos * reserved bit, and then the MAC-layer data, starting with the
639a85e14b0SPeter Avalos * frame control field).
640a85e14b0SPeter Avalos *
641a85e14b0SPeter Avalos * Requested by Max Filippov <jcmvbkbc@gmail.com>.
642a85e14b0SPeter Avalos */
643a85e14b0SPeter Avalos #define LINKTYPE_IEEE802_15_4_NONASK_PHY 215
644a85e14b0SPeter Avalos
645a85e14b0SPeter Avalos /*
646a85e14b0SPeter Avalos * David Gibson <david@gibson.dropbear.id.au> requested this for
647a85e14b0SPeter Avalos * captures from the Linux kernel /dev/input/eventN devices. This
648a85e14b0SPeter Avalos * is used to communicate keystrokes and mouse movements from the
649a85e14b0SPeter Avalos * Linux kernel to display systems, such as Xorg.
650a85e14b0SPeter Avalos */
651a85e14b0SPeter Avalos #define LINKTYPE_LINUX_EVDEV 216
652a85e14b0SPeter Avalos
653a85e14b0SPeter Avalos /*
654a85e14b0SPeter Avalos * GSM Um and Abis interfaces, preceded by a "gsmtap" header.
655a85e14b0SPeter Avalos *
656a85e14b0SPeter Avalos * Requested by Harald Welte <laforge@gnumonks.org>.
657a85e14b0SPeter Avalos */
658a85e14b0SPeter Avalos #define LINKTYPE_GSMTAP_UM 217
659a85e14b0SPeter Avalos #define LINKTYPE_GSMTAP_ABIS 218
660a85e14b0SPeter Avalos
661a85e14b0SPeter Avalos /*
662a85e14b0SPeter Avalos * MPLS, with an MPLS label as the link-layer header.
663a85e14b0SPeter Avalos * Requested by Michele Marchetto <michele@openbsd.org> on behalf
664a85e14b0SPeter Avalos * of OpenBSD.
665a85e14b0SPeter Avalos */
666a85e14b0SPeter Avalos #define LINKTYPE_MPLS 219
667a85e14b0SPeter Avalos
668a85e14b0SPeter Avalos /*
669a85e14b0SPeter Avalos * USB packets, beginning with a Linux USB header, with the USB header
670a85e14b0SPeter Avalos * padded to 64 bytes; required for memory-mapped access.
671a85e14b0SPeter Avalos */
672a85e14b0SPeter Avalos #define LINKTYPE_USB_LINUX_MMAPPED 220
673a85e14b0SPeter Avalos
674a85e14b0SPeter Avalos /*
675a85e14b0SPeter Avalos * DECT packets, with a pseudo-header; requested by
676a85e14b0SPeter Avalos * Matthias Wenzel <tcpdump@mazzoo.de>.
677a85e14b0SPeter Avalos */
678a85e14b0SPeter Avalos #define LINKTYPE_DECT 221
679a85e14b0SPeter Avalos
680a85e14b0SPeter Avalos /*
681a85e14b0SPeter Avalos * From: "Lidwa, Eric (GSFC-582.0)[SGT INC]" <eric.lidwa-1@nasa.gov>
682a85e14b0SPeter Avalos * Date: Mon, 11 May 2009 11:18:30 -0500
683a85e14b0SPeter Avalos *
684a85e14b0SPeter Avalos * DLT_AOS. We need it for AOS Space Data Link Protocol.
685a85e14b0SPeter Avalos * I have already written dissectors for but need an OK from
686a85e14b0SPeter Avalos * legal before I can submit a patch.
687a85e14b0SPeter Avalos *
688a85e14b0SPeter Avalos */
689a85e14b0SPeter Avalos #define LINKTYPE_AOS 222
690a85e14b0SPeter Avalos
691a85e14b0SPeter Avalos /*
692a85e14b0SPeter Avalos * Wireless HART (Highway Addressable Remote Transducer)
693a85e14b0SPeter Avalos * From the HART Communication Foundation
694a85e14b0SPeter Avalos * IES/PAS 62591
695a85e14b0SPeter Avalos *
696a85e14b0SPeter Avalos * Requested by Sam Roberts <vieuxtech@gmail.com>.
697a85e14b0SPeter Avalos */
698a85e14b0SPeter Avalos #define LINKTYPE_WIHART 223
699a85e14b0SPeter Avalos
700a85e14b0SPeter Avalos /*
701a85e14b0SPeter Avalos * Fibre Channel FC-2 frames, beginning with a Frame_Header.
702a85e14b0SPeter Avalos * Requested by Kahou Lei <kahou82@gmail.com>.
703a85e14b0SPeter Avalos */
704a85e14b0SPeter Avalos #define LINKTYPE_FC_2 224
705a85e14b0SPeter Avalos
706a85e14b0SPeter Avalos /*
707a85e14b0SPeter Avalos * Fibre Channel FC-2 frames, beginning with an encoding of the
708a85e14b0SPeter Avalos * SOF, and ending with an encoding of the EOF.
709a85e14b0SPeter Avalos *
710a85e14b0SPeter Avalos * The encodings represent the frame delimiters as 4-byte sequences
711a85e14b0SPeter Avalos * representing the corresponding ordered sets, with K28.5
712a85e14b0SPeter Avalos * represented as 0xBC, and the D symbols as the corresponding
713a85e14b0SPeter Avalos * byte values; for example, SOFi2, which is K28.5 - D21.5 - D1.2 - D21.2,
714a85e14b0SPeter Avalos * is represented as 0xBC 0xB5 0x55 0x55.
715a85e14b0SPeter Avalos *
716a85e14b0SPeter Avalos * Requested by Kahou Lei <kahou82@gmail.com>.
717a85e14b0SPeter Avalos */
718a85e14b0SPeter Avalos #define LINKTYPE_FC_2_WITH_FRAME_DELIMS 225
719a85e14b0SPeter Avalos
720a85e14b0SPeter Avalos /*
721a85e14b0SPeter Avalos * Solaris ipnet pseudo-header; requested by Darren Reed <Darren.Reed@Sun.COM>.
722a85e14b0SPeter Avalos *
723a85e14b0SPeter Avalos * The pseudo-header starts with a one-byte version number; for version 2,
724a85e14b0SPeter Avalos * the pseudo-header is:
725a85e14b0SPeter Avalos *
726a85e14b0SPeter Avalos * struct dl_ipnetinfo {
7273a289941SAaron LI * uint8_t dli_version;
7283a289941SAaron LI * uint8_t dli_family;
7293a289941SAaron LI * uint16_t dli_htype;
7303a289941SAaron LI * uint32_t dli_pktlen;
7313a289941SAaron LI * uint32_t dli_ifindex;
7323a289941SAaron LI * uint32_t dli_grifindex;
7333a289941SAaron LI * uint32_t dli_zsrc;
7343a289941SAaron LI * uint32_t dli_zdst;
735a85e14b0SPeter Avalos * };
736a85e14b0SPeter Avalos *
737a85e14b0SPeter Avalos * dli_version is 2 for the current version of the pseudo-header.
738a85e14b0SPeter Avalos *
739a85e14b0SPeter Avalos * dli_family is a Solaris address family value, so it's 2 for IPv4
740a85e14b0SPeter Avalos * and 26 for IPv6.
741a85e14b0SPeter Avalos *
742a85e14b0SPeter Avalos * dli_htype is a "hook type" - 0 for incoming packets, 1 for outgoing
743a85e14b0SPeter Avalos * packets, and 2 for packets arriving from another zone on the same
744a85e14b0SPeter Avalos * machine.
745a85e14b0SPeter Avalos *
746a85e14b0SPeter Avalos * dli_pktlen is the length of the packet data following the pseudo-header
747a85e14b0SPeter Avalos * (so the captured length minus dli_pktlen is the length of the
748a85e14b0SPeter Avalos * pseudo-header, assuming the entire pseudo-header was captured).
749a85e14b0SPeter Avalos *
750a85e14b0SPeter Avalos * dli_ifindex is the interface index of the interface on which the
751a85e14b0SPeter Avalos * packet arrived.
752a85e14b0SPeter Avalos *
753a85e14b0SPeter Avalos * dli_grifindex is the group interface index number (for IPMP interfaces).
754a85e14b0SPeter Avalos *
755a85e14b0SPeter Avalos * dli_zsrc is the zone identifier for the source of the packet.
756a85e14b0SPeter Avalos *
757a85e14b0SPeter Avalos * dli_zdst is the zone identifier for the destination of the packet.
758a85e14b0SPeter Avalos *
759a85e14b0SPeter Avalos * A zone number of 0 is the global zone; a zone number of 0xffffffff
760a85e14b0SPeter Avalos * means that the packet arrived from another host on the network, not
761a85e14b0SPeter Avalos * from another zone on the same machine.
762a85e14b0SPeter Avalos *
763a85e14b0SPeter Avalos * An IPv4 or IPv6 datagram follows the pseudo-header; dli_family indicates
764a85e14b0SPeter Avalos * which of those it is.
765a85e14b0SPeter Avalos */
766a85e14b0SPeter Avalos #define LINKTYPE_IPNET 226
767a85e14b0SPeter Avalos
768a85e14b0SPeter Avalos /*
769a85e14b0SPeter Avalos * CAN (Controller Area Network) frames, with a pseudo-header as supplied
77097a9217aSAntonio Huete Jimenez * by Linux SocketCAN, and with multi-byte numerical fields in that header
77197a9217aSAntonio Huete Jimenez * in big-endian byte order.
77297a9217aSAntonio Huete Jimenez *
77397a9217aSAntonio Huete Jimenez * See Documentation/networking/can.txt in the Linux source.
774a85e14b0SPeter Avalos *
775a85e14b0SPeter Avalos * Requested by Felix Obenhuber <felix@obenhuber.de>.
776a85e14b0SPeter Avalos */
777a85e14b0SPeter Avalos #define LINKTYPE_CAN_SOCKETCAN 227
778a85e14b0SPeter Avalos
779a85e14b0SPeter Avalos /*
780a85e14b0SPeter Avalos * Raw IPv4/IPv6; different from DLT_RAW in that the DLT_ value specifies
781a85e14b0SPeter Avalos * whether it's v4 or v6. Requested by Darren Reed <Darren.Reed@Sun.COM>.
782a85e14b0SPeter Avalos */
783a85e14b0SPeter Avalos #define LINKTYPE_IPV4 228
784a85e14b0SPeter Avalos #define LINKTYPE_IPV6 229
785a85e14b0SPeter Avalos
786a85e14b0SPeter Avalos /*
787a85e14b0SPeter Avalos * IEEE 802.15.4, exactly as it appears in the spec (no padding, no
788a85e14b0SPeter Avalos * nothing), and with no FCS at the end of the frame; requested by
789a85e14b0SPeter Avalos * Jon Smirl <jonsmirl@gmail.com>.
790a85e14b0SPeter Avalos */
791a85e14b0SPeter Avalos #define LINKTYPE_IEEE802_15_4_NOFCS 230
792a85e14b0SPeter Avalos
793a85e14b0SPeter Avalos /*
794a85e14b0SPeter Avalos * Raw D-Bus:
795a85e14b0SPeter Avalos *
796*ea16f64eSAntonio Huete Jimenez * https://www.freedesktop.org/wiki/Software/dbus
797a85e14b0SPeter Avalos *
798a85e14b0SPeter Avalos * messages:
799a85e14b0SPeter Avalos *
800*ea16f64eSAntonio Huete Jimenez * https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-messages
801a85e14b0SPeter Avalos *
802a85e14b0SPeter Avalos * starting with the endianness flag, followed by the message type, etc.,
803a85e14b0SPeter Avalos * but without the authentication handshake before the message sequence:
804a85e14b0SPeter Avalos *
805*ea16f64eSAntonio Huete Jimenez * https://dbus.freedesktop.org/doc/dbus-specification.html#auth-protocol
806a85e14b0SPeter Avalos *
807a85e14b0SPeter Avalos * Requested by Martin Vidner <martin@vidner.net>.
808a85e14b0SPeter Avalos */
809a85e14b0SPeter Avalos #define LINKTYPE_DBUS 231
810a85e14b0SPeter Avalos
811a85e14b0SPeter Avalos /*
812a85e14b0SPeter Avalos * Juniper-private data link type, as per request from
813a85e14b0SPeter Avalos * Hannes Gredler <hannes@juniper.net>.
814a85e14b0SPeter Avalos */
815a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_VS 232
816a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_SRX_E2E 233
817a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_FIBRECHANNEL 234
818a85e14b0SPeter Avalos
819a85e14b0SPeter Avalos /*
820a85e14b0SPeter Avalos * DVB-CI (DVB Common Interface for communication between a PC Card
821a85e14b0SPeter Avalos * module and a DVB receiver). See
822a85e14b0SPeter Avalos *
823*ea16f64eSAntonio Huete Jimenez * https://www.kaiser.cx/pcap-dvbci.html
824a85e14b0SPeter Avalos *
825a85e14b0SPeter Avalos * for the specification.
826a85e14b0SPeter Avalos *
827a85e14b0SPeter Avalos * Requested by Martin Kaiser <martin@kaiser.cx>.
828a85e14b0SPeter Avalos */
829a85e14b0SPeter Avalos #define LINKTYPE_DVB_CI 235
830a85e14b0SPeter Avalos
831a85e14b0SPeter Avalos /*
832a85e14b0SPeter Avalos * Variant of 3GPP TS 27.010 multiplexing protocol. Requested
833a85e14b0SPeter Avalos * by Hans-Christoph Schemmel <hans-christoph.schemmel@cinterion.com>.
834a85e14b0SPeter Avalos */
835a85e14b0SPeter Avalos #define LINKTYPE_MUX27010 236
836a85e14b0SPeter Avalos
837a85e14b0SPeter Avalos /*
838a85e14b0SPeter Avalos * STANAG 5066 D_PDUs. Requested by M. Baris Demiray
839a85e14b0SPeter Avalos * <barisdemiray@gmail.com>.
840a85e14b0SPeter Avalos */
841a85e14b0SPeter Avalos #define LINKTYPE_STANAG_5066_D_PDU 237
842a85e14b0SPeter Avalos
843a85e14b0SPeter Avalos /*
844a85e14b0SPeter Avalos * Juniper-private data link type, as per request from
845a85e14b0SPeter Avalos * Hannes Gredler <hannes@juniper.net>.
846a85e14b0SPeter Avalos */
847a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_ATM_CEMIC 238
848a85e14b0SPeter Avalos
849a85e14b0SPeter Avalos /*
850a85e14b0SPeter Avalos * NetFilter LOG messages
851a85e14b0SPeter Avalos * (payload of netlink NFNL_SUBSYS_ULOG/NFULNL_MSG_PACKET packets)
852a85e14b0SPeter Avalos *
853a85e14b0SPeter Avalos * Requested by Jakub Zawadzki <darkjames-ws@darkjames.pl>
854a85e14b0SPeter Avalos */
855a85e14b0SPeter Avalos #define LINKTYPE_NFLOG 239
856a85e14b0SPeter Avalos
857a85e14b0SPeter Avalos /*
858a85e14b0SPeter Avalos * Hilscher Gesellschaft fuer Systemautomation mbH link-layer type
859a85e14b0SPeter Avalos * for Ethernet packets with a 4-byte pseudo-header and always
860a85e14b0SPeter Avalos * with the payload including the FCS, as supplied by their
861a85e14b0SPeter Avalos * netANALYZER hardware and software.
862a85e14b0SPeter Avalos *
863a85e14b0SPeter Avalos * Requested by Holger P. Frommer <HPfrommer@hilscher.com>
864a85e14b0SPeter Avalos */
865a85e14b0SPeter Avalos #define LINKTYPE_NETANALYZER 240
866a85e14b0SPeter Avalos
867a85e14b0SPeter Avalos /*
868a85e14b0SPeter Avalos * Hilscher Gesellschaft fuer Systemautomation mbH link-layer type
869a85e14b0SPeter Avalos * for Ethernet packets with a 4-byte pseudo-header and FCS and
870a85e14b0SPeter Avalos * 1 byte of SFD, as supplied by their netANALYZER hardware and
871a85e14b0SPeter Avalos * software.
872a85e14b0SPeter Avalos *
873a85e14b0SPeter Avalos * Requested by Holger P. Frommer <HPfrommer@hilscher.com>
874a85e14b0SPeter Avalos */
875a85e14b0SPeter Avalos #define LINKTYPE_NETANALYZER_TRANSPARENT 241
876a85e14b0SPeter Avalos
877a85e14b0SPeter Avalos /*
8780e381983SMatthew Dillon * IP-over-InfiniBand, as specified by RFC 4391.
879a85e14b0SPeter Avalos *
880a85e14b0SPeter Avalos * Requested by Petr Sumbera <petr.sumbera@oracle.com>.
881a85e14b0SPeter Avalos */
882a85e14b0SPeter Avalos #define LINKTYPE_IPOIB 242
883a85e14b0SPeter Avalos
8840e1eae1fSPeter Avalos /*
8850e1eae1fSPeter Avalos * MPEG-2 transport stream (ISO 13818-1/ITU-T H.222.0).
8860e1eae1fSPeter Avalos *
8870e1eae1fSPeter Avalos * Requested by Guy Martin <gmsoft@tuxicoman.be>.
8880e1eae1fSPeter Avalos */
8890e1eae1fSPeter Avalos #define LINKTYPE_MPEG_2_TS 243
8900e1eae1fSPeter Avalos
8910e1eae1fSPeter Avalos /*
8920e1eae1fSPeter Avalos * ng4T GmbH's UMTS Iub/Iur-over-ATM and Iub/Iur-over-IP format as
8930e1eae1fSPeter Avalos * used by their ng40 protocol tester.
8940e1eae1fSPeter Avalos *
8950e1eae1fSPeter Avalos * Requested by Jens Grimmer <jens.grimmer@ng4t.com>.
8960e1eae1fSPeter Avalos */
8970e1eae1fSPeter Avalos #define LINKTYPE_NG40 244
8980e1eae1fSPeter Avalos
8990e1eae1fSPeter Avalos /*
9000e1eae1fSPeter Avalos * Pseudo-header giving adapter number and flags, followed by an NFC
9010e1eae1fSPeter Avalos * (Near-Field Communications) Logical Link Control Protocol (LLCP) PDU,
9020e1eae1fSPeter Avalos * as specified by NFC Forum Logical Link Control Protocol Technical
9030e1eae1fSPeter Avalos * Specification LLCP 1.1.
9040e1eae1fSPeter Avalos *
9050e1eae1fSPeter Avalos * Requested by Mike Wakerly <mikey@google.com>.
9060e1eae1fSPeter Avalos */
9070e1eae1fSPeter Avalos #define LINKTYPE_NFC_LLCP 245
9080e1eae1fSPeter Avalos
9090e1eae1fSPeter Avalos /*
9100e1eae1fSPeter Avalos * pfsync output; DLT_PFSYNC is 18, which collides with DLT_CIP in
9113a289941SAaron LI * SuSE 6.3, on OpenBSD, NetBSD, DragonFly BSD, and macOS, and
9120e1eae1fSPeter Avalos * is 121, which collides with DLT_HHDLC, in FreeBSD. We pick a
9130e1eae1fSPeter Avalos * shiny new link-layer header type value that doesn't collide with
9140e1eae1fSPeter Avalos * anything, in the hopes that future pfsync savefiles, if any,
9150e1eae1fSPeter Avalos * won't require special hacks to distinguish from other savefiles.
9160e1eae1fSPeter Avalos *
9170e1eae1fSPeter Avalos */
9180e1eae1fSPeter Avalos #define LINKTYPE_PFSYNC 246
9190e1eae1fSPeter Avalos
9200e381983SMatthew Dillon /*
9210e381983SMatthew Dillon * Raw InfiniBand packets, starting with the Local Routing Header.
9220e381983SMatthew Dillon *
9230e381983SMatthew Dillon * Requested by Oren Kladnitsky <orenk@mellanox.com>.
9240e381983SMatthew Dillon */
9250e381983SMatthew Dillon #define LINKTYPE_INFINIBAND 247
9260e381983SMatthew Dillon
9270e381983SMatthew Dillon /*
9280e381983SMatthew Dillon * SCTP, with no lower-level protocols (i.e., no IPv4 or IPv6).
9290e381983SMatthew Dillon *
9300e381983SMatthew Dillon * Requested by Michael Tuexen <Michael.Tuexen@lurchi.franken.de>.
9310e381983SMatthew Dillon */
9320e381983SMatthew Dillon #define LINKTYPE_SCTP 248
9330e381983SMatthew Dillon
93497a9217aSAntonio Huete Jimenez /*
93597a9217aSAntonio Huete Jimenez * USB packets, beginning with a USBPcap header.
93697a9217aSAntonio Huete Jimenez *
93797a9217aSAntonio Huete Jimenez * Requested by Tomasz Mon <desowin@gmail.com>
93897a9217aSAntonio Huete Jimenez */
93997a9217aSAntonio Huete Jimenez #define LINKTYPE_USBPCAP 249
94097a9217aSAntonio Huete Jimenez
94197a9217aSAntonio Huete Jimenez /*
94297a9217aSAntonio Huete Jimenez * Schweitzer Engineering Laboratories "RTAC" product serial-line
94397a9217aSAntonio Huete Jimenez * packets.
94497a9217aSAntonio Huete Jimenez *
94597a9217aSAntonio Huete Jimenez * Requested by Chris Bontje <chris_bontje@selinc.com>.
94697a9217aSAntonio Huete Jimenez */
947*ea16f64eSAntonio Huete Jimenez #define LINKTYPE_RTAC_SERIAL 250
94897a9217aSAntonio Huete Jimenez
94997a9217aSAntonio Huete Jimenez /*
95097a9217aSAntonio Huete Jimenez * Bluetooth Low Energy air interface link-layer packets.
95197a9217aSAntonio Huete Jimenez *
95297a9217aSAntonio Huete Jimenez * Requested by Mike Kershaw <dragorn@kismetwireless.net>.
95397a9217aSAntonio Huete Jimenez */
95497a9217aSAntonio Huete Jimenez #define LINKTYPE_BLUETOOTH_LE_LL 251
95597a9217aSAntonio Huete Jimenez
95697a9217aSAntonio Huete Jimenez /*
95797a9217aSAntonio Huete Jimenez * Link-layer header type for upper-protocol layer PDU saves from wireshark.
95897a9217aSAntonio Huete Jimenez *
95997a9217aSAntonio Huete Jimenez * the actual contents are determined by two TAGs stored with each
96097a9217aSAntonio Huete Jimenez * packet:
96197a9217aSAntonio Huete Jimenez * EXP_PDU_TAG_LINKTYPE the link type (LINKTYPE_ value) of the
96297a9217aSAntonio Huete Jimenez * original packet.
96397a9217aSAntonio Huete Jimenez *
96497a9217aSAntonio Huete Jimenez * EXP_PDU_TAG_PROTO_NAME the name of the wireshark dissector
96597a9217aSAntonio Huete Jimenez * that can make sense of the data stored.
96697a9217aSAntonio Huete Jimenez */
96797a9217aSAntonio Huete Jimenez #define LINKTYPE_WIRESHARK_UPPER_PDU 252
96897a9217aSAntonio Huete Jimenez
96997a9217aSAntonio Huete Jimenez /*
97097a9217aSAntonio Huete Jimenez * Link-layer header type for the netlink protocol (nlmon devices).
97197a9217aSAntonio Huete Jimenez */
97297a9217aSAntonio Huete Jimenez #define LINKTYPE_NETLINK 253
97397a9217aSAntonio Huete Jimenez
97497a9217aSAntonio Huete Jimenez /*
97597a9217aSAntonio Huete Jimenez * Bluetooth Linux Monitor headers for the BlueZ stack.
97697a9217aSAntonio Huete Jimenez */
97797a9217aSAntonio Huete Jimenez #define LINKTYPE_BLUETOOTH_LINUX_MONITOR 254
97897a9217aSAntonio Huete Jimenez
97997a9217aSAntonio Huete Jimenez /*
98097a9217aSAntonio Huete Jimenez * Bluetooth Basic Rate/Enhanced Data Rate baseband packets, as
98197a9217aSAntonio Huete Jimenez * captured by Ubertooth.
98297a9217aSAntonio Huete Jimenez */
98397a9217aSAntonio Huete Jimenez #define LINKTYPE_BLUETOOTH_BREDR_BB 255
98497a9217aSAntonio Huete Jimenez
98597a9217aSAntonio Huete Jimenez /*
98697a9217aSAntonio Huete Jimenez * Bluetooth Low Energy link layer packets, as captured by Ubertooth.
98797a9217aSAntonio Huete Jimenez */
98897a9217aSAntonio Huete Jimenez #define LINKTYPE_BLUETOOTH_LE_LL_WITH_PHDR 256
98997a9217aSAntonio Huete Jimenez
99097a9217aSAntonio Huete Jimenez /*
99197a9217aSAntonio Huete Jimenez * PROFIBUS data link layer.
99297a9217aSAntonio Huete Jimenez */
99397a9217aSAntonio Huete Jimenez #define LINKTYPE_PROFIBUS_DL 257
99497a9217aSAntonio Huete Jimenez
99597a9217aSAntonio Huete Jimenez /*
99697a9217aSAntonio Huete Jimenez * Apple's DLT_PKTAP headers.
99797a9217aSAntonio Huete Jimenez *
99897a9217aSAntonio Huete Jimenez * Sadly, the folks at Apple either had no clue that the DLT_USERn values
99997a9217aSAntonio Huete Jimenez * are for internal use within an organization and partners only, and
100097a9217aSAntonio Huete Jimenez * didn't know that the right way to get a link-layer header type is to
100197a9217aSAntonio Huete Jimenez * ask tcpdump.org for one, or knew and didn't care, so they just
100297a9217aSAntonio Huete Jimenez * used DLT_USER2, which causes problems for everything except for
100397a9217aSAntonio Huete Jimenez * their version of tcpdump.
100497a9217aSAntonio Huete Jimenez *
100597a9217aSAntonio Huete Jimenez * So I'll just give them one; hopefully this will show up in a
100697a9217aSAntonio Huete Jimenez * libpcap release in time for them to get this into 10.10 Big Sur
100797a9217aSAntonio Huete Jimenez * or whatever Mavericks' successor is called. LINKTYPE_PKTAP
10083a289941SAaron LI * will be 258 *even on macOS*; that is *intentional*, so that
100997a9217aSAntonio Huete Jimenez * PKTAP files look the same on *all* OSes (different OSes can have
101097a9217aSAntonio Huete Jimenez * different numerical values for a given DLT_, but *MUST NOT* have
101197a9217aSAntonio Huete Jimenez * different values for what goes in a file, as files can be moved
101297a9217aSAntonio Huete Jimenez * between OSes!).
101397a9217aSAntonio Huete Jimenez */
101497a9217aSAntonio Huete Jimenez #define LINKTYPE_PKTAP 258
101597a9217aSAntonio Huete Jimenez
101697a9217aSAntonio Huete Jimenez /*
101797a9217aSAntonio Huete Jimenez * Ethernet packets preceded by a header giving the last 6 octets
101897a9217aSAntonio Huete Jimenez * of the preamble specified by 802.3-2012 Clause 65, section
101997a9217aSAntonio Huete Jimenez * 65.1.3.2 "Transmit".
102097a9217aSAntonio Huete Jimenez */
102197a9217aSAntonio Huete Jimenez #define LINKTYPE_EPON 259
102297a9217aSAntonio Huete Jimenez
102397a9217aSAntonio Huete Jimenez /*
102497a9217aSAntonio Huete Jimenez * IPMI trace packets, as specified by Table 3-20 "Trace Data Block Format"
102597a9217aSAntonio Huete Jimenez * in the PICMG HPM.2 specification.
102697a9217aSAntonio Huete Jimenez */
102797a9217aSAntonio Huete Jimenez #define LINKTYPE_IPMI_HPM_2 260
102897a9217aSAntonio Huete Jimenez
102997a9217aSAntonio Huete Jimenez /*
103097a9217aSAntonio Huete Jimenez * per Joshua Wright <jwright@hasborg.com>, formats for Zwave captures.
103197a9217aSAntonio Huete Jimenez */
103297a9217aSAntonio Huete Jimenez #define LINKTYPE_ZWAVE_R1_R2 261
103397a9217aSAntonio Huete Jimenez #define LINKTYPE_ZWAVE_R3 262
103497a9217aSAntonio Huete Jimenez
103597a9217aSAntonio Huete Jimenez /*
103697a9217aSAntonio Huete Jimenez * per Steve Karg <skarg@users.sourceforge.net>, formats for Wattstopper
103797a9217aSAntonio Huete Jimenez * Digital Lighting Management room bus serial protocol captures.
103897a9217aSAntonio Huete Jimenez */
103997a9217aSAntonio Huete Jimenez #define LINKTYPE_WATTSTOPPER_DLM 263
104097a9217aSAntonio Huete Jimenez
104197a9217aSAntonio Huete Jimenez /*
104297a9217aSAntonio Huete Jimenez * ISO 14443 contactless smart card messages.
104397a9217aSAntonio Huete Jimenez */
104497a9217aSAntonio Huete Jimenez #define LINKTYPE_ISO_14443 264
104597a9217aSAntonio Huete Jimenez
104697a9217aSAntonio Huete Jimenez /*
104797a9217aSAntonio Huete Jimenez * Radio data system (RDS) groups. IEC 62106.
104897a9217aSAntonio Huete Jimenez * Per Jonathan Brucker <jonathan.brucke@gmail.com>.
104997a9217aSAntonio Huete Jimenez */
105097a9217aSAntonio Huete Jimenez #define LINKTYPE_RDS 265
105197a9217aSAntonio Huete Jimenez
10523a289941SAaron LI /*
10533a289941SAaron LI * USB packets, beginning with a Darwin (macOS, etc.) header.
10543a289941SAaron LI */
10553a289941SAaron LI #define LINKTYPE_USB_DARWIN 266
10563a289941SAaron LI
10573a289941SAaron LI /*
10583a289941SAaron LI * OpenBSD DLT_OPENFLOW.
10593a289941SAaron LI */
10603a289941SAaron LI #define LINKTYPE_OPENFLOW 267
10613a289941SAaron LI
10623a289941SAaron LI /*
10633a289941SAaron LI * SDLC frames containing SNA PDUs.
10643a289941SAaron LI */
10653a289941SAaron LI #define LINKTYPE_SDLC 268
10663a289941SAaron LI
10673a289941SAaron LI /*
10683a289941SAaron LI * per "Selvig, Bjorn" <b.selvig@ti.com> used for
10693a289941SAaron LI * TI protocol sniffer.
10703a289941SAaron LI */
10713a289941SAaron LI #define LINKTYPE_TI_LLN_SNIFFER 269
10723a289941SAaron LI
10733a289941SAaron LI /*
10743a289941SAaron LI * per: Erik de Jong <erikdejong at gmail.com> for
10753a289941SAaron LI * https://github.com/eriknl/LoRaTap/releases/tag/v0.1
10763a289941SAaron LI */
10773a289941SAaron LI #define LINKTYPE_LORATAP 270
10783a289941SAaron LI
10793a289941SAaron LI /*
10803a289941SAaron LI * per: Stefanha at gmail.com for
1081*ea16f64eSAntonio Huete Jimenez * https://lists.sandelman.ca/pipermail/tcpdump-workers/2017-May/000772.html
10823a289941SAaron LI * and: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/vsockmon.h
1083*ea16f64eSAntonio Huete Jimenez * for: https://qemu-project.org/Features/VirtioVsock
10843a289941SAaron LI */
10853a289941SAaron LI #define LINKTYPE_VSOCK 271
10863a289941SAaron LI
10873a289941SAaron LI /*
10883a289941SAaron LI * Nordic Semiconductor Bluetooth LE sniffer.
10893a289941SAaron LI */
10903a289941SAaron LI #define LINKTYPE_NORDIC_BLE 272
10913a289941SAaron LI
10923a289941SAaron LI /*
10933a289941SAaron LI * Excentis DOCSIS 3.1 RF sniffer (XRA-31)
10943a289941SAaron LI * per: bruno.verstuyft at excentis.com
1095*ea16f64eSAntonio Huete Jimenez * https://www.xra31.com/xra-header
10963a289941SAaron LI */
10973a289941SAaron LI #define LINKTYPE_DOCSIS31_XRA31 273
10983a289941SAaron LI
10993a289941SAaron LI /*
11003a289941SAaron LI * mPackets, as specified by IEEE 802.3br Figure 99-4, starting
11013a289941SAaron LI * with the preamble and always ending with a CRC field.
11023a289941SAaron LI */
11033a289941SAaron LI #define LINKTYPE_ETHERNET_MPACKET 274
11043a289941SAaron LI
11053a289941SAaron LI /*
11063a289941SAaron LI * DisplayPort AUX channel monitoring data as specified by VESA
1107*ea16f64eSAntonio Huete Jimenez * DisplayPort(DP) Standard preceded by a pseudo-header.
11083a289941SAaron LI * per dirk.eibach at gdsys.cc
11093a289941SAaron LI */
11103a289941SAaron LI #define LINKTYPE_DISPLAYPORT_AUX 275
11113a289941SAaron LI
11123a289941SAaron LI /*
11133a289941SAaron LI * Linux cooked sockets v2.
11143a289941SAaron LI */
11153a289941SAaron LI #define LINKTYPE_LINUX_SLL2 276
11163a289941SAaron LI
1117*ea16f64eSAntonio Huete Jimenez /*
1118*ea16f64eSAntonio Huete Jimenez * Sercos Monitor, per Manuel Jacob <manuel.jacob at steinbeis-stg.de>
1119*ea16f64eSAntonio Huete Jimenez */
1120*ea16f64eSAntonio Huete Jimenez #define LINKTYPE_SERCOS_MONITOR 277
1121*ea16f64eSAntonio Huete Jimenez
1122*ea16f64eSAntonio Huete Jimenez /*
1123*ea16f64eSAntonio Huete Jimenez * OpenVizsla http://openvizsla.org is open source USB analyzer hardware.
1124*ea16f64eSAntonio Huete Jimenez * It consists of FPGA with attached USB phy and FTDI chip for streaming
1125*ea16f64eSAntonio Huete Jimenez * the data to the host PC.
1126*ea16f64eSAntonio Huete Jimenez *
1127*ea16f64eSAntonio Huete Jimenez * Current OpenVizsla data encapsulation format is described here:
1128*ea16f64eSAntonio Huete Jimenez * https://github.com/matwey/libopenvizsla/wiki/OpenVizsla-protocol-description
1129*ea16f64eSAntonio Huete Jimenez *
1130*ea16f64eSAntonio Huete Jimenez */
1131*ea16f64eSAntonio Huete Jimenez #define LINKTYPE_OPENVIZSLA 278
1132*ea16f64eSAntonio Huete Jimenez
1133*ea16f64eSAntonio Huete Jimenez /*
1134*ea16f64eSAntonio Huete Jimenez * The Elektrobit High Speed Capture and Replay (EBHSCR) protocol is produced
1135*ea16f64eSAntonio Huete Jimenez * by a PCIe Card for interfacing high speed automotive interfaces.
1136*ea16f64eSAntonio Huete Jimenez *
1137*ea16f64eSAntonio Huete Jimenez * The specification for this frame format can be found at:
1138*ea16f64eSAntonio Huete Jimenez * https://www.elektrobit.com/ebhscr
1139*ea16f64eSAntonio Huete Jimenez *
1140*ea16f64eSAntonio Huete Jimenez * for Guenter.Ebermann at elektrobit.com
1141*ea16f64eSAntonio Huete Jimenez *
1142*ea16f64eSAntonio Huete Jimenez */
1143*ea16f64eSAntonio Huete Jimenez #define LINKTYPE_EBHSCR 279
1144*ea16f64eSAntonio Huete Jimenez
1145*ea16f64eSAntonio Huete Jimenez /*
1146*ea16f64eSAntonio Huete Jimenez * The https://fd.io vpp graph dispatch tracer produces pcap trace files
1147*ea16f64eSAntonio Huete Jimenez * in the format documented here:
1148*ea16f64eSAntonio Huete Jimenez * https://fdio-vpp.readthedocs.io/en/latest/gettingstarted/developers/vnet.html#graph-dispatcher-pcap-tracing
1149*ea16f64eSAntonio Huete Jimenez */
1150*ea16f64eSAntonio Huete Jimenez #define LINKTYPE_VPP_DISPATCH 280
1151*ea16f64eSAntonio Huete Jimenez
1152*ea16f64eSAntonio Huete Jimenez /*
1153*ea16f64eSAntonio Huete Jimenez * Broadcom Ethernet switches (ROBO switch) 4 bytes proprietary tagging format.
1154*ea16f64eSAntonio Huete Jimenez */
1155*ea16f64eSAntonio Huete Jimenez #define LINKTYPE_DSA_TAG_BRCM 281
1156*ea16f64eSAntonio Huete Jimenez #define LINKTYPE_DSA_TAG_BRCM_PREPEND 282
1157*ea16f64eSAntonio Huete Jimenez
1158*ea16f64eSAntonio Huete Jimenez /*
1159*ea16f64eSAntonio Huete Jimenez * IEEE 802.15.4 with pseudo-header and optional meta-data TLVs, PHY payload
1160*ea16f64eSAntonio Huete Jimenez * exactly as it appears in the spec (no padding, no nothing), and FCS if
1161*ea16f64eSAntonio Huete Jimenez * specified by FCS Type TLV; requested by James Ko <jck@exegin.com>.
1162*ea16f64eSAntonio Huete Jimenez * Specification at https://github.com/jkcko/ieee802.15.4-tap
1163*ea16f64eSAntonio Huete Jimenez */
1164*ea16f64eSAntonio Huete Jimenez #define LINKTYPE_IEEE802_15_4_TAP 283
1165*ea16f64eSAntonio Huete Jimenez
1166*ea16f64eSAntonio Huete Jimenez /*
1167*ea16f64eSAntonio Huete Jimenez * Marvell (Ethertype) Distributed Switch Architecture proprietary tagging format.
1168*ea16f64eSAntonio Huete Jimenez */
1169*ea16f64eSAntonio Huete Jimenez #define LINKTYPE_DSA_TAG_DSA 284
1170*ea16f64eSAntonio Huete Jimenez #define LINKTYPE_DSA_TAG_EDSA 285
1171*ea16f64eSAntonio Huete Jimenez
1172*ea16f64eSAntonio Huete Jimenez /*
1173*ea16f64eSAntonio Huete Jimenez * Payload of lawful intercept packets using the ELEE protocol;
1174*ea16f64eSAntonio Huete Jimenez * https://socket.hr/draft-dfranusic-opsawg-elee-00.xml
1175*ea16f64eSAntonio Huete Jimenez * https://xml2rfc.tools.ietf.org/cgi-bin/xml2rfc.cgi?url=https://socket.hr/draft-dfranusic-opsawg-elee-00.xml&modeAsFormat=html/ascii
1176*ea16f64eSAntonio Huete Jimenez */
1177*ea16f64eSAntonio Huete Jimenez #define LINKTYPE_ELEE 286
1178*ea16f64eSAntonio Huete Jimenez
1179*ea16f64eSAntonio Huete Jimenez /*
1180*ea16f64eSAntonio Huete Jimenez * Serial frames transmitted between a host and a Z-Wave chip.
1181*ea16f64eSAntonio Huete Jimenez */
1182*ea16f64eSAntonio Huete Jimenez #define LINKTYPE_Z_WAVE_SERIAL 287
1183*ea16f64eSAntonio Huete Jimenez
1184*ea16f64eSAntonio Huete Jimenez /*
1185*ea16f64eSAntonio Huete Jimenez * USB 2.0, 1.1, and 1.0 packets as transmitted over the cable.
1186*ea16f64eSAntonio Huete Jimenez */
1187*ea16f64eSAntonio Huete Jimenez #define LINKTYPE_USB_2_0 288
1188*ea16f64eSAntonio Huete Jimenez
1189*ea16f64eSAntonio Huete Jimenez /*
1190*ea16f64eSAntonio Huete Jimenez * ATSC Link-Layer Protocol (A/330) packets.
1191*ea16f64eSAntonio Huete Jimenez */
1192*ea16f64eSAntonio Huete Jimenez #define LINKTYPE_ATSC_ALP 289
1193*ea16f64eSAntonio Huete Jimenez
1194*ea16f64eSAntonio Huete Jimenez #define LINKTYPE_MATCHING_MAX 289 /* highest value in the "matching" range */
11953a289941SAaron LI
11963a289941SAaron LI /*
11973a289941SAaron LI * The DLT_ and LINKTYPE_ values in the "matching" range should be the
11983a289941SAaron LI * same, so DLT_MATCHING_MAX and LINKTYPE_MATCHING_MAX should be the
11993a289941SAaron LI * same.
12003a289941SAaron LI */
12013a289941SAaron LI #if LINKTYPE_MATCHING_MAX != DLT_MATCHING_MAX
12023a289941SAaron LI #error The LINKTYPE_ matching range does not match the DLT_ matching range
12033a289941SAaron LI #endif
1204a85e14b0SPeter Avalos
1205a85e14b0SPeter Avalos static struct linktype_map {
1206a85e14b0SPeter Avalos int dlt;
1207a85e14b0SPeter Avalos int linktype;
1208a85e14b0SPeter Avalos } map[] = {
1209a85e14b0SPeter Avalos /*
1210a85e14b0SPeter Avalos * These DLT_* codes have LINKTYPE_* codes with values identical
1211a85e14b0SPeter Avalos * to the values of the corresponding DLT_* code.
1212a85e14b0SPeter Avalos */
1213a85e14b0SPeter Avalos { DLT_NULL, LINKTYPE_NULL },
1214a85e14b0SPeter Avalos { DLT_EN10MB, LINKTYPE_ETHERNET },
1215a85e14b0SPeter Avalos { DLT_EN3MB, LINKTYPE_EXP_ETHERNET },
1216a85e14b0SPeter Avalos { DLT_AX25, LINKTYPE_AX25 },
1217a85e14b0SPeter Avalos { DLT_PRONET, LINKTYPE_PRONET },
1218a85e14b0SPeter Avalos { DLT_CHAOS, LINKTYPE_CHAOS },
12190e1eae1fSPeter Avalos { DLT_IEEE802, LINKTYPE_IEEE802_5 },
1220a85e14b0SPeter Avalos { DLT_ARCNET, LINKTYPE_ARCNET_BSD },
1221a85e14b0SPeter Avalos { DLT_SLIP, LINKTYPE_SLIP },
1222a85e14b0SPeter Avalos { DLT_PPP, LINKTYPE_PPP },
1223a85e14b0SPeter Avalos { DLT_FDDI, LINKTYPE_FDDI },
12240e1eae1fSPeter Avalos { DLT_SYMANTEC_FIREWALL, LINKTYPE_SYMANTEC_FIREWALL },
1225a85e14b0SPeter Avalos
1226a85e14b0SPeter Avalos /*
1227a85e14b0SPeter Avalos * These DLT_* codes have different values on different
1228a85e14b0SPeter Avalos * platforms; we map them to LINKTYPE_* codes that
1229a85e14b0SPeter Avalos * have values that should never be equal to any DLT_*
1230a85e14b0SPeter Avalos * code.
1231a85e14b0SPeter Avalos */
1232a85e14b0SPeter Avalos #ifdef DLT_FR
1233a85e14b0SPeter Avalos /* BSD/OS Frame Relay */
1234a85e14b0SPeter Avalos { DLT_FR, LINKTYPE_FRELAY },
1235a85e14b0SPeter Avalos #endif
1236a85e14b0SPeter Avalos
1237a85e14b0SPeter Avalos { DLT_ATM_RFC1483, LINKTYPE_ATM_RFC1483 },
1238a85e14b0SPeter Avalos { DLT_RAW, LINKTYPE_RAW },
1239a85e14b0SPeter Avalos { DLT_SLIP_BSDOS, LINKTYPE_SLIP_BSDOS },
1240a85e14b0SPeter Avalos { DLT_PPP_BSDOS, LINKTYPE_PPP_BSDOS },
1241a85e14b0SPeter Avalos
1242a85e14b0SPeter Avalos /* BSD/OS Cisco HDLC */
1243a85e14b0SPeter Avalos { DLT_C_HDLC, LINKTYPE_C_HDLC },
1244a85e14b0SPeter Avalos
1245a85e14b0SPeter Avalos /*
1246a85e14b0SPeter Avalos * These DLT_* codes are not on all platforms, but, so far,
1247a85e14b0SPeter Avalos * there don't appear to be any platforms that define
1248a85e14b0SPeter Avalos * other codes with those values; we map them to
1249a85e14b0SPeter Avalos * different LINKTYPE_* values anyway, just in case.
1250a85e14b0SPeter Avalos */
1251a85e14b0SPeter Avalos
1252a85e14b0SPeter Avalos /* Linux ATM Classical IP */
1253a85e14b0SPeter Avalos { DLT_ATM_CLIP, LINKTYPE_ATM_CLIP },
1254a85e14b0SPeter Avalos
1255a85e14b0SPeter Avalos /* NetBSD sync/async serial PPP (or Cisco HDLC) */
1256a85e14b0SPeter Avalos { DLT_PPP_SERIAL, LINKTYPE_PPP_HDLC },
1257a85e14b0SPeter Avalos
1258a85e14b0SPeter Avalos /* NetBSD PPP over Ethernet */
1259a85e14b0SPeter Avalos { DLT_PPP_ETHER, LINKTYPE_PPP_ETHER },
1260a85e14b0SPeter Avalos
1261a85e14b0SPeter Avalos /*
1262a85e14b0SPeter Avalos * All LINKTYPE_ values between LINKTYPE_MATCHING_MIN
1263a85e14b0SPeter Avalos * and LINKTYPE_MATCHING_MAX are mapped to identical
1264a85e14b0SPeter Avalos * DLT_ values.
1265a85e14b0SPeter Avalos */
1266a85e14b0SPeter Avalos
1267a85e14b0SPeter Avalos { -1, -1 }
1268a85e14b0SPeter Avalos };
1269a85e14b0SPeter Avalos
1270a85e14b0SPeter Avalos int
dlt_to_linktype(int dlt)1271a85e14b0SPeter Avalos dlt_to_linktype(int dlt)
1272a85e14b0SPeter Avalos {
1273a85e14b0SPeter Avalos int i;
1274a85e14b0SPeter Avalos
1275a85e14b0SPeter Avalos /*
127697a9217aSAntonio Huete Jimenez * DLTs that, on some platforms, have values in the matching range
127797a9217aSAntonio Huete Jimenez * but that *don't* have the same value as the corresponding
127897a9217aSAntonio Huete Jimenez * LINKTYPE because, for some reason, not all OSes have the
127997a9217aSAntonio Huete Jimenez * same value for that DLT (note that the DLT's value might be
128097a9217aSAntonio Huete Jimenez * outside the matching range on some of those OSes).
12810e1eae1fSPeter Avalos */
12820e1eae1fSPeter Avalos if (dlt == DLT_PFSYNC)
12830e1eae1fSPeter Avalos return (LINKTYPE_PFSYNC);
128497a9217aSAntonio Huete Jimenez if (dlt == DLT_PKTAP)
128597a9217aSAntonio Huete Jimenez return (LINKTYPE_PKTAP);
12860e1eae1fSPeter Avalos
12870e1eae1fSPeter Avalos /*
128897a9217aSAntonio Huete Jimenez * For all other values in the matching range, the DLT
128997a9217aSAntonio Huete Jimenez * value is the same as the LINKTYPE value.
1290a85e14b0SPeter Avalos */
1291a85e14b0SPeter Avalos if (dlt >= DLT_MATCHING_MIN && dlt <= DLT_MATCHING_MAX)
1292a85e14b0SPeter Avalos return (dlt);
1293a85e14b0SPeter Avalos
1294a85e14b0SPeter Avalos /*
1295a85e14b0SPeter Avalos * Map the values outside that range.
1296a85e14b0SPeter Avalos */
1297a85e14b0SPeter Avalos for (i = 0; map[i].dlt != -1; i++) {
1298a85e14b0SPeter Avalos if (map[i].dlt == dlt)
1299a85e14b0SPeter Avalos return (map[i].linktype);
1300a85e14b0SPeter Avalos }
1301a85e14b0SPeter Avalos
1302a85e14b0SPeter Avalos /*
130397a9217aSAntonio Huete Jimenez * If we don't have a mapping for this DLT, return an
1304a85e14b0SPeter Avalos * error; that means that this is a value with no corresponding
130597a9217aSAntonio Huete Jimenez * LINKTYPE, and we need to assign one.
1306a85e14b0SPeter Avalos */
1307a85e14b0SPeter Avalos return (-1);
1308a85e14b0SPeter Avalos }
1309a85e14b0SPeter Avalos
1310a85e14b0SPeter Avalos int
linktype_to_dlt(int linktype)1311a85e14b0SPeter Avalos linktype_to_dlt(int linktype)
1312a85e14b0SPeter Avalos {
1313a85e14b0SPeter Avalos int i;
1314a85e14b0SPeter Avalos
1315a85e14b0SPeter Avalos /*
131697a9217aSAntonio Huete Jimenez * LINKTYPEs in the matching range that *don't*
131797a9217aSAntonio Huete Jimenez * have the same value as the corresponding DLTs
131897a9217aSAntonio Huete Jimenez * because, for some reason, not all OSes have the
131997a9217aSAntonio Huete Jimenez * same value for that DLT.
13200e1eae1fSPeter Avalos */
13210e1eae1fSPeter Avalos if (linktype == LINKTYPE_PFSYNC)
13220e1eae1fSPeter Avalos return (DLT_PFSYNC);
132397a9217aSAntonio Huete Jimenez if (linktype == LINKTYPE_PKTAP)
132497a9217aSAntonio Huete Jimenez return (DLT_PKTAP);
13250e1eae1fSPeter Avalos
13260e1eae1fSPeter Avalos /*
1327*ea16f64eSAntonio Huete Jimenez * For all other values in the matching range, except for
1328*ea16f64eSAntonio Huete Jimenez * LINKTYPE_ATM_CLIP, the LINKTYPE value is the same as
1329*ea16f64eSAntonio Huete Jimenez * the DLT value.
1330*ea16f64eSAntonio Huete Jimenez *
1331*ea16f64eSAntonio Huete Jimenez * LINKTYPE_ATM_CLIP is a special case. DLT_ATM_CLIP is
1332*ea16f64eSAntonio Huete Jimenez * not on all platforms, but, so far, there don't appear
1333*ea16f64eSAntonio Huete Jimenez * to be any platforms that define it as anything other
1334*ea16f64eSAntonio Huete Jimenez * than 19; we define LINKTYPE_ATM_CLIP as something
1335*ea16f64eSAntonio Huete Jimenez * other than 19, just in case. That value is in the
1336*ea16f64eSAntonio Huete Jimenez * matching range, so we have to check for it.
1337a85e14b0SPeter Avalos */
1338a85e14b0SPeter Avalos if (linktype >= LINKTYPE_MATCHING_MIN &&
1339*ea16f64eSAntonio Huete Jimenez linktype <= LINKTYPE_MATCHING_MAX &&
1340*ea16f64eSAntonio Huete Jimenez linktype != LINKTYPE_ATM_CLIP)
1341a85e14b0SPeter Avalos return (linktype);
1342a85e14b0SPeter Avalos
1343a85e14b0SPeter Avalos /*
1344a85e14b0SPeter Avalos * Map the values outside that range.
1345a85e14b0SPeter Avalos */
1346a85e14b0SPeter Avalos for (i = 0; map[i].linktype != -1; i++) {
1347a85e14b0SPeter Avalos if (map[i].linktype == linktype)
1348a85e14b0SPeter Avalos return (map[i].dlt);
1349a85e14b0SPeter Avalos }
1350a85e14b0SPeter Avalos
1351a85e14b0SPeter Avalos /*
135297a9217aSAntonio Huete Jimenez * If we don't have an entry for this LINKTYPE, return
1353*ea16f64eSAntonio Huete Jimenez * the link type value; it may be a DLT from an newer
135497a9217aSAntonio Huete Jimenez * version of libpcap.
1355a85e14b0SPeter Avalos */
1356a85e14b0SPeter Avalos return linktype;
1357a85e14b0SPeter Avalos }
1358a85e14b0SPeter Avalos
13593a289941SAaron LI /*
13603a289941SAaron LI * Return the maximum snapshot length for a given DLT_ value.
13613a289941SAaron LI *
13623a289941SAaron LI * For most link-layer types, we use MAXIMUM_SNAPLEN.
13633a289941SAaron LI *
13643a289941SAaron LI * For DLT_DBUS, the maximum is 128MiB, as per
13653a289941SAaron LI *
13663a289941SAaron LI * https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-messages
13673a289941SAaron LI *
1368*ea16f64eSAntonio Huete Jimenez * For DLT_EBHSCR, the maximum is 8MiB, as per
1369*ea16f64eSAntonio Huete Jimenez *
1370*ea16f64eSAntonio Huete Jimenez * https://www.elektrobit.com/ebhscr
1371*ea16f64eSAntonio Huete Jimenez *
13723a289941SAaron LI * For DLT_USBPCAP, the maximum is 1MiB, as per
13733a289941SAaron LI *
13743a289941SAaron LI * https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=15985
13753a289941SAaron LI */
13763a289941SAaron LI u_int
max_snaplen_for_dlt(int dlt)13773a289941SAaron LI max_snaplen_for_dlt(int dlt)
13783a289941SAaron LI {
13793a289941SAaron LI switch (dlt) {
13803a289941SAaron LI
13813a289941SAaron LI case DLT_DBUS:
13823a289941SAaron LI return 128*1024*1024;
13833a289941SAaron LI
1384*ea16f64eSAntonio Huete Jimenez case DLT_EBHSCR:
1385*ea16f64eSAntonio Huete Jimenez return 8*1024*1024;
1386*ea16f64eSAntonio Huete Jimenez
13873a289941SAaron LI case DLT_USBPCAP:
13883a289941SAaron LI return 1024*1024;
13893a289941SAaron LI
13903a289941SAaron LI default:
13913a289941SAaron LI return MAXIMUM_SNAPLEN;
13923a289941SAaron LI }
13933a289941SAaron LI }
139497a9217aSAntonio Huete Jimenez
139597a9217aSAntonio Huete Jimenez /*
139697a9217aSAntonio Huete Jimenez * DLT_LINUX_SLL packets with a protocol type of LINUX_SLL_P_CAN or
139797a9217aSAntonio Huete Jimenez * LINUX_SLL_P_CANFD have SocketCAN headers in front of the payload,
139897a9217aSAntonio Huete Jimenez * with the CAN ID being in host byte order.
139997a9217aSAntonio Huete Jimenez *
140097a9217aSAntonio Huete Jimenez * When reading a DLT_LINUX_SLL capture file, we need to check for those
140197a9217aSAntonio Huete Jimenez * packets and convert the CAN ID from the byte order of the host that
140297a9217aSAntonio Huete Jimenez * wrote the file to this host's byte order.
140397a9217aSAntonio Huete Jimenez */
140497a9217aSAntonio Huete Jimenez static void
swap_linux_sll_header(const struct pcap_pkthdr * hdr,u_char * buf)140597a9217aSAntonio Huete Jimenez swap_linux_sll_header(const struct pcap_pkthdr *hdr, u_char *buf)
140697a9217aSAntonio Huete Jimenez {
140797a9217aSAntonio Huete Jimenez u_int caplen = hdr->caplen;
140897a9217aSAntonio Huete Jimenez u_int length = hdr->len;
140997a9217aSAntonio Huete Jimenez struct sll_header *shdr = (struct sll_header *)buf;
14103a289941SAaron LI uint16_t protocol;
141197a9217aSAntonio Huete Jimenez pcap_can_socketcan_hdr *chdr;
141297a9217aSAntonio Huete Jimenez
141397a9217aSAntonio Huete Jimenez if (caplen < (u_int) sizeof(struct sll_header) ||
141497a9217aSAntonio Huete Jimenez length < (u_int) sizeof(struct sll_header)) {
141597a9217aSAntonio Huete Jimenez /* Not enough data to have the protocol field */
141697a9217aSAntonio Huete Jimenez return;
141797a9217aSAntonio Huete Jimenez }
141897a9217aSAntonio Huete Jimenez
1419*ea16f64eSAntonio Huete Jimenez protocol = EXTRACT_BE_U_2(&shdr->sll_protocol);
142097a9217aSAntonio Huete Jimenez if (protocol != LINUX_SLL_P_CAN && protocol != LINUX_SLL_P_CANFD)
142197a9217aSAntonio Huete Jimenez return;
142297a9217aSAntonio Huete Jimenez
142397a9217aSAntonio Huete Jimenez /*
142497a9217aSAntonio Huete Jimenez * SocketCAN packet; fix up the packet's header.
142597a9217aSAntonio Huete Jimenez */
142697a9217aSAntonio Huete Jimenez chdr = (pcap_can_socketcan_hdr *)(buf + sizeof(struct sll_header));
142797a9217aSAntonio Huete Jimenez if (caplen < (u_int) sizeof(struct sll_header) + sizeof(chdr->can_id) ||
142897a9217aSAntonio Huete Jimenez length < (u_int) sizeof(struct sll_header) + sizeof(chdr->can_id)) {
142997a9217aSAntonio Huete Jimenez /* Not enough data to have the CAN ID */
143097a9217aSAntonio Huete Jimenez return;
143197a9217aSAntonio Huete Jimenez }
143297a9217aSAntonio Huete Jimenez chdr->can_id = SWAPLONG(chdr->can_id);
143397a9217aSAntonio Huete Jimenez }
143497a9217aSAntonio Huete Jimenez
1435a85e14b0SPeter Avalos /*
1436a85e14b0SPeter Avalos * The DLT_USB_LINUX and DLT_USB_LINUX_MMAPPED headers are in host
1437a85e14b0SPeter Avalos * byte order when capturing (it's supplied directly from a
1438a85e14b0SPeter Avalos * memory-mapped buffer shared by the kernel).
1439a85e14b0SPeter Avalos *
1440a85e14b0SPeter Avalos * When reading a DLT_USB_LINUX or DLT_USB_LINUX_MMAPPED capture file,
144197a9217aSAntonio Huete Jimenez * we need to convert it from the byte order of the host that wrote
144297a9217aSAntonio Huete Jimenez * the file to this host's byte order.
1443a85e14b0SPeter Avalos */
144497a9217aSAntonio Huete Jimenez static void
swap_linux_usb_header(const struct pcap_pkthdr * hdr,u_char * buf,int header_len_64_bytes)1445a85e14b0SPeter Avalos swap_linux_usb_header(const struct pcap_pkthdr *hdr, u_char *buf,
1446a85e14b0SPeter Avalos int header_len_64_bytes)
1447a85e14b0SPeter Avalos {
1448a85e14b0SPeter Avalos pcap_usb_header_mmapped *uhdr = (pcap_usb_header_mmapped *)buf;
1449a85e14b0SPeter Avalos bpf_u_int32 offset = 0;
1450a85e14b0SPeter Avalos
1451a85e14b0SPeter Avalos /*
1452a85e14b0SPeter Avalos * "offset" is the offset *past* the field we're swapping;
1453a85e14b0SPeter Avalos * we skip the field *before* checking to make sure
1454a85e14b0SPeter Avalos * the captured data length includes the entire field.
1455a85e14b0SPeter Avalos */
1456a85e14b0SPeter Avalos
1457a85e14b0SPeter Avalos /*
1458a85e14b0SPeter Avalos * The URB id is a totally opaque value; do we really need to
1459a85e14b0SPeter Avalos * convert it to the reading host's byte order???
1460a85e14b0SPeter Avalos */
1461a85e14b0SPeter Avalos offset += 8; /* skip past id */
1462a85e14b0SPeter Avalos if (hdr->caplen < offset)
1463a85e14b0SPeter Avalos return;
1464a85e14b0SPeter Avalos uhdr->id = SWAPLL(uhdr->id);
1465a85e14b0SPeter Avalos
1466a85e14b0SPeter Avalos offset += 4; /* skip past various 1-byte fields */
1467a85e14b0SPeter Avalos
1468a85e14b0SPeter Avalos offset += 2; /* skip past bus_id */
1469a85e14b0SPeter Avalos if (hdr->caplen < offset)
1470a85e14b0SPeter Avalos return;
1471a85e14b0SPeter Avalos uhdr->bus_id = SWAPSHORT(uhdr->bus_id);
1472a85e14b0SPeter Avalos
1473a85e14b0SPeter Avalos offset += 2; /* skip past various 1-byte fields */
1474a85e14b0SPeter Avalos
1475a85e14b0SPeter Avalos offset += 8; /* skip past ts_sec */
1476a85e14b0SPeter Avalos if (hdr->caplen < offset)
1477a85e14b0SPeter Avalos return;
1478a85e14b0SPeter Avalos uhdr->ts_sec = SWAPLL(uhdr->ts_sec);
1479a85e14b0SPeter Avalos
1480a85e14b0SPeter Avalos offset += 4; /* skip past ts_usec */
1481a85e14b0SPeter Avalos if (hdr->caplen < offset)
1482a85e14b0SPeter Avalos return;
1483a85e14b0SPeter Avalos uhdr->ts_usec = SWAPLONG(uhdr->ts_usec);
1484a85e14b0SPeter Avalos
1485a85e14b0SPeter Avalos offset += 4; /* skip past status */
1486a85e14b0SPeter Avalos if (hdr->caplen < offset)
1487a85e14b0SPeter Avalos return;
1488a85e14b0SPeter Avalos uhdr->status = SWAPLONG(uhdr->status);
1489a85e14b0SPeter Avalos
1490a85e14b0SPeter Avalos offset += 4; /* skip past urb_len */
1491a85e14b0SPeter Avalos if (hdr->caplen < offset)
1492a85e14b0SPeter Avalos return;
1493a85e14b0SPeter Avalos uhdr->urb_len = SWAPLONG(uhdr->urb_len);
1494a85e14b0SPeter Avalos
1495a85e14b0SPeter Avalos offset += 4; /* skip past data_len */
1496a85e14b0SPeter Avalos if (hdr->caplen < offset)
1497a85e14b0SPeter Avalos return;
1498a85e14b0SPeter Avalos uhdr->data_len = SWAPLONG(uhdr->data_len);
1499a85e14b0SPeter Avalos
1500a85e14b0SPeter Avalos if (uhdr->transfer_type == URB_ISOCHRONOUS) {
1501a85e14b0SPeter Avalos offset += 4; /* skip past s.iso.error_count */
1502a85e14b0SPeter Avalos if (hdr->caplen < offset)
1503a85e14b0SPeter Avalos return;
1504a85e14b0SPeter Avalos uhdr->s.iso.error_count = SWAPLONG(uhdr->s.iso.error_count);
1505a85e14b0SPeter Avalos
1506a85e14b0SPeter Avalos offset += 4; /* skip past s.iso.numdesc */
1507a85e14b0SPeter Avalos if (hdr->caplen < offset)
1508a85e14b0SPeter Avalos return;
1509a85e14b0SPeter Avalos uhdr->s.iso.numdesc = SWAPLONG(uhdr->s.iso.numdesc);
1510a85e14b0SPeter Avalos } else
1511a85e14b0SPeter Avalos offset += 8; /* skip USB setup header */
1512a85e14b0SPeter Avalos
151397a9217aSAntonio Huete Jimenez /*
151497a9217aSAntonio Huete Jimenez * With the old header, there are no isochronous descriptors
151597a9217aSAntonio Huete Jimenez * after the header.
151697a9217aSAntonio Huete Jimenez *
151797a9217aSAntonio Huete Jimenez * With the new header, the actual number of descriptors in
151897a9217aSAntonio Huete Jimenez * the header is not s.iso.numdesc, it's ndesc - only the
151997a9217aSAntonio Huete Jimenez * first N descriptors, for some value of N, are put into
152097a9217aSAntonio Huete Jimenez * the header, and ndesc is set to the actual number copied.
152197a9217aSAntonio Huete Jimenez * In addition, if s.iso.numdesc is negative, no descriptors
152297a9217aSAntonio Huete Jimenez * are captured, and ndesc is set to 0.
152397a9217aSAntonio Huete Jimenez */
1524a85e14b0SPeter Avalos if (header_len_64_bytes) {
1525a85e14b0SPeter Avalos /*
1526a85e14b0SPeter Avalos * This is either the "version 1" header, with
1527a85e14b0SPeter Avalos * 16 bytes of additional fields at the end, or
1528a85e14b0SPeter Avalos * a "version 0" header from a memory-mapped
1529a85e14b0SPeter Avalos * capture, with 16 bytes of zeroed-out padding
1530a85e14b0SPeter Avalos * at the end. Byte swap them as if this were
1531a85e14b0SPeter Avalos * a "version 1" header.
1532a85e14b0SPeter Avalos */
1533a85e14b0SPeter Avalos offset += 4; /* skip past interval */
1534a85e14b0SPeter Avalos if (hdr->caplen < offset)
1535a85e14b0SPeter Avalos return;
1536a85e14b0SPeter Avalos uhdr->interval = SWAPLONG(uhdr->interval);
1537a85e14b0SPeter Avalos
1538a85e14b0SPeter Avalos offset += 4; /* skip past start_frame */
1539a85e14b0SPeter Avalos if (hdr->caplen < offset)
1540a85e14b0SPeter Avalos return;
1541a85e14b0SPeter Avalos uhdr->start_frame = SWAPLONG(uhdr->start_frame);
1542a85e14b0SPeter Avalos
1543a85e14b0SPeter Avalos offset += 4; /* skip past xfer_flags */
1544a85e14b0SPeter Avalos if (hdr->caplen < offset)
1545a85e14b0SPeter Avalos return;
1546a85e14b0SPeter Avalos uhdr->xfer_flags = SWAPLONG(uhdr->xfer_flags);
1547a85e14b0SPeter Avalos
1548a85e14b0SPeter Avalos offset += 4; /* skip past ndesc */
1549a85e14b0SPeter Avalos if (hdr->caplen < offset)
1550a85e14b0SPeter Avalos return;
1551a85e14b0SPeter Avalos uhdr->ndesc = SWAPLONG(uhdr->ndesc);
1552a85e14b0SPeter Avalos
1553a85e14b0SPeter Avalos if (uhdr->transfer_type == URB_ISOCHRONOUS) {
1554a85e14b0SPeter Avalos /* swap the values in struct linux_usb_isodesc */
155597a9217aSAntonio Huete Jimenez usb_isodesc *pisodesc;
15563a289941SAaron LI uint32_t i;
155797a9217aSAntonio Huete Jimenez
1558a85e14b0SPeter Avalos pisodesc = (usb_isodesc *)(void *)(buf+offset);
155997a9217aSAntonio Huete Jimenez for (i = 0; i < uhdr->ndesc; i++) {
1560a85e14b0SPeter Avalos offset += 4; /* skip past status */
1561a85e14b0SPeter Avalos if (hdr->caplen < offset)
1562a85e14b0SPeter Avalos return;
1563a85e14b0SPeter Avalos pisodesc->status = SWAPLONG(pisodesc->status);
1564a85e14b0SPeter Avalos
1565a85e14b0SPeter Avalos offset += 4; /* skip past offset */
1566a85e14b0SPeter Avalos if (hdr->caplen < offset)
1567a85e14b0SPeter Avalos return;
1568a85e14b0SPeter Avalos pisodesc->offset = SWAPLONG(pisodesc->offset);
1569a85e14b0SPeter Avalos
1570a85e14b0SPeter Avalos offset += 4; /* skip past len */
1571a85e14b0SPeter Avalos if (hdr->caplen < offset)
1572a85e14b0SPeter Avalos return;
1573a85e14b0SPeter Avalos pisodesc->len = SWAPLONG(pisodesc->len);
1574a85e14b0SPeter Avalos
1575a85e14b0SPeter Avalos offset += 4; /* skip past padding */
1576a85e14b0SPeter Avalos
1577a85e14b0SPeter Avalos pisodesc++;
1578a85e14b0SPeter Avalos }
1579a85e14b0SPeter Avalos }
1580a85e14b0SPeter Avalos }
158197a9217aSAntonio Huete Jimenez }
158297a9217aSAntonio Huete Jimenez
158397a9217aSAntonio Huete Jimenez /*
158497a9217aSAntonio Huete Jimenez * The DLT_NFLOG "packets" have a mixture of big-endian and host-byte-order
158597a9217aSAntonio Huete Jimenez * data. They begin with a fixed-length header with big-endian fields,
158697a9217aSAntonio Huete Jimenez * followed by a set of TLVs, where the type and length are in host
158797a9217aSAntonio Huete Jimenez * byte order but the values are either big-endian or are a raw byte
158897a9217aSAntonio Huete Jimenez * sequence that's the same regardless of the host's byte order.
158997a9217aSAntonio Huete Jimenez *
159097a9217aSAntonio Huete Jimenez * When reading a DLT_NFLOG capture file, we need to convert the type
159197a9217aSAntonio Huete Jimenez * and length values from the byte order of the host that wrote the
159297a9217aSAntonio Huete Jimenez * file to the byte order of this host.
159397a9217aSAntonio Huete Jimenez */
159497a9217aSAntonio Huete Jimenez static void
swap_nflog_header(const struct pcap_pkthdr * hdr,u_char * buf)159597a9217aSAntonio Huete Jimenez swap_nflog_header(const struct pcap_pkthdr *hdr, u_char *buf)
159697a9217aSAntonio Huete Jimenez {
159797a9217aSAntonio Huete Jimenez u_char *p = buf;
159897a9217aSAntonio Huete Jimenez nflog_hdr_t *nfhdr = (nflog_hdr_t *)buf;
159997a9217aSAntonio Huete Jimenez nflog_tlv_t *tlv;
160097a9217aSAntonio Huete Jimenez u_int caplen = hdr->caplen;
160197a9217aSAntonio Huete Jimenez u_int length = hdr->len;
16023a289941SAaron LI uint16_t size;
160397a9217aSAntonio Huete Jimenez
160497a9217aSAntonio Huete Jimenez if (caplen < (u_int) sizeof(nflog_hdr_t) ||
160597a9217aSAntonio Huete Jimenez length < (u_int) sizeof(nflog_hdr_t)) {
160697a9217aSAntonio Huete Jimenez /* Not enough data to have any TLVs. */
160797a9217aSAntonio Huete Jimenez return;
160897a9217aSAntonio Huete Jimenez }
160997a9217aSAntonio Huete Jimenez
161097a9217aSAntonio Huete Jimenez if (nfhdr->nflog_version != 0) {
161197a9217aSAntonio Huete Jimenez /* Unknown NFLOG version */
161297a9217aSAntonio Huete Jimenez return;
161397a9217aSAntonio Huete Jimenez }
161497a9217aSAntonio Huete Jimenez
161597a9217aSAntonio Huete Jimenez length -= sizeof(nflog_hdr_t);
161697a9217aSAntonio Huete Jimenez caplen -= sizeof(nflog_hdr_t);
161797a9217aSAntonio Huete Jimenez p += sizeof(nflog_hdr_t);
161897a9217aSAntonio Huete Jimenez
161997a9217aSAntonio Huete Jimenez while (caplen >= sizeof(nflog_tlv_t)) {
162097a9217aSAntonio Huete Jimenez tlv = (nflog_tlv_t *) p;
162197a9217aSAntonio Huete Jimenez
162297a9217aSAntonio Huete Jimenez /* Swap the type and length. */
162397a9217aSAntonio Huete Jimenez tlv->tlv_type = SWAPSHORT(tlv->tlv_type);
162497a9217aSAntonio Huete Jimenez tlv->tlv_length = SWAPSHORT(tlv->tlv_length);
162597a9217aSAntonio Huete Jimenez
162697a9217aSAntonio Huete Jimenez /* Get the length of the TLV. */
162797a9217aSAntonio Huete Jimenez size = tlv->tlv_length;
162897a9217aSAntonio Huete Jimenez if (size % 4 != 0)
162997a9217aSAntonio Huete Jimenez size += 4 - size % 4;
163097a9217aSAntonio Huete Jimenez
163197a9217aSAntonio Huete Jimenez /* Is the TLV's length less than the minimum? */
163297a9217aSAntonio Huete Jimenez if (size < sizeof(nflog_tlv_t)) {
163397a9217aSAntonio Huete Jimenez /* Yes. Give up now. */
163497a9217aSAntonio Huete Jimenez return;
163597a9217aSAntonio Huete Jimenez }
163697a9217aSAntonio Huete Jimenez
163797a9217aSAntonio Huete Jimenez /* Do we have enough data for the full TLV? */
163897a9217aSAntonio Huete Jimenez if (caplen < size || length < size) {
163997a9217aSAntonio Huete Jimenez /* No. */
164097a9217aSAntonio Huete Jimenez return;
164197a9217aSAntonio Huete Jimenez }
164297a9217aSAntonio Huete Jimenez
164397a9217aSAntonio Huete Jimenez /* Skip over the TLV. */
164497a9217aSAntonio Huete Jimenez length -= size;
164597a9217aSAntonio Huete Jimenez caplen -= size;
164697a9217aSAntonio Huete Jimenez p += size;
164797a9217aSAntonio Huete Jimenez }
164897a9217aSAntonio Huete Jimenez }
164997a9217aSAntonio Huete Jimenez
165097a9217aSAntonio Huete Jimenez void
swap_pseudo_headers(int linktype,struct pcap_pkthdr * hdr,u_char * data)165197a9217aSAntonio Huete Jimenez swap_pseudo_headers(int linktype, struct pcap_pkthdr *hdr, u_char *data)
165297a9217aSAntonio Huete Jimenez {
165397a9217aSAntonio Huete Jimenez /*
165497a9217aSAntonio Huete Jimenez * Convert pseudo-headers from the byte order of
165597a9217aSAntonio Huete Jimenez * the host on which the file was saved to our
165697a9217aSAntonio Huete Jimenez * byte order, as necessary.
165797a9217aSAntonio Huete Jimenez */
165897a9217aSAntonio Huete Jimenez switch (linktype) {
165997a9217aSAntonio Huete Jimenez
166097a9217aSAntonio Huete Jimenez case DLT_LINUX_SLL:
166197a9217aSAntonio Huete Jimenez swap_linux_sll_header(hdr, data);
166297a9217aSAntonio Huete Jimenez break;
166397a9217aSAntonio Huete Jimenez
166497a9217aSAntonio Huete Jimenez case DLT_USB_LINUX:
166597a9217aSAntonio Huete Jimenez swap_linux_usb_header(hdr, data, 0);
166697a9217aSAntonio Huete Jimenez break;
166797a9217aSAntonio Huete Jimenez
166897a9217aSAntonio Huete Jimenez case DLT_USB_LINUX_MMAPPED:
166997a9217aSAntonio Huete Jimenez swap_linux_usb_header(hdr, data, 1);
167097a9217aSAntonio Huete Jimenez break;
167197a9217aSAntonio Huete Jimenez
167297a9217aSAntonio Huete Jimenez case DLT_NFLOG:
167397a9217aSAntonio Huete Jimenez swap_nflog_header(hdr, data);
167497a9217aSAntonio Huete Jimenez break;
167597a9217aSAntonio Huete Jimenez }
167697a9217aSAntonio Huete Jimenez }
1677