Coverage Report

Created: 2024-02-25 06:23

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