xref: /dflybsd-src/contrib/libpcap/pcap-common.c (revision a85e14b0832b9d7c1a3e7d4ce4aff1e6553e2162)
1*a85e14b0SPeter Avalos /*
2*a85e14b0SPeter Avalos  * Copyright (c) 1993, 1994, 1995, 1996, 1997
3*a85e14b0SPeter Avalos  *	The Regents of the University of California.  All rights reserved.
4*a85e14b0SPeter Avalos  *
5*a85e14b0SPeter Avalos  * Redistribution and use in source and binary forms, with or without
6*a85e14b0SPeter Avalos  * modification, are permitted provided that: (1) source code distributions
7*a85e14b0SPeter Avalos  * retain the above copyright notice and this paragraph in its entirety, (2)
8*a85e14b0SPeter Avalos  * distributions including binary code include the above copyright notice and
9*a85e14b0SPeter Avalos  * this paragraph in its entirety in the documentation or other materials
10*a85e14b0SPeter Avalos  * provided with the distribution, and (3) all advertising materials mentioning
11*a85e14b0SPeter Avalos  * features or use of this software display the following acknowledgement:
12*a85e14b0SPeter Avalos  * ``This product includes software developed by the University of California,
13*a85e14b0SPeter Avalos  * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14*a85e14b0SPeter Avalos  * the University nor the names of its contributors may be used to endorse
15*a85e14b0SPeter Avalos  * or promote products derived from this software without specific prior
16*a85e14b0SPeter Avalos  * written permission.
17*a85e14b0SPeter Avalos  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18*a85e14b0SPeter Avalos  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19*a85e14b0SPeter Avalos  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20*a85e14b0SPeter Avalos  *
21*a85e14b0SPeter Avalos  * pcap-common.c - common code for pcap and pcap-ng files
22*a85e14b0SPeter Avalos  */
23*a85e14b0SPeter Avalos 
24*a85e14b0SPeter Avalos #ifdef HAVE_CONFIG_H
25*a85e14b0SPeter Avalos #include "config.h"
26*a85e14b0SPeter Avalos #endif
27*a85e14b0SPeter Avalos 
28*a85e14b0SPeter Avalos #ifdef WIN32
29*a85e14b0SPeter Avalos #include <pcap-stdinc.h>
30*a85e14b0SPeter Avalos #else /* WIN32 */
31*a85e14b0SPeter Avalos #if HAVE_INTTYPES_H
32*a85e14b0SPeter Avalos #include <inttypes.h>
33*a85e14b0SPeter Avalos #elif HAVE_STDINT_H
34*a85e14b0SPeter Avalos #include <stdint.h>
35*a85e14b0SPeter Avalos #endif
36*a85e14b0SPeter Avalos #ifdef HAVE_SYS_BITYPES_H
37*a85e14b0SPeter Avalos #include <sys/bitypes.h>
38*a85e14b0SPeter Avalos #endif
39*a85e14b0SPeter Avalos #include <sys/types.h>
40*a85e14b0SPeter Avalos #endif /* WIN32 */
41*a85e14b0SPeter Avalos 
42*a85e14b0SPeter Avalos #include "pcap-int.h"
43*a85e14b0SPeter Avalos #include "pcap/usb.h"
44*a85e14b0SPeter Avalos 
45*a85e14b0SPeter Avalos #include "pcap-common.h"
46*a85e14b0SPeter Avalos 
47*a85e14b0SPeter Avalos /*
48*a85e14b0SPeter Avalos  * We don't write DLT_* values to capture files, because they're not the
49*a85e14b0SPeter Avalos  * same on all platforms.
50*a85e14b0SPeter Avalos  *
51*a85e14b0SPeter Avalos  * Unfortunately, the various flavors of BSD have not always used the same
52*a85e14b0SPeter Avalos  * numerical values for the same data types, and various patches to
53*a85e14b0SPeter Avalos  * libpcap for non-BSD OSes have added their own DLT_* codes for link
54*a85e14b0SPeter Avalos  * layer encapsulation types seen on those OSes, and those codes have had,
55*a85e14b0SPeter Avalos  * in some cases, values that were also used, on other platforms, for other
56*a85e14b0SPeter Avalos  * link layer encapsulation types.
57*a85e14b0SPeter Avalos  *
58*a85e14b0SPeter Avalos  * This means that capture files of a type whose numerical DLT_* code
59*a85e14b0SPeter Avalos  * means different things on different BSDs, or with different versions
60*a85e14b0SPeter Avalos  * of libpcap, can't always be read on systems other than those like
61*a85e14b0SPeter Avalos  * the one running on the machine on which the capture was made.
62*a85e14b0SPeter Avalos  *
63*a85e14b0SPeter Avalos  * Instead, we define here a set of LINKTYPE_* codes, and map DLT_* codes
64*a85e14b0SPeter Avalos  * to LINKTYPE_* codes when writing a savefile header, and map LINKTYPE_*
65*a85e14b0SPeter Avalos  * codes to DLT_* codes when reading a savefile header.
66*a85e14b0SPeter Avalos  *
67*a85e14b0SPeter Avalos  * For those DLT_* codes that have, as far as we know, the same values on
68*a85e14b0SPeter Avalos  * all platforms (DLT_NULL through DLT_FDDI), we define LINKTYPE_xxx as
69*a85e14b0SPeter Avalos  * DLT_xxx; that way, captures of those types can still be read by
70*a85e14b0SPeter Avalos  * versions of libpcap that map LINKTYPE_* values to DLT_* values, and
71*a85e14b0SPeter Avalos  * captures of those types written by versions of libpcap that map DLT_
72*a85e14b0SPeter Avalos  * values to LINKTYPE_ values can still be read by older versions
73*a85e14b0SPeter Avalos  * of libpcap.
74*a85e14b0SPeter Avalos  *
75*a85e14b0SPeter Avalos  * The other LINKTYPE_* codes are given values starting at 100, in the
76*a85e14b0SPeter Avalos  * hopes that no DLT_* code will be given one of those values.
77*a85e14b0SPeter Avalos  *
78*a85e14b0SPeter Avalos  * In order to ensure that a given LINKTYPE_* code's value will refer to
79*a85e14b0SPeter Avalos  * the same encapsulation type on all platforms, you should not allocate
80*a85e14b0SPeter Avalos  * a new LINKTYPE_* value without consulting
81*a85e14b0SPeter Avalos  * "tcpdump-workers@lists.tcpdump.org".  The tcpdump developers will
82*a85e14b0SPeter Avalos  * allocate a value for you, and will not subsequently allocate it to
83*a85e14b0SPeter Avalos  * anybody else; that value will be added to the "pcap.h" in the
84*a85e14b0SPeter Avalos  * tcpdump.org Git repository, so that a future libpcap release will
85*a85e14b0SPeter Avalos  * include it.
86*a85e14b0SPeter Avalos  *
87*a85e14b0SPeter Avalos  * You should, if possible, also contribute patches to libpcap and tcpdump
88*a85e14b0SPeter Avalos  * to handle the new encapsulation type, so that they can also be checked
89*a85e14b0SPeter Avalos  * into the tcpdump.org Git repository and so that they will appear in
90*a85e14b0SPeter Avalos  * future libpcap and tcpdump releases.
91*a85e14b0SPeter Avalos  *
92*a85e14b0SPeter Avalos  * Do *NOT* assume that any values after the largest value in this file
93*a85e14b0SPeter Avalos  * are available; you might not have the most up-to-date version of this
94*a85e14b0SPeter Avalos  * file, and new values after that one might have been assigned.  Also,
95*a85e14b0SPeter Avalos  * do *NOT* use any values below 100 - those might already have been
96*a85e14b0SPeter Avalos  * taken by one (or more!) organizations.
97*a85e14b0SPeter Avalos  *
98*a85e14b0SPeter Avalos  * Any platform that defines additional DLT_* codes should:
99*a85e14b0SPeter Avalos  *
100*a85e14b0SPeter Avalos  *	request a LINKTYPE_* code and value from tcpdump.org,
101*a85e14b0SPeter Avalos  *	as per the above;
102*a85e14b0SPeter Avalos  *
103*a85e14b0SPeter Avalos  *	add, in their version of libpcap, an entry to map
104*a85e14b0SPeter Avalos  *	those DLT_* codes to the corresponding LINKTYPE_*
105*a85e14b0SPeter Avalos  *	code;
106*a85e14b0SPeter Avalos  *
107*a85e14b0SPeter Avalos  *	redefine, in their "net/bpf.h", any DLT_* values
108*a85e14b0SPeter Avalos  *	that collide with the values used by their additional
109*a85e14b0SPeter Avalos  *	DLT_* codes, to remove those collisions (but without
110*a85e14b0SPeter Avalos  *	making them collide with any of the LINKTYPE_*
111*a85e14b0SPeter Avalos  *	values equal to 50 or above; they should also avoid
112*a85e14b0SPeter Avalos  *	defining DLT_* values that collide with those
113*a85e14b0SPeter Avalos  *	LINKTYPE_* values, either).
114*a85e14b0SPeter Avalos  */
115*a85e14b0SPeter Avalos #define LINKTYPE_NULL		DLT_NULL
116*a85e14b0SPeter Avalos #define LINKTYPE_ETHERNET	DLT_EN10MB	/* also for 100Mb and up */
117*a85e14b0SPeter Avalos #define LINKTYPE_EXP_ETHERNET	DLT_EN3MB	/* 3Mb experimental Ethernet */
118*a85e14b0SPeter Avalos #define LINKTYPE_AX25		DLT_AX25
119*a85e14b0SPeter Avalos #define LINKTYPE_PRONET		DLT_PRONET
120*a85e14b0SPeter Avalos #define LINKTYPE_CHAOS		DLT_CHAOS
121*a85e14b0SPeter Avalos #define LINKTYPE_TOKEN_RING	DLT_IEEE802	/* DLT_IEEE802 is used for Token Ring */
122*a85e14b0SPeter Avalos #define LINKTYPE_ARCNET_BSD	DLT_ARCNET	/* BSD-style headers */
123*a85e14b0SPeter Avalos #define LINKTYPE_SLIP		DLT_SLIP
124*a85e14b0SPeter Avalos #define LINKTYPE_PPP		DLT_PPP
125*a85e14b0SPeter Avalos #define LINKTYPE_FDDI		DLT_FDDI
126*a85e14b0SPeter Avalos 
127*a85e14b0SPeter Avalos /*
128*a85e14b0SPeter Avalos  * LINKTYPE_PPP is for use when there might, or might not, be an RFC 1662
129*a85e14b0SPeter Avalos  * PPP in HDLC-like framing header (with 0xff 0x03 before the PPP protocol
130*a85e14b0SPeter Avalos  * field) at the beginning of the packet.
131*a85e14b0SPeter Avalos  *
132*a85e14b0SPeter Avalos  * This is for use when there is always such a header; the address field
133*a85e14b0SPeter Avalos  * might be 0xff, for regular PPP, or it might be an address field for Cisco
134*a85e14b0SPeter Avalos  * point-to-point with HDLC framing as per section 4.3.1 of RFC 1547 ("Cisco
135*a85e14b0SPeter Avalos  * HDLC").  This is, for example, what you get with NetBSD's DLT_PPP_SERIAL.
136*a85e14b0SPeter Avalos  *
137*a85e14b0SPeter Avalos  * We give it the same value as NetBSD's DLT_PPP_SERIAL, in the hopes that
138*a85e14b0SPeter Avalos  * nobody else will choose a DLT_ value of 50, and so that DLT_PPP_SERIAL
139*a85e14b0SPeter Avalos  * captures will be written out with a link type that NetBSD's tcpdump
140*a85e14b0SPeter Avalos  * can read.
141*a85e14b0SPeter Avalos  */
142*a85e14b0SPeter Avalos #define LINKTYPE_PPP_HDLC	50		/* PPP in HDLC-like framing */
143*a85e14b0SPeter Avalos 
144*a85e14b0SPeter Avalos #define LINKTYPE_PPP_ETHER	51		/* NetBSD PPP-over-Ethernet */
145*a85e14b0SPeter Avalos 
146*a85e14b0SPeter Avalos #define LINKTYPE_SYMANTEC_FIREWALL 99		/* Symantec Enterprise Firewall */
147*a85e14b0SPeter Avalos 
148*a85e14b0SPeter Avalos /*
149*a85e14b0SPeter Avalos  * These correspond to DLT_s that have different values on different
150*a85e14b0SPeter Avalos  * platforms; we map between these values in capture files and
151*a85e14b0SPeter Avalos  * the DLT_ values as returned by pcap_datalink() and passed to
152*a85e14b0SPeter Avalos  * pcap_open_dead().
153*a85e14b0SPeter Avalos  */
154*a85e14b0SPeter Avalos #define LINKTYPE_ATM_RFC1483	100		/* LLC/SNAP-encapsulated ATM */
155*a85e14b0SPeter Avalos #define LINKTYPE_RAW		101		/* raw IP */
156*a85e14b0SPeter Avalos #define LINKTYPE_SLIP_BSDOS	102		/* BSD/OS SLIP BPF header */
157*a85e14b0SPeter Avalos #define LINKTYPE_PPP_BSDOS	103		/* BSD/OS PPP BPF header */
158*a85e14b0SPeter Avalos 
159*a85e14b0SPeter Avalos /*
160*a85e14b0SPeter Avalos  * Values starting with 104 are used for newly-assigned link-layer
161*a85e14b0SPeter Avalos  * header type values; for those link-layer header types, the DLT_
162*a85e14b0SPeter Avalos  * value returned by pcap_datalink() and passed to pcap_open_dead(),
163*a85e14b0SPeter Avalos  * and the LINKTYPE_ value that appears in capture files, are the
164*a85e14b0SPeter Avalos  * same.
165*a85e14b0SPeter Avalos  *
166*a85e14b0SPeter Avalos  * LINKTYPE_MATCHING_MIN is the lowest such value; LINKTYPE_MATCHING_MAX
167*a85e14b0SPeter Avalos  * is the highest such value.
168*a85e14b0SPeter Avalos  */
169*a85e14b0SPeter Avalos #define LINKTYPE_MATCHING_MIN	104		/* lowest value in the "matching" range */
170*a85e14b0SPeter Avalos 
171*a85e14b0SPeter Avalos #define LINKTYPE_C_HDLC		104		/* Cisco HDLC */
172*a85e14b0SPeter Avalos #define LINKTYPE_IEEE802_11	105		/* IEEE 802.11 (wireless) */
173*a85e14b0SPeter Avalos #define LINKTYPE_ATM_CLIP	106		/* Linux Classical IP over ATM */
174*a85e14b0SPeter Avalos #define LINKTYPE_FRELAY		107		/* Frame Relay */
175*a85e14b0SPeter Avalos #define LINKTYPE_LOOP		108		/* OpenBSD loopback */
176*a85e14b0SPeter Avalos #define LINKTYPE_ENC		109		/* OpenBSD IPSEC enc */
177*a85e14b0SPeter Avalos 
178*a85e14b0SPeter Avalos /*
179*a85e14b0SPeter Avalos  * These three types are reserved for future use.
180*a85e14b0SPeter Avalos  */
181*a85e14b0SPeter Avalos #define LINKTYPE_LANE8023	110		/* ATM LANE + 802.3 */
182*a85e14b0SPeter Avalos #define LINKTYPE_HIPPI		111		/* NetBSD HIPPI */
183*a85e14b0SPeter Avalos #define LINKTYPE_HDLC		112		/* NetBSD HDLC framing */
184*a85e14b0SPeter Avalos 
185*a85e14b0SPeter Avalos #define LINKTYPE_LINUX_SLL	113		/* Linux cooked socket capture */
186*a85e14b0SPeter Avalos #define LINKTYPE_LTALK		114		/* Apple LocalTalk hardware */
187*a85e14b0SPeter Avalos #define LINKTYPE_ECONET		115		/* Acorn Econet */
188*a85e14b0SPeter Avalos 
189*a85e14b0SPeter Avalos /*
190*a85e14b0SPeter Avalos  * Reserved for use with OpenBSD ipfilter.
191*a85e14b0SPeter Avalos  */
192*a85e14b0SPeter Avalos #define LINKTYPE_IPFILTER	116
193*a85e14b0SPeter Avalos 
194*a85e14b0SPeter Avalos #define LINKTYPE_PFLOG		117		/* OpenBSD DLT_PFLOG */
195*a85e14b0SPeter Avalos #define LINKTYPE_CISCO_IOS	118		/* For Cisco-internal use */
196*a85e14b0SPeter Avalos #define LINKTYPE_PRISM_HEADER	119		/* 802.11+Prism II monitor mode */
197*a85e14b0SPeter Avalos #define LINKTYPE_AIRONET_HEADER	120		/* FreeBSD Aironet driver stuff */
198*a85e14b0SPeter Avalos 
199*a85e14b0SPeter Avalos /*
200*a85e14b0SPeter Avalos  * Reserved for Siemens HiPath HDLC.
201*a85e14b0SPeter Avalos  */
202*a85e14b0SPeter Avalos #define LINKTYPE_HHDLC		121
203*a85e14b0SPeter Avalos 
204*a85e14b0SPeter Avalos #define LINKTYPE_IP_OVER_FC	122		/* RFC 2625 IP-over-Fibre Channel */
205*a85e14b0SPeter Avalos #define LINKTYPE_SUNATM		123		/* Solaris+SunATM */
206*a85e14b0SPeter Avalos 
207*a85e14b0SPeter Avalos /*
208*a85e14b0SPeter Avalos  * Reserved as per request from Kent Dahlgren <kent@praesum.com>
209*a85e14b0SPeter Avalos  * for private use.
210*a85e14b0SPeter Avalos  */
211*a85e14b0SPeter Avalos #define LINKTYPE_RIO		124		/* RapidIO */
212*a85e14b0SPeter Avalos #define LINKTYPE_PCI_EXP	125		/* PCI Express */
213*a85e14b0SPeter Avalos #define LINKTYPE_AURORA		126		/* Xilinx Aurora link layer */
214*a85e14b0SPeter Avalos 
215*a85e14b0SPeter Avalos #define LINKTYPE_IEEE802_11_RADIO 127		/* 802.11 plus BSD radio header */
216*a85e14b0SPeter Avalos 
217*a85e14b0SPeter Avalos /*
218*a85e14b0SPeter Avalos  * Reserved for the TZSP encapsulation, as per request from
219*a85e14b0SPeter Avalos  * Chris Waters <chris.waters@networkchemistry.com>
220*a85e14b0SPeter Avalos  * TZSP is a generic encapsulation for any other link type,
221*a85e14b0SPeter Avalos  * which includes a means to include meta-information
222*a85e14b0SPeter Avalos  * with the packet, e.g. signal strength and channel
223*a85e14b0SPeter Avalos  * for 802.11 packets.
224*a85e14b0SPeter Avalos  */
225*a85e14b0SPeter Avalos #define LINKTYPE_TZSP		128		/* Tazmen Sniffer Protocol */
226*a85e14b0SPeter Avalos 
227*a85e14b0SPeter Avalos #define LINKTYPE_ARCNET_LINUX	129		/* Linux-style headers */
228*a85e14b0SPeter Avalos 
229*a85e14b0SPeter Avalos /*
230*a85e14b0SPeter Avalos  * Juniper-private data link types, as per request from
231*a85e14b0SPeter Avalos  * Hannes Gredler <hannes@juniper.net>.  The corresponding
232*a85e14b0SPeter Avalos  * DLT_s are used for passing on chassis-internal
233*a85e14b0SPeter Avalos  * metainformation such as QOS profiles, etc..
234*a85e14b0SPeter Avalos  */
235*a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_MLPPP  130
236*a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_MLFR   131
237*a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_ES     132
238*a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_GGSN   133
239*a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_MFR    134
240*a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_ATM2   135
241*a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_SERVICES 136
242*a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_ATM1   137
243*a85e14b0SPeter Avalos 
244*a85e14b0SPeter Avalos #define LINKTYPE_APPLE_IP_OVER_IEEE1394 138	/* Apple IP-over-IEEE 1394 cooked header */
245*a85e14b0SPeter Avalos 
246*a85e14b0SPeter Avalos #define LINKTYPE_MTP2_WITH_PHDR	139
247*a85e14b0SPeter Avalos #define LINKTYPE_MTP2		140
248*a85e14b0SPeter Avalos #define LINKTYPE_MTP3		141
249*a85e14b0SPeter Avalos #define LINKTYPE_SCCP		142
250*a85e14b0SPeter Avalos 
251*a85e14b0SPeter Avalos #define LINKTYPE_DOCSIS		143		/* DOCSIS MAC frames */
252*a85e14b0SPeter Avalos 
253*a85e14b0SPeter Avalos #define LINKTYPE_LINUX_IRDA	144		/* Linux-IrDA */
254*a85e14b0SPeter Avalos 
255*a85e14b0SPeter Avalos /*
256*a85e14b0SPeter Avalos  * Reserved for IBM SP switch and IBM Next Federation switch.
257*a85e14b0SPeter Avalos  */
258*a85e14b0SPeter Avalos #define LINKTYPE_IBM_SP		145
259*a85e14b0SPeter Avalos #define LINKTYPE_IBM_SN		146
260*a85e14b0SPeter Avalos 
261*a85e14b0SPeter Avalos /*
262*a85e14b0SPeter Avalos  * Reserved for private use.  If you have some link-layer header type
263*a85e14b0SPeter Avalos  * that you want to use within your organization, with the capture files
264*a85e14b0SPeter Avalos  * using that link-layer header type not ever be sent outside your
265*a85e14b0SPeter Avalos  * organization, you can use these values.
266*a85e14b0SPeter Avalos  *
267*a85e14b0SPeter Avalos  * No libpcap release will use these for any purpose, nor will any
268*a85e14b0SPeter Avalos  * tcpdump release use them, either.
269*a85e14b0SPeter Avalos  *
270*a85e14b0SPeter Avalos  * Do *NOT* use these in capture files that you expect anybody not using
271*a85e14b0SPeter Avalos  * your private versions of capture-file-reading tools to read; in
272*a85e14b0SPeter Avalos  * particular, do *NOT* use them in products, otherwise you may find that
273*a85e14b0SPeter Avalos  * people won't be able to use tcpdump, or snort, or Ethereal, or... to
274*a85e14b0SPeter Avalos  * read capture files from your firewall/intrusion detection/traffic
275*a85e14b0SPeter Avalos  * monitoring/etc. appliance, or whatever product uses that LINKTYPE_ value,
276*a85e14b0SPeter Avalos  * and you may also find that the developers of those applications will
277*a85e14b0SPeter Avalos  * not accept patches to let them read those files.
278*a85e14b0SPeter Avalos  *
279*a85e14b0SPeter Avalos  * Also, do not use them if somebody might send you a capture using them
280*a85e14b0SPeter Avalos  * for *their* private type and tools using them for *your* private type
281*a85e14b0SPeter Avalos  * would have to read them.
282*a85e14b0SPeter Avalos  *
283*a85e14b0SPeter Avalos  * Instead, in those cases, ask "tcpdump-workers@lists.tcpdump.org" for a
284*a85e14b0SPeter Avalos  * new DLT_ and LINKTYPE_ value, as per the comment in pcap/bpf.h, and use
285*a85e14b0SPeter Avalos  * the type you're given.
286*a85e14b0SPeter Avalos  */
287*a85e14b0SPeter Avalos #define LINKTYPE_USER0		147
288*a85e14b0SPeter Avalos #define LINKTYPE_USER1		148
289*a85e14b0SPeter Avalos #define LINKTYPE_USER2		149
290*a85e14b0SPeter Avalos #define LINKTYPE_USER3		150
291*a85e14b0SPeter Avalos #define LINKTYPE_USER4		151
292*a85e14b0SPeter Avalos #define LINKTYPE_USER5		152
293*a85e14b0SPeter Avalos #define LINKTYPE_USER6		153
294*a85e14b0SPeter Avalos #define LINKTYPE_USER7		154
295*a85e14b0SPeter Avalos #define LINKTYPE_USER8		155
296*a85e14b0SPeter Avalos #define LINKTYPE_USER9		156
297*a85e14b0SPeter Avalos #define LINKTYPE_USER10		157
298*a85e14b0SPeter Avalos #define LINKTYPE_USER11		158
299*a85e14b0SPeter Avalos #define LINKTYPE_USER12		159
300*a85e14b0SPeter Avalos #define LINKTYPE_USER13		160
301*a85e14b0SPeter Avalos #define LINKTYPE_USER14		161
302*a85e14b0SPeter Avalos #define LINKTYPE_USER15		162
303*a85e14b0SPeter Avalos 
304*a85e14b0SPeter Avalos /*
305*a85e14b0SPeter Avalos  * For future use with 802.11 captures - defined by AbsoluteValue
306*a85e14b0SPeter Avalos  * Systems to store a number of bits of link-layer information
307*a85e14b0SPeter Avalos  * including radio information:
308*a85e14b0SPeter Avalos  *
309*a85e14b0SPeter Avalos  *	http://www.shaftnet.org/~pizza/software/capturefrm.txt
310*a85e14b0SPeter Avalos  *
311*a85e14b0SPeter Avalos  * but could and arguably should also be used by non-AVS Linux
312*a85e14b0SPeter Avalos  * 802.11 drivers; that may happen in the future.
313*a85e14b0SPeter Avalos  */
314*a85e14b0SPeter Avalos #define LINKTYPE_IEEE802_11_RADIO_AVS 163	/* 802.11 plus AVS radio header */
315*a85e14b0SPeter Avalos 
316*a85e14b0SPeter Avalos /*
317*a85e14b0SPeter Avalos  * Juniper-private data link type, as per request from
318*a85e14b0SPeter Avalos  * Hannes Gredler <hannes@juniper.net>.  The corresponding
319*a85e14b0SPeter Avalos  * DLT_s are used for passing on chassis-internal
320*a85e14b0SPeter Avalos  * metainformation such as QOS profiles, etc..
321*a85e14b0SPeter Avalos  */
322*a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_MONITOR 164
323*a85e14b0SPeter Avalos 
324*a85e14b0SPeter Avalos /*
325*a85e14b0SPeter Avalos  * Reserved for BACnet MS/TP.
326*a85e14b0SPeter Avalos  */
327*a85e14b0SPeter Avalos #define LINKTYPE_BACNET_MS_TP	165
328*a85e14b0SPeter Avalos 
329*a85e14b0SPeter Avalos /*
330*a85e14b0SPeter Avalos  * Another PPP variant as per request from Karsten Keil <kkeil@suse.de>.
331*a85e14b0SPeter Avalos  *
332*a85e14b0SPeter Avalos  * This is used in some OSes to allow a kernel socket filter to distinguish
333*a85e14b0SPeter Avalos  * between incoming and outgoing packets, on a socket intended to
334*a85e14b0SPeter Avalos  * supply pppd with outgoing packets so it can do dial-on-demand and
335*a85e14b0SPeter Avalos  * hangup-on-lack-of-demand; incoming packets are filtered out so they
336*a85e14b0SPeter Avalos  * don't cause pppd to hold the connection up (you don't want random
337*a85e14b0SPeter Avalos  * input packets such as port scans, packets from old lost connections,
338*a85e14b0SPeter Avalos  * etc. to force the connection to stay up).
339*a85e14b0SPeter Avalos  *
340*a85e14b0SPeter Avalos  * The first byte of the PPP header (0xff03) is modified to accomodate
341*a85e14b0SPeter Avalos  * the direction - 0x00 = IN, 0x01 = OUT.
342*a85e14b0SPeter Avalos  */
343*a85e14b0SPeter Avalos #define LINKTYPE_PPP_PPPD	166
344*a85e14b0SPeter Avalos 
345*a85e14b0SPeter Avalos /*
346*a85e14b0SPeter Avalos  * Juniper-private data link type, as per request from
347*a85e14b0SPeter Avalos  * Hannes Gredler <hannes@juniper.net>.  The DLT_s are used
348*a85e14b0SPeter Avalos  * for passing on chassis-internal metainformation such as
349*a85e14b0SPeter Avalos  * QOS profiles, cookies, etc..
350*a85e14b0SPeter Avalos  */
351*a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_PPPOE     167
352*a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_PPPOE_ATM 168
353*a85e14b0SPeter Avalos 
354*a85e14b0SPeter Avalos #define LINKTYPE_GPRS_LLC	169		/* GPRS LLC */
355*a85e14b0SPeter Avalos #define LINKTYPE_GPF_T		170		/* GPF-T (ITU-T G.7041/Y.1303) */
356*a85e14b0SPeter Avalos #define LINKTYPE_GPF_F		171		/* GPF-T (ITU-T G.7041/Y.1303) */
357*a85e14b0SPeter Avalos 
358*a85e14b0SPeter Avalos /*
359*a85e14b0SPeter Avalos  * Requested by Oolan Zimmer <oz@gcom.com> for use in Gcom's T1/E1 line
360*a85e14b0SPeter Avalos  * monitoring equipment.
361*a85e14b0SPeter Avalos  */
362*a85e14b0SPeter Avalos #define LINKTYPE_GCOM_T1E1	172
363*a85e14b0SPeter Avalos #define LINKTYPE_GCOM_SERIAL	173
364*a85e14b0SPeter Avalos 
365*a85e14b0SPeter Avalos /*
366*a85e14b0SPeter Avalos  * Juniper-private data link type, as per request from
367*a85e14b0SPeter Avalos  * Hannes Gredler <hannes@juniper.net>.  The DLT_ is used
368*a85e14b0SPeter Avalos  * for internal communication to Physical Interface Cards (PIC)
369*a85e14b0SPeter Avalos  */
370*a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_PIC_PEER    174
371*a85e14b0SPeter Avalos 
372*a85e14b0SPeter Avalos /*
373*a85e14b0SPeter Avalos  * Link types requested by Gregor Maier <gregor@endace.com> of Endace
374*a85e14b0SPeter Avalos  * Measurement Systems.  They add an ERF header (see
375*a85e14b0SPeter Avalos  * http://www.endace.com/support/EndaceRecordFormat.pdf) in front of
376*a85e14b0SPeter Avalos  * the link-layer header.
377*a85e14b0SPeter Avalos  */
378*a85e14b0SPeter Avalos #define LINKTYPE_ERF_ETH	175	/* Ethernet */
379*a85e14b0SPeter Avalos #define LINKTYPE_ERF_POS	176	/* Packet-over-SONET */
380*a85e14b0SPeter Avalos 
381*a85e14b0SPeter Avalos /*
382*a85e14b0SPeter Avalos  * Requested by Daniele Orlandi <daniele@orlandi.com> for raw LAPD
383*a85e14b0SPeter Avalos  * for vISDN (http://www.orlandi.com/visdn/).  Its link-layer header
384*a85e14b0SPeter Avalos  * includes additional information before the LAPD header, so it's
385*a85e14b0SPeter Avalos  * not necessarily a generic LAPD header.
386*a85e14b0SPeter Avalos  */
387*a85e14b0SPeter Avalos #define LINKTYPE_LINUX_LAPD	177
388*a85e14b0SPeter Avalos 
389*a85e14b0SPeter Avalos /*
390*a85e14b0SPeter Avalos  * Juniper-private data link type, as per request from
391*a85e14b0SPeter Avalos  * Hannes Gredler <hannes@juniper.net>.
392*a85e14b0SPeter Avalos  * The Link Types are used for prepending meta-information
393*a85e14b0SPeter Avalos  * like interface index, interface name
394*a85e14b0SPeter Avalos  * before standard Ethernet, PPP, Frelay & C-HDLC Frames
395*a85e14b0SPeter Avalos  */
396*a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_ETHER  178
397*a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_PPP    179
398*a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_FRELAY 180
399*a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_CHDLC  181
400*a85e14b0SPeter Avalos 
401*a85e14b0SPeter Avalos /*
402*a85e14b0SPeter Avalos  * Multi Link Frame Relay (FRF.16)
403*a85e14b0SPeter Avalos  */
404*a85e14b0SPeter Avalos #define LINKTYPE_MFR            182
405*a85e14b0SPeter Avalos 
406*a85e14b0SPeter Avalos /*
407*a85e14b0SPeter Avalos  * Juniper-private data link type, as per request from
408*a85e14b0SPeter Avalos  * Hannes Gredler <hannes@juniper.net>.
409*a85e14b0SPeter Avalos  * The DLT_ is used for internal communication with a
410*a85e14b0SPeter Avalos  * voice Adapter Card (PIC)
411*a85e14b0SPeter Avalos  */
412*a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_VP     183
413*a85e14b0SPeter Avalos 
414*a85e14b0SPeter Avalos /*
415*a85e14b0SPeter Avalos  * Arinc 429 frames.
416*a85e14b0SPeter Avalos  * DLT_ requested by Gianluca Varenni <gianluca.varenni@cacetech.com>.
417*a85e14b0SPeter Avalos  * Every frame contains a 32bit A429 label.
418*a85e14b0SPeter Avalos  * More documentation on Arinc 429 can be found at
419*a85e14b0SPeter Avalos  * http://www.condoreng.com/support/downloads/tutorials/ARINCTutorial.pdf
420*a85e14b0SPeter Avalos  */
421*a85e14b0SPeter Avalos #define LINKTYPE_A429           184
422*a85e14b0SPeter Avalos 
423*a85e14b0SPeter Avalos /*
424*a85e14b0SPeter Avalos  * Arinc 653 Interpartition Communication messages.
425*a85e14b0SPeter Avalos  * DLT_ requested by Gianluca Varenni <gianluca.varenni@cacetech.com>.
426*a85e14b0SPeter Avalos  * Please refer to the A653-1 standard for more information.
427*a85e14b0SPeter Avalos  */
428*a85e14b0SPeter Avalos #define LINKTYPE_A653_ICM       185
429*a85e14b0SPeter Avalos 
430*a85e14b0SPeter Avalos /*
431*a85e14b0SPeter Avalos  * USB packets, beginning with a USB setup header; requested by
432*a85e14b0SPeter Avalos  * Paolo Abeni <paolo.abeni@email.it>.
433*a85e14b0SPeter Avalos  */
434*a85e14b0SPeter Avalos #define LINKTYPE_USB		186
435*a85e14b0SPeter Avalos 
436*a85e14b0SPeter Avalos /*
437*a85e14b0SPeter Avalos  * Bluetooth HCI UART transport layer (part H:4); requested by
438*a85e14b0SPeter Avalos  * Paolo Abeni.
439*a85e14b0SPeter Avalos  */
440*a85e14b0SPeter Avalos #define LINKTYPE_BLUETOOTH_HCI_H4	187
441*a85e14b0SPeter Avalos 
442*a85e14b0SPeter Avalos /*
443*a85e14b0SPeter Avalos  * IEEE 802.16 MAC Common Part Sublayer; requested by Maria Cruz
444*a85e14b0SPeter Avalos  * <cruz_petagay@bah.com>.
445*a85e14b0SPeter Avalos  */
446*a85e14b0SPeter Avalos #define LINKTYPE_IEEE802_16_MAC_CPS	188
447*a85e14b0SPeter Avalos 
448*a85e14b0SPeter Avalos /*
449*a85e14b0SPeter Avalos  * USB packets, beginning with a Linux USB header; requested by
450*a85e14b0SPeter Avalos  * Paolo Abeni <paolo.abeni@email.it>.
451*a85e14b0SPeter Avalos  */
452*a85e14b0SPeter Avalos #define LINKTYPE_USB_LINUX		189
453*a85e14b0SPeter Avalos 
454*a85e14b0SPeter Avalos /*
455*a85e14b0SPeter Avalos  * Controller Area Network (CAN) v. 2.0B packets.
456*a85e14b0SPeter Avalos  * DLT_ requested by Gianluca Varenni <gianluca.varenni@cacetech.com>.
457*a85e14b0SPeter Avalos  * Used to dump CAN packets coming from a CAN Vector board.
458*a85e14b0SPeter Avalos  * More documentation on the CAN v2.0B frames can be found at
459*a85e14b0SPeter Avalos  * http://www.can-cia.org/downloads/?269
460*a85e14b0SPeter Avalos  */
461*a85e14b0SPeter Avalos #define LINKTYPE_CAN20B         190
462*a85e14b0SPeter Avalos 
463*a85e14b0SPeter Avalos /*
464*a85e14b0SPeter Avalos  * IEEE 802.15.4, with address fields padded, as is done by Linux
465*a85e14b0SPeter Avalos  * drivers; requested by Juergen Schimmer.
466*a85e14b0SPeter Avalos  */
467*a85e14b0SPeter Avalos #define LINKTYPE_IEEE802_15_4_LINUX	191
468*a85e14b0SPeter Avalos 
469*a85e14b0SPeter Avalos /*
470*a85e14b0SPeter Avalos  * Per Packet Information encapsulated packets.
471*a85e14b0SPeter Avalos  * LINKTYPE_ requested by Gianluca Varenni <gianluca.varenni@cacetech.com>.
472*a85e14b0SPeter Avalos  */
473*a85e14b0SPeter Avalos #define LINKTYPE_PPI			192
474*a85e14b0SPeter Avalos 
475*a85e14b0SPeter Avalos /*
476*a85e14b0SPeter Avalos  * Header for 802.16 MAC Common Part Sublayer plus a radiotap radio header;
477*a85e14b0SPeter Avalos  * requested by Charles Clancy.
478*a85e14b0SPeter Avalos  */
479*a85e14b0SPeter Avalos #define LINKTYPE_IEEE802_16_MAC_CPS_RADIO	193
480*a85e14b0SPeter Avalos 
481*a85e14b0SPeter Avalos /*
482*a85e14b0SPeter Avalos  * Juniper-private data link type, as per request from
483*a85e14b0SPeter Avalos  * Hannes Gredler <hannes@juniper.net>.
484*a85e14b0SPeter Avalos  * The DLT_ is used for internal communication with a
485*a85e14b0SPeter Avalos  * integrated service module (ISM).
486*a85e14b0SPeter Avalos  */
487*a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_ISM    194
488*a85e14b0SPeter Avalos 
489*a85e14b0SPeter Avalos /*
490*a85e14b0SPeter Avalos  * IEEE 802.15.4, exactly as it appears in the spec (no padding, no
491*a85e14b0SPeter Avalos  * nothing); requested by Mikko Saarnivala <mikko.saarnivala@sensinode.com>.
492*a85e14b0SPeter Avalos  */
493*a85e14b0SPeter Avalos #define LINKTYPE_IEEE802_15_4	195
494*a85e14b0SPeter Avalos 
495*a85e14b0SPeter Avalos /*
496*a85e14b0SPeter Avalos  * Various link-layer types, with a pseudo-header, for SITA
497*a85e14b0SPeter Avalos  * (http://www.sita.aero/); requested by Fulko Hew (fulko.hew@gmail.com).
498*a85e14b0SPeter Avalos  */
499*a85e14b0SPeter Avalos #define LINKTYPE_SITA		196
500*a85e14b0SPeter Avalos 
501*a85e14b0SPeter Avalos /*
502*a85e14b0SPeter Avalos  * Various link-layer types, with a pseudo-header, for Endace DAG cards;
503*a85e14b0SPeter Avalos  * encapsulates Endace ERF records.  Requested by Stephen Donnelly
504*a85e14b0SPeter Avalos  * <stephen@endace.com>.
505*a85e14b0SPeter Avalos  */
506*a85e14b0SPeter Avalos #define LINKTYPE_ERF		197
507*a85e14b0SPeter Avalos 
508*a85e14b0SPeter Avalos /*
509*a85e14b0SPeter Avalos  * Special header prepended to Ethernet packets when capturing from a
510*a85e14b0SPeter Avalos  * u10 Networks board.  Requested by Phil Mulholland
511*a85e14b0SPeter Avalos  * <phil@u10networks.com>.
512*a85e14b0SPeter Avalos  */
513*a85e14b0SPeter Avalos #define LINKTYPE_RAIF1		198
514*a85e14b0SPeter Avalos 
515*a85e14b0SPeter Avalos /*
516*a85e14b0SPeter Avalos  * IPMB packet for IPMI, beginning with the I2C slave address, followed
517*a85e14b0SPeter Avalos  * by the netFn and LUN, etc..  Requested by Chanthy Toeung
518*a85e14b0SPeter Avalos  * <chanthy.toeung@ca.kontron.com>.
519*a85e14b0SPeter Avalos  */
520*a85e14b0SPeter Avalos #define LINKTYPE_IPMB		199
521*a85e14b0SPeter Avalos 
522*a85e14b0SPeter Avalos /*
523*a85e14b0SPeter Avalos  * Juniper-private data link type, as per request from
524*a85e14b0SPeter Avalos  * Hannes Gredler <hannes@juniper.net>.
525*a85e14b0SPeter Avalos  * The DLT_ is used for capturing data on a secure tunnel interface.
526*a85e14b0SPeter Avalos  */
527*a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_ST     200
528*a85e14b0SPeter Avalos 
529*a85e14b0SPeter Avalos /*
530*a85e14b0SPeter Avalos  * Bluetooth HCI UART transport layer (part H:4), with pseudo-header
531*a85e14b0SPeter Avalos  * that includes direction information; requested by Paolo Abeni.
532*a85e14b0SPeter Avalos  */
533*a85e14b0SPeter Avalos #define LINKTYPE_BLUETOOTH_HCI_H4_WITH_PHDR	201
534*a85e14b0SPeter Avalos 
535*a85e14b0SPeter Avalos /*
536*a85e14b0SPeter Avalos  * AX.25 packet with a 1-byte KISS header; see
537*a85e14b0SPeter Avalos  *
538*a85e14b0SPeter Avalos  *	http://www.ax25.net/kiss.htm
539*a85e14b0SPeter Avalos  *
540*a85e14b0SPeter Avalos  * as per Richard Stearn <richard@rns-stearn.demon.co.uk>.
541*a85e14b0SPeter Avalos  */
542*a85e14b0SPeter Avalos #define LINKTYPE_AX25_KISS	202
543*a85e14b0SPeter Avalos 
544*a85e14b0SPeter Avalos /*
545*a85e14b0SPeter Avalos  * LAPD packets from an ISDN channel, starting with the address field,
546*a85e14b0SPeter Avalos  * with no pseudo-header.
547*a85e14b0SPeter Avalos  * Requested by Varuna De Silva <varunax@gmail.com>.
548*a85e14b0SPeter Avalos  */
549*a85e14b0SPeter Avalos #define LINKTYPE_LAPD		203
550*a85e14b0SPeter Avalos 
551*a85e14b0SPeter Avalos /*
552*a85e14b0SPeter Avalos  * Variants of various link-layer headers, with a one-byte direction
553*a85e14b0SPeter Avalos  * pseudo-header prepended - zero means "received by this host",
554*a85e14b0SPeter Avalos  * non-zero (any non-zero value) means "sent by this host" - as per
555*a85e14b0SPeter Avalos  * Will Barker <w.barker@zen.co.uk>.
556*a85e14b0SPeter Avalos  */
557*a85e14b0SPeter Avalos #define LINKTYPE_PPP_WITH_DIR	204	/* PPP */
558*a85e14b0SPeter Avalos #define LINKTYPE_C_HDLC_WITH_DIR 205	/* Cisco HDLC */
559*a85e14b0SPeter Avalos #define LINKTYPE_FRELAY_WITH_DIR 206	/* Frame Relay */
560*a85e14b0SPeter Avalos #define LINKTYPE_LAPB_WITH_DIR	207	/* LAPB */
561*a85e14b0SPeter Avalos 
562*a85e14b0SPeter Avalos /*
563*a85e14b0SPeter Avalos  * 208 is reserved for an as-yet-unspecified proprietary link-layer
564*a85e14b0SPeter Avalos  * type, as requested by Will Barker.
565*a85e14b0SPeter Avalos  */
566*a85e14b0SPeter Avalos 
567*a85e14b0SPeter Avalos /*
568*a85e14b0SPeter Avalos  * IPMB with a Linux-specific pseudo-header; as requested by Alexey Neyman
569*a85e14b0SPeter Avalos  * <avn@pigeonpoint.com>.
570*a85e14b0SPeter Avalos  */
571*a85e14b0SPeter Avalos #define LINKTYPE_IPMB_LINUX	209
572*a85e14b0SPeter Avalos 
573*a85e14b0SPeter Avalos /*
574*a85e14b0SPeter Avalos  * FlexRay automotive bus - http://www.flexray.com/ - as requested
575*a85e14b0SPeter Avalos  * by Hannes Kaelber <hannes.kaelber@x2e.de>.
576*a85e14b0SPeter Avalos  */
577*a85e14b0SPeter Avalos #define LINKTYPE_FLEXRAY	210
578*a85e14b0SPeter Avalos 
579*a85e14b0SPeter Avalos /*
580*a85e14b0SPeter Avalos  * Media Oriented Systems Transport (MOST) bus for multimedia
581*a85e14b0SPeter Avalos  * transport - http://www.mostcooperation.com/ - as requested
582*a85e14b0SPeter Avalos  * by Hannes Kaelber <hannes.kaelber@x2e.de>.
583*a85e14b0SPeter Avalos  */
584*a85e14b0SPeter Avalos #define LINKTYPE_MOST		211
585*a85e14b0SPeter Avalos 
586*a85e14b0SPeter Avalos /*
587*a85e14b0SPeter Avalos  * Local Interconnect Network (LIN) bus for vehicle networks -
588*a85e14b0SPeter Avalos  * http://www.lin-subbus.org/ - as requested by Hannes Kaelber
589*a85e14b0SPeter Avalos  * <hannes.kaelber@x2e.de>.
590*a85e14b0SPeter Avalos  */
591*a85e14b0SPeter Avalos #define LINKTYPE_LIN		212
592*a85e14b0SPeter Avalos 
593*a85e14b0SPeter Avalos /*
594*a85e14b0SPeter Avalos  * X2E-private data link type used for serial line capture,
595*a85e14b0SPeter Avalos  * as requested by Hannes Kaelber <hannes.kaelber@x2e.de>.
596*a85e14b0SPeter Avalos  */
597*a85e14b0SPeter Avalos #define LINKTYPE_X2E_SERIAL	213
598*a85e14b0SPeter Avalos 
599*a85e14b0SPeter Avalos /*
600*a85e14b0SPeter Avalos  * X2E-private data link type used for the Xoraya data logger
601*a85e14b0SPeter Avalos  * family, as requested by Hannes Kaelber <hannes.kaelber@x2e.de>.
602*a85e14b0SPeter Avalos  */
603*a85e14b0SPeter Avalos #define LINKTYPE_X2E_XORAYA	214
604*a85e14b0SPeter Avalos 
605*a85e14b0SPeter Avalos /*
606*a85e14b0SPeter Avalos  * IEEE 802.15.4, exactly as it appears in the spec (no padding, no
607*a85e14b0SPeter Avalos  * nothing), but with the PHY-level data for non-ASK PHYs (4 octets
608*a85e14b0SPeter Avalos  * of 0 as preamble, one octet of SFD, one octet of frame length+
609*a85e14b0SPeter Avalos  * reserved bit, and then the MAC-layer data, starting with the
610*a85e14b0SPeter Avalos  * frame control field).
611*a85e14b0SPeter Avalos  *
612*a85e14b0SPeter Avalos  * Requested by Max Filippov <jcmvbkbc@gmail.com>.
613*a85e14b0SPeter Avalos  */
614*a85e14b0SPeter Avalos #define LINKTYPE_IEEE802_15_4_NONASK_PHY	215
615*a85e14b0SPeter Avalos 
616*a85e14b0SPeter Avalos /*
617*a85e14b0SPeter Avalos  * David Gibson <david@gibson.dropbear.id.au> requested this for
618*a85e14b0SPeter Avalos  * captures from the Linux kernel /dev/input/eventN devices. This
619*a85e14b0SPeter Avalos  * is used to communicate keystrokes and mouse movements from the
620*a85e14b0SPeter Avalos  * Linux kernel to display systems, such as Xorg.
621*a85e14b0SPeter Avalos  */
622*a85e14b0SPeter Avalos #define LINKTYPE_LINUX_EVDEV	216
623*a85e14b0SPeter Avalos 
624*a85e14b0SPeter Avalos /*
625*a85e14b0SPeter Avalos  * GSM Um and Abis interfaces, preceded by a "gsmtap" header.
626*a85e14b0SPeter Avalos  *
627*a85e14b0SPeter Avalos  * Requested by Harald Welte <laforge@gnumonks.org>.
628*a85e14b0SPeter Avalos  */
629*a85e14b0SPeter Avalos #define LINKTYPE_GSMTAP_UM	217
630*a85e14b0SPeter Avalos #define LINKTYPE_GSMTAP_ABIS	218
631*a85e14b0SPeter Avalos 
632*a85e14b0SPeter Avalos /*
633*a85e14b0SPeter Avalos  * MPLS, with an MPLS label as the link-layer header.
634*a85e14b0SPeter Avalos  * Requested by Michele Marchetto <michele@openbsd.org> on behalf
635*a85e14b0SPeter Avalos  * of OpenBSD.
636*a85e14b0SPeter Avalos  */
637*a85e14b0SPeter Avalos #define LINKTYPE_MPLS		219
638*a85e14b0SPeter Avalos 
639*a85e14b0SPeter Avalos /*
640*a85e14b0SPeter Avalos  * USB packets, beginning with a Linux USB header, with the USB header
641*a85e14b0SPeter Avalos  * padded to 64 bytes; required for memory-mapped access.
642*a85e14b0SPeter Avalos  */
643*a85e14b0SPeter Avalos #define LINKTYPE_USB_LINUX_MMAPPED		220
644*a85e14b0SPeter Avalos 
645*a85e14b0SPeter Avalos /*
646*a85e14b0SPeter Avalos  * DECT packets, with a pseudo-header; requested by
647*a85e14b0SPeter Avalos  * Matthias Wenzel <tcpdump@mazzoo.de>.
648*a85e14b0SPeter Avalos  */
649*a85e14b0SPeter Avalos #define LINKTYPE_DECT		221
650*a85e14b0SPeter Avalos 
651*a85e14b0SPeter Avalos /*
652*a85e14b0SPeter Avalos  * From: "Lidwa, Eric (GSFC-582.0)[SGT INC]" <eric.lidwa-1@nasa.gov>
653*a85e14b0SPeter Avalos  * Date: Mon, 11 May 2009 11:18:30 -0500
654*a85e14b0SPeter Avalos  *
655*a85e14b0SPeter Avalos  * DLT_AOS. We need it for AOS Space Data Link Protocol.
656*a85e14b0SPeter Avalos  *   I have already written dissectors for but need an OK from
657*a85e14b0SPeter Avalos  *   legal before I can submit a patch.
658*a85e14b0SPeter Avalos  *
659*a85e14b0SPeter Avalos  */
660*a85e14b0SPeter Avalos #define LINKTYPE_AOS		222
661*a85e14b0SPeter Avalos 
662*a85e14b0SPeter Avalos /*
663*a85e14b0SPeter Avalos  * Wireless HART (Highway Addressable Remote Transducer)
664*a85e14b0SPeter Avalos  * From the HART Communication Foundation
665*a85e14b0SPeter Avalos  * IES/PAS 62591
666*a85e14b0SPeter Avalos  *
667*a85e14b0SPeter Avalos  * Requested by Sam Roberts <vieuxtech@gmail.com>.
668*a85e14b0SPeter Avalos  */
669*a85e14b0SPeter Avalos #define LINKTYPE_WIHART		223
670*a85e14b0SPeter Avalos 
671*a85e14b0SPeter Avalos /*
672*a85e14b0SPeter Avalos  * Fibre Channel FC-2 frames, beginning with a Frame_Header.
673*a85e14b0SPeter Avalos  * Requested by Kahou Lei <kahou82@gmail.com>.
674*a85e14b0SPeter Avalos  */
675*a85e14b0SPeter Avalos #define LINKTYPE_FC_2		224
676*a85e14b0SPeter Avalos 
677*a85e14b0SPeter Avalos /*
678*a85e14b0SPeter Avalos  * Fibre Channel FC-2 frames, beginning with an encoding of the
679*a85e14b0SPeter Avalos  * SOF, and ending with an encoding of the EOF.
680*a85e14b0SPeter Avalos  *
681*a85e14b0SPeter Avalos  * The encodings represent the frame delimiters as 4-byte sequences
682*a85e14b0SPeter Avalos  * representing the corresponding ordered sets, with K28.5
683*a85e14b0SPeter Avalos  * represented as 0xBC, and the D symbols as the corresponding
684*a85e14b0SPeter Avalos  * byte values; for example, SOFi2, which is K28.5 - D21.5 - D1.2 - D21.2,
685*a85e14b0SPeter Avalos  * is represented as 0xBC 0xB5 0x55 0x55.
686*a85e14b0SPeter Avalos  *
687*a85e14b0SPeter Avalos  * Requested by Kahou Lei <kahou82@gmail.com>.
688*a85e14b0SPeter Avalos  */
689*a85e14b0SPeter Avalos #define LINKTYPE_FC_2_WITH_FRAME_DELIMS		225
690*a85e14b0SPeter Avalos 
691*a85e14b0SPeter Avalos /*
692*a85e14b0SPeter Avalos  * Solaris ipnet pseudo-header; requested by Darren Reed <Darren.Reed@Sun.COM>.
693*a85e14b0SPeter Avalos  *
694*a85e14b0SPeter Avalos  * The pseudo-header starts with a one-byte version number; for version 2,
695*a85e14b0SPeter Avalos  * the pseudo-header is:
696*a85e14b0SPeter Avalos  *
697*a85e14b0SPeter Avalos  * struct dl_ipnetinfo {
698*a85e14b0SPeter Avalos  *     u_int8_t   dli_version;
699*a85e14b0SPeter Avalos  *     u_int8_t   dli_family;
700*a85e14b0SPeter Avalos  *     u_int16_t  dli_htype;
701*a85e14b0SPeter Avalos  *     u_int32_t  dli_pktlen;
702*a85e14b0SPeter Avalos  *     u_int32_t  dli_ifindex;
703*a85e14b0SPeter Avalos  *     u_int32_t  dli_grifindex;
704*a85e14b0SPeter Avalos  *     u_int32_t  dli_zsrc;
705*a85e14b0SPeter Avalos  *     u_int32_t  dli_zdst;
706*a85e14b0SPeter Avalos  * };
707*a85e14b0SPeter Avalos  *
708*a85e14b0SPeter Avalos  * dli_version is 2 for the current version of the pseudo-header.
709*a85e14b0SPeter Avalos  *
710*a85e14b0SPeter Avalos  * dli_family is a Solaris address family value, so it's 2 for IPv4
711*a85e14b0SPeter Avalos  * and 26 for IPv6.
712*a85e14b0SPeter Avalos  *
713*a85e14b0SPeter Avalos  * dli_htype is a "hook type" - 0 for incoming packets, 1 for outgoing
714*a85e14b0SPeter Avalos  * packets, and 2 for packets arriving from another zone on the same
715*a85e14b0SPeter Avalos  * machine.
716*a85e14b0SPeter Avalos  *
717*a85e14b0SPeter Avalos  * dli_pktlen is the length of the packet data following the pseudo-header
718*a85e14b0SPeter Avalos  * (so the captured length minus dli_pktlen is the length of the
719*a85e14b0SPeter Avalos  * pseudo-header, assuming the entire pseudo-header was captured).
720*a85e14b0SPeter Avalos  *
721*a85e14b0SPeter Avalos  * dli_ifindex is the interface index of the interface on which the
722*a85e14b0SPeter Avalos  * packet arrived.
723*a85e14b0SPeter Avalos  *
724*a85e14b0SPeter Avalos  * dli_grifindex is the group interface index number (for IPMP interfaces).
725*a85e14b0SPeter Avalos  *
726*a85e14b0SPeter Avalos  * dli_zsrc is the zone identifier for the source of the packet.
727*a85e14b0SPeter Avalos  *
728*a85e14b0SPeter Avalos  * dli_zdst is the zone identifier for the destination of the packet.
729*a85e14b0SPeter Avalos  *
730*a85e14b0SPeter Avalos  * A zone number of 0 is the global zone; a zone number of 0xffffffff
731*a85e14b0SPeter Avalos  * means that the packet arrived from another host on the network, not
732*a85e14b0SPeter Avalos  * from another zone on the same machine.
733*a85e14b0SPeter Avalos  *
734*a85e14b0SPeter Avalos  * An IPv4 or IPv6 datagram follows the pseudo-header; dli_family indicates
735*a85e14b0SPeter Avalos  * which of those it is.
736*a85e14b0SPeter Avalos  */
737*a85e14b0SPeter Avalos #define LINKTYPE_IPNET		226
738*a85e14b0SPeter Avalos 
739*a85e14b0SPeter Avalos /*
740*a85e14b0SPeter Avalos  * CAN (Controller Area Network) frames, with a pseudo-header as supplied
741*a85e14b0SPeter Avalos  * by Linux SocketCAN.  See Documentation/networking/can.txt in the Linux
742*a85e14b0SPeter Avalos  * source.
743*a85e14b0SPeter Avalos  *
744*a85e14b0SPeter Avalos  * Requested by Felix Obenhuber <felix@obenhuber.de>.
745*a85e14b0SPeter Avalos  */
746*a85e14b0SPeter Avalos #define LINKTYPE_CAN_SOCKETCAN	227
747*a85e14b0SPeter Avalos 
748*a85e14b0SPeter Avalos /*
749*a85e14b0SPeter Avalos  * Raw IPv4/IPv6; different from DLT_RAW in that the DLT_ value specifies
750*a85e14b0SPeter Avalos  * whether it's v4 or v6.  Requested by Darren Reed <Darren.Reed@Sun.COM>.
751*a85e14b0SPeter Avalos  */
752*a85e14b0SPeter Avalos #define LINKTYPE_IPV4		228
753*a85e14b0SPeter Avalos #define LINKTYPE_IPV6		229
754*a85e14b0SPeter Avalos 
755*a85e14b0SPeter Avalos /*
756*a85e14b0SPeter Avalos  * IEEE 802.15.4, exactly as it appears in the spec (no padding, no
757*a85e14b0SPeter Avalos  * nothing), and with no FCS at the end of the frame; requested by
758*a85e14b0SPeter Avalos  * Jon Smirl <jonsmirl@gmail.com>.
759*a85e14b0SPeter Avalos  */
760*a85e14b0SPeter Avalos #define LINKTYPE_IEEE802_15_4_NOFCS		230
761*a85e14b0SPeter Avalos 
762*a85e14b0SPeter Avalos /*
763*a85e14b0SPeter Avalos  * Raw D-Bus:
764*a85e14b0SPeter Avalos  *
765*a85e14b0SPeter Avalos  *	http://www.freedesktop.org/wiki/Software/dbus
766*a85e14b0SPeter Avalos  *
767*a85e14b0SPeter Avalos  * messages:
768*a85e14b0SPeter Avalos  *
769*a85e14b0SPeter Avalos  *	http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-messages
770*a85e14b0SPeter Avalos  *
771*a85e14b0SPeter Avalos  * starting with the endianness flag, followed by the message type, etc.,
772*a85e14b0SPeter Avalos  * but without the authentication handshake before the message sequence:
773*a85e14b0SPeter Avalos  *
774*a85e14b0SPeter Avalos  *	http://dbus.freedesktop.org/doc/dbus-specification.html#auth-protocol
775*a85e14b0SPeter Avalos  *
776*a85e14b0SPeter Avalos  * Requested by Martin Vidner <martin@vidner.net>.
777*a85e14b0SPeter Avalos  */
778*a85e14b0SPeter Avalos #define LINKTYPE_DBUS		231
779*a85e14b0SPeter Avalos 
780*a85e14b0SPeter Avalos /*
781*a85e14b0SPeter Avalos  * Juniper-private data link type, as per request from
782*a85e14b0SPeter Avalos  * Hannes Gredler <hannes@juniper.net>.
783*a85e14b0SPeter Avalos  */
784*a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_VS			232
785*a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_SRX_E2E		233
786*a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_FIBRECHANNEL		234
787*a85e14b0SPeter Avalos 
788*a85e14b0SPeter Avalos /*
789*a85e14b0SPeter Avalos  * DVB-CI (DVB Common Interface for communication between a PC Card
790*a85e14b0SPeter Avalos  * module and a DVB receiver).  See
791*a85e14b0SPeter Avalos  *
792*a85e14b0SPeter Avalos  *	http://www.kaiser.cx/pcap-dvbci.html
793*a85e14b0SPeter Avalos  *
794*a85e14b0SPeter Avalos  * for the specification.
795*a85e14b0SPeter Avalos  *
796*a85e14b0SPeter Avalos  * Requested by Martin Kaiser <martin@kaiser.cx>.
797*a85e14b0SPeter Avalos  */
798*a85e14b0SPeter Avalos #define LINKTYPE_DVB_CI		235
799*a85e14b0SPeter Avalos 
800*a85e14b0SPeter Avalos /*
801*a85e14b0SPeter Avalos  * Variant of 3GPP TS 27.010 multiplexing protocol.  Requested
802*a85e14b0SPeter Avalos  * by Hans-Christoph Schemmel <hans-christoph.schemmel@cinterion.com>.
803*a85e14b0SPeter Avalos  */
804*a85e14b0SPeter Avalos #define LINKTYPE_MUX27010	236
805*a85e14b0SPeter Avalos 
806*a85e14b0SPeter Avalos /*
807*a85e14b0SPeter Avalos  * STANAG 5066 D_PDUs.  Requested by M. Baris Demiray
808*a85e14b0SPeter Avalos  * <barisdemiray@gmail.com>.
809*a85e14b0SPeter Avalos  */
810*a85e14b0SPeter Avalos #define LINKTYPE_STANAG_5066_D_PDU		237
811*a85e14b0SPeter Avalos 
812*a85e14b0SPeter Avalos /*
813*a85e14b0SPeter Avalos  * Juniper-private data link type, as per request from
814*a85e14b0SPeter Avalos  * Hannes Gredler <hannes@juniper.net>.
815*a85e14b0SPeter Avalos  */
816*a85e14b0SPeter Avalos #define LINKTYPE_JUNIPER_ATM_CEMIC		238
817*a85e14b0SPeter Avalos 
818*a85e14b0SPeter Avalos /*
819*a85e14b0SPeter Avalos  * NetFilter LOG messages
820*a85e14b0SPeter Avalos  * (payload of netlink NFNL_SUBSYS_ULOG/NFULNL_MSG_PACKET packets)
821*a85e14b0SPeter Avalos  *
822*a85e14b0SPeter Avalos  * Requested by Jakub Zawadzki <darkjames-ws@darkjames.pl>
823*a85e14b0SPeter Avalos  */
824*a85e14b0SPeter Avalos #define LINKTYPE_NFLOG		239
825*a85e14b0SPeter Avalos 
826*a85e14b0SPeter Avalos /*
827*a85e14b0SPeter Avalos  * Hilscher Gesellschaft fuer Systemautomation mbH link-layer type
828*a85e14b0SPeter Avalos  * for Ethernet packets with a 4-byte pseudo-header and always
829*a85e14b0SPeter Avalos  * with the payload including the FCS, as supplied by their
830*a85e14b0SPeter Avalos  * netANALYZER hardware and software.
831*a85e14b0SPeter Avalos  *
832*a85e14b0SPeter Avalos  * Requested by Holger P. Frommer <HPfrommer@hilscher.com>
833*a85e14b0SPeter Avalos  */
834*a85e14b0SPeter Avalos #define LINKTYPE_NETANALYZER	240
835*a85e14b0SPeter Avalos 
836*a85e14b0SPeter Avalos /*
837*a85e14b0SPeter Avalos  * Hilscher Gesellschaft fuer Systemautomation mbH link-layer type
838*a85e14b0SPeter Avalos  * for Ethernet packets with a 4-byte pseudo-header and FCS and
839*a85e14b0SPeter Avalos  * 1 byte of SFD, as supplied by their netANALYZER hardware and
840*a85e14b0SPeter Avalos  * software.
841*a85e14b0SPeter Avalos  *
842*a85e14b0SPeter Avalos  * Requested by Holger P. Frommer <HPfrommer@hilscher.com>
843*a85e14b0SPeter Avalos  */
844*a85e14b0SPeter Avalos #define LINKTYPE_NETANALYZER_TRANSPARENT	241
845*a85e14b0SPeter Avalos 
846*a85e14b0SPeter Avalos /*
847*a85e14b0SPeter Avalos  * IP-over-Infiniband, as specified by RFC 4391.
848*a85e14b0SPeter Avalos  *
849*a85e14b0SPeter Avalos  * Requested by Petr Sumbera <petr.sumbera@oracle.com>.
850*a85e14b0SPeter Avalos  */
851*a85e14b0SPeter Avalos #define LINKTYPE_IPOIB		242
852*a85e14b0SPeter Avalos 
853*a85e14b0SPeter Avalos #define LINKTYPE_MATCHING_MAX	242		/* highest value in the "matching" range */
854*a85e14b0SPeter Avalos 
855*a85e14b0SPeter Avalos static struct linktype_map {
856*a85e14b0SPeter Avalos 	int	dlt;
857*a85e14b0SPeter Avalos 	int	linktype;
858*a85e14b0SPeter Avalos } map[] = {
859*a85e14b0SPeter Avalos 	/*
860*a85e14b0SPeter Avalos 	 * These DLT_* codes have LINKTYPE_* codes with values identical
861*a85e14b0SPeter Avalos 	 * to the values of the corresponding DLT_* code.
862*a85e14b0SPeter Avalos 	 */
863*a85e14b0SPeter Avalos 	{ DLT_NULL,		LINKTYPE_NULL },
864*a85e14b0SPeter Avalos 	{ DLT_EN10MB,		LINKTYPE_ETHERNET },
865*a85e14b0SPeter Avalos 	{ DLT_EN3MB,		LINKTYPE_EXP_ETHERNET },
866*a85e14b0SPeter Avalos 	{ DLT_AX25,		LINKTYPE_AX25 },
867*a85e14b0SPeter Avalos 	{ DLT_PRONET,		LINKTYPE_PRONET },
868*a85e14b0SPeter Avalos 	{ DLT_CHAOS,		LINKTYPE_CHAOS },
869*a85e14b0SPeter Avalos 	{ DLT_IEEE802,		LINKTYPE_TOKEN_RING },
870*a85e14b0SPeter Avalos 	{ DLT_ARCNET,		LINKTYPE_ARCNET_BSD },
871*a85e14b0SPeter Avalos 	{ DLT_SLIP,		LINKTYPE_SLIP },
872*a85e14b0SPeter Avalos 	{ DLT_PPP,		LINKTYPE_PPP },
873*a85e14b0SPeter Avalos 	{ DLT_FDDI,	 	LINKTYPE_FDDI },
874*a85e14b0SPeter Avalos 
875*a85e14b0SPeter Avalos 	/*
876*a85e14b0SPeter Avalos 	 * These DLT_* codes have different values on different
877*a85e14b0SPeter Avalos 	 * platforms; we map them to LINKTYPE_* codes that
878*a85e14b0SPeter Avalos 	 * have values that should never be equal to any DLT_*
879*a85e14b0SPeter Avalos 	 * code.
880*a85e14b0SPeter Avalos 	 */
881*a85e14b0SPeter Avalos #ifdef DLT_FR
882*a85e14b0SPeter Avalos 	/* BSD/OS Frame Relay */
883*a85e14b0SPeter Avalos 	{ DLT_FR,		LINKTYPE_FRELAY },
884*a85e14b0SPeter Avalos #endif
885*a85e14b0SPeter Avalos 
886*a85e14b0SPeter Avalos 	{ DLT_SYMANTEC_FIREWALL, LINKTYPE_SYMANTEC_FIREWALL },
887*a85e14b0SPeter Avalos 	{ DLT_ATM_RFC1483, 	LINKTYPE_ATM_RFC1483 },
888*a85e14b0SPeter Avalos 	{ DLT_RAW,		LINKTYPE_RAW },
889*a85e14b0SPeter Avalos 	{ DLT_SLIP_BSDOS,	LINKTYPE_SLIP_BSDOS },
890*a85e14b0SPeter Avalos 	{ DLT_PPP_BSDOS,	LINKTYPE_PPP_BSDOS },
891*a85e14b0SPeter Avalos 
892*a85e14b0SPeter Avalos 	/* BSD/OS Cisco HDLC */
893*a85e14b0SPeter Avalos 	{ DLT_C_HDLC,		LINKTYPE_C_HDLC },
894*a85e14b0SPeter Avalos 
895*a85e14b0SPeter Avalos 	/*
896*a85e14b0SPeter Avalos 	 * These DLT_* codes are not on all platforms, but, so far,
897*a85e14b0SPeter Avalos 	 * there don't appear to be any platforms that define
898*a85e14b0SPeter Avalos 	 * other codes with those values; we map them to
899*a85e14b0SPeter Avalos 	 * different LINKTYPE_* values anyway, just in case.
900*a85e14b0SPeter Avalos 	 */
901*a85e14b0SPeter Avalos 
902*a85e14b0SPeter Avalos 	/* Linux ATM Classical IP */
903*a85e14b0SPeter Avalos 	{ DLT_ATM_CLIP,		LINKTYPE_ATM_CLIP },
904*a85e14b0SPeter Avalos 
905*a85e14b0SPeter Avalos 	/* NetBSD sync/async serial PPP (or Cisco HDLC) */
906*a85e14b0SPeter Avalos 	{ DLT_PPP_SERIAL,	LINKTYPE_PPP_HDLC },
907*a85e14b0SPeter Avalos 
908*a85e14b0SPeter Avalos 	/* NetBSD PPP over Ethernet */
909*a85e14b0SPeter Avalos 	{ DLT_PPP_ETHER,	LINKTYPE_PPP_ETHER },
910*a85e14b0SPeter Avalos 
911*a85e14b0SPeter Avalos 	/*
912*a85e14b0SPeter Avalos 	 * All LINKTYPE_ values between LINKTYPE_MATCHING_MIN
913*a85e14b0SPeter Avalos 	 * and LINKTYPE_MATCHING_MAX are mapped to identical
914*a85e14b0SPeter Avalos 	 * DLT_ values.
915*a85e14b0SPeter Avalos 	 */
916*a85e14b0SPeter Avalos 
917*a85e14b0SPeter Avalos 	{ -1,			-1 }
918*a85e14b0SPeter Avalos };
919*a85e14b0SPeter Avalos 
920*a85e14b0SPeter Avalos int
921*a85e14b0SPeter Avalos dlt_to_linktype(int dlt)
922*a85e14b0SPeter Avalos {
923*a85e14b0SPeter Avalos 	int i;
924*a85e14b0SPeter Avalos 
925*a85e14b0SPeter Avalos 	/*
926*a85e14b0SPeter Avalos 	 * Map the values in the matching range.
927*a85e14b0SPeter Avalos 	 */
928*a85e14b0SPeter Avalos 	if (dlt >= DLT_MATCHING_MIN && dlt <= DLT_MATCHING_MAX)
929*a85e14b0SPeter Avalos 		return (dlt);
930*a85e14b0SPeter Avalos 
931*a85e14b0SPeter Avalos 	/*
932*a85e14b0SPeter Avalos 	 * Map the values outside that range.
933*a85e14b0SPeter Avalos 	 */
934*a85e14b0SPeter Avalos 	for (i = 0; map[i].dlt != -1; i++) {
935*a85e14b0SPeter Avalos 		if (map[i].dlt == dlt)
936*a85e14b0SPeter Avalos 			return (map[i].linktype);
937*a85e14b0SPeter Avalos 	}
938*a85e14b0SPeter Avalos 
939*a85e14b0SPeter Avalos 	/*
940*a85e14b0SPeter Avalos 	 * If we don't have a mapping for this DLT_ code, return an
941*a85e14b0SPeter Avalos 	 * error; that means that this is a value with no corresponding
942*a85e14b0SPeter Avalos 	 * LINKTYPE_ code, and we need to assign one.
943*a85e14b0SPeter Avalos 	 */
944*a85e14b0SPeter Avalos 	return (-1);
945*a85e14b0SPeter Avalos }
946*a85e14b0SPeter Avalos 
947*a85e14b0SPeter Avalos int
948*a85e14b0SPeter Avalos linktype_to_dlt(int linktype)
949*a85e14b0SPeter Avalos {
950*a85e14b0SPeter Avalos 	int i;
951*a85e14b0SPeter Avalos 
952*a85e14b0SPeter Avalos 	/*
953*a85e14b0SPeter Avalos 	 * Map the values in the matching range.
954*a85e14b0SPeter Avalos 	 */
955*a85e14b0SPeter Avalos 	if (linktype >= LINKTYPE_MATCHING_MIN &&
956*a85e14b0SPeter Avalos 	    linktype <= LINKTYPE_MATCHING_MAX)
957*a85e14b0SPeter Avalos 		return (linktype);
958*a85e14b0SPeter Avalos 
959*a85e14b0SPeter Avalos 	/*
960*a85e14b0SPeter Avalos 	 * Map the values outside that range.
961*a85e14b0SPeter Avalos 	 */
962*a85e14b0SPeter Avalos 	for (i = 0; map[i].linktype != -1; i++) {
963*a85e14b0SPeter Avalos 		if (map[i].linktype == linktype)
964*a85e14b0SPeter Avalos 			return (map[i].dlt);
965*a85e14b0SPeter Avalos 	}
966*a85e14b0SPeter Avalos 
967*a85e14b0SPeter Avalos 	/*
968*a85e14b0SPeter Avalos 	 * If we don't have an entry for this link type, return
969*a85e14b0SPeter Avalos 	 * the link type value; it may be a DLT_ value from an
970*a85e14b0SPeter Avalos 	 * older version of libpcap.
971*a85e14b0SPeter Avalos 	 */
972*a85e14b0SPeter Avalos 	return linktype;
973*a85e14b0SPeter Avalos }
974*a85e14b0SPeter Avalos 
975*a85e14b0SPeter Avalos /*
976*a85e14b0SPeter Avalos  * The DLT_USB_LINUX and DLT_USB_LINUX_MMAPPED headers are in host
977*a85e14b0SPeter Avalos  * byte order when capturing (it's supplied directly from a
978*a85e14b0SPeter Avalos  * memory-mapped buffer shared by the kernel).
979*a85e14b0SPeter Avalos  *
980*a85e14b0SPeter Avalos  * When reading a DLT_USB_LINUX or DLT_USB_LINUX_MMAPPED capture file,
981*a85e14b0SPeter Avalos  * we need to convert it from the capturing host's byte order to
982*a85e14b0SPeter Avalos  * the reading host's byte order.
983*a85e14b0SPeter Avalos  */
984*a85e14b0SPeter Avalos void
985*a85e14b0SPeter Avalos swap_linux_usb_header(const struct pcap_pkthdr *hdr, u_char *buf,
986*a85e14b0SPeter Avalos     int header_len_64_bytes)
987*a85e14b0SPeter Avalos {
988*a85e14b0SPeter Avalos 	pcap_usb_header_mmapped *uhdr = (pcap_usb_header_mmapped *)buf;
989*a85e14b0SPeter Avalos 	bpf_u_int32 offset = 0;
990*a85e14b0SPeter Avalos 	usb_isodesc *pisodesc;
991*a85e14b0SPeter Avalos 	int32_t numdesc, i;
992*a85e14b0SPeter Avalos 
993*a85e14b0SPeter Avalos 	/*
994*a85e14b0SPeter Avalos 	 * "offset" is the offset *past* the field we're swapping;
995*a85e14b0SPeter Avalos 	 * we skip the field *before* checking to make sure
996*a85e14b0SPeter Avalos 	 * the captured data length includes the entire field.
997*a85e14b0SPeter Avalos 	 */
998*a85e14b0SPeter Avalos 
999*a85e14b0SPeter Avalos 	/*
1000*a85e14b0SPeter Avalos 	 * The URB id is a totally opaque value; do we really need to
1001*a85e14b0SPeter Avalos 	 * convert it to the reading host's byte order???
1002*a85e14b0SPeter Avalos 	 */
1003*a85e14b0SPeter Avalos 	offset += 8;			/* skip past id */
1004*a85e14b0SPeter Avalos 	if (hdr->caplen < offset)
1005*a85e14b0SPeter Avalos 		return;
1006*a85e14b0SPeter Avalos 	uhdr->id = SWAPLL(uhdr->id);
1007*a85e14b0SPeter Avalos 
1008*a85e14b0SPeter Avalos 	offset += 4;			/* skip past various 1-byte fields */
1009*a85e14b0SPeter Avalos 
1010*a85e14b0SPeter Avalos 	offset += 2;			/* skip past bus_id */
1011*a85e14b0SPeter Avalos 	if (hdr->caplen < offset)
1012*a85e14b0SPeter Avalos 		return;
1013*a85e14b0SPeter Avalos 	uhdr->bus_id = SWAPSHORT(uhdr->bus_id);
1014*a85e14b0SPeter Avalos 
1015*a85e14b0SPeter Avalos 	offset += 2;			/* skip past various 1-byte fields */
1016*a85e14b0SPeter Avalos 
1017*a85e14b0SPeter Avalos 	offset += 8;			/* skip past ts_sec */
1018*a85e14b0SPeter Avalos 	if (hdr->caplen < offset)
1019*a85e14b0SPeter Avalos 		return;
1020*a85e14b0SPeter Avalos 	uhdr->ts_sec = SWAPLL(uhdr->ts_sec);
1021*a85e14b0SPeter Avalos 
1022*a85e14b0SPeter Avalos 	offset += 4;			/* skip past ts_usec */
1023*a85e14b0SPeter Avalos 	if (hdr->caplen < offset)
1024*a85e14b0SPeter Avalos 		return;
1025*a85e14b0SPeter Avalos 	uhdr->ts_usec = SWAPLONG(uhdr->ts_usec);
1026*a85e14b0SPeter Avalos 
1027*a85e14b0SPeter Avalos 	offset += 4;			/* skip past status */
1028*a85e14b0SPeter Avalos 	if (hdr->caplen < offset)
1029*a85e14b0SPeter Avalos 		return;
1030*a85e14b0SPeter Avalos 	uhdr->status = SWAPLONG(uhdr->status);
1031*a85e14b0SPeter Avalos 
1032*a85e14b0SPeter Avalos 	offset += 4;			/* skip past urb_len */
1033*a85e14b0SPeter Avalos 	if (hdr->caplen < offset)
1034*a85e14b0SPeter Avalos 		return;
1035*a85e14b0SPeter Avalos 	uhdr->urb_len = SWAPLONG(uhdr->urb_len);
1036*a85e14b0SPeter Avalos 
1037*a85e14b0SPeter Avalos 	offset += 4;			/* skip past data_len */
1038*a85e14b0SPeter Avalos 	if (hdr->caplen < offset)
1039*a85e14b0SPeter Avalos 		return;
1040*a85e14b0SPeter Avalos 	uhdr->data_len = SWAPLONG(uhdr->data_len);
1041*a85e14b0SPeter Avalos 
1042*a85e14b0SPeter Avalos 	if (uhdr->transfer_type == URB_ISOCHRONOUS) {
1043*a85e14b0SPeter Avalos 		offset += 4;			/* skip past s.iso.error_count */
1044*a85e14b0SPeter Avalos 		if (hdr->caplen < offset)
1045*a85e14b0SPeter Avalos 			return;
1046*a85e14b0SPeter Avalos 		uhdr->s.iso.error_count = SWAPLONG(uhdr->s.iso.error_count);
1047*a85e14b0SPeter Avalos 
1048*a85e14b0SPeter Avalos 		offset += 4;			/* skip past s.iso.numdesc */
1049*a85e14b0SPeter Avalos 		if (hdr->caplen < offset)
1050*a85e14b0SPeter Avalos 			return;
1051*a85e14b0SPeter Avalos 		uhdr->s.iso.numdesc = SWAPLONG(uhdr->s.iso.numdesc);
1052*a85e14b0SPeter Avalos 	} else
1053*a85e14b0SPeter Avalos 		offset += 8;			/* skip USB setup header */
1054*a85e14b0SPeter Avalos 
1055*a85e14b0SPeter Avalos 	if (header_len_64_bytes) {
1056*a85e14b0SPeter Avalos 		/*
1057*a85e14b0SPeter Avalos 		 * This is either the "version 1" header, with
1058*a85e14b0SPeter Avalos 		 * 16 bytes of additional fields at the end, or
1059*a85e14b0SPeter Avalos 		 * a "version 0" header from a memory-mapped
1060*a85e14b0SPeter Avalos 		 * capture, with 16 bytes of zeroed-out padding
1061*a85e14b0SPeter Avalos 		 * at the end.  Byte swap them as if this were
1062*a85e14b0SPeter Avalos 		 * a "version 1" header.
1063*a85e14b0SPeter Avalos 		 */
1064*a85e14b0SPeter Avalos 		offset += 4;			/* skip past interval */
1065*a85e14b0SPeter Avalos 		if (hdr->caplen < offset)
1066*a85e14b0SPeter Avalos 			return;
1067*a85e14b0SPeter Avalos 		uhdr->interval = SWAPLONG(uhdr->interval);
1068*a85e14b0SPeter Avalos 
1069*a85e14b0SPeter Avalos 		offset += 4;			/* skip past start_frame */
1070*a85e14b0SPeter Avalos 		if (hdr->caplen < offset)
1071*a85e14b0SPeter Avalos 			return;
1072*a85e14b0SPeter Avalos 		uhdr->start_frame = SWAPLONG(uhdr->start_frame);
1073*a85e14b0SPeter Avalos 
1074*a85e14b0SPeter Avalos 		offset += 4;			/* skip past xfer_flags */
1075*a85e14b0SPeter Avalos 		if (hdr->caplen < offset)
1076*a85e14b0SPeter Avalos 			return;
1077*a85e14b0SPeter Avalos 		uhdr->xfer_flags = SWAPLONG(uhdr->xfer_flags);
1078*a85e14b0SPeter Avalos 
1079*a85e14b0SPeter Avalos 		offset += 4;			/* skip past ndesc */
1080*a85e14b0SPeter Avalos 		if (hdr->caplen < offset)
1081*a85e14b0SPeter Avalos 			return;
1082*a85e14b0SPeter Avalos 		uhdr->ndesc = SWAPLONG(uhdr->ndesc);
1083*a85e14b0SPeter Avalos 	}
1084*a85e14b0SPeter Avalos 
1085*a85e14b0SPeter Avalos 	if (uhdr->transfer_type == URB_ISOCHRONOUS) {
1086*a85e14b0SPeter Avalos 		/* swap the values in struct linux_usb_isodesc */
1087*a85e14b0SPeter Avalos 		pisodesc = (usb_isodesc *)(void *)(buf+offset);
1088*a85e14b0SPeter Avalos 		numdesc = uhdr->s.iso.numdesc;
1089*a85e14b0SPeter Avalos 		for (i = 0; i < numdesc; i++) {
1090*a85e14b0SPeter Avalos 			offset += 4;		/* skip past status */
1091*a85e14b0SPeter Avalos 			if (hdr->caplen < offset)
1092*a85e14b0SPeter Avalos 				return;
1093*a85e14b0SPeter Avalos 			pisodesc->status = SWAPLONG(pisodesc->status);
1094*a85e14b0SPeter Avalos 
1095*a85e14b0SPeter Avalos 			offset += 4;		/* skip past offset */
1096*a85e14b0SPeter Avalos 			if (hdr->caplen < offset)
1097*a85e14b0SPeter Avalos 				return;
1098*a85e14b0SPeter Avalos 			pisodesc->offset = SWAPLONG(pisodesc->offset);
1099*a85e14b0SPeter Avalos 
1100*a85e14b0SPeter Avalos 			offset += 4;		/* skip past len */
1101*a85e14b0SPeter Avalos 			if (hdr->caplen < offset)
1102*a85e14b0SPeter Avalos 				return;
1103*a85e14b0SPeter Avalos 			pisodesc->len = SWAPLONG(pisodesc->len);
1104*a85e14b0SPeter Avalos 
1105*a85e14b0SPeter Avalos 			offset += 4;		/* skip past padding */
1106*a85e14b0SPeter Avalos 
1107*a85e14b0SPeter Avalos 			pisodesc++;
1108*a85e14b0SPeter Avalos 		}
1109*a85e14b0SPeter Avalos 	}
1110*a85e14b0SPeter Avalos }
1111