FreeRDP
urbdrc_types.h
1 
21 #ifndef FREERDP_CHANNEL_URBDRC_CLIENT_TYPES_H
22 #define FREERDP_CHANNEL_URBDRC_CLIENT_TYPES_H
23 
24 #include <freerdp/config.h>
25 
26 #include <freerdp/dvc.h>
27 #include <freerdp/types.h>
28 
29 #include <msusb.h>
30 
31 #include <winpr/stream.h>
32 
33 #define RIM_CAPABILITY_VERSION_01 0x00000001
34 
35 #define CAPABILITIES_NEGOTIATOR 0x00000000
36 #define CLIENT_DEVICE_SINK 0x00000001
37 #define SERVER_CHANNEL_NOTIFICATION 0x00000002
38 #define CLIENT_CHANNEL_NOTIFICATION 0x00000003
39 #define BASE_USBDEVICE_NUM 0x00000005
40 
41 #define RIMCALL_RELEASE 0x00000001
42 #define RIMCALL_QUERYINTERFACE 0x00000002
43 #define RIM_EXCHANGE_CAPABILITY_REQUEST 0x00000100
44 #define CHANNEL_CREATED 0x00000100
45 #define ADD_VIRTUAL_CHANNEL 0x00000100
46 #define ADD_DEVICE 0x00000101
47 
48 #define INIT_CHANNEL_IN 1
49 #define INIT_CHANNEL_OUT 0
50 
51 /* InterfaceClass */
52 #define CLASS_RESERVE 0x00
53 #define CLASS_AUDIO 0x01
54 #define CLASS_COMMUNICATION_IF 0x02
55 #define CLASS_HID 0x03
56 #define CLASS_PHYSICAL 0x05
57 #define CLASS_IMAGE 0x06
58 #define CLASS_PRINTER 0x07
59 #define CLASS_MASS_STORAGE 0x08
60 #define CLASS_HUB 0x09
61 #define CLASS_COMMUNICATION_DATA_IF 0x0a
62 #define CLASS_SMART_CARD 0x0b
63 #define CLASS_CONTENT_SECURITY 0x0d
64 #define CLASS_VIDEO 0x0e
65 #define CLASS_PERSONAL_HEALTHCARE 0x0f
66 #define CLASS_DIAGNOSTIC 0xdc
67 #define CLASS_WIRELESS_CONTROLLER 0xe0
68 #define CLASS_ELSE_DEVICE 0xef
69 #define CLASS_DEPENDENCE 0xfe
70 #define CLASS_VENDOR_DEPENDENCE 0xff
71 
72 /* usb version */
73 #define USB_v1_0 0x100
74 #define USB_v1_1 0x110
75 #define USB_v2_0 0x200
76 #define USB_v3_0 0x300
77 
78 #define STREAM_ID_NONE 0x0UL
79 #define STREAM_ID_PROXY 0x1UL
80 #define STREAM_ID_STUB 0x2UL
81 #define STREAM_ID_MASK 0xC0000000
82 #define INTERFACE_ID_MASK 0x3FFFFFFF
83 
84 #define CANCEL_REQUEST 0x00000100
85 #define REGISTER_REQUEST_CALLBACK 0x00000101
86 #define IO_CONTROL 0x00000102
87 #define INTERNAL_IO_CONTROL 0x00000103
88 #define QUERY_DEVICE_TEXT 0x00000104
89 
90 #define TRANSFER_IN_REQUEST 0x00000105
91 #define TRANSFER_OUT_REQUEST 0x00000106
92 #define RETRACT_DEVICE 0x00000107
93 
94 #define IOCONTROL_COMPLETION 0x00000100
95 #define URB_COMPLETION 0x00000101
96 #define URB_COMPLETION_NO_DATA 0x00000102
97 
98 /* The USB device is to be stopped from being redirected because the
99  * device is blocked by the server's policy. */
100 #define UsbRetractReason_BlockedByPolicy 0x00000001
101 
102 enum device_text_type
103 {
104  DeviceTextDescription = 0,
105  DeviceTextLocationInformation = 1,
106 };
107 
108 enum device_descriptor_table
109 {
110  B_LENGTH = 0,
111  B_DESCRIPTOR_TYPE = 1,
112  BCD_USB = 2,
113  B_DEVICE_CLASS = 4,
114  B_DEVICE_SUBCLASS = 5,
115  B_DEVICE_PROTOCOL = 6,
116  B_MAX_PACKET_SIZE0 = 7,
117  ID_VENDOR = 8,
118  ID_PRODUCT = 10,
119  BCD_DEVICE = 12,
120  I_MANUFACTURER = 14,
121  I_PRODUCT = 15,
122  I_SERIAL_NUMBER = 16,
123  B_NUM_CONFIGURATIONS = 17
124 };
125 
126 #define PIPE_CANCEL 0
127 #define PIPE_RESET 1
128 
129 #define IOCTL_INTERNAL_USB_SUBMIT_URB 0x00220003
130 #define IOCTL_INTERNAL_USB_RESET_PORT 0x00220007
131 #define IOCTL_INTERNAL_USB_GET_PORT_STATUS 0x00220013
132 #define IOCTL_INTERNAL_USB_CYCLE_PORT 0x0022001F
133 #define IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION 0x00220027
134 
135 #define TS_URB_SELECT_CONFIGURATION 0x0000
136 #define TS_URB_SELECT_INTERFACE 0x0001
137 #define TS_URB_PIPE_REQUEST 0x0002
138 #define TS_URB_TAKE_FRAME_LENGTH_CONTROL 0x0003
139 #define TS_URB_RELEASE_FRAME_LENGTH_CONTROL 0x0004
140 #define TS_URB_GET_FRAME_LENGTH 0x0005
141 #define TS_URB_SET_FRAME_LENGTH 0x0006
142 #define TS_URB_GET_CURRENT_FRAME_NUMBER 0x0007
143 #define TS_URB_CONTROL_TRANSFER 0x0008
144 #define TS_URB_BULK_OR_INTERRUPT_TRANSFER 0x0009
145 #define TS_URB_ISOCH_TRANSFER 0x000A
146 #define TS_URB_GET_DESCRIPTOR_FROM_DEVICE 0x000B
147 #define TS_URB_SET_DESCRIPTOR_TO_DEVICE 0x000C
148 #define TS_URB_SET_FEATURE_TO_DEVICE 0x000D
149 #define TS_URB_SET_FEATURE_TO_INTERFACE 0x000E
150 #define TS_URB_SET_FEATURE_TO_ENDPOINT 0x000F
151 #define TS_URB_CLEAR_FEATURE_TO_DEVICE 0x0010
152 #define TS_URB_CLEAR_FEATURE_TO_INTERFACE 0x0011
153 #define TS_URB_CLEAR_FEATURE_TO_ENDPOINT 0x0012
154 #define TS_URB_GET_STATUS_FROM_DEVICE 0x0013
155 #define TS_URB_GET_STATUS_FROM_INTERFACE 0x0014
156 #define TS_URB_GET_STATUS_FROM_ENDPOINT 0x0015
157 #define TS_URB_RESERVED_0X0016 0x0016
158 #define TS_URB_VENDOR_DEVICE 0x0017
159 #define TS_URB_VENDOR_INTERFACE 0x0018
160 #define TS_URB_VENDOR_ENDPOINT 0x0019
161 #define TS_URB_CLASS_DEVICE 0x001A
162 #define TS_URB_CLASS_INTERFACE 0x001B
163 #define TS_URB_CLASS_ENDPOINT 0x001C
164 #define TS_URB_RESERVE_0X001D 0x001D
165 #define TS_URB_SYNC_RESET_PIPE_AND_CLEAR_STALL 0x001E
166 #define TS_URB_CLASS_OTHER 0x001F
167 #define TS_URB_VENDOR_OTHER 0x0020
168 #define TS_URB_GET_STATUS_FROM_OTHER 0x0021
169 #define TS_URB_CLEAR_FEATURE_TO_OTHER 0x0022
170 #define TS_URB_SET_FEATURE_TO_OTHER 0x0023
171 #define TS_URB_GET_DESCRIPTOR_FROM_ENDPOINT 0x0024
172 #define TS_URB_SET_DESCRIPTOR_TO_ENDPOINT 0x0025
173 #define TS_URB_CONTROL_GET_CONFIGURATION_REQUEST 0x0026
174 #define TS_URB_CONTROL_GET_INTERFACE_REQUEST 0x0027
175 #define TS_URB_GET_DESCRIPTOR_FROM_INTERFACE 0x0028
176 #define TS_URB_SET_DESCRIPTOR_TO_INTERFACE 0x0029
177 #define TS_URB_GET_OS_FEATURE_DESCRIPTOR_REQUEST 0x002A
178 #define TS_URB_RESERVE_0X002B 0x002B
179 #define TS_URB_RESERVE_0X002C 0x002C
180 #define TS_URB_RESERVE_0X002D 0x002D
181 #define TS_URB_RESERVE_0X002E 0x002E
182 #define TS_URB_RESERVE_0X002F 0x002F
183 // USB 2.0 calls start at 0x0030
184 #define TS_URB_SYNC_RESET_PIPE 0x0030
185 #define TS_URB_SYNC_CLEAR_STALL 0x0031
186 #define TS_URB_CONTROL_TRANSFER_EX 0x0032
187 
188 #define USBD_STATUS_SUCCESS 0x0
189 #define USBD_STATUS_PENDING 0x40000000
190 #define USBD_STATUS_CANCELED 0xC0010000
191 
192 #define USBD_STATUS_INVALID_URB_FUNCTION 0x80000200
193 #define USBD_STATUS_CRC 0xC0000001
194 #define USBD_STATUS_BTSTUFF 0xC0000002
195 #define USBD_STATUS_DATA_TOGGLE_MISMATCH 0xC0000003
196 #define USBD_STATUS_STALL_PID 0xC0000004
197 #define USBD_STATUS_DEV_NOT_RESPONDING 0xC0000005
198 #define USBD_STATUS_PID_CHECK_FAILURE 0xC0000006
199 #define USBD_STATUS_UNEXPECTED_PID 0xC0000007
200 #define USBD_STATUS_DATA_OVERRUN 0xC0000008
201 #define USBD_STATUS_DATA_UNDERRUN 0xC0000009
202 #define USBD_STATUS_RESERVED1 0xC000000A
203 #define USBD_STATUS_RESERVED2 0xC000000B
204 #define USBD_STATUS_BUFFER_OVERRUN 0xC000000C
205 #define USBD_STATUS_BUFFER_UNDERRUN 0xC000000D
206 
207 /* unknown */
208 #define USBD_STATUS_NO_DATA 0xC000000E
209 
210 #define USBD_STATUS_NOT_ACCESSED 0xC000000F
211 #define USBD_STATUS_FIFO 0xC0000010
212 #define USBD_STATUS_XACT_ERROR 0xC0000011
213 #define USBD_STATUS_BABBLE_DETECTED 0xC0000012
214 #define USBD_STATUS_DATA_BUFFER_ERROR 0xC0000013
215 
216 #define USBD_STATUS_NOT_SUPPORTED 0xC0000E00
217 #define USBD_STATUS_BUFFER_TOO_SMALL 0xC0003000
218 #define USBD_STATUS_TIMEOUT 0xC0006000
219 #define USBD_STATUS_DEVICE_GONE 0xC0007000
220 
221 #define USBD_STATUS_NO_MEMORY 0x80000100
222 #define USBD_STATUS_INVALID_URB_FUNCTION 0x80000200
223 #define USBD_STATUS_INVALID_PARAMETER 0x80000300
224 #define USBD_STATUS_REQUEST_FAILED 0x80000500
225 #define USBD_STATUS_INVALID_PIPE_HANDLE 0x80000600
226 #define USBD_STATUS_ERROR_SHORT_TRANSFER 0x80000900
227 
228 // Values for URB TransferFlags Field
229 //
230 
231 /*
232  Set if data moves device->host
233 */
234 #define USBD_TRANSFER_DIRECTION 0x00000001
235 /*
236  This bit if not set indicates that a short packet, and hence,
237  a short transfer is an error condition
238 */
239 #define USBD_SHORT_TRANSFER_OK 0x00000002
240 /*
241  Subit the iso transfer on the next frame
242 */
243 #define USBD_START_ISO_TRANSFER_ASAP 0x00000004
244 #define USBD_DEFAULT_PIPE_TRANSFER 0x00000008
245 
246 #define USBD_TRANSFER_DIRECTION_FLAG(flags) ((flags)&USBD_TRANSFER_DIRECTION)
247 
248 #define USBD_TRANSFER_DIRECTION_OUT 0
249 #define USBD_TRANSFER_DIRECTION_IN 1
250 
251 #define VALID_TRANSFER_FLAGS_MASK USBD_SHORT_TRANSFER_OK | \
252  USBD_TRANSFER_DIRECTION | \
253  USBD_START_ISO_TRANSFER_ASAP | \
254  USBD_DEFAULT_PIPE_TRANSFER)
255 
256 #define ENDPOINT_HALT 0x00
257 #define DEVICE_REMOTE_WAKEUP 0x01
258 
259 /* transfer type */
260 #define CONTROL_TRANSFER 0x00
261 #define ISOCHRONOUS_TRANSFER 0x01
262 #define BULK_TRANSFER 0x02
263 #define INTERRUPT_TRANSFER 0x03
264 
265 #define ClearHubFeature (0x2000 | LIBUSB_REQUEST_CLEAR_FEATURE)
266 #define ClearPortFeature (0x2300 | LIBUSB_REQUEST_CLEAR_FEATURE)
267 #define GetHubDescriptor (0xa000 | LIBUSB_REQUEST_GET_DESCRIPTOR)
268 #define GetHubStatus (0xa000 | LIBUSB_REQUEST_GET_STATUS)
269 #define GetPortStatus (0xa300 | LIBUSB_REQUEST_GET_STATUS)
270 #define SetHubFeature (0x2000 | LIBUSB_REQUEST_SET_FEATURE)
271 #define SetPortFeature (0x2300 | LIBUSB_REQUEST_SET_FEATURE)
272 
273 #define USBD_PF_CHANGE_MAX_PACKET 0x00000001
274 #define USBD_PF_SHORT_PACKET_OPT 0x00000002
275 #define USBD_PF_ENABLE_RT_THREAD_ACCESS 0x00000004
276 #define USBD_PF_MAP_ADD_TRANSFERS 0x00000008
277 
278 /* feature request */
279 #define URB_SET_FEATURE 0x00
280 #define URB_CLEAR_FEATURE 0x01
281 
282 #define USBD_PF_CHANGE_MAX_PACKET 0x00000001
283 #define USBD_PF_SHORT_PACKET_OPT 0x00000002
284 #define USBD_PF_ENABLE_RT_THREAD_ACCESS 0x00000004
285 #define USBD_PF_MAP_ADD_TRANSFERS 0x00000008
286 
287 #define URB_CONTROL_TRANSFER_EXTERNAL 0x1
288 #define URB_CONTROL_TRANSFER_NONEXTERNAL 0x0
289 
290 #define USBFS_URB_SHORT_NOT_OK 0x01
291 #define USBFS_URB_ISO_ASAP 0x02
292 #define USBFS_URB_BULK_CONTINUATION 0x04
293 #define USBFS_URB_QUEUE_BULK 0x10
294 
295 #define URBDRC_DEVICE_INITIALIZED 0x01
296 #define URBDRC_DEVICE_NOT_FOUND 0x02
297 #define URBDRC_DEVICE_CHANNEL_CLOSED 0x08
298 #define URBDRC_DEVICE_ALREADY_SEND 0x10
299 #define URBDRC_DEVICE_DETACH_KERNEL 0x20
300 
301 #define UDEVMAN_FLAG_ADD_BY_VID_PID 0x01
302 #define UDEVMAN_FLAG_ADD_BY_ADDR 0x02
303 #define UDEVMAN_FLAG_ADD_BY_AUTO 0x04
304 #define UDEVMAN_FLAG_DEBUG 0x08
305 
306 #endif /* FREERDP_CHANNEL_URBDRC_CLIENT_TYPES_H */