libpcap  1.10.1
About: libpcap is a packet filter library used by tools like tcpdump.
  Fossies Dox: libpcap-1.10.1.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

usb.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2006 Paolo Abeni (Italy)
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  * 3. The name of the author may not be used to endorse or promote
15  * products derived from this software without specific prior written
16  * permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  *
30  * Basic USB data struct
31  * By Paolo Abeni <paolo.abeni@email.it>
32  */
33 
34 #ifndef lib_pcap_usb_h
35 #define lib_pcap_usb_h
36 
37 #include <pcap/pcap-inttypes.h>
38 
39 /*
40  * possible transfer mode
41  */
42 #define URB_TRANSFER_IN 0x80
43 #define URB_ISOCHRONOUS 0x0
44 #define URB_INTERRUPT 0x1
45 #define URB_CONTROL 0x2
46 #define URB_BULK 0x3
47 
48 /*
49  * possible event type
50  */
51 #define URB_SUBMIT 'S'
52 #define URB_COMPLETE 'C'
53 #define URB_ERROR 'E'
54 
55 /*
56  * USB setup header as defined in USB specification.
57  * Appears at the front of each Control S-type packet in DLT_USB captures.
58  */
59 typedef struct _usb_setup {
60  uint8_t bmRequestType;
61  uint8_t bRequest;
62  uint16_t wValue;
63  uint16_t wIndex;
64  uint16_t wLength;
66 
67 /*
68  * Information from the URB for Isochronous transfers.
69  */
70 typedef struct _iso_rec {
71  int32_t error_count;
72  int32_t numdesc;
74 
75 /*
76  * Header prepended by linux kernel to each event.
77  * Appears at the front of each packet in DLT_USB_LINUX captures.
78  */
79 typedef struct _usb_header {
80  uint64_t id;
81  uint8_t event_type;
82  uint8_t transfer_type;
83  uint8_t endpoint_number;
84  uint8_t device_address;
85  uint16_t bus_id;
86  char setup_flag;/*if !=0 the urb setup header is not present*/
87  char data_flag; /*if !=0 no urb data is present*/
88  int64_t ts_sec;
89  int32_t ts_usec;
90  int32_t status;
91  uint32_t urb_len;
92  uint32_t data_len; /* amount of urb data really present in this event*/
95 
96 /*
97  * Header prepended by linux kernel to each event for the 2.6.31
98  * and later kernels; for the 2.6.21 through 2.6.30 kernels, the
99  * "iso_rec" information, and the fields starting with "interval"
100  * are zeroed-out padding fields.
101  *
102  * Appears at the front of each packet in DLT_USB_LINUX_MMAPPED captures.
103  */
104 typedef struct _usb_header_mmapped {
105  uint64_t id;
106  uint8_t event_type;
107  uint8_t transfer_type;
109  uint8_t device_address;
110  uint16_t bus_id;
111  char setup_flag;/*if !=0 the urb setup header is not present*/
112  char data_flag; /*if !=0 no urb data is present*/
113  int64_t ts_sec;
114  int32_t ts_usec;
115  int32_t status;
116  uint32_t urb_len;
117  uint32_t data_len; /* amount of urb data really present in this event*/
118  union {
121  } s;
122  int32_t interval; /* for Interrupt and Isochronous events */
123  int32_t start_frame; /* for Isochronous events */
124  uint32_t xfer_flags; /* copy of URB's transfer flags */
125  uint32_t ndesc; /* number of isochronous descriptors */
127 
128 /*
129  * Isochronous descriptors; for isochronous transfers there might be
130  * one or more of these at the beginning of the packet data. The
131  * number of descriptors is given by the "ndesc" field in the header;
132  * as indicated, in older kernels that don't put the descriptors at
133  * the beginning of the packet, that field is zeroed out, so that field
134  * can be trusted even in captures from older kernels.
135  */
136 typedef struct _usb_isodesc {
137  int32_t status;
138  uint32_t offset;
139  uint32_t len;
140  uint8_t pad[4];
142 
143 #endif
Definition: usb.h:70
int32_t error_count
Definition: usb.h:71
int32_t numdesc
Definition: usb.h:72
uint16_t bus_id
Definition: usb.h:110
int32_t interval
Definition: usb.h:122
uint32_t ndesc
Definition: usb.h:125
char data_flag
Definition: usb.h:112
uint8_t event_type
Definition: usb.h:106
int32_t ts_usec
Definition: usb.h:114
int64_t ts_sec
Definition: usb.h:113
pcap_usb_setup setup
Definition: usb.h:119
uint32_t data_len
Definition: usb.h:117
uint32_t xfer_flags
Definition: usb.h:124
char setup_flag
Definition: usb.h:111
iso_rec iso
Definition: usb.h:120
uint8_t transfer_type
Definition: usb.h:107
uint8_t device_address
Definition: usb.h:109
uint8_t endpoint_number
Definition: usb.h:108
uint32_t urb_len
Definition: usb.h:116
int32_t status
Definition: usb.h:115
uint64_t id
Definition: usb.h:105
union _usb_header_mmapped::@3 s
int32_t start_frame
Definition: usb.h:123
int64_t ts_sec
Definition: usb.h:88
uint32_t data_len
Definition: usb.h:92
uint64_t id
Definition: usb.h:80
pcap_usb_setup setup
Definition: usb.h:93
uint32_t urb_len
Definition: usb.h:91
char setup_flag
Definition: usb.h:86
uint16_t bus_id
Definition: usb.h:85
uint8_t device_address
Definition: usb.h:84
uint8_t transfer_type
Definition: usb.h:82
char data_flag
Definition: usb.h:87
uint8_t event_type
Definition: usb.h:81
uint8_t endpoint_number
Definition: usb.h:83
int32_t ts_usec
Definition: usb.h:89
int32_t status
Definition: usb.h:90
int32_t status
Definition: usb.h:137
uint32_t offset
Definition: usb.h:138
uint8_t pad[4]
Definition: usb.h:140
uint32_t len
Definition: usb.h:139
Definition: usb.h:59
uint8_t bRequest
Definition: usb.h:61
uint16_t wValue
Definition: usb.h:62
uint16_t wIndex
Definition: usb.h:63
uint16_t wLength
Definition: usb.h:64
uint8_t bmRequestType
Definition: usb.h:60
struct _usb_header_mmapped pcap_usb_header_mmapped
struct _iso_rec iso_rec
struct _usb_header pcap_usb_header
struct _usb_isodesc usb_isodesc
struct _usb_setup pcap_usb_setup