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