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