4 * By Paolo Abeni <paolo.abeni@email.it>
7 * http://www.usb.org/developers/docs/usb_20_122909-2.zip
9 * https://github.com/torvalds/linux/blob/master/Documentation/usb/usbmon.rst
11 * http://desowin.org/usbpcap/captureformat.html
13 * SPDX-License-Identifier: GPL-2.0-or-later
19 #include <epan/packet.h>
20 #include <epan/exceptions.h>
21 #include <epan/addr_resolv.h>
22 #include <epan/address_types.h>
23 #include <epan/conversation_table.h>
24 #include <epan/expert.h>
25 #include <epan/prefs.h>
26 #include <epan/decode_as.h>
27 #include <epan/proto_data.h>
28 #include <epan/unit_strings.h>
29 #include <wsutil/pint.h>
30 #include <wsutil/ws_roundup.h>
32 #include "packet-usb.h"
33 #include "packet-mausb.h"
34 #include "packet-usbip.h"
35 #include "packet-netmon.h"
37 /* dissector handles */
38 static dissector_handle_t linux_usb_handle
;
39 static dissector_handle_t linux_usb_mmapped_handle
;
40 static dissector_handle_t win32_usb_handle
;
41 static dissector_handle_t freebsd_usb_handle
;
42 static dissector_handle_t darwin_usb_handle
;
43 static dissector_handle_t netmon_usb_port_handle
;
45 /* protocols and header fields */
47 static int proto_usbport
;
49 /* USB pseudoheader fields, both FreeBSD and Linux */
50 static int hf_usb_totlen
;
51 static int hf_usb_busunit
;
52 static int hf_usb_address
;
53 static int hf_usb_mode
;
54 static int hf_usb_freebsd_urb_type
;
55 static int hf_usb_freebsd_transfer_type
;
56 static int hf_usb_xferflags
;
57 static int hf_usb_xferflags_force_short_xfer
;
58 static int hf_usb_xferflags_short_xfer_ok
;
59 static int hf_usb_xferflags_short_frames_ok
;
60 static int hf_usb_xferflags_pipe_bof
;
61 static int hf_usb_xferflags_proxy_buffer
;
62 static int hf_usb_xferflags_ext_buffer
;
63 static int hf_usb_xferflags_manual_status
;
64 static int hf_usb_xferflags_no_pipe_ok
;
65 static int hf_usb_xferflags_stall_pipe
;
66 static int hf_usb_xferstatus
;
67 static int hf_usb_xferstatus_open
;
68 static int hf_usb_xferstatus_transferring
;
69 static int hf_usb_xferstatus_did_dma_delay
;
70 static int hf_usb_xferstatus_did_close
;
71 static int hf_usb_xferstatus_draining
;
72 static int hf_usb_xferstatus_started
;
73 static int hf_usb_xferstatus_bw_reclaimed
;
74 static int hf_usb_xferstatus_control_xfr
;
75 static int hf_usb_xferstatus_control_hdr
;
76 static int hf_usb_xferstatus_control_act
;
77 static int hf_usb_xferstatus_control_stall
;
78 static int hf_usb_xferstatus_short_frames_ok
;
79 static int hf_usb_xferstatus_short_xfer_ok
;
80 static int hf_usb_xferstatus_bdma_enable
;
81 static int hf_usb_xferstatus_bdma_no_post_sync
;
82 static int hf_usb_xferstatus_bdma_setup
;
83 static int hf_usb_xferstatus_isochronous_xfr
;
84 static int hf_usb_xferstatus_curr_dma_set
;
85 static int hf_usb_xferstatus_can_cancel_immed
;
86 static int hf_usb_xferstatus_doing_callback
;
87 static int hf_usb_error
;
88 static int hf_usb_interval
;
89 static int hf_usb_nframes
;
90 static int hf_usb_packet_size
;
91 static int hf_usb_packet_count
;
92 static int hf_usb_speed
;
93 static int hf_usb_frame_length
;
94 static int hf_usb_frame_flags
;
95 static int hf_usb_frame_flags_read
;
96 static int hf_usb_frame_flags_data_follows
;
97 static int hf_usb_frame_data
;
98 static int hf_usb_urb_id
;
99 static int hf_usb_linux_urb_type
;
100 static int hf_usb_linux_transfer_type
;
101 static int hf_usb_endpoint_address
;
102 static int hf_usb_endpoint_direction
;
103 static int hf_usb_endpoint_number
;
104 static int hf_usb_device_address
;
105 static int hf_usb_bus_id
;
106 static int hf_usb_setup_flag
;
107 static int hf_usb_data_flag
;
108 static int hf_usb_urb_ts_sec
;
109 static int hf_usb_urb_ts_usec
;
110 static int hf_usb_urb_status
;
111 static int hf_usb_urb_len
;
112 static int hf_usb_urb_data_len
;
113 static int hf_usb_urb_unused_setup_header
;
114 static int hf_usb_urb_interval
;
115 static int hf_usb_urb_start_frame
;
116 static int hf_usb_urb_copy_of_transfer_flags
;
119 static int hf_short_not_ok
;
120 static int hf_iso_asap
;
121 static int hf_no_transfer_dma_map
;
122 static int hf_no_fsbr
;
123 static int hf_zero_packet
;
124 static int hf_no_interrupt
;
125 static int hf_free_buffer
;
126 static int hf_dir_in
;
127 static int hf_dma_map_single
;
128 static int hf_dma_map_page
;
129 static int hf_dma_map_sg
;
130 static int hf_map_local
;
131 static int hf_setup_map_single
;
132 static int hf_setup_map_local
;
133 static int hf_dma_sg_combined
;
134 static int hf_aligned_temp_buffer
;
136 static int * const transfer_flags_fields
[] = {
139 &hf_no_transfer_dma_map
,
149 &hf_setup_map_single
,
152 &hf_aligned_temp_buffer
,
156 /* Win32 USBPcap pseudoheader fields */
157 static int hf_usb_win32_header_len
;
158 static int hf_usb_irp_id
;
159 static int hf_usb_usbd_status
;
160 static int hf_usb_function
;
161 static int hf_usb_info
;
162 static int hf_usb_usbpcap_info_reserved
;
163 static int hf_usb_usbpcap_info_direction
;
164 static int hf_usb_win32_device_address
;
165 static int hf_usb_win32_transfer_type
;
166 /* hf_usb_bus_id, hf_usb_endpoint_address, hf_usb_endpoint_direction,
167 * hf_usb_endpoint_number are common with
168 * FreeBSD and Linux pseudoheaders */
169 static int hf_usb_win32_data_len
;
170 static int hf_usb_win32_control_stage
;
171 static int hf_usb_win32_iso_start_frame
;
172 static int hf_usb_win32_iso_num_packets
;
173 static int hf_usb_win32_iso_error_count
;
174 static int hf_usb_win32_iso_offset
;
175 static int hf_usb_win32_iso_length
;
176 static int hf_usb_win32_iso_status
;
178 static int hf_usb_request
;
179 static int hf_usb_request_unknown_class
;
180 static int hf_usb_value
;
181 static int hf_usb_index
;
182 static int hf_usb_length
;
183 /* static int hf_usb_data_len; */
184 static int hf_usb_capdata
;
185 static int hf_usb_device_wFeatureSelector
;
186 static int hf_usb_interface_wFeatureSelector
;
187 static int hf_usb_endpoint_wFeatureSelector
;
188 static int hf_usb_wInterface
;
189 static int hf_usb_wEndpoint
;
190 static int hf_usb_wStatus
;
191 static int hf_usb_wFrameNumber
;
193 static int hf_usb_iso_error_count
;
194 static int hf_usb_iso_numdesc
;
195 static int hf_usb_iso_status
;
196 static int hf_usb_iso_off
;
197 static int hf_usb_iso_len
;
198 static int hf_usb_iso_actual_len
;
199 static int hf_usb_iso_pad
;
200 static int hf_usb_iso_data
;
202 static int hf_usb_bmRequestType
;
203 static int hf_usb_control_response_generic
;
204 static int hf_usb_bmRequestType_direction
;
205 static int hf_usb_bmRequestType_type
;
206 static int hf_usb_bmRequestType_recipient
;
207 static int hf_usb_bDescriptorType
;
208 static int hf_usb_get_descriptor_resp_generic
;
209 static int hf_usb_descriptor_index
;
210 static int hf_usb_language_id
;
211 static int hf_usb_bLength
;
212 static int hf_usb_bcdUSB
;
213 static int hf_usb_bDeviceClass
;
214 static int hf_usb_bDeviceSubClass
;
215 static int hf_usb_bDeviceProtocol
;
216 static int hf_usb_bMaxPacketSize0
;
217 static int hf_usb_idVendor
;
218 static int hf_usb_idProduct
;
219 static int hf_usb_bcdDevice
;
220 static int hf_usb_iManufacturer
;
221 static int hf_usb_iProduct
;
222 static int hf_usb_iSerialNumber
;
223 static int hf_usb_bNumConfigurations
;
224 static int hf_usb_wLANGID
;
225 static int hf_usb_bString
;
226 static int hf_usb_bInterfaceNumber
;
227 static int hf_usb_bAlternateSetting
;
228 static int hf_usb_bNumEndpoints
;
229 static int hf_usb_bInterfaceClass
;
230 static int hf_usb_bInterfaceSubClass
;
231 static int hf_usb_bInterfaceSubClass_audio
;
232 static int hf_usb_bInterfaceSubClass_cdc
;
233 static int hf_usb_bInterfaceSubClass_massstorage
;
234 static int hf_usb_bInterfaceSubClass_hid
;
235 static int hf_usb_bInterfaceSubClass_misc
;
236 static int hf_usb_bInterfaceSubClass_app
;
237 static int hf_usb_bInterfaceProtocol
;
238 static int hf_usb_bInterfaceProtocol_cdc
;
239 static int hf_usb_bInterfaceProtocol_massstorage
;
240 static int hf_usb_bInterfaceProtocol_cdc_data
;
241 static int hf_usb_bInterfaceProtocol_hid_boot
;
242 static int hf_usb_bInterfaceProtocol_app_dfu
;
243 static int hf_usb_bInterfaceProtocol_app_irda
;
244 static int hf_usb_bInterfaceProtocol_app_usb_test_and_measurement
;
245 static int hf_usb_iInterface
;
246 static int hf_usb_bEndpointAddress
;
247 static int hf_usb_bmAttributes
;
248 static int hf_usb_bEndpointAttributeTransfer
;
249 static int hf_usb_bEndpointAttributeSynchonisation
;
250 static int hf_usb_bEndpointAttributeBehaviour
;
251 static int hf_usb_wMaxPacketSize
;
252 static int hf_usb_wMaxPacketSize_size
;
253 static int hf_usb_wMaxPacketSize_slots
;
254 static int hf_usb_bInterval
;
255 static int hf_usb_bMaxBurst
;
256 static int hf_usb_audio_bRefresh
;
257 static int hf_usb_audio_bSynchAddress
;
258 static int hf_usb_bSSEndpointAttributeBulkMaxStreams
;
259 static int hf_usb_bSSEndpointAttributeIsoMult
;
260 static int hf_usb_wBytesPerInterval
;
261 static int hf_usb_wTotalLength
;
262 static int hf_usb_bNumInterfaces
;
263 static int hf_usb_bConfigurationValue
;
264 static int hf_usb_iConfiguration
;
265 static int hf_usb_bMaxPower
;
266 static int hf_usb_configuration_bmAttributes
;
267 static int hf_usb_configuration_legacy10buspowered
;
268 static int hf_usb_configuration_selfpowered
;
269 static int hf_usb_configuration_remotewakeup
;
270 static int hf_usb_bEndpointAddress_direction
;
271 static int hf_usb_bEndpointAddress_number
;
272 static int hf_usb_response_in
;
273 static int hf_usb_time
;
274 static int hf_usb_request_in
;
275 static int hf_usb_bFirstInterface
;
276 static int hf_usb_bInterfaceCount
;
277 static int hf_usb_bFunctionClass
;
278 static int hf_usb_bFunctionSubClass
;
279 static int hf_usb_bFunctionProtocol
;
280 static int hf_usb_iFunction
;
281 static int hf_usb_bNumDeviceCaps
;
282 static int hf_usb_bDevCapabilityType
;
283 static int hf_usb_usb20ext_bmAttributes
;
284 static int hf_usb_usb20ext_LPM
;
285 static int hf_usb_usb20ext_BESL_HIRD
;
286 static int hf_usb_usb20ext_baseline_BESL_valid
;
287 static int hf_usb_usb20ext_deep_BESL_valid
;
288 static int hf_usb_usb20ext_baseline_BESL
;
289 static int hf_usb_usb20ext_deep_BESL
;
290 static int hf_usb_bReserved
;
291 static int hf_usb_PlatformCapabilityUUID
;
292 static int hf_usb_webusb_bcdVersion
;
293 static int hf_usb_webusb_bVendorCode
;
294 static int hf_usb_webusb_iLandingPage
;
295 static int hf_usb_msos20_dwWindowsVersion
;
296 static int hf_usb_msos20_wMSOSDescriptorSetTotalLength
;
297 static int hf_usb_msos20_bMS_VendorCode
;
298 static int hf_usb_msos20_bAltEnumCode
;
299 static int hf_usb_data_fragment
;
300 static int hf_usb_src
;
301 static int hf_usb_dst
;
302 static int hf_usb_addr
;
303 static int hf_usb_ss_bmAttributes
;
304 static int hf_usb_ss_bmAttributes_reserved0
;
305 static int hf_usb_ss_bmAttributes_LTM
;
306 static int hf_usb_ss_bmAttributes_reserved7_2
;
307 static int hf_usb_ss_wSpeedSupported
;
308 static int hf_usb_ss_wSpeedSupported_LS
;
309 static int hf_usb_ss_wSpeedSupported_FS
;
310 static int hf_usb_ss_wSpeedSupported_HS
;
311 static int hf_usb_ss_wSpeedSupported_Gen1
;
312 static int hf_usb_ss_wSpeedSupported_reserved
;
313 static int hf_usb_ss_bFunctionalitySupport
;
314 static int hf_usb_ss_bU1DevExitLat
;
315 static int hf_usb_ss_wU2DevExitLat
;
318 static int hf_usb_darwin_bcd_version
;
319 static int hf_usb_darwin_header_len
;
320 static int hf_usb_darwin_request_type
;
321 static int hf_usb_darwin_io_len
;
322 static int hf_usb_darwin_io_status
;
323 static int hf_usb_darwin_iso_num_packets
;
324 static int hf_usb_darwin_io_id
;
325 static int hf_usb_darwin_device_location
;
326 static int hf_usb_darwin_speed
;
327 static int hf_usb_darwin_device_address
;
328 static int hf_usb_darwin_endpoint_address
;
329 static int hf_usb_darwin_endpoint_type
;
330 static int hf_usb_darwin_iso_status
;
331 static int hf_usb_darwin_iso_frame_number
;
332 static int hf_usb_darwin_iso_timestamp
;
335 static int hf_usbport_event_id
;
336 static int hf_usbport_device_object
;
337 static int hf_usbport_pci_bus
;
338 static int hf_usbport_pci_device
;
339 static int hf_usbport_pci_function
;
340 static int hf_usbport_pci_vendor_id
;
341 static int hf_usbport_pci_device_id
;
342 static int hf_usbport_port_path_depth
;
343 static int hf_usbport_port_path0
;
344 static int hf_usbport_port_path1
;
345 static int hf_usbport_port_path2
;
346 static int hf_usbport_port_path3
;
347 static int hf_usbport_port_path4
;
348 static int hf_usbport_port_path5
;
349 static int hf_usbport_device_handle
;
350 static int hf_usbport_device_speed
;
351 static int hf_usbport_endpoint
;
352 static int hf_usbport_pipehandle
;
353 static int hf_usbport_endpoint_desc_length
;
354 static int hf_usbport_endpoint_desc_type
;
355 static int hf_usbport_endpoint_address
;
356 static int hf_usbport_bm_attributes
;
357 static int hf_usbport_max_packet_size
;
358 static int hf_usbport_interval
;
359 static int hf_usbport_irp
;
360 static int hf_usbport_urb
;
361 static int hf_usbport_urb_transfer_data
;
362 static int hf_usbport_urb_header_length
;
363 static int hf_usbport_urb_header_function
;
364 static int hf_usbport_urb_header_status
;
365 static int hf_usbport_urb_header_usbddevice_handle
;
366 static int hf_usbport_urb_header_usbdflags
;
367 static int hf_usbport_urb_configuration_desc
;
368 static int hf_usbport_urb_configuration_handle
;
369 static int hf_usbport_urb_pipe_handle
;
370 static int hf_usbport_urb_xferflags
;
371 static int hf_usbport_urb_transfer_buffer_length
;
372 static int hf_usbport_urb_transfer_buffer
;
373 static int hf_usbport_urb_transfer_buffer_mdl
;
374 static int hf_usbport_urb_reserved_mbz
;
375 static int hf_usbport_urb_reserved_hcd
;
376 static int hf_usbport_urb_reserved
;
377 static int hf_usbport_keyword
;
378 static int hf_usbport_keyword_diagnostic
;
379 static int hf_usbport_keyword_power_diagnostics
;
380 static int hf_usbport_keyword_perf_diagnostics
;
381 static int hf_usbport_keyword_reserved1
;
383 static int ett_usb_hdr
;
384 static int ett_usb_setup_hdr
;
385 static int ett_usb_isodesc
;
386 static int ett_usb_win32_iso_packet
;
387 static int ett_usb_endpoint
;
388 static int ett_usb_setup_bmrequesttype
;
389 static int ett_usb_usbpcap_info
;
390 static int ett_descriptor_device
;
391 static int ett_configuration_bmAttributes
;
392 static int ett_configuration_bEndpointAddress
;
393 static int ett_endpoint_bmAttributes
;
394 static int ett_endpoint_wMaxPacketSize
;
395 static int ett_usb_xferflags
;
396 static int ett_usb_xferstatus
;
397 static int ett_usb_frame
;
398 static int ett_usb_frame_flags
;
399 static int ett_usbport
;
400 static int ett_usbport_host_controller
;
401 static int ett_usbport_path
;
402 static int ett_usbport_device
;
403 static int ett_usbport_endpoint
;
404 static int ett_usbport_endpoint_desc
;
405 static int ett_usbport_urb
;
406 static int ett_usbport_keyword
;
407 static int ett_transfer_flags
;
408 static int ett_usb20ext_bmAttributes
;
409 static int ett_ss_bmAttributes
;
410 static int ett_ss_wSpeedSupported
;
412 static expert_field ei_usb_undecoded
;
413 static expert_field ei_usb_bLength_even
;
414 static expert_field ei_usb_bLength_too_short
;
415 static expert_field ei_usb_desc_length_invalid
;
416 static expert_field ei_usb_invalid_setup
;
417 static expert_field ei_usb_ss_ep_companion_before_ep
;
418 static expert_field ei_usb_usbpcap_unknown_urb
;
419 static expert_field ei_usb_bad_length
;
420 static expert_field ei_usb_invalid_max_packet_size
;
421 static expert_field ei_usb_invalid_max_packet_size0
;
422 static expert_field ei_usb_invalid_endpoint_type
;
423 static expert_field ei_usb_unexpected_desc_type
;
425 static expert_field ei_usbport_invalid_path_depth
;
427 static int usb_address_type
= -1;
429 static int * const usb_endpoint_fields
[] = {
430 &hf_usb_endpoint_direction
,
431 &hf_usb_endpoint_number
,
435 static int * const usb_usbpcap_info_fields
[] = {
436 &hf_usb_usbpcap_info_reserved
,
437 &hf_usb_usbpcap_info_direction
,
442 static bool try_heuristics
= true;
444 static dissector_table_t usb_bulk_dissector_table
;
445 static dissector_table_t usb_control_dissector_table
;
446 static dissector_table_t usb_interrupt_dissector_table
;
447 static dissector_table_t usb_descriptor_dissector_table
;
449 static heur_dissector_list_t heur_bulk_subdissector_list
;
450 static heur_dissector_list_t heur_control_subdissector_list
;
451 static heur_dissector_list_t heur_interrupt_subdissector_list
;
453 static wmem_tree_t
*device_to_protocol_table
;
454 static wmem_tree_t
*device_to_product_table
;
455 static wmem_tree_t
*usbpcap_setup_data
;
457 static dissector_table_t device_to_dissector
;
458 static dissector_table_t protocol_to_dissector
;
459 static dissector_table_t product_to_dissector
;
461 typedef struct _device_product_data_t
{
466 unsigned device_address
;
467 } device_product_data_t
;
469 typedef struct _device_protocol_data_t
{
472 unsigned device_address
;
473 } device_protocol_data_t
;
475 typedef struct _usb_alt_setting_t
{
477 uint8_t interfaceClass
;
478 uint8_t interfaceSubclass
;
479 uint8_t interfaceProtocol
;
480 uint8_t interfaceNum
;
485 uint8_t setup_data
[8];
486 } usbpcap_setup_data_t
;
488 static const value_string usb_speed_vals
[] = {
489 {USB_SPEED_UNKNOWN
, "Unknown Speed"},
490 {USB_SPEED_LOW
, "Low-Speed"},
491 {USB_SPEED_FULL
, "Full-Speed"},
492 {USB_SPEED_HIGH
, "High-Speed"},
496 /* http://www.usb.org/developers/docs/USB_LANGIDs.pdf */
497 static const value_string usb_langid_vals
[] = {
498 {0x0000, "no language specified"},
499 {0x0401, "Arabic (Saudi Arabia)"},
500 {0x0402, "Bulgarian"},
502 {0x0404, "Chinese (Taiwan)"},
505 {0x0407, "German (Standard)"},
507 {0x0409, "English (United States)"},
508 {0x040a, "Spanish (Traditional Sort)"},
510 {0x040c, "French (Standard)"},
512 {0x040e, "Hungarian"},
513 {0x040f, "Icelandic"},
514 {0x0410, "Italian (Standard)"},
515 {0x0411, "Japanese"},
517 {0x0413, "Dutch (Netherlands)"},
518 {0x0414, "Norwegian (Bokmal)"},
520 {0x0416, "Portuguese (Brazil)"},
521 {0x0418, "Romanian"},
523 {0x041a, "Croatian"},
525 {0x041c, "Albanian"},
529 {0x0420, "Urdu (Pakistan)"},
530 {0x0421, "Indonesian"},
531 {0x0422, "Ukrainian"},
532 {0x0423, "Belarussian"},
533 {0x0424, "Slovenian"},
534 {0x0425, "Estonian"},
536 {0x0427, "Lithuanian"},
538 {0x042a, "Vietnamese"},
539 {0x042b, "Armenian"},
540 {0x042c, "Azeri (Latin)"},
542 {0x042f, "Macedonian"},
544 {0x0436, "Afrikaans"},
545 {0x0437, "Georgian"},
546 {0x0438, "Faeroese"},
548 {0x043e, "Malay (Malaysian)"},
550 {0x0441, "Swahili (Kenya)"},
551 {0x0443, "Uzbek (Latin)"},
552 {0x0444, "Tatar (Tatarstan)"},
555 {0x0447, "Gujarati"},
560 {0x044c, "Malayalam"},
561 {0x044d, "Assamese"},
563 {0x044f, "Sanskrit"},
566 {0x0458, "Manipuri"},
568 {0x04ff, "HID (Usage Data Descriptor)"},
569 {0x0801, "Arabic (Iraq)"},
570 {0x0804, "Chinese (PRC)"},
571 {0x0807, "German (Switzerland)"},
572 {0x0809, "English (United Kingdom)"},
573 {0x080a, "Spanish (Mexican)"},
574 {0x080c, "French (Belgian)"},
575 {0x0810, "Italian (Switzerland)"},
576 {0x0812, "Korean (Johab)"},
577 {0x0813, "Dutch (Belgium)"},
578 {0x0814, "Norwegian (Nynorsk)"},
579 {0x0816, "Portuguese (Standard)"},
580 {0x081a, "Serbian (Latin)"},
581 {0x081d, "Swedish (Finland)"},
582 {0x0820, "Urdu (India)"},
583 {0x0827, "Lithuanian (Classic)"},
584 {0x082c, "Azeri (Cyrillic)"},
585 {0x083e, "Malay (Brunei Darussalam)"},
586 {0x0843, "Uzbek (Cyrillic)"},
587 {0x0860, "Kashmiri (India)"},
588 {0x0861, "Nepali (India)"},
589 {0x0c01, "Arabic (Egypt)"},
590 {0x0c04, "Chinese (Hong Kong SAR, PRC)"},
591 {0x0c07, "German (Austria)"},
592 {0x0c09, "English (Australian)"},
593 {0x0c0a, "Spanish (Modern Sort)"},
594 {0x0c0c, "French (Canadian)"},
595 {0x0c1a, "Serbian (Cyrillic)"},
596 {0x1001, "Arabic (Libya)"},
597 {0x1004, "Chinese (Singapore)"},
598 {0x1007, "German (Luxembourg)"},
599 {0x1009, "English (Canadian)"},
600 {0x100a, "Spanish (Guatemala)"},
601 {0x100c, "French (Switzerland)"},
602 {0x1401, "Arabic (Algeria)"},
603 {0x1404, "Chinese (Macau SAR)"},
604 {0x1407, "German (Liechtenstein)"},
605 {0x1409, "English (New Zealand)"},
606 {0x140a, "Spanish (Costa Rica)"},
607 {0x140c, "French (Luxembourg)"},
608 {0x1801, "Arabic (Morocco)"},
609 {0x1809, "English (Ireland)"},
610 {0x180a, "Spanish (Panama)"},
611 {0x180c, "French (Monaco)"},
612 {0x1c01, "Arabic (Tunisia)"},
613 {0x1c09, "English (South Africa)"},
614 {0x1c0a, "Spanish (Dominican Republic)"},
615 {0x2001, "Arabic (Oman)"},
616 {0x2009, "English (Jamaica)"},
617 {0x200a, "Spanish (Venezuela)"},
618 {0x2401, "Arabic (Yemen)"},
619 {0x2409, "English (Caribbean)"},
620 {0x240a, "Spanish (Colombia)"},
621 {0x2801, "Arabic (Syria)"},
622 {0x2809, "English (Belize)"},
623 {0x280a, "Spanish (Peru)"},
624 {0x2c01, "Arabic (Jordan)"},
625 {0x2c09, "English (Trinidad)"},
626 {0x2c0a, "Spanish (Argentina)"},
627 {0x3001, "Arabic (Lebanon)"},
628 {0x3009, "English (Zimbabwe)"},
629 {0x300a, "Spanish (Ecuador)"},
630 {0x3401, "Arabic (Kuwait)"},
631 {0x3409, "English (Philippines)"},
632 {0x340a, "Spanish (Chile)"},
633 {0x3801, "Arabic (U.A.E.)"},
634 {0x380a, "Spanish (Uruguay)"},
635 {0x3c01, "Arabic (Bahrain)"},
636 {0x3c0a, "Spanish (Paraguay)"},
637 {0x4001, "Arabic (Qatar)"},
638 {0x400a, "Spanish (Bolivia)"},
639 {0x440a, "Spanish (El Salvador)"},
640 {0x480a, "Spanish (Honduras)"},
641 {0x4c0a, "Spanish (Nicaragua)"},
642 {0x500a, "Spanish (Puerto Rico)"},
643 {0xf0ff, "HID (Vendor Defined 1)"},
644 {0xf4ff, "HID (Vendor Defined 2)"},
645 {0xf8ff, "HID (Vendor Defined 3)"},
646 {0xfcff, "HID (Vendor Defined 4)"},
649 value_string_ext usb_langid_vals_ext
= VALUE_STRING_EXT_INIT(usb_langid_vals
);
651 static const value_string usb_class_vals
[] = {
652 {IF_CLASS_DEVICE
, "Device"},
653 {IF_CLASS_AUDIO
, "Audio"},
654 {IF_CLASS_COMMUNICATIONS
, "Communications and CDC Control"},
655 {IF_CLASS_HID
, "HID"},
656 {IF_CLASS_PHYSICAL
, "Physical"},
657 {IF_CLASS_IMAGE
, "Imaging"},
658 {IF_CLASS_PRINTER
, "Printer"},
659 {IF_CLASS_MASS_STORAGE
, "Mass Storage"},
660 {IF_CLASS_HUB
, "Hub"},
661 {IF_CLASS_CDC_DATA
, "CDC-Data"},
662 {IF_CLASS_SMART_CARD
, "Smart Card"},
663 {IF_CLASS_CONTENT_SECURITY
, "Content Security"},
664 {IF_CLASS_VIDEO
, "Video"},
665 {IF_CLASS_PERSONAL_HEALTHCARE
, "Personal Healthcare"},
666 {IF_CLASS_AUDIO_VIDEO
, "Audio/Video Devices"},
667 {IF_CLASS_BILLBOARD
, "Billboard Device"},
668 {IF_CLASS_USB_C_BRIDGE
, "USB Type-C Bridge"},
669 {IF_CLASS_BULK_DISPLAY_PROTO
, "USB Bulk Display Protocol Device"},
670 {IF_CLASS_MCTP_USB_EP
, "MCTP over USB Protocol Endpoint Device"},
671 {IF_CLASS_I3C
, "I3C Device"},
672 {IF_CLASS_DIAGNOSTIC_DEVICE
, "Diagnostic Device"},
673 {IF_CLASS_WIRELESS_CONTROLLER
, "Wireless Controller"},
674 {IF_CLASS_MISCELLANEOUS
, "Miscellaneous"},
675 {IF_CLASS_APPLICATION_SPECIFIC
, "Application Specific"},
676 {IF_CLASS_VENDOR_SPECIFIC
, "Vendor Specific"},
679 value_string_ext usb_class_vals_ext
= VALUE_STRING_EXT_INIT(usb_class_vals
);
681 /* use usb class, subclass and protocol id together
682 http://www.usb.org/developers/defined_class
683 USB Class Definitions for Communications Devices, Revision 1.2 December 6, 2012
685 static const value_string usb_protocols
[] = {
686 {0x000000, "Use class code info from Interface Descriptors"},
687 {0x060101, "Still Imaging"},
688 {0x090000, "Full speed Hub"},
689 {0x090001, "Hi-speed hub with single TT"},
690 {0x090002, "Hi-speed hub with multiple TTs"},
691 {0x0D0000, "Content Security"},
692 {0x100100, "AVControl Interface"},
693 {0x100200, "AVData Video Streaming Interface"},
694 {0x100300, "AVData Audio Streaming Interface"},
695 {0x140001, "MCTP 1.x - MCTP Management-controller and Managed-Device endpoints"},
696 {0x140002, "MCTP 2.x - MCTP Management-controller and Managed-Device endpoints"},
697 {0x140101, "MCTP 1.x - MCTP Host Interface endpoint"},
698 {0x140102, "MCTP 2.x - MCTP Host Interface endpoint"},
699 {0xDC0101, "USB2 Compliance Device"},
700 {0xDC0200, "Debug Target vendor defined"},
701 {0xDC0201, "GNU Remote Debug Command Set"},
702 {0xDC0301, "Vendor defined Trace protocol on DbC"},
703 {0xDC0401, "Vendor defined Dfx protocol on DbC"},
704 {0xDC0500, "Vendor defined Trace protocol over General Purpose (GP) endpoint on DvC"},
705 {0xDC0501, "GNU Protocol protocol over General Purpose (GP) endpoint on DvC"},
706 {0xDC0601, "Vendor defined Dfx protocol on DvC"},
707 {0xDC0701, "Vendor defined Trace protocol on DvC"},
708 {0xE00101, "Bluetooth Programming Interface"},
709 {0xE00102, "UWB Radio Control Interface"},
710 {0xE00103, "Remote NDIS"},
711 {0xE00104, "Bluetooth AMP Controller"},
712 {0xE00201, "Host Wire Adapter Control/Data interface"},
713 {0xE00202, "Device Wire Adapter Control/Data interface"},
714 {0xE00203, "Device Wire Adapter Isochronous interface"},
715 {0xEF0101, "Active Sync device"},
716 {0xEF0102, "Palm Sync"},
717 {0xEF0201, "Interface Association Descriptor"},
718 {0xEF0202, "Wire Adapter Multifunction Peripheral programming interface"},
719 {0xEF0301, "Cable Based Association Framework"},
720 {0xEF0401, "RNDIS over Ethernet"},
721 {0xEF0402, "RNDIS over WiFi"},
722 {0xEF0403, "RNDIS over WiMAX"},
723 {0xEF0404, "RNDIS over WWAN"},
724 {0xEF0405, "RNDIS for Raw IPv4"},
725 {0xEF0406, "RNDIS for Raw IPv6"},
726 {0xEF0407, "RNDIS for GPRS"},
727 {0xEF0500, "USB3 Vision Control Interface"},
728 {0xEF0501, "USB3 Vision Event Interface"},
729 {0xEF0502, "USB3 Vision Streaming Interface"},
730 {0xEF0601, "Stream Transport Efficient Protocol for content protection"},
731 {0xEF0602, "Stream Transport Efficient Protocol for Raw content protection"},
732 {0xEF0700, "Command Interface in IAD"},
733 {0xEF0702, "Command Interface in Interface Descriptor"},
734 {0xEF0703, "Media Interface in Interface Descriptor"},
735 {0xFE0101, "Device Firmware Upgrade"},
736 {0xFE0200, "IRDA Bridge device"},
737 {0xFE0300, "USB Test and Measurement Device"},
738 {0xFE0301, "USB Test and Measurement Device conforming to the USBTMC USB488"},
741 static value_string_ext usb_protocols_ext
= VALUE_STRING_EXT_INIT(usb_protocols
);
743 /* BOS Descriptor Device Capability Type Codes
744 https://www.usb.org/bos-descriptor-types
746 #define BOS_CAP_WIRELESS_USB 0x01
747 #define BOS_CAP_USB_20_EXTENSION 0x02
748 #define BOS_CAP_SUPERSPEED_USB 0x03
749 #define BOS_CAP_CONTAINER_ID 0x04
750 #define BOS_CAP_PLATFORM 0x05
751 #define BOS_CAP_POWER_DELIVERY 0x06
752 #define BOS_CAP_BATTERY_INFO 0x07
753 #define BOS_CAP_PD_CONSUMER_PORT 0x08
754 #define BOS_CAP_PD_PROVIDER_PORT 0x09
755 #define BOS_CAP_SUPERSPEED_PLUS 0x0A
756 #define BOS_CAP_PRECISION_TIME_MEAS 0x0B
757 #define BOS_CAP_WIRELESS_USB_EXT 0x0C
758 #define BOS_CAP_BILLBOARD 0x0D
759 #define BOS_CAP_AUTHENTICATION 0x0E
760 #define BOS_CAP_BILLBOARD_EX 0x0F
761 #define BOS_CAP_CONFIGURATION_SUMMARY 0x10
762 #define BOS_CAP_FWSTATUS 0x11
763 #define BOS_CAP_USB3_GEN_T 0x13
764 static const value_string usb_capability_vals
[] = {
765 {BOS_CAP_WIRELESS_USB
, "Wireless USB"},
766 {BOS_CAP_USB_20_EXTENSION
, "USB 2.0 Extension Descriptor"},
767 {BOS_CAP_SUPERSPEED_USB
, "SuperSpeed USB"},
768 {BOS_CAP_CONTAINER_ID
, "Container ID"},
769 {BOS_CAP_PLATFORM
, "Platform"},
770 {BOS_CAP_POWER_DELIVERY
, "Power Delivery Capability"},
771 {BOS_CAP_BATTERY_INFO
, "Battery Info Capability"},
772 {BOS_CAP_PD_CONSUMER_PORT
, "PD Consumer Port Capability"},
773 {BOS_CAP_PD_PROVIDER_PORT
, "PD Provider Port Capability"},
774 {BOS_CAP_SUPERSPEED_PLUS
, "SuperSpeed Plus"},
775 {BOS_CAP_PRECISION_TIME_MEAS
, "Precision Time Measurement"},
776 {BOS_CAP_WIRELESS_USB_EXT
, "Wireless USB Ext"},
777 {BOS_CAP_BILLBOARD
, "Billboard Capability"},
778 {BOS_CAP_AUTHENTICATION
, "Authentication Capability Descriptor"},
779 {BOS_CAP_BILLBOARD_EX
, "Billboard Ex capability"},
780 {BOS_CAP_CONFIGURATION_SUMMARY
, "Configuration Summary"},
781 {BOS_CAP_FWSTATUS
, "Firmware Status"},
782 {0x12, "TBD (reserved for USB Audio 4.0)"},
783 {BOS_CAP_USB3_GEN_T
, "USB 3 Gen T Capability"},
784 {0x14, "TBD (reserved for USB PD)"},
787 static value_string_ext usb_capability_vals_ext
= VALUE_STRING_EXT_INIT(usb_capability_vals
);
789 #define SS_SPEED_SUPPORTED_BIT_LS 0
790 #define SS_SPEED_SUPPORTED_BIT_FS 1
791 #define SS_SPEED_SUPPORTED_BIT_HS 2
792 #define SS_SPEED_SUPPORTED_BIT_GEN1 3
793 #define SS_SPEED_SUPPORTED_STR_LS "low-speed"
794 #define SS_SPEED_SUPPORTED_STR_FS "full-speed"
795 #define SS_SPEED_SUPPORTED_STR_HS "high-speed"
796 #define SS_SPEED_SUPPORTED_STR_GEN1 "Gen 1 speed"
797 static const value_string usb_ss_bFunctionalitySupport_vals
[] = {
798 {SS_SPEED_SUPPORTED_BIT_LS
, SS_SPEED_SUPPORTED_STR_LS
},
799 {SS_SPEED_SUPPORTED_BIT_FS
, SS_SPEED_SUPPORTED_STR_FS
},
800 {SS_SPEED_SUPPORTED_BIT_HS
, SS_SPEED_SUPPORTED_STR_HS
},
801 {SS_SPEED_SUPPORTED_BIT_GEN1
, SS_SPEED_SUPPORTED_STR_GEN1
},
804 static value_string_ext usb_ss_bFunctionalitySupport_vals_ext
=
805 VALUE_STRING_EXT_INIT(usb_ss_bFunctionalitySupport_vals
);
806 static const true_false_string tfs_usb_ss_bmAttributes_reserved0
= {
807 "FIXME: Shall be set to zero",
808 "Shall be set to zero"
814 #define FREEBSD_MODE_HOST 0
815 #define FREEBSD_MODE_DEVICE 1
816 static const value_string usb_freebsd_transfer_mode_vals
[] = {
817 {FREEBSD_MODE_HOST
, "Host"},
818 {FREEBSD_MODE_DEVICE
, "Device"},
823 #define FREEBSD_URB_SUBMIT 0
824 #define FREEBSD_URB_COMPLETE 1
825 static const value_string usb_freebsd_urb_type_vals
[] = {
826 {FREEBSD_URB_SUBMIT
, "URB_SUBMIT"},
827 {FREEBSD_URB_COMPLETE
, "URB_COMPLETE"},
832 #define FREEBSD_URB_CONTROL 0
833 #define FREEBSD_URB_ISOCHRONOUS 1
834 #define FREEBSD_URB_BULK 2
835 #define FREEBSD_URB_INTERRUPT 3
837 static const value_string usb_freebsd_transfer_type_vals
[] = {
838 {FREEBSD_URB_CONTROL
, "URB_CONTROL"},
839 {FREEBSD_URB_ISOCHRONOUS
, "URB_ISOCHRONOUS"},
840 {FREEBSD_URB_BULK
, "URB_BULK"},
841 {FREEBSD_URB_INTERRUPT
, "URB_INTERRUPT"},
846 #define FREEBSD_FLAG_FORCE_SHORT_XFER 0x00000001
847 #define FREEBSD_FLAG_SHORT_XFER_OK 0x00000002
848 #define FREEBSD_FLAG_SHORT_FRAMES_OK 0x00000004
849 #define FREEBSD_FLAG_PIPE_BOF 0x00000008
850 #define FREEBSD_FLAG_PROXY_BUFFER 0x00000010
851 #define FREEBSD_FLAG_EXT_BUFFER 0x00000020
852 #define FREEBSD_FLAG_MANUAL_STATUS 0x00000040
853 #define FREEBSD_FLAG_NO_PIPE_OK 0x00000080
854 #define FREEBSD_FLAG_STALL_PIPE 0x00000100
856 static int * const usb_xferflags_fields
[] = {
857 &hf_usb_xferflags_force_short_xfer
,
858 &hf_usb_xferflags_short_xfer_ok
,
859 &hf_usb_xferflags_short_frames_ok
,
860 &hf_usb_xferflags_pipe_bof
,
861 &hf_usb_xferflags_proxy_buffer
,
862 &hf_usb_xferflags_ext_buffer
,
863 &hf_usb_xferflags_manual_status
,
864 &hf_usb_xferflags_no_pipe_ok
,
865 &hf_usb_xferflags_stall_pipe
,
869 /* Transfer status */
870 #define FREEBSD_STATUS_OPEN 0x00000001
871 #define FREEBSD_STATUS_TRANSFERRING 0x00000002
872 #define FREEBSD_STATUS_DID_DMA_DELAY 0x00000004
873 #define FREEBSD_STATUS_DID_CLOSE 0x00000008
874 #define FREEBSD_STATUS_DRAINING 0x00000010
875 #define FREEBSD_STATUS_STARTED 0x00000020
876 #define FREEBSD_STATUS_BW_RECLAIMED 0x00000040
877 #define FREEBSD_STATUS_CONTROL_XFR 0x00000080
878 #define FREEBSD_STATUS_CONTROL_HDR 0x00000100
879 #define FREEBSD_STATUS_CONTROL_ACT 0x00000200
880 #define FREEBSD_STATUS_CONTROL_STALL 0x00000400
881 #define FREEBSD_STATUS_SHORT_FRAMES_OK 0x00000800
882 #define FREEBSD_STATUS_SHORT_XFER_OK 0x00001000
883 #define FREEBSD_STATUS_BDMA_ENABLE 0x00002000
884 #define FREEBSD_STATUS_BDMA_NO_POST_SYNC 0x00004000
885 #define FREEBSD_STATUS_BDMA_SETUP 0x00008000
886 #define FREEBSD_STATUS_ISOCHRONOUS_XFR 0x00010000
887 #define FREEBSD_STATUS_CURR_DMA_SET 0x00020000
888 #define FREEBSD_STATUS_CAN_CANCEL_IMMED 0x00040000
889 #define FREEBSD_STATUS_DOING_CALLBACK 0x00080000
891 static int * const usb_xferstatus_fields
[] = {
892 &hf_usb_xferstatus_open
,
893 &hf_usb_xferstatus_transferring
,
894 &hf_usb_xferstatus_did_dma_delay
,
895 &hf_usb_xferstatus_did_close
,
896 &hf_usb_xferstatus_draining
,
897 &hf_usb_xferstatus_started
,
898 &hf_usb_xferstatus_bw_reclaimed
,
899 &hf_usb_xferstatus_control_xfr
,
900 &hf_usb_xferstatus_control_hdr
,
901 &hf_usb_xferstatus_control_act
,
902 &hf_usb_xferstatus_control_stall
,
903 &hf_usb_xferstatus_short_frames_ok
,
904 &hf_usb_xferstatus_short_xfer_ok
,
905 &hf_usb_xferstatus_bdma_enable
,
906 &hf_usb_xferstatus_bdma_no_post_sync
,
907 &hf_usb_xferstatus_bdma_setup
,
908 &hf_usb_xferstatus_isochronous_xfr
,
909 &hf_usb_xferstatus_curr_dma_set
,
910 &hf_usb_xferstatus_can_cancel_immed
,
911 &hf_usb_xferstatus_doing_callback
,
916 #define FREEBSD_ERR_NORMAL_COMPLETION 0
917 #define FREEBSD_ERR_PENDING_REQUESTS 1
918 #define FREEBSD_ERR_NOT_STARTED 2
919 #define FREEBSD_ERR_INVAL 3
920 #define FREEBSD_ERR_NOMEM 4
921 #define FREEBSD_ERR_CANCELLED 5
922 #define FREEBSD_ERR_BAD_ADDRESS 6
923 #define FREEBSD_ERR_BAD_BUFSIZE 7
924 #define FREEBSD_ERR_BAD_FLAG 8
925 #define FREEBSD_ERR_NO_CALLBACK 9
926 #define FREEBSD_ERR_IN_USE 10
927 #define FREEBSD_ERR_NO_ADDR 11
928 #define FREEBSD_ERR_NO_PIPE 12
929 #define FREEBSD_ERR_ZERO_NFRAMES 13
930 #define FREEBSD_ERR_ZERO_MAXP 14
931 #define FREEBSD_ERR_SET_ADDR_FAILED 15
932 #define FREEBSD_ERR_NO_POWER 16
933 #define FREEBSD_ERR_TOO_DEEP 17
934 #define FREEBSD_ERR_IOERROR 18
935 #define FREEBSD_ERR_NOT_CONFIGURED 19
936 #define FREEBSD_ERR_TIMEOUT 20
937 #define FREEBSD_ERR_SHORT_XFER 21
938 #define FREEBSD_ERR_STALLED 22
939 #define FREEBSD_ERR_INTERRUPTED 23
940 #define FREEBSD_ERR_DMA_LOAD_FAILED 24
941 #define FREEBSD_ERR_BAD_CONTEXT 25
942 #define FREEBSD_ERR_NO_ROOT_HUB 26
943 #define FREEBSD_ERR_NO_INTR_THREAD 27
944 #define FREEBSD_ERR_NOT_LOCKED 28
946 static const value_string usb_freebsd_err_vals
[] = {
947 {FREEBSD_ERR_NORMAL_COMPLETION
, "Normal completion"},
948 {FREEBSD_ERR_PENDING_REQUESTS
, "Pending requests"},
949 {FREEBSD_ERR_NOT_STARTED
, "Not started"},
950 {FREEBSD_ERR_INVAL
, "Invalid"},
951 {FREEBSD_ERR_NOMEM
, "No memory"},
952 {FREEBSD_ERR_CANCELLED
, "Cancelled"},
953 {FREEBSD_ERR_BAD_ADDRESS
, "Bad address"},
954 {FREEBSD_ERR_BAD_BUFSIZE
, "Bad buffer size"},
955 {FREEBSD_ERR_BAD_FLAG
, "Bad flag"},
956 {FREEBSD_ERR_NO_CALLBACK
, "No callback"},
957 {FREEBSD_ERR_IN_USE
, "In use"},
958 {FREEBSD_ERR_NO_ADDR
, "No address"},
959 {FREEBSD_ERR_NO_PIPE
, "No pipe"},
960 {FREEBSD_ERR_ZERO_NFRAMES
, "Number of frames is zero"},
961 {FREEBSD_ERR_ZERO_MAXP
, "MAXP is zero"},
962 {FREEBSD_ERR_SET_ADDR_FAILED
, "Set address failed"},
963 {FREEBSD_ERR_NO_POWER
, "No power"},
964 {FREEBSD_ERR_TOO_DEEP
, "Too deep"},
965 {FREEBSD_ERR_IOERROR
, "I/O error"},
966 {FREEBSD_ERR_NOT_CONFIGURED
, "Not configured"},
967 {FREEBSD_ERR_TIMEOUT
, "Timeout"},
968 {FREEBSD_ERR_SHORT_XFER
, "Short transfer"},
969 {FREEBSD_ERR_STALLED
, "Stalled"},
970 {FREEBSD_ERR_INTERRUPTED
, "Interrupted"},
971 {FREEBSD_ERR_DMA_LOAD_FAILED
, "DMA load failed"},
972 {FREEBSD_ERR_BAD_CONTEXT
, "Bad context"},
973 {FREEBSD_ERR_NO_ROOT_HUB
, "No root hub"},
974 {FREEBSD_ERR_NO_INTR_THREAD
, "No interrupt thread"},
975 {FREEBSD_ERR_NOT_LOCKED
, "Not locked"},
980 #define FREEBSD_SPEED_VARIABLE 0
981 #define FREEBSD_SPEED_LOW 1
982 #define FREEBSD_SPEED_FULL 2
983 #define FREEBSD_SPEED_HIGH 3
984 #define FREEBSD_SPEED_SUPER 4
986 static const value_string usb_freebsd_speed_vals
[] = {
987 {FREEBSD_SPEED_VARIABLE
, "Variable"},
988 {FREEBSD_SPEED_LOW
, "Low"},
989 {FREEBSD_SPEED_FULL
, "Full"},
990 {FREEBSD_SPEED_HIGH
, "High"},
991 {FREEBSD_SPEED_SUPER
, "Super"},
996 #define FREEBSD_FRAMEFLAG_READ 0x00000001
997 #define FREEBSD_FRAMEFLAG_DATA_FOLLOWS 0x00000002
999 static int * const usb_frame_flags_fields
[] = {
1000 &hf_usb_frame_flags_read
,
1001 &hf_usb_frame_flags_data_follows
,
1005 static const value_string usb_linux_urb_type_vals
[] = {
1006 {URB_SUBMIT
, "URB_SUBMIT"},
1007 {URB_COMPLETE
, "URB_COMPLETE"},
1008 {URB_ERROR
, "URB_ERROR"},
1012 static const value_string usb_linux_transfer_type_vals
[] = {
1013 {URB_CONTROL
, "URB_CONTROL"},
1014 {URB_ISOCHRONOUS
, "URB_ISOCHRONOUS"},
1015 {URB_INTERRUPT
, "URB_INTERRUPT"},
1016 {URB_BULK
, "URB_BULK"},
1020 static const value_string usb_transfer_type_and_direction_vals
[] = {
1021 {URB_CONTROL
, "URB_CONTROL out"},
1022 {URB_ISOCHRONOUS
, "URB_ISOCHRONOUS out"},
1023 {URB_INTERRUPT
, "URB_INTERRUPT out"},
1024 {URB_BULK
, "URB_BULK out"},
1025 {URB_CONTROL
| URB_TRANSFER_IN
, "URB_CONTROL in"},
1026 {URB_ISOCHRONOUS
| URB_TRANSFER_IN
, "URB_ISOCHRONOUS in"},
1027 {URB_INTERRUPT
| URB_TRANSFER_IN
, "URB_INTERRUPT in"},
1028 {URB_BULK
| URB_TRANSFER_IN
, "URB_BULK in"},
1032 static const value_string usb_endpoint_direction_vals
[] = {
1038 static const range_string usb_setup_flag_rvals
[] = {
1040 {1, 255, "not relevant"},
1044 static const range_string usb_data_flag_rvals
[] = {
1046 {1, 255, "not present"},
1050 extern value_string_ext ext_usb_vendors_vals
;
1051 extern value_string_ext ext_usb_products_vals
;
1052 extern value_string_ext ext_usb_audio_subclass_vals
;
1053 extern value_string_ext ext_usb_com_subclass_vals
;
1054 extern value_string_ext ext_usb_massstorage_subclass_vals
;
1055 extern value_string_ext linux_negative_errno_vals_ext
;
1058 * Standard descriptor types.
1060 * all class specific descriptor types were removed from this list
1061 * a descriptor type is not globally unique
1062 * dissectors for the USB classes should provide their own value string
1063 * and pass it to dissect_usb_descriptor_header()
1066 #define USB_DT_DEVICE 1
1067 #define USB_DT_CONFIG 2
1068 #define USB_DT_STRING 3
1069 #define USB_DT_INTERFACE 4
1070 #define USB_DT_ENDPOINT 5
1071 #define USB_DT_DEVICE_QUALIFIER 6
1072 #define USB_DT_OTHER_SPEED_CONFIG 7
1073 #define USB_DT_INTERFACE_POWER 8
1074 /* these are from a minor usb 2.0 revision (ECN) */
1075 #define USB_DT_OTG 9
1076 #define USB_DT_DEBUG 10
1077 #define USB_DT_INTERFACE_ASSOCIATION 11
1078 /* these are from usb 3.0 specification */
1079 #define USB_DT_BOS 0x0F
1080 #define USB_DT_DEVICE_CAPABILITY 0x10
1081 #define USB_DT_SUPERSPEED_EP_COMPANION 0x30
1082 /* these are from usb 3.1 specification */
1083 #define USB_DT_SUPERSPEED_ISO_EP_COMPANION 0x31
1085 /* There are only Standard Descriptor Types, Class-specific types are
1086 provided by "usb.descriptor" descriptors table*/
1087 static const value_string std_descriptor_type_vals
[] = {
1088 {USB_DT_DEVICE
, "DEVICE"},
1089 {USB_DT_CONFIG
, "CONFIGURATION"},
1090 {USB_DT_STRING
, "STRING"},
1091 {USB_DT_INTERFACE
, "INTERFACE"},
1092 {USB_DT_ENDPOINT
, "ENDPOINT"},
1093 {USB_DT_DEVICE_QUALIFIER
, "DEVICE QUALIFIER"},
1094 {USB_DT_OTHER_SPEED_CONFIG
, "OTHER SPEED CONFIG"},
1095 {USB_DT_INTERFACE_POWER
, "INTERFACE POWER"},
1096 {USB_DT_OTG
, "OTG"},
1097 {USB_DT_DEBUG
, "DEBUG"},
1098 {USB_DT_INTERFACE_ASSOCIATION
, "INTERFACE ASSOCIATION"},
1099 {USB_DT_BOS
, "BOS"},
1100 {USB_DT_DEVICE_CAPABILITY
, "DEVICE CAPABILITY"},
1101 {USB_DT_SUPERSPEED_EP_COMPANION
, "SUPERSPEED USB ENDPOINT COMPANION"},
1102 {USB_DT_SUPERSPEED_ISO_EP_COMPANION
, "SUPERSPEED PLUS ISOCHRONOUS ENDPOINT COMPANION"},
1105 static value_string_ext std_descriptor_type_vals_ext
=
1106 VALUE_STRING_EXT_INIT(std_descriptor_type_vals
);
1109 * Feature selectors.
1110 * Per USB 3.1 spec, Table 9-7
1112 #define USB_FS_ENDPOINT_HALT 0
1113 #define USB_FS_FUNCTION_SUSPEND 0 /* same as ENDPOINT_HALT */
1114 #define USB_FS_DEVICE_REMOTE_WAKEUP 1
1115 #define USB_FS_TEST_MODE 2
1116 #define USB_FS_B_HNP_ENABLE 3
1117 #define USB_FS_A_HNP_SUPPORT 4
1118 #define USB_FS_A_ALT_HNP_SUPPORT 5
1119 #define USB_FS_WUSB_DEVICE 6
1120 #define USB_FS_U1_ENABLE 48
1121 #define USB_FS_U2_ENABLE 49
1122 #define USB_FS_LTM_ENABLE 50
1123 #define USB_FS_B3_NTF_HOST_REL 51
1124 #define USB_FS_B3_RSP_ENABLE 52
1125 #define USB_FS_LDM_ENABLE 53
1127 static const value_string usb_endpoint_feature_selector_vals
[] = {
1128 {USB_FS_ENDPOINT_HALT
, "ENDPOINT HALT"},
1132 static const value_string usb_interface_feature_selector_vals
[] = {
1133 {USB_FS_FUNCTION_SUSPEND
, "FUNCTION SUSPEND"},
1137 static const value_string usb_device_feature_selector_vals
[] = {
1138 {USB_FS_DEVICE_REMOTE_WAKEUP
, "DEVICE REMOTE WAKEUP"},
1139 {USB_FS_TEST_MODE
, "TEST MODE"},
1140 {USB_FS_B_HNP_ENABLE
, "B HNP ENABLE"},
1141 {USB_FS_A_HNP_SUPPORT
, "A HNP SUPPORT"},
1142 {USB_FS_A_ALT_HNP_SUPPORT
, "A ALT HNP SUPPORT"},
1143 {USB_FS_WUSB_DEVICE
, "WUSB DEVICE"},
1144 {USB_FS_U1_ENABLE
, "U1 ENABLE"},
1145 {USB_FS_U2_ENABLE
, "U2 ENABLE"},
1146 {USB_FS_LTM_ENABLE
, "LTM ENABLE"},
1147 {USB_FS_B3_NTF_HOST_REL
, "B3 NTF HOST REL"},
1148 {USB_FS_B3_RSP_ENABLE
, "B3 RSP ENABLE"},
1149 {USB_FS_LDM_ENABLE
, "LDM ENABLE"},
1154 /* the transfer type in the endpoint descriptor, i.e. the type of the endpoint
1155 (this is not the same as the URB transfer type) */
1156 #define USB_EP_CONTROL 0x00
1157 #define USB_EP_ISOCHRONOUS 0x01
1158 #define USB_EP_BULK 0x02
1159 #define USB_EP_INTERRUPT 0x03
1161 static const value_string usb_bmAttributes_transfer_vals
[] = {
1162 {USB_EP_CONTROL
, "Control-Transfer"},
1163 {USB_EP_ISOCHRONOUS
, "Isochronous-Transfer"},
1164 {USB_EP_BULK
, "Bulk-Transfer"},
1165 {USB_EP_INTERRUPT
, "Interrupt-Transfer"},
1169 static const value_string usb_bmAttributes_sync_vals
[] = {
1171 {0x01, "Asynchronous"},
1173 {0x03, "Synchronous"},
1177 static const value_string usb_bmAttributes_behaviour_vals
[] = {
1178 {0x00, "Data-Endpoint"},
1179 {0x01, "Explicit Feedback-Endpoint"},
1180 {0x02, "Implicit Feedback-Data-Endpoint"},
1185 static const value_string usb_wMaxPacketSize_slots_vals
[] = {
1193 /* USBPcap versions up to 1.4.1.0 captures USB control as 2 or 3 packets:
1194 * * SETUP with 8 bytes of Setup data
1195 * * DATA with optional data (either OUT or IN)
1196 * * STATUS without any USB payload, only the pseudoheader
1198 * USBPcap versions 1.5.0.0 and up captures USB control as 2 packets:
1199 * * SETUP with 8 bytes of Setup data and optional DATA OUT
1200 * * COMPLETE with optional DATA IN
1202 * The SETUP/COMPLETE matches the way control transfers are captured by
1205 #define USB_CONTROL_STAGE_SETUP 0x00
1206 #define USB_CONTROL_STAGE_DATA 0x01
1207 #define USB_CONTROL_STAGE_STATUS 0x02
1208 #define USB_CONTROL_STAGE_COMPLETE 0x03
1210 static const value_string usb_control_stage_vals
[] = {
1211 {USB_CONTROL_STAGE_SETUP
, "Setup"},
1212 {USB_CONTROL_STAGE_DATA
, "Data"},
1213 {USB_CONTROL_STAGE_STATUS
, "Status"},
1214 {USB_CONTROL_STAGE_COMPLETE
, "Complete"},
1218 /* Extra URB code to indicate relevant USB IRPs that don't directly
1219 * have any matching USB transfer.
1221 #define USBPCAP_URB_IRP_INFO 0xFE
1223 static const value_string win32_usb_transfer_type_vals
[] = {
1224 {URB_CONTROL
, "URB_CONTROL"},
1225 {URB_ISOCHRONOUS
, "URB_ISOCHRONOUS"},
1226 {URB_INTERRUPT
, "URB_INTERRUPT"},
1227 {URB_BULK
, "URB_BULK"},
1228 {USBPCAP_URB_IRP_INFO
, "USB IRP Info"},
1232 static const value_string win32_urb_function_vals
[] = {
1233 {0x0000, "URB_FUNCTION_SELECT_CONFIGURATION"},
1234 {0x0001, "URB_FUNCTION_SELECT_INTERFACE"},
1235 {0x0002, "URB_FUNCTION_ABORT_PIPE"},
1236 {0x0003, "URB_FUNCTION_TAKE_FRAME_LENGTH_CONTROL"},
1237 {0x0004, "URB_FUNCTION_RELEASE_FRAME_LENGTH_CONTROL"},
1238 {0x0005, "URB_FUNCTION_GET_FRAME_LENGTH"},
1239 {0x0006, "URB_FUNCTION_SET_FRAME_LENGTH"},
1240 {0x0007, "URB_FUNCTION_GET_CURRENT_FRAME_NUMBER"},
1241 {0x0008, "URB_FUNCTION_CONTROL_TRANSFER"},
1242 {0x0009, "URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER"},
1243 {0x000A, "URB_FUNCTION_ISOCH_TRANSFER"},
1244 {0x000B, "URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE"},
1245 {0x000C, "URB_FUNCTION_SET_DESCRIPTOR_TO_DEVICE"},
1246 {0x000D, "URB_FUNCTION_SET_FEATURE_TO_DEVICE"},
1247 {0x000E, "URB_FUNCTION_SET_FEATURE_TO_INTERFACE"},
1248 {0x000F, "URB_FUNCTION_SET_FEATURE_TO_ENDPOINT"},
1249 {0x0010, "URB_FUNCTION_CLEAR_FEATURE_TO_DEVICE"},
1250 {0x0011, "URB_FUNCTION_CLEAR_FEATURE_TO_INTERFACE"},
1251 {0x0012, "URB_FUNCTION_CLEAR_FEATURE_TO_ENDPOINT"},
1252 {0x0013, "URB_FUNCTION_GET_STATUS_FROM_DEVICE"},
1253 {0x0014, "URB_FUNCTION_GET_STATUS_FROM_INTERFACE"},
1254 {0x0015, "URB_FUNCTION_GET_STATUS_FROM_ENDPOINT"},
1255 {0x0016, "URB_FUNCTION_RESERVED_0X0016"},
1256 {0x0017, "URB_FUNCTION_VENDOR_DEVICE"},
1257 {0x0018, "URB_FUNCTION_VENDOR_INTERFACE"},
1258 {0x0019, "URB_FUNCTION_VENDOR_ENDPOINT"},
1259 {0x001A, "URB_FUNCTION_CLASS_DEVICE"},
1260 {0x001B, "URB_FUNCTION_CLASS_INTERFACE"},
1261 {0x001C, "URB_FUNCTION_CLASS_ENDPOINT"},
1262 {0x001D, "URB_FUNCTION_RESERVE_0X001D"},
1263 {0x001E, "URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL"},
1264 {0x001F, "URB_FUNCTION_CLASS_OTHER"},
1265 {0x0020, "URB_FUNCTION_VENDOR_OTHER"},
1266 {0x0021, "URB_FUNCTION_GET_STATUS_FROM_OTHER"},
1267 {0x0022, "URB_FUNCTION_CLEAR_FEATURE_TO_OTHER"},
1268 {0x0023, "URB_FUNCTION_SET_FEATURE_TO_OTHER"},
1269 {0x0024, "URB_FUNCTION_GET_DESCRIPTOR_FROM_ENDPOINT"},
1270 {0x0025, "URB_FUNCTION_SET_DESCRIPTOR_TO_ENDPOINT"},
1271 {0x0026, "URB_FUNCTION_GET_CONFIGURATION"},
1272 {0x0027, "URB_FUNCTION_GET_INTERFACE"},
1273 {0x0028, "URB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE"},
1274 {0x0029, "URB_FUNCTION_SET_DESCRIPTOR_TO_INTERFACE"},
1275 {0x002A, "URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR"},
1276 {0x002B, "URB_FUNCTION_RESERVE_0X002B"},
1277 {0x002C, "URB_FUNCTION_RESERVE_0X002C"},
1278 {0x002D, "URB_FUNCTION_RESERVE_0X002D"},
1279 {0x002E, "URB_FUNCTION_RESERVE_0X002E"},
1280 {0x002F, "URB_FUNCTION_RESERVE_0X002F"},
1281 {0x0030, "URB_FUNCTION_SYNC_RESET_PIPE"},
1282 {0x0031, "URB_FUNCTION_SYNC_CLEAR_STALL"},
1283 {0x0032, "URB_FUNCTION_CONTROL_TRANSFER_EX"},
1284 {0x0033, "URB_FUNCTION_RESERVE_0X0033"},
1285 {0x0034, "URB_FUNCTION_RESERVE_0X0034"},
1288 static value_string_ext win32_urb_function_vals_ext
= VALUE_STRING_EXT_INIT(win32_urb_function_vals
);
1290 static const value_string win32_usbd_status_vals
[] = {
1291 {0x00000000, "USBD_STATUS_SUCCESS"},
1292 {0x40000000, "USBD_STATUS_PENDING"},
1294 {0x80000200, "USBD_STATUS_INVALID_URB_FUNCTION"},
1295 {0x80000300, "USBD_STATUS_INVALID_PARAMETER"},
1296 {0x80000400, "USBD_STATUS_ERROR_BUSY"},
1297 {0x80000600, "USBD_STATUS_INVALID_PIPE_HANDLE"},
1298 {0x80000700, "USBD_STATUS_NO_BANDWIDTH"},
1299 {0x80000800, "USBD_STATUS_INTERNAL_HC_ERROR"},
1300 {0x80000900, "USBD_STATUS_ERROR_SHORT_TRANSFER"},
1302 {0xC0000001, "USBD_STATUS_CRC"},
1303 {0xC0000002, "USBD_STATUS_BTSTUFF"},
1304 {0xC0000003, "USBD_STATUS_DATA_TOGGLE_MISMATCH"},
1305 {0xC0000004, "USBD_STATUS_STALL_PID"},
1306 {0xC0000005, "USBD_STATUS_DEV_NOT_RESPONDING"},
1307 {0xC0000006, "USBD_STATUS_PID_CHECK_FAILURE"},
1308 {0xC0000007, "USBD_STATUS_UNEXPECTED_PID"},
1309 {0xC0000008, "USBD_STATUS_DATA_OVERRUN"},
1310 {0xC0000009, "USBD_STATUS_DATA_UNDERRUN"},
1311 {0xC000000A, "USBD_STATUS_RESERVED1"},
1312 {0xC000000B, "USBD_STATUS_RESERVED2"},
1313 {0xC000000C, "USBD_STATUS_BUFFER_OVERRUN"},
1314 {0xC000000D, "USBD_STATUS_BUFFER_UNDERRUN"},
1315 {0xC000000F, "USBD_STATUS_NOT_ACCESSED"},
1316 {0xC0000010, "USBD_STATUS_FIFO"},
1317 {0xC0000011, "USBD_STATUS_XACT_ERROR"},
1318 {0xC0000012, "USBD_STATUS_BABBLE_DETECTED"},
1319 {0xC0000013, "USBD_STATUS_DATA_BUFFER_ERROR"},
1320 {0xC0000030, "USBD_STATUS_ENDPOINT_HALTED"},
1322 {0xC0000A00, "USBD_STATUS_BAD_START_FRAME"},
1323 {0xC0000B00, "USBD_STATUS_ISOCH_REQUEST_FAILED"},
1324 {0xC0000C00, "USBD_STATUS_FRAME_CONTROL_OWNED"},
1325 {0xC0000D00, "USBD_STATUS_FRAME_CONTROL_NOT_OWNED"},
1326 {0xC0000E00, "USBD_STATUS_NOT_SUPPORTED"},
1327 {0xC0000F00, "USBD_STATUS_INVALID_CONFIGURATION_DESCRIPTOR"},
1328 {0xC0001000, "USBD_STATUS_INSUFFICIENT_RESOURCES"},
1329 {0xC0002000, "USBD_STATUS_SET_CONFIG_FAILED"},
1330 {0xC0003000, "USBD_STATUS_BUFFER_TOO_SMALL"},
1331 {0xC0004000, "USBD_STATUS_INTERFACE_NOT_FOUND"},
1332 {0xC0005000, "USBD_STATUS_INVALID_PIPE_FLAGS"},
1333 {0xC0006000, "USBD_STATUS_TIMEOUT"},
1334 {0xC0007000, "USBD_STATUS_DEVICE_GONE"},
1335 {0xC0008000, "USBD_STATUS_STATUS_NOT_MAPPED"},
1336 {0xC0009000, "USBD_STATUS_HUB_INTERNAL_ERROR"},
1337 {0xC0010000, "USBD_STATUS_CANCELED"},
1338 {0xC0020000, "USBD_STATUS_ISO_NOT_ACCESSED_BY_HW"},
1339 {0xC0030000, "USBD_STATUS_ISO_TD_ERROR"},
1340 {0xC0040000, "USBD_STATUS_ISO_NA_LATE_USBPORT"},
1341 {0xC0050000, "USBD_STATUS_ISO_NOT_ACCESSED_LATE"},
1342 {0xC0100000, "USBD_STATUS_BAD_DESCRIPTOR"},
1343 {0xC0100001, "USBD_STATUS_BAD_DESCRIPTOR_BLEN"},
1344 {0xC0100002, "USBD_STATUS_BAD_DESCRIPTOR_TYPE"},
1345 {0xC0100003, "USBD_STATUS_BAD_INTERFACE_DESCRIPTOR"},
1346 {0xC0100004, "USBD_STATUS_BAD_ENDPOINT_DESCRIPTOR"},
1347 {0xC0100005, "USBD_STATUS_BAD_INTERFACE_ASSOC_DESCRIPTOR"},
1348 {0xC0100006, "USBD_STATUS_BAD_CONFIG_DESC_LENGTH"},
1349 {0xC0100007, "USBD_STATUS_BAD_NUMBER_OF_INTERFACES"},
1350 {0xC0100008, "USBD_STATUS_BAD_NUMBER_OF_ENDPOINTS"},
1351 {0xC0100009, "USBD_STATUS_BAD_ENDPOINT_ADDRESS"},
1354 static value_string_ext win32_usbd_status_vals_ext
= VALUE_STRING_EXT_INIT(win32_usbd_status_vals
);
1356 static const value_string win32_usb_info_direction_vals
[] = {
1362 static const value_string usb_cdc_protocol_vals
[] = {
1363 {0x00, "No class specific protocol required"},
1364 {0x01, "AT Commands: V.250 etc"},
1365 {0x02, "AT Commands defined by PCCA-101"},
1366 {0x03, "AT Commands defined by PCCA-101 & Annex O"},
1367 {0x04, "AT Commands defined by GSM 07.07"},
1368 {0x05, "AT Commands defined by 3GPP 27.007"},
1369 {0x06, "AT Commands defined by TIA for CDMA"},
1370 {0x07, "Ethernet Emulation Model"},
1371 {0xFE, "External Protocol: Commands defined by Command Set Functional Descriptor"},
1372 {0xFF, "Vendor-specific"},
1375 static value_string_ext usb_cdc_protocol_vals_ext
= VALUE_STRING_EXT_INIT(usb_cdc_protocol_vals
);
1377 extern value_string_ext usb_massstorage_protocol_vals_ext
;
1379 static const value_string usb_cdc_data_protocol_vals
[] = {
1380 {0x00, "No class specific protocol required"},
1381 {0x01, "Network Transfer Block"},
1382 {0x02, "Network Transfer Block (IP + DSS)"},
1383 {0x30, "Physical interface protocol for ISDN BRI"},
1385 {0x32, "Transparent"},
1386 {0x50, "Management protocol for Q.921 data link protocol"},
1387 {0x51, "Data link protocol for Q.931"},
1388 {0x52, "TEI-multiplexor for Q.921 data link protocol"},
1389 {0x90, "Data compression procedures"},
1390 {0x91, "Euro-ISDN protocol control"},
1391 {0x92, "V.24 rate adaptation to ISDN"},
1392 {0x93, "CAPI Commands"},
1393 {0xFE, "The protocol(s) are described using a Protocol Unit Functional Descriptors on Communications Class Interface"},
1394 {0xFF, "Vendor-specific"},
1397 static value_string_ext usb_cdc_data_protocol_vals_ext
= VALUE_STRING_EXT_INIT(usb_cdc_data_protocol_vals
);
1399 static const value_string usb_hid_subclass_vals
[] = {
1401 {1, "Boot Interface"},
1404 static value_string_ext usb_hid_subclass_vals_ext
= VALUE_STRING_EXT_INIT(usb_hid_subclass_vals
);
1406 static const value_string usb_hid_boot_protocol_vals
[] = {
1412 static value_string_ext usb_hid_boot_protocol_vals_ext
= VALUE_STRING_EXT_INIT(usb_hid_boot_protocol_vals
);
1414 static const value_string usb_misc_subclass_vals
[] = {
1415 {0x03, "Cable Based Association Framework"},
1417 {IF_SUBCLASS_MISC_U3V
, "USB3 Vision"},
1418 {0x06, "Stream Transport Efficient Protocol"},
1421 static value_string_ext usb_misc_subclass_vals_ext
= VALUE_STRING_EXT_INIT(usb_misc_subclass_vals
);
1424 static const value_string usb_app_subclass_vals
[] = {
1425 {0x01, "Device Firmware Upgrade"},
1426 {0x02, "IRDA Bridge"},
1427 {0x03, "USB Test and Measurement Device"},
1430 static value_string_ext usb_app_subclass_vals_ext
= VALUE_STRING_EXT_INIT(usb_app_subclass_vals
);
1433 static const value_string usb_app_dfu_protocol_vals
[] = {
1434 {0x01, "Runtime protocol"},
1435 {0x02, "DFU mode protocol"},
1438 static value_string_ext usb_app_dfu_protocol_vals_ext
= VALUE_STRING_EXT_INIT(usb_app_dfu_protocol_vals
);
1440 static const value_string usb_app_irda_protocol_vals
[] = {
1441 {0x00, "IRDA Bridge device"},
1444 static value_string_ext usb_app_irda_protocol_vals_ext
= VALUE_STRING_EXT_INIT(usb_app_irda_protocol_vals
);
1446 static const value_string usb_app_usb_test_and_measurement_protocol_vals
[] = {
1447 {0x00, "USB Test and Measurement Device"},
1448 {0x01, "USB Test and Measurement Device conforming to the USBTMC USB488 Subclass Specification"},
1451 static value_string_ext usb_app_usb_test_and_measurement_protocol_vals_ext
= VALUE_STRING_EXT_INIT(usb_app_usb_test_and_measurement_protocol_vals
);
1456 #define DARWIN_IO_SUBMIT 0
1457 #define DARWIN_IO_COMPLETE 1
1460 static const value_string usb_darwin_request_type_vals
[] = {
1461 {DARWIN_IO_SUBMIT
, "SUBMIT"},
1462 {DARWIN_IO_COMPLETE
, "COMPLETE"},
1467 static const value_string usb_darwin_endpoint_type_vals
[] = {
1468 {USB_EP_CONTROL
, "Control"},
1469 {USB_EP_ISOCHRONOUS
, "Isochronous"},
1470 {USB_EP_BULK
, "Bulk"},
1471 {USB_EP_INTERRUPT
, "Interrupt"},
1476 #define DARWIN_SPEED_LOW 0
1477 #define DARWIN_SPEED_FULL 1
1478 #define DARWIN_SPEED_HIGH 2
1479 #define DARWIN_SPEED_SUPER 3
1480 #define DARWIN_SPEED_SUPERPLUS 4
1482 static const value_string usb_darwin_speed_vals
[] = {
1483 {DARWIN_SPEED_LOW
, "Low"},
1484 {DARWIN_SPEED_FULL
, "Full"},
1485 {DARWIN_SPEED_HIGH
, "High"},
1486 {DARWIN_SPEED_SUPER
, "Super"},
1487 {DARWIN_SPEED_SUPERPLUS
, "Super+"},
1491 static const value_string darwin_usb_status_vals
[] = {
1492 {0x00000000, "kIOReturnSuccess"},
1493 {0xe00002bc, "kIOReturnError"},
1494 {0xe00002bd, "kIOReturnNoMemory"},
1495 {0xe00002be, "kIOReturnNoResources"},
1496 {0xe00002bf, "kIOReturnIPCError"},
1497 {0xe00002c0, "kIOReturnNoDevice"},
1498 {0xe00002c1, "kIOReturnNotPrivileged"},
1499 {0xe00002c2, "kIOReturnBadArgument"},
1500 {0xe00002c3, "kIOReturnLockedRead"},
1501 {0xe00002c4, "kIOReturnLockedWrite"},
1502 {0xe00002c5, "kIOReturnExclusiveAccess"},
1503 {0xe00002c6, "kIOReturnBadMessageID"},
1504 {0xe00002c7, "kIOReturnUnsupported"},
1505 {0xe00002c8, "kIOReturnVMError"},
1506 {0xe00002c9, "kIOReturnInternalError"},
1507 {0xe00002ca, "kIOReturnIOError"},
1509 {0xe00002cc, "kIOReturnCannotLock"},
1510 {0xe00002cd, "kIOReturnNotOpen"},
1511 {0xe00002ce, "kIOReturnNotReadable"},
1512 {0xe00002cf, "kIOReturnNotWritable"},
1513 {0xe00002d0, "kIOReturnNotAligned"},
1514 {0xe00002d1, "kIOReturnBadMedia"},
1515 {0xe00002d2, "kIOReturnStillOpen"},
1516 {0xe00002d3, "kIOReturnRLDError"},
1517 {0xe00002d4, "kIOReturnDMAError"},
1518 {0xe00002d5, "kIOReturnBusy"},
1519 {0xe00002d6, "kIOReturnTimeout"},
1520 {0xe00002d7, "kIOReturnOffline"},
1521 {0xe00002d8, "kIOReturnNotReady"},
1522 {0xe00002d9, "kIOReturnNotAttached"},
1523 {0xe00002da, "kIOReturnNoChannels"},
1524 {0xe00002db, "kIOReturnNoSpace"},
1526 {0xe00002dd, "kIOReturnPortExists"},
1527 {0xe00002de, "kIOReturnCannotWire"},
1528 {0xe00002df, "kIOReturnNoInterrupt"},
1529 {0xe00002e0, "kIOReturnNoFrames"},
1530 {0xe00002e1, "kIOReturnMessageTooLarge"},
1531 {0xe00002e2, "kIOReturnNotPermitted"},
1532 {0xe00002e3, "kIOReturnNoPower"},
1533 {0xe00002e4, "kIOReturnNoMedia"},
1534 {0xe00002e5, "kIOReturnUnformattedMedia"},
1535 {0xe00002e6, "kIOReturnUnsupportedMode"},
1536 {0xe00002e7, "kIOReturnUnderrun"},
1537 {0xe00002e8, "kIOReturnOverrun"},
1538 {0xe00002e9, "kIOReturnDeviceError"},
1539 {0xe00002ea, "kIOReturnNoCompletion"},
1540 {0xe00002eb, "kIOReturnAborted"},
1541 {0xe00002ec, "kIOReturnNoBandwidth"},
1542 {0xe00002ed, "kIOReturnNotResponding"},
1543 {0xe00002ee, "kIOReturnIsoTooOld"},
1544 {0xe00002ef, "kIOReturnIsoTooNew"},
1545 {0xe00002f0, "kIOReturnNotFound"},
1549 static const uint32_t darwin_endpoint_to_linux
[] =
1558 static value_string_ext usb_darwin_status_vals_ext
= VALUE_STRING_EXT_INIT(darwin_usb_status_vals
);
1561 static const value_string netmon_event_id_vals
[] = {
1562 {1, "USBPORT_ETW_EVENT_HC_ADD USBPORT_ETW_EVENT_HC_ADD"},
1563 {2, "USBPORT_ETW_EVENT_HC_REMOVAL USBPORT_ETW_EVENT_HC_REMOVAL"},
1564 {3, "USBPORT_ETW_EVENT_HC_INFORMATION USBPORT_ETW_EVENT_HC_INFORMATION"},
1565 {4, "USBPORT_ETW_EVENT_HC_START USBPORT_ETW_EVENT_HC_START"},
1566 {5, "USBPORT_ETW_EVENT_HC_STOP USBPORT_ETW_EVENT_HC_STOP"},
1567 {6, "USBPORT_ETW_EVENT_HC_SUSPEND USBPORT_ETW_EVENT_HC_SUSPEND"},
1568 {7, "USBPORT_ETW_EVENT_HC_RESUME USBPORT_ETW_EVENT_HC_RESUME"},
1569 {8, "USBPORT_ETW_EVENT_HC_ASYNC_SCHEDULE_ENABLE"},
1570 {9, "USBPORT_ETW_EVENT_HC_ASYNC_SCHEDULE_DISABLE"},
1571 {10, "USBPORT_ETW_EVENT_HC_PERIODIC_SCHEDULE_ENABLE"},
1572 {11, "USBPORT_ETW_EVENT_HC_PERIODIC_SCHEDULE_DISABLE"},
1573 {12, "USBPORT_ETW_EVENT_DEVICE_CREATE"},
1574 {13, "USBPORT_ETW_EVENT_DEVICE_INITIALIZE"},
1575 {14, "USBPORT_ETW_EVENT_DEVICE_REMOVAL"},
1576 {15, "USBPORT_ETW_EVENT_DEVICE_INFORMATION"},
1577 {16, "USBPORT_ETW_EVENT_DEVICE_IDLE_STATE_SET"},
1578 {17, "USBPORT_ETW_EVENT_DEVICE_IDLE_STATE_CLEAR"},
1579 {18, "USBPORT_ETW_EVENT_ENDPOINT_OPEN"},
1580 {19, "USBPORT_ETW_EVENT_ENDPOINT_CLOSE USBPORT_ETW_EVENT_ENDPOINT_CLOSE"},
1581 {20, "USBPORT_ETW_EVENT_ENDPOINT_INFORMATION"},
1582 {21, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_SELECT_CONFIGURATION"},
1583 {22, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_SELECT_INTERFACE"},
1584 {23, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_GET_CURRENT_FRAME_NUMBER"},
1585 {24, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_CONTROL_TRANSFER"},
1586 {25, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_CONTROL_TRANSFER_EX"},
1587 {26, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER"},
1588 {27, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_ISOCH_TRANSFER"},
1589 {28, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE"},
1590 {29, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_SET_DESCRIPTOR_TO_DEVICE"},
1591 {30, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_GET_DESCRIPTOR_FROM_ENDPOINT"},
1592 {31, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_SET_DESCRIPTOR_TO_ENDPOINT"},
1593 {32, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE"},
1594 {33, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_SET_DESCRIPTOR_TO_INTERFACE"},
1595 {34, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_SET_FEATURE_TO_DEVICE"},
1596 {35, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_SET_FEATURE_TO_INTERFACE"},
1597 {36, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_SET_FEATURE_TO_ENDPOINT"},
1598 {37, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_CLEAR_FEATURE_TO_DEVICE"},
1599 {38, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_CLEAR_FEATURE_TO_INTERFACE"},
1600 {39, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_CLEAR_FEATURE_TO_ENDPOINT"},
1601 {40, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_CLEAR_FEATURE_TO_OTHER"},
1602 {41, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_SET_FEATURE_TO_OTHER"},
1603 {42, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_GET_STATUS_FROM_DEVICE"},
1604 {43, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_GET_STATUS_FROM_INTERFACE"},
1605 {44, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_GET_STATUS_FROM_ENDPOINT"},
1606 {45, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_GET_STATUS_FROM_OTHER"},
1607 {46, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_VENDOR_DEVICE"},
1608 {47, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_VENDOR_INTERFACE"},
1609 {48, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_VENDOR_ENDPOINT"},
1610 {49, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_CLASS_DEVICE"},
1611 {50, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_CLASS_INTERFACE"},
1612 {51, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_CLASS_ENDPOINT"},
1613 {52, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_CLASS_OTHER"},
1614 {53, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_VENDOR_OTHER"},
1615 {54, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_ABORT_PIPE"},
1616 {55, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL"},
1617 {56, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_SYNC_RESET_PIPE"},
1618 {57, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_SYNC_CLEAR_STALL"},
1619 {58, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_GET_CONFIGURATION"},
1620 {59, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_GET_INTERFACE"},
1621 {60, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR"},
1622 {61, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_TAKE_FRAME_LENGTH_CONTROL"},
1623 {62, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_RELEASE_FRAME_LENGTH_CONTROL"},
1624 {63, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_GET_FRAME_LENGTH"},
1625 {64, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_SET_FRAME_LENGTH"},
1626 {65, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_RESERVED"},
1627 {66, "USBPORT_ETW_EVENT_COMPLETE_URB_FUNCTION_CONTROL_TRANSFER"},
1628 {67, "USBPORT_ETW_EVENT_COMPLETE_URB_FUNCTION_CONTROL_TRANSFER_EX"},
1629 {68, "USBPORT_ETW_EVENT_COMPLETE_URB_FUNCTION_CONTROL_TRANSFER_DATA"},
1630 {69, "USBPORT_ETW_EVENT_COMPLETE_URB_FUNCTION_CONTROL_TRANSFER_EX_DATA"},
1631 {70, "USBPORT_ETW_EVENT_COMPLETE_URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER"},
1632 {71, "USBPORT_ETW_EVENT_COMPLETE_URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER_DATA"},
1633 {72, "USBPORT_ETW_EVENT_COMPLETE_URB_FUNCTION_ISOCH_TRANSFER"},
1634 {73, "USBPORT_ETW_EVENT_COMPLETE_URB_FUNCTION_ISOCH_TRANSFER_DATA"},
1635 {74, "USBPORT_ETW_EVENT_INTERNAL_URB_FUNCTION_CONTROL_TRANSFER"},
1636 {75, "USBPORT_ETW_EVENT_COMPLETE_INTERNAL_URB_FUNCTION_CONTROL_TRANSFER"},
1637 {76, "USBPORT_ETW_EVENT_COMPLETE_INTERNAL_URB_FUNCTION_CONTROL_TRANSFER_DATA"},
1638 {77, "USBPORT_ETW_EVENT_COMPLETE_URB_FUNCTION_ABORT_PIPE"},
1639 {78, "USBPORT_ETW_EVENT_DISPATCH_URB_INVALID_HEADER_LENGTH_WARNING"},
1640 {79, "USBPORT_ETW_EVENT_DISPATCH_URB_INVALID_FUNCTION"},
1641 {80, "USBPORT_ETW_EVENT_DISPATCH_URB_INVALID_HEADER_LENGTH"},
1642 {81, "USBPORT_ETW_EVENT_DISPATCH_URB_INVALID_DEVICE_HANDLE"},
1643 {82, "USBPORT_ETW_EVENT_DISPATCH_URB_INVALID_FUNCTION_NOT_SUPPORTED"},
1644 {83, "USBPORT_ETW_EVENT_DISPATCH_URB_INVALID_FUNCTION_RESERVED"},
1645 {84, "USBPORT_ETW_EVENT_DISPATCH_URB_INVALID_DUE_TO_HC_SUSPEND"},
1646 {85, "USBPORT_ETW_EVENT_DISPATCH_URB_INVALID_URB_LINK"},
1647 {86, "USBPORT_ETW_EVENT_DISPATCH_URB_INVALID_PIPE_HANDLE"},
1648 {87, "USBPORT_ETW_EVENT_DISPATCH_URB_INVALID_ZERO_BW_PIPE_HANDLE"},
1649 {88, "USBPORT_ETW_EVENT_DISPATCH_URB_NOP_ZERO_BW_PIPE_HANDLE_REQUEST"},
1650 {89, "USBPORT_ETW_EVENT_DISPATCH_URB_INVALID_CONTROL_TRANSFER_ENDPOINT"},
1651 {90, "USBPORT_ETW_EVENT_DISPATCH_URB_INVALID_CONTROL_TRANSFER_BUFFER_LENGTH"},
1652 {91, "USBPORT_ETW_EVENT_DISPATCH_URB_INVALID_BULK_OR_INTERRUPT_TRANSFER_ENDPOINT"},
1653 {92, "USBPORT_ETW_EVENT_DISPATCH_URB_INVALID_BULK_OR_INTERRUPT_TRANSFER_BUFFER_LENGTH"},
1654 {93, "USBPORT_ETW_EVENT_DISPATCH_URB_INVALID_ISOCHRONOUS_TRANSFER_ENDPOINT"},
1655 {94, "USBPORT_ETW_EVENT_DISPATCH_URB_INVALID_NULL_TRANSFER_BUFFER_AND_MDL"},
1656 {95, "USBPORT_ETW_EVENT_DISPATCH_URB_INVALID_NON_NULL_TRANSFER_BUFFER_MDL"},
1657 {96, "USBPORT_ETW_EVENT_DISPATCH_URB_ALLOCATE_MDL_FAILURE"},
1658 {97, "USBPORT_ETW_EVENT_DISPATCH_URB_ALLOCATE_TRANSFER_CONTEXT_FAILURE"},
1659 {98, "USBPORT_ETW_EVENT_DISPATCH_URB_NOP_ROOTHUB_PIPE_HANDLE_REQUEST"},
1660 {99, "USBPORT_ETW_EVENT_DISPATCH_URB_INVALID_ISOCHRONOUS_ZERO_LENGTH"},
1661 {100, "USBPORT_ETW_EVENT_DISPATCH_URB_INVALID_ISOCHRONOUS_NUM_PACKETS"},
1662 {101, "USBPORT_ETW_EVENT_DISPATCH_URB_INVALID_ISOCHRONOUS_START_FRAME"},
1663 {102, "USBPORT_ETW_EVENT_IRP_CANCEL"},
1664 {103, "USBPORT_ETW_EVENT_USBUSER_OP_RAW_RESET_PORT_DISPATCH"},
1665 {104, "USBPORT_ETW_EVENT_USBUSER_OP_RAW_RESET_PORT_STATUS1"},
1666 {105, "USBPORT_ETW_EVENT_USBUSER_OP_RAW_RESET_PORT_STATUS2"},
1667 {106, "USBPORT_ETW_EVENT_USBUSER_OP_RAW_RESET_PORT_STATUS3"},
1668 {107, "USBPORT_ETW_EVENT_USBUSER_OP_RAW_RESET_PORT_COMPLETE"},
1669 {108, "USBPORT_ETW_EVENT_USBUSER_OP_SEND_ONE_PACKET_DISPATCH"},
1670 {109, "USBPORT_ETW_EVENT_USBUSER_OP_SEND_ONE_PACKET_DISPATCH_DATA"},
1671 {110, "USBPORT_ETW_EVENT_USBUSER_OP_SEND_ONE_PACKET_TIMEOUT"},
1672 {111, "USBPORT_ETW_EVENT_USBUSER_OP_SEND_ONE_PACKET_COMPLETE"},
1673 {112, "USBPORT_ETW_EVENT_USBUSER_OP_SEND_ONE_PACKET_COMPLETE_DATA"},
1674 {113, "USBPORT_ETW_EVENT_CODE_EXECUTION_TIME"},
1675 {114, "USBPORT_ETW_EVENT_PUT_SGLIST_EXECUTION_TIME"},
1676 {115, "USBPORT_ETW_EVENT_BUILD_SGLIST_EXECUTION_TIME"},
1677 {1024, "USBPORT_ETW_EVENT_HC_EHCI_MINIPORT_START_DISPATCH"},
1678 {1025, "USBPORT_ETW_EVENT_HC_EHCI_MINIPORT_START_COMPLETE"},
1679 {1026, "USBPORT_ETW_EVENT_HC_EHCI_MINIPORT_START_COMPLETE_ERROR_1"},
1680 {1027, "USBPORT_ETW_EVENT_HC_EHCI_MINIPORT_START_COMPLETE_ERROR_2"},
1681 {1028, "USBPORT_ETW_EVENT_HC_EHCI_MINIPORT_START_COMPLETE_ERROR_3"},
1682 {1029, "USBPORT_ETW_EVENT_HC_EHCI_MINIPORT_START_COMPLETE_ERROR_4"},
1683 {1030, "USBPORT_ETW_EVENT_HC_EHCI_MINIPORT_START_COMPLETE_ERROR_5"},
1684 {1031, "USBPORT_ETW_EVENT_HC_EHCI_MINIPORT_STOP_DISPATCH"},
1685 {1032, "USBPORT_ETW_EVENT_HC_EHCI_MINIPORT_STOP_COMPLETE"},
1686 {1033, "USBPORT_ETW_EVENT_HC_EHCI_MINIPORT_SUSPEND_DISPATCH"},
1687 {1034, "USBPORT_ETW_EVENT_HC_EHCI_MINIPORT_SUSPEND_COMPLETE"},
1688 {1035, "USBPORT_ETW_EVENT_HC_EHCI_MINIPORT_RESUME_DISPATCH"},
1689 {1036, "USBPORT_ETW_EVENT_HC_EHCI_MINIPORT_RESUME_COMPLETE"},
1690 {1037, "USBPORT_ETW_EVENT_HC_EHCI_MINIPORT_RESUME_COMPLETE_ERROR_1"},
1691 {1038, "USBPORT_ETW_EVENT_HC_EHCI_MINIPORT_RESUME_COMPLETE_ERROR_2"},
1692 {1039, "USBPORT_ETW_EVENT_HC_EHCI_MINIPORT_RESUME_COMPLETE_ERROR_3"},
1693 {1040, "USBPORT_ETW_EVENT_HC_EHCI_MINIPORT_RESUME_COMPLETE_ERROR_4"},
1694 {1041, "USBPORT_ETW_EVENT_HC_EHCI_MINIPORT_RESUME_COMPLETE_ERROR_5"},
1695 {1042, "USBPORT_ETW_EVENT_HC_EHCI_MINIPORT_RESUME_COMPLETE_ERROR_6"},
1696 {2048, "USBPORT_ETW_EVENT_HC_OHCI_MINIPORT_START_DISPATCH"},
1697 {2049, "USBPORT_ETW_EVENT_HC_OHCI_MINIPORT_START_COMPLETE"},
1698 {2050, "USBPORT_ETW_EVENT_HC_OHCI_MINIPORT_START_COMPLETE_ERROR_1"},
1699 {2051, "USBPORT_ETW_EVENT_HC_OHCI_MINIPORT_START_COMPLETE_ERROR_2"},
1700 {2052, "USBPORT_ETW_EVENT_HC_OHCI_MINIPORT_START_COMPLETE_ERROR_3"},
1701 {2053, "USBPORT_ETW_EVENT_HC_OHCI_MINIPORT_START_COMPLETE_ERROR_4"},
1702 {2054, "USBPORT_ETW_EVENT_HC_OHCI_MINIPORT_START_COMPLETE_ERROR_5"},
1703 {2055, "USBPORT_ETW_EVENT_HC_OHCI_MINIPORT_STOP_DISPATCH"},
1704 {2056, "USBPORT_ETW_EVENT_HC_OHCI_MINIPORT_STOP_COMPLETE"},
1705 {2057, "USBPORT_ETW_EVENT_HC_OHCI_MINIPORT_SUSPEND_DISPATCH"},
1706 {2058, "USBPORT_ETW_EVENT_HC_OHCI_MINIPORT_SUSPEND_COMPLETE"},
1707 {2059, "USBPORT_ETW_EVENT_HC_OHCI_MINIPORT_RESUME_DISPATCH"},
1708 {2060, "USBPORT_ETW_EVENT_HC_OHCI_MINIPORT_RESUME_COMPLETE"},
1709 {2061, "USBPORT_ETW_EVENT_HC_OHCI_MINIPORT_RESUME_COMPLETE_ERROR_1"},
1710 {2062, "USBPORT_ETW_EVENT_HC_OHCI_MINIPORT_RESUME_COMPLETE_ERROR_2"},
1711 {2063, "USBPORT_ETW_EVENT_HC_OHCI_MINIPORT_RESUME_COMPLETE_ERROR_3"},
1712 {2064, "USBPORT_ETW_EVENT_HC_OHCI_MINIPORT_RESUME_COMPLETE_ERROR_4"},
1713 {2065, "USBPORT_ETW_EVENT_HC_OHCI_MINIPORT_RESUME_COMPLETE_ERROR_5"},
1714 {3072, "USBPORT_ETW_EVENT_HC_UHCI_MINIPORT_START_DISPATCH"},
1715 {3073, "USBPORT_ETW_EVENT_HC_UHCI_MINIPORT_START_COMPLETE"},
1716 {3074, "USBPORT_ETW_EVENT_HC_UHCI_MINIPORT_START_COMPLETE_ERROR_1"},
1717 {3075, "USBPORT_ETW_EVENT_HC_UHCI_MINIPORT_START_COMPLETE_ERROR_2"},
1718 {3076, "USBPORT_ETW_EVENT_HC_UHCI_MINIPORT_START_COMPLETE_ERROR_3"},
1719 {3077, "USBPORT_ETW_EVENT_HC_UHCI_MINIPORT_START_COMPLETE_ERROR_4"},
1720 {3078, "USBPORT_ETW_EVENT_HC_UHCI_MINIPORT_STOP_DISPATCH"},
1721 {3079, "USBPORT_ETW_EVENT_HC_UHCI_MINIPORT_STOP_COMPLETE"},
1722 {3080, "USBPORT_ETW_EVENT_HC_UHCI_MINIPORT_SUSPEND_DISPATCH"},
1723 {3081, "USBPORT_ETW_EVENT_HC_UHCI_MINIPORT_SUSPEND_COMPLETE"},
1724 {3082, "USBPORT_ETW_EVENT_HC_UHCI_MINIPORT_RESUME_DISPATCH"},
1725 {3083, "USBPORT_ETW_EVENT_HC_UHCI_MINIPORT_RESUME_COMPLETE"},
1726 {3084, "USBPORT_ETW_EVENT_HC_UHCI_MINIPORT_RESUME_COMPLETE_ERROR_1"},
1727 {3085, "USBPORT_ETW_EVENT_HC_UHCI_MINIPORT_RESUME_COMPLETE_ERROR_2"},
1728 {3086, "USBPORT_ETW_EVENT_HC_UHCI_MINIPORT_RESUME_COMPLETE_ERROR_3"},
1729 {3087, "USBPORT_ETW_EVENT_HC_UHCI_MINIPORT_RESUME_COMPLETE_ERROR_4"},
1730 {3088, "USBPORT_ETW_EVENT_HC_UHCI_MINIPORT_RESUME_COMPLETE_ERROR_5"},
1731 {3089, "USBPORT_ETW_EVENT_RTPM_TRANSITION"},
1732 {3090, "USBPORT_ETW_EVENT_DISPATCH_WAIT_WAKE"},
1733 {3091, "USBPORT_ETW_EVENT_COMPLETE_WAIT_WAKE"},
1736 static value_string_ext netmon_event_id_vals_ext
= VALUE_STRING_EXT_INIT(netmon_event_id_vals
);
1738 static const value_string netmon_urb_function_vals
[] = {
1739 {0x0000, "SELECT_CONFIGURATION"},
1740 {0x0001, "SELECT_INTERFACE"},
1741 {0x0002, "ABORT_PIPE"},
1742 {0x0003, "TAKE_FRAME_LENGTH_CONTROL"},
1743 {0x0004, "RELEASE_FRAME_LENGTH_CONTROL"},
1744 {0x0005, "GET_FRAME_LENGTH"},
1745 {0x0006, "SET_FRAME_LENGTH"},
1746 {0x0007, "GET_CURRENT_FRAME_NUMBER"},
1747 {0x0008, "CONTROL_TRANSFER"},
1748 {0x0009, "BULK_OR_INTERRUPT_TRANSFER"},
1749 {0x000A, "ISOCH_TRANSFER"},
1750 {0x000B, "GET_DESCRIPTOR_FROM_DEVICE"},
1751 {0x000C, "SET_DESCRIPTOR_TO_DEVICE"},
1752 {0x000D, "SET_FEATURE_TO_DEVICE"},
1753 {0x000E, "SET_FEATURE_TO_INTERFACE"},
1754 {0x000F, "SET_FEATURE_TO_ENDPOINT"},
1755 {0x0010, "CLEAR_FEATURE_TO_DEVICE"},
1756 {0x0011, "CLEAR_FEATURE_TO_INTERFACE"},
1757 {0x0012, "CLEAR_FEATURE_TO_ENDPOINT"},
1758 {0x0013, "GET_STATUS_FROM_DEVICE"},
1759 {0x0014, "GET_STATUS_FROM_INTERFACE"},
1760 {0x0015, "GET_STATUS_FROM_ENDPOINT"},
1761 {0x0016, "RESERVED"},
1762 {0x0017, "VENDOR_DEVICE"},
1763 {0x0018, "VENDOR_INTERFACE"},
1764 {0x0019, "VENDOR_ENDPOINT"},
1765 {0x001A, "CLASS_DEVICE"},
1766 {0x001B, "CLASS_INTERFACE"},
1767 {0x001C, "CLASS_ENDPOINT"},
1768 {0x001D, "RESERVE_0X001D"},
1769 {0x001E, "SYNC_RESET_PIPE_AND_CLEAR_STALL"},
1770 {0x001F, "CLASS_OTHER"},
1771 {0x0020, "VENDOR_OTHER"},
1772 {0x0021, "GET_STATUS_FROM_OTHER"},
1773 {0x0022, "CLEAR_FEATURE_TO_OTHER"},
1774 {0x0023, "SET_FEATURE_TO_OTHER"},
1775 {0x0024, "GET_DESCRIPTOR_FROM_ENDPOINT"},
1776 {0x0025, "SET_DESCRIPTOR_TO_ENDPOINT"},
1777 {0x0026, "GET_CONFIGURATION"},
1778 {0x0027, "GET_INTERFACE"},
1779 {0x0028, "GET_DESCRIPTOR_FROM_INTERFACE"},
1780 {0x0029, "SET_DESCRIPTOR_TO_INTERFACE"},
1781 {0x002A, "GET_MS_FEATURE_DESCRIPTOR"},
1782 {0x0030, "SYNC_RESET_PIPE"},
1783 {0x0031, "SYNC_CLEAR_STALL"},
1784 {0x0032, "CONTROL_TRANSFER_EX"},
1785 {0x0035, "OPEN_STATIC_STREAMS"},
1786 {0x0036, "CLOSE_STATIC_STREAMS"},
1787 {0x0037, "BULK_OR_INTERRUPT_TRANSFER_USING_CHAINED_MDL"},
1788 {0x0038, "ISOCH_TRANSFER_USING_CHAINED_MDL"},
1791 static value_string_ext netmon_urb_function_vals_ext
= VALUE_STRING_EXT_INIT(netmon_urb_function_vals
);
1794 void proto_register_usb(void);
1795 void proto_reg_handoff_usb(void);
1797 /* USB address handling */
1798 static int usb_addr_to_str(const address
* addr
, char *buf
, int buf_len _U_
)
1800 const uint8_t *addrp
= (const uint8_t *)addr
->data
;
1802 if(pletoh32(&addrp
[0])==0xffffffff){
1803 (void) g_strlcpy(buf
, "host", buf_len
);
1805 snprintf(buf
, buf_len
, "%d.%d.%d", pletoh16(&addrp
[8]),
1806 pletoh32(&addrp
[0]), pletoh32(&addrp
[4]) & 0x0f);
1809 return (int)(strlen(buf
)+1);
1812 static int usb_addr_str_len(const address
* addr _U_
)
1818 /* This keys provide information for DecodeBy and other dissector via
1819 per packet data: p_get_proto_data()/p_add_proto_data() */
1820 #define USB_BUS_ID 0
1821 #define USB_DEVICE_ADDRESS 1
1822 #define USB_VENDOR_ID 2
1823 #define USB_PRODUCT_ID 3
1824 #define USB_DEVICE_CLASS 4
1825 #define USB_DEVICE_SUBCLASS 5
1826 #define USB_DEVICE_PROTOCOL 6
1829 usb_device_prompt(packet_info
*pinfo
, char* result
)
1831 snprintf(result
, MAX_DECODE_AS_PROMPT_LEN
, "Bus ID %u \nDevice Address %u\nas ",
1832 GPOINTER_TO_UINT(p_get_proto_data(pinfo
->pool
, pinfo
, proto_usb
, USB_BUS_ID
)),
1833 GPOINTER_TO_UINT(p_get_proto_data(pinfo
->pool
, pinfo
, proto_usb
, USB_DEVICE_ADDRESS
)));
1837 usb_device_value(packet_info
*pinfo
)
1839 uint32_t value
= GPOINTER_TO_UINT(p_get_proto_data(pinfo
->pool
, pinfo
, proto_usb
, USB_BUS_ID
)) << 16;
1840 value
|= GPOINTER_TO_UINT(p_get_proto_data(pinfo
->pool
, pinfo
, proto_usb
, USB_DEVICE_ADDRESS
));
1841 return GUINT_TO_POINTER(value
);
1845 usb_product_prompt(packet_info
*pinfo
, char* result
)
1847 snprintf(result
, MAX_DECODE_AS_PROMPT_LEN
, "Vendor ID 0x%04x \nProduct ID 0x%04x\nas ",
1848 GPOINTER_TO_UINT(p_get_proto_data(pinfo
->pool
, pinfo
, proto_usb
, USB_VENDOR_ID
)),
1849 GPOINTER_TO_UINT(p_get_proto_data(pinfo
->pool
, pinfo
, proto_usb
, USB_PRODUCT_ID
)));
1853 usb_product_value(packet_info
*pinfo
)
1855 uint32_t value
= GPOINTER_TO_UINT(p_get_proto_data(pinfo
->pool
, pinfo
, proto_usb
, USB_VENDOR_ID
)) << 16;
1856 value
|= GPOINTER_TO_UINT(p_get_proto_data(pinfo
->pool
, pinfo
, proto_usb
, USB_PRODUCT_ID
));
1857 return GUINT_TO_POINTER(value
);
1861 usb_protocol_prompt(packet_info
*pinfo
, char* result
)
1863 snprintf(result
, MAX_DECODE_AS_PROMPT_LEN
, "Class ID 0x%04x \nSubclass ID 0x%04x\nProtocol 0x%04x\nas ",
1864 GPOINTER_TO_UINT(p_get_proto_data(pinfo
->pool
, pinfo
, proto_usb
, USB_DEVICE_CLASS
)),
1865 GPOINTER_TO_UINT(p_get_proto_data(pinfo
->pool
, pinfo
, proto_usb
, USB_DEVICE_SUBCLASS
)),
1866 GPOINTER_TO_UINT(p_get_proto_data(pinfo
->pool
, pinfo
, proto_usb
, USB_DEVICE_PROTOCOL
)));
1870 usb_protocol_value(packet_info
*pinfo
)
1872 uint32_t value
= GPOINTER_TO_UINT(p_get_proto_data(pinfo
->pool
, pinfo
, proto_usb
, USB_DEVICE_CLASS
)) << 16;
1873 value
|= GPOINTER_TO_UINT(p_get_proto_data(pinfo
->pool
, pinfo
, proto_usb
, USB_DEVICE_SUBCLASS
)) << 8;
1874 value
|= GPOINTER_TO_UINT(p_get_proto_data(pinfo
->pool
, pinfo
, proto_usb
, USB_DEVICE_PROTOCOL
));
1875 return GUINT_TO_POINTER(value
);
1878 static build_valid_func usb_product_da_build_value
[1] = {usb_product_value
};
1879 static decode_as_value_t usb_product_da_values
= {usb_product_prompt
, 1, usb_product_da_build_value
};
1880 static decode_as_t usb_product_da
= {
1881 "usb", "usb.product",
1882 1, 0, &usb_product_da_values
, NULL
, NULL
,
1883 decode_as_default_populate_list
, decode_as_default_reset
,
1884 decode_as_default_change
, NULL
};
1886 static build_valid_func usb_device_da_build_value
[1] = {usb_device_value
};
1887 static decode_as_value_t usb_device_da_values
= {usb_device_prompt
, 1, usb_device_da_build_value
};
1888 static decode_as_t usb_device_da
= {
1889 "usb", "usb.device",
1890 1, 0, &usb_device_da_values
, NULL
, NULL
,
1891 decode_as_default_populate_list
, decode_as_default_reset
,
1892 decode_as_default_change
, NULL
};
1894 static build_valid_func usb_protocol_da_build_value
[1] = {usb_protocol_value
};
1895 static decode_as_value_t usb_protocol_da_values
= {usb_protocol_prompt
, 1, usb_protocol_da_build_value
};
1896 static decode_as_t usb_protocol_da
= {
1897 "usb", "usb.protocol",
1898 1, 0, &usb_protocol_da_values
, NULL
, NULL
,
1899 decode_as_default_populate_list
, decode_as_default_reset
,
1900 decode_as_default_change
, NULL
};
1903 static usb_conv_info_t
*
1904 get_usb_conv_info(conversation_t
*conversation
)
1906 usb_conv_info_t
*usb_conv_info
;
1908 /* do we have conversation specific data ? */
1909 usb_conv_info
= (usb_conv_info_t
*)conversation_get_proto_data(conversation
, proto_usb
);
1910 if (!usb_conv_info
) {
1911 /* no not yet so create some */
1912 usb_conv_info
= wmem_new0(wmem_file_scope(), usb_conv_info_t
);
1913 usb_conv_info
->interfaceClass
= IF_CLASS_UNKNOWN
;
1914 usb_conv_info
->interfaceSubclass
= IF_SUBCLASS_UNKNOWN
;
1915 usb_conv_info
->interfaceProtocol
= IF_PROTOCOL_UNKNOWN
;
1916 usb_conv_info
->deviceVendor
= DEV_VENDOR_UNKNOWN
;
1917 usb_conv_info
->deviceProduct
= DEV_PRODUCT_UNKNOWN
;
1918 usb_conv_info
->deviceVersion
= DEV_VERSION_UNKNOWN
;
1919 usb_conv_info
->alt_settings
= wmem_array_new(wmem_file_scope(), sizeof(usb_alt_setting_t
));
1920 usb_conv_info
->transactions
= wmem_tree_new(wmem_file_scope());
1921 usb_conv_info
->descriptor_transfer_type
= URB_UNKNOWN
;
1922 usb_conv_info
->max_packet_size
= 0;
1924 conversation_add_proto_data(conversation
, proto_usb
, usb_conv_info
);
1927 return usb_conv_info
;
1931 /* urb_info_t contains some components that are valid only for one specific packet
1932 clear_usb_conv_tmp_data() clears these components, it should be called
1933 before we dissect a new packet */
1934 static void clear_usb_conv_tmp_data(urb_info_t
*urb
)
1936 /* caller must have checked that urb!= NULL */
1938 urb
->direction
= P2P_DIR_UNKNOWN
;
1939 urb
->transfer_type
= URB_UNKNOWN
;
1940 urb
->is_request
= false;
1941 urb
->is_setup
= false;
1942 urb
->setup_requesttype
= 0;
1943 urb
->speed
= USB_SPEED_UNKNOWN
;
1945 /* when we parse the configuration, interface and endpoint
1946 descriptors, we store the current interface class in endpoint 0's
1949 this must be cleared since endpoint 0 does not belong to any
1952 we used to clear these info in dissect_usb_configuration_descriptor()
1953 this doesn't work when the descriptor parsing throws an exception */
1955 if (urb
->conv
&& (urb
->endpoint
== 0)) {
1956 urb
->conv
->interfaceClass
= IF_CLASS_UNKNOWN
;
1957 urb
->conv
->interfaceSubclass
= IF_SUBCLASS_UNKNOWN
;
1958 urb
->conv
->interfaceProtocol
= IF_PROTOCOL_UNKNOWN
;
1962 static conversation_t
*
1963 get_usb_conversation(packet_info
*pinfo
,
1964 address
*src_addr
, address
*dst_addr
,
1965 uint32_t src_endpoint
, uint32_t dst_endpoint
)
1967 conversation_t
*conversation
;
1970 * Do we have a conversation for this connection?
1972 conversation
= find_conversation(pinfo
->num
,
1974 conversation_pt_to_conversation_type(pinfo
->ptype
),
1975 src_endpoint
, dst_endpoint
, 0);
1977 return conversation
;
1980 /* We don't yet have a conversation, so create one. */
1981 conversation
= conversation_new(pinfo
->num
,
1983 conversation_pt_to_conversation_type(pinfo
->ptype
),
1984 src_endpoint
, dst_endpoint
, 0);
1985 return conversation
;
1988 /* Fetch or create usb_conv_info for a specified interface. */
1990 get_usb_iface_conv_info(packet_info
*pinfo
, uint8_t interface_num
)
1992 conversation_t
*conversation
;
1995 if_port
= GUINT32_TO_LE(INTERFACE_PORT
| interface_num
);
1997 if (pinfo
->srcport
== NO_ENDPOINT
) {
1998 conversation
= get_usb_conversation(pinfo
, &pinfo
->src
, &pinfo
->dst
, pinfo
->srcport
, if_port
);
2000 conversation
= get_usb_conversation(pinfo
, &pinfo
->src
, &pinfo
->dst
, if_port
, pinfo
->destport
);
2003 return get_usb_conv_info(conversation
);
2006 /* Fetch usb_conv_info for specified endpoint, return NULL if not found */
2008 get_existing_usb_ep_conv_info(packet_info
* pinfo
, uint16_t bus_id
, uint16_t device_address
, int endpoint
)
2010 usb_address_t
*src_addr
= wmem_new0(pinfo
->pool
, usb_address_t
),
2011 *dst_addr
= wmem_new0(pinfo
->pool
, usb_address_t
);
2013 conversation_t
*conversation
;
2014 usb_conv_info_t
*usb_conv_info
= NULL
;
2016 src_addr
->bus_id
= GUINT16_TO_LE(bus_id
);
2017 src_addr
->device
= GUINT16_TO_LE(device_address
);
2018 src_addr
->endpoint
= GUINT32_TO_LE(endpoint
);
2020 dst_addr
->bus_id
= GUINT16_TO_LE(bus_id
);
2021 dst_addr
->device
= 0xffffffff;
2022 dst_addr
->endpoint
= NO_ENDPOINT
;
2024 set_address(&src
, usb_address_type
, USB_ADDR_LEN
, (char *)src_addr
);
2025 set_address(&dst
, usb_address_type
, USB_ADDR_LEN
, (char *)dst_addr
);
2027 conversation
= find_conversation(pinfo
->num
, &src
, &dst
,
2028 conversation_pt_to_conversation_type(PT_USB
),
2029 src_addr
->endpoint
, dst_addr
->endpoint
, 0);
2031 usb_conv_info
= (usb_conv_info_t
*)conversation_get_proto_data(conversation
, proto_usb
);
2033 return usb_conv_info
;
2036 static const char* usb_conv_get_filter_type(conv_item_t
* conv
, conv_filter_type_e filter
)
2038 if ((filter
== CONV_FT_SRC_ADDRESS
) && (conv
->src_address
.type
== usb_address_type
))
2041 if ((filter
== CONV_FT_DST_ADDRESS
) && (conv
->dst_address
.type
== usb_address_type
))
2044 if ((filter
== CONV_FT_ANY_ADDRESS
) && (conv
->src_address
.type
== usb_address_type
))
2047 return CONV_FILTER_INVALID
;
2050 static ct_dissector_info_t usb_ct_dissector_info
= {&usb_conv_get_filter_type
};
2052 static tap_packet_status
2053 usb_conversation_packet(void *pct
, packet_info
*pinfo
, epan_dissect_t
*edt _U_
, const void *vip _U_
, tap_flags_t flags
)
2055 conv_hash_t
*hash
= (conv_hash_t
*) pct
;
2056 hash
->flags
= flags
;
2058 add_conversation_table_data(hash
, &pinfo
->src
, &pinfo
->dst
, 0, 0, 1, pinfo
->fd
->pkt_len
, &pinfo
->rel_ts
, &pinfo
->abs_ts
, &usb_ct_dissector_info
, CONVERSATION_NONE
);
2060 return TAP_PACKET_REDRAW
;
2063 static const char* usb_endpoint_get_filter_type(endpoint_item_t
* endpoint
, conv_filter_type_e filter
)
2065 if ((filter
== CONV_FT_ANY_ADDRESS
) && (endpoint
->myaddress
.type
== usb_address_type
))
2068 return CONV_FILTER_INVALID
;
2072 usb_col_filter_str(const address
* addr _U_
, bool is_src
)
2074 return is_src
? "usb.src" : "usb.dst";
2077 static et_dissector_info_t usb_endpoint_dissector_info
= {&usb_endpoint_get_filter_type
};
2079 static tap_packet_status
2080 usb_endpoint_packet(void *pit
, packet_info
*pinfo
, epan_dissect_t
*edt _U_
, const void *vip _U_
, tap_flags_t flags
)
2082 conv_hash_t
*hash
= (conv_hash_t
*) pit
;
2083 hash
->flags
= flags
;
2085 /* Take two "add" passes per packet, adding for each direction, ensures that all
2086 packets are counted properly (even if address is sending to itself)
2087 XXX - this could probably be done more efficiently inside endpoint_table */
2088 add_endpoint_table_data(hash
, &pinfo
->src
, 0, true, 1, pinfo
->fd
->pkt_len
, &usb_endpoint_dissector_info
, ENDPOINT_NONE
);
2089 add_endpoint_table_data(hash
, &pinfo
->dst
, 0, false, 1, pinfo
->fd
->pkt_len
, &usb_endpoint_dissector_info
, ENDPOINT_NONE
);
2091 return TAP_PACKET_REDRAW
;
2094 /* SETUP dissectors */
2098 * These dissectors are used to dissect the setup part and the data
2099 * for URB_CONTROL_INPUT / CLEAR FEATURE
2105 dissect_usb_setup_clear_feature_request(packet_info
*pinfo _U_
, proto_tree
*tree
,
2106 tvbuff_t
*tvb
, int offset
,
2112 recip
= USB_RECIPIENT(urb
->usb_trans_info
->setup
.requesttype
);
2114 /* feature selector, zero/interface/endpoint */
2116 case RQT_SETUP_RECIPIENT_DEVICE
:
2117 proto_tree_add_item(tree
, hf_usb_device_wFeatureSelector
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
2119 proto_tree_add_item(tree
, hf_usb_index
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
2122 case RQT_SETUP_RECIPIENT_INTERFACE
:
2123 proto_tree_add_item(tree
, hf_usb_interface_wFeatureSelector
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
2125 proto_tree_add_item(tree
, hf_usb_wInterface
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
2128 case RQT_SETUP_RECIPIENT_ENDPOINT
:
2129 proto_tree_add_item(tree
, hf_usb_endpoint_wFeatureSelector
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
2131 proto_tree_add_item(tree
, hf_usb_wEndpoint
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
2134 case RQT_SETUP_RECIPIENT_OTHER
:
2136 proto_tree_add_item(tree
, hf_usb_value
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
2138 proto_tree_add_item(tree
, hf_usb_index
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
2142 /* No conversation information, so recipient type is unknown */
2143 proto_tree_add_item(tree
, hf_usb_value
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
2145 proto_tree_add_item(tree
, hf_usb_index
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
2150 proto_tree_add_item(tree
, hf_usb_length
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
2157 dissect_usb_setup_clear_feature_response(packet_info
*pinfo _U_
, proto_tree
*tree _U_
,
2158 tvbuff_t
*tvb _U_
, int offset
,
2159 urb_info_t
*urb _U_
)
2166 * These dissectors are used to dissect the setup part and the data
2167 * for URB_CONTROL_INPUT / GET CONFIGURATION
2173 dissect_usb_setup_get_configuration_response(packet_info
*pinfo _U_
, proto_tree
*tree _U_
,
2174 tvbuff_t
*tvb _U_
, int offset
,
2175 urb_info_t
*urb _U_
)
2177 proto_tree_add_item(tree
, hf_usb_bConfigurationValue
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2185 * These dissectors are used to dissect the setup part and the data
2186 * for URB_CONTROL_INPUT / GET DESCRIPTOR
2189 proto_item
* dissect_usb_descriptor_header(proto_tree
*tree
,
2190 tvbuff_t
*tvb
, int offset
,
2191 value_string_ext
*type_val_str
)
2194 proto_item
*length_item
;
2197 length_item
= proto_tree_add_item(tree
, hf_usb_bLength
,
2198 tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2201 desc_type
= tvb_get_uint8(tvb
, offset
);
2202 /* if the caller provided no class specific value string, we're
2203 * using the standard descriptor types */
2205 type_val_str
= &std_descriptor_type_vals_ext
;
2207 proto_tree_add_uint_format_value(tree
, hf_usb_bDescriptorType
,
2208 tvb
, offset
, 1, desc_type
, "0x%02x (%s)", desc_type
,
2209 val_to_str_ext_const(desc_type
, type_val_str
, "unknown"));
2215 dissect_max_packet_size0(packet_info
*pinfo
, proto_tree
*tree
,
2216 tvbuff_t
*tvb
, int offset
,
2217 urb_info_t
*urb
, bool other_speed
)
2220 uint32_t max_packet_size
;
2221 unsigned int sanitized_max_packet_size
;
2222 usb_speed_t speed
= urb
->speed
;
2224 item
= proto_tree_add_item_ret_uint(tree
, hf_usb_bMaxPacketSize0
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
, &max_packet_size
);
2226 if (speed
== USB_SPEED_FULL
)
2227 speed
= USB_SPEED_HIGH
;
2228 else if (speed
== USB_SPEED_HIGH
)
2229 speed
= USB_SPEED_FULL
;
2231 sanitized_max_packet_size
= sanitize_usb_max_packet_size(ENDPOINT_TYPE_CONTROL
, speed
, max_packet_size
);
2232 if (sanitized_max_packet_size
!= max_packet_size
) {
2233 expert_add_info_format(pinfo
, item
, &ei_usb_invalid_max_packet_size0
,
2234 "%s endpoint zero max packet size cannot be %u, using %d instead.",
2235 try_val_to_str(speed
, usb_speed_vals
), max_packet_size
, sanitized_max_packet_size
);
2241 dissect_usb_device_qualifier_descriptor(packet_info
*pinfo
, proto_tree
*parent_tree
,
2242 tvbuff_t
*tvb
, int offset
,
2248 int old_offset
= offset
;
2250 const char *description
;
2252 tree
= proto_tree_add_subtree(parent_tree
, tvb
, offset
, -1, ett_descriptor_device
, &item
, "DEVICE QUALIFIER DESCRIPTOR");
2254 dissect_usb_descriptor_header(tree
, tvb
, offset
, NULL
);
2258 proto_tree_add_item(tree
, hf_usb_bcdUSB
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
2261 protocol
= tvb_get_ntoh24(tvb
, offset
);
2262 description
= val_to_str_ext_const(protocol
, &usb_protocols_ext
, "");
2265 proto_tree_add_item(tree
, hf_usb_bDeviceClass
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2268 /* bDeviceSubClass */
2269 proto_tree_add_item(tree
, hf_usb_bDeviceSubClass
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2272 /* bDeviceProtocol */
2273 nitem
= proto_tree_add_item(tree
, hf_usb_bDeviceProtocol
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2275 proto_item_append_text(nitem
, " (%s)", description
);
2278 if (!pinfo
->fd
->visited
) {
2280 unsigned k_device_address
;
2281 unsigned k_frame_number
;
2282 wmem_tree_key_t key
[4];
2283 device_protocol_data_t
*device_protocol_data
;
2285 k_frame_number
= pinfo
->num
;
2286 k_device_address
= urb
->device_address
;
2287 k_bus_id
= urb
->bus_id
;
2290 key
[0].key
= &k_device_address
;
2292 key
[1].key
= &k_bus_id
;
2294 key
[2].key
= &k_frame_number
;
2298 device_protocol_data
= wmem_new(wmem_file_scope(), device_protocol_data_t
);
2299 device_protocol_data
->protocol
= protocol
;
2300 device_protocol_data
->bus_id
= urb
->bus_id
;
2301 device_protocol_data
->device_address
= urb
->device_address
;
2302 wmem_tree_insert32_array(device_to_protocol_table
, key
, device_protocol_data
);
2305 /* bMaxPacketSize0 */
2306 dissect_max_packet_size0(pinfo
, tree
, tvb
, offset
, urb
, true);
2309 /* bNumConfigurations */
2310 proto_tree_add_item(tree
, hf_usb_bNumConfigurations
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2313 /* one reserved byte */
2316 proto_item_set_len(item
, offset
-old_offset
);
2323 dissect_usb_device_descriptor(packet_info
*pinfo
, proto_tree
*parent_tree
,
2324 tvbuff_t
*tvb
, int offset
,
2330 int old_offset
= offset
;
2332 const char *description
;
2335 uint16_t product_id
;
2337 tree
= proto_tree_add_subtree(parent_tree
, tvb
, offset
, -1, ett_descriptor_device
, &item
, "DEVICE DESCRIPTOR");
2339 dissect_usb_descriptor_header(tree
, tvb
, offset
, NULL
);
2343 proto_tree_add_item(tree
, hf_usb_bcdUSB
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
2346 protocol
= tvb_get_ntoh24(tvb
, offset
);
2347 description
= val_to_str_ext_const(protocol
, &usb_protocols_ext
, "");
2350 proto_tree_add_item(tree
, hf_usb_bDeviceClass
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2353 /* bDeviceSubClass */
2354 proto_tree_add_item(tree
, hf_usb_bDeviceSubClass
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2357 /* bDeviceProtocol */
2358 nitem
= proto_tree_add_item(tree
, hf_usb_bDeviceProtocol
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2360 proto_item_append_text(nitem
, " (%s)", description
);
2363 /* bMaxPacketSize0 */
2364 dissect_max_packet_size0(pinfo
, tree
, tvb
, offset
, urb
, false);
2367 /* if request was only for the first 8 bytes */
2368 /* per 5.5.3 of USB2.0 Spec */
2369 if (8 == urb
->usb_trans_info
->setup
.wLength
) {
2370 proto_item_set_len(item
, offset
-old_offset
);
2375 proto_tree_add_item_ret_uint(tree
, hf_usb_idVendor
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
, &vendor_id
);
2376 urb
->conv
->deviceVendor
= (uint16_t)vendor_id
;
2380 product_id
= tvb_get_letohs(tvb
, offset
);
2381 urb
->conv
->deviceProduct
= product_id
;
2382 product
= (uint16_t)vendor_id
<< 16 | product_id
;
2384 proto_tree_add_uint_format_value(tree
, hf_usb_idProduct
, tvb
, offset
, 2, product_id
, "%s (0x%04x)",
2385 val_to_str_ext_const(product
, &ext_usb_products_vals
, "Unknown"),
2390 urb
->conv
->deviceVersion
= tvb_get_letohs(tvb
, offset
);
2391 proto_tree_add_item(tree
, hf_usb_bcdDevice
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
2394 if (!pinfo
->fd
->visited
) {
2396 unsigned k_device_address
;
2397 unsigned k_frame_number
;
2398 wmem_tree_key_t key
[4];
2399 device_product_data_t
*device_product_data
;
2400 device_protocol_data_t
*device_protocol_data
;
2402 k_frame_number
= pinfo
->num
;
2403 k_device_address
= urb
->device_address
;
2404 k_bus_id
= urb
->bus_id
;
2407 key
[0].key
= &k_device_address
;
2409 key
[1].key
= &k_bus_id
;
2411 key
[2].key
= &k_frame_number
;
2415 device_product_data
= wmem_new(wmem_file_scope(), device_product_data_t
);
2416 device_product_data
->vendor
= vendor_id
;
2417 device_product_data
->product
= product_id
;
2418 device_product_data
->device
= urb
->conv
->deviceVersion
;
2419 device_product_data
->bus_id
= urb
->bus_id
;
2420 device_product_data
->device_address
= urb
->device_address
;
2421 wmem_tree_insert32_array(device_to_product_table
, key
, device_product_data
);
2423 device_protocol_data
= wmem_new(wmem_file_scope(), device_protocol_data_t
);
2424 device_protocol_data
->protocol
= protocol
;
2425 device_protocol_data
->bus_id
= urb
->bus_id
;
2426 device_protocol_data
->device_address
= urb
->device_address
;
2428 wmem_tree_insert32_array(device_to_protocol_table
, key
, device_protocol_data
);
2432 proto_tree_add_item(tree
, hf_usb_iManufacturer
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2436 proto_tree_add_item(tree
, hf_usb_iProduct
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2440 urb
->conv
->iSerialNumber
= tvb_get_uint8(tvb
, offset
);
2441 proto_tree_add_item(tree
, hf_usb_iSerialNumber
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2444 /* bNumConfigurations */
2445 proto_tree_add_item(tree
, hf_usb_bNumConfigurations
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2448 proto_item_set_len(item
, offset
-old_offset
);
2455 dissect_usb_string_descriptor(packet_info
*pinfo _U_
, proto_tree
*parent_tree
,
2456 tvbuff_t
*tvb
, int offset
,
2461 int old_offset
= offset
;
2463 proto_item
*len_item
;
2464 usb_trans_info_t
*usb_trans_info
;
2466 usb_trans_info
= urb
->usb_trans_info
;
2468 tree
= proto_tree_add_subtree(parent_tree
, tvb
, offset
, -1, ett_descriptor_device
, &item
, "STRING DESCRIPTOR");
2470 len
= tvb_get_uint8(tvb
, offset
);
2471 /* The USB spec says that the languages / the string are UTF16 and not
2472 0-terminated, i.e. the length field must contain an even number */
2475 len_item
= proto_tree_add_item(tree
, hf_usb_bLength
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2476 expert_add_info(pinfo
, len_item
, &ei_usb_bLength_even
);
2478 /* bDescriptorType */
2479 proto_tree_add_item(tree
, hf_usb_bDescriptorType
, tvb
, offset
+1, 1, ENC_LITTLE_ENDIAN
);
2482 len_item
= dissect_usb_descriptor_header(tree
, tvb
, offset
, NULL
);
2485 /* Report an error, and give up, if the length is < 2 */
2487 expert_add_info(pinfo
, len_item
, &ei_usb_bLength_too_short
);
2491 if (!usb_trans_info
->u
.get_descriptor
.usb_index
) {
2492 /* list of languages */
2493 while (offset
>= old_offset
&& len
> (offset
- old_offset
)) {
2495 proto_tree_add_item(tree
, hf_usb_wLANGID
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
2500 /* handle case of host requesting only substring */
2501 uint8_t len_str
= MIN(len
-2, usb_trans_info
->setup
.wLength
-2);
2502 proto_tree_add_item(tree
, hf_usb_bString
, tvb
, offset
, len_str
, ENC_UTF_16
| ENC_LITTLE_ENDIAN
);
2506 proto_item_set_len(item
, offset
-old_offset
);
2515 dissect_usb_interface_descriptor(packet_info
*pinfo
, proto_tree
*parent_tree
,
2516 tvbuff_t
*tvb
, int offset
,
2521 const char *class_str
= NULL
;
2522 int old_offset
= offset
;
2524 uint8_t interface_num
;
2525 uint8_t alt_setting
;
2526 usb_trans_info_t
*usb_trans_info
;
2528 usb_trans_info
= urb
->usb_trans_info
;
2530 tree
= proto_tree_add_subtree(parent_tree
, tvb
, offset
, -1, ett_descriptor_device
, &item
, "INTERFACE DESCRIPTOR");
2532 len
= tvb_get_uint8(tvb
, offset
);
2533 dissect_usb_descriptor_header(tree
, tvb
, offset
, NULL
);
2536 /* bInterfaceNumber */
2537 interface_num
= tvb_get_uint8(tvb
, offset
);
2538 proto_tree_add_item(tree
, hf_usb_bInterfaceNumber
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2539 urb
->conv
->interfaceNum
= interface_num
;
2542 /* bAlternateSetting */
2543 alt_setting
= tvb_get_uint8(tvb
, offset
);
2544 proto_tree_add_item(tree
, hf_usb_bAlternateSetting
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2548 proto_tree_add_item(tree
, hf_usb_bNumEndpoints
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2551 /* bInterfaceClass */
2552 proto_tree_add_item(tree
, hf_usb_bInterfaceClass
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2553 /* save the class so we can access it later in the endpoint descriptor */
2554 urb
->conv
->interfaceClass
= tvb_get_uint8(tvb
, offset
);
2556 class_str
= val_to_str_ext(urb
->conv
->interfaceClass
, &usb_class_vals_ext
, "unknown (0x%X)");
2557 proto_item_append_text(item
, " (%u.%u): class %s", interface_num
, alt_setting
, class_str
);
2559 if (!pinfo
->fd
->visited
) {
2560 usb_alt_setting_t alternate_setting
;
2562 /* Register conversation for this interface in case CONTROL messages are sent to it */
2563 usb_trans_info
->interface_info
= get_usb_iface_conv_info(pinfo
, interface_num
);
2565 alternate_setting
.altSetting
= alt_setting
;
2566 alternate_setting
.interfaceClass
= tvb_get_uint8(tvb
, offset
);
2567 alternate_setting
.interfaceSubclass
= tvb_get_uint8(tvb
, offset
+1);
2568 alternate_setting
.interfaceProtocol
= tvb_get_uint8(tvb
, offset
+2);
2569 alternate_setting
.interfaceNum
= interface_num
;
2570 wmem_array_append_one(usb_trans_info
->interface_info
->alt_settings
, alternate_setting
);
2572 if (alt_setting
== 0) {
2573 /* By default let's assume alternate setting 0 will be used */
2575 usb_trans_info
->interface_info
->interfaceClass
= alternate_setting
.interfaceClass
;
2576 usb_trans_info
->interface_info
->interfaceSubclass
= alternate_setting
.interfaceSubclass
;
2577 usb_trans_info
->interface_info
->interfaceProtocol
= alternate_setting
.interfaceProtocol
;
2578 usb_trans_info
->interface_info
->interfaceNum
= alternate_setting
.interfaceNum
;
2579 usb_trans_info
->interface_info
->deviceVendor
= urb
->conv
->deviceVendor
;
2580 usb_trans_info
->interface_info
->deviceProduct
= urb
->conv
->deviceProduct
;
2581 usb_trans_info
->interface_info
->deviceVersion
= urb
->conv
->deviceVersion
;
2586 /* bInterfaceSubClass */
2587 switch (urb
->conv
->interfaceClass
) {
2588 case IF_CLASS_AUDIO
:
2589 proto_tree_add_item(tree
, hf_usb_bInterfaceSubClass_audio
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2591 case IF_CLASS_COMMUNICATIONS
:
2592 proto_tree_add_item(tree
, hf_usb_bInterfaceSubClass_cdc
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2594 case IF_CLASS_MASS_STORAGE
:
2595 proto_tree_add_item(tree
, hf_usb_bInterfaceSubClass_massstorage
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2598 proto_tree_add_item(tree
, hf_usb_bInterfaceSubClass_hid
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2600 case IF_CLASS_MISCELLANEOUS
:
2601 proto_tree_add_item(tree
, hf_usb_bInterfaceSubClass_misc
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2603 case IF_CLASS_APPLICATION_SPECIFIC
:
2604 proto_tree_add_item(tree
, hf_usb_bInterfaceSubClass_app
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2607 proto_tree_add_item(tree
, hf_usb_bInterfaceSubClass
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2610 /* save the subclass so we can access it later in class-specific descriptors */
2611 urb
->conv
->interfaceSubclass
= tvb_get_uint8(tvb
, offset
);
2614 /* bInterfaceProtocol */
2615 switch (urb
->conv
->interfaceClass
) {
2616 case IF_CLASS_COMMUNICATIONS
:
2617 proto_tree_add_item(tree
, hf_usb_bInterfaceProtocol_cdc
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2619 case IF_CLASS_MASS_STORAGE
:
2620 proto_tree_add_item(tree
, hf_usb_bInterfaceProtocol_massstorage
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2622 case IF_CLASS_CDC_DATA
:
2623 proto_tree_add_item(tree
, hf_usb_bInterfaceProtocol_cdc_data
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2625 case IF_CLASS_APPLICATION_SPECIFIC
:
2626 switch (urb
->conv
->interfaceSubclass
) {
2628 proto_tree_add_item(tree
, hf_usb_bInterfaceProtocol_app_dfu
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2631 proto_tree_add_item(tree
, hf_usb_bInterfaceProtocol_app_irda
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2634 proto_tree_add_item(tree
, hf_usb_bInterfaceProtocol_app_usb_test_and_measurement
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2637 proto_tree_add_item(tree
, hf_usb_bInterfaceProtocol
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2641 if (urb
->conv
->interfaceSubclass
== 1) {
2642 proto_tree_add_item(tree
, hf_usb_bInterfaceProtocol_hid_boot
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2646 proto_tree_add_item(tree
, hf_usb_bInterfaceProtocol
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2650 proto_tree_add_item(tree
, hf_usb_bInterfaceProtocol
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2653 urb
->conv
->interfaceProtocol
= tvb_get_uint8(tvb
, offset
);
2657 proto_tree_add_item(tree
, hf_usb_iInterface
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2660 proto_item_set_len(item
, len
);
2662 if (offset
< old_offset
+len
) {
2663 /* skip unknown records */
2664 offset
= old_offset
+ len
;
2671 const true_false_string tfs_endpoint_direction
= {
2676 void dissect_usb_endpoint_address(proto_tree
*tree
, tvbuff_t
*tvb
, int offset
)
2678 proto_item
*endpoint_item
;
2679 proto_tree
*endpoint_tree
;
2682 endpoint_item
= proto_tree_add_item(tree
, hf_usb_bEndpointAddress
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2683 endpoint_tree
= proto_item_add_subtree(endpoint_item
, ett_configuration_bEndpointAddress
);
2685 endpoint
= tvb_get_uint8(tvb
, offset
);
2686 proto_tree_add_item(endpoint_tree
, hf_usb_bEndpointAddress_direction
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2687 proto_item_append_text(endpoint_item
, " %s", (endpoint
&0x80)?"IN":"OUT");
2688 proto_tree_add_item(endpoint_tree
, hf_usb_bEndpointAddress_number
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2689 proto_item_append_text(endpoint_item
, " Endpoint:%d", endpoint
&0x0f);
2693 sanitize_usb_max_packet_size(uint8_t ep_type
, usb_speed_t speed
,
2694 unsigned int max_packet_size
)
2696 unsigned int sanitized_ep_size
= USB_MPS_EP_SIZE(max_packet_size
);
2697 unsigned int sanitized_adtnl
= USB_MPS_ADDNL(max_packet_size
);
2700 sanitized_adtnl
= 0;
2702 case ENDPOINT_TYPE_CONTROL
:
2703 /* 8 is the only allowed value */
2704 sanitized_ep_size
= 8;
2706 case ENDPOINT_TYPE_INTERRUPT
:
2707 if (max_packet_size
> 8)
2708 sanitized_ep_size
= 8;
2715 case USB_SPEED_FULL
:
2716 sanitized_adtnl
= 0;
2718 case ENDPOINT_TYPE_CONTROL
:
2719 case ENDPOINT_TYPE_BULK
:
2720 /* Allowed values are: 8, 16, 32 and 64 */
2721 if (max_packet_size
> 32)
2722 sanitized_ep_size
= 64;
2723 else if (max_packet_size
> 16)
2724 sanitized_ep_size
= 32;
2725 else if (max_packet_size
> 8)
2726 sanitized_ep_size
= 16;
2728 sanitized_ep_size
= 8;
2730 case ENDPOINT_TYPE_INTERRUPT
:
2731 if (max_packet_size
> 64)
2732 sanitized_ep_size
= 64;
2734 case ENDPOINT_TYPE_ISOCHRONOUS
:
2735 if (max_packet_size
> 1023)
2736 sanitized_ep_size
= 1023;
2742 case USB_SPEED_HIGH
:
2744 case ENDPOINT_TYPE_CONTROL
:
2745 sanitized_adtnl
= 0;
2746 /* 64 is the only allowed value */
2747 sanitized_ep_size
= 64;
2749 case ENDPOINT_TYPE_BULK
:
2750 sanitized_adtnl
= 0;
2751 /* 512 is the only allowed value */
2752 sanitized_ep_size
= 512;
2754 case ENDPOINT_TYPE_INTERRUPT
:
2755 case ENDPOINT_TYPE_ISOCHRONOUS
:
2756 /* If endpoint max packet size is out of range for high-bandwidth
2757 * endpoint, treat the endpoint as a standard one.
2759 if ((sanitized_adtnl
> 2) ||
2760 ((sanitized_adtnl
== 2) && (max_packet_size
< 683)) ||
2761 ((sanitized_adtnl
== 1) && (max_packet_size
< 513)))
2762 sanitized_adtnl
= 0;
2763 if (max_packet_size
> 1024)
2764 sanitized_ep_size
= 1024;
2770 case USB_SPEED_UNKNOWN
:
2775 return USB_MPS(sanitized_ep_size
, sanitized_adtnl
);
2778 static char *usb_max_packet_size_str(unsigned int max_packet_size
)
2780 unsigned int ep_size
= USB_MPS_EP_SIZE(max_packet_size
);
2781 unsigned int addnl
= USB_MPS_ADDNL(max_packet_size
);
2783 if (addnl
== 1 || addnl
== 2) {
2784 return wmem_strdup_printf(wmem_packet_scope(), "%u * %u = %u",
2785 addnl
+ 1, ep_size
, (addnl
+ 1) * ep_size
);
2787 return wmem_strdup_printf(wmem_packet_scope(), "%u", ep_size
);
2792 dissect_usb_endpoint_descriptor(packet_info
*pinfo
, proto_tree
*parent_tree
,
2793 tvbuff_t
*tvb
, int offset
,
2795 uint8_t *out_ep_type
, usb_speed_t speed
)
2799 proto_item
*ep_attrib_item
;
2800 proto_tree
*ep_attrib_tree
;
2801 proto_item
*ep_type_item
;
2802 proto_item
*ep_pktsize_item
;
2803 proto_tree
*ep_pktsize_tree
;
2804 int old_offset
= offset
;
2808 uint32_t max_packet_size
;
2809 char *max_packet_size_str
;
2810 unsigned int sanitized_max_packet_size
;
2811 usb_trans_info_t
*usb_trans_info
= NULL
;
2812 conversation_t
*conversation
= NULL
;
2815 usb_trans_info
= urb
->usb_trans_info
;
2817 tree
= proto_tree_add_subtree(parent_tree
, tvb
, offset
, -1, ett_descriptor_device
, &item
, "ENDPOINT DESCRIPTOR");
2819 len
= tvb_get_uint8(tvb
, offset
);
2820 dissect_usb_descriptor_header(tree
, tvb
, offset
, NULL
);
2823 endpoint
= tvb_get_uint8(tvb
, offset
);
2824 dissect_usb_endpoint_address(tree
, tvb
, offset
);
2827 /* Together with class from the interface descriptor we know what kind
2828 * of class the device at endpoint is.
2829 * Make sure a conversation exists for this endpoint and attach a
2830 * usb_conv_into_t structure to it.
2832 * All endpoints for the same interface descriptor share the same
2833 * usb_conv_info structure.
2835 if ((!pinfo
->fd
->visited
) && usb_trans_info
&& usb_trans_info
->interface_info
) {
2836 if (pinfo
->destport
== NO_ENDPOINT
) {
2838 usb_address_t
*usb_addr
= wmem_new0(pinfo
->pool
, usb_address_t
);
2840 /* packet is sent from a USB device's endpoint 0 to the host
2841 * replace endpoint 0 with the endpoint of this descriptor
2842 * and find the corresponding conversation
2844 usb_addr
->bus_id
= ((const usb_address_t
*)(pinfo
->src
.data
))->bus_id
;
2845 usb_addr
->device
= ((const usb_address_t
*)(pinfo
->src
.data
))->device
;
2846 usb_addr
->endpoint
= GUINT32_TO_LE(endpoint
);
2847 set_address(&tmp_addr
, usb_address_type
, USB_ADDR_LEN
, (char *)usb_addr
);
2848 conversation
= get_usb_conversation(pinfo
, &tmp_addr
, &pinfo
->dst
, usb_addr
->endpoint
, pinfo
->destport
);
2852 usb_trans_info
->interface_endpoint
= endpoint
;
2853 conversation_add_proto_data(conversation
, proto_usb
, usb_trans_info
->interface_info
);
2858 ep_type
= ENDPOINT_TYPE(tvb_get_uint8(tvb
, offset
));
2860 *out_ep_type
= ep_type
;
2863 ep_attrib_item
= proto_tree_add_item(tree
, hf_usb_bmAttributes
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2864 ep_attrib_tree
= proto_item_add_subtree(ep_attrib_item
, ett_endpoint_bmAttributes
);
2866 ep_type_item
= proto_tree_add_item(ep_attrib_tree
, hf_usb_bEndpointAttributeTransfer
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2867 if (ep_type
==USB_EP_ISOCHRONOUS
) {
2868 proto_tree_add_item(ep_attrib_tree
, hf_usb_bEndpointAttributeSynchonisation
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2869 proto_tree_add_item(ep_attrib_tree
, hf_usb_bEndpointAttributeBehaviour
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2872 /* At Low-Speed, only control and interrupt transfers are allowed */
2873 if ((speed
== USB_SPEED_LOW
) && !((ep_type
== USB_EP_CONTROL
) || (ep_type
== USB_EP_INTERRUPT
))) {
2874 expert_add_info(pinfo
, ep_type_item
, &ei_usb_invalid_endpoint_type
);
2878 /* wMaxPacketSize */
2879 max_packet_size
= tvb_get_uint16(tvb
, offset
, ENC_LITTLE_ENDIAN
);
2880 max_packet_size_str
= usb_max_packet_size_str(max_packet_size
);
2881 ep_pktsize_item
= proto_tree_add_uint_format_value(tree
, hf_usb_wMaxPacketSize
,
2882 tvb
, offset
, 2, max_packet_size
, "%s", max_packet_size_str
);
2883 ep_pktsize_tree
= proto_item_add_subtree(ep_pktsize_item
, ett_endpoint_wMaxPacketSize
);
2884 if ((ep_type
== ENDPOINT_TYPE_INTERRUPT
) || (ep_type
== ENDPOINT_TYPE_ISOCHRONOUS
)) {
2885 proto_tree_add_item(ep_pktsize_tree
, hf_usb_wMaxPacketSize_slots
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
2887 proto_tree_add_item(ep_pktsize_tree
, hf_usb_wMaxPacketSize_size
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
2888 sanitized_max_packet_size
= sanitize_usb_max_packet_size(ep_type
, speed
, max_packet_size
);
2889 if (sanitized_max_packet_size
!= max_packet_size
) {
2890 expert_add_info_format(pinfo
, ep_pktsize_item
, &ei_usb_invalid_max_packet_size
,
2891 "%s %s endpoint max packet size cannot be %s, using %s instead.",
2892 try_val_to_str(speed
, usb_speed_vals
), try_val_to_str(ep_type
, usb_bmAttributes_transfer_vals
),
2893 max_packet_size_str
, usb_max_packet_size_str(sanitized_max_packet_size
));
2894 max_packet_size
= sanitized_max_packet_size
;
2899 usb_conv_info_t
* endpoint_conv_info
= get_usb_conv_info(conversation
);
2900 uint8_t transfer_type
;
2903 case ENDPOINT_TYPE_CONTROL
:
2904 transfer_type
= URB_CONTROL
;
2906 case ENDPOINT_TYPE_ISOCHRONOUS
:
2907 transfer_type
= URB_ISOCHRONOUS
;
2909 case ENDPOINT_TYPE_BULK
:
2910 transfer_type
= URB_BULK
;
2912 case ENDPOINT_TYPE_INTERRUPT
:
2913 transfer_type
= URB_INTERRUPT
;
2916 transfer_type
= URB_UNKNOWN
;
2919 endpoint_conv_info
->descriptor_transfer_type
= transfer_type
;
2920 endpoint_conv_info
->max_packet_size
= max_packet_size
;
2924 proto_tree_add_item(tree
, hf_usb_bInterval
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2927 /* bRefresh and bSynchAddress are present only in the Audio 1.0
2928 * Endpoint Descriptors, so observe the descriptor size */
2929 if (urb
&& urb
->conv
&& (urb
->conv
->interfaceClass
== IF_CLASS_AUDIO
)
2931 proto_tree_add_item(tree
, hf_usb_audio_bRefresh
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2934 proto_tree_add_item(tree
, hf_usb_audio_bSynchAddress
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2938 proto_item_set_len(item
, len
);
2940 if (offset
< old_offset
+len
) {
2941 /* mark unknown records as undecoded */
2942 proto_tree_add_expert(tree
, pinfo
, &ei_usb_undecoded
, tvb
, offset
, old_offset
+ len
- offset
);
2943 offset
= old_offset
+ len
;
2950 dissect_usb_endpoint_companion_descriptor(packet_info
*pinfo
, proto_tree
*parent_tree
,
2951 tvbuff_t
*tvb
, int offset
,
2952 urb_info_t
*urb _U_
,
2957 proto_item
*ep_attrib_item
;
2958 proto_tree
*ep_attrib_tree
;
2959 int old_offset
= offset
;
2962 tree
= proto_tree_add_subtree(parent_tree
, tvb
, offset
, -1, ett_descriptor_device
, &item
, "SUPERSPEED ENDPOINT COMPANION DESCRIPTOR");
2964 len
= tvb_get_uint8(tvb
, offset
);
2965 dissect_usb_descriptor_header(tree
, tvb
, offset
, NULL
);
2969 proto_tree_add_item(tree
, hf_usb_bMaxBurst
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2973 ep_attrib_item
= proto_tree_add_item(tree
, hf_usb_bmAttributes
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2975 case ENDPOINT_TYPE_CONTROL
:
2977 case ENDPOINT_TYPE_ISOCHRONOUS
:
2978 ep_attrib_tree
= proto_item_add_subtree(ep_attrib_item
, ett_endpoint_bmAttributes
);
2979 proto_tree_add_item(ep_attrib_tree
, hf_usb_bSSEndpointAttributeIsoMult
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2981 case ENDPOINT_TYPE_BULK
:
2982 ep_attrib_tree
= proto_item_add_subtree(ep_attrib_item
, ett_endpoint_bmAttributes
);
2983 proto_tree_add_item(ep_attrib_tree
, hf_usb_bSSEndpointAttributeBulkMaxStreams
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
2985 case ENDPOINT_TYPE_INTERRUPT
:
2988 expert_add_info(pinfo
, ep_attrib_item
, &ei_usb_ss_ep_companion_before_ep
);
2993 /* wBytesPerInterval */
2994 proto_tree_add_item(tree
, hf_usb_wBytesPerInterval
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
2997 proto_item_set_len(item
, len
);
2999 if (offset
< old_offset
+ len
) {
3000 /* mark unknown records as undecoded */
3001 proto_tree_add_expert(tree
, pinfo
, &ei_usb_undecoded
, tvb
, offset
, old_offset
+ len
- offset
);
3002 offset
= old_offset
+ len
;
3010 dissect_usb_interface_assn_descriptor(packet_info
*pinfo _U_
, proto_tree
*parent_tree
,
3011 tvbuff_t
*tvb
, int offset
,
3012 urb_info_t
*urb _U_
)
3016 int old_offset
= offset
;
3018 tree
= proto_tree_add_subtree(parent_tree
, tvb
, offset
, -1, ett_descriptor_device
, &item
, "INTERFACE ASSOCIATION DESCRIPTOR");
3020 dissect_usb_descriptor_header(tree
, tvb
, offset
, NULL
);
3023 /* bFirstInterface */
3024 proto_tree_add_item(tree
, hf_usb_bFirstInterface
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
3027 /* bInterfaceCount */
3028 proto_tree_add_item(tree
, hf_usb_bInterfaceCount
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
3031 /* bFunctionClass */
3032 proto_tree_add_item(tree
, hf_usb_bFunctionClass
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
3035 /* bFunctionSubclass */
3036 proto_tree_add_item(tree
, hf_usb_bFunctionSubClass
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
3039 /* bFunctionProtocol */
3040 proto_tree_add_item(tree
, hf_usb_bFunctionProtocol
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
3044 proto_tree_add_item(tree
, hf_usb_iFunction
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
3047 proto_item_set_len(item
, offset
-old_offset
);
3053 dissect_usb_unknown_descriptor(packet_info
*pinfo _U_
, proto_tree
*parent_tree
,
3054 tvbuff_t
*tvb
, int offset
,
3055 urb_info_t
*urb _U_
)
3061 tree
= proto_tree_add_subtree(parent_tree
, tvb
, offset
, -1, ett_descriptor_device
, &item
, "UNKNOWN DESCRIPTOR");
3063 bLength
= tvb_get_uint8(tvb
, offset
);
3064 dissect_usb_descriptor_header(tree
, tvb
, offset
, NULL
);
3067 proto_item_set_len(item
, bLength
);
3073 static const true_false_string tfs_mustbeone
= {
3074 "Must be 1 for USB 1.1 and higher",
3075 "FIXME: Is this a USB 1.0 device"
3077 static const true_false_string tfs_selfpowered
= {
3078 "This device is SELF-POWERED",
3079 "This device is powered from the USB bus"
3081 static const true_false_string tfs_remotewakeup
= {
3082 "This device supports REMOTE WAKEUP",
3083 "This device does NOT support remote wakeup"
3086 dissect_usb_configuration_descriptor(packet_info
*pinfo _U_
, proto_tree
*parent_tree
,
3087 tvbuff_t
*tvb
, int offset
,
3088 urb_info_t
*urb
, usb_speed_t speed
)
3092 int old_offset
= offset
;
3094 proto_item
*flags_item
;
3095 proto_tree
*flags_tree
;
3097 uint8_t last_ep_type
= ENDPOINT_TYPE_NOT_SET
;
3098 proto_item
*power_item
;
3100 bool truncation_expected
;
3101 usb_trans_info_t
*usb_trans_info
;
3103 usb_trans_info
= urb
->usb_trans_info
;
3105 urb
->conv
->interfaceClass
= IF_CLASS_UNKNOWN
;
3106 urb
->conv
->interfaceSubclass
= IF_SUBCLASS_UNKNOWN
;
3107 urb
->conv
->interfaceProtocol
= IF_PROTOCOL_UNKNOWN
;
3109 tree
= proto_tree_add_subtree(parent_tree
, tvb
, offset
, -1, ett_descriptor_device
, &item
, "CONFIGURATION DESCRIPTOR");
3111 dissect_usb_descriptor_header(tree
, tvb
, offset
, NULL
);
3115 proto_tree_add_item(tree
, hf_usb_wTotalLength
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3116 len
= tvb_get_letohs(tvb
, offset
);
3119 /* bNumInterfaces */
3120 proto_tree_add_item(tree
, hf_usb_bNumInterfaces
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
3123 /* bConfigurationValue */
3124 proto_tree_add_item(tree
, hf_usb_bConfigurationValue
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
3127 /* iConfiguration */
3128 proto_tree_add_item(tree
, hf_usb_iConfiguration
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
3132 flags_item
= proto_tree_add_item(tree
, hf_usb_configuration_bmAttributes
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
3133 flags_tree
= proto_item_add_subtree(flags_item
, ett_configuration_bmAttributes
);
3135 flags
= tvb_get_uint8(tvb
, offset
);
3136 proto_tree_add_item(flags_tree
, hf_usb_configuration_legacy10buspowered
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
3137 proto_tree_add_item(flags_tree
, hf_usb_configuration_selfpowered
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
3138 proto_item_append_text(flags_item
, " %sSELF-POWERED", (flags
&0x40)?"":"NOT ");
3139 proto_tree_add_item(flags_tree
, hf_usb_configuration_remotewakeup
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
3140 proto_item_append_text(flags_item
, " %sREMOTE-WAKEUP", (flags
&0x20)?"":"NO ");
3144 power_item
= proto_tree_add_item(tree
, hf_usb_bMaxPower
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
3145 power
= tvb_get_uint8(tvb
, offset
);
3146 proto_item_append_text(power_item
, " (%dmA)", power
*2);
3149 /* initialize interface_info to NULL */
3150 usb_trans_info
->interface_info
= NULL
;
3152 truncation_expected
= (usb_trans_info
->setup
.wLength
< len
);
3154 /* decode any additional interface and endpoint descriptors */
3155 while(len
>(offset
-old_offset
)) {
3157 uint8_t next_len
= 0;
3158 int remaining_tvb
, remaining_len
;
3159 tvbuff_t
*next_tvb
= NULL
;
3161 /* Handle truncated descriptors appropriately */
3162 remaining_tvb
= tvb_reported_length_remaining(tvb
, offset
);
3163 if (remaining_tvb
> 0) {
3164 next_len
= tvb_get_uint8(tvb
, offset
);
3165 remaining_len
= len
- (offset
- old_offset
);
3166 if ((next_len
< 3) || (next_len
> remaining_len
)) {
3167 proto_tree_add_expert_format(parent_tree
, pinfo
, &ei_usb_desc_length_invalid
,
3168 tvb
, offset
, 1, "Invalid descriptor length: %u", next_len
);
3174 if ((remaining_tvb
== 0) || (next_len
> remaining_tvb
)) {
3175 if (truncation_expected
)
3179 next_type
= tvb_get_uint8(tvb
, offset
+1);
3181 case USB_DT_INTERFACE
:
3182 offset
= dissect_usb_interface_descriptor(pinfo
, parent_tree
, tvb
, offset
, urb
);
3184 case USB_DT_ENDPOINT
:
3185 offset
= dissect_usb_endpoint_descriptor(pinfo
, parent_tree
, tvb
, offset
, urb
, &last_ep_type
, speed
);
3187 case USB_DT_INTERFACE_ASSOCIATION
:
3188 offset
= dissect_usb_interface_assn_descriptor(pinfo
, parent_tree
, tvb
, offset
, urb
);
3190 case USB_DT_SUPERSPEED_EP_COMPANION
:
3191 offset
= dissect_usb_endpoint_companion_descriptor(pinfo
, parent_tree
, tvb
, offset
, urb
, last_ep_type
);
3194 next_tvb
= tvb_new_subset_length(tvb
, offset
, next_len
);
3195 if (dissector_try_uint_with_data(usb_descriptor_dissector_table
, urb
->conv
->interfaceClass
, next_tvb
, pinfo
, parent_tree
, true, urb
)) {
3198 offset
= dissect_usb_unknown_descriptor(pinfo
, parent_tree
, tvb
, offset
, urb
);
3201 /* was: return offset; */
3205 proto_item_set_len(item
, offset
-old_offset
);
3210 /* https://wicg.github.io/webusb/#webusb-platform-capability-descriptor */
3212 dissect_webusb_platform_descriptor(packet_info
*pinfo _U_
, proto_tree
*tree
,
3213 tvbuff_t
*tvb
, int offset
,
3214 urb_info_t
*urb _U_
)
3216 proto_tree_add_item(tree
, hf_usb_webusb_bcdVersion
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3219 proto_tree_add_item(tree
, hf_usb_webusb_bVendorCode
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
3222 proto_tree_add_item(tree
, hf_usb_webusb_iLandingPage
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
3228 /* Microsoft OS 2.0 Descriptors Specification */
3230 dissect_msos20_platform_descriptor(packet_info
*pinfo _U_
, proto_tree
*tree
,
3231 tvbuff_t
*tvb
, int offset
,
3232 urb_info_t
*urb _U_
)
3234 proto_tree_add_item(tree
, hf_usb_msos20_dwWindowsVersion
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
3237 proto_tree_add_item(tree
, hf_usb_msos20_wMSOSDescriptorSetTotalLength
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3240 proto_tree_add_item(tree
, hf_usb_msos20_bMS_VendorCode
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
3243 proto_tree_add_item(tree
, hf_usb_msos20_bAltEnumCode
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
3252 int (*dissect
)(packet_info
*pinfo
, proto_tree
*tree
,
3253 tvbuff_t
*tvb
, int offset
,
3255 } bos_platform_uuids
[] = {
3256 { {0x3408b638, 0x09a9, 0x47a0, {0x8b, 0xfd, 0xa0, 0x76, 0x88, 0x15, 0xb6, 0x65}},
3257 "WebUSB Platform Capability descriptor",
3258 dissect_webusb_platform_descriptor
},
3260 { {0xd8dd60df, 0x4589, 0x4cc7, {0x9c, 0xd2, 0x65, 0x9d, 0x9e, 0x64, 0x8a, 0x9f}},
3261 "Microsoft OS 2.0 Platform Capability descriptor",
3262 dissect_msos20_platform_descriptor
},
3265 /* USB 3.2 Specification Table 9-13. Format of a Device Capability Descriptor */
3267 dissect_usb_device_capability_descriptor(packet_info
*pinfo
, proto_tree
*tree
,
3268 tvbuff_t
*tvb
, int offset
,
3272 const char *cap_text
;
3276 proto_tree_add_item(tree
, hf_usb_bDevCapabilityType
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
3277 cap_type
= tvb_get_uint8(tvb
, offset
);
3280 cap_text
= try_val_to_str_ext(cap_type
, &usb_capability_vals_ext
);
3282 if (cap_type
== BOS_CAP_USB_20_EXTENSION
) {
3283 /* USB 2.0 ECN Errata for Link Power Management */
3284 static int * const usb20ext_fields
[] = {
3285 &hf_usb_usb20ext_LPM
,
3286 &hf_usb_usb20ext_BESL_HIRD
,
3287 &hf_usb_usb20ext_baseline_BESL_valid
,
3288 &hf_usb_usb20ext_deep_BESL_valid
,
3289 &hf_usb_usb20ext_baseline_BESL
,
3290 &hf_usb_usb20ext_deep_BESL
,
3294 proto_tree_add_bitmask_with_flags(tree
, tvb
, offset
, hf_usb_usb20ext_bmAttributes
,
3295 ett_usb20ext_bmAttributes
, usb20ext_fields
, ENC_LITTLE_ENDIAN
, BMT_NO_APPEND
);
3297 } else if (cap_type
== BOS_CAP_PLATFORM
) {
3298 proto_tree_add_item(tree
, hf_usb_bReserved
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
3301 tvb_get_letohguid(tvb
, offset
, &uuid
);
3302 proto_tree_add_guid(tree
, hf_usb_PlatformCapabilityUUID
, tvb
, offset
, 16, &uuid
);
3305 for (i
= 0; i
< array_length(bos_platform_uuids
); i
++) {
3306 if (guid_cmp(&bos_platform_uuids
[i
].uuid
, &uuid
) == 0) {
3307 offset
= bos_platform_uuids
[i
].dissect(pinfo
, tree
, tvb
, offset
, urb
);
3308 cap_text
= bos_platform_uuids
[i
].text
;
3312 } else if (cap_type
== BOS_CAP_SUPERSPEED_USB
) {
3313 /* USB 3.2 Specification 9.6.2.2 SuperSpeed USB Device Capability */
3314 static int * const usb_ss_bmAtrributes_fields
[] = {
3315 &hf_usb_ss_bmAttributes_reserved0
,
3316 &hf_usb_ss_bmAttributes_LTM
,
3317 &hf_usb_ss_bmAttributes_reserved7_2
,
3320 static int * const usb_ss_wSpeedSupported_fields
[] = {
3321 &hf_usb_ss_wSpeedSupported_LS
,
3322 &hf_usb_ss_wSpeedSupported_FS
,
3323 &hf_usb_ss_wSpeedSupported_HS
,
3324 &hf_usb_ss_wSpeedSupported_Gen1
,
3325 &hf_usb_ss_wSpeedSupported_reserved
,
3329 proto_tree_add_bitmask(tree
, tvb
, offset
, hf_usb_ss_bmAttributes
,
3330 ett_ss_bmAttributes
, usb_ss_bmAtrributes_fields
, ENC_LITTLE_ENDIAN
);
3332 proto_tree_add_bitmask(tree
, tvb
, offset
, hf_usb_ss_wSpeedSupported
,
3333 ett_ss_wSpeedSupported
, usb_ss_wSpeedSupported_fields
, ENC_LITTLE_ENDIAN
);
3335 proto_tree_add_item(tree
, hf_usb_ss_bFunctionalitySupport
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
3337 proto_tree_add_item(tree
, hf_usb_ss_bU1DevExitLat
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
3339 proto_tree_add_item(tree
, hf_usb_ss_wU2DevExitLat
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3344 proto_item_append_text(tree
, ": %s", cap_text
);
3350 /* USB 3.2 Specification 9.6.2 Binary Device Object Store (BOS) */
3352 dissect_usb_bos_descriptor(packet_info
*pinfo
, proto_tree
*parent_tree
,
3353 tvbuff_t
*tvb
, int offset
,
3358 int old_offset
= offset
;
3360 usb_trans_info_t
*usb_trans_info
;
3362 usb_trans_info
= urb
->usb_trans_info
;
3364 tree
= proto_tree_add_subtree(parent_tree
, tvb
, offset
, -1, ett_descriptor_device
, &item
, "BOS DESCRIPTOR");
3366 dissect_usb_descriptor_header(tree
, tvb
, offset
, NULL
);
3370 proto_tree_add_item(tree
, hf_usb_wTotalLength
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3371 total_len
= tvb_get_letohs(tvb
, offset
);
3374 proto_tree_add_item(tree
, hf_usb_bNumDeviceCaps
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
3377 if (offset
- old_offset
>= usb_trans_info
->setup
.wLength
) {
3378 /* Do not report the most common case where host finds out about
3379 * wTotalLength by requesting just BOS descriptor as Malformed Packet.
3380 * TODO: Generic handling of "host requested too few bytes" (which is
3381 * perfectly fine, but complicates dissection) because host is allowed
3382 * to request any number of bytes.
3387 /* Dissect capabilities */
3388 while (total_len
> (offset
- old_offset
)) {
3389 proto_item
*desc_item
;
3390 int prev_offset
= offset
;
3391 uint8_t desc_len
, desc_type
;
3393 tree
= proto_tree_add_subtree(parent_tree
, tvb
, offset
, -1, ett_descriptor_device
, &desc_item
, "DEVICE CAPABILITY DESCRIPTOR");
3395 item
= proto_tree_add_item(tree
, hf_usb_bLength
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
3396 desc_len
= tvb_get_uint8(tvb
, offset
);
3399 expert_add_info_format(pinfo
, item
, &ei_usb_bLength_too_short
, "Invalid Length (must be 3 or larger)");
3403 item
= proto_tree_add_item(tree
, hf_usb_bDescriptorType
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
3404 desc_type
= tvb_get_uint8(tvb
, offset
);
3406 if (desc_type
== USB_DT_DEVICE_CAPABILITY
) {
3407 tvbuff_t
*desc_tvb
= tvb_new_subset_length(tvb
, offset
, desc_len
- 2);
3408 offset
+= dissect_usb_device_capability_descriptor(pinfo
, tree
, desc_tvb
, 0, urb
);
3410 expert_add_info(pinfo
, item
, &ei_usb_unexpected_desc_type
);
3411 /* Already reported unexpected type, do not mark rest as undecoded */
3412 offset
= prev_offset
+ desc_len
;
3415 if (offset
< prev_offset
+ desc_len
) {
3416 proto_tree_add_expert(tree
, pinfo
, &ei_usb_undecoded
, tvb
, offset
, prev_offset
+ desc_len
- offset
);
3417 offset
= prev_offset
+ desc_len
;
3419 proto_item_set_len(item
, offset
- prev_offset
);
3422 proto_item_set_len(item
, offset
- old_offset
);
3429 dissect_usb_setup_get_descriptor_request(packet_info
*pinfo
, proto_tree
*tree
,
3430 tvbuff_t
*tvb
, int offset
,
3433 usb_trans_info_t
*usb_trans_info
, trans_info
;
3436 usb_trans_info
= urb
->usb_trans_info
;
3438 usb_trans_info
= &trans_info
;
3440 /* descriptor index */
3441 proto_tree_add_item(tree
, hf_usb_descriptor_index
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
3442 usb_trans_info
->u
.get_descriptor
.usb_index
= tvb_get_uint8(tvb
, offset
);
3445 /* descriptor type */
3446 proto_tree_add_item(tree
, hf_usb_bDescriptorType
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
3447 usb_trans_info
->u
.get_descriptor
.type
= tvb_get_uint8(tvb
, offset
);
3449 col_append_fstr(pinfo
->cinfo
, COL_INFO
, " %s",
3450 val_to_str_ext(usb_trans_info
->u
.get_descriptor
.type
, &std_descriptor_type_vals_ext
, "Unknown type %u"));
3453 proto_tree_add_item(tree
, hf_usb_language_id
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3457 proto_tree_add_item(tree
, hf_usb_length
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3464 dissect_usb_setup_get_descriptor_response(packet_info
*pinfo
, proto_tree
*tree
,
3465 tvbuff_t
*tvb
, int offset
,
3468 usb_trans_info_t
*usb_trans_info
;
3471 usb_trans_info
= urb
->usb_trans_info
;
3474 col_append_fstr(pinfo
->cinfo
, COL_INFO
, " %s",
3475 val_to_str_ext(usb_trans_info
->u
.get_descriptor
.type
, &std_descriptor_type_vals_ext
, "Unknown type %u"));
3477 switch(usb_trans_info
->u
.get_descriptor
.type
) {
3478 case USB_DT_INTERFACE
:
3479 case USB_DT_ENDPOINT
:
3480 /* an interface or an endpoint descriptor can only be accessed
3481 as part of a configuration descriptor */
3484 offset
= dissect_usb_device_descriptor(pinfo
, tree
, tvb
, offset
, urb
);
3486 case USB_DT_OTHER_SPEED_CONFIG
:
3487 /* USB 2.0 Specification: 9.2.6.6 Speed Dependent Descriptors */
3488 if (speed
== USB_SPEED_FULL
)
3489 speed
= USB_SPEED_HIGH
;
3490 else if (speed
== USB_SPEED_HIGH
)
3491 speed
= USB_SPEED_FULL
;
3494 offset
= dissect_usb_configuration_descriptor(pinfo
, tree
, tvb
, offset
, urb
, speed
);
3497 offset
= dissect_usb_string_descriptor(pinfo
, tree
, tvb
, offset
, urb
);
3499 case USB_DT_DEVICE_QUALIFIER
:
3500 offset
= dissect_usb_device_qualifier_descriptor(pinfo
, tree
, tvb
, offset
, urb
);
3503 offset
= dissect_usb_bos_descriptor(pinfo
, tree
, tvb
, offset
, urb
);
3506 /* XXX dissect the descriptor coming back from the device */
3508 unsigned len
= tvb_reported_length_remaining(tvb
, offset
);
3509 proto_tree_add_bytes_format(tree
, hf_usb_get_descriptor_resp_generic
, tvb
, offset
, len
, NULL
,
3510 "GET DESCRIPTOR Response data (unknown descriptor type %u): %s",
3511 usb_trans_info
->u
.get_descriptor
.type
,
3512 tvb_bytes_to_str(pinfo
->pool
, tvb
, offset
, len
));
3513 offset
= offset
+ len
;
3523 * These dissectors are used to dissect the setup part and the data
3524 * for URB_CONTROL_INPUT / GET INTERFACE
3530 dissect_usb_setup_get_interface_request(packet_info
*pinfo _U_
, proto_tree
*tree
,
3531 tvbuff_t
*tvb
, int offset
,
3532 urb_info_t
*urb _U_
)
3535 proto_tree_add_item(tree
, hf_usb_value
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3539 proto_tree_add_item(tree
, hf_usb_wInterface
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3543 proto_tree_add_item(tree
, hf_usb_length
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3550 dissect_usb_setup_get_interface_response(packet_info
*pinfo _U_
, proto_tree
*tree
,
3551 tvbuff_t
*tvb
, int offset
,
3552 urb_info_t
*urb _U_
)
3554 /* alternate setting */
3555 proto_tree_add_item(tree
, hf_usb_bAlternateSetting
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
3563 * These dissectors are used to dissect the setup part and the data
3564 * for URB_CONTROL_INPUT / GET STATUS
3570 dissect_usb_setup_get_status_request(packet_info
*pinfo _U_
, proto_tree
*tree
,
3571 tvbuff_t
*tvb
, int offset
,
3572 urb_info_t
*urb _U_
)
3575 proto_tree_add_item(tree
, hf_usb_value
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3578 /* zero/interface/endpoint */
3582 recip
= USB_RECIPIENT(urb
->usb_trans_info
->setup
.requesttype
);
3585 case RQT_SETUP_RECIPIENT_INTERFACE
:
3586 proto_tree_add_item(tree
, hf_usb_wInterface
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3589 case RQT_SETUP_RECIPIENT_ENDPOINT
:
3590 proto_tree_add_item(tree
, hf_usb_wEndpoint
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3593 case RQT_SETUP_RECIPIENT_DEVICE
:
3594 case RQT_SETUP_RECIPIENT_OTHER
:
3596 proto_tree_add_item(tree
, hf_usb_index
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3600 proto_tree_add_item(tree
, hf_usb_index
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3605 proto_tree_add_item(tree
, hf_usb_length
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3612 dissect_usb_setup_get_status_response(packet_info
*pinfo _U_
, proto_tree
*tree
,
3613 tvbuff_t
*tvb
, int offset
,
3614 urb_info_t
*urb _U_
)
3617 /* XXX - show bits */
3618 proto_tree_add_item(tree
, hf_usb_wStatus
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3626 * These dissectors are used to dissect the setup part and the data
3627 * for URB_CONTROL_INPUT / SET ADDRESS
3633 dissect_usb_setup_set_address_request(packet_info
*pinfo _U_
, proto_tree
*tree
,
3634 tvbuff_t
*tvb
, int offset
,
3635 urb_info_t
*urb _U_
)
3637 /* device address */
3638 proto_tree_add_item(tree
, hf_usb_device_address
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3642 proto_tree_add_item(tree
, hf_usb_index
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3646 proto_tree_add_item(tree
, hf_usb_length
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3653 dissect_usb_setup_set_address_response(packet_info
*pinfo _U_
, proto_tree
*tree _U_
,
3654 tvbuff_t
*tvb _U_
, int offset
,
3655 urb_info_t
*urb _U_
)
3662 * These dissectors are used to dissect the setup part and the data
3663 * for URB_CONTROL_INPUT / SET CONFIGURATION
3669 dissect_usb_setup_set_configuration_request(packet_info
*pinfo _U_
, proto_tree
*tree
,
3670 tvbuff_t
*tvb
, int offset
,
3671 urb_info_t
*urb _U_
)
3673 /* configuration value */
3674 proto_tree_add_item(tree
, hf_usb_bConfigurationValue
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
3678 proto_tree_add_item(tree
, hf_usb_index
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3682 proto_tree_add_item(tree
, hf_usb_length
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3689 dissect_usb_setup_set_configuration_response(packet_info
*pinfo _U_
, proto_tree
*tree _U_
,
3690 tvbuff_t
*tvb _U_
, int offset
,
3691 urb_info_t
*urb _U_
)
3698 * These dissectors are used to dissect the setup part and the data
3699 * for URB_CONTROL_INPUT / SET FEATURE
3705 dissect_usb_setup_set_feature_request(packet_info
*pinfo _U_
, proto_tree
*tree
,
3706 tvbuff_t
*tvb
, int offset
,
3712 recip
= USB_RECIPIENT(urb
->usb_trans_info
->setup
.requesttype
);
3714 /* feature selector, zero/interface/endpoint */
3716 case RQT_SETUP_RECIPIENT_DEVICE
:
3717 proto_tree_add_item(tree
, hf_usb_device_wFeatureSelector
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3719 proto_tree_add_item(tree
, hf_usb_index
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3722 case RQT_SETUP_RECIPIENT_INTERFACE
:
3723 proto_tree_add_item(tree
, hf_usb_interface_wFeatureSelector
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3725 proto_tree_add_item(tree
, hf_usb_wInterface
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3728 case RQT_SETUP_RECIPIENT_ENDPOINT
:
3729 proto_tree_add_item(tree
, hf_usb_endpoint_wFeatureSelector
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3731 proto_tree_add_item(tree
, hf_usb_wEndpoint
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3734 case RQT_SETUP_RECIPIENT_OTHER
:
3736 proto_tree_add_item(tree
, hf_usb_value
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3738 proto_tree_add_item(tree
, hf_usb_index
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3742 /* No conversation information, so recipient type is unknown */
3743 proto_tree_add_item(tree
, hf_usb_value
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3745 proto_tree_add_item(tree
, hf_usb_index
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3750 proto_tree_add_item(tree
, hf_usb_length
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3757 dissect_usb_setup_set_feature_response(packet_info
*pinfo _U_
, proto_tree
*tree _U_
,
3758 tvbuff_t
*tvb _U_
, int offset
,
3759 urb_info_t
*urb _U_
)
3766 * These dissectors are used to dissect the setup part and the data
3767 * for URB_CONTROL_INPUT / SET INTERFACE
3773 dissect_usb_setup_set_interface_request(packet_info
*pinfo
, proto_tree
*tree
,
3774 tvbuff_t
*tvb
, int offset
,
3775 urb_info_t
*urb _U_
)
3777 uint8_t alt_setting
, interface_num
;
3779 /* alternate setting */
3780 alt_setting
= tvb_get_uint8(tvb
, offset
);
3781 proto_tree_add_uint(tree
, hf_usb_bAlternateSetting
, tvb
, offset
, 2, alt_setting
);
3785 interface_num
= tvb_get_uint8(tvb
, offset
);
3786 proto_tree_add_uint(tree
, hf_usb_wInterface
, tvb
, offset
, 2, interface_num
);
3790 proto_tree_add_item(tree
, hf_usb_length
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3793 if (!PINFO_FD_VISITED(pinfo
)) {
3795 usb_conv_info_t
*iface_conv_info
= get_usb_iface_conv_info(pinfo
, interface_num
);
3797 /* update the conversation info with the selected alternate setting */
3798 count
= wmem_array_get_count(iface_conv_info
->alt_settings
);
3799 for (i
= 0; i
< count
; i
++) {
3800 usb_alt_setting_t
*alternate_setting
= (usb_alt_setting_t
*)wmem_array_index(iface_conv_info
->alt_settings
, i
);
3802 if (alternate_setting
->altSetting
== alt_setting
) {
3803 iface_conv_info
->interfaceClass
= alternate_setting
->interfaceClass
;
3804 iface_conv_info
->interfaceSubclass
= alternate_setting
->interfaceSubclass
;
3805 iface_conv_info
->interfaceProtocol
= alternate_setting
->interfaceProtocol
;
3806 iface_conv_info
->interfaceNum
= alternate_setting
->interfaceNum
;
3816 dissect_usb_setup_set_interface_response(packet_info
*pinfo _U_
, proto_tree
*tree _U_
,
3817 tvbuff_t
*tvb _U_
, int offset
,
3818 urb_info_t
*urb _U_
)
3825 * These dissectors are used to dissect the setup part and the data
3826 * for URB_CONTROL_INPUT / SYNCH FRAME
3832 dissect_usb_setup_synch_frame_request(packet_info
*pinfo _U_
, proto_tree
*tree
,
3833 tvbuff_t
*tvb
, int offset
,
3834 urb_info_t
*urb _U_
)
3837 proto_tree_add_item(tree
, hf_usb_value
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3841 proto_tree_add_item(tree
, hf_usb_wEndpoint
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3845 proto_tree_add_item(tree
, hf_usb_length
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3852 dissect_usb_setup_synch_frame_response(packet_info
*pinfo _U_
, proto_tree
*tree _U_
,
3853 tvbuff_t
*tvb _U_
, int offset
,
3854 urb_info_t
*urb _U_
)
3857 proto_tree_add_item(tree
, hf_usb_wFrameNumber
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3863 /* Dissector used for unknown USB setup request/responses */
3865 dissect_usb_setup_generic(packet_info
*pinfo _U_
, proto_tree
*tree
,
3866 tvbuff_t
*tvb
, int offset
,
3867 urb_info_t
*urb _U_
)
3870 proto_tree_add_item(tree
, hf_usb_value
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3872 proto_tree_add_item(tree
, hf_usb_index
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3874 proto_tree_add_item(tree
, hf_usb_length
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
3882 typedef int (*usb_setup_dissector
)(packet_info
*pinfo
, proto_tree
*tree
,
3883 tvbuff_t
*tvb
, int offset
,
3886 typedef struct _usb_setup_dissector_table_t
{
3888 usb_setup_dissector dissector
;
3890 } usb_setup_dissector_table_t
;
3891 static const usb_setup_dissector_table_t setup_request_dissectors
[] = {
3892 {USB_SETUP_GET_STATUS
, dissect_usb_setup_get_status_request
},
3893 {USB_SETUP_CLEAR_FEATURE
, dissect_usb_setup_clear_feature_request
},
3894 {USB_SETUP_SET_FEATURE
, dissect_usb_setup_set_feature_request
},
3895 {USB_SETUP_SET_ADDRESS
, dissect_usb_setup_set_address_request
},
3896 {USB_SETUP_GET_DESCRIPTOR
, dissect_usb_setup_get_descriptor_request
},
3897 {USB_SETUP_SET_CONFIGURATION
, dissect_usb_setup_set_configuration_request
},
3898 {USB_SETUP_GET_INTERFACE
, dissect_usb_setup_get_interface_request
},
3899 {USB_SETUP_SET_INTERFACE
, dissect_usb_setup_set_interface_request
},
3900 {USB_SETUP_SYNCH_FRAME
, dissect_usb_setup_synch_frame_request
},
3904 static const usb_setup_dissector_table_t setup_response_dissectors
[] = {
3905 {USB_SETUP_GET_STATUS
, dissect_usb_setup_get_status_response
},
3906 {USB_SETUP_CLEAR_FEATURE
, dissect_usb_setup_clear_feature_response
},
3907 {USB_SETUP_SET_FEATURE
, dissect_usb_setup_set_feature_response
},
3908 {USB_SETUP_SET_ADDRESS
, dissect_usb_setup_set_address_response
},
3909 {USB_SETUP_GET_DESCRIPTOR
, dissect_usb_setup_get_descriptor_response
},
3910 {USB_SETUP_GET_CONFIGURATION
, dissect_usb_setup_get_configuration_response
},
3911 {USB_SETUP_SET_CONFIGURATION
, dissect_usb_setup_set_configuration_response
},
3912 {USB_SETUP_GET_INTERFACE
, dissect_usb_setup_get_interface_response
},
3913 {USB_SETUP_SET_INTERFACE
, dissect_usb_setup_set_interface_response
},
3914 {USB_SETUP_SYNCH_FRAME
, dissect_usb_setup_synch_frame_response
},
3918 static const value_string setup_request_names_vals
[] = {
3919 {USB_SETUP_GET_STATUS
, "GET STATUS"},
3920 {USB_SETUP_CLEAR_FEATURE
, "CLEAR FEATURE"},
3921 {USB_SETUP_SET_FEATURE
, "SET FEATURE"},
3922 {USB_SETUP_SET_ADDRESS
, "SET ADDRESS"},
3923 {USB_SETUP_GET_DESCRIPTOR
, "GET DESCRIPTOR"},
3924 {USB_SETUP_SET_DESCRIPTOR
, "SET DESCRIPTOR"},
3925 {USB_SETUP_GET_CONFIGURATION
, "GET CONFIGURATION"},
3926 {USB_SETUP_SET_CONFIGURATION
, "SET CONFIGURATION"},
3927 {USB_SETUP_GET_INTERFACE
, "GET INTERFACE"},
3928 {USB_SETUP_SET_INTERFACE
, "SET INTERFACE"},
3929 {USB_SETUP_SYNCH_FRAME
, "SYNCH FRAME"},
3930 {USB_SETUP_SET_SEL
, "SET SEL"},
3931 {USB_SETUP_SET_ISOCH_DELAY
, "SET ISOCH DELAY"},
3934 static value_string_ext setup_request_names_vals_ext
= VALUE_STRING_EXT_INIT(setup_request_names_vals
);
3937 static const true_false_string tfs_bmrequesttype_direction
= {
3942 static const value_string bmrequesttype_type_vals
[] = {
3943 {RQT_SETUP_TYPE_STANDARD
, "Standard"},
3944 {RQT_SETUP_TYPE_CLASS
, "Class"},
3945 {RQT_SETUP_TYPE_VENDOR
, "Vendor"},
3949 static const value_string bmrequesttype_recipient_vals
[] = {
3950 {RQT_SETUP_RECIPIENT_DEVICE
, "Device" },
3951 {RQT_SETUP_RECIPIENT_INTERFACE
, "Interface" },
3952 {RQT_SETUP_RECIPIENT_ENDPOINT
, "Endpoint" },
3953 {RQT_SETUP_RECIPIENT_OTHER
, "Other" },
3957 /* Dissector used for standard usb setup requests */
3959 dissect_usb_standard_setup_request(packet_info
*pinfo
, proto_tree
*tree
,
3960 tvbuff_t
*tvb
, urb_info_t
*urb
,
3961 usb_trans_info_t
*usb_trans_info
)
3964 const usb_setup_dissector_table_t
*tmp
;
3965 usb_setup_dissector dissector
;
3967 proto_tree_add_item(tree
, hf_usb_request
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
3970 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "%s Request",
3971 val_to_str_ext(usb_trans_info
->setup
.request
, &setup_request_names_vals_ext
, "Unknown type %x"));
3974 for(tmp
= setup_request_dissectors
;tmp
->dissector
;tmp
++) {
3975 if (tmp
->request
== usb_trans_info
->setup
.request
) {
3976 dissector
= tmp
->dissector
;
3982 dissector
= &dissect_usb_setup_generic
;
3985 offset
= dissector(pinfo
, tree
, tvb
, offset
, urb
);
3991 /* Dissector used for standard usb setup responses */
3993 dissect_usb_standard_setup_response(packet_info
*pinfo
, proto_tree
*tree
,
3994 tvbuff_t
*tvb
, int offset
,
3997 const usb_setup_dissector_table_t
*tmp
;
3998 usb_setup_dissector dissector
;
3999 int length_remaining
;
4002 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "%s Response",
4003 val_to_str_ext(urb
->usb_trans_info
->setup
.request
,
4004 &setup_request_names_vals_ext
, "Unknown type %x"));
4007 for(tmp
= setup_response_dissectors
;tmp
->dissector
;tmp
++) {
4008 if (tmp
->request
== urb
->usb_trans_info
->setup
.request
) {
4009 dissector
= tmp
->dissector
;
4014 length_remaining
= tvb_reported_length_remaining(tvb
, offset
);
4016 if (length_remaining
<= 0)
4020 offset
= dissector(pinfo
, tree
, tvb
, offset
, urb
);
4022 proto_tree_add_item(tree
, hf_usb_control_response_generic
,
4023 tvb
, offset
, length_remaining
, ENC_NA
);
4024 offset
+= length_remaining
;
4032 usb_tap_queue_packet(packet_info
*pinfo
, uint8_t urb_type
,
4035 usb_tap_data_t
*tap_data
;
4037 tap_data
= wmem_new(pinfo
->pool
, usb_tap_data_t
);
4038 tap_data
->urb_type
= urb_type
;
4039 tap_data
->transfer_type
= (uint8_t)(urb
->transfer_type
);
4040 tap_data
->urb
= urb
;
4041 tap_data
->trans_info
= urb
->usb_trans_info
;
4043 tap_queue_packet(usb_tap
, pinfo
, tap_data
);
4048 is_usb_standard_setup_request(usb_trans_info_t
*usb_trans_info
)
4050 uint8_t type
, recip
;
4052 type
= USB_TYPE(usb_trans_info
->setup
.requesttype
);
4053 recip
= USB_RECIPIENT(usb_trans_info
->setup
.requesttype
);
4055 if (type
!= RQT_SETUP_TYPE_STANDARD
)
4058 /* the USB standards defines the GET_DESCRIPTOR request only as a
4060 if it's not aimed at a device, it's a non-standard request that
4061 should be handled by a class-specific dissector */
4062 if (usb_trans_info
->setup
.request
== USB_SETUP_GET_DESCRIPTOR
&&
4063 recip
!= RQT_SETUP_RECIPIENT_DEVICE
) {
4072 try_dissect_next_protocol(proto_tree
*tree
, tvbuff_t
*next_tvb
, packet_info
*pinfo
,
4073 urb_info_t
*urb
, uint8_t urb_type
, proto_tree
*urb_tree
,
4074 proto_tree
*setup_tree
)
4077 wmem_tree_key_t key
[4];
4078 uint32_t k_frame_number
;
4079 uint32_t k_device_address
;
4081 usb_trans_info_t
*usb_trans_info
;
4082 heur_dtbl_entry_t
*hdtbl_entry
;
4083 heur_dissector_list_t heur_subdissector_list
= NULL
;
4084 dissector_table_t usb_dissector_table
= NULL
;
4085 proto_item
*sub_item
;
4086 device_product_data_t
*device_product_data
;
4087 device_protocol_data_t
*device_protocol_data
;
4089 /* if we select the next dissector based on a class,
4090 this is the (device or interface) class we're using */
4093 uint8_t transfer_type
;
4094 bool use_setup_tree
= false;
4098 * Not enough information to choose the next protocol.
4099 * XXX - is there something we can still do here?
4101 if (tvb_reported_length(next_tvb
) > 0)
4102 call_data_dissector(next_tvb
, pinfo
, tree
);
4104 return tvb_captured_length(next_tvb
);
4107 /* try dissect by "usb.device" */
4108 ret
= dissector_try_uint_with_data(device_to_dissector
,
4109 (uint32_t)(urb
->bus_id
<<16 | urb
->device_address
),
4110 next_tvb
, pinfo
, tree
, true, urb
);
4112 return tvb_captured_length(next_tvb
);
4114 k_frame_number
= pinfo
->num
;
4115 k_device_address
= urb
->device_address
;
4116 k_bus_id
= urb
->bus_id
;
4119 key
[0].key
= &k_device_address
;
4121 key
[1].key
= &k_bus_id
;
4123 key
[2].key
= &k_frame_number
;
4127 /* try dissect by "usb.protocol" */
4128 device_protocol_data
= (device_protocol_data_t
*)wmem_tree_lookup32_array_le(device_to_protocol_table
, key
);
4130 if (device_protocol_data
&&
4131 device_protocol_data
->bus_id
== urb
->bus_id
&&
4132 device_protocol_data
->device_address
== urb
->device_address
) {
4133 ret
= dissector_try_uint_with_data(protocol_to_dissector
,
4134 (uint32_t)device_protocol_data
->protocol
,
4135 next_tvb
, pinfo
, tree
, true, urb
);
4137 return tvb_captured_length(next_tvb
);
4140 device_product_data
= (device_product_data_t
*)wmem_tree_lookup32_array_le(device_to_product_table
, key
);
4142 if (device_product_data
&& device_product_data
->bus_id
== urb
->bus_id
&&
4143 device_product_data
->device_address
== urb
->device_address
) {
4144 ret
= dissector_try_uint_with_data(product_to_dissector
,
4145 (uint32_t)(device_product_data
->vendor
<<16 | device_product_data
->product
),
4146 next_tvb
, pinfo
, tree
, true, urb
);
4148 return tvb_captured_length(next_tvb
);
4151 transfer_type
= urb
->transfer_type
;
4152 if (transfer_type
== URB_UNKNOWN
)
4153 transfer_type
= urb
->conv
->descriptor_transfer_type
;
4155 switch(transfer_type
) {
4157 heur_subdissector_list
= heur_bulk_subdissector_list
;
4158 usb_dissector_table
= usb_bulk_dissector_table
;
4162 heur_subdissector_list
= heur_interrupt_subdissector_list
;
4163 usb_dissector_table
= usb_interrupt_dissector_table
;
4167 usb_trans_info
= urb
->usb_trans_info
;
4168 if (!usb_trans_info
)
4171 /* for standard control requests and responses, there's no
4172 need to query dissector tables */
4173 if (is_usb_standard_setup_request(usb_trans_info
))
4176 /* When dissecting requests, and Setup Data tree is created,
4177 pass it to next dissector instead of parent. */
4178 if (urb
->is_request
&& setup_tree
)
4179 use_setup_tree
= true;
4181 ctrl_recip
= USB_RECIPIENT(usb_trans_info
->setup
.requesttype
);
4183 if (ctrl_recip
== RQT_SETUP_RECIPIENT_INTERFACE
) {
4184 uint8_t interface_num
= usb_trans_info
->setup
.wIndex
& 0xff;
4185 urb_info_t
*new_urb
= wmem_new(pinfo
->pool
, urb_info_t
);
4187 memcpy(new_urb
, urb
, sizeof(urb_info_t
));
4190 heur_subdissector_list
= heur_control_subdissector_list
;
4191 usb_dissector_table
= usb_control_dissector_table
;
4193 urb
->conv
= get_usb_iface_conv_info(pinfo
, interface_num
);
4194 urb
->usb_trans_info
= usb_trans_info
;
4195 urb
->endpoint
= NO_ENDPOINT8
;
4197 else if (ctrl_recip
== RQT_SETUP_RECIPIENT_ENDPOINT
) {
4198 address endpoint_addr
;
4200 uint32_t src_endpoint
, dst_endpoint
;
4201 conversation_t
*conversation
;
4202 urb_info_t
*new_urb
= wmem_new(pinfo
->pool
, urb_info_t
);
4204 memcpy(new_urb
, urb
, sizeof(urb_info_t
));
4207 heur_subdissector_list
= heur_control_subdissector_list
;
4208 usb_dissector_table
= usb_control_dissector_table
;
4210 endpoint
= usb_trans_info
->setup
.wIndex
& 0xff;
4212 if (urb
->is_request
) {
4213 usb_address_t
*dst_addr
= wmem_new0(pinfo
->pool
, usb_address_t
);
4214 dst_addr
->bus_id
= urb
->bus_id
;
4215 dst_addr
->device
= urb
->device_address
;
4216 dst_addr
->endpoint
= dst_endpoint
= GUINT32_TO_LE(endpoint
);
4217 set_address(&endpoint_addr
, usb_address_type
, USB_ADDR_LEN
, (char *)dst_addr
);
4219 conversation
= get_usb_conversation(pinfo
, &pinfo
->src
, &endpoint_addr
, pinfo
->srcport
, dst_endpoint
);
4222 usb_address_t
*src_addr
= wmem_new0(pinfo
->pool
, usb_address_t
);
4223 src_addr
->bus_id
= urb
->bus_id
;
4224 src_addr
->device
= urb
->device_address
;
4225 src_addr
->endpoint
= src_endpoint
= GUINT32_TO_LE(endpoint
);
4226 set_address(&endpoint_addr
, usb_address_type
, USB_ADDR_LEN
, (char *)src_addr
);
4228 conversation
= get_usb_conversation(pinfo
, &endpoint_addr
, &pinfo
->dst
, src_endpoint
, pinfo
->destport
);
4231 urb
->conv
= get_usb_conv_info(conversation
);
4232 urb
->usb_trans_info
= usb_trans_info
;
4235 /* the recipient is "device" or "other" or "reserved"
4236 there's no way for us to determine the interfaceClass
4237 we set the usb_dissector_table anyhow as some
4238 dissectors register for control messages to
4239 IF_CLASS_UNKNOWN (this should be fixed) */
4240 heur_subdissector_list
= heur_control_subdissector_list
;
4241 usb_dissector_table
= usb_control_dissector_table
;
4244 usb_tap_queue_packet(pinfo
, urb_type
, urb
);
4245 sub_item
= proto_tree_add_uint(urb_tree
, hf_usb_bInterfaceClass
, next_tvb
, 0, 0, urb
->conv
->interfaceClass
);
4246 proto_item_set_generated(sub_item
);
4253 /* try "usb.protocol" on interface level */
4254 protocol
= (urb
->conv
->interfaceClass
& 0xFF) << 16 |
4255 (urb
->conv
->interfaceSubclass
& 0xFF) << 8 |
4256 (urb
->conv
->interfaceProtocol
& 0xFF);
4257 ret
= dissector_try_uint_with_data(protocol_to_dissector
, protocol
,
4258 next_tvb
, pinfo
, tree
, true, urb
);
4260 return tvb_captured_length(next_tvb
);
4262 if (try_heuristics
&& heur_subdissector_list
) {
4263 bool dissector_found
= dissector_try_heuristic(heur_subdissector_list
,
4264 next_tvb
, pinfo
, use_setup_tree
? setup_tree
: tree
, &hdtbl_entry
, urb
);
4265 if (dissector_found
)
4266 return tvb_captured_length(next_tvb
);
4269 if (usb_dissector_table
) {
4270 /* we prefer the interface class unless it says we should refer
4272 XXX - use the device class if the interface class is unknown */
4273 if (urb
->conv
->interfaceClass
== IF_CLASS_DEVICE
) {
4274 usb_class
= (urb
->device_protocol
>>16) & 0xFF;
4277 usb_class
= urb
->conv
->interfaceClass
;
4280 ret
= dissector_try_uint_with_data(usb_dissector_table
, usb_class
,
4281 next_tvb
, pinfo
, use_setup_tree
? setup_tree
: tree
, true, urb
);
4283 return tvb_captured_length(next_tvb
);
4285 /* try protocol specific dissector if there is one */
4286 usb_class
= USB_PROTOCOL_KEY(urb
->conv
->interfaceClass
,
4287 urb
->conv
->interfaceSubclass
,
4288 urb
->conv
->interfaceProtocol
);
4289 ret
= dissector_try_uint_with_data(usb_dissector_table
, usb_class
,
4290 next_tvb
, pinfo
, use_setup_tree
? setup_tree
: tree
, true, urb
);
4292 return tvb_captured_length(next_tvb
);
4300 dissect_usb_setup_response(packet_info
*pinfo
, proto_tree
*tree
,
4301 tvbuff_t
*tvb
, int offset
,
4302 uint8_t urb_type
, urb_info_t
*urb
)
4305 tvbuff_t
*next_tvb
= NULL
;
4306 int length_remaining
;
4308 parent
= proto_tree_get_parent_tree(tree
);
4311 if (urb
->usb_trans_info
&& is_usb_standard_setup_request(urb
->usb_trans_info
)) {
4312 offset
= dissect_usb_standard_setup_response(pinfo
, parent
, tvb
, offset
, urb
);
4315 next_tvb
= tvb_new_subset_remaining(tvb
, offset
);
4316 offset
+= try_dissect_next_protocol(parent
, next_tvb
, pinfo
, urb
, urb_type
, tree
, NULL
);
4318 length_remaining
= tvb_reported_length_remaining(tvb
, offset
);
4319 if (length_remaining
> 0) {
4320 proto_tree_add_item(parent
, hf_usb_control_response_generic
,
4321 tvb
, offset
, length_remaining
, ENC_NA
);
4322 offset
+= length_remaining
;
4327 /* no matching request available */
4328 length_remaining
= tvb_reported_length_remaining(tvb
, offset
);
4329 if (length_remaining
> 0) {
4330 proto_tree_add_item(parent
, hf_usb_control_response_generic
, tvb
,
4331 offset
, length_remaining
, ENC_NA
);
4332 offset
+= length_remaining
;
4341 dissect_usb_bmrequesttype(proto_tree
*parent_tree
, tvbuff_t
*tvb
, int offset
, uint8_t *byte
)
4345 static int * const bmRequestType_bits
[] = {
4346 &hf_usb_bmRequestType_direction
,
4347 &hf_usb_bmRequestType_type
,
4348 &hf_usb_bmRequestType_recipient
,
4352 proto_tree_add_bitmask_with_flags_ret_uint64(parent_tree
, tvb
, offset
, hf_usb_bmRequestType
, ett_usb_setup_bmrequesttype
,
4353 bmRequestType_bits
, ENC_LITTLE_ENDIAN
, BMT_NO_APPEND
, &val
);
4354 *byte
= (uint8_t) val
;
4360 dissect_urb_transfer_flags(tvbuff_t
*tvb
, int offset
, proto_tree
* tree
, int hf
, int endian
)
4362 proto_tree_add_bitmask(tree
, tvb
, offset
, hf
, ett_transfer_flags
, transfer_flags_fields
, endian
);
4367 dissect_linux_usb_pseudo_header_ext(tvbuff_t
*tvb
, int offset
,
4368 packet_info
*pinfo _U_
,
4371 proto_tree_add_item(tree
, hf_usb_urb_interval
, tvb
, offset
, 4, ENC_HOST_ENDIAN
);
4373 proto_tree_add_item(tree
, hf_usb_urb_start_frame
, tvb
, offset
, 4, ENC_HOST_ENDIAN
);
4375 dissect_urb_transfer_flags(tvb
, offset
, tree
, hf_usb_urb_copy_of_transfer_flags
, ENC_HOST_ENDIAN
);
4377 proto_tree_add_item(tree
, hf_usb_iso_numdesc
, tvb
, offset
, 4, ENC_HOST_ENDIAN
);
4384 /* Dissector used for usb setup requests */
4386 dissect_usb_setup_request(packet_info
*pinfo
, proto_tree
*tree
,
4387 tvbuff_t
*tvb
, int offset
,
4388 uint8_t urb_type
, urb_info_t
*urb
,
4389 usb_header_t header_type
, uint64_t usb_id
)
4394 proto_tree
*parent
, *setup_tree
;
4395 usb_trans_info_t
*usb_trans_info
, trans_info
;
4396 tvbuff_t
*next_tvb
, *data_tvb
= NULL
;
4397 uint8_t bm_request_type
;
4399 /* we should do the NULL check in all non-static functions */
4401 usb_trans_info
= urb
->usb_trans_info
;
4403 usb_trans_info
= &trans_info
;
4405 parent
= proto_tree_get_parent_tree(tree
);
4407 setup_tree
= proto_tree_add_subtree(parent
, tvb
, offset
, 8, ett_usb_setup_hdr
, NULL
, "Setup Data");
4409 req_type
= USB_TYPE(tvb_get_uint8(tvb
, offset
));
4410 usb_trans_info
->setup
.requesttype
= tvb_get_uint8(tvb
, offset
);
4412 urb
->setup_requesttype
= tvb_get_uint8(tvb
, offset
);
4413 if (req_type
!= RQT_SETUP_TYPE_CLASS
)
4414 usb_tap_queue_packet(pinfo
, urb_type
, urb
);
4417 offset
= dissect_usb_bmrequesttype(setup_tree
, tvb
, offset
, &bm_request_type
);
4419 /* as we're going through the data, we build a next_tvb that
4420 contains the the setup packet without the request type
4421 and request-specific data
4422 all subsequent dissection routines work on this tvb */
4424 setup_offset
= offset
;
4425 usb_trans_info
->setup
.request
= tvb_get_uint8(tvb
, offset
);
4427 usb_trans_info
->setup
.wValue
= tvb_get_letohs(tvb
, offset
);
4429 usb_trans_info
->setup
.wIndex
= tvb_get_letohs(tvb
, offset
);
4431 usb_trans_info
->setup
.wLength
= tvb_get_letohs(tvb
, offset
);
4434 if (header_type
== USB_HEADER_LINUX_64_BYTES
) {
4435 offset
= dissect_linux_usb_pseudo_header_ext(tvb
, offset
, pinfo
, tree
);
4436 } else if (header_type
== USB_HEADER_USBPCAP
) {
4437 if ((bm_request_type
& 0x80) == 0 &&
4438 usb_trans_info
->setup
.wLength
> 0 &&
4439 tvb_reported_length_remaining(tvb
, offset
) == 0) {
4440 /* UPBPcap older than 1.5.0.0 packet, save setup data
4441 and do not call subdissector */
4442 if (!PINFO_FD_VISITED(pinfo
)) {
4443 wmem_tree_key_t key
[3];
4444 usbpcap_setup_data_t
*setup_data
= wmem_new(wmem_file_scope(), usbpcap_setup_data_t
);
4445 setup_data
->usb_id
= usb_id
;
4446 tvb_memcpy(tvb
, setup_data
->setup_data
, setup_offset
-1, 8);
4448 key
[0].key
= (uint32_t *)&usb_id
;
4450 key
[1].key
= &pinfo
->num
;
4453 wmem_tree_insert32_array(usbpcap_setup_data
, key
, setup_data
);
4455 proto_tree_add_item(setup_tree
, hf_usb_request_unknown_class
, tvb
, setup_offset
, 1, ENC_LITTLE_ENDIAN
);
4456 dissect_usb_setup_generic(pinfo
, setup_tree
, tvb
, setup_offset
+1, urb
);
4462 if (tvb_captured_length_remaining(tvb
, offset
) > 0) {
4463 next_tvb
= tvb_new_composite();
4464 tvb_composite_append(next_tvb
, tvb_new_subset_length(tvb
, setup_offset
, 7));
4466 data_tvb
= tvb_new_subset_remaining(tvb
, offset
);
4467 tvb_composite_append(next_tvb
, data_tvb
);
4468 offset
+= tvb_captured_length(data_tvb
);
4469 tvb_composite_finalize(next_tvb
);
4470 next_tvb
= tvb_new_child_real_data(tvb
,
4471 (const uint8_t *) tvb_memdup(pinfo
->pool
, next_tvb
, 0, tvb_captured_length(next_tvb
)),
4472 tvb_captured_length(next_tvb
),
4473 tvb_captured_length(next_tvb
));
4474 add_new_data_source(pinfo
, next_tvb
, "USB Control");
4476 next_tvb
= tvb_new_subset_length(tvb
, setup_offset
, 7);
4479 /* at this point, offset contains the number of bytes that we
4482 if (is_usb_standard_setup_request(usb_trans_info
)) {
4483 /* there's no point in checking the return value as there's no
4484 fallback for standard setup requests */
4485 dissect_usb_standard_setup_request(pinfo
, setup_tree
,
4486 next_tvb
, urb
, usb_trans_info
);
4489 /* no standard request - pass it on to class-specific dissectors */
4490 ret
= try_dissect_next_protocol(
4491 parent
, next_tvb
, pinfo
, urb
, urb_type
, tree
, setup_tree
);
4493 /* no class-specific dissector could handle it,
4494 dissect it as generic setup request */
4495 proto_tree_add_item(setup_tree
, hf_usb_request_unknown_class
,
4496 next_tvb
, 0, 1, ENC_LITTLE_ENDIAN
);
4497 dissect_usb_setup_generic(pinfo
, setup_tree
,
4500 /* at this point, non-standard request has been dissected */
4504 proto_tree_add_item(setup_tree
, hf_usb_data_fragment
, data_tvb
, 0, -1, ENC_NA
);
4510 /* dissect the linux-specific USB pseudo header and fill the conversation struct
4511 return the number of dissected bytes */
4513 dissect_linux_usb_pseudo_header(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
,
4514 urb_info_t
*urb
, uint64_t *urb_id
)
4516 uint8_t transfer_type
;
4517 uint8_t endpoint_byte
;
4518 uint8_t transfer_type_and_direction
;
4523 *urb_id
= tvb_get_uint64(tvb
, 0, ENC_HOST_ENDIAN
);
4524 proto_tree_add_uint64(tree
, hf_usb_urb_id
, tvb
, 0, 8, *urb_id
);
4526 /* show the urb type of this URB as string and as a character */
4527 urb_type
= tvb_get_uint8(tvb
, 8);
4528 urb
->is_request
= (urb_type
==URB_SUBMIT
);
4529 proto_tree_add_uint(tree
, hf_usb_linux_urb_type
, tvb
, 8, 1, urb_type
);
4530 proto_tree_add_item(tree
, hf_usb_linux_transfer_type
, tvb
, 9, 1, ENC_LITTLE_ENDIAN
);
4532 transfer_type
= tvb_get_uint8(tvb
, 9);
4533 urb
->transfer_type
= transfer_type
;
4535 endpoint_byte
= tvb_get_uint8(tvb
, 10); /* direction bit | endpoint */
4536 urb
->endpoint
= endpoint_byte
;
4537 if (endpoint_byte
& URB_TRANSFER_IN
)
4538 urb
->direction
= P2P_DIR_RECV
;
4540 urb
->direction
= P2P_DIR_SENT
;
4542 transfer_type_and_direction
= (transfer_type
& 0x7F) | (endpoint_byte
& 0x80);
4543 col_append_str(pinfo
->cinfo
, COL_INFO
,
4544 val_to_str(transfer_type_and_direction
, usb_transfer_type_and_direction_vals
, "Unknown type %x"));
4546 proto_tree_add_bitmask(tree
, tvb
, 10, hf_usb_endpoint_address
, ett_usb_endpoint
, usb_endpoint_fields
, ENC_NA
);
4547 proto_tree_add_item(tree
, hf_usb_device_address
, tvb
, 11, 1, ENC_LITTLE_ENDIAN
);
4548 urb
->device_address
= (uint16_t)tvb_get_uint8(tvb
, 11);
4550 proto_tree_add_item_ret_uint(tree
, hf_usb_bus_id
, tvb
, 12, 2, ENC_HOST_ENDIAN
, &bus_id
);
4551 urb
->bus_id
= (uint16_t) bus_id
;
4553 /* Right after the pseudo header we always have
4554 * sizeof(struct usb_device_setup_hdr) bytes. The content of these
4555 * bytes only have meaning in case setup_flag == 0.
4557 proto_tree_add_item_ret_uint(tree
, hf_usb_setup_flag
, tvb
, 14, 1, ENC_NA
, &flag
);
4559 urb
->is_setup
= true;
4560 if (urb
->transfer_type
!=URB_CONTROL
)
4561 proto_tree_add_expert(tree
, pinfo
, &ei_usb_invalid_setup
, tvb
, 14, 1);
4563 urb
->is_setup
= false;
4566 proto_tree_add_item(tree
, hf_usb_data_flag
, tvb
, 15, 1, ENC_NA
);
4568 proto_tree_add_item(tree
, hf_usb_urb_ts_sec
, tvb
, 16, 8, ENC_HOST_ENDIAN
);
4569 proto_tree_add_item(tree
, hf_usb_urb_ts_usec
, tvb
, 24, 4, ENC_HOST_ENDIAN
);
4570 proto_tree_add_item(tree
, hf_usb_urb_status
, tvb
, 28, 4, ENC_HOST_ENDIAN
);
4571 proto_tree_add_item(tree
, hf_usb_urb_len
, tvb
, 32, 4, ENC_HOST_ENDIAN
);
4572 proto_tree_add_item(tree
, hf_usb_urb_data_len
, tvb
, 36, 4, ENC_HOST_ENDIAN
);
4577 /* dissect the usbpcap_buffer_packet_header and fill the conversation struct
4578 this function does not handle the transfer-specific headers
4579 return the number of bytes processed */
4581 dissect_usbpcap_buffer_packet_header(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
,
4582 urb_info_t
*urb
, uint32_t *win32_data_len
, uint64_t *irp_id
)
4585 uint32_t function_code
;
4586 uint8_t transfer_type
;
4587 uint8_t endpoint_byte
;
4588 uint8_t transfer_type_and_direction
;
4591 proto_tree_add_item(tree
, hf_usb_win32_header_len
, tvb
, 0, 2, ENC_LITTLE_ENDIAN
);
4592 *irp_id
= tvb_get_uint64(tvb
, 2, ENC_LITTLE_ENDIAN
);
4593 proto_tree_add_uint64(tree
, hf_usb_irp_id
, tvb
, 2, 8, *irp_id
);
4594 proto_tree_add_item(tree
, hf_usb_usbd_status
, tvb
, 10, 4, ENC_LITTLE_ENDIAN
);
4595 proto_tree_add_item_ret_uint(tree
, hf_usb_function
, tvb
, 14, 2, ENC_LITTLE_ENDIAN
, &function_code
);
4597 proto_tree_add_bitmask(tree
, tvb
, 16, hf_usb_info
, ett_usb_usbpcap_info
, usb_usbpcap_info_fields
, ENC_LITTLE_ENDIAN
);
4598 tmp_val8
= tvb_get_uint8(tvb
, 16);
4599 /* TODO: Handle errors */
4600 if (tmp_val8
& 0x01) {
4601 urb
->is_request
= false;
4603 urb
->is_request
= true;
4606 proto_tree_add_item(tree
, hf_usb_bus_id
, tvb
, 17, 2, ENC_LITTLE_ENDIAN
);
4607 urb
->bus_id
= tvb_get_letohs(tvb
, 17);
4609 proto_tree_add_item(tree
, hf_usb_win32_device_address
, tvb
, 19, 2, ENC_LITTLE_ENDIAN
);
4610 urb
->device_address
= tvb_get_letohs(tvb
, 19);
4612 endpoint_byte
= tvb_get_uint8(tvb
, 21);
4613 urb
->direction
= endpoint_byte
&URB_TRANSFER_IN
? P2P_DIR_RECV
: P2P_DIR_SENT
;
4614 urb
->endpoint
= endpoint_byte
;
4615 proto_tree_add_bitmask(tree
, tvb
, 21, hf_usb_endpoint_address
, ett_usb_endpoint
, usb_endpoint_fields
, ENC_LITTLE_ENDIAN
);
4617 transfer_type
= tvb_get_uint8(tvb
, 22);
4618 urb
->transfer_type
= transfer_type
;
4619 item
= proto_tree_add_item(tree
, hf_usb_win32_transfer_type
, tvb
, 22, 1, ENC_LITTLE_ENDIAN
);
4620 if (transfer_type
== URB_UNKNOWN
) {
4621 expert_add_info(pinfo
, item
, &ei_usb_usbpcap_unknown_urb
);
4624 /* Workaround bug in captures created with USBPcap earlier than 1.3.0.0 */
4625 if ((endpoint_byte
== 0x00) && (transfer_type
== URB_CONTROL
) && (tvb_get_uint8(tvb
, 27) == USB_CONTROL_STAGE_DATA
)) {
4626 urb
->is_request
= true;
4629 if (transfer_type
!= USBPCAP_URB_IRP_INFO
) {
4630 transfer_type_and_direction
= (transfer_type
& 0x7F) | (endpoint_byte
& 0x80);
4631 col_append_str(pinfo
->cinfo
, COL_INFO
,
4632 val_to_str(transfer_type_and_direction
, usb_transfer_type_and_direction_vals
, "Unknown type %x"));
4634 col_append_str(pinfo
->cinfo
, COL_INFO
,
4635 val_to_str_ext(function_code
, &win32_urb_function_vals_ext
, "Unknown function %x"));
4638 *win32_data_len
= tvb_get_letohl(tvb
, 23);
4639 proto_tree_add_item(tree
, hf_usb_win32_data_len
, tvb
, 23, 4, ENC_LITTLE_ENDIAN
);
4641 /* by default, we assume it's no setup packet
4642 the correct values will be set when we parse the control header */
4643 urb
->is_setup
= false;
4644 urb
->setup_requesttype
= 0;
4646 /* we don't handle the transfer-specific headers here */
4652 dissect_darwin_buffer_packet_header(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
,
4653 urb_info_t
*urb
, uint64_t *id
)
4655 uint8_t transfer_type
;
4656 uint8_t request_type
;
4657 uint8_t endpoint_byte
;
4658 uint8_t transfer_type_and_direction
;
4659 uint8_t header_length
;
4661 proto_tree_add_item(tree
, hf_usb_darwin_bcd_version
, tvb
, 0, 2, ENC_LITTLE_ENDIAN
);
4663 header_length
= tvb_get_uint8(tvb
, 2);
4664 proto_tree_add_item(tree
, hf_usb_darwin_header_len
, tvb
, 2, 1, ENC_LITTLE_ENDIAN
);
4666 request_type
= tvb_get_uint8(tvb
, 3);
4667 urb
->is_request
= (request_type
== DARWIN_IO_SUBMIT
);
4668 proto_tree_add_uint(tree
, hf_usb_darwin_request_type
, tvb
, 3, 1, request_type
);
4670 proto_tree_add_item(tree
, hf_usb_darwin_io_len
, tvb
, 4, 4, ENC_LITTLE_ENDIAN
);
4672 proto_tree_add_item(tree
, hf_usb_darwin_io_status
, tvb
, 8, 4, ENC_LITTLE_ENDIAN
);
4674 proto_tree_add_item(tree
, hf_usb_darwin_iso_num_packets
, tvb
, 12, 4, ENC_LITTLE_ENDIAN
);
4676 *id
= tvb_get_uint64(tvb
, 16, ENC_LITTLE_ENDIAN
);
4677 proto_tree_add_uint64(tree
, hf_usb_darwin_io_id
, tvb
, 16, 8, *id
);
4679 proto_tree_add_item(tree
, hf_usb_darwin_device_location
, tvb
, 24, 4, ENC_LITTLE_ENDIAN
);
4680 urb
->bus_id
= tvb_get_letohl(tvb
, 24) >> 24;
4682 proto_tree_add_item(tree
, hf_usb_darwin_speed
, tvb
, 28, 1, ENC_LITTLE_ENDIAN
);
4684 urb
->device_address
= (uint16_t)tvb_get_uint8(tvb
, 29);
4685 proto_tree_add_uint(tree
, hf_usb_darwin_device_address
, tvb
, 29, 1, urb
->device_address
);
4687 endpoint_byte
= tvb_get_uint8(tvb
, 30); /* direction bit | endpoint */
4688 urb
->endpoint
= endpoint_byte
;
4689 if (endpoint_byte
& URB_TRANSFER_IN
) {
4690 urb
->direction
= P2P_DIR_RECV
;
4693 urb
->direction
= P2P_DIR_SENT
;
4695 proto_tree_add_uint(tree
, hf_usb_darwin_endpoint_address
, tvb
, 30, 1, endpoint_byte
);
4696 proto_tree_add_bitmask(tree
, tvb
, 30, hf_usb_endpoint_number
, ett_usb_endpoint
, usb_endpoint_fields
, ENC_LITTLE_ENDIAN
);
4698 transfer_type
= MIN(tvb_get_uint8(tvb
, 31), G_N_ELEMENTS(darwin_endpoint_to_linux
) - 1);
4699 urb
->transfer_type
= darwin_endpoint_to_linux
[transfer_type
];
4700 proto_tree_add_uint(tree
, hf_usb_darwin_endpoint_type
, tvb
, 31, 1, transfer_type
);
4702 transfer_type_and_direction
= (darwin_endpoint_to_linux
[transfer_type
] & 0x7F) | (endpoint_byte
& 0x80);
4703 col_append_str(pinfo
->cinfo
, COL_INFO
,
4704 val_to_str(transfer_type_and_direction
, usb_transfer_type_and_direction_vals
, "Unknown type %x"));
4705 col_append_str(pinfo
->cinfo
, COL_INFO
, urb
->is_request
== true ? " (submitted)" : " (completed)");
4707 urb
->is_setup
= false;
4708 if ((urb
->is_request
== true) && (urb
->transfer_type
== URB_CONTROL
)) {
4709 urb
->is_setup
= true;
4712 urb
->setup_requesttype
= 0;
4714 /* we don't handle the transfer-specific headers here */
4715 return header_length
;
4718 /* Set the usb_address_t fields based on the direction of the urb */
4720 usb_set_addr(proto_tree
*tree
, tvbuff_t
*tvb
, packet_info
*pinfo
, uint16_t bus_id
, uint16_t device_address
,
4721 int endpoint
, bool req
)
4723 proto_item
*sub_item
;
4724 usb_address_t
*src_addr
= wmem_new0(pinfo
->pool
, usb_address_t
),
4725 *dst_addr
= wmem_new0(pinfo
->pool
, usb_address_t
);
4726 uint8_t *str_src_addr
;
4727 uint8_t *str_dst_addr
;
4731 src_addr
->device
= 0xffffffff;
4732 src_addr
->endpoint
= NO_ENDPOINT
;
4733 dst_addr
->device
= GUINT16_TO_LE(device_address
);
4734 dst_addr
->endpoint
= GUINT32_TO_LE(endpoint
);
4737 src_addr
->device
= GUINT16_TO_LE(device_address
);
4738 src_addr
->endpoint
= GUINT32_TO_LE(endpoint
);
4739 dst_addr
->device
= 0xffffffff;
4740 dst_addr
->endpoint
= NO_ENDPOINT
;
4742 src_addr
->bus_id
= GUINT16_TO_LE(bus_id
);
4743 dst_addr
->bus_id
= GUINT16_TO_LE(bus_id
);
4745 set_address(&pinfo
->net_src
, usb_address_type
, USB_ADDR_LEN
, (char *)src_addr
);
4746 copy_address_shallow(&pinfo
->src
, &pinfo
->net_src
);
4747 set_address(&pinfo
->net_dst
, usb_address_type
, USB_ADDR_LEN
, (char *)dst_addr
);
4748 copy_address_shallow(&pinfo
->dst
, &pinfo
->net_dst
);
4750 pinfo
->ptype
= PT_USB
;
4751 pinfo
->srcport
= src_addr
->endpoint
;
4752 pinfo
->destport
= dst_addr
->endpoint
;
4753 /* sent/received is from the perspective of the USB host */
4754 pinfo
->p2p_dir
= req
? P2P_DIR_SENT
: P2P_DIR_RECV
;
4756 str_src_addr
= address_to_str(pinfo
->pool
, &pinfo
->src
);
4757 str_dst_addr
= address_to_str(pinfo
->pool
, &pinfo
->dst
);
4759 sub_item
= proto_tree_add_string(tree
, hf_usb_src
, tvb
, 0, 0, str_src_addr
);
4760 proto_item_set_generated(sub_item
);
4762 sub_item
= proto_tree_add_string(tree
, hf_usb_addr
, tvb
, 0, 0, str_src_addr
);
4763 proto_item_set_hidden(sub_item
);
4765 sub_item
= proto_tree_add_string(tree
, hf_usb_dst
, tvb
, 0, 0, str_dst_addr
);
4766 proto_item_set_generated(sub_item
);
4768 sub_item
= proto_tree_add_string(tree
, hf_usb_addr
, tvb
, 0, 0, str_dst_addr
);
4769 proto_item_set_hidden(sub_item
);
4773 /* Gets the transfer info for a given packet
4774 * Generates transfer info if none exists yet
4775 * Also adds request/response info to the tree for the given packet */
4776 static usb_trans_info_t
4777 *usb_get_trans_info(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
,
4778 usb_header_t header_type
, urb_info_t
*urb
, uint64_t usb_id
)
4780 usb_trans_info_t
*usb_trans_info
;
4783 wmem_tree_key_t key
[3];
4785 /* request/response matching so we can keep track of transaction specific
4789 key
[0].key
= (uint32_t *)&usb_id
;
4791 key
[1].key
= &pinfo
->num
;
4795 if (urb
->is_request
) {
4796 /* this is a request */
4797 usb_trans_info
= (usb_trans_info_t
*)wmem_tree_lookup32_array(urb
->conv
->transactions
, key
);
4798 if (!usb_trans_info
) {
4799 usb_trans_info
= wmem_new0(wmem_file_scope(), usb_trans_info_t
);
4800 usb_trans_info
->request_in
= pinfo
->num
;
4801 usb_trans_info
->req_time
= pinfo
->abs_ts
;
4802 usb_trans_info
->header_type
= header_type
;
4803 usb_trans_info
->usb_id
= usb_id
;
4805 wmem_tree_insert32_array(urb
->conv
->transactions
, key
, usb_trans_info
);
4808 if (usb_trans_info
->response_in
) {
4809 ti
= proto_tree_add_uint(tree
, hf_usb_response_in
, tvb
, 0, 0, usb_trans_info
->response_in
);
4810 proto_item_set_generated(ti
);
4814 /* this is a response */
4815 if (pinfo
->fd
->visited
) {
4816 usb_trans_info
= (usb_trans_info_t
*)wmem_tree_lookup32_array(urb
->conv
->transactions
, key
);
4819 usb_trans_info
= (usb_trans_info_t
*)wmem_tree_lookup32_array_le(urb
->conv
->transactions
, key
);
4820 if (usb_trans_info
) {
4821 if (usb_trans_info
->usb_id
== usb_id
) {
4822 if (usb_trans_info
->response_in
== 0) {
4823 /* USBPcap generates 2 frames for response; store the first one */
4824 usb_trans_info
->response_in
= pinfo
->num
;
4826 wmem_tree_insert32_array(urb
->conv
->transactions
, key
, usb_trans_info
);
4828 usb_trans_info
= NULL
;
4833 if (usb_trans_info
&& usb_trans_info
->request_in
) {
4835 ti
= proto_tree_add_uint(tree
, hf_usb_request_in
, tvb
, 0, 0, usb_trans_info
->request_in
);
4836 proto_item_set_generated(ti
);
4839 nstime_delta(&deltat
, &t
, &usb_trans_info
->req_time
);
4840 ti
= proto_tree_add_time(tree
, hf_usb_time
, tvb
, 0, 0, &deltat
);
4841 proto_item_set_generated(ti
);
4845 return usb_trans_info
;
4849 /* dissect a group of isochronous packets inside an usb packet in
4851 #define MAX_ISO_PACKETS 100000 // Arbitrary
4853 dissect_usbpcap_iso_packets(packet_info
*pinfo _U_
, proto_tree
*urb_tree
, uint8_t urb_type
,
4854 tvbuff_t
*tvb
, int offset
, uint32_t win32_data_len
, urb_info_t
*urb
)
4857 uint32_t num_packets
;
4858 int data_start_offset
;
4859 proto_item
*num_packets_ti
, *urb_tree_ti
;
4861 proto_tree_add_item(urb_tree
, hf_usb_win32_iso_start_frame
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
4864 num_packets
= tvb_get_letohl(tvb
, offset
);
4865 num_packets_ti
= proto_tree_add_item(urb_tree
, hf_usb_win32_iso_num_packets
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
4868 proto_tree_add_item(urb_tree
, hf_usb_win32_iso_error_count
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
4871 if (num_packets
> MAX_ISO_PACKETS
) {
4872 expert_add_info_format(pinfo
, num_packets_ti
, &ei_usb_bad_length
, "Too many isochronous transfer packets (%u)", num_packets
);
4873 return tvb_captured_length(tvb
);
4876 data_start_offset
= offset
+ 12 * num_packets
;
4877 urb_tree_ti
= proto_tree_get_parent(urb_tree
);
4878 proto_item_set_len(urb_tree_ti
, data_start_offset
);
4880 for (i
= 0; i
< num_packets
; i
++) {
4881 uint32_t this_offset
;
4882 uint32_t next_offset
;
4884 proto_item
*iso_packet_ti
, *ti
;
4885 proto_tree
*iso_packet_tree
;
4887 iso_packet_ti
= proto_tree_add_protocol_format(
4888 proto_tree_get_root(urb_tree
), proto_usb
,
4889 tvb
, offset
, 12, "USB isochronous packet");
4890 iso_packet_tree
= proto_item_add_subtree(iso_packet_ti
, ett_usb_win32_iso_packet
);
4892 this_offset
= tvb_get_letohl(tvb
, offset
);
4893 if (num_packets
- i
== 1) {
4894 /* this is the last packet */
4895 next_offset
= win32_data_len
;
4897 /* there is next packet */
4898 next_offset
= tvb_get_letohl(tvb
, offset
+ 12);
4901 if (next_offset
> this_offset
) {
4902 iso_len
= next_offset
- this_offset
;
4907 /* If this packet does not contain isochronous data, do not try to display it */
4908 if (!((urb
->is_request
&& urb
->direction
==P2P_DIR_SENT
) ||
4909 (!urb
->is_request
&& urb
->direction
==P2P_DIR_RECV
))) {
4913 proto_tree_add_item(iso_packet_tree
, hf_usb_win32_iso_offset
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
4916 ti
= proto_tree_add_item(iso_packet_tree
, hf_usb_win32_iso_length
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
4917 if (urb
->direction
==P2P_DIR_SENT
) {
4918 /* Isochronous OUT transfer */
4919 proto_item_append_text(ti
, " (not used)");
4921 /* Isochronous IN transfer.
4922 * Length field is being set by host controller.
4924 if (urb
->is_request
) {
4925 /* Length was not yet set */
4926 proto_item_append_text(ti
, " (irrelevant)");
4928 /* Length was set and (should be) valid */
4929 proto_item_append_text(ti
, " (relevant)");
4930 iso_len
= tvb_get_letohl(tvb
, offset
);
4935 ti
= proto_tree_add_item(iso_packet_tree
, hf_usb_win32_iso_status
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
4936 if (urb_type
== URB_SUBMIT
) {
4937 proto_item_append_text(ti
, " (irrelevant)");
4939 proto_item_append_text(ti
, " (relevant)");
4943 if (iso_len
&& data_start_offset
+ this_offset
+ iso_len
<= tvb_captured_length(tvb
)) {
4944 proto_tree_add_item(iso_packet_tree
, hf_usb_iso_data
, tvb
, (int)(data_start_offset
+ this_offset
), (int)iso_len
, ENC_NA
);
4945 proto_tree_set_appendix(iso_packet_tree
, tvb
, (int)(data_start_offset
+ this_offset
), (int)iso_len
);
4949 if ((urb
->is_request
&& urb
->direction
==P2P_DIR_SENT
) ||
4950 (!urb
->is_request
&& urb
->direction
==P2P_DIR_RECV
)) {
4951 /* We have dissected all the isochronous data */
4952 offset
+= win32_data_len
;
4960 dissect_linux_usb_iso_transfer(packet_info
*pinfo _U_
, proto_tree
*urb_tree
,
4961 usb_header_t header_type
, tvbuff_t
*tvb
, int offset
,
4964 uint32_t iso_numdesc
= 0;
4968 uint32_t iso_status
;
4969 uint32_t iso_off
= 0;
4970 uint32_t iso_len
= 0;
4972 tii
= proto_tree_add_uint(urb_tree
, hf_usb_bInterfaceClass
, tvb
, offset
, 0, urb
->conv
->interfaceClass
);
4973 proto_item_set_generated(tii
);
4975 /* All fields which belong to Linux usbmon headers are in host-endian
4976 * byte order. The fields coming from the USB communication are in little
4977 * endian format (see usb_20.pdf, chapter 8.1 Byte/Bit ordering).
4979 * When a capture file is transferred to a host with different endianness
4980 * than packet was captured then the necessary swapping happens in
4981 * wiretap/pcap-common.c, pcap_byteswap_linux_usb_pseudoheader().
4984 /* iso urbs on linux can't possibly contain a setup packet
4985 see mon_bin_event() in the linux kernel */
4987 proto_tree_add_item(urb_tree
, hf_usb_iso_error_count
, tvb
, offset
, 4, ENC_HOST_ENDIAN
);
4990 proto_tree_add_item_ret_uint(urb_tree
, hf_usb_iso_numdesc
, tvb
, offset
, 4, ENC_HOST_ENDIAN
, &iso_numdesc
);
4993 if (header_type
== USB_HEADER_LINUX_64_BYTES
) {
4994 offset
= dissect_linux_usb_pseudo_header_ext(tvb
, offset
, pinfo
, urb_tree
);
4997 data_base
= offset
+ iso_numdesc
*16;
4998 for (i
= 0; i
<iso_numdesc
; i
++) {
4999 proto_item
*iso_desc_ti
;
5000 proto_tree
*iso_desc_tree
;
5002 iso_desc_ti
= proto_tree_add_protocol_format(urb_tree
, proto_usb
, tvb
, offset
,
5003 16, "USB isodesc %u", i
);
5004 iso_desc_tree
= proto_item_add_subtree(iso_desc_ti
, ett_usb_isodesc
);
5006 proto_tree_add_item_ret_int(iso_desc_tree
, hf_usb_iso_status
, tvb
, offset
, 4, ENC_HOST_ENDIAN
, &iso_status
);
5007 proto_item_append_text(iso_desc_ti
, " [%s]", val_to_str_ext(iso_status
, &linux_negative_errno_vals_ext
, "Error %d"));
5010 proto_tree_add_item_ret_uint(iso_desc_tree
, hf_usb_iso_off
, tvb
, offset
, 4, ENC_HOST_ENDIAN
, &iso_off
);
5013 proto_tree_add_item_ret_uint(iso_desc_tree
, hf_usb_iso_len
, tvb
, offset
, 4, ENC_HOST_ENDIAN
, &iso_len
);
5015 proto_item_append_text(iso_desc_ti
, " (%u bytes)", iso_len
);
5018 /* Show the ISO data if we captured them and either the status
5019 is OK or the packet is sent from host to device.
5020 The Linux kernel sets the status field in outgoing isochronous
5021 URBs to -EXDEV and fills the data part with valid data.
5023 if ((pinfo
->p2p_dir
==P2P_DIR_SENT
|| !iso_status
) &&
5024 iso_len
&& data_base
+ iso_off
+ iso_len
<= tvb_captured_length(tvb
)) {
5025 proto_tree_add_item(iso_desc_tree
, hf_usb_iso_data
, tvb
, data_base
+ iso_off
, iso_len
, ENC_NA
);
5026 proto_tree_set_appendix(iso_desc_tree
, tvb
, (int)(data_base
+iso_off
), (int)iso_len
);
5029 proto_tree_add_item(iso_desc_tree
, hf_usb_iso_pad
, tvb
, offset
, 4, ENC_HOST_ENDIAN
);
5033 /* we jump to the end of the last iso data chunk
5034 this assumes that the iso data starts immediately after the
5036 we have to use the offsets from the last iso descriptor, we can't keep
5037 track of the offset ourselves as there may be gaps
5038 between data packets in the transfer buffer */
5039 return data_base
+iso_off
+iso_len
;
5043 dissect_usbip_iso_transfer(packet_info
*pinfo _U_
, proto_tree
*urb_tree
,
5044 tvbuff_t
*tvb
, int offset
, uint32_t iso_numdesc
, uint32_t desc_offset
,
5050 uint32_t iso_off
= 0;
5051 uint32_t iso_len
= 0;
5053 tii
= proto_tree_add_uint(urb_tree
, hf_usb_bInterfaceClass
, tvb
, offset
, 0, urb
->conv
->interfaceClass
);
5054 proto_item_set_generated(tii
);
5056 /* All fields which belong to usbip are in big-endian byte order.
5057 * unlike the linux kernel, the usb isoc descriptor is appended at
5058 * the end of the isoc data. We have to reassemble the pdus and jump
5059 * to the end (actual_length) and the remaining data is the isoc
5064 for (i
= 0; i
<iso_numdesc
; i
++) {
5065 proto_item
*iso_desc_ti
;
5066 proto_tree
*iso_desc_tree
;
5069 iso_desc_ti
= proto_tree_add_protocol_format(urb_tree
, proto_usb
, tvb
, desc_offset
,
5070 16, "USB isodesc %u", i
);
5071 iso_desc_tree
= proto_item_add_subtree(iso_desc_ti
, ett_usb_isodesc
);
5073 proto_tree_add_item_ret_uint(iso_desc_tree
, hf_usb_iso_off
, tvb
, desc_offset
, 4, ENC_BIG_ENDIAN
, &iso_off
);
5076 proto_tree_add_item(iso_desc_tree
, hf_usb_iso_len
, tvb
, desc_offset
, 4, ENC_BIG_ENDIAN
);
5079 proto_tree_add_item_ret_uint(iso_desc_tree
, hf_usb_iso_actual_len
, tvb
, desc_offset
, 4, ENC_BIG_ENDIAN
, &iso_len
);
5082 proto_tree_add_item_ret_int(iso_desc_tree
, hf_usb_iso_status
, tvb
, desc_offset
, 4, ENC_BIG_ENDIAN
, &iso_status
);
5083 proto_item_append_text(iso_desc_ti
, " [%s]", val_to_str_ext(iso_status
, &linux_negative_errno_vals_ext
, "Error %d"));
5087 proto_item_append_text(iso_desc_ti
, " (%u bytes)", iso_len
);
5089 /* Show the ISO data if we captured them and either the status
5090 is OK or the packet is sent from host to device.
5091 The Linux kernel sets the status field in outgoing isochronous
5092 URBs to -EXDEV and fills the data part with valid data.
5094 if ((pinfo
->p2p_dir
==P2P_DIR_SENT
|| !iso_status
) &&
5095 iso_len
&& data_base
+ iso_off
+ iso_len
<= tvb_reported_length(tvb
)) {
5096 proto_tree_add_item(iso_desc_tree
, hf_usb_iso_data
, tvb
, (unsigned) data_base
+ iso_off
, iso_len
, ENC_NA
);
5097 proto_tree_set_appendix(iso_desc_tree
, tvb
, (unsigned) data_base
+ iso_off
, (int)iso_len
);
5104 dissect_darwin_usb_iso_transfer(packet_info
*pinfo _U_
, proto_tree
*tree
, usb_header_t header_type _U_
,
5105 uint8_t urb_type _U_
, tvbuff_t
*tvb
, int32_t offset
, urb_info_t
*urb
)
5107 uint32_t frame_length
;
5108 uint32_t frame_header_length
;
5110 uint32_t iso_tree_start
;
5112 uint32_t iso_numdesc
;
5116 len
= (int32_t)tvb_captured_length(tvb
);
5119 tii
= proto_tree_add_uint(tree
, hf_usb_bInterfaceClass
, tvb
, offset
, 0, urb
->conv
->interfaceClass
);
5120 proto_item_set_generated(tii
);
5122 status
= tvb_get_uint32(tvb
, 8, ENC_LITTLE_ENDIAN
);
5123 iso_numdesc
= tvb_get_uint32(tvb
, 12, ENC_LITTLE_ENDIAN
);
5125 iso_tree_start
= offset
;
5126 for (i
= 0; (i
< iso_numdesc
) && (len
> 8 /* header len + frame len */); i
++) {
5127 proto_item
*iso_desc_ti
;
5128 proto_tree
*iso_desc_tree
;
5130 /* Fetch ISO descriptor fields stored in little-endian byte order. */
5131 frame_header_length
= tvb_get_uint32(tvb
, offset
, ENC_LITTLE_ENDIAN
);
5132 frame_length
= tvb_get_uint32(tvb
, offset
+ 4, ENC_LITTLE_ENDIAN
);
5134 if ((len
< frame_header_length
) || (frame_header_length
< 20)) {
5138 iso_desc_ti
= proto_tree_add_protocol_format(tree
, proto_usb
, tvb
, offset
,
5141 iso_desc_tree
= proto_item_add_subtree(iso_desc_ti
, ett_usb_isodesc
);
5143 proto_tree_add_item(iso_desc_tree
, hf_usb_darwin_iso_frame_number
, tvb
, offset
+ 12, 8, ENC_LITTLE_ENDIAN
);
5145 proto_tree_add_item(iso_desc_tree
, hf_usb_iso_len
, tvb
, offset
+ 4, 4, ENC_LITTLE_ENDIAN
);
5147 if (urb
->is_request
== false) {
5148 proto_tree_add_item(iso_desc_tree
, hf_usb_darwin_iso_timestamp
, tvb
, offset
+ 20, 8, ENC_LITTLE_ENDIAN
);
5149 proto_tree_add_item_ret_uint(iso_desc_tree
, hf_usb_darwin_iso_status
, tvb
, offset
+ 8, 4, ENC_LITTLE_ENDIAN
, &status
);
5151 proto_item_append_text(iso_desc_ti
, " [%s]", val_to_str_ext(status
, &usb_darwin_status_vals_ext
, "Error %d"));
5154 if (frame_length
> len
) {
5158 proto_tree_add_item(iso_desc_tree
, hf_usb_iso_data
, tvb
, offset
+ frame_header_length
, frame_length
, ENC_NA
);
5159 proto_tree_set_appendix(iso_desc_tree
, tvb
, (int)iso_tree_start
, (int)(offset
- iso_tree_start
));
5161 len
-= frame_length
;
5162 offset
+= frame_length
;
5165 /* Padding to align the next header */
5166 offset
+= frame_header_length
;
5167 offset
= WS_ROUNDUP_4(offset
);
5168 iso_tree_start
= offset
;
5170 len
-= frame_header_length
;
5177 dissect_usb_payload(tvbuff_t
*tvb
, packet_info
*pinfo
,
5178 proto_tree
*parent
, proto_tree
*tree
,
5179 urb_info_t
*urb
, uint8_t urb_type
,
5180 int offset
, uint16_t device_address
)
5182 wmem_tree_key_t key
[4];
5183 uint32_t k_frame_number
;
5184 uint32_t k_device_address
;
5186 device_product_data_t
*device_product_data
= NULL
;
5187 device_protocol_data_t
*device_protocol_data
= NULL
;
5188 tvbuff_t
*next_tvb
= NULL
;
5190 k_frame_number
= pinfo
->num
;
5191 k_device_address
= device_address
;
5192 k_bus_id
= urb
->bus_id
;
5195 key
[0].key
= &k_device_address
;
5197 key
[1].key
= &k_bus_id
;
5199 key
[2].key
= &k_frame_number
;
5203 device_product_data
= (device_product_data_t
*) wmem_tree_lookup32_array_le(device_to_product_table
, key
);
5204 if (device_product_data
&& device_product_data
->bus_id
== urb
->bus_id
&&
5205 device_product_data
->device_address
== device_address
) {
5206 p_add_proto_data(pinfo
->pool
, pinfo
, proto_usb
, USB_VENDOR_ID
, GUINT_TO_POINTER((unsigned)device_product_data
->vendor
));
5207 p_add_proto_data(pinfo
->pool
, pinfo
, proto_usb
, USB_PRODUCT_ID
, GUINT_TO_POINTER((unsigned)device_product_data
->product
));
5208 urb
->conv
->deviceVendor
= device_product_data
->vendor
;
5209 urb
->conv
->deviceProduct
= device_product_data
->product
;
5210 urb
->conv
->deviceVersion
= device_product_data
->device
;
5213 device_protocol_data
= (device_protocol_data_t
*) wmem_tree_lookup32_array_le(device_to_protocol_table
, key
);
5214 if (device_protocol_data
&& device_protocol_data
->bus_id
== urb
->bus_id
&&
5215 device_protocol_data
->device_address
== device_address
) {
5216 p_add_proto_data(pinfo
->pool
, pinfo
, proto_usb
, USB_DEVICE_CLASS
, GUINT_TO_POINTER(device_protocol_data
->protocol
>> 16));
5217 p_add_proto_data(pinfo
->pool
, pinfo
, proto_usb
, USB_DEVICE_SUBCLASS
, GUINT_TO_POINTER((device_protocol_data
->protocol
>> 8) & 0xFF));
5218 p_add_proto_data(pinfo
->pool
, pinfo
, proto_usb
, USB_DEVICE_PROTOCOL
, GUINT_TO_POINTER(device_protocol_data
->protocol
& 0xFF));
5219 urb
->device_protocol
= device_protocol_data
->protocol
;
5222 p_add_proto_data(pinfo
->pool
, pinfo
, proto_usb
, USB_BUS_ID
, GUINT_TO_POINTER((unsigned)urb
->bus_id
));
5223 p_add_proto_data(pinfo
->pool
, pinfo
, proto_usb
, USB_DEVICE_ADDRESS
, GUINT_TO_POINTER((unsigned)device_address
));
5225 if (tvb_captured_length_remaining(tvb
, offset
) > 0) {
5226 next_tvb
= tvb_new_subset_remaining(tvb
, offset
);
5227 offset
+= try_dissect_next_protocol(parent
, next_tvb
, pinfo
, urb
, urb_type
, tree
, NULL
);
5230 if (tvb_captured_length_remaining(tvb
, offset
) > 0) {
5231 /* There is still leftover capture data to add (padding?) */
5232 proto_tree_add_item(parent
, hf_usb_capdata
, tvb
, offset
, -1, ENC_NA
);
5239 dissect_freebsd_usb(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*parent
, void *data _U_
)
5243 proto_tree
*tree
= NULL
, *frame_tree
= NULL
;
5247 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "USB");
5251 ti
= proto_tree_add_protocol_format(parent
, proto_usb
, tvb
, 0, 128,
5253 tree
= proto_item_add_subtree(ti
, ett_usb_hdr
);
5256 proto_tree_add_item(tree
, hf_usb_totlen
, tvb
, 0, 4, ENC_LITTLE_ENDIAN
);
5257 proto_tree_add_item(tree
, hf_usb_busunit
, tvb
, 4, 4, ENC_LITTLE_ENDIAN
);
5258 proto_tree_add_item(tree
, hf_usb_address
, tvb
, 8, 1, ENC_LITTLE_ENDIAN
);
5259 proto_tree_add_item(tree
, hf_usb_mode
, tvb
, 9, 1, ENC_LITTLE_ENDIAN
);
5260 proto_tree_add_item(tree
, hf_usb_freebsd_urb_type
, tvb
, 10, 1, ENC_LITTLE_ENDIAN
);
5261 proto_tree_add_item(tree
, hf_usb_freebsd_transfer_type
, tvb
, 11, 1, ENC_LITTLE_ENDIAN
);
5262 proto_tree_add_bitmask(tree
, tvb
, 12, hf_usb_xferflags
, ett_usb_xferflags
,
5263 usb_xferflags_fields
, ENC_LITTLE_ENDIAN
);
5264 proto_tree_add_bitmask(tree
, tvb
, 16, hf_usb_xferstatus
, ett_usb_xferstatus
,
5265 usb_xferstatus_fields
, ENC_LITTLE_ENDIAN
);
5266 proto_tree_add_item(tree
, hf_usb_error
, tvb
, 20, 4, ENC_LITTLE_ENDIAN
);
5267 proto_tree_add_item(tree
, hf_usb_interval
, tvb
, 24, 4, ENC_LITTLE_ENDIAN
);
5268 proto_tree_add_item_ret_uint(tree
, hf_usb_nframes
, tvb
, 28, 4, ENC_LITTLE_ENDIAN
, &nframes
);
5269 proto_tree_add_item(tree
, hf_usb_packet_size
, tvb
, 32, 4, ENC_LITTLE_ENDIAN
);
5270 proto_tree_add_item(tree
, hf_usb_packet_count
, tvb
, 36, 4, ENC_LITTLE_ENDIAN
);
5271 proto_tree_add_bitmask(tree
, tvb
, 40, hf_usb_endpoint_address
, ett_usb_endpoint
, usb_endpoint_fields
, ENC_NA
);
5272 proto_tree_add_item(tree
, hf_usb_speed
, tvb
, 44, 1, ENC_LITTLE_ENDIAN
);
5275 for (i
= 0; i
< nframes
; i
++) {
5277 uint64_t frameflags
;
5279 frame_tree
= proto_tree_add_subtree_format(tree
, tvb
, offset
, -1,
5282 proto_tree_add_item_ret_uint(frame_tree
, hf_usb_frame_length
,
5283 tvb
, offset
, 4, ENC_LITTLE_ENDIAN
,
5286 proto_tree_add_bitmask_ret_uint64(frame_tree
, tvb
, offset
,
5288 ett_usb_frame_flags
,
5289 usb_frame_flags_fields
,
5290 ENC_LITTLE_ENDIAN
, &frameflags
);
5292 if (frameflags
& FREEBSD_FRAMEFLAG_DATA_FOLLOWS
) {
5294 * XXX - ultimately, we should dissect this data.
5296 proto_tree_add_item(frame_tree
, hf_usb_frame_data
, tvb
, offset
,
5298 offset
+= WS_ROUNDUP_4(framelen
);
5300 proto_item_set_end(ti
, tvb
, offset
);
5303 return tvb_captured_length(tvb
);
5307 netmon_HostController2(proto_tree
*tree
, tvbuff_t
*tvb
, int offset
, uint16_t flags
)
5309 proto_tree
*host_tree
;
5311 host_tree
= proto_tree_add_subtree(tree
, tvb
, offset
, (flags
& EVENT_HEADER_FLAG_64_BIT_HEADER
) ? 20 : 16, ett_usbport_host_controller
, NULL
, "HostController");
5312 netmon_etl_field(host_tree
, tvb
, &offset
, hf_usbport_device_object
, flags
);
5314 proto_tree_add_item(host_tree
, hf_usbport_pci_bus
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
5316 proto_tree_add_item(host_tree
, hf_usbport_pci_device
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
5318 proto_tree_add_item(host_tree
, hf_usbport_pci_function
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
5320 proto_tree_add_item(host_tree
, hf_usbport_pci_vendor_id
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
5322 proto_tree_add_item(host_tree
, hf_usbport_pci_device_id
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
5329 netmon_UsbPortPath(proto_tree
*tree
, tvbuff_t
*tvb
, int offset
, packet_info
*pinfo
)
5331 proto_item
*path_item
, *depth_item
;
5332 proto_tree
*path_tree
;
5333 uint32_t path_depth
, path0
, path1
, path2
, path3
, path4
, path5
;
5335 path_tree
= proto_tree_add_subtree(tree
, tvb
, offset
, 28, ett_usbport_path
, &path_item
, "PortPath: ");
5336 depth_item
= proto_tree_add_item_ret_uint(path_tree
, hf_usbport_port_path_depth
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
, &path_depth
);
5338 proto_tree_add_item_ret_uint(path_tree
, hf_usbport_port_path0
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
, &path0
);
5340 proto_tree_add_item_ret_uint(path_tree
, hf_usbport_port_path1
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
, &path1
);
5342 proto_tree_add_item_ret_uint(path_tree
, hf_usbport_port_path2
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
, &path2
);
5344 proto_tree_add_item_ret_uint(path_tree
, hf_usbport_port_path3
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
, &path3
);
5346 proto_tree_add_item_ret_uint(path_tree
, hf_usbport_port_path4
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
, &path4
);
5348 proto_tree_add_item_ret_uint(path_tree
, hf_usbport_port_path5
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
, &path5
);
5350 if (path_depth
== 0) {
5351 proto_item_append_text(path_item
, "-");
5353 if (path_depth
> 0) {
5354 proto_item_append_text(path_item
, "%d", path0
);
5356 if (path_depth
> 1) {
5357 proto_item_append_text(path_item
, ",%d", path1
);
5359 if (path_depth
> 2) {
5360 proto_item_append_text(path_item
, ",%d", path2
);
5362 if (path_depth
> 3) {
5363 proto_item_append_text(path_item
, ",%d", path3
);
5365 if (path_depth
> 4) {
5366 proto_item_append_text(path_item
, ",%d", path4
);
5368 if (path_depth
> 5) {
5369 proto_item_append_text(path_item
, ",%d", path5
);
5371 if (path_depth
> 6) {
5372 expert_add_info(pinfo
, depth_item
, &ei_usbport_invalid_path_depth
);
5379 netmon_fid_USBPORT_Device(proto_tree
*tree
, tvbuff_t
*tvb
, int offset
, uint16_t flags
, packet_info
*pinfo
)
5381 proto_item
*device_item
;
5382 proto_tree
*device_tree
;
5384 device_tree
= proto_tree_add_subtree(tree
, tvb
, offset
, 4, ett_usbport_device
, &device_item
, "Device");
5385 netmon_etl_field(device_tree
, tvb
, &offset
, hf_usbport_device_handle
, flags
);
5386 proto_tree_add_item(device_tree
, hf_usb_idVendor
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
5388 proto_tree_add_item(device_tree
, hf_usb_idProduct
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
5390 offset
= netmon_UsbPortPath(device_tree
, tvb
, offset
, pinfo
);
5391 proto_tree_add_item(device_tree
, hf_usbport_device_speed
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
5393 proto_tree_add_item(device_tree
, hf_usb_device_address
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
5400 netmon_fid_USBPORT_Endpoint(proto_tree
*tree
, tvbuff_t
*tvb
, int offset
, uint16_t flags
)
5402 proto_tree
*endpoint_tree
;
5404 endpoint_tree
= proto_tree_add_subtree(tree
, tvb
, offset
, (flags
& EVENT_HEADER_FLAG_64_BIT_HEADER
) ? 24 : 12, ett_usbport_endpoint
, NULL
, "Endpoint");
5405 netmon_etl_field(endpoint_tree
, tvb
, &offset
, hf_usbport_endpoint
, flags
);
5406 netmon_etl_field(endpoint_tree
, tvb
, &offset
, hf_usbport_pipehandle
, flags
);
5407 netmon_etl_field(endpoint_tree
, tvb
, &offset
, hf_usbport_device_handle
, flags
);
5413 netmon_fid_USBPORT_Endpoint_Descriptor(proto_tree
*tree
, tvbuff_t
*tvb
, int offset
)
5415 proto_tree
*endpoint_desc_tree
;
5417 endpoint_desc_tree
= proto_tree_add_subtree(tree
, tvb
, offset
, 7, ett_usbport_endpoint_desc
, NULL
, "Endpoint Descriptor");
5418 proto_tree_add_item(endpoint_desc_tree
, hf_usbport_endpoint_desc_length
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
5420 proto_tree_add_item(endpoint_desc_tree
, hf_usbport_endpoint_desc_type
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
5422 proto_tree_add_item(endpoint_desc_tree
, hf_usbport_endpoint_address
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
5424 proto_tree_add_item(endpoint_desc_tree
, hf_usbport_bm_attributes
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
5426 proto_tree_add_item(endpoint_desc_tree
, hf_usbport_max_packet_size
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
5428 proto_tree_add_item(endpoint_desc_tree
, hf_usbport_interval
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
5435 netmon_URB(proto_tree
*tree
, tvbuff_t
*tvb
, int offset
, uint16_t flags
)
5437 proto_item
*urb_item
;
5438 proto_tree
*urb_tree
;
5440 int i
, start_offset
= offset
;
5442 urb_tree
= proto_tree_add_subtree(tree
, tvb
, offset
, 8, ett_usbport_urb
, &urb_item
, "URB");
5443 proto_tree_add_item(urb_tree
, hf_usbport_urb_header_length
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
5445 proto_tree_add_item_ret_uint(urb_tree
, hf_usbport_urb_header_function
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
, &func
);
5446 proto_item_append_text(urb_item
, ": %s", val_to_str_ext_const(func
, &netmon_urb_function_vals_ext
, "Unknown"));
5448 proto_tree_add_item(urb_tree
, hf_usbport_urb_header_status
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
5450 netmon_etl_field(urb_tree
, tvb
, &offset
, hf_usbport_urb_header_usbddevice_handle
, flags
);
5451 netmon_etl_field(urb_tree
, tvb
, &offset
, hf_usbport_urb_header_usbdflags
, flags
);
5456 netmon_etl_field(urb_tree
, tvb
, &offset
, hf_usbport_urb_configuration_desc
, flags
);
5457 netmon_etl_field(urb_tree
, tvb
, &offset
, hf_usbport_urb_configuration_handle
, flags
);
5459 case 0x0008: //URB_FUNCTION_CONTROL_TRANSFER
5460 case 0x0009: //URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER
5461 case 0x000A: //URB_FUNCTION_ISOCH_TRANSFER
5462 case 0x000B: //URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE
5463 case 0x000C: //URB_FUNCTION_SET_DESCRIPTOR_TO_DEVICE
5464 case 0x000D: //URB_FUNCTION_SET_FEATURE_TO_DEVICE
5465 case 0x000E: //URB_FUNCTION_SET_FEATURE_TO_INTERFACE
5466 case 0x000F: //URB_FUNCTION_SET_FEATURE_TO_ENDPOINT
5467 case 0x0010: //URB_FUNCTION_CLEAR_FEATURE_TO_DEVICE
5468 case 0x0011: //URB_FUNCTION_CLEAR_FEATURE_TO_INTERFACE
5469 case 0x0012: //URB_FUNCTION_CLEAR_FEATURE_TO_ENDPOINT
5470 case 0x0013: //URB_FUNCTION_GET_STATUS_FROM_DEVICE
5471 case 0x0014: //URB_FUNCTION_GET_STATUS_FROM_INTERFACE
5472 case 0x0015: //URB_FUNCTION_GET_STATUS_FROM_ENDPOINT
5473 case 0x0017: //URB_FUNCTION_VENDOR_DEVICE
5474 case 0x0018: //URB_FUNCTION_VENDOR_INTERFACE
5475 case 0x0019: //URB_FUNCTION_VENDOR_ENDPOINT
5476 case 0x001A: //URB_FUNCTION_CLASS_DEVICE
5477 case 0x001B: //URB_FUNCTION_CLASS_INTERFACE
5478 case 0x001C: //URB_FUNCTION_CLASS_ENDPOINT
5479 case 0x001F: //URB_FUNCTION_CLASS_OTHER
5480 case 0x0020: //URB_FUNCTION_VENDOR_OTHER
5481 case 0x0021: //URB_FUNCTION_GET_STATUS_FROM_OTHER
5482 case 0x0022: //URB_FUNCTION_CLEAR_FEATURE_TO_OTHER
5483 case 0x0023: //URB_FUNCTION_SET_FEATURE_TO_OTHER
5484 case 0x0024: //URB_FUNCTION_GET_DESCRIPTOR_FROM_ENDPOINT
5485 case 0x0025: //URB_FUNCTION_SET_DESCRIPTOR_TO_ENDPOINT
5486 case 0x0026: //URB_FUNCTION_GET_CONFIGURATION
5487 case 0x0027: //URB_FUNCTION_GET_INTERFACE
5488 case 0x0028: //URB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE
5489 case 0x0029: //URB_FUNCTION_SET_DESCRIPTOR_TO_INTERFACE
5490 case 0x002A: //URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR
5491 case 0x0032: //URB_FUNCTION_CONTROL_TRANSFER_EX
5492 case 0x0037: //URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER_USING_CHAINED_MDL
5493 case 0x0038: //URB_FUNCTION_ISOCH_TRANSFER_USING_CHAINED_MDL
5494 netmon_etl_field(urb_tree
, tvb
, &offset
, hf_usbport_urb_pipe_handle
, flags
);
5495 proto_tree_add_bitmask(urb_tree
, tvb
, offset
, hf_usbport_urb_xferflags
, ett_usb_xferflags
,
5496 usb_xferflags_fields
, ENC_LITTLE_ENDIAN
);
5498 proto_tree_add_item(urb_tree
, hf_usbport_urb_transfer_buffer_length
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
5500 netmon_etl_field(urb_tree
, tvb
, &offset
, hf_usbport_urb_transfer_buffer
, flags
);
5501 netmon_etl_field(urb_tree
, tvb
, &offset
, hf_usbport_urb_transfer_buffer_mdl
, flags
);
5502 netmon_etl_field(urb_tree
, tvb
, &offset
, hf_usbport_urb_reserved_mbz
, flags
);
5503 for (i
= 0; i
< 8; i
++)
5505 netmon_etl_field(urb_tree
, tvb
, &offset
, hf_usbport_urb_reserved_hcd
, flags
);
5509 case 0x0002: //URB_FUNCTION_ABORT_PIPE
5510 case 0x001E: //URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL
5511 case 0x0030: //URB_FUNCTION_SYNC_RESET_PIPE
5512 case 0x0031: //URB_FUNCTION_SYNC_CLEAR_STALL
5513 case 0x0036: //URB_FUNCTION_CLOSE_STATIC_STREAMS
5514 netmon_etl_field(urb_tree
, tvb
, &offset
, hf_usbport_urb_pipe_handle
, flags
);
5515 proto_tree_add_item(urb_tree
, hf_usbport_urb_reserved
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
5520 proto_item_set_len(urb_item
, offset
-start_offset
);
5524 #define USBPORT_KEYWORD_DIAGNOSTIC UINT64_C(0x0000000000000001)
5525 #define USBPORT_KEYWORD_POWER_DIAGNOSTICS UINT64_C(0x0000000000000002)
5526 #define USBPORT_KEYWORD_PERF_DIAGNOSTICS UINT64_C(0x0000000000000004)
5527 #define USBPORT_KEYWORD_RESERVED1 UINT64_C(0xFFFFFFFFFFFFFFF8)
5530 dissect_netmon_usb_port(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*parent
, void* data
)
5532 proto_item
*ti
, *generated
;
5533 proto_tree
*usb_port_tree
;
5535 struct netmon_provider_id_data
*provider_id_data
= (struct netmon_provider_id_data
*)data
;
5536 static int * const keyword_fields
[] = {
5537 &hf_usbport_keyword_diagnostic
,
5538 &hf_usbport_keyword_power_diagnostics
,
5539 &hf_usbport_keyword_perf_diagnostics
,
5540 &hf_usbport_keyword_reserved1
,
5544 DISSECTOR_ASSERT(provider_id_data
!= NULL
);
5546 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "USBPort");
5547 col_clear(pinfo
->cinfo
, COL_INFO
);
5549 ti
= proto_tree_add_item(parent
, proto_usbport
, tvb
, 0, -1, ENC_NA
);
5550 usb_port_tree
= proto_item_add_subtree(ti
, ett_usbport
);
5552 generated
= proto_tree_add_uint(usb_port_tree
, hf_usbport_event_id
, tvb
, 0, 0, provider_id_data
->event_id
);
5553 proto_item_set_generated(generated
);
5554 generated
= proto_tree_add_bitmask_value(usb_port_tree
, tvb
, 0, hf_usbport_keyword
, ett_usbport_keyword
, keyword_fields
, provider_id_data
->keyword
);
5555 proto_item_set_generated(generated
);
5557 switch (provider_id_data
->event_id
)
5560 offset
= netmon_HostController2(usb_port_tree
, tvb
, offset
, provider_id_data
->event_flags
);
5561 offset
= netmon_fid_USBPORT_Device(usb_port_tree
, tvb
, offset
, provider_id_data
->event_flags
, pinfo
);
5562 offset
= netmon_fid_USBPORT_Endpoint(usb_port_tree
, tvb
, offset
, provider_id_data
->event_flags
);
5563 offset
= netmon_fid_USBPORT_Endpoint_Descriptor(usb_port_tree
, tvb
, offset
);
5564 netmon_etl_field(usb_port_tree
, tvb
, &offset
, hf_usbport_irp
, provider_id_data
->event_flags
);
5565 netmon_etl_field(usb_port_tree
, tvb
, &offset
, hf_usbport_urb
, provider_id_data
->event_flags
);
5566 offset
= netmon_URB(usb_port_tree
, tvb
, offset
, provider_id_data
->event_flags
);
5567 proto_tree_add_item(usb_port_tree
, hf_usbport_urb_transfer_data
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
5571 return tvb_captured_length(tvb
);
5575 dissect_usb_common(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*parent
,
5576 usb_header_t header_type
, void *extra_data
)
5581 uint32_t win32_data_len
= 0;
5582 uint32_t iso_numdesc
= 0;
5583 uint32_t desc_offset
= 0;
5584 uint32_t location
= 0;
5585 proto_item
*urb_tree_ti
;
5589 conversation_t
*conversation
;
5590 uint16_t device_address
;
5592 uint8_t usbpcap_control_stage
= 0;
5594 struct mausb_header
*ma_header
= NULL
;
5595 struct usbip_header
*ip_header
= NULL
;
5596 usb_pseudo_urb_t
*pseudo_urb
= NULL
;
5598 /* the goal is to get the conversation struct as early as possible
5599 and store all status values in this struct
5600 at first, we read the fields required to create/identify
5601 the right conversation struct */
5602 switch (header_type
) {
5604 case USB_HEADER_LINUX_48_BYTES
:
5605 case USB_HEADER_LINUX_64_BYTES
:
5606 urb_type
= tvb_get_uint8(tvb
, 8);
5607 endpoint
= tvb_get_uint8(tvb
, 10);
5608 device_address
= (uint16_t)tvb_get_uint8(tvb
, 11);
5609 bus_id
= tvb_get_letohs(tvb
, 12);
5612 case USB_HEADER_USBPCAP
:
5613 urb_type
= tvb_get_uint8(tvb
, 16) & 0x01 ? URB_COMPLETE
: URB_SUBMIT
;
5614 device_address
= tvb_get_letohs(tvb
, 19);
5615 endpoint
= tvb_get_uint8(tvb
, 21);
5616 if ((endpoint
== 0x00) && (tvb_get_uint8(tvb
, 22) == URB_CONTROL
) &&
5617 (tvb_get_uint8(tvb
, 27) == USB_CONTROL_STAGE_DATA
)) {
5618 /* USBPcap before 1.3.0.0 DATA OUT packet (the info at offset 16 is wrong) */
5619 urb_type
= URB_SUBMIT
;
5621 bus_id
= tvb_get_letohs(tvb
, 17);
5624 case USB_HEADER_MAUSB
:
5625 ma_header
= (struct mausb_header
*) extra_data
;
5626 urb_type
= mausb_is_from_host(ma_header
) ? URB_SUBMIT
: URB_COMPLETE
;
5627 device_address
= mausb_ep_handle_dev_addr(ma_header
->handle
);
5628 endpoint
= mausb_ep_handle_ep_num(ma_header
->handle
);
5629 bus_id
= mausb_ep_handle_bus_num(ma_header
->handle
);
5630 if (mausb_ep_handle_ep_d(ma_header
->handle
)) {
5636 case USB_HEADER_USBIP
:
5637 ip_header
= (struct usbip_header
*) extra_data
;
5638 urb_type
= tvb_get_ntohl(tvb
, 0) == 1 ? URB_SUBMIT
: URB_COMPLETE
;
5639 device_address
= ip_header
->devid
;
5640 bus_id
= ip_header
->busid
;
5641 endpoint
= ip_header
->ep
;
5642 if (ip_header
->dir
== 1) {
5648 case USB_HEADER_DARWIN
:
5649 urb_type
= tvb_get_uint8(tvb
, 3) ? URB_COMPLETE
: URB_SUBMIT
;
5650 endpoint
= tvb_get_uint8(tvb
, 30);
5651 device_address
= (uint16_t)tvb_get_uint8(tvb
, 29);
5652 location
= tvb_get_letohl(tvb
, 24);
5653 bus_id
= location
>> 24;
5656 case USB_HEADER_PSEUDO_URB
:
5657 pseudo_urb
= (usb_pseudo_urb_t
*) extra_data
;
5658 urb_type
= pseudo_urb
->from_host
? URB_SUBMIT
: URB_COMPLETE
;
5659 device_address
= pseudo_urb
->device_address
;
5660 endpoint
= pseudo_urb
->endpoint
;
5661 bus_id
= pseudo_urb
->bus_id
;
5665 return; /* invalid USB pseudo header */
5668 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "USB");
5669 urb_tree_ti
= proto_tree_add_protocol_format(parent
, proto_usb
, tvb
, 0, -1, "USB URB");
5670 tree
= proto_item_add_subtree(urb_tree_ti
, ett_usb_hdr
);
5672 if (endpoint
== 0x80) {
5673 /* Control endpoint is only bidirectional endpoint, use 0 to look up
5674 * correct conversation.
5679 usb_set_addr(tree
, tvb
, pinfo
, bus_id
, device_address
, endpoint
,
5680 (urb_type
== URB_SUBMIT
));
5682 conversation
= get_usb_conversation(pinfo
, &pinfo
->src
, &pinfo
->dst
, pinfo
->srcport
, pinfo
->destport
);
5683 urb
= wmem_new0(pinfo
->pool
, urb_info_t
);
5684 urb
->conv
= get_usb_conv_info(conversation
);
5685 urb
->endpoint
= endpoint
;
5686 clear_usb_conv_tmp_data(urb
);
5689 switch (header_type
) {
5691 case USB_HEADER_LINUX_48_BYTES
:
5692 case USB_HEADER_LINUX_64_BYTES
:
5693 proto_item_set_len(urb_tree_ti
, (header_type
== USB_HEADER_LINUX_64_BYTES
) ? 64 : 48);
5694 offset
= dissect_linux_usb_pseudo_header(tvb
, pinfo
, tree
, urb
, &usb_id
);
5697 case USB_HEADER_USBPCAP
:
5698 offset
= dissect_usbpcap_buffer_packet_header(tvb
, pinfo
, tree
, urb
, &win32_data_len
, &usb_id
);
5699 /* the length that we're setting here might have to be corrected
5700 if there's a transfer-specific pseudo-header following */
5701 proto_item_set_len(urb_tree_ti
, offset
);
5704 case USB_HEADER_MAUSB
:
5705 /* MA USB header gets dissected earlier, just set conversation variables */
5706 offset
= MAUSB_DPH_LENGTH
;
5707 mausb_set_urb_info(urb
, ma_header
);
5711 case USB_HEADER_USBIP
:
5712 iso_numdesc
= tvb_get_ntohl(tvb
, 0x20);
5713 urb
->transfer_type
= endpoint
== 0 ? URB_CONTROL
: (iso_numdesc
!= 0xffffffff ? URB_ISOCHRONOUS
: URB_UNKNOWN
);
5714 urb
->direction
= ip_header
->dir
== USBIP_DIR_OUT
? P2P_DIR_SENT
: P2P_DIR_RECV
;
5715 urb
->is_setup
= endpoint
== 0 ? (tvb_get_ntoh64(tvb
, 0x28) != UINT64_C(0)) : false;
5716 urb
->is_request
= (urb_type
==URB_SUBMIT
);
5717 offset
= urb
->is_setup
? USBIP_HEADER_WITH_SETUP_LEN
: USBIP_HEADER_LEN
;
5719 /* The ISOC descriptor is located at the end of the isoc frame behind the isoc data. */
5720 if ((urb
->is_request
&& urb
->direction
== USBIP_DIR_OUT
) ||
5721 (!urb
->is_request
&& urb
->direction
== USBIP_DIR_IN
)) {
5722 desc_offset
+= tvb_get_ntohl(tvb
, 0x18);
5725 desc_offset
+= offset
;
5729 case USB_HEADER_DARWIN
:
5730 offset
= dissect_darwin_buffer_packet_header(tvb
, pinfo
, tree
, urb
, &usb_id
);
5731 proto_item_set_len(urb_tree_ti
, offset
);
5734 case USB_HEADER_PSEUDO_URB
:
5735 urb
->transfer_type
= pseudo_urb
->transfer_type
;
5736 urb
->direction
= pseudo_urb
->from_host
? P2P_DIR_SENT
: P2P_DIR_RECV
;
5737 urb
->is_setup
= pseudo_urb
->from_host
&& (pseudo_urb
->transfer_type
== URB_CONTROL
);
5738 urb
->is_request
= pseudo_urb
->from_host
;
5739 urb
->speed
= pseudo_urb
->speed
;
5748 urb
->usb_trans_info
= usb_get_trans_info(tvb
, pinfo
, tree
, header_type
, urb
, usb_id
);
5750 if (urb
->transfer_type
!= URB_CONTROL
) {
5751 usb_tap_queue_packet(pinfo
, urb_type
, urb
);
5754 switch(urb
->transfer_type
) {
5757 item
= proto_tree_add_uint(tree
, hf_usb_bInterfaceClass
, tvb
, 0, 0, urb
->conv
->interfaceClass
);
5758 proto_item_set_generated(item
);
5760 switch (header_type
) {
5762 case USB_HEADER_LINUX_48_BYTES
:
5763 case USB_HEADER_LINUX_64_BYTES
:
5764 /* bulk and interrupt transfers never contain a setup packet */
5765 proto_tree_add_item(tree
, hf_usb_urb_unused_setup_header
, tvb
, offset
, 8, ENC_NA
);
5767 if (header_type
== USB_HEADER_LINUX_64_BYTES
) {
5768 offset
= dissect_linux_usb_pseudo_header_ext(tvb
, offset
, pinfo
, tree
);
5772 case USB_HEADER_USBPCAP
:
5775 case USB_HEADER_MAUSB
:
5778 case USB_HEADER_USBIP
:
5781 case USB_HEADER_DARWIN
:
5784 case USB_HEADER_PSEUDO_URB
:
5790 if (header_type
== USB_HEADER_USBPCAP
) {
5791 proto_tree_add_item(tree
, hf_usb_win32_control_stage
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
5792 usbpcap_control_stage
= tvb_get_uint8(tvb
, offset
);
5794 proto_item_set_len(urb_tree_ti
, offset
);
5795 if (usbpcap_control_stage
== USB_CONTROL_STAGE_SETUP
) {
5796 urb
->is_setup
= true;
5797 } else if (usbpcap_control_stage
== USB_CONTROL_STAGE_DATA
&& urb_type
== URB_SUBMIT
) {
5798 /* USBPcap before 1.5.0.0 */
5799 wmem_tree_key_t key
[3];
5801 key
[0].key
= (uint32_t *)&usb_id
;
5803 key
[1].key
= &pinfo
->num
;
5806 usbpcap_setup_data_t
*setup_data
= (usbpcap_setup_data_t
*)wmem_tree_lookup32_array_le(usbpcap_setup_data
, key
);
5807 if (setup_data
&& setup_data
->usb_id
== usb_id
) {
5808 tvbuff_t
*reassembled_tvb
= tvb_new_composite();
5809 tvb_composite_append(reassembled_tvb
, tvb_new_child_real_data(tvb
, setup_data
->setup_data
, 8, 8));
5810 tvb_composite_append(reassembled_tvb
, tvb_new_subset_remaining(tvb
, offset
));
5811 tvb_composite_finalize(reassembled_tvb
);
5812 add_new_data_source(pinfo
, reassembled_tvb
, "USBPcap reassembled setup");
5813 urb
->is_setup
= true;
5814 tvb
= reassembled_tvb
;
5820 if (urb
->is_request
) {
5821 if (urb
->is_setup
) {
5822 offset
= dissect_usb_setup_request(pinfo
, tree
, tvb
, offset
, urb_type
,
5823 urb
, header_type
, usb_id
);
5826 switch (header_type
) {
5828 case USB_HEADER_LINUX_48_BYTES
:
5829 case USB_HEADER_LINUX_64_BYTES
:
5830 proto_tree_add_item(tree
, hf_usb_urb_unused_setup_header
, tvb
, offset
, 8, ENC_NA
);
5832 if (header_type
== USB_HEADER_LINUX_64_BYTES
) {
5833 offset
= dissect_linux_usb_pseudo_header_ext(tvb
, offset
, pinfo
, tree
);
5837 case USB_HEADER_USBPCAP
:
5840 case USB_HEADER_MAUSB
:
5843 case USB_HEADER_USBIP
:
5846 case USB_HEADER_DARWIN
:
5849 case USB_HEADER_PSEUDO_URB
:
5854 /* this is a response */
5856 switch (header_type
) {
5858 case USB_HEADER_LINUX_48_BYTES
:
5859 case USB_HEADER_LINUX_64_BYTES
:
5860 /* Skip setup header - it's never applicable for responses */
5861 proto_tree_add_item(tree
, hf_usb_urb_unused_setup_header
, tvb
, offset
, 8, ENC_NA
);
5863 if (header_type
== USB_HEADER_LINUX_64_BYTES
) {
5864 offset
= dissect_linux_usb_pseudo_header_ext(tvb
, offset
, pinfo
, tree
);
5868 case USB_HEADER_USBPCAP
:
5869 /* Check if this is status stage */
5870 if ((urb
->usb_trans_info
) &&
5871 (usbpcap_control_stage
== USB_CONTROL_STAGE_STATUS
)) {
5872 const char *description
;
5873 if (USB_TYPE(urb
->usb_trans_info
->setup
.requesttype
) == RQT_SETUP_TYPE_STANDARD
) {
5874 description
= val_to_str_ext(urb
->usb_trans_info
->setup
.request
,
5875 &setup_request_names_vals_ext
, "Unknown type %x") ;
5877 description
= "URB_CONTROL";
5879 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "%s status", description
);
5880 /* There is no data to dissect */
5885 case USB_HEADER_MAUSB
:
5888 case USB_HEADER_USBIP
:
5891 case USB_HEADER_DARWIN
:
5894 case USB_HEADER_PSEUDO_URB
:
5898 offset
= dissect_usb_setup_response(pinfo
, tree
, tvb
, offset
,
5902 case URB_ISOCHRONOUS
:
5903 switch (header_type
) {
5905 case USB_HEADER_LINUX_48_BYTES
:
5906 case USB_HEADER_LINUX_64_BYTES
:
5907 offset
= dissect_linux_usb_iso_transfer(pinfo
, tree
, header_type
,
5911 case USB_HEADER_USBPCAP
:
5912 offset
= dissect_usbpcap_iso_packets(pinfo
, tree
,
5913 urb_type
, tvb
, offset
, win32_data_len
, urb
);
5916 case USB_HEADER_MAUSB
:
5919 case USB_HEADER_USBIP
:
5920 offset
= dissect_usbip_iso_transfer(pinfo
, tree
,
5921 tvb
, offset
, iso_numdesc
, desc_offset
, urb
);
5924 case USB_HEADER_DARWIN
:
5925 offset
= dissect_darwin_usb_iso_transfer(pinfo
, tree
, header_type
,
5926 urb_type
, tvb
, offset
, urb
);
5929 case USB_HEADER_PSEUDO_URB
:
5935 /* unknown transfer type */
5936 switch (header_type
) {
5937 case USB_HEADER_LINUX_48_BYTES
:
5938 case USB_HEADER_LINUX_64_BYTES
:
5939 proto_tree_add_item(tree
, hf_usb_urb_unused_setup_header
, tvb
, offset
, 8, ENC_NA
);
5941 if (header_type
== USB_HEADER_LINUX_64_BYTES
) {
5942 offset
= dissect_linux_usb_pseudo_header_ext(tvb
, offset
, pinfo
, tree
);
5946 case USB_HEADER_USBPCAP
:
5949 case USB_HEADER_MAUSB
:
5952 case USB_HEADER_USBIP
:
5955 case USB_HEADER_DARWIN
:
5958 case USB_HEADER_PSEUDO_URB
:
5964 dissect_usb_payload(tvb
, pinfo
, parent
, tree
, urb
, urb_type
,
5965 offset
, device_address
);
5969 dissect_linux_usb(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*parent
, void* data _U_
)
5971 dissect_usb_common(tvb
, pinfo
, parent
, USB_HEADER_LINUX_48_BYTES
, NULL
);
5972 return tvb_captured_length(tvb
);
5976 dissect_linux_usb_mmapped(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*parent
, void* data _U_
)
5978 dissect_usb_common(tvb
, pinfo
, parent
, USB_HEADER_LINUX_64_BYTES
, NULL
);
5979 return tvb_captured_length(tvb
);
5984 dissect_win32_usb(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*parent
, void* data _U_
)
5986 dissect_usb_common(tvb
, pinfo
, parent
, USB_HEADER_USBPCAP
, NULL
);
5987 return tvb_captured_length(tvb
);
5991 dissect_darwin_usb(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*parent
, void* data _U_
)
5993 dissect_usb_common(tvb
, pinfo
, parent
, USB_HEADER_DARWIN
, NULL
);
5994 return tvb_captured_length(tvb
);
5998 proto_register_usb(void)
6000 module_t
*usb_module
;
6001 static hf_register_info hf
[] = {
6003 /* USB packet pseudoheader members */
6006 { "Total length", "usb.totlen",
6007 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
6011 { "Host controller unit number", "usb.busunit",
6012 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
6016 { "USB device index", "usb.address",
6017 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
6021 { "Mode of transfer", "usb.transfer_mode",
6022 FT_UINT8
, BASE_DEC
, VALS(usb_freebsd_transfer_mode_vals
), 0x0,
6025 { &hf_usb_freebsd_urb_type
,
6026 { "URB type", "usb.freebsd_type",
6027 FT_UINT8
, BASE_DEC
, VALS(usb_freebsd_urb_type_vals
), 0x0,
6030 { &hf_usb_freebsd_transfer_type
,
6031 { "URB transfer type", "usb.freebsd_transfer_type",
6032 FT_UINT8
, BASE_HEX
, VALS(usb_freebsd_transfer_type_vals
), 0x0,
6035 { &hf_usb_xferflags
,
6036 { "Transfer flags", "usb.xferflags",
6037 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
6040 { &hf_usb_xferflags_force_short_xfer
,
6041 { "Force short transfer", "usb.xferflags.force_short_xfer",
6042 FT_BOOLEAN
, 32, NULL
, FREEBSD_FLAG_FORCE_SHORT_XFER
,
6045 { &hf_usb_xferflags_short_xfer_ok
,
6046 { "Short transfer OK", "usb.xferflags.short_xfer_ok",
6047 FT_BOOLEAN
, 32, NULL
, FREEBSD_FLAG_SHORT_XFER_OK
,
6050 { &hf_usb_xferflags_short_frames_ok
,
6051 { "Short frames OK", "usb.xferflags.short_frames_ok",
6052 FT_BOOLEAN
, 32, NULL
, FREEBSD_FLAG_SHORT_FRAMES_OK
,
6055 { &hf_usb_xferflags_pipe_bof
,
6056 { "Pipe BOF", "usb.xferflags.pipe_bof",
6057 FT_BOOLEAN
, 32, NULL
, FREEBSD_FLAG_PIPE_BOF
,
6060 { &hf_usb_xferflags_proxy_buffer
,
6061 { "Proxy buffer", "usb.xferflags.proxy_buffer",
6062 FT_BOOLEAN
, 32, NULL
, FREEBSD_FLAG_PROXY_BUFFER
,
6065 { &hf_usb_xferflags_ext_buffer
,
6066 { "External buffer", "usb.xferflags.ext_buffer",
6067 FT_BOOLEAN
, 32, NULL
, FREEBSD_FLAG_EXT_BUFFER
,
6070 { &hf_usb_xferflags_manual_status
,
6071 { "Manual status", "usb.xferflags.manual_status",
6072 FT_BOOLEAN
, 32, NULL
, FREEBSD_FLAG_MANUAL_STATUS
,
6075 { &hf_usb_xferflags_no_pipe_ok
,
6076 { "No pipe OK", "usb.xferflags.no_pipe_ok",
6077 FT_BOOLEAN
, 32, NULL
, FREEBSD_FLAG_NO_PIPE_OK
,
6080 { &hf_usb_xferflags_stall_pipe
,
6081 { "Stall pipe", "usb.xferflags.stall_pipe",
6082 FT_BOOLEAN
, 32, NULL
, FREEBSD_FLAG_STALL_PIPE
,
6085 { &hf_usb_xferstatus
,
6086 { "Transfer status", "usb.xferstatus",
6087 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
6090 { &hf_usb_xferstatus_open
,
6091 { "Pipe has been opened", "usb.xferstatus.open",
6092 FT_BOOLEAN
, 32, NULL
, FREEBSD_STATUS_OPEN
,
6095 { &hf_usb_xferstatus_transferring
,
6096 { "Transfer in progress", "usb.xferstatus.transferring",
6097 FT_BOOLEAN
, 32, NULL
, FREEBSD_STATUS_TRANSFERRING
,
6100 { &hf_usb_xferstatus_did_dma_delay
,
6101 { "Waited for hardware DMA", "usb.xferstatus.did_dma_delay",
6102 FT_BOOLEAN
, 32, NULL
, FREEBSD_STATUS_DID_DMA_DELAY
,
6105 { &hf_usb_xferstatus_did_close
,
6106 { "Transfer closed", "usb.xferstatus.did_close",
6107 FT_BOOLEAN
, 32, NULL
, FREEBSD_STATUS_DID_CLOSE
,
6110 { &hf_usb_xferstatus_draining
,
6111 { "Draining transfer", "usb.xferstatus.draining",
6112 FT_BOOLEAN
, 32, NULL
, FREEBSD_STATUS_DRAINING
,
6115 { &hf_usb_xferstatus_started
,
6116 { "Transfer started", "usb.xferstatus.started",
6117 FT_BOOLEAN
, 32, NULL
, FREEBSD_STATUS_STARTED
,
6118 "Whether the transfer is started or stopped", HFILL
}},
6120 { &hf_usb_xferstatus_bw_reclaimed
,
6121 { "Bandwidth reclaimed", "usb.xferstatus.bw_reclaimed",
6122 FT_BOOLEAN
, 32, NULL
, FREEBSD_STATUS_BW_RECLAIMED
,
6125 { &hf_usb_xferstatus_control_xfr
,
6126 { "Control transfer", "usb.xferstatus.control_xfr",
6127 FT_BOOLEAN
, 32, NULL
, FREEBSD_STATUS_CONTROL_XFR
,
6130 { &hf_usb_xferstatus_control_hdr
,
6131 { "Control header being sent", "usb.xferstatus.control_hdr",
6132 FT_BOOLEAN
, 32, NULL
, FREEBSD_STATUS_CONTROL_HDR
,
6135 { &hf_usb_xferstatus_control_act
,
6136 { "Control transfer active", "usb.xferstatus.control_act",
6137 FT_BOOLEAN
, 32, NULL
, FREEBSD_STATUS_CONTROL_ACT
,
6140 { &hf_usb_xferstatus_control_stall
,
6141 { "Control transfer should be stalled", "usb.xferstatus.control_stall",
6142 FT_BOOLEAN
, 32, NULL
, FREEBSD_STATUS_CONTROL_STALL
,
6145 { &hf_usb_xferstatus_short_frames_ok
,
6146 { "Short frames OK", "usb.xferstatus.short_frames_ok",
6147 FT_BOOLEAN
, 32, NULL
, FREEBSD_STATUS_SHORT_FRAMES_OK
,
6150 { &hf_usb_xferstatus_short_xfer_ok
,
6151 { "Short transfer OK", "usb.xferstatus.short_xfer_ok",
6152 FT_BOOLEAN
, 32, NULL
, FREEBSD_STATUS_SHORT_XFER_OK
,
6155 { &hf_usb_xferstatus_bdma_enable
,
6156 { "BUS-DMA enabled", "usb.xferstatus.bdma_enable",
6157 FT_BOOLEAN
, 32, NULL
, FREEBSD_STATUS_BDMA_ENABLE
,
6160 { &hf_usb_xferstatus_bdma_no_post_sync
,
6161 { "BUS-DMA post sync op not done", "usb.xferstatus.bdma_no_post_sync",
6162 FT_BOOLEAN
, 32, NULL
, FREEBSD_STATUS_BDMA_NO_POST_SYNC
,
6165 { &hf_usb_xferstatus_bdma_setup
,
6166 { "BUS-DMA set up", "usb.xferstatus.bdma_setup",
6167 FT_BOOLEAN
, 32, NULL
, FREEBSD_STATUS_BDMA_SETUP
,
6170 { &hf_usb_xferstatus_isochronous_xfr
,
6171 { "Isochronous transfer", "usb.xferstatus.isochronous_xfr",
6172 FT_BOOLEAN
, 32, NULL
, FREEBSD_STATUS_ISOCHRONOUS_XFR
,
6175 { &hf_usb_xferstatus_curr_dma_set
,
6176 { "Current DMA set", "usb.xferstatus.curr_dma_set",
6177 FT_UINT32
, BASE_DEC
, NULL
, FREEBSD_STATUS_CURR_DMA_SET
,
6180 { &hf_usb_xferstatus_can_cancel_immed
,
6181 { "Transfer can be cancelled immediately", "usb.xferstatus.can_cancel_immed",
6182 FT_BOOLEAN
, 32, NULL
, FREEBSD_STATUS_CAN_CANCEL_IMMED
,
6185 { &hf_usb_xferstatus_doing_callback
,
6186 { "Executing the callback", "usb.xferstatus.doing_callback",
6187 FT_BOOLEAN
, 32, NULL
, FREEBSD_STATUS_DOING_CALLBACK
,
6191 { "Error", "usb.error",
6192 FT_UINT32
, BASE_DEC
, VALS(usb_freebsd_err_vals
), 0x0,
6196 { "Interval", "usb.interval",
6197 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
6198 "Interval (ms)", HFILL
}},
6201 { "Number of following frames", "usb.nframes",
6202 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
6205 { &hf_usb_packet_size
,
6206 { "Packet size used", "usb.packet_size",
6207 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
6210 { &hf_usb_packet_count
,
6211 { "Packet count used", "usb.packet_count",
6212 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
6216 { "Speed", "usb.speed",
6217 FT_UINT8
, BASE_DEC
, VALS(usb_freebsd_speed_vals
), 0x0,
6220 { &hf_usb_frame_length
,
6221 { "Frame length", "usb.frame.length",
6222 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
6225 { &hf_usb_frame_flags
,
6226 { "Frame flags", "usb.frame.flags",
6227 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
6230 { &hf_usb_frame_flags_read
,
6231 { "Data direction is read", "usb.frame.read",
6232 FT_BOOLEAN
, 32, NULL
, FREEBSD_FRAMEFLAG_READ
,
6235 { &hf_usb_frame_flags_data_follows
,
6236 { "Frame contains data", "usb.frame.data_follows",
6237 FT_BOOLEAN
, 32, NULL
, FREEBSD_FRAMEFLAG_DATA_FOLLOWS
,
6240 { &hf_usb_frame_data
,
6241 { "Frame data", "usb.frame.data",
6242 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
6246 { "URB id", "usb.urb_id",
6247 FT_UINT64
, BASE_HEX
, NULL
, 0x0,
6250 { &hf_usb_linux_urb_type
,
6251 { "URB type", "usb.urb_type",
6252 FT_CHAR
, BASE_HEX
, VALS(usb_linux_urb_type_vals
), 0x0,
6255 { &hf_usb_linux_transfer_type
,
6256 { "URB transfer type", "usb.transfer_type",
6257 FT_UINT8
, BASE_HEX
, VALS(usb_linux_transfer_type_vals
), 0x0,
6260 { &hf_usb_endpoint_address
,
6261 { "Endpoint", "usb.endpoint_address",
6262 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
6263 "USB endpoint address", HFILL
}},
6265 { &hf_usb_endpoint_direction
,
6266 { "Direction", "usb.endpoint_address.direction",
6267 FT_UINT8
, BASE_DEC
, VALS(usb_endpoint_direction_vals
), 0x80,
6268 "USB endpoint direction", HFILL
}},
6270 { &hf_usb_endpoint_number
,
6271 { "Endpoint number", "usb.endpoint_address.number",
6272 FT_UINT8
, BASE_DEC
, NULL
, 0x0F,
6273 "USB endpoint number", HFILL
}},
6275 { &hf_usb_device_address
,
6276 { "Device", "usb.device_address",
6277 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
6278 "USB device address", HFILL
}},
6281 { "URB bus id", "usb.bus_id",
6282 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
6285 { &hf_usb_setup_flag
,
6286 { "Device setup request", "usb.setup_flag",
6287 FT_CHAR
, BASE_HEX
|BASE_RANGE_STRING
, RVALS(usb_setup_flag_rvals
), 0x0,
6288 "USB device setup request is relevant (0) or not", HFILL
}},
6290 { &hf_usb_data_flag
,
6291 { "Data", "usb.data_flag",
6292 FT_CHAR
, BASE_HEX
|BASE_RANGE_STRING
, RVALS(usb_data_flag_rvals
), 0x0,
6293 "USB data is present (0) or not", HFILL
}},
6295 { &hf_usb_urb_ts_sec
,
6296 { "URB sec", "usb.urb_ts_sec",
6297 FT_UINT64
, BASE_DEC
, NULL
, 0x0,
6300 { &hf_usb_urb_ts_usec
,
6301 { "URB usec", "usb.urb_ts_usec",
6302 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
6305 { &hf_usb_urb_status
,
6306 { "URB status", "usb.urb_status",
6307 FT_INT32
, BASE_DEC
|BASE_EXT_STRING
, &linux_negative_errno_vals_ext
, 0x0,
6311 { "URB length [bytes]", "usb.urb_len",
6312 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
6313 "URB length in bytes", HFILL
}},
6315 { &hf_usb_urb_data_len
,
6316 { "Data length [bytes]", "usb.data_len",
6317 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
6318 "URB data length in bytes", HFILL
}},
6320 { &hf_usb_urb_unused_setup_header
,
6321 { "Unused Setup Header",
6322 "usb.unused_setup_header", FT_NONE
, BASE_NONE
,
6323 NULL
, 0x0, NULL
, HFILL
}},
6325 { &hf_usb_urb_interval
,
6327 "usb.interval", FT_UINT32
, BASE_DEC
,
6328 NULL
, 0x0, NULL
, HFILL
}},
6330 { &hf_usb_urb_start_frame
,
6332 "usb.start_frame", FT_UINT32
, BASE_DEC
,
6333 NULL
, 0x0, NULL
, HFILL
}},
6335 { &hf_usb_urb_copy_of_transfer_flags
,
6336 { "Copy of Transfer Flags",
6337 "usb.copy_of_transfer_flags", FT_UINT32
, BASE_HEX
,
6338 NULL
, 0x0, NULL
, HFILL
}},
6342 "usb.transfer_flags.short_not_ok", FT_BOOLEAN
, 32,
6343 NULL
, URB_SHORT_NOT_OK
, NULL
, HFILL
}},
6347 "usb.transfer_flags.iso_asap", FT_BOOLEAN
, 32,
6348 NULL
, URB_ISO_ASAP
, NULL
, HFILL
}},
6350 { &hf_no_transfer_dma_map
,
6351 { "No transfer DMA map",
6352 "usb.transfer_flags.no_transfer_dma_map", FT_BOOLEAN
, 32,
6353 NULL
, URB_NO_TRANSFER_DMA_MAP
, NULL
, HFILL
}},
6357 "usb.transfer_flags.no_fsbr", FT_BOOLEAN
, 32,
6358 NULL
, URB_NO_FSBR
, NULL
, HFILL
}},
6361 { "Zero Packet", "usb.transfer_flags.zero_packet", FT_BOOLEAN
, 32,
6362 NULL
, URB_ZERO_PACKET
, NULL
, HFILL
}},
6365 { "No Interrupt", "usb.transfer_flags.no_interrupt", FT_BOOLEAN
, 32,
6366 NULL
, URB_NO_INTERRUPT
, NULL
, HFILL
}},
6369 { "Free Buffer", "usb.transfer_flags.free_buffer", FT_BOOLEAN
, 32,
6370 NULL
, URB_FREE_BUFFER
, NULL
, HFILL
}},
6373 { "Dir IN", "usb.transfer_flags.dir_in", FT_BOOLEAN
, 32,
6374 NULL
, URB_DIR_IN
, NULL
, HFILL
}},
6376 { &hf_dma_map_single
,
6377 { "DMA Map Single", "usb.transfer_flags.dma_map_single", FT_BOOLEAN
, 32,
6378 NULL
, URB_DMA_MAP_SINGLE
, NULL
, HFILL
}},
6381 { "DMA Map Page", "usb.transfer_flags.dma_map_page", FT_BOOLEAN
, 32,
6382 NULL
, URB_DMA_MAP_PAGE
, NULL
, HFILL
}},
6385 { "DMA Map SG", "usb.transfer_flags.dma_map_sg", FT_BOOLEAN
, 32,
6386 NULL
, URB_DMA_MAP_SG
, NULL
, HFILL
}},
6389 { "Map Local", "usb.transfer_flags.map_local", FT_BOOLEAN
, 32,
6390 NULL
, URB_MAP_LOCAL
, NULL
, HFILL
}},
6392 { &hf_setup_map_single
,
6393 { "Setup Map Single", "usb.transfer_flags.setup_map_single", FT_BOOLEAN
, 32,
6394 NULL
, URB_SETUP_MAP_SINGLE
, NULL
, HFILL
}},
6396 { &hf_setup_map_local
,
6397 { "Setup Map Local", "usb.transfer_flags.setup_map_local", FT_BOOLEAN
, 32,
6398 NULL
, URB_SETUP_MAP_LOCAL
, NULL
, HFILL
}},
6400 { &hf_dma_sg_combined
,
6401 { "DMA S-G Combined", "usb.transfer_flags.dma_sg_combined", FT_BOOLEAN
, 32,
6402 NULL
, URB_DMA_SG_COMBINED
, NULL
, HFILL
}},
6404 { &hf_aligned_temp_buffer
,
6405 { "Aligned Temp Buffer", "usb.transfer_flags.aligned_temp_buffer", FT_BOOLEAN
, 32,
6406 NULL
, URB_ALIGNED_TEMP_BUFFER
, NULL
, HFILL
}},
6408 /* Win32 USBPcap pseudoheader */
6409 { &hf_usb_win32_header_len
,
6410 { "USBPcap pseudoheader length", "usb.usbpcap_header_len",
6411 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
6415 { "IRP ID", "usb.irp_id",
6416 FT_UINT64
, BASE_HEX
, NULL
, 0x0,
6419 { &hf_usb_usbd_status
,
6420 { "IRP USBD_STATUS", "usb.usbd_status",
6421 FT_UINT32
, BASE_HEX
| BASE_EXT_STRING
, &win32_usbd_status_vals_ext
, 0x0,
6422 "USB request status value", HFILL
}},
6425 { "URB Function", "usb.function",
6426 FT_UINT16
, BASE_HEX
|BASE_EXT_STRING
, &win32_urb_function_vals_ext
, 0x0,
6430 { "IRP information", "usb.irp_info",
6431 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
6434 { &hf_usb_usbpcap_info_reserved
,
6435 { "Reserved", "usb.irp_info.reserved",
6436 FT_UINT8
, BASE_HEX
, NULL
, 0xFE,
6439 { &hf_usb_usbpcap_info_direction
,
6440 { "Direction", "usb.irp_info.direction",
6441 FT_UINT8
, BASE_HEX
, VALS(win32_usb_info_direction_vals
), 0x01,
6444 { &hf_usb_win32_device_address
,
6445 { "Device address", "usb.device_address",
6446 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
6447 "Windows USB device address", HFILL
}},
6449 { &hf_usb_win32_transfer_type
,
6450 { "URB transfer type", "usb.transfer_type",
6451 FT_UINT8
, BASE_HEX
, VALS(win32_usb_transfer_type_vals
), 0x0,
6454 { &hf_usb_win32_data_len
,
6455 { "Packet Data Length", "usb.data_len",
6456 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
6459 { &hf_usb_win32_control_stage
,
6460 { "Control transfer stage", "usb.control_stage",
6461 FT_UINT8
, BASE_DEC
, VALS(usb_control_stage_vals
), 0x0,
6464 { &hf_usb_win32_iso_start_frame
,
6465 { "Isochronous transfer start frame", "usb.win32.iso_frame",
6466 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
6469 { &hf_usb_win32_iso_num_packets
,
6470 { "Isochronous transfer number of packets", "usb.win32.iso_num_packets",
6471 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
6474 { &hf_usb_win32_iso_error_count
,
6475 { "Isochronous transfer error count", "usb.win32.iso_error_count",
6476 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
6479 { &hf_usb_win32_iso_offset
,
6480 { "ISO Data offset", "usb.win32.iso_offset",
6481 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
6484 { &hf_usb_win32_iso_length
,
6485 { "ISO Data length", "usb.win32.iso_data_len",
6486 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
6489 { &hf_usb_win32_iso_status
,
6490 { "ISO USBD status", "usb.win32.iso_status",
6491 FT_UINT32
, BASE_HEX
| BASE_EXT_STRING
, &win32_usbd_status_vals_ext
, 0x0,
6494 /* macOS usbdump pseudoheader */
6495 { &hf_usb_darwin_bcd_version
,
6496 { "Darwin header bcdVersion", "usb.darwin.bcdVersion",
6497 FT_UINT16
, BASE_HEX
, NULL
, 0x0,
6500 { &hf_usb_darwin_header_len
,
6501 { "Darwin header length", "usb.darwin.header_len",
6502 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
6505 { &hf_usb_darwin_request_type
,
6506 { "Request type", "usb.darwin.request_type",
6507 FT_UINT8
, BASE_DEC
, VALS(usb_darwin_request_type_vals
), 0x0,
6510 { &hf_usb_darwin_io_len
,
6511 { "I/O length [bytes]", "usb.darwin.io_len",
6512 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
6513 "Request length in bytes", HFILL
}},
6515 { &hf_usb_darwin_io_status
,
6516 { "Request status", "usb.darwin.io_status",
6517 FT_UINT32
, BASE_HEX
| BASE_EXT_STRING
, &usb_darwin_status_vals_ext
, 0x0,
6518 "USB request status", HFILL
}},
6520 { &hf_usb_darwin_iso_num_packets
,
6521 { "Isochronous transfer number of frames", "usb.darwin.io_frame_count",
6522 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
6525 { &hf_usb_darwin_io_id
,
6526 { "I/O ID", "usb.darwin.io_id",
6527 FT_UINT64
, BASE_HEX
, NULL
, 0x0,
6530 { &hf_usb_darwin_device_location
,
6531 { "Device location ID", "usb.darwin.location_id",
6532 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
6535 { &hf_usb_darwin_speed
,
6536 { "Device speed", "usb.darwin_device_speed",
6537 FT_UINT8
, BASE_DEC
, VALS(usb_darwin_speed_vals
), 0x0,
6540 { &hf_usb_darwin_device_address
,
6541 { "USB device index", "usb.darwin.device_address",
6542 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
6545 { &hf_usb_darwin_endpoint_address
,
6546 { "Endpoint address", "usb.darwin.endpoint_address",
6547 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
6548 "Endpoint address and direction", HFILL
}},
6550 { &hf_usb_darwin_endpoint_type
,
6551 { "Endpoint transfer type", "usb.darwin.endpoint_type",
6552 FT_UINT8
, BASE_DEC
, VALS(usb_darwin_endpoint_type_vals
), 0x0,
6555 { &hf_usb_darwin_iso_status
,
6556 { "Frame status", "usb.darwin.iso.status",
6557 FT_UINT32
, BASE_HEX
| BASE_EXT_STRING
, &usb_darwin_status_vals_ext
, 0x0,
6560 { &hf_usb_darwin_iso_timestamp
,
6561 { "Frame timestamp", "usb.darwin.iso.timestamp",
6562 FT_UINT64
, BASE_HEX
, NULL
, 0x0,
6565 { &hf_usb_darwin_iso_frame_number
,
6566 { "Frame number", "usb.darwin.iso.frame_number",
6567 FT_UINT64
, BASE_HEX
, NULL
, 0x0,
6570 { &hf_usb_bmRequestType
,
6571 { "bmRequestType", "usb.bmRequestType",
6572 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
6575 /* Only used when response type cannot be determined */
6576 { &hf_usb_control_response_generic
,
6577 { "CONTROL response data", "usb.control.Response",
6578 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
6582 { "bRequest", "usb.setup.bRequest",
6583 FT_UINT8
, BASE_DEC
| BASE_EXT_STRING
, &setup_request_names_vals_ext
, 0x0,
6586 /* Same as hf_usb_request but no descriptive text */
6587 { &hf_usb_request_unknown_class
,
6588 { "bRequest", "usb.setup.bRequest",
6589 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
6593 { "wValue", "usb.setup.wValue",
6594 FT_UINT16
, BASE_HEX
, NULL
, 0x0,
6598 { "wIndex", "usb.setup.wIndex",
6599 FT_UINT16
, BASE_DEC_HEX
, NULL
, 0x0,
6603 { "wLength", "usb.setup.wLength",
6604 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
6607 { &hf_usb_device_wFeatureSelector
,
6608 { "wFeatureSelector", "usb.setup.wFeatureSelector",
6609 FT_UINT16
, BASE_DEC
, VALS(usb_device_feature_selector_vals
), 0x0,
6612 { &hf_usb_interface_wFeatureSelector
,
6613 { "wFeatureSelector", "usb.setup.wFeatureSelector",
6614 FT_UINT16
, BASE_DEC
, VALS(usb_interface_feature_selector_vals
), 0x0,
6617 { &hf_usb_endpoint_wFeatureSelector
,
6618 { "wFeatureSelector", "usb.setup.wFeatureSelector",
6619 FT_UINT16
, BASE_DEC
, VALS(usb_endpoint_feature_selector_vals
), 0x0,
6622 { &hf_usb_wInterface
,
6623 { "wInterface", "usb.setup.wInterface",
6624 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
6627 { &hf_usb_wEndpoint
,
6628 { "wEndpoint", "usb.setup.wEndpoint",
6629 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
6633 { "wStatus", "usb.setup.wStatus",
6634 FT_UINT16
, BASE_HEX
, NULL
, 0x0,
6637 { &hf_usb_wFrameNumber
,
6638 { "wFrameNumber", "usb.setup.wFrameNumber",
6639 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
6642 /* --------------------------------- */
6643 { &hf_usb_iso_error_count
, /* host endian byte order */
6644 { "ISO error count", "usb.iso.error_count",
6645 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
6648 { &hf_usb_iso_numdesc
,
6649 { "Number of ISO descriptors", "usb.iso.numdesc",
6650 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
6653 /* fields of struct mon_bin_isodesc from linux/drivers/usb/mon/mon_bin.c */
6654 { &hf_usb_iso_status
,
6655 { "Status", "usb.iso.iso_status",
6656 FT_INT32
, BASE_DEC
|BASE_EXT_STRING
, &linux_negative_errno_vals_ext
, 0x0,
6657 "ISO descriptor status", HFILL
}},
6660 { "Offset [bytes]", "usb.iso.iso_off",
6661 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
6662 "ISO data offset in bytes starting from the end of the last ISO descriptor", HFILL
}},
6665 { "Length [bytes]", "usb.iso.iso_len",
6666 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
6667 "ISO data length in bytes", HFILL
}},
6669 { &hf_usb_iso_actual_len
,
6670 { "Actual Length [bytes]", "usb.iso.iso_actual_len",
6671 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
6672 "ISO data actual length in bytes", HFILL
}},
6674 { &hf_usb_iso_pad
, /* host endian byte order */
6675 { "Padding", "usb.iso.pad",
6676 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
6677 "Padding field of ISO descriptor structure", HFILL
}},
6680 {"ISO Data", "usb.iso.data",
6681 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
6683 /* --------------------------------- */
6686 {"Application Data Length", "usb.data.length",
6687 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
6692 {"Leftover Capture Data", "usb.capdata",
6693 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
6694 "Padding added by the USB capture system", HFILL
}},
6696 { &hf_usb_bmRequestType_direction
,
6697 { "Direction", "usb.bmRequestType.direction",
6698 FT_BOOLEAN
, 8, TFS(&tfs_bmrequesttype_direction
), USB_DIR_IN
,
6701 { &hf_usb_bmRequestType_type
,
6702 { "Type", "usb.bmRequestType.type",
6703 FT_UINT8
, BASE_HEX
, VALS(bmrequesttype_type_vals
), USB_TYPE_MASK
,
6706 { &hf_usb_bmRequestType_recipient
,
6707 { "Recipient", "usb.bmRequestType.recipient",
6708 FT_UINT8
, BASE_HEX
, VALS(bmrequesttype_recipient_vals
), 0x1f,
6711 { &hf_usb_bDescriptorType
,
6712 { "bDescriptorType", "usb.bDescriptorType",
6713 FT_UINT8
, BASE_HEX
|BASE_EXT_STRING
, &std_descriptor_type_vals_ext
, 0x0,
6716 /* Only used when descriptor type cannot be determined */
6717 { &hf_usb_get_descriptor_resp_generic
,
6718 { "GET DESCRIPTOR Response data", "usb.getDescriptor.Response",
6719 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
6722 { &hf_usb_descriptor_index
,
6723 { "Descriptor Index", "usb.DescriptorIndex",
6724 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
6727 { &hf_usb_language_id
,
6728 { "Language Id", "usb.LanguageId",
6729 FT_UINT16
, BASE_HEX
|BASE_EXT_STRING
,&usb_langid_vals_ext
, 0x0,
6733 { "bLength", "usb.bLength",
6734 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
6738 { "bcdUSB", "usb.bcdUSB",
6739 FT_UINT16
, BASE_HEX
, NULL
, 0x0,
6742 { &hf_usb_bDeviceClass
,
6743 { "bDeviceClass", "usb.bDeviceClass",
6744 FT_UINT8
, BASE_HEX
|BASE_EXT_STRING
, &usb_class_vals_ext
, 0x0,
6747 { &hf_usb_bDeviceSubClass
,
6748 { "bDeviceSubClass", "usb.bDeviceSubClass",
6749 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
6752 { &hf_usb_bDeviceProtocol
,
6753 { "bDeviceProtocol", "usb.bDeviceProtocol",
6754 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
6757 { &hf_usb_bMaxPacketSize0
,
6758 { "bMaxPacketSize0", "usb.bMaxPacketSize0",
6759 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
6763 { "idVendor", "usb.idVendor",
6764 FT_UINT16
, BASE_HEX
| BASE_EXT_STRING
, &ext_usb_vendors_vals
, 0x0,
6767 { &hf_usb_idProduct
,
6768 { "idProduct", "usb.idProduct",
6769 FT_UINT16
, BASE_HEX
, NULL
, 0x0,
6772 { &hf_usb_bcdDevice
,
6773 { "bcdDevice", "usb.bcdDevice",
6774 FT_UINT16
, BASE_HEX
, NULL
, 0x0,
6777 { &hf_usb_iManufacturer
,
6778 { "iManufacturer", "usb.iManufacturer",
6779 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
6783 { "iProduct", "usb.iProduct",
6784 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
6787 { &hf_usb_iSerialNumber
,
6788 { "iSerialNumber", "usb.iSerialNumber",
6789 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
6792 { &hf_usb_bNumConfigurations
,
6793 { "bNumConfigurations", "usb.bNumConfigurations",
6794 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
6798 { "wLANGID", "usb.wLANGID",
6799 FT_UINT16
, BASE_HEX
|BASE_EXT_STRING
,&usb_langid_vals_ext
, 0x0,
6803 { "bString", "usb.bString",
6804 FT_STRING
, BASE_NONE
, NULL
, 0x0,
6807 { &hf_usb_bInterfaceNumber
,
6808 { "bInterfaceNumber", "usb.bInterfaceNumber",
6809 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
6812 { &hf_usb_bAlternateSetting
,
6813 { "bAlternateSetting", "usb.bAlternateSetting",
6814 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
6817 { &hf_usb_bNumEndpoints
,
6818 { "bNumEndpoints", "usb.bNumEndpoints",
6819 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
6822 { &hf_usb_bInterfaceClass
,
6823 { "bInterfaceClass", "usb.bInterfaceClass",
6824 FT_UINT8
, BASE_HEX
|BASE_EXT_STRING
, &usb_class_vals_ext
, 0x0,
6827 { &hf_usb_bInterfaceSubClass
,
6828 { "bInterfaceSubClass", "usb.bInterfaceSubClass",
6829 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
6832 { &hf_usb_bInterfaceSubClass_audio
,
6833 { "bInterfaceSubClass", "usb.bInterfaceSubClass",
6834 FT_UINT8
, BASE_HEX
| BASE_EXT_STRING
, &ext_usb_audio_subclass_vals
, 0x0,
6837 { &hf_usb_bInterfaceSubClass_cdc
,
6838 { "bInterfaceSubClass", "usb.bInterfaceSubClass",
6839 FT_UINT8
, BASE_HEX
| BASE_EXT_STRING
, &ext_usb_com_subclass_vals
, 0x0,
6842 { &hf_usb_bInterfaceSubClass_massstorage
,
6843 { "bInterfaceSubClass", "usb.bInterfaceSubClass",
6844 FT_UINT8
, BASE_HEX
| BASE_EXT_STRING
, &ext_usb_massstorage_subclass_vals
, 0x0,
6847 { &hf_usb_bInterfaceSubClass_hid
,
6848 { "bInterfaceSubClass", "usb.bInterfaceSubClass",
6849 FT_UINT8
, BASE_HEX
| BASE_EXT_STRING
, &usb_hid_subclass_vals_ext
, 0x0,
6852 { &hf_usb_bInterfaceSubClass_misc
,
6853 { "bInterfaceSubClass", "usb.bInterfaceSubClass",
6854 FT_UINT8
, BASE_HEX
| BASE_EXT_STRING
, &usb_misc_subclass_vals_ext
, 0x0,
6857 { &hf_usb_bInterfaceSubClass_app
,
6858 { "bInterfaceSubClass", "usb.bInterfaceSubClass",
6859 FT_UINT8
, BASE_HEX
| BASE_EXT_STRING
, &usb_app_subclass_vals_ext
, 0x0,
6862 { &hf_usb_bInterfaceProtocol
,
6863 { "bInterfaceProtocol", "usb.bInterfaceProtocol",
6864 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
6867 { &hf_usb_bInterfaceProtocol_cdc
,
6868 { "bInterfaceProtocol", "usb.bInterfaceProtocol",
6869 FT_UINT8
, BASE_HEX
| BASE_EXT_STRING
, &usb_cdc_protocol_vals_ext
, 0x0,
6872 { &hf_usb_bInterfaceProtocol_massstorage
,
6873 { "bInterfaceProtocol", "usb.bInterfaceProtocol",
6874 FT_UINT8
, BASE_HEX
| BASE_EXT_STRING
, &usb_massstorage_protocol_vals_ext
, 0x0,
6877 { &hf_usb_bInterfaceProtocol_cdc_data
,
6878 { "bInterfaceProtocol", "usb.bInterfaceProtocol",
6879 FT_UINT8
, BASE_HEX
| BASE_EXT_STRING
, &usb_cdc_data_protocol_vals_ext
, 0x0,
6882 { &hf_usb_bInterfaceProtocol_hid_boot
,
6883 { "bInterfaceProtocol", "usb.bInterfaceProtocol",
6884 FT_UINT8
, BASE_HEX
| BASE_EXT_STRING
, &usb_hid_boot_protocol_vals_ext
, 0x0,
6887 { &hf_usb_bInterfaceProtocol_app_dfu
,
6888 { "bInterfaceProtocol", "usb.bInterfaceProtocol",
6889 FT_UINT8
, BASE_HEX
| BASE_EXT_STRING
, &usb_app_dfu_protocol_vals_ext
, 0x0,
6892 { &hf_usb_bInterfaceProtocol_app_irda
,
6893 { "bInterfaceProtocol", "usb.bInterfaceProtocol",
6894 FT_UINT8
, BASE_HEX
| BASE_EXT_STRING
, &usb_app_irda_protocol_vals_ext
, 0x0,
6897 { &hf_usb_bInterfaceProtocol_app_usb_test_and_measurement
,
6898 { "bInterfaceProtocol", "usb.bInterfaceProtocol",
6899 FT_UINT8
, BASE_HEX
| BASE_EXT_STRING
, &usb_app_usb_test_and_measurement_protocol_vals_ext
, 0x0,
6903 { &hf_usb_iInterface
,
6904 { "iInterface", "usb.iInterface",
6905 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
6908 { &hf_usb_bEndpointAddress
,
6909 { "bEndpointAddress", "usb.bEndpointAddress",
6910 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
6913 { &hf_usb_configuration_bmAttributes
,
6914 { "Configuration bmAttributes", "usb.configuration.bmAttributes",
6915 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
6918 { &hf_usb_bmAttributes
,
6919 { "bmAttributes", "usb.bmAttributes",
6920 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
6923 { &hf_usb_bEndpointAttributeTransfer
,
6924 { "Transfertype", "usb.bmAttributes.transfer",
6925 FT_UINT8
, BASE_HEX
, VALS(usb_bmAttributes_transfer_vals
), 0x03,
6928 { &hf_usb_bEndpointAttributeSynchonisation
,
6929 { "Synchronisationtype", "usb.bmAttributes.sync",
6930 FT_UINT8
, BASE_HEX
, VALS(usb_bmAttributes_sync_vals
), 0x0c,
6933 { &hf_usb_bEndpointAttributeBehaviour
,
6934 { "Behaviourtype", "usb.bmAttributes.behaviour",
6935 FT_UINT8
, BASE_HEX
, VALS(usb_bmAttributes_behaviour_vals
), 0x30,
6938 { &hf_usb_wMaxPacketSize
,
6939 { "wMaxPacketSize", "usb.wMaxPacketSize",
6940 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
6943 { &hf_usb_wMaxPacketSize_size
,
6944 { "Maximum Packet Size", "usb.wMaxPacketSize.size",
6945 FT_UINT16
, BASE_DEC
, NULL
, 0x07FF,
6948 { &hf_usb_wMaxPacketSize_slots
,
6949 { "Transactions per microframe", "usb.wMaxPacketSize.slots",
6950 FT_UINT16
, BASE_DEC
, VALS(usb_wMaxPacketSize_slots_vals
), (3<<11),
6953 { &hf_usb_bInterval
,
6954 { "bInterval", "usb.bInterval",
6955 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
6958 { &hf_usb_bMaxBurst
,
6959 { "bMaxBurst", "usb.bMaxBurst",
6960 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
6961 "Valid values are from 0 to 15. For control endpoints this value shall be 0.", HFILL
}},
6963 { &hf_usb_audio_bRefresh
,
6964 { "bRefresh", "usb.audio.bRefresh",
6965 FT_UINT8
, BASE_DEC
, NULL
, 0x00,
6968 { &hf_usb_audio_bSynchAddress
,
6969 { "bSynchAddress", "usb.audio.bSynchAddress",
6970 FT_UINT8
, BASE_DEC
, NULL
, 0x00,
6973 { &hf_usb_bSSEndpointAttributeBulkMaxStreams
,
6974 { "MaxStreams", "usb.bmAttributes.MaxStreams",
6975 FT_UINT8
, BASE_DEC
, NULL
, 0x0F,
6976 "Number of streams = 2 to the power MaxStreams", HFILL
}},
6978 { &hf_usb_bSSEndpointAttributeIsoMult
,
6979 { "Mult", "usb.bmAttributes.Mult",
6980 FT_UINT8
, BASE_DEC
, NULL
, 0x03,
6981 "Maximum number of packets = bMaxBurst * (Mult + 1)", HFILL
} },
6983 { &hf_usb_wBytesPerInterval
,
6984 { "wBytesPerInterval", "usb.wBytesPerInterval",
6985 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
6988 { &hf_usb_wTotalLength
,
6989 { "wTotalLength", "usb.wTotalLength",
6990 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
6993 { &hf_usb_bNumInterfaces
,
6994 { "bNumInterfaces", "usb.bNumInterfaces",
6995 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
6998 { &hf_usb_bConfigurationValue
,
6999 { "bConfigurationValue", "usb.bConfigurationValue",
7000 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
7003 { &hf_usb_iConfiguration
,
7004 { "iConfiguration", "usb.iConfiguration",
7005 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
7008 { &hf_usb_bMaxPower
,
7009 { "bMaxPower", "usb.bMaxPower",
7010 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
7013 { &hf_usb_configuration_legacy10buspowered
,
7014 { "Must be 1", "usb.configuration.legacy10buspowered",
7015 FT_BOOLEAN
, 8, TFS(&tfs_mustbeone
), 0x80,
7016 "Legacy USB 1.0 bus powered", HFILL
}},
7018 { &hf_usb_configuration_selfpowered
,
7019 { "Self-Powered", "usb.configuration.selfpowered",
7020 FT_BOOLEAN
, 8, TFS(&tfs_selfpowered
), 0x40,
7023 { &hf_usb_configuration_remotewakeup
,
7024 { "Remote Wakeup", "usb.configuration.remotewakeup",
7025 FT_BOOLEAN
, 8, TFS(&tfs_remotewakeup
), 0x20,
7028 { &hf_usb_bEndpointAddress_number
,
7029 { "Endpoint Number", "usb.bEndpointAddress.number",
7030 FT_UINT8
, BASE_HEX
, NULL
, 0x0f,
7033 { &hf_usb_bEndpointAddress_direction
,
7034 { "Direction", "usb.bEndpointAddress.direction",
7035 FT_BOOLEAN
, 8, TFS(&tfs_endpoint_direction
), 0x80,
7038 { &hf_usb_request_in
,
7039 { "Request in", "usb.request_in",
7040 FT_FRAMENUM
, BASE_NONE
, FRAMENUM_TYPE(FT_FRAMENUM_REQUEST
), 0,
7041 "The request to this packet is in this packet", HFILL
}},
7044 { "Time from request", "usb.time",
7045 FT_RELATIVE_TIME
, BASE_NONE
, NULL
, 0,
7046 "Time between Request and Response for USB cmds", HFILL
}},
7048 { &hf_usb_response_in
,
7049 { "Response in", "usb.response_in",
7050 FT_FRAMENUM
, BASE_NONE
, FRAMENUM_TYPE(FT_FRAMENUM_RESPONSE
), 0,
7051 "The response to this packet is in this packet", HFILL
}},
7053 { &hf_usb_bFirstInterface
,
7054 { "bFirstInterface", "usb.bFirstInterface",
7055 FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
7057 { &hf_usb_bInterfaceCount
,
7058 { "bInterfaceCount",
7059 "usb.bInterfaceCount", FT_UINT8
, BASE_DEC
,
7060 NULL
, 0x0, NULL
, HFILL
}},
7062 { &hf_usb_bFunctionClass
,
7063 { "bFunctionClass", "usb.bFunctionClass",
7064 FT_UINT8
, BASE_HEX
|BASE_EXT_STRING
, &usb_class_vals_ext
, 0x0, NULL
, HFILL
}},
7066 { &hf_usb_bFunctionSubClass
,
7067 { "bFunctionSubClass",
7068 "usb.bFunctionSubClass", FT_UINT8
, BASE_HEX
,
7069 NULL
, 0x0, NULL
, HFILL
}},
7071 { &hf_usb_bFunctionProtocol
,
7072 { "bFunctionProtocol", "usb.bFunctionProtocol",
7073 FT_UINT8
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
7075 { &hf_usb_iFunction
,
7077 "usb.iFunction", FT_UINT8
, BASE_DEC
,
7078 NULL
, 0x0, NULL
, HFILL
}},
7080 { &hf_usb_bNumDeviceCaps
,
7081 { "bNumDeviceCaps", "usb.bNumDeviceCaps",
7082 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
7085 { &hf_usb_bDevCapabilityType
,
7086 { "bDevCapabilityType", "usb.bDevCapabilityType",
7087 FT_UINT8
, BASE_HEX
|BASE_EXT_STRING
, &usb_capability_vals_ext
, 0x0,
7090 { &hf_usb_usb20ext_bmAttributes
,
7091 { "bmAttributes", "usb.usb20ext.bmAttributes",
7092 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
7095 { &hf_usb_usb20ext_LPM
,
7096 { "LPM", "usb.usb20ext.bmAttributes.LPM",
7097 FT_BOOLEAN
, 32, NULL
, 0x00000002,
7100 { &hf_usb_usb20ext_BESL_HIRD
,
7101 { "BESL & Alternate HIRD", "usb.usb20ext.bmAttributes.BESL",
7102 FT_BOOLEAN
, 32, NULL
, 0x00000004,
7105 { &hf_usb_usb20ext_baseline_BESL_valid
,
7106 { "Baseline BESL valid", "usb.usb20ext.bmAttributes.baseline_BESL_valid",
7107 FT_BOOLEAN
, 32, NULL
, 0x00000008,
7110 { &hf_usb_usb20ext_deep_BESL_valid
,
7111 { "Deep BESL valid", "usb.usb20ext.bmAttributes.deep_BESL_valid",
7112 FT_BOOLEAN
, 32, NULL
, 0x00000010,
7115 { &hf_usb_usb20ext_baseline_BESL
,
7116 { "Recommended Baseline BESL", "usb.usb20ext.bmAttributes.baseline_BESL",
7117 FT_UINT32
, BASE_CUSTOM
, CF_FUNC(usb_lpm_besl_str
), 0x00000F00,
7120 { &hf_usb_usb20ext_deep_BESL
,
7121 { "Recommended Deep BESL", "usb.usb20ext.bmAttributes.deep_BESL",
7122 FT_UINT32
, BASE_CUSTOM
, CF_FUNC(usb_lpm_besl_str
), 0x0000F000,
7125 { &hf_usb_bReserved
,
7126 { "bReserved", "usb.bReserved",
7127 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
7128 "This field is reserved and shall be set to zero", HFILL
}},
7130 { &hf_usb_PlatformCapabilityUUID
,
7131 { "PlatformCapabilityUUID", "usb.PlatformCapabilityUUID",
7132 FT_GUID
, BASE_NONE
, NULL
, 0x0,
7135 { &hf_usb_webusb_bcdVersion
,
7136 { "bcdVersion", "usb.webusb.bcdVersion",
7137 FT_UINT16
, BASE_HEX
, NULL
, 0x0,
7138 "WebUSB descriptor version", HFILL
}},
7140 { &hf_usb_webusb_bVendorCode
,
7141 { "bVendorCode", "usb.webusb.bVendorCode",
7142 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
7143 "bRequest value for WebUSB", HFILL
}},
7145 { &hf_usb_webusb_iLandingPage
,
7146 { "iLandingPage", "usb.webusb.iLandingPage",
7147 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
7148 "URL for landing page", HFILL
}},
7150 { &hf_usb_msos20_dwWindowsVersion
,
7151 { "dwWindowsVersion", "usb.msos20.dwWindowsVersion",
7152 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
7155 { &hf_usb_msos20_wMSOSDescriptorSetTotalLength
,
7156 { "wMSOSDescriptorSetTotalLength", "usb.msos20.wMSOSDescriptorSetTotalLength",
7157 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
7160 { &hf_usb_msos20_bMS_VendorCode
,
7161 { "bMS_VendorCode", "usb.msos20.bMS_VendorCode",
7162 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
7165 { &hf_usb_msos20_bAltEnumCode
,
7166 { "bAltEnumCode", "usb.msos20.bAltEnumCode",
7167 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
7170 { &hf_usb_data_fragment
,
7172 "usb.data_fragment", FT_BYTES
, BASE_NONE
,
7173 NULL
, 0x0, NULL
, HFILL
}},
7175 { "Source", "usb.src",
7176 FT_STRING
, BASE_NONE
, NULL
, 0x0,
7180 { "Destination", "usb.dst",
7181 FT_STRING
, BASE_NONE
, NULL
, 0x0,
7185 { "Source or Destination", "usb.addr",
7186 FT_STRING
, BASE_NONE
, NULL
, 0x0,
7189 { &hf_usb_ss_bmAttributes
,
7190 { "bmAttributes", "usb.ss.bmAttributes",
7191 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
7193 { &hf_usb_ss_bmAttributes_reserved0
,
7194 { "Reserved", "usb.ss.bmAttributes.reserved0",
7195 FT_BOOLEAN
, 8, TFS(&tfs_usb_ss_bmAttributes_reserved0
), 0x01,
7197 { &hf_usb_ss_bmAttributes_LTM
,
7198 { "LTM", "usb.ss.bmAttributes.LTM",
7199 FT_BOOLEAN
, 8, NULL
, 0x02,
7201 { &hf_usb_ss_bmAttributes_reserved7_2
,
7202 { "Reserved", "usb.ss.bmAttributes.reserved7_2",
7203 FT_UINT8
, BASE_HEX
, NULL
, 0xFC,
7205 { &hf_usb_ss_wSpeedSupported
,
7206 { "wSpeedSupported", "usb.ss.wSpeedSupported",
7207 FT_UINT16
, BASE_HEX
, NULL
, 0x0,
7209 { &hf_usb_ss_wSpeedSupported_LS
,
7210 { SS_SPEED_SUPPORTED_STR_LS
, "usb.ss.wSpeedSupported.LS",
7211 FT_BOOLEAN
, 16, NULL
, 1 << SS_SPEED_SUPPORTED_BIT_LS
,
7213 { &hf_usb_ss_wSpeedSupported_FS
,
7214 { SS_SPEED_SUPPORTED_STR_FS
, "usb.ss.wSpeedSupported.FS",
7215 FT_BOOLEAN
, 16, NULL
, 1 << SS_SPEED_SUPPORTED_BIT_FS
,
7217 { &hf_usb_ss_wSpeedSupported_HS
,
7218 { SS_SPEED_SUPPORTED_STR_HS
, "usb.ss.wSpeedSupported.HS",
7219 FT_BOOLEAN
, 16, NULL
, 1 << SS_SPEED_SUPPORTED_BIT_HS
,
7221 { &hf_usb_ss_wSpeedSupported_Gen1
,
7222 { SS_SPEED_SUPPORTED_STR_GEN1
, "usb.ss.wSpeedSupported.Gen1",
7223 FT_BOOLEAN
, 16, NULL
, 1 << SS_SPEED_SUPPORTED_BIT_GEN1
,
7225 { &hf_usb_ss_wSpeedSupported_reserved
,
7226 { "Reserved", "usb.ss.wSpeedSupported.reserved",
7227 FT_UINT16
, BASE_HEX
, NULL
, 0xFFF0,
7229 { &hf_usb_ss_bFunctionalitySupport
,
7230 { "bFunctionalitySupport", "usb.ss.bFunctionalitySupport",
7231 FT_UINT8
, BASE_HEX
|BASE_EXT_STRING
, &usb_ss_bFunctionalitySupport_vals_ext
, 0x0,
7233 { &hf_usb_ss_bU1DevExitLat
,
7234 { "bU1DevExitLat", "usb.ss.bU1DevExitLat",
7235 FT_UINT8
, BASE_DEC
|BASE_UNIT_STRING
, UNS(&units_microseconds
), 0x0,
7237 { &hf_usb_ss_wU2DevExitLat
,
7238 { "wU2DevExitLat", "usb.ss.wU2DevExitLat",
7239 FT_UINT16
, BASE_DEC
|BASE_UNIT_STRING
, UNS(&units_microseconds
), 0x0,
7243 static hf_register_info hf_usbport
[] = {
7244 { &hf_usbport_event_id
,
7245 { "Event ID", "usbport.event_id",
7246 FT_UINT32
, BASE_DEC_HEX
|BASE_EXT_STRING
, &netmon_event_id_vals_ext
, 0x0,
7249 { &hf_usbport_device_object
,
7250 { "Device Object", "usbport.device_object",
7251 FT_UINT64
, BASE_HEX
, NULL
, 0x0,
7254 { &hf_usbport_pci_bus
,
7255 { "PCI Bus", "usbport.pci_bus",
7256 FT_UINT32
, BASE_DEC_HEX
, NULL
, 0x0,
7259 { &hf_usbport_pci_device
,
7260 { "PCI Bus", "usbport.pci_device",
7261 FT_UINT16
, BASE_DEC_HEX
, NULL
, 0x0,
7264 { &hf_usbport_pci_function
,
7265 { "PCI Function", "usbport.pci_function",
7266 FT_UINT16
, BASE_DEC_HEX
, NULL
, 0x0,
7269 { &hf_usbport_pci_vendor_id
,
7270 { "PCI Vendor ID", "usbport.pci_vendor_id",
7271 FT_UINT16
, BASE_DEC_HEX
, NULL
, 0x0,
7274 { &hf_usbport_pci_device_id
,
7275 { "PCI Device ID", "usbport.pci_device_id",
7276 FT_UINT16
, BASE_DEC_HEX
, NULL
, 0x0,
7279 { &hf_usbport_port_path_depth
,
7280 { "Path Depth", "usbport.port_path_depth",
7281 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
7284 { &hf_usbport_port_path0
,
7285 { "Path0", "usbport.port_path0",
7286 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
7289 { &hf_usbport_port_path1
,
7290 { "Path1", "usbport.port_path1",
7291 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
7294 { &hf_usbport_port_path2
,
7295 { "Path2", "usbport.port_path2",
7296 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
7299 { &hf_usbport_port_path3
,
7300 { "Path3", "usbport.port_path3",
7301 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
7304 { &hf_usbport_port_path4
,
7305 { "Path4", "usbport.port_path4",
7306 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
7309 { &hf_usbport_port_path5
,
7310 { "Path5", "usbport.port_path5",
7311 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
7314 { &hf_usbport_device_handle
,
7315 { "Device Handle", "usbport.device_handle",
7316 FT_UINT64
, BASE_HEX
, NULL
, 0x0,
7319 { &hf_usbport_device_speed
,
7320 { "Device Speed", "usbport.device_speed",
7321 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
7324 { &hf_usbport_endpoint
,
7325 { "Endpoint", "usbport.endpoint",
7326 FT_UINT64
, BASE_HEX
, NULL
, 0x0,
7329 { &hf_usbport_pipehandle
,
7330 { "Pipe Handle", "usbport.pipehandle",
7331 FT_UINT64
, BASE_HEX
, NULL
, 0x0,
7334 { &hf_usbport_endpoint_desc_length
,
7335 { "Length", "usbport.endpoint_desc_length",
7336 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
7339 { &hf_usbport_endpoint_desc_type
,
7340 { "Description Type", "usbport.endpoint_desc_type",
7341 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
7344 { &hf_usbport_endpoint_address
,
7345 { "Endpoint Address", "usbport.endpoint_address",
7346 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
7349 { &hf_usbport_bm_attributes
,
7350 { "bmAttributes", "usbport.bm_attributes",
7351 FT_UINT8
, BASE_DEC_HEX
, NULL
, 0x0,
7354 { &hf_usbport_max_packet_size
,
7355 { "Max Packet Size", "usbport.max_packet_size",
7356 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
7359 { &hf_usbport_interval
,
7360 { "Interval", "usbport.interval",
7361 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
7365 { "IRP", "usbport.irp",
7366 FT_UINT64
, BASE_HEX
, NULL
, 0x0,
7370 { "URB", "usbport.urb",
7371 FT_UINT64
, BASE_HEX
, NULL
, 0x0,
7374 { &hf_usbport_urb_transfer_data
,
7375 { "URB Transfer data", "usbport.urb_transfer_data",
7376 FT_UINT_BYTES
, BASE_NONE
, NULL
, 0x0,
7379 { &hf_usbport_urb_header_length
,
7380 { "URB Header Length", "usbport.urb_header_length",
7381 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
7384 { &hf_usbport_urb_header_function
,
7385 { "URB Header Function", "usbport.urb_header_function",
7386 FT_UINT16
, BASE_DEC
|BASE_EXT_STRING
, &netmon_urb_function_vals_ext
, 0x0,
7389 { &hf_usbport_urb_header_status
,
7390 { "URB Header Status", "usbport.urb_header_status",
7391 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
7394 { &hf_usbport_urb_header_usbddevice_handle
,
7395 { "URB Header Device Handle", "usbport.urb_header_usbddevice_handle",
7396 FT_UINT64
, BASE_HEX
, NULL
, 0x0,
7399 { &hf_usbport_urb_header_usbdflags
,
7400 { "URB Header Flags", "usbport.urb_header_usbdflags",
7401 FT_UINT64
, BASE_HEX
, NULL
, 0x0,
7404 { &hf_usbport_urb_configuration_desc
,
7405 { "URB Configuration Description", "usbport.urb_configuration_desc",
7406 FT_UINT64
, BASE_HEX
, NULL
, 0x0,
7409 { &hf_usbport_urb_configuration_handle
,
7410 { "URB Configuration Handle", "usbport.urb_configuration_handle",
7411 FT_UINT64
, BASE_HEX
, NULL
, 0x0,
7414 { &hf_usbport_urb_pipe_handle
,
7415 { "URB Pipe Handle", "usbport.urb_pipe_handle",
7416 FT_UINT64
, BASE_HEX
, NULL
, 0x0,
7419 { &hf_usbport_urb_xferflags
,
7420 { "URB Transfer Flags", "usbport.urb_xferflags",
7421 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
7424 { &hf_usbport_urb_transfer_buffer_length
,
7425 { "URB Transfer Buffer Length", "usbport.urb_transfer_buffer_length",
7426 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
7429 { &hf_usbport_urb_transfer_buffer
,
7430 { "URB Transfer Buffer", "usbport.urb_transfer_buffer",
7431 FT_UINT64
, BASE_HEX
, NULL
, 0x0,
7434 { &hf_usbport_urb_transfer_buffer_mdl
,
7435 { "URB Transfer Buffer MDL", "usbport.urb_transfer_buffer_mdl",
7436 FT_UINT64
, BASE_HEX
, NULL
, 0x0,
7439 { &hf_usbport_urb_reserved_mbz
,
7440 { "URB Reserved MBZ", "usbport.urb_reserved_mbz",
7441 FT_UINT64
, BASE_HEX
, NULL
, 0x0,
7444 { &hf_usbport_urb_reserved_hcd
,
7445 { "URB Reserved HCD", "usbport.urb_reserved_hcd",
7446 FT_UINT64
, BASE_HEX
, NULL
, 0x0,
7449 { &hf_usbport_urb_reserved
,
7450 { "URB Reserved", "usbport.urb_reserved",
7451 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
7454 { &hf_usbport_keyword
,
7455 { "Keyword", "usbport.keyword",
7456 FT_UINT64
, BASE_HEX
, NULL
, 0x0,
7459 { &hf_usbport_keyword_diagnostic
,
7460 { "USBPORT_ETW_KEYWORD_DIAGNOSTIC", "usbport.keyword.diagnostic",
7461 FT_BOOLEAN
, 64, NULL
, USBPORT_KEYWORD_DIAGNOSTIC
,
7464 { &hf_usbport_keyword_power_diagnostics
,
7465 { "USBPORT_ETW_KEYWORD_POWER_DIAGNOSTICS", "usbport.keyword.power_diagnostics",
7466 FT_BOOLEAN
, 64, NULL
, USBPORT_KEYWORD_POWER_DIAGNOSTICS
,
7469 { &hf_usbport_keyword_perf_diagnostics
,
7470 { "USBPORT_ETW_KEYWORD_PERF_DIAGNOSTICS", "usbport.keyword.perf_diagnostics",
7471 FT_BOOLEAN
, 64, NULL
, USBPORT_KEYWORD_PERF_DIAGNOSTICS
,
7474 { &hf_usbport_keyword_reserved1
,
7475 { "Reserved1", "usbport.keyword.reserved1",
7476 FT_UINT64
, BASE_HEX
, NULL
, USBPORT_KEYWORD_RESERVED1
,
7481 static int *usb_ett
[] = {
7485 &ett_usb_win32_iso_packet
,
7488 &ett_usb_xferstatus
,
7490 &ett_usb_frame_flags
,
7491 &ett_usb_setup_bmrequesttype
,
7492 &ett_usb_usbpcap_info
,
7493 &ett_descriptor_device
,
7494 &ett_configuration_bmAttributes
,
7495 &ett_configuration_bEndpointAddress
,
7496 &ett_endpoint_bmAttributes
,
7497 &ett_endpoint_wMaxPacketSize
,
7498 &ett_transfer_flags
,
7499 &ett_usb20ext_bmAttributes
,
7500 &ett_ss_bmAttributes
,
7501 &ett_ss_wSpeedSupported
,
7504 static int *usbport_ett
[] = {
7506 &ett_usbport_host_controller
,
7508 &ett_usbport_device
,
7509 &ett_usbport_endpoint
,
7510 &ett_usbport_endpoint_desc
,
7512 &ett_usbport_keyword
,
7515 static ei_register_info ei
[] = {
7516 { &ei_usb_undecoded
, { "usb.undecoded", PI_UNDECODED
, PI_WARN
, "Not dissected yet (report to wireshark.org)", EXPFILL
}},
7517 { &ei_usb_bLength_even
, { "usb.bLength.even", PI_PROTOCOL
, PI_WARN
, "Invalid STRING DESCRIPTOR Length (must be even)", EXPFILL
}},
7518 { &ei_usb_bLength_too_short
, { "usb.bLength.too_short", PI_MALFORMED
, PI_ERROR
, "Invalid STRING DESCRIPTOR Length (must be 2 or larger)", EXPFILL
}},
7519 { &ei_usb_desc_length_invalid
, { "usb.desc_length.invalid", PI_MALFORMED
, PI_ERROR
, "Invalid descriptor length", EXPFILL
}},
7520 { &ei_usb_invalid_setup
, { "usb.setup.invalid", PI_MALFORMED
, PI_ERROR
, "Only control URBs may contain a setup packet", EXPFILL
}},
7521 { &ei_usb_ss_ep_companion_before_ep
, { "usb.bmAttributes.invalid_order", PI_MALFORMED
, PI_ERROR
, "SuperSpeed Endpoint Companion must come after Endpoint Descriptor", EXPFILL
}},
7522 { &ei_usb_usbpcap_unknown_urb
, { "usb.usbpcap.unknown_urb", PI_MALFORMED
, PI_ERROR
, "USBPcap did not recognize URB Function code (report to desowin.org/USBPcap)", EXPFILL
}},
7523 { &ei_usb_bad_length
, { "usb.bad_length", PI_MALFORMED
, PI_ERROR
, "Invalid length", EXPFILL
}},
7524 { &ei_usb_invalid_max_packet_size
, { "usb.wMaxPacketSize.invalid", PI_PROTOCOL
, PI_WARN
, "Invalid Max Packet Size", EXPFILL
}},
7525 { &ei_usb_invalid_max_packet_size0
, { "usb.bMaxPacketSize0.invalid", PI_PROTOCOL
, PI_WARN
, "Invalid Max Packet Size", EXPFILL
}},
7526 { &ei_usb_invalid_endpoint_type
, { "usb.bmAttributes.transfer.invalid", PI_PROTOCOL
, PI_WARN
, "Transfer type not allowed at Low-Speed", EXPFILL
}},
7527 { &ei_usb_unexpected_desc_type
, { "usb.bDescriptorType.unexpected", PI_MALFORMED
, PI_ERROR
, "Unexpected descriptor type", EXPFILL
}},
7529 static ei_register_info ei_usbport
[] = {
7530 { &ei_usbport_invalid_path_depth
, { "usbport.path_depth.invalid", PI_PROTOCOL
, PI_WARN
, "Invalid path depth", EXPFILL
}},
7533 expert_module_t
*expert_usb
, *expert_usbport
;
7535 proto_usb
= proto_register_protocol("USB", "USB", "usb");
7536 proto_usbport
= proto_register_protocol("USBPort", "USBPort", "usbport");
7538 proto_register_field_array(proto_usb
, hf
, array_length(hf
));
7539 proto_register_field_array(proto_usbport
, hf_usbport
, array_length(hf_usbport
));
7540 proto_register_subtree_array(usb_ett
, array_length(usb_ett
));
7541 proto_register_subtree_array(usbport_ett
, array_length(usbport_ett
));
7543 expert_usb
= expert_register_protocol(proto_usb
);
7544 expert_register_field_array(expert_usb
, ei
, array_length(ei
));
7545 expert_usbport
= expert_register_protocol(proto_usbport
);
7546 expert_register_field_array(expert_usbport
, ei_usbport
, array_length(ei_usbport
));
7548 device_to_product_table
= wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope());
7549 device_to_protocol_table
= wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope());
7550 usbpcap_setup_data
= wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope());
7551 device_to_dissector
= register_dissector_table("usb.device", "USB device", proto_usb
, FT_UINT32
, BASE_HEX
);
7552 protocol_to_dissector
= register_dissector_table("usb.protocol", "USB protocol", proto_usb
, FT_UINT32
, BASE_HEX
);
7553 product_to_dissector
= register_dissector_table("usb.product", "USB product", proto_usb
, FT_UINT32
, BASE_HEX
);
7555 usb_bulk_dissector_table
= register_dissector_table("usb.bulk",
7556 "USB bulk endpoint", proto_usb
, FT_UINT32
, BASE_HEX
);
7557 heur_bulk_subdissector_list
= register_heur_dissector_list_with_description("usb.bulk", "USB bulk fallback", proto_usb
);
7558 usb_control_dissector_table
= register_dissector_table("usb.control",
7559 "USB control endpoint", proto_usb
, FT_UINT32
, BASE_HEX
);
7560 heur_control_subdissector_list
= register_heur_dissector_list_with_description("usb.control", "USB control fallback", proto_usb
);
7561 usb_interrupt_dissector_table
= register_dissector_table("usb.interrupt",
7562 "USB interrupt endpoint", proto_usb
, FT_UINT32
, BASE_HEX
);
7563 heur_interrupt_subdissector_list
= register_heur_dissector_list_with_description("usb.interrupt", "USB interrupt fallback", proto_usb
);
7564 usb_descriptor_dissector_table
= register_dissector_table("usb.descriptor",
7565 "USB descriptor", proto_usb
, FT_UINT8
, BASE_DEC
);
7567 usb_module
= prefs_register_protocol(proto_usb
, NULL
);
7568 prefs_register_bool_preference(usb_module
, "try_heuristics",
7569 "Try heuristic sub-dissectors",
7570 "Try to decode a packet using a heuristic sub-dissector before "
7571 "attempting to dissect the packet using the \"usb.bulk\", \"usb.interrupt\" or "
7572 "\"usb.control\" dissector tables.", &try_heuristics
);
7574 usb_tap
= register_tap("usb");
7576 register_decode_as(&usb_protocol_da
);
7577 register_decode_as(&usb_product_da
);
7578 register_decode_as(&usb_device_da
);
7580 linux_usb_handle
= register_dissector("usb_linux", dissect_linux_usb
, proto_usb
);
7581 linux_usb_mmapped_handle
= register_dissector("usb_linux_mmapped", dissect_linux_usb_mmapped
, proto_usb
);
7582 win32_usb_handle
= register_dissector("usb_win32", dissect_win32_usb
, proto_usb
);
7583 freebsd_usb_handle
= register_dissector("usb_freebsd", dissect_freebsd_usb
, proto_usb
);
7584 darwin_usb_handle
= register_dissector("usb_darwin", dissect_darwin_usb
, proto_usb
);
7585 netmon_usb_port_handle
= register_dissector("usb_netmon", dissect_netmon_usb_port
, proto_usbport
);
7587 usb_address_type
= address_type_dissector_register("AT_USB", "USB Address", usb_addr_to_str
, usb_addr_str_len
, NULL
, usb_col_filter_str
, NULL
, NULL
, NULL
);
7589 register_conversation_table(proto_usb
, true, usb_conversation_packet
, usb_endpoint_packet
);
7593 proto_reg_handoff_usb(void)
7595 static guid_key usb_port_key
= {{ 0xc88a4ef5, 0xd048, 0x4013, { 0x94, 0x08, 0xe0, 0x4b, 0x7d, 0xb2, 0x81, 0x4a }}, 0 };
7597 dissector_add_uint("wtap_encap", WTAP_ENCAP_USB_LINUX
, linux_usb_handle
);
7598 dissector_add_uint("wtap_encap", WTAP_ENCAP_USB_LINUX_MMAPPED
, linux_usb_mmapped_handle
);
7599 dissector_add_uint("wtap_encap", WTAP_ENCAP_USBPCAP
, win32_usb_handle
);
7600 dissector_add_uint("wtap_encap", WTAP_ENCAP_USB_FREEBSD
, freebsd_usb_handle
);
7601 dissector_add_uint("wtap_encap", WTAP_ENCAP_USB_DARWIN
, darwin_usb_handle
);
7603 dissector_add_guid( "netmon.provider_id", &usb_port_key
, netmon_usb_port_handle
);
7607 * Editor modelines - https://www.wireshark.org/tools/modelines.html
7612 * indent-tabs-mode: nil
7615 * vi: set shiftwidth=4 tabstop=8 expandtab:
7616 * :indentSize=4:tabSize=8:noTabs=true: