2 * Copyright (c) 1993, 1994, 1995, 1996, 1997
3 * The Regents of the University of California. All rights reserved.
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
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.
21 * pcap-common.c - common code for pcap and pcap-ng files
29 #include <pcap-stdinc.h>
36 #ifdef HAVE_SYS_BITYPES_H
37 #include <sys/bitypes.h>
39 #include <sys/types.h>
45 #include "pcap-common.h"
48 * We don't write DLT_* values to capture files, because they're not the
49 * same on all platforms.
51 * Unfortunately, the various flavors of BSD have not always used the same
52 * numerical values for the same data types, and various patches to
53 * libpcap for non-BSD OSes have added their own DLT_* codes for link
54 * layer encapsulation types seen on those OSes, and those codes have had,
55 * in some cases, values that were also used, on other platforms, for other
56 * link layer encapsulation types.
58 * This means that capture files of a type whose numerical DLT_* code
59 * means different things on different BSDs, or with different versions
60 * of libpcap, can't always be read on systems other than those like
61 * the one running on the machine on which the capture was made.
63 * Instead, we define here a set of LINKTYPE_* codes, and map DLT_* codes
64 * to LINKTYPE_* codes when writing a savefile header, and map LINKTYPE_*
65 * codes to DLT_* codes when reading a savefile header.
67 * For those DLT_* codes that have, as far as we know, the same values on
68 * all platforms (DLT_NULL through DLT_FDDI), we define LINKTYPE_xxx as
69 * DLT_xxx; that way, captures of those types can still be read by
70 * versions of libpcap that map LINKTYPE_* values to DLT_* values, and
71 * captures of those types written by versions of libpcap that map DLT_
72 * values to LINKTYPE_ values can still be read by older versions
75 * The other LINKTYPE_* codes are given values starting at 100, in the
76 * hopes that no DLT_* code will be given one of those values.
78 * In order to ensure that a given LINKTYPE_* code's value will refer to
79 * the same encapsulation type on all platforms, you should not allocate
80 * a new LINKTYPE_* value without consulting
81 * "tcpdump-workers@lists.tcpdump.org". The tcpdump developers will
82 * allocate a value for you, and will not subsequently allocate it to
83 * anybody else; that value will be added to the "pcap.h" in the
84 * tcpdump.org Git repository, so that a future libpcap release will
87 * You should, if possible, also contribute patches to libpcap and tcpdump
88 * to handle the new encapsulation type, so that they can also be checked
89 * into the tcpdump.org Git repository and so that they will appear in
90 * future libpcap and tcpdump releases.
92 * Do *NOT* assume that any values after the largest value in this file
93 * are available; you might not have the most up-to-date version of this
94 * file, and new values after that one might have been assigned. Also,
95 * do *NOT* use any values below 100 - those might already have been
96 * taken by one (or more!) organizations.
98 #define LINKTYPE_NULL DLT_NULL
99 #define LINKTYPE_ETHERNET DLT_EN10MB /* also for 100Mb and up */
100 #define LINKTYPE_EXP_ETHERNET DLT_EN3MB /* 3Mb experimental Ethernet */
101 #define LINKTYPE_AX25 DLT_AX25
102 #define LINKTYPE_PRONET DLT_PRONET
103 #define LINKTYPE_CHAOS DLT_CHAOS
104 #define LINKTYPE_TOKEN_RING DLT_IEEE802 /* DLT_IEEE802 is used for Token Ring */
105 #define LINKTYPE_ARCNET_BSD DLT_ARCNET /* BSD-style headers */
106 #define LINKTYPE_SLIP DLT_SLIP
107 #define LINKTYPE_PPP DLT_PPP
108 #define LINKTYPE_FDDI DLT_FDDI
111 * LINKTYPE_PPP is for use when there might, or might not, be an RFC 1662
112 * PPP in HDLC-like framing header (with 0xff 0x03 before the PPP protocol
113 * field) at the beginning of the packet.
115 * This is for use when there is always such a header; the address field
116 * might be 0xff, for regular PPP, or it might be an address field for Cisco
117 * point-to-point with HDLC framing as per section 4.3.1 of RFC 1547 ("Cisco
118 * HDLC"). This is, for example, what you get with NetBSD's DLT_PPP_SERIAL.
120 * We give it the same value as NetBSD's DLT_PPP_SERIAL, in the hopes that
121 * nobody else will choose a DLT_ value of 50, and so that DLT_PPP_SERIAL
122 * captures will be written out with a link type that NetBSD's tcpdump
125 #define LINKTYPE_PPP_HDLC 50 /* PPP in HDLC-like framing */
127 #define LINKTYPE_PPP_ETHER 51 /* NetBSD PPP-over-Ethernet */
129 #define LINKTYPE_SYMANTEC_FIREWALL 99 /* Symantec Enterprise Firewall */
131 #define LINKTYPE_ATM_RFC1483 100 /* LLC/SNAP-encapsulated ATM */
132 #define LINKTYPE_RAW 101 /* raw IP */
133 #define LINKTYPE_SLIP_BSDOS 102 /* BSD/OS SLIP BPF header */
134 #define LINKTYPE_PPP_BSDOS 103 /* BSD/OS PPP BPF header */
135 #define LINKTYPE_C_HDLC 104 /* Cisco HDLC */
136 #define LINKTYPE_IEEE802_11 105 /* IEEE 802.11 (wireless) */
137 #define LINKTYPE_ATM_CLIP 106 /* Linux Classical IP over ATM */
138 #define LINKTYPE_FRELAY 107 /* Frame Relay */
139 #define LINKTYPE_LOOP 108 /* OpenBSD loopback */
140 #define LINKTYPE_ENC 109 /* OpenBSD IPSEC enc */
143 * These three types are reserved for future use.
145 #define LINKTYPE_LANE8023 110 /* ATM LANE + 802.3 */
146 #define LINKTYPE_HIPPI 111 /* NetBSD HIPPI */
147 #define LINKTYPE_HDLC 112 /* NetBSD HDLC framing */
149 #define LINKTYPE_LINUX_SLL 113 /* Linux cooked socket capture */
150 #define LINKTYPE_LTALK 114 /* Apple LocalTalk hardware */
151 #define LINKTYPE_ECONET 115 /* Acorn Econet */
154 * Reserved for use with OpenBSD ipfilter.
156 #define LINKTYPE_IPFILTER 116
158 #define LINKTYPE_PFLOG 117 /* OpenBSD DLT_PFLOG */
159 #define LINKTYPE_CISCO_IOS 118 /* For Cisco-internal use */
160 #define LINKTYPE_PRISM_HEADER 119 /* 802.11+Prism II monitor mode */
161 #define LINKTYPE_AIRONET_HEADER 120 /* FreeBSD Aironet driver stuff */
164 * Reserved for Siemens HiPath HDLC.
166 #define LINKTYPE_HHDLC 121
168 #define LINKTYPE_IP_OVER_FC 122 /* RFC 2625 IP-over-Fibre Channel */
169 #define LINKTYPE_SUNATM 123 /* Solaris+SunATM */
172 * Reserved as per request from Kent Dahlgren <kent@praesum.com>
175 #define LINKTYPE_RIO 124 /* RapidIO */
176 #define LINKTYPE_PCI_EXP 125 /* PCI Express */
177 #define LINKTYPE_AURORA 126 /* Xilinx Aurora link layer */
179 #define LINKTYPE_IEEE802_11_RADIO 127 /* 802.11 plus BSD radio header */
182 * Reserved for the TZSP encapsulation, as per request from
183 * Chris Waters <chris.waters@networkchemistry.com>
184 * TZSP is a generic encapsulation for any other link type,
185 * which includes a means to include meta-information
186 * with the packet, e.g. signal strength and channel
187 * for 802.11 packets.
189 #define LINKTYPE_TZSP 128 /* Tazmen Sniffer Protocol */
191 #define LINKTYPE_ARCNET_LINUX 129 /* Linux-style headers */
194 * Juniper-private data link types, as per request from
195 * Hannes Gredler <hannes@juniper.net>. The corresponding
196 * DLT_s are used for passing on chassis-internal
197 * metainformation such as QOS profiles, etc..
199 #define LINKTYPE_JUNIPER_MLPPP 130
200 #define LINKTYPE_JUNIPER_MLFR 131
201 #define LINKTYPE_JUNIPER_ES 132
202 #define LINKTYPE_JUNIPER_GGSN 133
203 #define LINKTYPE_JUNIPER_MFR 134
204 #define LINKTYPE_JUNIPER_ATM2 135
205 #define LINKTYPE_JUNIPER_SERVICES 136
206 #define LINKTYPE_JUNIPER_ATM1 137
208 #define LINKTYPE_APPLE_IP_OVER_IEEE1394 138 /* Apple IP-over-IEEE 1394 cooked header */
210 #define LINKTYPE_MTP2_WITH_PHDR 139
211 #define LINKTYPE_MTP2 140
212 #define LINKTYPE_MTP3 141
213 #define LINKTYPE_SCCP 142
215 #define LINKTYPE_DOCSIS 143 /* DOCSIS MAC frames */
217 #define LINKTYPE_LINUX_IRDA 144 /* Linux-IrDA */
220 * Reserved for IBM SP switch and IBM Next Federation switch.
222 #define LINKTYPE_IBM_SP 145
223 #define LINKTYPE_IBM_SN 146
226 * Reserved for private use. If you have some link-layer header type
227 * that you want to use within your organization, with the capture files
228 * using that link-layer header type not ever be sent outside your
229 * organization, you can use these values.
231 * No libpcap release will use these for any purpose, nor will any
232 * tcpdump release use them, either.
234 * Do *NOT* use these in capture files that you expect anybody not using
235 * your private versions of capture-file-reading tools to read; in
236 * particular, do *NOT* use them in products, otherwise you may find that
237 * people won't be able to use tcpdump, or snort, or Ethereal, or... to
238 * read capture files from your firewall/intrusion detection/traffic
239 * monitoring/etc. appliance, or whatever product uses that LINKTYPE_ value,
240 * and you may also find that the developers of those applications will
241 * not accept patches to let them read those files.
243 * Also, do not use them if somebody might send you a capture using them
244 * for *their* private type and tools using them for *your* private type
245 * would have to read them.
247 * Instead, in those cases, ask "tcpdump-workers@lists.tcpdump.org" for a
248 * new DLT_ and LINKTYPE_ value, as per the comment in pcap/bpf.h, and use
249 * the type you're given.
251 #define LINKTYPE_USER0 147
252 #define LINKTYPE_USER1 148
253 #define LINKTYPE_USER2 149
254 #define LINKTYPE_USER3 150
255 #define LINKTYPE_USER4 151
256 #define LINKTYPE_USER5 152
257 #define LINKTYPE_USER6 153
258 #define LINKTYPE_USER7 154
259 #define LINKTYPE_USER8 155
260 #define LINKTYPE_USER9 156
261 #define LINKTYPE_USER10 157
262 #define LINKTYPE_USER11 158
263 #define LINKTYPE_USER12 159
264 #define LINKTYPE_USER13 160
265 #define LINKTYPE_USER14 161
266 #define LINKTYPE_USER15 162
269 * For future use with 802.11 captures - defined by AbsoluteValue
270 * Systems to store a number of bits of link-layer information
271 * including radio information:
273 * http://www.shaftnet.org/~pizza/software/capturefrm.txt
275 * but could and arguably should also be used by non-AVS Linux
276 * 802.11 drivers; that may happen in the future.
278 #define LINKTYPE_IEEE802_11_RADIO_AVS 163 /* 802.11 plus AVS radio header */
281 * Juniper-private data link type, as per request from
282 * Hannes Gredler <hannes@juniper.net>. The corresponding
283 * DLT_s are used for passing on chassis-internal
284 * metainformation such as QOS profiles, etc..
286 #define LINKTYPE_JUNIPER_MONITOR 164
289 * Reserved for BACnet MS/TP.
291 #define LINKTYPE_BACNET_MS_TP 165
294 * Another PPP variant as per request from Karsten Keil <kkeil@suse.de>.
296 * This is used in some OSes to allow a kernel socket filter to distinguish
297 * between incoming and outgoing packets, on a socket intended to
298 * supply pppd with outgoing packets so it can do dial-on-demand and
299 * hangup-on-lack-of-demand; incoming packets are filtered out so they
300 * don't cause pppd to hold the connection up (you don't want random
301 * input packets such as port scans, packets from old lost connections,
302 * etc. to force the connection to stay up).
304 * The first byte of the PPP header (0xff03) is modified to accomodate
305 * the direction - 0x00 = IN, 0x01 = OUT.
307 #define LINKTYPE_PPP_PPPD 166
310 * Juniper-private data link type, as per request from
311 * Hannes Gredler <hannes@juniper.net>. The DLT_s are used
312 * for passing on chassis-internal metainformation such as
313 * QOS profiles, cookies, etc..
315 #define LINKTYPE_JUNIPER_PPPOE 167
316 #define LINKTYPE_JUNIPER_PPPOE_ATM 168
318 #define LINKTYPE_GPRS_LLC 169 /* GPRS LLC */
319 #define LINKTYPE_GPF_T 170 /* GPF-T (ITU-T G.7041/Y.1303) */
320 #define LINKTYPE_GPF_F 171 /* GPF-T (ITU-T G.7041/Y.1303) */
323 * Requested by Oolan Zimmer <oz@gcom.com> for use in Gcom's T1/E1 line
324 * monitoring equipment.
326 #define LINKTYPE_GCOM_T1E1 172
327 #define LINKTYPE_GCOM_SERIAL 173
330 * Juniper-private data link type, as per request from
331 * Hannes Gredler <hannes@juniper.net>. The DLT_ is used
332 * for internal communication to Physical Interface Cards (PIC)
334 #define LINKTYPE_JUNIPER_PIC_PEER 174
337 * Link types requested by Gregor Maier <gregor@endace.com> of Endace
338 * Measurement Systems. They add an ERF header (see
339 * http://www.endace.com/support/EndaceRecordFormat.pdf) in front of
340 * the link-layer header.
342 #define LINKTYPE_ERF_ETH 175 /* Ethernet */
343 #define LINKTYPE_ERF_POS 176 /* Packet-over-SONET */
346 * Requested by Daniele Orlandi <daniele@orlandi.com> for raw LAPD
347 * for vISDN (http://www.orlandi.com/visdn/). Its link-layer header
348 * includes additional information before the LAPD header, so it's
349 * not necessarily a generic LAPD header.
351 #define LINKTYPE_LINUX_LAPD 177
354 * Juniper-private data link type, as per request from
355 * Hannes Gredler <hannes@juniper.net>.
356 * The Link Types are used for prepending meta-information
357 * like interface index, interface name
358 * before standard Ethernet, PPP, Frelay & C-HDLC Frames
360 #define LINKTYPE_JUNIPER_ETHER 178
361 #define LINKTYPE_JUNIPER_PPP 179
362 #define LINKTYPE_JUNIPER_FRELAY 180
363 #define LINKTYPE_JUNIPER_CHDLC 181
366 * Multi Link Frame Relay (FRF.16)
368 #define LINKTYPE_MFR 182
371 * Juniper-private data link type, as per request from
372 * Hannes Gredler <hannes@juniper.net>.
373 * The DLT_ is used for internal communication with a
374 * voice Adapter Card (PIC)
376 #define LINKTYPE_JUNIPER_VP 183
380 * DLT_ requested by Gianluca Varenni <gianluca.varenni@cacetech.com>.
381 * Every frame contains a 32bit A429 label.
382 * More documentation on Arinc 429 can be found at
383 * http://www.condoreng.com/support/downloads/tutorials/ARINCTutorial.pdf
385 #define LINKTYPE_A429 184
388 * Arinc 653 Interpartition Communication messages.
389 * DLT_ requested by Gianluca Varenni <gianluca.varenni@cacetech.com>.
390 * Please refer to the A653-1 standard for more information.
392 #define LINKTYPE_A653_ICM 185
395 * USB packets, beginning with a USB setup header; requested by
396 * Paolo Abeni <paolo.abeni@email.it>.
398 #define LINKTYPE_USB 186
401 * Bluetooth HCI UART transport layer (part H:4); requested by
404 #define LINKTYPE_BLUETOOTH_HCI_H4 187
407 * IEEE 802.16 MAC Common Part Sublayer; requested by Maria Cruz
408 * <cruz_petagay@bah.com>.
410 #define LINKTYPE_IEEE802_16_MAC_CPS 188
413 * USB packets, beginning with a Linux USB header; requested by
414 * Paolo Abeni <paolo.abeni@email.it>.
416 #define LINKTYPE_USB_LINUX 189
419 * Controller Area Network (CAN) v. 2.0B packets.
420 * DLT_ requested by Gianluca Varenni <gianluca.varenni@cacetech.com>.
421 * Used to dump CAN packets coming from a CAN Vector board.
422 * More documentation on the CAN v2.0B frames can be found at
423 * http://www.can-cia.org/downloads/?269
425 #define LINKTYPE_CAN20B 190
428 * IEEE 802.15.4, with address fields padded, as is done by Linux
429 * drivers; requested by Juergen Schimmer.
431 #define LINKTYPE_IEEE802_15_4_LINUX 191
434 * Per Packet Information encapsulated packets.
435 * LINKTYPE_ requested by Gianluca Varenni <gianluca.varenni@cacetech.com>.
437 #define LINKTYPE_PPI 192
440 * Header for 802.16 MAC Common Part Sublayer plus a radiotap radio header;
441 * requested by Charles Clancy.
443 #define LINKTYPE_IEEE802_16_MAC_CPS_RADIO 193
446 * Juniper-private data link type, as per request from
447 * Hannes Gredler <hannes@juniper.net>.
448 * The DLT_ is used for internal communication with a
449 * integrated service module (ISM).
451 #define LINKTYPE_JUNIPER_ISM 194
454 * IEEE 802.15.4, exactly as it appears in the spec (no padding, no
455 * nothing); requested by Mikko Saarnivala <mikko.saarnivala@sensinode.com>.
457 #define LINKTYPE_IEEE802_15_4 195
460 * Various link-layer types, with a pseudo-header, for SITA
461 * (http://www.sita.aero/); requested by Fulko Hew (fulko.hew@gmail.com).
463 #define LINKTYPE_SITA 196
466 * Various link-layer types, with a pseudo-header, for Endace DAG cards;
467 * encapsulates Endace ERF records. Requested by Stephen Donnelly
468 * <stephen@endace.com>.
470 #define LINKTYPE_ERF 197
473 * Special header prepended to Ethernet packets when capturing from a
474 * u10 Networks board. Requested by Phil Mulholland
475 * <phil@u10networks.com>.
477 #define LINKTYPE_RAIF1 198
480 * IPMB packet for IPMI, beginning with the I2C slave address, followed
481 * by the netFn and LUN, etc.. Requested by Chanthy Toeung
482 * <chanthy.toeung@ca.kontron.com>.
484 #define LINKTYPE_IPMB 199
487 * Juniper-private data link type, as per request from
488 * Hannes Gredler <hannes@juniper.net>.
489 * The DLT_ is used for capturing data on a secure tunnel interface.
491 #define LINKTYPE_JUNIPER_ST 200
494 * Bluetooth HCI UART transport layer (part H:4), with pseudo-header
495 * that includes direction information; requested by Paolo Abeni.
497 #define LINKTYPE_BLUETOOTH_HCI_H4_WITH_PHDR 201
500 * AX.25 packet with a 1-byte KISS header; see
502 * http://www.ax25.net/kiss.htm
504 * as per Richard Stearn <richard@rns-stearn.demon.co.uk>.
506 #define LINKTYPE_AX25_KISS 202
509 * LAPD packets from an ISDN channel, starting with the address field,
510 * with no pseudo-header.
511 * Requested by Varuna De Silva <varunax@gmail.com>.
513 #define LINKTYPE_LAPD 203
516 * Variants of various link-layer headers, with a one-byte direction
517 * pseudo-header prepended - zero means "received by this host",
518 * non-zero (any non-zero value) means "sent by this host" - as per
519 * Will Barker <w.barker@zen.co.uk>.
521 #define LINKTYPE_PPP_WITH_DIR 204 /* PPP */
522 #define LINKTYPE_C_HDLC_WITH_DIR 205 /* Cisco HDLC */
523 #define LINKTYPE_FRELAY_WITH_DIR 206 /* Frame Relay */
524 #define LINKTYPE_LAPB_WITH_DIR 207 /* LAPB */
527 * 208 is reserved for an as-yet-unspecified proprietary link-layer
528 * type, as requested by Will Barker.
532 * IPMB with a Linux-specific pseudo-header; as requested by Alexey Neyman
533 * <avn@pigeonpoint.com>.
535 #define LINKTYPE_IPMB_LINUX 209
538 * FlexRay automotive bus - http://www.flexray.com/ - as requested
539 * by Hannes Kaelber <hannes.kaelber@x2e.de>.
541 #define LINKTYPE_FLEXRAY 210
544 * Media Oriented Systems Transport (MOST) bus for multimedia
545 * transport - http://www.mostcooperation.com/ - as requested
546 * by Hannes Kaelber <hannes.kaelber@x2e.de>.
548 #define LINKTYPE_MOST 211
551 * Local Interconnect Network (LIN) bus for vehicle networks -
552 * http://www.lin-subbus.org/ - as requested by Hannes Kaelber
553 * <hannes.kaelber@x2e.de>.
555 #define LINKTYPE_LIN 212
558 * X2E-private data link type used for serial line capture,
559 * as requested by Hannes Kaelber <hannes.kaelber@x2e.de>.
561 #define LINKTYPE_X2E_SERIAL 213
564 * X2E-private data link type used for the Xoraya data logger
565 * family, as requested by Hannes Kaelber <hannes.kaelber@x2e.de>.
567 #define LINKTYPE_X2E_XORAYA 214
570 * IEEE 802.15.4, exactly as it appears in the spec (no padding, no
571 * nothing), but with the PHY-level data for non-ASK PHYs (4 octets
572 * of 0 as preamble, one octet of SFD, one octet of frame length+
573 * reserved bit, and then the MAC-layer data, starting with the
574 * frame control field).
576 * Requested by Max Filippov <jcmvbkbc@gmail.com>.
578 #define LINKTYPE_IEEE802_15_4_NONASK_PHY 215
581 * David Gibson <david@gibson.dropbear.id.au> requested this for
582 * captures from the Linux kernel /dev/input/eventN devices. This
583 * is used to communicate keystrokes and mouse movements from the
584 * Linux kernel to display systems, such as Xorg.
586 #define LINKTYPE_LINUX_EVDEV 216
589 * GSM Um and Abis interfaces, preceded by a "gsmtap" header.
591 * Requested by Harald Welte <laforge@gnumonks.org>.
593 #define LINKTYPE_GSMTAP_UM 217
594 #define LINKTYPE_GSMTAP_ABIS 218
597 * MPLS, with an MPLS label as the link-layer header.
598 * Requested by Michele Marchetto <michele@openbsd.org> on behalf
601 #define LINKTYPE_MPLS 219
604 * USB packets, beginning with a Linux USB header, with the USB header
605 * padded to 64 bytes; required for memory-mapped access.
607 #define LINKTYPE_USB_LINUX_MMAPPED 220
610 * DECT packets, with a pseudo-header; requested by
611 * Matthias Wenzel <tcpdump@mazzoo.de>.
613 #define LINKTYPE_DECT 221
616 * From: "Lidwa, Eric (GSFC-582.0)[SGT INC]" <eric.lidwa-1@nasa.gov>
617 * Date: Mon, 11 May 2009 11:18:30 -0500
619 * DLT_AOS. We need it for AOS Space Data Link Protocol.
620 * I have already written dissectors for but need an OK from
621 * legal before I can submit a patch.
624 #define LINKTYPE_AOS 222
627 * Wireless HART (Highway Addressable Remote Transducer)
628 * From the HART Communication Foundation
631 * Requested by Sam Roberts <vieuxtech@gmail.com>.
633 #define LINKTYPE_WIHART 223
636 * Fibre Channel FC-2 frames, beginning with a Frame_Header.
637 * Requested by Kahou Lei <kahou82@gmail.com>.
639 #define LINKTYPE_FC_2 224
642 * Fibre Channel FC-2 frames, beginning with an encoding of the
643 * SOF, and ending with an encoding of the EOF.
645 * The encodings represent the frame delimiters as 4-byte sequences
646 * representing the corresponding ordered sets, with K28.5
647 * represented as 0xBC, and the D symbols as the corresponding
648 * byte values; for example, SOFi2, which is K28.5 - D21.5 - D1.2 - D21.2,
649 * is represented as 0xBC 0xB5 0x55 0x55.
651 * Requested by Kahou Lei <kahou82@gmail.com>.
653 #define LINKTYPE_FC_2_WITH_FRAME_DELIMS 225
656 * Solaris ipnet pseudo-header; requested by Darren Reed <Darren.Reed@Sun.COM>.
658 * The pseudo-header starts with a one-byte version number; for version 2,
659 * the pseudo-header is:
661 * struct dl_ipnetinfo {
662 * u_int8_t dli_version;
663 * u_int8_t dli_family;
664 * u_int16_t dli_htype;
665 * u_int32_t dli_pktlen;
666 * u_int32_t dli_ifindex;
667 * u_int32_t dli_grifindex;
668 * u_int32_t dli_zsrc;
669 * u_int32_t dli_zdst;
672 * dli_version is 2 for the current version of the pseudo-header.
674 * dli_family is a Solaris address family value, so it's 2 for IPv4
677 * dli_htype is a "hook type" - 0 for incoming packets, 1 for outgoing
678 * packets, and 2 for packets arriving from another zone on the same
681 * dli_pktlen is the length of the packet data following the pseudo-header
682 * (so the captured length minus dli_pktlen is the length of the
683 * pseudo-header, assuming the entire pseudo-header was captured).
685 * dli_ifindex is the interface index of the interface on which the
688 * dli_grifindex is the group interface index number (for IPMP interfaces).
690 * dli_zsrc is the zone identifier for the source of the packet.
692 * dli_zdst is the zone identifier for the destination of the packet.
694 * A zone number of 0 is the global zone; a zone number of 0xffffffff
695 * means that the packet arrived from another host on the network, not
696 * from another zone on the same machine.
698 * An IPv4 or IPv6 datagram follows the pseudo-header; dli_family indicates
699 * which of those it is.
701 #define LINKTYPE_IPNET 226
704 * CAN (Controller Area Network) frames, with a pseudo-header as supplied
705 * by Linux SocketCAN. See Documentation/networking/can.txt in the Linux
708 * Requested by Felix Obenhuber <felix@obenhuber.de>.
710 #define LINKTYPE_CAN_SOCKETCAN 227
713 * Raw IPv4/IPv6; different from DLT_RAW in that the DLT_ value specifies
714 * whether it's v4 or v6. Requested by Darren Reed <Darren.Reed@Sun.COM>.
716 #define LINKTYPE_IPV4 228
717 #define LINKTYPE_IPV6 229
720 * IEEE 802.15.4, exactly as it appears in the spec (no padding, no
721 * nothing), and with no FCS at the end of the frame; requested by
722 * Jon Smirl <jonsmirl@gmail.com>.
724 #define LINKTYPE_IEEE802_15_4_NOFCS 230
729 * http://www.freedesktop.org/wiki/Software/dbus
733 * http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-messages
735 * starting with the endianness flag, followed by the message type, etc.,
736 * but without the authentication handshake before the message sequence:
738 * http://dbus.freedesktop.org/doc/dbus-specification.html#auth-protocol
740 * Requested by Martin Vidner <martin@vidner.net>.
742 #define LINKTYPE_DBUS 231
745 * Juniper-private data link type, as per request from
746 * Hannes Gredler <hannes@juniper.net>.
748 #define LINKTYPE_JUNIPER_VS 232
749 #define LINKTYPE_JUNIPER_SRX_E2E 233
750 #define LINKTYPE_JUNIPER_FIBRECHANNEL 234
753 * DVB-CI (DVB Common Interface for communication between a PC Card
754 * module and a DVB receiver). See
756 * http://www.kaiser.cx/pcap-dvbci.html
758 * for the specification.
760 * Requested by Martin Kaiser <martin@kaiser.cx>.
762 #define LINKTYPE_DVB_CI 235
765 * Variant of 3GPP TS 27.010 multiplexing protocol. Requested
766 * by Hans-Christoph Schemmel <hans-christoph.schemmel@cinterion.com>.
768 #define LINKTYPE_MUX27010 236
771 * STANAG 5066 D_PDUs. Requested by M. Baris Demiray
772 * <barisdemiray@gmail.com>.
774 #define LINKTYPE_STANAG_5066_D_PDU 237
777 * Juniper-private data link type, as per request from
778 * Hannes Gredler <hannes@juniper.net>.
780 #define LINKTYPE_JUNIPER_ATM_CEMIC 238
782 static struct linktype_map
{
787 * These DLT_* codes have LINKTYPE_* codes with values identical
788 * to the values of the corresponding DLT_* code.
790 { DLT_NULL
, LINKTYPE_NULL
},
791 { DLT_EN10MB
, LINKTYPE_ETHERNET
},
792 { DLT_EN3MB
, LINKTYPE_EXP_ETHERNET
},
793 { DLT_AX25
, LINKTYPE_AX25
},
794 { DLT_PRONET
, LINKTYPE_PRONET
},
795 { DLT_CHAOS
, LINKTYPE_CHAOS
},
796 { DLT_IEEE802
, LINKTYPE_TOKEN_RING
},
797 { DLT_ARCNET
, LINKTYPE_ARCNET_BSD
},
798 { DLT_SLIP
, LINKTYPE_SLIP
},
799 { DLT_PPP
, LINKTYPE_PPP
},
800 { DLT_FDDI
, LINKTYPE_FDDI
},
803 * These DLT_* codes have different values on different
804 * platforms; we map them to LINKTYPE_* codes that
805 * have values that should never be equal to any DLT_*
809 /* BSD/OS Frame Relay */
810 { DLT_FR
, LINKTYPE_FRELAY
},
813 { DLT_SYMANTEC_FIREWALL
, LINKTYPE_SYMANTEC_FIREWALL
},
814 { DLT_ATM_RFC1483
, LINKTYPE_ATM_RFC1483
},
815 { DLT_RAW
, LINKTYPE_RAW
},
816 { DLT_SLIP_BSDOS
, LINKTYPE_SLIP_BSDOS
},
817 { DLT_PPP_BSDOS
, LINKTYPE_PPP_BSDOS
},
819 /* BSD/OS Cisco HDLC */
820 { DLT_C_HDLC
, LINKTYPE_C_HDLC
},
823 * These DLT_* codes are not on all platforms, but, so far,
824 * there don't appear to be any platforms that define
825 * other codes with those values; we map them to
826 * different LINKTYPE_* values anyway, just in case.
829 /* Linux ATM Classical IP */
830 { DLT_ATM_CLIP
, LINKTYPE_ATM_CLIP
},
832 /* NetBSD sync/async serial PPP (or Cisco HDLC) */
833 { DLT_PPP_SERIAL
, LINKTYPE_PPP_HDLC
},
835 /* NetBSD PPP over Ethernet */
836 { DLT_PPP_ETHER
, LINKTYPE_PPP_ETHER
},
838 /* IEEE 802.11 wireless */
839 { DLT_IEEE802_11
, LINKTYPE_IEEE802_11
},
842 { DLT_FRELAY
, LINKTYPE_FRELAY
},
844 /* OpenBSD loopback */
845 { DLT_LOOP
, LINKTYPE_LOOP
},
847 /* OpenBSD IPSEC enc */
848 { DLT_ENC
, LINKTYPE_ENC
},
850 /* Linux cooked socket capture */
851 { DLT_LINUX_SLL
, LINKTYPE_LINUX_SLL
},
853 /* Apple LocalTalk hardware */
854 { DLT_LTALK
, LINKTYPE_LTALK
},
857 { DLT_ECONET
, LINKTYPE_ECONET
},
859 /* OpenBSD DLT_PFLOG */
860 { DLT_PFLOG
, LINKTYPE_PFLOG
},
862 /* For Cisco-internal use */
863 { DLT_CISCO_IOS
, LINKTYPE_CISCO_IOS
},
865 /* Prism II monitor-mode header plus 802.11 header */
866 { DLT_PRISM_HEADER
, LINKTYPE_PRISM_HEADER
},
868 /* FreeBSD Aironet driver stuff */
869 { DLT_AIRONET_HEADER
, LINKTYPE_AIRONET_HEADER
},
871 /* Siemens HiPath HDLC */
872 { DLT_HHDLC
, LINKTYPE_HHDLC
},
874 /* RFC 2625 IP-over-Fibre Channel */
875 { DLT_IP_OVER_FC
, LINKTYPE_IP_OVER_FC
},
878 { DLT_SUNATM
, LINKTYPE_SUNATM
},
881 { DLT_RIO
, LINKTYPE_RIO
},
884 { DLT_PCI_EXP
, LINKTYPE_PCI_EXP
},
886 /* Xilinx Aurora link layer */
887 { DLT_AURORA
, LINKTYPE_AURORA
},
889 /* 802.11 plus BSD radio header */
890 { DLT_IEEE802_11_RADIO
, LINKTYPE_IEEE802_11_RADIO
},
892 /* Tazmen Sniffer Protocol */
893 { DLT_TZSP
, LINKTYPE_TZSP
},
895 /* Arcnet with Linux-style link-layer headers */
896 { DLT_ARCNET_LINUX
, LINKTYPE_ARCNET_LINUX
},
898 /* Juniper-internal chassis encapsulation */
899 { DLT_JUNIPER_MLPPP
, LINKTYPE_JUNIPER_MLPPP
},
900 { DLT_JUNIPER_MLFR
, LINKTYPE_JUNIPER_MLFR
},
901 { DLT_JUNIPER_ES
, LINKTYPE_JUNIPER_ES
},
902 { DLT_JUNIPER_GGSN
, LINKTYPE_JUNIPER_GGSN
},
903 { DLT_JUNIPER_MFR
, LINKTYPE_JUNIPER_MFR
},
904 { DLT_JUNIPER_ATM2
, LINKTYPE_JUNIPER_ATM2
},
905 { DLT_JUNIPER_SERVICES
, LINKTYPE_JUNIPER_SERVICES
},
906 { DLT_JUNIPER_ATM1
, LINKTYPE_JUNIPER_ATM1
},
908 /* Apple IP-over-IEEE 1394 cooked header */
909 { DLT_APPLE_IP_OVER_IEEE1394
, LINKTYPE_APPLE_IP_OVER_IEEE1394
},
912 { DLT_MTP2_WITH_PHDR
, LINKTYPE_MTP2_WITH_PHDR
},
913 { DLT_MTP2
, LINKTYPE_MTP2
},
914 { DLT_MTP3
, LINKTYPE_MTP3
},
915 { DLT_SCCP
, LINKTYPE_SCCP
},
917 /* DOCSIS MAC frames */
918 { DLT_DOCSIS
, LINKTYPE_DOCSIS
},
920 /* IrDA IrLAP packets + Linux-cooked header */
921 { DLT_LINUX_IRDA
, LINKTYPE_LINUX_IRDA
},
923 /* IBM SP and Next Federation switches */
924 { DLT_IBM_SP
, LINKTYPE_IBM_SP
},
925 { DLT_IBM_SN
, LINKTYPE_IBM_SN
},
927 /* 802.11 plus AVS radio header */
928 { DLT_IEEE802_11_RADIO_AVS
, LINKTYPE_IEEE802_11_RADIO_AVS
},
931 * Any platform that defines additional DLT_* codes should:
933 * request a LINKTYPE_* code and value from tcpdump.org,
936 * add, in their version of libpcap, an entry to map
937 * those DLT_* codes to the corresponding LINKTYPE_*
940 * redefine, in their "net/bpf.h", any DLT_* values
941 * that collide with the values used by their additional
942 * DLT_* codes, to remove those collisions (but without
943 * making them collide with any of the LINKTYPE_*
944 * values equal to 50 or above; they should also avoid
945 * defining DLT_* values that collide with those
946 * LINKTYPE_* values, either).
949 /* Juniper-internal chassis encapsulation */
950 { DLT_JUNIPER_MONITOR
, LINKTYPE_JUNIPER_MONITOR
},
953 { DLT_BACNET_MS_TP
, LINKTYPE_BACNET_MS_TP
},
955 /* PPP for pppd, with direction flag in the PPP header */
956 { DLT_PPP_PPPD
, LINKTYPE_PPP_PPPD
},
958 /* Juniper-internal chassis encapsulation */
959 { DLT_JUNIPER_PPPOE
, LINKTYPE_JUNIPER_PPPOE
},
960 { DLT_JUNIPER_PPPOE_ATM
,LINKTYPE_JUNIPER_PPPOE_ATM
},
963 { DLT_GPRS_LLC
, LINKTYPE_GPRS_LLC
},
965 /* Transparent Generic Framing Procedure (ITU-T G.7041/Y.1303) */
966 { DLT_GPF_T
, LINKTYPE_GPF_T
},
968 /* Framed Generic Framing Procedure (ITU-T G.7041/Y.1303) */
969 { DLT_GPF_F
, LINKTYPE_GPF_F
},
971 { DLT_GCOM_T1E1
, LINKTYPE_GCOM_T1E1
},
972 { DLT_GCOM_SERIAL
, LINKTYPE_GCOM_SERIAL
},
974 /* Juniper-internal chassis encapsulation */
975 { DLT_JUNIPER_PIC_PEER
, LINKTYPE_JUNIPER_PIC_PEER
},
978 { DLT_ERF_ETH
, LINKTYPE_ERF_ETH
},
979 { DLT_ERF_POS
, LINKTYPE_ERF_POS
},
982 { DLT_LINUX_LAPD
, LINKTYPE_LINUX_LAPD
},
984 /* Juniper meta-information before Ether, PPP, Frame Relay, C-HDLC Frames */
985 { DLT_JUNIPER_ETHER
, LINKTYPE_JUNIPER_ETHER
},
986 { DLT_JUNIPER_PPP
, LINKTYPE_JUNIPER_PPP
},
987 { DLT_JUNIPER_FRELAY
, LINKTYPE_JUNIPER_FRELAY
},
988 { DLT_JUNIPER_CHDLC
, LINKTYPE_JUNIPER_CHDLC
},
990 /* Multi Link Frame Relay (FRF.16) */
991 { DLT_MFR
, LINKTYPE_MFR
},
993 /* Juniper Voice PIC */
994 { DLT_JUNIPER_VP
, LINKTYPE_JUNIPER_VP
},
996 /* Controller Area Network (CAN) v2.0B */
997 { DLT_A429
, LINKTYPE_A429
},
999 /* Arinc 653 Interpartition Communication messages */
1000 { DLT_A653_ICM
, LINKTYPE_A653_ICM
},
1003 { DLT_USB
, LINKTYPE_USB
},
1005 /* Bluetooth HCI UART transport layer */
1006 { DLT_BLUETOOTH_HCI_H4
, LINKTYPE_BLUETOOTH_HCI_H4
},
1008 /* IEEE 802.16 MAC Common Part Sublayer */
1009 { DLT_IEEE802_16_MAC_CPS
, LINKTYPE_IEEE802_16_MAC_CPS
},
1011 /* USB with Linux header */
1012 { DLT_USB_LINUX
, LINKTYPE_USB_LINUX
},
1014 /* Controller Area Network (CAN) v2.0B */
1015 { DLT_CAN20B
, LINKTYPE_CAN20B
},
1017 /* IEEE 802.15.4 with address fields padded */
1018 { DLT_IEEE802_15_4_LINUX
, LINKTYPE_IEEE802_15_4_LINUX
},
1020 /* Per Packet Information encapsulated packets */
1021 { DLT_PPI
, LINKTYPE_PPI
},
1023 /* IEEE 802.16 MAC Common Part Sublayer plus radiotap header */
1024 { DLT_IEEE802_16_MAC_CPS_RADIO
, LINKTYPE_IEEE802_16_MAC_CPS_RADIO
},
1026 /* Juniper Voice ISM */
1027 { DLT_JUNIPER_ISM
, LINKTYPE_JUNIPER_ISM
},
1029 /* IEEE 802.15.4 exactly as it appears in the spec, with FCS */
1030 { DLT_IEEE802_15_4
, LINKTYPE_IEEE802_15_4
},
1032 /* Various link-layer types for SITA */
1033 { DLT_SITA
, LINKTYPE_SITA
},
1035 /* Various link-layer types for Endace */
1036 { DLT_ERF
, LINKTYPE_ERF
},
1038 /* Special header for u10 Networks boards */
1039 { DLT_RAIF1
, LINKTYPE_RAIF1
},
1042 { DLT_IPMB
, LINKTYPE_IPMB
},
1044 /* Juniper Secure Tunnel */
1045 { DLT_JUNIPER_ST
, LINKTYPE_JUNIPER_ST
},
1047 /* Bluetooth HCI UART transport layer, with pseudo-header */
1048 { DLT_BLUETOOTH_HCI_H4_WITH_PHDR
, LINKTYPE_BLUETOOTH_HCI_H4_WITH_PHDR
},
1050 /* AX.25 with KISS header */
1051 { DLT_AX25_KISS
, LINKTYPE_AX25_KISS
},
1053 /* Raw LAPD, with no pseudo-header */
1054 { DLT_LAPD
, LINKTYPE_LAPD
},
1056 /* PPP with one-byte pseudo-header giving direction */
1057 { DLT_PPP_WITH_DIR
, LINKTYPE_PPP_WITH_DIR
},
1059 /* Cisco HDLC with one-byte pseudo-header giving direction */
1060 { DLT_C_HDLC_WITH_DIR
, LINKTYPE_C_HDLC_WITH_DIR
},
1062 /* Frame Relay with one-byte pseudo-header giving direction */
1063 { DLT_FRELAY_WITH_DIR
, LINKTYPE_FRELAY_WITH_DIR
},
1065 /* LAPB with one-byte pseudo-header giving direction */
1066 { DLT_LAPB_WITH_DIR
, LINKTYPE_LAPB_WITH_DIR
},
1068 /* IPMB with Linux pseudo-header */
1069 { DLT_IPMB_LINUX
, LINKTYPE_IPMB_LINUX
},
1072 { DLT_FLEXRAY
, LINKTYPE_FLEXRAY
},
1075 { DLT_MOST
, LINKTYPE_MOST
},
1078 { DLT_LIN
, LINKTYPE_LIN
},
1080 /* X2E-private serial line capture */
1081 { DLT_X2E_SERIAL
, LINKTYPE_X2E_SERIAL
},
1083 /* X2E-private for Xoraya data logger family */
1084 { DLT_X2E_XORAYA
, LINKTYPE_X2E_XORAYA
},
1086 /* IEEE 802.15.4 with PHY data for non-ASK PHYs */
1087 { DLT_IEEE802_15_4_NONASK_PHY
, LINKTYPE_IEEE802_15_4_NONASK_PHY
},
1089 /* Input device events from Linux /dev/input/eventN devices */
1090 { DLT_LINUX_EVDEV
, LINKTYPE_LINUX_EVDEV
},
1093 { DLT_GSMTAP_UM
, LINKTYPE_GSMTAP_UM
},
1094 { DLT_GSMTAP_ABIS
, LINKTYPE_GSMTAP_ABIS
},
1096 /* MPLS, with an MPLS label as the link-layer header */
1097 { DLT_MPLS
, LINKTYPE_MPLS
},
1099 /* USB with padded Linux header */
1100 { DLT_USB_LINUX_MMAPPED
, LINKTYPE_USB_LINUX_MMAPPED
},
1102 /* DECT packets with a pseudo-header */
1103 { DLT_DECT
, LINKTYPE_DECT
},
1105 /* AOS Space Data Link Protocol */
1106 { DLT_AOS
, LINKTYPE_AOS
},
1109 { DLT_WIHART
, LINKTYPE_WIHART
},
1111 /* Fibre Channel FC-2 frames without SOF or EOF */
1112 { DLT_FC_2
, LINKTYPE_FC_2
},
1114 /* Fibre Channel FC-2 frames with SOF and EOF */
1115 { DLT_FC_2_WITH_FRAME_DELIMS
, LINKTYPE_FC_2_WITH_FRAME_DELIMS
},
1118 { DLT_IPNET
, LINKTYPE_IPNET
},
1120 /* CAN frames with SocketCAN headers */
1121 { DLT_CAN_SOCKETCAN
, LINKTYPE_CAN_SOCKETCAN
},
1124 { DLT_IPV4
, LINKTYPE_IPV4
},
1125 { DLT_IPV6
, LINKTYPE_IPV6
},
1127 /* IEEE 802.15.4 exactly as it appears in the spec, without FCS */
1128 { DLT_IEEE802_15_4_NOFCS
, LINKTYPE_IEEE802_15_4_NOFCS
},
1130 /* D-Bus messages */
1131 { DLT_DBUS
, LINKTYPE_DBUS
},
1133 /* Juniper Virtual Server */
1134 { DLT_JUNIPER_VS
, LINKTYPE_JUNIPER_VS
},
1136 /* Juniper SRX E2E debugging */
1137 { DLT_JUNIPER_SRX_E2E
, LINKTYPE_JUNIPER_SRX_E2E
},
1139 /* Juniper Fibrechannel */
1140 { DLT_JUNIPER_FIBRECHANNEL
, LINKTYPE_JUNIPER_FIBRECHANNEL
},
1143 { DLT_DVB_CI
, LINKTYPE_DVB_CI
},
1145 /* Variant of 3GPP TS 27.010 */
1146 { DLT_MUX27010
, LINKTYPE_MUX27010
},
1148 /* STANAG 5066 D_PDUs */
1149 { DLT_STANAG_5066_D_PDU
, LINKTYPE_STANAG_5066_D_PDU
},
1151 /* Juniper ATM CE MIC */
1152 { DLT_JUNIPER_ATM_CEMIC
, LINKTYPE_JUNIPER_ATM_CEMIC
},
1158 dlt_to_linktype(int dlt
)
1162 for (i
= 0; map
[i
].dlt
!= -1; i
++) {
1163 if (map
[i
].dlt
== dlt
)
1164 return (map
[i
].linktype
);
1168 * If we don't have a mapping for this DLT_ code, return an
1169 * error; that means that the table above needs to have an
1176 linktype_to_dlt(int linktype
)
1180 for (i
= 0; map
[i
].linktype
!= -1; i
++) {
1181 if (map
[i
].linktype
== linktype
)
1182 return (map
[i
].dlt
);
1186 * If we don't have an entry for this link type, return
1187 * the link type value; it may be a DLT_ value from an
1188 * older version of libpcap.
1194 * The DLT_USB_LINUX and DLT_USB_LINUX_MMAPPED headers are in host
1195 * byte order when capturing (it's supplied directly from a
1196 * memory-mapped buffer shared by the kernel).
1198 * When reading a DLT_USB_LINUX or DLT_USB_LINUX_MMAPPED capture file,
1199 * we need to convert it from the capturing host's byte order to
1200 * the reading host's byte order.
1203 swap_linux_usb_header(const struct pcap_pkthdr
*hdr
, u_char
*buf
,
1204 int header_len_64_bytes
)
1206 pcap_usb_header_mmapped
*uhdr
= (pcap_usb_header_mmapped
*)buf
;
1207 bpf_u_int32 offset
= 0;
1208 usb_isodesc
*pisodesc
;
1212 * "offset" is the offset *past* the field we're swapping;
1213 * we skip the field *before* checking to make sure
1214 * the captured data length includes the entire field.
1218 * The URB id is a totally opaque value; do we really need to
1219 * convert it to the reading host's byte order???
1221 offset
+= 8; /* skip past id */
1222 if (hdr
->caplen
< offset
)
1224 uhdr
->id
= SWAPLL(uhdr
->id
);
1226 offset
+= 4; /* skip past various 1-byte fields */
1228 offset
+= 2; /* skip past bus_id */
1229 if (hdr
->caplen
< offset
)
1231 uhdr
->bus_id
= SWAPSHORT(uhdr
->bus_id
);
1233 offset
+= 2; /* skip past various 1-byte fields */
1235 offset
+= 8; /* skip past ts_sec */
1236 if (hdr
->caplen
< offset
)
1238 uhdr
->ts_sec
= SWAPLL(uhdr
->ts_sec
);
1240 offset
+= 4; /* skip past ts_usec */
1241 if (hdr
->caplen
< offset
)
1243 uhdr
->ts_usec
= SWAPLONG(uhdr
->ts_usec
);
1245 offset
+= 4; /* skip past status */
1246 if (hdr
->caplen
< offset
)
1248 uhdr
->status
= SWAPLONG(uhdr
->status
);
1250 offset
+= 4; /* skip past urb_len */
1251 if (hdr
->caplen
< offset
)
1253 uhdr
->urb_len
= SWAPLONG(uhdr
->urb_len
);
1255 offset
+= 4; /* skip past data_len */
1256 if (hdr
->caplen
< offset
)
1258 uhdr
->data_len
= SWAPLONG(uhdr
->data_len
);
1260 if (uhdr
->transfer_type
== URB_ISOCHRONOUS
) {
1261 offset
+= 4; /* skip past s.iso.error_count */
1262 if (hdr
->caplen
< offset
)
1264 uhdr
->s
.iso
.error_count
= SWAPLONG(uhdr
->s
.iso
.error_count
);
1266 offset
+= 4; /* skip past s.iso.numdesc */
1267 if (hdr
->caplen
< offset
)
1269 uhdr
->s
.iso
.numdesc
= SWAPLONG(uhdr
->s
.iso
.numdesc
);
1271 offset
+= 8; /* skip USB setup header */
1273 if (header_len_64_bytes
) {
1275 * This is either the "version 1" header, with
1276 * 16 bytes of additional fields at the end, or
1277 * a "version 0" header from a memory-mapped
1278 * capture, with 16 bytes of zeroed-out padding
1279 * at the end. Byte swap them as if this were
1280 * a "version 1" header.
1282 offset
+= 4; /* skip past interval */
1283 if (hdr
->caplen
< offset
)
1285 uhdr
->interval
= SWAPLONG(uhdr
->interval
);
1287 offset
+= 4; /* skip past start_frame */
1288 if (hdr
->caplen
< offset
)
1290 uhdr
->start_frame
= SWAPLONG(uhdr
->start_frame
);
1292 offset
+= 4; /* skip past xfer_flags */
1293 if (hdr
->caplen
< offset
)
1295 uhdr
->xfer_flags
= SWAPLONG(uhdr
->xfer_flags
);
1297 offset
+= 4; /* skip past ndesc */
1298 if (hdr
->caplen
< offset
)
1300 uhdr
->ndesc
= SWAPLONG(uhdr
->ndesc
);
1303 if (uhdr
->transfer_type
== URB_ISOCHRONOUS
) {
1304 /* swap the values in struct linux_usb_isodesc */
1305 pisodesc
= (usb_isodesc
*)(void *)(buf
+offset
);
1306 numdesc
= uhdr
->s
.iso
.numdesc
;
1307 for (i
= 0; i
< numdesc
; i
++) {
1308 offset
+= 4; /* skip past status */
1309 if (hdr
->caplen
< offset
)
1311 pisodesc
->status
= SWAPLONG(pisodesc
->status
);
1313 offset
+= 4; /* skip past offset */
1314 if (hdr
->caplen
< offset
)
1316 pisodesc
->offset
= SWAPLONG(pisodesc
->offset
);
1318 offset
+= 4; /* skip past len */
1319 if (hdr
->caplen
< offset
)
1321 pisodesc
->len
= SWAPLONG(pisodesc
->len
);
1323 offset
+= 4; /* skip past padding */