1190214Srpaulo/* 2190214Srpaulo * Copyright (c) 2006 Paolo Abeni (Italy) 3190214Srpaulo * All rights reserved. 4190214Srpaulo * 5190214Srpaulo * Redistribution and use in source and binary forms, with or without 6190214Srpaulo * modification, are permitted provided that the following conditions 7190214Srpaulo * are met: 8190214Srpaulo * 9190214Srpaulo * 1. Redistributions of source code must retain the above copyright 10190214Srpaulo * notice, this list of conditions and the following disclaimer. 11190214Srpaulo * 2. Redistributions in binary form must reproduce the above copyright 12190214Srpaulo * notice, this list of conditions and the following disclaimer in the 13190214Srpaulo * documentation and/or other materials provided with the distribution. 14190214Srpaulo * 3. The name of the author may not be used to endorse or promote 15190214Srpaulo * products derived from this software without specific prior written 16190214Srpaulo * permission. 17190214Srpaulo * 18190214Srpaulo * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19190214Srpaulo * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20190214Srpaulo * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21190214Srpaulo * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22190214Srpaulo * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23190214Srpaulo * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24190214Srpaulo * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25190214Srpaulo * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26190214Srpaulo * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27190214Srpaulo * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28190214Srpaulo * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29190214Srpaulo * 30190214Srpaulo * Basic USB data struct 31190214Srpaulo * By Paolo Abeni <paolo.abeni@email.it> 32190214Srpaulo * 33214518Srpaulo * @(#) $Header: /tcpdump/master/libpcap/pcap/usb.h,v 1.9 2008-12-23 20:13:29 guy Exp $ 34190214Srpaulo */ 35190214Srpaulo 36190214Srpaulo#ifndef _PCAP_USB_STRUCTS_H__ 37190214Srpaulo#define _PCAP_USB_STRUCTS_H__ 38190214Srpaulo 39190214Srpaulo/* 40190214Srpaulo * possible transfer mode 41190214Srpaulo */ 42190214Srpaulo#define URB_TRANSFER_IN 0x80 43190214Srpaulo#define URB_ISOCHRONOUS 0x0 44190214Srpaulo#define URB_INTERRUPT 0x1 45190214Srpaulo#define URB_CONTROL 0x2 46190214Srpaulo#define URB_BULK 0x3 47190214Srpaulo 48190214Srpaulo/* 49190214Srpaulo * possible event type 50190214Srpaulo */ 51190214Srpaulo#define URB_SUBMIT 'S' 52190214Srpaulo#define URB_COMPLETE 'C' 53190214Srpaulo#define URB_ERROR 'E' 54190214Srpaulo 55190214Srpaulo/* 56190214Srpaulo * USB setup header as defined in USB specification. 57214518Srpaulo * Appears at the front of each Control S-type packet in DLT_USB captures. 58190214Srpaulo */ 59190214Srpaulotypedef struct _usb_setup { 60190214Srpaulo u_int8_t bmRequestType; 61190214Srpaulo u_int8_t bRequest; 62190214Srpaulo u_int16_t wValue; 63190214Srpaulo u_int16_t wIndex; 64190214Srpaulo u_int16_t wLength; 65190214Srpaulo} pcap_usb_setup; 66190214Srpaulo 67214518Srpaulo/* 68214518Srpaulo * Information from the URB for Isochronous transfers. 69214518Srpaulo */ 70214518Srpaulotypedef struct _iso_rec { 71214518Srpaulo int32_t error_count; 72214518Srpaulo int32_t numdesc; 73214518Srpaulo} iso_rec; 74190214Srpaulo 75190214Srpaulo/* 76190214Srpaulo * Header prepended by linux kernel to each event. 77190214Srpaulo * Appears at the front of each packet in DLT_USB_LINUX captures. 78190214Srpaulo */ 79190214Srpaulotypedef struct _usb_header { 80190214Srpaulo u_int64_t id; 81190214Srpaulo u_int8_t event_type; 82190214Srpaulo u_int8_t transfer_type; 83190214Srpaulo u_int8_t endpoint_number; 84190214Srpaulo u_int8_t device_address; 85190214Srpaulo u_int16_t bus_id; 86190214Srpaulo char setup_flag;/*if !=0 the urb setup header is not present*/ 87190214Srpaulo char data_flag; /*if !=0 no urb data is present*/ 88190214Srpaulo int64_t ts_sec; 89190214Srpaulo int32_t ts_usec; 90190214Srpaulo int32_t status; 91190214Srpaulo u_int32_t urb_len; 92190214Srpaulo u_int32_t data_len; /* amount of urb data really present in this event*/ 93190214Srpaulo pcap_usb_setup setup; 94190214Srpaulo} pcap_usb_header; 95190214Srpaulo 96214518Srpaulo/* 97214518Srpaulo * Header prepended by linux kernel to each event for the 2.6.31 98214518Srpaulo * and later kernels; for the 2.6.21 through 2.6.30 kernels, the 99214518Srpaulo * "iso_rec" information, and the fields starting with "interval" 100214518Srpaulo * are zeroed-out padding fields. 101214518Srpaulo * 102214518Srpaulo * Appears at the front of each packet in DLT_USB_LINUX_MMAPPED captures. 103214518Srpaulo */ 104214518Srpaulotypedef struct _usb_header_mmapped { 105214518Srpaulo u_int64_t id; 106214518Srpaulo u_int8_t event_type; 107214518Srpaulo u_int8_t transfer_type; 108214518Srpaulo u_int8_t endpoint_number; 109214518Srpaulo u_int8_t device_address; 110214518Srpaulo u_int16_t bus_id; 111214518Srpaulo char setup_flag;/*if !=0 the urb setup header is not present*/ 112214518Srpaulo char data_flag; /*if !=0 no urb data is present*/ 113214518Srpaulo int64_t ts_sec; 114214518Srpaulo int32_t ts_usec; 115214518Srpaulo int32_t status; 116214518Srpaulo u_int32_t urb_len; 117214518Srpaulo u_int32_t data_len; /* amount of urb data really present in this event*/ 118214518Srpaulo union { 119214518Srpaulo pcap_usb_setup setup; 120214518Srpaulo iso_rec iso; 121214518Srpaulo } s; 122214518Srpaulo int32_t interval; /* for Interrupt and Isochronous events */ 123214518Srpaulo int32_t start_frame; /* for Isochronous events */ 124214518Srpaulo u_int32_t xfer_flags; /* copy of URB's transfer flags */ 125214518Srpaulo u_int32_t ndesc; /* number of isochronous descriptors */ 126214518Srpaulo} pcap_usb_header_mmapped; 127190214Srpaulo 128214518Srpaulo/* 129214518Srpaulo * Isochronous descriptors; for isochronous transfers there might be 130214518Srpaulo * one or more of these at the beginning of the packet data. The 131214518Srpaulo * number of descriptors is given by the "ndesc" field in the header; 132214518Srpaulo * as indicated, in older kernels that don't put the descriptors at 133214518Srpaulo * the beginning of the packet, that field is zeroed out, so that field 134214518Srpaulo * can be trusted even in captures from older kernels. 135214518Srpaulo */ 136214518Srpaulotypedef struct _usb_isodesc { 137214518Srpaulo int32_t status; 138214518Srpaulo u_int32_t offset; 139214518Srpaulo u_int32_t len; 140214518Srpaulo u_int8_t pad[4]; 141214518Srpaulo} usb_isodesc; 142214518Srpaulo 143190214Srpaulo#endif 144