1254885Sdumbbell/* 2254885Sdumbbell * Copyright (c) 2006 Paolo Abeni (Italy) 3254885Sdumbbell * All rights reserved. 4254885Sdumbbell * 5254885Sdumbbell * Redistribution and use in source and binary forms, with or without 6254885Sdumbbell * modification, are permitted provided that the following conditions 7254885Sdumbbell * are met: 8254885Sdumbbell * 9254885Sdumbbell * 1. Redistributions of source code must retain the above copyright 10254885Sdumbbell * notice, this list of conditions and the following disclaimer. 11254885Sdumbbell * 2. Redistributions in binary form must reproduce the above copyright 12254885Sdumbbell * notice, this list of conditions and the following disclaimer in the 13254885Sdumbbell * documentation and/or other materials provided with the distribution. 14254885Sdumbbell * 3. The name of the author may not be used to endorse or promote 15254885Sdumbbell * products derived from this software without specific prior written 16254885Sdumbbell * permission. 17254885Sdumbbell * 18254885Sdumbbell * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19254885Sdumbbell * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20254885Sdumbbell * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21254885Sdumbbell * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22254885Sdumbbell * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23254885Sdumbbell * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24254885Sdumbbell * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25254885Sdumbbell * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26254885Sdumbbell * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27254885Sdumbbell * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28254885Sdumbbell * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29254885Sdumbbell * 30254885Sdumbbell * Basic USB data struct 31254885Sdumbbell * By Paolo Abeni <paolo.abeni@email.it> 32254885Sdumbbell * 33254885Sdumbbell * @(#) $Header: /tcpdump/master/libpcap/pcap/usb.h,v 1.9 2008-12-23 20:13:29 guy Exp $ 34254885Sdumbbell */ 35254885Sdumbbell 36254885Sdumbbell#ifndef _PCAP_USB_STRUCTS_H__ 37254885Sdumbbell#define _PCAP_USB_STRUCTS_H__ 38254885Sdumbbell 39254885Sdumbbell/* 40254885Sdumbbell * possible transfer mode 41254885Sdumbbell */ 42254885Sdumbbell#define URB_TRANSFER_IN 0x80 43254885Sdumbbell#define URB_ISOCHRONOUS 0x0 44254885Sdumbbell#define URB_INTERRUPT 0x1 45254885Sdumbbell#define URB_CONTROL 0x2 46254885Sdumbbell#define URB_BULK 0x3 47254885Sdumbbell 48254885Sdumbbell/* 49254885Sdumbbell * possible event type 50254885Sdumbbell */ 51254885Sdumbbell#define URB_SUBMIT 'S' 52254885Sdumbbell#define URB_COMPLETE 'C' 53254885Sdumbbell#define URB_ERROR 'E' 54254885Sdumbbell 55254885Sdumbbell/* 56254885Sdumbbell * USB setup header as defined in USB specification. 57254885Sdumbbell * Appears at the front of each Control S-type packet in DLT_USB captures. 58254885Sdumbbell */ 59254885Sdumbbelltypedef struct _usb_setup { 60254885Sdumbbell u_int8_t bmRequestType; 61254885Sdumbbell u_int8_t bRequest; 62254885Sdumbbell u_int16_t wValue; 63254885Sdumbbell u_int16_t wIndex; 64254885Sdumbbell u_int16_t wLength; 65254885Sdumbbell} pcap_usb_setup; 66254885Sdumbbell 67254885Sdumbbell/* 68254885Sdumbbell * Information from the URB for Isochronous transfers. 69254885Sdumbbell */ 70254885Sdumbbelltypedef struct _iso_rec { 71254885Sdumbbell int32_t error_count; 72254885Sdumbbell int32_t numdesc; 73254885Sdumbbell} iso_rec; 74254885Sdumbbell 75254885Sdumbbell/* 76254885Sdumbbell * Header prepended by linux kernel to each event. 77254885Sdumbbell * Appears at the front of each packet in DLT_USB_LINUX captures. 78254885Sdumbbell */ 79254885Sdumbbelltypedef struct _usb_header { 80254885Sdumbbell u_int64_t id; 81254885Sdumbbell u_int8_t event_type; 82254885Sdumbbell u_int8_t transfer_type; 83254885Sdumbbell u_int8_t endpoint_number; 84254885Sdumbbell u_int8_t device_address; 85254885Sdumbbell u_int16_t bus_id; 86254885Sdumbbell char setup_flag;/*if !=0 the urb setup header is not present*/ 87254885Sdumbbell char data_flag; /*if !=0 no urb data is present*/ 88254885Sdumbbell int64_t ts_sec; 89254885Sdumbbell int32_t ts_usec; 90254885Sdumbbell int32_t status; 91254885Sdumbbell u_int32_t urb_len; 92254885Sdumbbell u_int32_t data_len; /* amount of urb data really present in this event*/ 93254885Sdumbbell pcap_usb_setup setup; 94254885Sdumbbell} pcap_usb_header; 95254885Sdumbbell 96254885Sdumbbell/* 97254885Sdumbbell * Header prepended by linux kernel to each event for the 2.6.31 98254885Sdumbbell * and later kernels; for the 2.6.21 through 2.6.30 kernels, the 99254885Sdumbbell * "iso_rec" information, and the fields starting with "interval" 100254885Sdumbbell * are zeroed-out padding fields. 101254885Sdumbbell * 102254885Sdumbbell * Appears at the front of each packet in DLT_USB_LINUX_MMAPPED captures. 103254885Sdumbbell */ 104254885Sdumbbelltypedef struct _usb_header_mmapped { 105254885Sdumbbell u_int64_t id; 106254885Sdumbbell u_int8_t event_type; 107254885Sdumbbell u_int8_t transfer_type; 108254885Sdumbbell u_int8_t endpoint_number; 109254885Sdumbbell u_int8_t device_address; 110254885Sdumbbell u_int16_t bus_id; 111254885Sdumbbell char setup_flag;/*if !=0 the urb setup header is not present*/ 112254885Sdumbbell char data_flag; /*if !=0 no urb data is present*/ 113254885Sdumbbell int64_t ts_sec; 114254885Sdumbbell int32_t ts_usec; 115254885Sdumbbell int32_t status; 116254885Sdumbbell u_int32_t urb_len; 117254885Sdumbbell u_int32_t data_len; /* amount of urb data really present in this event*/ 118254885Sdumbbell union { 119254885Sdumbbell pcap_usb_setup setup; 120254885Sdumbbell iso_rec iso; 121254885Sdumbbell } s; 122254885Sdumbbell int32_t interval; /* for Interrupt and Isochronous events */ 123254885Sdumbbell int32_t start_frame; /* for Isochronous events */ 124254885Sdumbbell u_int32_t xfer_flags; /* copy of URB's transfer flags */ 125254885Sdumbbell u_int32_t ndesc; /* number of isochronous descriptors */ 126254885Sdumbbell} pcap_usb_header_mmapped; 127254885Sdumbbell 128254885Sdumbbell/* 129254885Sdumbbell * Isochronous descriptors; for isochronous transfers there might be 130254885Sdumbbell * one or more of these at the beginning of the packet data. The 131254885Sdumbbell * number of descriptors is given by the "ndesc" field in the header; 132254885Sdumbbell * as indicated, in older kernels that don't put the descriptors at 133254885Sdumbbell * the beginning of the packet, that field is zeroed out, so that field 134254885Sdumbbell * can be trusted even in captures from older kernels. 135254885Sdumbbell */ 136254885Sdumbbelltypedef struct _usb_isodesc { 137254885Sdumbbell int32_t status; 138254885Sdumbbell u_int32_t offset; 139254885Sdumbbell u_int32_t len; 140254885Sdumbbell u_int8_t pad[4]; 141254885Sdumbbell} usb_isodesc; 142254885Sdumbbell 143254885Sdumbbell#endif 144254885Sdumbbell