20 #include <freerdp/config.h>
22 #include "urbdrc_helpers.h"
23 #include "urbdrc_types.h"
24 #include <winpr/print.h>
26 const char* mask_to_string(UINT32 mask)
31 return "STREAM_ID_NONE";
34 return "STREAM_ID_PROXY";
37 return "STREAM_ID_STUB";
43 const char* interface_to_string(UINT32
id)
47 case CAPABILITIES_NEGOTIATOR:
48 return "CAPABILITIES_NEGOTIATOR";
50 case SERVER_CHANNEL_NOTIFICATION:
51 return "SERVER_CHANNEL_NOTIFICATION";
53 case CLIENT_CHANNEL_NOTIFICATION:
54 return "CLIENT_CHANNEL_NOTIFICATION";
57 return "DEVICE_MESSAGE";
61 static const char* call_to_string_none(BOOL client, UINT32 interfaceId, UINT32 functionId)
63 WINPR_UNUSED(interfaceId);
66 return "RIM_EXCHANGE_CAPABILITY_RESPONSE [none |client]";
71 case RIM_EXCHANGE_CAPABILITY_REQUEST:
72 return "RIM_EXCHANGE_CAPABILITY_REQUEST [none |server]";
75 return "RIMCALL_RELEASE [none |server]";
77 case RIMCALL_QUERYINTERFACE:
78 return "RIMCALL_QUERYINTERFACE [none |server]";
81 return "UNKNOWN [none |server]";
86 static const char* call_to_string_proxy_server(UINT32 functionId)
90 case QUERY_DEVICE_TEXT:
91 return "QUERY_DEVICE_TEXT [proxy|server]";
93 case INTERNAL_IO_CONTROL:
94 return "INTERNAL_IO_CONTROL [proxy|server]";
97 return "IO_CONTROL [proxy|server]";
99 case REGISTER_REQUEST_CALLBACK:
100 return "REGISTER_REQUEST_CALLBACK [proxy|server]";
103 return "CANCEL_REQUEST [proxy|server]";
106 return "RETRACT_DEVICE [proxy|server]";
108 case TRANSFER_IN_REQUEST:
109 return "TRANSFER_IN_REQUEST [proxy|server]";
111 case TRANSFER_OUT_REQUEST:
112 return "TRANSFER_OUT_REQUEST [proxy|server]";
115 return "UNKNOWN [proxy|server]";
119 static const char* call_to_string_proxy_client(UINT32 functionId)
123 case URB_COMPLETION_NO_DATA:
124 return "URB_COMPLETION_NO_DATA [proxy|client]";
127 return "URB_COMPLETION [proxy|client]";
129 case IOCONTROL_COMPLETION:
130 return "IOCONTROL_COMPLETION [proxy|client]";
132 case TRANSFER_OUT_REQUEST:
133 return "TRANSFER_OUT_REQUEST [proxy|client]";
136 return "UNKNOWN [proxy|client]";
140 static const char* call_to_string_proxy(BOOL client, UINT32 interfaceId, UINT32 functionId)
142 switch (interfaceId & INTERFACE_ID_MASK)
144 case CLIENT_DEVICE_SINK:
147 case ADD_VIRTUAL_CHANNEL:
148 return "ADD_VIRTUAL_CHANNEL [proxy|sink ]";
151 return "ADD_DEVICE [proxy|sink ]";
152 case RIMCALL_RELEASE:
153 return "RIMCALL_RELEASE [proxy|sink ]";
155 case RIMCALL_QUERYINTERFACE:
156 return "RIMCALL_QUERYINTERFACE [proxy|sink ]";
158 return "UNKNOWN [proxy|sink ]";
161 case SERVER_CHANNEL_NOTIFICATION:
164 case CHANNEL_CREATED:
165 return "CHANNEL_CREATED [proxy|server]";
167 case RIMCALL_RELEASE:
168 return "RIMCALL_RELEASE [proxy|server]";
170 case RIMCALL_QUERYINTERFACE:
171 return "RIMCALL_QUERYINTERFACE [proxy|server]";
174 return "UNKNOWN [proxy|server]";
177 case CLIENT_CHANNEL_NOTIFICATION:
180 case CHANNEL_CREATED:
181 return "CHANNEL_CREATED [proxy|client]";
182 case RIMCALL_RELEASE:
183 return "RIMCALL_RELEASE [proxy|client]";
184 case RIMCALL_QUERYINTERFACE:
185 return "RIMCALL_QUERYINTERFACE [proxy|client]";
187 return "UNKNOWN [proxy|client]";
192 return call_to_string_proxy_client(functionId);
194 return call_to_string_proxy_server(functionId);
198 static const char* call_to_string_stub(BOOL client, UINT32 interfaceNr, UINT32 functionId)
200 return "QUERY_DEVICE_TEXT_RSP [stub |client]";
203 const char* call_to_string(BOOL client, UINT32 interfaceNr, UINT32 functionId)
205 const UINT32 mask = (interfaceNr & STREAM_ID_MASK) >> 30;
206 const UINT32 interfaceId = interfaceNr & INTERFACE_ID_MASK;
211 return call_to_string_none(client, interfaceId, functionId);
213 case STREAM_ID_PROXY:
214 return call_to_string_proxy(client, interfaceId, functionId);
217 return call_to_string_stub(client, interfaceId, functionId);
220 return "UNKNOWN[mask]";
224 const char* urb_function_string(UINT16 urb)
228 case TS_URB_SELECT_CONFIGURATION:
229 return "TS_URB_SELECT_CONFIGURATION";
231 case TS_URB_SELECT_INTERFACE:
232 return "TS_URB_SELECT_INTERFACE";
234 case TS_URB_PIPE_REQUEST:
235 return "TS_URB_PIPE_REQUEST";
237 case TS_URB_TAKE_FRAME_LENGTH_CONTROL:
238 return "TS_URB_TAKE_FRAME_LENGTH_CONTROL";
240 case TS_URB_RELEASE_FRAME_LENGTH_CONTROL:
241 return "TS_URB_RELEASE_FRAME_LENGTH_CONTROL";
243 case TS_URB_GET_FRAME_LENGTH:
244 return "TS_URB_GET_FRAME_LENGTH";
246 case TS_URB_SET_FRAME_LENGTH:
247 return "TS_URB_SET_FRAME_LENGTH";
249 case TS_URB_GET_CURRENT_FRAME_NUMBER:
250 return "TS_URB_GET_CURRENT_FRAME_NUMBER";
252 case TS_URB_CONTROL_TRANSFER:
253 return "TS_URB_CONTROL_TRANSFER";
255 case TS_URB_BULK_OR_INTERRUPT_TRANSFER:
256 return "TS_URB_BULK_OR_INTERRUPT_TRANSFER";
258 case TS_URB_ISOCH_TRANSFER:
259 return "TS_URB_ISOCH_TRANSFER";
261 case TS_URB_GET_DESCRIPTOR_FROM_DEVICE:
262 return "TS_URB_GET_DESCRIPTOR_FROM_DEVICE";
264 case TS_URB_SET_DESCRIPTOR_TO_DEVICE:
265 return "TS_URB_SET_DESCRIPTOR_TO_DEVICE";
267 case TS_URB_SET_FEATURE_TO_DEVICE:
268 return "TS_URB_SET_FEATURE_TO_DEVICE";
270 case TS_URB_SET_FEATURE_TO_INTERFACE:
271 return "TS_URB_SET_FEATURE_TO_INTERFACE";
273 case TS_URB_SET_FEATURE_TO_ENDPOINT:
274 return "TS_URB_SET_FEATURE_TO_ENDPOINT";
276 case TS_URB_CLEAR_FEATURE_TO_DEVICE:
277 return "TS_URB_CLEAR_FEATURE_TO_DEVICE";
279 case TS_URB_CLEAR_FEATURE_TO_INTERFACE:
280 return "TS_URB_CLEAR_FEATURE_TO_INTERFACE";
282 case TS_URB_CLEAR_FEATURE_TO_ENDPOINT:
283 return "TS_URB_CLEAR_FEATURE_TO_ENDPOINT";
285 case TS_URB_GET_STATUS_FROM_DEVICE:
286 return "TS_URB_GET_STATUS_FROM_DEVICE";
288 case TS_URB_GET_STATUS_FROM_INTERFACE:
289 return "TS_URB_GET_STATUS_FROM_INTERFACE";
291 case TS_URB_GET_STATUS_FROM_ENDPOINT:
292 return "TS_URB_GET_STATUS_FROM_ENDPOINT";
294 case TS_URB_RESERVED_0X0016:
295 return "TS_URB_RESERVED_0X0016";
297 case TS_URB_VENDOR_DEVICE:
298 return "TS_URB_VENDOR_DEVICE";
300 case TS_URB_VENDOR_INTERFACE:
301 return "TS_URB_VENDOR_INTERFACE";
303 case TS_URB_VENDOR_ENDPOINT:
304 return "TS_URB_VENDOR_ENDPOINT";
306 case TS_URB_CLASS_DEVICE:
307 return "TS_URB_CLASS_DEVICE";
309 case TS_URB_CLASS_INTERFACE:
310 return "TS_URB_CLASS_INTERFACE";
312 case TS_URB_CLASS_ENDPOINT:
313 return "TS_URB_CLASS_ENDPOINT";
315 case TS_URB_RESERVE_0X001D:
316 return "TS_URB_RESERVE_0X001D";
318 case TS_URB_SYNC_RESET_PIPE_AND_CLEAR_STALL:
319 return "TS_URB_SYNC_RESET_PIPE_AND_CLEAR_STALL";
321 case TS_URB_CLASS_OTHER:
322 return "TS_URB_CLASS_OTHER";
324 case TS_URB_VENDOR_OTHER:
325 return "TS_URB_VENDOR_OTHER";
327 case TS_URB_GET_STATUS_FROM_OTHER:
328 return "TS_URB_GET_STATUS_FROM_OTHER";
330 case TS_URB_CLEAR_FEATURE_TO_OTHER:
331 return "TS_URB_CLEAR_FEATURE_TO_OTHER";
333 case TS_URB_SET_FEATURE_TO_OTHER:
334 return "TS_URB_SET_FEATURE_TO_OTHER";
336 case TS_URB_GET_DESCRIPTOR_FROM_ENDPOINT:
337 return "TS_URB_GET_DESCRIPTOR_FROM_ENDPOINT";
339 case TS_URB_SET_DESCRIPTOR_TO_ENDPOINT:
340 return "TS_URB_SET_DESCRIPTOR_TO_ENDPOINT";
342 case TS_URB_CONTROL_GET_CONFIGURATION_REQUEST:
343 return "TS_URB_CONTROL_GET_CONFIGURATION_REQUEST";
345 case TS_URB_CONTROL_GET_INTERFACE_REQUEST:
346 return "TS_URB_CONTROL_GET_INTERFACE_REQUEST";
348 case TS_URB_GET_DESCRIPTOR_FROM_INTERFACE:
349 return "TS_URB_GET_DESCRIPTOR_FROM_INTERFACE";
351 case TS_URB_SET_DESCRIPTOR_TO_INTERFACE:
352 return "TS_URB_SET_DESCRIPTOR_TO_INTERFACE";
354 case TS_URB_GET_OS_FEATURE_DESCRIPTOR_REQUEST:
355 return "TS_URB_GET_OS_FEATURE_DESCRIPTOR_REQUEST";
357 case TS_URB_RESERVE_0X002B:
358 return "TS_URB_RESERVE_0X002B";
360 case TS_URB_RESERVE_0X002C:
361 return "TS_URB_RESERVE_0X002C";
363 case TS_URB_RESERVE_0X002D:
364 return "TS_URB_RESERVE_0X002D";
366 case TS_URB_RESERVE_0X002E:
367 return "TS_URB_RESERVE_0X002E";
369 case TS_URB_RESERVE_0X002F:
370 return "TS_URB_RESERVE_0X002F";
372 case TS_URB_SYNC_RESET_PIPE:
373 return "TS_URB_SYNC_RESET_PIPE";
375 case TS_URB_SYNC_CLEAR_STALL:
376 return "TS_URB_SYNC_CLEAR_STALL";
378 case TS_URB_CONTROL_TRANSFER_EX:
379 return "TS_URB_CONTROL_TRANSFER_EX";
386 void urbdrc_dump_message(wLog* log, BOOL client, BOOL write,
wStream* s)
388 const char* type = write ?
"WRITE" :
"READ";
389 UINT32 InterfaceId = 0;
390 UINT32 MessageId = 0;
391 UINT32 FunctionId = 0;
395 pos = Stream_GetPosition(s);
399 Stream_SetPosition(s, 0);
402 length = Stream_GetRemainingLength(s);
407 Stream_Read_UINT32(s, InterfaceId);
408 Stream_Read_UINT32(s, MessageId);
409 Stream_Read_UINT32(s, FunctionId);
410 Stream_SetPosition(s, pos);
412 WLog_Print(log, WLOG_DEBUG,
413 "[%-5s] %s [%08" PRIx32
"] InterfaceId=%08" PRIx32
", MessageId=%08" PRIx32
414 ", FunctionId=%08" PRIx32
", length=%" PRIuz,
415 type, call_to_string(client, InterfaceId, FunctionId), FunctionId, InterfaceId,
416 MessageId, FunctionId, length);
417 #if defined(WITH_DEBUG_URBDRC)
419 WLog_Print(log, WLOG_TRACE,
"-------------------------- URBDRC sent: ---");
421 WLog_Print(log, WLOG_TRACE,
"-------------------------- URBDRC received:");
422 winpr_HexLogDump(log, WLOG_TRACE, Stream_Buffer(s), length);
423 WLog_Print(log, WLOG_TRACE,
"-------------------------- URBDRC end -----");