Drop main() prototype. Syncs with NetBSD-8
[minix.git] / external / bsd / libpcap / dist / pcap / usb.h
blob0243eff45686a96637f24dab9b7aa20daf341aba
1 /* $NetBSD: usb.h,v 1.3 2015/03/31 21:39:43 christos Exp $ */
3 /*
4 * Copyright (c) 2006 Paolo Abeni (Italy)
5 * All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote
17 * products derived from this software without specific prior written
18 * permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 * Basic USB data struct
33 * By Paolo Abeni <paolo.abeni@email.it>
36 #ifndef _PCAP_USB_STRUCTS_H__
37 #define _PCAP_USB_STRUCTS_H__
40 * possible transfer mode
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
49 * possible event type
51 #define URB_SUBMIT 'S'
52 #define URB_COMPLETE 'C'
53 #define URB_ERROR 'E'
56 * USB setup header as defined in USB specification.
57 * Appears at the front of each Control S-type packet in DLT_USB captures.
59 typedef struct _usb_setup {
60 u_int8_t bmRequestType;
61 u_int8_t bRequest;
62 u_int16_t wValue;
63 u_int16_t wIndex;
64 u_int16_t wLength;
65 } pcap_usb_setup;
68 * Information from the URB for Isochronous transfers.
70 typedef struct _iso_rec {
71 int32_t error_count;
72 int32_t numdesc;
73 } iso_rec;
76 * Header prepended by linux kernel to each event.
77 * Appears at the front of each packet in DLT_USB_LINUX captures.
79 typedef struct _usb_header {
80 u_int64_t id;
81 u_int8_t event_type;
82 u_int8_t transfer_type;
83 u_int8_t endpoint_number;
84 u_int8_t device_address;
85 u_int16_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 u_int32_t urb_len;
92 u_int32_t data_len; /* amount of urb data really present in this event*/
93 pcap_usb_setup setup;
94 } pcap_usb_header;
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.
102 * Appears at the front of each packet in DLT_USB_LINUX_MMAPPED captures.
104 typedef struct _usb_header_mmapped {
105 u_int64_t id;
106 u_int8_t event_type;
107 u_int8_t transfer_type;
108 u_int8_t endpoint_number;
109 u_int8_t device_address;
110 u_int16_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 u_int32_t urb_len;
117 u_int32_t data_len; /* amount of urb data really present in this event*/
118 union {
119 pcap_usb_setup setup;
120 iso_rec iso;
121 } s;
122 int32_t interval; /* for Interrupt and Isochronous events */
123 int32_t start_frame; /* for Isochronous events */
124 u_int32_t xfer_flags; /* copy of URB's transfer flags */
125 u_int32_t ndesc; /* number of isochronous descriptors */
126 } pcap_usb_header_mmapped;
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.
136 typedef struct _usb_isodesc {
137 int32_t status;
138 u_int32_t offset;
139 u_int32_t len;
140 u_int8_t pad[4];
141 } usb_isodesc;
143 #endif