Bug Summary

File:builds/wireshark/wireshark/epan/dissectors/packet-usb.c
Warning:line 4251, column 17
Access to field 'interfaceClass' results in a dereference of a null pointer (loaded from field 'conv')

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name packet-usb.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -fno-delete-null-pointer-checks -mframe-pointer=all -relaxed-aliasing -fmath-errno -ffp-contract=on -fno-rounding-math -ffloat16-excess-precision=fast -fbfloat16-excess-precision=fast -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/builds/wireshark/wireshark/build -fcoverage-compilation-dir=/builds/wireshark/wireshark/build -resource-dir /usr/lib/llvm-22/lib/clang/22 -isystem /usr/include/glib-2.0 -isystem /usr/lib/x86_64-linux-gnu/glib-2.0/include -isystem /builds/wireshark/wireshark/epan/dissectors -isystem /builds/wireshark/wireshark/build/epan/dissectors -isystem /usr/include/mit-krb5 -isystem /usr/include/libxml2 -isystem /builds/wireshark/wireshark/epan -D CARES_NO_DEPRECATED -D G_DISABLE_DEPRECATED -D G_DISABLE_SINGLE_INCLUDES -D WS_BUILD_DLL -D WS_DEBUG -D WS_DEBUG_UTF_8 -I /builds/wireshark/wireshark/build -I /builds/wireshark/wireshark -I /builds/wireshark/wireshark/include -D _GLIBCXX_ASSERTIONS -internal-isystem /usr/lib/llvm-22/lib/clang/22/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fmacro-prefix-map=/builds/wireshark/wireshark/= -fmacro-prefix-map=/builds/wireshark/wireshark/build/= -fmacro-prefix-map=../= -Wno-format-nonliteral -std=gnu17 -ferror-limit 19 -fvisibility=hidden -fwrapv -fwrapv-pointer -fstrict-flex-arrays=3 -stack-protector 2 -fstack-clash-protection -fcf-protection=full -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fexceptions -fcolor-diagnostics -analyzer-output=html -faddrsig -fdwarf2-cfi-asm -o /builds/wireshark/wireshark/sbout/2026-10-20-100337-3661-1 -x c /builds/wireshark/wireshark/epan/dissectors/packet-usb.c
1/* packet-usb.c
2 *
3 * USB basic dissector
4 * By Paolo Abeni <[email protected]>
5 * Ronnie Sahlberg 2006
6 *
7 * http://www.usb.org/developers/docs/usb_20_122909-2.zip
8 *
9 * https://github.com/torvalds/linux/blob/master/Documentation/usb/usbmon.rst
10 *
11 * http://desowin.org/usbpcap/captureformat.html
12 *
13 * SPDX-License-Identifier: GPL-2.0-or-later
14 */
15
16
17#include "config.h"
18
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>
31
32#include "data-usb.h"
33#include "data-errno.h"
34#include "packet-usb.h"
35#include "packet-mausb.h"
36#include "packet-usbip.h"
37#include "packet-netmon.h"
38
39/* dissector handles */
40static dissector_handle_t linux_usb_handle;
41static dissector_handle_t linux_usb_mmapped_handle;
42static dissector_handle_t win32_usb_handle;
43static dissector_handle_t freebsd_usb_handle;
44static dissector_handle_t darwin_usb_handle;
45static dissector_handle_t netmon_usb_port_handle;
46
47/* protocols and header fields */
48static int proto_usb;
49static int proto_usbport;
50
51/* USB pseudoheader fields, both FreeBSD and Linux */
52static int hf_usb_totlen;
53static int hf_usb_busunit;
54static int hf_usb_address;
55static int hf_usb_mode;
56static int hf_usb_freebsd_urb_type;
57static int hf_usb_freebsd_transfer_type;
58static int hf_usb_xferflags;
59static int hf_usb_xferflags_force_short_xfer;
60static int hf_usb_xferflags_short_xfer_ok;
61static int hf_usb_xferflags_short_frames_ok;
62static int hf_usb_xferflags_pipe_bof;
63static int hf_usb_xferflags_proxy_buffer;
64static int hf_usb_xferflags_ext_buffer;
65static int hf_usb_xferflags_manual_status;
66static int hf_usb_xferflags_no_pipe_ok;
67static int hf_usb_xferflags_stall_pipe;
68static int hf_usb_xferstatus;
69static int hf_usb_xferstatus_open;
70static int hf_usb_xferstatus_transferring;
71static int hf_usb_xferstatus_did_dma_delay;
72static int hf_usb_xferstatus_did_close;
73static int hf_usb_xferstatus_draining;
74static int hf_usb_xferstatus_started;
75static int hf_usb_xferstatus_bw_reclaimed;
76static int hf_usb_xferstatus_control_xfr;
77static int hf_usb_xferstatus_control_hdr;
78static int hf_usb_xferstatus_control_act;
79static int hf_usb_xferstatus_control_stall;
80static int hf_usb_xferstatus_short_frames_ok;
81static int hf_usb_xferstatus_short_xfer_ok;
82static int hf_usb_xferstatus_bdma_enable;
83static int hf_usb_xferstatus_bdma_no_post_sync;
84static int hf_usb_xferstatus_bdma_setup;
85static int hf_usb_xferstatus_isochronous_xfr;
86static int hf_usb_xferstatus_curr_dma_set;
87static int hf_usb_xferstatus_can_cancel_immed;
88static int hf_usb_xferstatus_doing_callback;
89static int hf_usb_error;
90static int hf_usb_interval;
91static int hf_usb_nframes;
92static int hf_usb_packet_size;
93static int hf_usb_packet_count;
94static int hf_usb_speed;
95static int hf_usb_frame_length;
96static int hf_usb_frame_flags;
97static int hf_usb_frame_flags_read;
98static int hf_usb_frame_flags_data_follows;
99static int hf_usb_frame_data;
100static int hf_usb_urb_id;
101static int hf_usb_linux_urb_type;
102static int hf_usb_linux_transfer_type;
103static int hf_usb_endpoint_address;
104static int hf_usb_endpoint_direction;
105static int hf_usb_endpoint_number;
106static int hf_usb_device_address;
107static int hf_usb_bus_id;
108static int hf_usb_setup_flag;
109static int hf_usb_data_flag;
110static int hf_usb_urb_ts_sec;
111static int hf_usb_urb_ts_usec;
112static int hf_usb_urb_status;
113static int hf_usb_urb_len;
114static int hf_usb_urb_data_len;
115static int hf_usb_urb_unused_setup_header;
116static int hf_usb_urb_interval;
117static int hf_usb_urb_start_frame;
118static int hf_usb_urb_copy_of_transfer_flags;
119
120/* transfer_flags */
121static int hf_short_not_ok;
122static int hf_iso_asap;
123static int hf_no_transfer_dma_map;
124static int hf_no_fsbr;
125static int hf_zero_packet;
126static int hf_no_interrupt;
127static int hf_free_buffer;
128static int hf_dir_in;
129static int hf_dma_map_single;
130static int hf_dma_map_page;
131static int hf_dma_map_sg;
132static int hf_map_local;
133static int hf_setup_map_single;
134static int hf_setup_map_local;
135static int hf_dma_sg_combined;
136static int hf_aligned_temp_buffer;
137
138static int * const transfer_flags_fields[] = {
139 &hf_short_not_ok,
140 &hf_iso_asap,
141 &hf_no_transfer_dma_map,
142 &hf_no_fsbr,
143 &hf_zero_packet,
144 &hf_no_interrupt,
145 &hf_free_buffer,
146 &hf_dir_in,
147 &hf_dma_map_single,
148 &hf_dma_map_page,
149 &hf_dma_map_sg,
150 &hf_map_local,
151 &hf_setup_map_single,
152 &hf_setup_map_local,
153 &hf_dma_sg_combined,
154 &hf_aligned_temp_buffer,
155 NULL((void*)0)
156};
157
158/* Win32 USBPcap pseudoheader fields */
159static int hf_usb_win32_header_len;
160static int hf_usb_irp_id;
161static int hf_usb_usbd_status;
162static int hf_usb_function;
163static int hf_usb_info;
164static int hf_usb_usbpcap_info_reserved;
165static int hf_usb_usbpcap_info_direction;
166static int hf_usb_win32_device_address;
167static int hf_usb_win32_transfer_type;
168/* hf_usb_bus_id, hf_usb_endpoint_address, hf_usb_endpoint_direction,
169 * hf_usb_endpoint_number are common with
170 * FreeBSD and Linux pseudoheaders */
171static int hf_usb_win32_data_len;
172static int hf_usb_win32_control_stage;
173static int hf_usb_win32_iso_start_frame;
174static int hf_usb_win32_iso_num_packets;
175static int hf_usb_win32_iso_error_count;
176static int hf_usb_win32_iso_offset;
177static int hf_usb_win32_iso_length;
178static int hf_usb_win32_iso_status;
179
180static int hf_usb_request;
181static int hf_usb_request_unknown_class;
182static int hf_usb_value;
183static int hf_usb_index;
184static int hf_usb_length;
185/* static int hf_usb_data_len; */
186static int hf_usb_capdata;
187static int hf_usb_device_wFeatureSelector;
188static int hf_usb_interface_wFeatureSelector;
189static int hf_usb_endpoint_wFeatureSelector;
190static int hf_usb_wInterface;
191static int hf_usb_wEndpoint;
192static int hf_usb_wStatus;
193static int hf_usb_wFrameNumber;
194
195static int hf_usb_iso_error_count;
196static int hf_usb_iso_numdesc;
197static int hf_usb_iso_status;
198static int hf_usb_iso_off;
199static int hf_usb_iso_len;
200static int hf_usb_iso_actual_len;
201static int hf_usb_iso_pad;
202static int hf_usb_iso_data;
203
204static int hf_usb_bmRequestType;
205static int hf_usb_control_response_generic;
206static int hf_usb_bmRequestType_direction;
207static int hf_usb_bmRequestType_type;
208static int hf_usb_bmRequestType_recipient;
209static int hf_usb_bDescriptorType;
210static int hf_usb_get_descriptor_resp_generic;
211static int hf_usb_descriptor_index;
212static int hf_usb_language_id;
213static int hf_usb_bLength;
214static int hf_usb_bcdUSB;
215static int hf_usb_bDeviceClass;
216static int hf_usb_bDeviceSubClass;
217static int hf_usb_bDeviceProtocol;
218static int hf_usb_bMaxPacketSize0;
219static int hf_usb_idVendor;
220static int hf_usb_idProduct;
221static int hf_usb_bcdDevice;
222static int hf_usb_iManufacturer;
223static int hf_usb_iProduct;
224static int hf_usb_iSerialNumber;
225static int hf_usb_bNumConfigurations;
226static int hf_usb_wLANGID;
227static int hf_usb_bString;
228static int hf_usb_bInterfaceNumber;
229static int hf_usb_bAlternateSetting;
230static int hf_usb_bNumEndpoints;
231static int hf_usb_bInterfaceClass;
232static int hf_usb_bInterfaceSubClass;
233static int hf_usb_bInterfaceSubClass_audio;
234static int hf_usb_bInterfaceSubClass_cdc;
235static int hf_usb_bInterfaceSubClass_massstorage;
236static int hf_usb_bInterfaceSubClass_hid;
237static int hf_usb_bInterfaceSubClass_misc;
238static int hf_usb_bInterfaceSubClass_app;
239static int hf_usb_bInterfaceProtocol;
240static int hf_usb_bInterfaceProtocol_cdc;
241static int hf_usb_bInterfaceProtocol_massstorage;
242static int hf_usb_bInterfaceProtocol_cdc_data;
243static int hf_usb_bInterfaceProtocol_hid_boot;
244static int hf_usb_bInterfaceProtocol_app_dfu;
245static int hf_usb_bInterfaceProtocol_app_irda;
246static int hf_usb_bInterfaceProtocol_app_usb_test_and_measurement;
247static int hf_usb_iInterface;
248static int hf_usb_bEndpointAddress;
249static int hf_usb_bmAttributes;
250static int hf_usb_bEndpointAttributeTransfer;
251static int hf_usb_bEndpointAttributeSynchonisation;
252static int hf_usb_bEndpointAttributeBehaviour;
253static int hf_usb_wMaxPacketSize;
254static int hf_usb_wMaxPacketSize_size;
255static int hf_usb_wMaxPacketSize_slots;
256static int hf_usb_bInterval;
257static int hf_usb_bMaxBurst;
258static int hf_usb_audio_bRefresh;
259static int hf_usb_audio_bSynchAddress;
260static int hf_usb_bSSEndpointAttributeBulkMaxStreams;
261static int hf_usb_bSSEndpointAttributeIsoMult;
262static int hf_usb_wBytesPerInterval;
263static int hf_usb_wTotalLength;
264static int hf_usb_bNumInterfaces;
265static int hf_usb_bConfigurationValue;
266static int hf_usb_iConfiguration;
267static int hf_usb_bMaxPower;
268static int hf_usb_configuration_bmAttributes;
269static int hf_usb_configuration_legacy10buspowered;
270static int hf_usb_configuration_selfpowered;
271static int hf_usb_configuration_remotewakeup;
272static int hf_usb_bEndpointAddress_direction;
273static int hf_usb_bEndpointAddress_number;
274static int hf_usb_response_in;
275static int hf_usb_time;
276static int hf_usb_request_in;
277static int hf_usb_bFirstInterface;
278static int hf_usb_bInterfaceCount;
279static int hf_usb_bFunctionClass;
280static int hf_usb_bFunctionSubClass;
281static int hf_usb_bFunctionProtocol;
282static int hf_usb_iFunction;
283static int hf_usb_bNumDeviceCaps;
284static int hf_usb_bDevCapabilityType;
285static int hf_usb_usb20ext_bmAttributes;
286static int hf_usb_usb20ext_LPM;
287static int hf_usb_usb20ext_BESL_HIRD;
288static int hf_usb_usb20ext_baseline_BESL_valid;
289static int hf_usb_usb20ext_deep_BESL_valid;
290static int hf_usb_usb20ext_baseline_BESL;
291static int hf_usb_usb20ext_deep_BESL;
292static int hf_usb_bReserved;
293static int hf_usb_PlatformCapabilityUUID;
294static int hf_usb_webusb_bcdVersion;
295static int hf_usb_webusb_bVendorCode;
296static int hf_usb_webusb_iLandingPage;
297static int hf_usb_msos20_dwWindowsVersion;
298static int hf_usb_msos20_wMSOSDescriptorSetTotalLength;
299static int hf_usb_msos20_bMS_VendorCode;
300static int hf_usb_msos20_bAltEnumCode;
301static int hf_usb_data_fragment;
302static int hf_usb_src;
303static int hf_usb_dst;
304static int hf_usb_addr;
305static int hf_usb_ss_bmAttributes;
306static int hf_usb_ss_bmAttributes_reserved0;
307static int hf_usb_ss_bmAttributes_LTM;
308static int hf_usb_ss_bmAttributes_reserved7_2;
309static int hf_usb_ss_wSpeedSupported;
310static int hf_usb_ss_wSpeedSupported_LS;
311static int hf_usb_ss_wSpeedSupported_FS;
312static int hf_usb_ss_wSpeedSupported_HS;
313static int hf_usb_ss_wSpeedSupported_Gen1;
314static int hf_usb_ss_wSpeedSupported_reserved;
315static int hf_usb_ss_bFunctionalitySupport;
316static int hf_usb_ss_bU1DevExitLat;
317static int hf_usb_ss_wU2DevExitLat;
318
319/* macOS */
320static int hf_usb_darwin_bcd_version;
321static int hf_usb_darwin_header_len;
322static int hf_usb_darwin_request_type;
323static int hf_usb_darwin_io_len;
324static int hf_usb_darwin_io_status;
325static int hf_usb_darwin_iso_num_packets;
326static int hf_usb_darwin_io_id;
327static int hf_usb_darwin_device_location;
328static int hf_usb_darwin_speed;
329static int hf_usb_darwin_device_address;
330static int hf_usb_darwin_endpoint_address;
331static int hf_usb_darwin_endpoint_type;
332static int hf_usb_darwin_iso_status;
333static int hf_usb_darwin_iso_frame_number;
334static int hf_usb_darwin_iso_timestamp;
335
336/* NetMon */
337static int hf_usbport_event_id;
338static int hf_usbport_device_object;
339static int hf_usbport_pci_bus;
340static int hf_usbport_pci_device;
341static int hf_usbport_pci_function;
342static int hf_usbport_pci_vendor_id;
343static int hf_usbport_pci_device_id;
344static int hf_usbport_port_path_depth;
345static int hf_usbport_port_path0;
346static int hf_usbport_port_path1;
347static int hf_usbport_port_path2;
348static int hf_usbport_port_path3;
349static int hf_usbport_port_path4;
350static int hf_usbport_port_path5;
351static int hf_usbport_device_handle;
352static int hf_usbport_device_speed;
353static int hf_usbport_endpoint;
354static int hf_usbport_pipehandle;
355static int hf_usbport_endpoint_desc_length;
356static int hf_usbport_endpoint_desc_type;
357static int hf_usbport_endpoint_address;
358static int hf_usbport_bm_attributes;
359static int hf_usbport_max_packet_size;
360static int hf_usbport_interval;
361static int hf_usbport_irp;
362static int hf_usbport_urb;
363static int hf_usbport_urb_transfer_data;
364static int hf_usbport_urb_header_length;
365static int hf_usbport_urb_header_function;
366static int hf_usbport_urb_header_status;
367static int hf_usbport_urb_header_usbddevice_handle;
368static int hf_usbport_urb_header_usbdflags;
369static int hf_usbport_urb_configuration_desc;
370static int hf_usbport_urb_configuration_handle;
371static int hf_usbport_urb_pipe_handle;
372static int hf_usbport_urb_xferflags;
373static int hf_usbport_urb_transfer_buffer_length;
374static int hf_usbport_urb_transfer_buffer;
375static int hf_usbport_urb_transfer_buffer_mdl;
376static int hf_usbport_urb_reserved_mbz;
377static int hf_usbport_urb_reserved_hcd;
378static int hf_usbport_urb_reserved;
379static int hf_usbport_keyword;
380static int hf_usbport_keyword_diagnostic;
381static int hf_usbport_keyword_power_diagnostics;
382static int hf_usbport_keyword_perf_diagnostics;
383static int hf_usbport_keyword_reserved1;
384
385static int ett_usb_hdr;
386static int ett_usb_setup_hdr;
387static int ett_usb_isodesc;
388static int ett_usb_win32_iso_packet;
389static int ett_usb_endpoint;
390static int ett_usb_setup_bmrequesttype;
391static int ett_usb_usbpcap_info;
392static int ett_descriptor_device;
393static int ett_configuration_bmAttributes;
394static int ett_configuration_bEndpointAddress;
395static int ett_endpoint_bmAttributes;
396static int ett_endpoint_wMaxPacketSize;
397static int ett_usb_xferflags;
398static int ett_usb_xferstatus;
399static int ett_usb_frame;
400static int ett_usb_frame_flags;
401static int ett_usbport;
402static int ett_usbport_host_controller;
403static int ett_usbport_path;
404static int ett_usbport_device;
405static int ett_usbport_endpoint;
406static int ett_usbport_endpoint_desc;
407static int ett_usbport_urb;
408static int ett_usbport_keyword;
409static int ett_transfer_flags;
410static int ett_usb20ext_bmAttributes;
411static int ett_ss_bmAttributes;
412static int ett_ss_wSpeedSupported;
413
414static expert_field ei_usb_undecoded;
415static expert_field ei_usb_bLength_even;
416static expert_field ei_usb_bLength_too_short;
417static expert_field ei_usb_desc_length_invalid;
418static expert_field ei_usb_invalid_setup;
419static expert_field ei_usb_ss_ep_companion_before_ep;
420static expert_field ei_usb_usbpcap_unknown_urb;
421static expert_field ei_usb_bad_length;
422static expert_field ei_usb_invalid_max_packet_size;
423static expert_field ei_usb_invalid_max_packet_size0;
424static expert_field ei_usb_invalid_endpoint_type;
425static expert_field ei_usb_unexpected_desc_type;
426
427static expert_field ei_usbport_invalid_path_depth;
428
429static int usb_address_type = -1;
430
431static int * const usb_endpoint_fields[] = {
432 &hf_usb_endpoint_direction,
433 &hf_usb_endpoint_number,
434 NULL((void*)0)
435};
436
437static int * const usb_usbpcap_info_fields[] = {
438 &hf_usb_usbpcap_info_reserved,
439 &hf_usb_usbpcap_info_direction,
440 NULL((void*)0)
441};
442
443static int usb_tap;
444static bool_Bool try_heuristics = true1;
445
446static dissector_table_t usb_bulk_dissector_table;
447static dissector_table_t usb_control_dissector_table;
448static dissector_table_t usb_interrupt_dissector_table;
449static dissector_table_t usb_descriptor_dissector_table;
450
451static heur_dissector_list_t heur_bulk_subdissector_list;
452static heur_dissector_list_t heur_control_subdissector_list;
453static heur_dissector_list_t heur_interrupt_subdissector_list;
454
455static wmem_tree_t *device_to_protocol_table;
456static wmem_tree_t *device_to_product_table;
457static wmem_tree_t *usbpcap_setup_data;
458
459static dissector_table_t device_to_dissector;
460static dissector_table_t protocol_to_dissector;
461static dissector_table_t product_to_dissector;
462
463typedef struct _device_product_data_t {
464 uint16_t vendor;
465 uint16_t product;
466 uint16_t device;
467 unsigned bus_id;
468 unsigned device_address;
469} device_product_data_t;
470
471typedef struct _device_protocol_data_t {
472 uint32_t protocol;
473 unsigned bus_id;
474 unsigned device_address;
475} device_protocol_data_t;
476
477typedef struct _usb_alt_setting_t {
478 uint8_t altSetting;
479 uint8_t interfaceClass;
480 uint8_t interfaceSubclass;
481 uint8_t interfaceProtocol;
482 uint8_t interfaceNum;
483} usb_alt_setting_t;
484
485typedef struct {
486 uint64_t usb_id;
487 uint8_t setup_data[8];
488} usbpcap_setup_data_t;
489
490static const value_string usb_speed_vals[] = {
491 {USB_SPEED_UNKNOWN, "Unknown Speed"},
492 {USB_SPEED_LOW, "Low-Speed"},
493 {USB_SPEED_FULL, "Full-Speed"},
494 {USB_SPEED_HIGH, "High-Speed"},
495 {0, NULL((void*)0)}
496};
497
498/* http://www.usb.org/developers/docs/USB_LANGIDs.pdf */
499static const value_string usb_langid_vals[] = {
500 {0x0000, "no language specified"},
501 {0x0401, "Arabic (Saudi Arabia)"},
502 {0x0402, "Bulgarian"},
503 {0x0403, "Catalan"},
504 {0x0404, "Chinese (Taiwan)"},
505 {0x0405, "Czech"},
506 {0x0406, "Danish"},
507 {0x0407, "German (Standard)"},
508 {0x0408, "Greek"},
509 {0x0409, "English (United States)"},
510 {0x040a, "Spanish (Traditional Sort)"},
511 {0x040b, "Finnish"},
512 {0x040c, "French (Standard)"},
513 {0x040d, "Hebrew"},
514 {0x040e, "Hungarian"},
515 {0x040f, "Icelandic"},
516 {0x0410, "Italian (Standard)"},
517 {0x0411, "Japanese"},
518 {0x0412, "Korean"},
519 {0x0413, "Dutch (Netherlands)"},
520 {0x0414, "Norwegian (Bokmal)"},
521 {0x0415, "Polish"},
522 {0x0416, "Portuguese (Brazil)"},
523 {0x0418, "Romanian"},
524 {0x0419, "Russian"},
525 {0x041a, "Croatian"},
526 {0x041b, "Slovak"},
527 {0x041c, "Albanian"},
528 {0x041d, "Swedish"},
529 {0x041e, "Thai"},
530 {0x041f, "Turkish"},
531 {0x0420, "Urdu (Pakistan)"},
532 {0x0421, "Indonesian"},
533 {0x0422, "Ukrainian"},
534 {0x0423, "Belarussian"},
535 {0x0424, "Slovenian"},
536 {0x0425, "Estonian"},
537 {0x0426, "Latvian"},
538 {0x0427, "Lithuanian"},
539 {0x0429, "Farsi"},
540 {0x042a, "Vietnamese"},
541 {0x042b, "Armenian"},
542 {0x042c, "Azeri (Latin)"},
543 {0x042d, "Basque"},
544 {0x042f, "Macedonian"},
545 {0x0430, "Sutu"},
546 {0x0436, "Afrikaans"},
547 {0x0437, "Georgian"},
548 {0x0438, "Faeroese"},
549 {0x0439, "Hindi"},
550 {0x043e, "Malay (Malaysian)"},
551 {0x043f, "Kazakh"},
552 {0x0441, "Swahili (Kenya)"},
553 {0x0443, "Uzbek (Latin)"},
554 {0x0444, "Tatar (Tatarstan)"},
555 {0x0445, "Bengali"},
556 {0x0446, "Punjabi"},
557 {0x0447, "Gujarati"},
558 {0x0448, "Oriya"},
559 {0x0449, "Tamil"},
560 {0x044a, "Telugu"},
561 {0x044b, "Kannada"},
562 {0x044c, "Malayalam"},
563 {0x044d, "Assamese"},
564 {0x044e, "Marathi"},
565 {0x044f, "Sanskrit"},
566 {0x0455, "Burmese"},
567 {0x0457, "Konkani"},
568 {0x0458, "Manipuri"},
569 {0x0459, "Sindhi"},
570 {0x04ff, "HID (Usage Data Descriptor)"},
571 {0x0801, "Arabic (Iraq)"},
572 {0x0804, "Chinese (PRC)"},
573 {0x0807, "German (Switzerland)"},
574 {0x0809, "English (United Kingdom)"},
575 {0x080a, "Spanish (Mexican)"},
576 {0x080c, "French (Belgian)"},
577 {0x0810, "Italian (Switzerland)"},
578 {0x0812, "Korean (Johab)"},
579 {0x0813, "Dutch (Belgium)"},
580 {0x0814, "Norwegian (Nynorsk)"},
581 {0x0816, "Portuguese (Standard)"},
582 {0x081a, "Serbian (Latin)"},
583 {0x081d, "Swedish (Finland)"},
584 {0x0820, "Urdu (India)"},
585 {0x0827, "Lithuanian (Classic)"},
586 {0x082c, "Azeri (Cyrillic)"},
587 {0x083e, "Malay (Brunei Darussalam)"},
588 {0x0843, "Uzbek (Cyrillic)"},
589 {0x0860, "Kashmiri (India)"},
590 {0x0861, "Nepali (India)"},
591 {0x0c01, "Arabic (Egypt)"},
592 {0x0c04, "Chinese (Hong Kong SAR, PRC)"},
593 {0x0c07, "German (Austria)"},
594 {0x0c09, "English (Australian)"},
595 {0x0c0a, "Spanish (Modern Sort)"},
596 {0x0c0c, "French (Canadian)"},
597 {0x0c1a, "Serbian (Cyrillic)"},
598 {0x1001, "Arabic (Libya)"},
599 {0x1004, "Chinese (Singapore)"},
600 {0x1007, "German (Luxembourg)"},
601 {0x1009, "English (Canadian)"},
602 {0x100a, "Spanish (Guatemala)"},
603 {0x100c, "French (Switzerland)"},
604 {0x1401, "Arabic (Algeria)"},
605 {0x1404, "Chinese (Macau SAR)"},
606 {0x1407, "German (Liechtenstein)"},
607 {0x1409, "English (New Zealand)"},
608 {0x140a, "Spanish (Costa Rica)"},
609 {0x140c, "French (Luxembourg)"},
610 {0x1801, "Arabic (Morocco)"},
611 {0x1809, "English (Ireland)"},
612 {0x180a, "Spanish (Panama)"},
613 {0x180c, "French (Monaco)"},
614 {0x1c01, "Arabic (Tunisia)"},
615 {0x1c09, "English (South Africa)"},
616 {0x1c0a, "Spanish (Dominican Republic)"},
617 {0x2001, "Arabic (Oman)"},
618 {0x2009, "English (Jamaica)"},
619 {0x200a, "Spanish (Venezuela)"},
620 {0x2401, "Arabic (Yemen)"},
621 {0x2409, "English (Caribbean)"},
622 {0x240a, "Spanish (Colombia)"},
623 {0x2801, "Arabic (Syria)"},
624 {0x2809, "English (Belize)"},
625 {0x280a, "Spanish (Peru)"},
626 {0x2c01, "Arabic (Jordan)"},
627 {0x2c09, "English (Trinidad)"},
628 {0x2c0a, "Spanish (Argentina)"},
629 {0x3001, "Arabic (Lebanon)"},
630 {0x3009, "English (Zimbabwe)"},
631 {0x300a, "Spanish (Ecuador)"},
632 {0x3401, "Arabic (Kuwait)"},
633 {0x3409, "English (Philippines)"},
634 {0x340a, "Spanish (Chile)"},
635 {0x3801, "Arabic (U.A.E.)"},
636 {0x380a, "Spanish (Uruguay)"},
637 {0x3c01, "Arabic (Bahrain)"},
638 {0x3c0a, "Spanish (Paraguay)"},
639 {0x4001, "Arabic (Qatar)"},
640 {0x400a, "Spanish (Bolivia)"},
641 {0x440a, "Spanish (El Salvador)"},
642 {0x480a, "Spanish (Honduras)"},
643 {0x4c0a, "Spanish (Nicaragua)"},
644 {0x500a, "Spanish (Puerto Rico)"},
645 {0xf0ff, "HID (Vendor Defined 1)"},
646 {0xf4ff, "HID (Vendor Defined 2)"},
647 {0xf8ff, "HID (Vendor Defined 3)"},
648 {0xfcff, "HID (Vendor Defined 4)"},
649 {0, NULL((void*)0)}
650};
651value_string_ext usb_langid_vals_ext = VALUE_STRING_EXT_INIT(usb_langid_vals){ _try_val_to_str_ext_init, 0, (sizeof (usb_langid_vals) / sizeof
((usb_langid_vals)[0]))-1, usb_langid_vals, "usb_langid_vals"
, ((void*)0) }
;
652
653static const value_string usb_class_vals[] = {
654 {IF_CLASS_DEVICE0x00, "Device"},
655 {IF_CLASS_AUDIO0x01, "Audio"},
656 {IF_CLASS_COMMUNICATIONS0x02, "Communications and CDC Control"},
657 {IF_CLASS_HID0x03, "HID"},
658 {IF_CLASS_PHYSICAL0x05, "Physical"},
659 {IF_CLASS_IMAGE0x06, "Imaging"},
660 {IF_CLASS_PRINTER0x07, "Printer"},
661 {IF_CLASS_MASS_STORAGE0x08, "Mass Storage"},
662 {IF_CLASS_HUB0x09, "Hub"},
663 {IF_CLASS_CDC_DATA0x0a, "CDC-Data"},
664 {IF_CLASS_SMART_CARD0x0b, "Smart Card"},
665 {IF_CLASS_CONTENT_SECURITY0x0d, "Content Security"},
666 {IF_CLASS_VIDEO0x0e, "Video"},
667 {IF_CLASS_PERSONAL_HEALTHCARE0x0f, "Personal Healthcare"},
668 {IF_CLASS_AUDIO_VIDEO0x10, "Audio/Video Devices"},
669 {IF_CLASS_BILLBOARD0x11, "Billboard Device"},
670 {IF_CLASS_USB_C_BRIDGE0x12, "USB Type-C Bridge"},
671 {IF_CLASS_BULK_DISPLAY_PROTO0x13, "USB Bulk Display Protocol Device"},
672 {IF_CLASS_MCTP_USB_EP0x14, "MCTP over USB Protocol Endpoint Device"},
673 {IF_CLASS_I3C0x3c, "I3C Device"},
674 {IF_CLASS_DIAGNOSTIC_DEVICE0xdc, "Diagnostic Device"},
675 {IF_CLASS_WIRELESS_CONTROLLER0xe0, "Wireless Controller"},
676 {IF_CLASS_MISCELLANEOUS0xef, "Miscellaneous"},
677 {IF_CLASS_APPLICATION_SPECIFIC0xfe, "Application Specific"},
678 {IF_CLASS_VENDOR_SPECIFIC0xff, "Vendor Specific"},
679 {0, NULL((void*)0)}
680};
681value_string_ext usb_class_vals_ext = VALUE_STRING_EXT_INIT(usb_class_vals){ _try_val_to_str_ext_init, 0, (sizeof (usb_class_vals) / sizeof
((usb_class_vals)[0]))-1, usb_class_vals, "usb_class_vals", (
(void*)0) }
;
682
683/* use usb class, subclass and protocol id together
684 http://www.usb.org/developers/defined_class
685 USB Class Definitions for Communications Devices, Revision 1.2 December 6, 2012
686*/
687static const value_string usb_protocols[] = {
688 {0x000000, "Use class code info from Interface Descriptors"},
689 {0x060101, "Still Imaging"},
690 {0x090000, "Full speed Hub"},
691 {0x090001, "Hi-speed hub with single TT"},
692 {0x090002, "Hi-speed hub with multiple TTs"},
693 {0x0D0000, "Content Security"},
694 {0x100100, "AVControl Interface"},
695 {0x100200, "AVData Video Streaming Interface"},
696 {0x100300, "AVData Audio Streaming Interface"},
697 {0x140001, "MCTP 1.x - MCTP Management-controller and Managed-Device endpoints"},
698 {0x140002, "MCTP 2.x - MCTP Management-controller and Managed-Device endpoints"},
699 {0x140101, "MCTP 1.x - MCTP Host Interface endpoint"},
700 {0x140102, "MCTP 2.x - MCTP Host Interface endpoint"},
701 {0xDC0101, "USB2 Compliance Device"},
702 {0xDC0200, "Debug Target vendor defined"},
703 {0xDC0201, "GNU Remote Debug Command Set"},
704 {0xDC0301, "Vendor defined Trace protocol on DbC"},
705 {0xDC0401, "Vendor defined Dfx protocol on DbC"},
706 {0xDC0500, "Vendor defined Trace protocol over General Purpose (GP) endpoint on DvC"},
707 {0xDC0501, "GNU Protocol protocol over General Purpose (GP) endpoint on DvC"},
708 {0xDC0601, "Vendor defined Dfx protocol on DvC"},
709 {0xDC0701, "Vendor defined Trace protocol on DvC"},
710 {0xE00101, "Bluetooth Programming Interface"},
711 {0xE00102, "UWB Radio Control Interface"},
712 {0xE00103, "Remote NDIS"},
713 {0xE00104, "Bluetooth AMP Controller"},
714 {0xE00201, "Host Wire Adapter Control/Data interface"},
715 {0xE00202, "Device Wire Adapter Control/Data interface"},
716 {0xE00203, "Device Wire Adapter Isochronous interface"},
717 {0xEF0101, "Active Sync device"},
718 {0xEF0102, "Palm Sync"},
719 {0xEF0201, "Interface Association Descriptor"},
720 {0xEF0202, "Wire Adapter Multifunction Peripheral programming interface"},
721 {0xEF0301, "Cable Based Association Framework"},
722 {0xEF0401, "RNDIS over Ethernet"},
723 {0xEF0402, "RNDIS over WiFi"},
724 {0xEF0403, "RNDIS over WiMAX"},
725 {0xEF0404, "RNDIS over WWAN"},
726 {0xEF0405, "RNDIS for Raw IPv4"},
727 {0xEF0406, "RNDIS for Raw IPv6"},
728 {0xEF0407, "RNDIS for GPRS"},
729 {0xEF0500, "USB3 Vision Control Interface"},
730 {0xEF0501, "USB3 Vision Event Interface"},
731 {0xEF0502, "USB3 Vision Streaming Interface"},
732 {0xEF0601, "Stream Transport Efficient Protocol for content protection"},
733 {0xEF0602, "Stream Transport Efficient Protocol for Raw content protection"},
734 {0xEF0700, "Command Interface in IAD"},
735 {0xEF0702, "Command Interface in Interface Descriptor"},
736 {0xEF0703, "Media Interface in Interface Descriptor"},
737 {0xFE0101, "Device Firmware Upgrade"},
738 {0xFE0200, "IRDA Bridge device"},
739 {0xFE0300, "USB Test and Measurement Device"},
740 {0xFE0301, "USB Test and Measurement Device conforming to the USBTMC USB488"},
741 {0, NULL((void*)0)}
742};
743static value_string_ext usb_protocols_ext = VALUE_STRING_EXT_INIT(usb_protocols){ _try_val_to_str_ext_init, 0, (sizeof (usb_protocols) / sizeof
((usb_protocols)[0]))-1, usb_protocols, "usb_protocols", ((void
*)0) }
;
744
745/* BOS Descriptor Device Capability Type Codes
746 https://www.usb.org/bos-descriptor-types
747*/
748#define BOS_CAP_WIRELESS_USB0x01 0x01
749#define BOS_CAP_USB_20_EXTENSION0x02 0x02
750#define BOS_CAP_SUPERSPEED_USB0x03 0x03
751#define BOS_CAP_CONTAINER_ID0x04 0x04
752#define BOS_CAP_PLATFORM0x05 0x05
753#define BOS_CAP_POWER_DELIVERY0x06 0x06
754#define BOS_CAP_BATTERY_INFO0x07 0x07
755#define BOS_CAP_PD_CONSUMER_PORT0x08 0x08
756#define BOS_CAP_PD_PROVIDER_PORT0x09 0x09
757#define BOS_CAP_SUPERSPEED_PLUS0x0A 0x0A
758#define BOS_CAP_PRECISION_TIME_MEAS0x0B 0x0B
759#define BOS_CAP_WIRELESS_USB_EXT0x0C 0x0C
760#define BOS_CAP_BILLBOARD0x0D 0x0D
761#define BOS_CAP_AUTHENTICATION0x0E 0x0E
762#define BOS_CAP_BILLBOARD_EX0x0F 0x0F
763#define BOS_CAP_CONFIGURATION_SUMMARY0x10 0x10
764#define BOS_CAP_FWSTATUS0x11 0x11
765#define BOS_CAP_USB3_GEN_T0x13 0x13
766static const value_string usb_capability_vals[] = {
767 {BOS_CAP_WIRELESS_USB0x01, "Wireless USB"},
768 {BOS_CAP_USB_20_EXTENSION0x02, "USB 2.0 Extension Descriptor"},
769 {BOS_CAP_SUPERSPEED_USB0x03, "SuperSpeed USB"},
770 {BOS_CAP_CONTAINER_ID0x04, "Container ID"},
771 {BOS_CAP_PLATFORM0x05, "Platform"},
772 {BOS_CAP_POWER_DELIVERY0x06, "Power Delivery Capability"},
773 {BOS_CAP_BATTERY_INFO0x07, "Battery Info Capability"},
774 {BOS_CAP_PD_CONSUMER_PORT0x08, "PD Consumer Port Capability"},
775 {BOS_CAP_PD_PROVIDER_PORT0x09, "PD Provider Port Capability"},
776 {BOS_CAP_SUPERSPEED_PLUS0x0A, "SuperSpeed Plus"},
777 {BOS_CAP_PRECISION_TIME_MEAS0x0B, "Precision Time Measurement"},
778 {BOS_CAP_WIRELESS_USB_EXT0x0C, "Wireless USB Ext"},
779 {BOS_CAP_BILLBOARD0x0D, "Billboard Capability"},
780 {BOS_CAP_AUTHENTICATION0x0E, "Authentication Capability Descriptor"},
781 {BOS_CAP_BILLBOARD_EX0x0F, "Billboard Ex capability"},
782 {BOS_CAP_CONFIGURATION_SUMMARY0x10, "Configuration Summary"},
783 {BOS_CAP_FWSTATUS0x11, "Firmware Status"},
784 {0x12, "TBD (reserved for USB Audio 4.0)"},
785 {BOS_CAP_USB3_GEN_T0x13, "USB 3 Gen T Capability"},
786 {0x14, "TBD (reserved for USB PD)"},
787 {0, NULL((void*)0)}
788};
789static value_string_ext usb_capability_vals_ext = VALUE_STRING_EXT_INIT(usb_capability_vals){ _try_val_to_str_ext_init, 0, (sizeof (usb_capability_vals) /
sizeof ((usb_capability_vals)[0]))-1, usb_capability_vals, "usb_capability_vals"
, ((void*)0) }
;
790
791#define SS_SPEED_SUPPORTED_BIT_LS0 0
792#define SS_SPEED_SUPPORTED_BIT_FS1 1
793#define SS_SPEED_SUPPORTED_BIT_HS2 2
794#define SS_SPEED_SUPPORTED_BIT_GEN13 3
795#define SS_SPEED_SUPPORTED_STR_LS"low-speed" "low-speed"
796#define SS_SPEED_SUPPORTED_STR_FS"full-speed" "full-speed"
797#define SS_SPEED_SUPPORTED_STR_HS"high-speed" "high-speed"
798#define SS_SPEED_SUPPORTED_STR_GEN1"Gen 1 speed" "Gen 1 speed"
799static const value_string usb_ss_bFunctionalitySupport_vals[] = {
800 {SS_SPEED_SUPPORTED_BIT_LS0, SS_SPEED_SUPPORTED_STR_LS"low-speed"},
801 {SS_SPEED_SUPPORTED_BIT_FS1, SS_SPEED_SUPPORTED_STR_FS"full-speed"},
802 {SS_SPEED_SUPPORTED_BIT_HS2, SS_SPEED_SUPPORTED_STR_HS"high-speed"},
803 {SS_SPEED_SUPPORTED_BIT_GEN13, SS_SPEED_SUPPORTED_STR_GEN1"Gen 1 speed"},
804 {0, NULL((void*)0)}
805};
806static value_string_ext usb_ss_bFunctionalitySupport_vals_ext =
807 VALUE_STRING_EXT_INIT(usb_ss_bFunctionalitySupport_vals){ _try_val_to_str_ext_init, 0, (sizeof (usb_ss_bFunctionalitySupport_vals
) / sizeof ((usb_ss_bFunctionalitySupport_vals)[0]))-1, usb_ss_bFunctionalitySupport_vals
, "usb_ss_bFunctionalitySupport_vals", ((void*)0) }
;
808static const true_false_string tfs_usb_ss_bmAttributes_reserved0 = {
809 "FIXME: Shall be set to zero",
810 "Shall be set to zero"
811};
812
813/* FreeBSD header */
814
815/* Transfer mode */
816#define FREEBSD_MODE_HOST0 0
817#define FREEBSD_MODE_DEVICE1 1
818static const value_string usb_freebsd_transfer_mode_vals[] = {
819 {FREEBSD_MODE_HOST0, "Host"},
820 {FREEBSD_MODE_DEVICE1, "Device"},
821 {0, NULL((void*)0)}
822};
823
824/* Type */
825#define FREEBSD_URB_SUBMIT0 0
826#define FREEBSD_URB_COMPLETE1 1
827static const value_string usb_freebsd_urb_type_vals[] = {
828 {FREEBSD_URB_SUBMIT0, "URB_SUBMIT"},
829 {FREEBSD_URB_COMPLETE1, "URB_COMPLETE"},
830 {0, NULL((void*)0)}
831};
832
833/* Transfer type */
834#define FREEBSD_URB_CONTROL0 0
835#define FREEBSD_URB_ISOCHRONOUS1 1
836#define FREEBSD_URB_BULK2 2
837#define FREEBSD_URB_INTERRUPT3 3
838
839static const value_string usb_freebsd_transfer_type_vals[] = {
840 {FREEBSD_URB_CONTROL0, "URB_CONTROL"},
841 {FREEBSD_URB_ISOCHRONOUS1, "URB_ISOCHRONOUS"},
842 {FREEBSD_URB_BULK2, "URB_BULK"},
843 {FREEBSD_URB_INTERRUPT3, "URB_INTERRUPT"},
844 {0, NULL((void*)0)}
845};
846
847/* Transfer flags */
848#define FREEBSD_FLAG_FORCE_SHORT_XFER0x00000001 0x00000001
849#define FREEBSD_FLAG_SHORT_XFER_OK0x00000002 0x00000002
850#define FREEBSD_FLAG_SHORT_FRAMES_OK0x00000004 0x00000004
851#define FREEBSD_FLAG_PIPE_BOF0x00000008 0x00000008
852#define FREEBSD_FLAG_PROXY_BUFFER0x00000010 0x00000010
853#define FREEBSD_FLAG_EXT_BUFFER0x00000020 0x00000020
854#define FREEBSD_FLAG_MANUAL_STATUS0x00000040 0x00000040
855#define FREEBSD_FLAG_NO_PIPE_OK0x00000080 0x00000080
856#define FREEBSD_FLAG_STALL_PIPE0x00000100 0x00000100
857
858static int * const usb_xferflags_fields[] = {
859 &hf_usb_xferflags_force_short_xfer,
860 &hf_usb_xferflags_short_xfer_ok,
861 &hf_usb_xferflags_short_frames_ok,
862 &hf_usb_xferflags_pipe_bof,
863 &hf_usb_xferflags_proxy_buffer,
864 &hf_usb_xferflags_ext_buffer,
865 &hf_usb_xferflags_manual_status,
866 &hf_usb_xferflags_no_pipe_ok,
867 &hf_usb_xferflags_stall_pipe,
868 NULL((void*)0)
869};
870
871/* Transfer status */
872#define FREEBSD_STATUS_OPEN0x00000001 0x00000001
873#define FREEBSD_STATUS_TRANSFERRING0x00000002 0x00000002
874#define FREEBSD_STATUS_DID_DMA_DELAY0x00000004 0x00000004
875#define FREEBSD_STATUS_DID_CLOSE0x00000008 0x00000008
876#define FREEBSD_STATUS_DRAINING0x00000010 0x00000010
877#define FREEBSD_STATUS_STARTED0x00000020 0x00000020
878#define FREEBSD_STATUS_BW_RECLAIMED0x00000040 0x00000040
879#define FREEBSD_STATUS_CONTROL_XFR0x00000080 0x00000080
880#define FREEBSD_STATUS_CONTROL_HDR0x00000100 0x00000100
881#define FREEBSD_STATUS_CONTROL_ACT0x00000200 0x00000200
882#define FREEBSD_STATUS_CONTROL_STALL0x00000400 0x00000400
883#define FREEBSD_STATUS_SHORT_FRAMES_OK0x00000800 0x00000800
884#define FREEBSD_STATUS_SHORT_XFER_OK0x00001000 0x00001000
885#define FREEBSD_STATUS_BDMA_ENABLE0x00002000 0x00002000
886#define FREEBSD_STATUS_BDMA_NO_POST_SYNC0x00004000 0x00004000
887#define FREEBSD_STATUS_BDMA_SETUP0x00008000 0x00008000
888#define FREEBSD_STATUS_ISOCHRONOUS_XFR0x00010000 0x00010000
889#define FREEBSD_STATUS_CURR_DMA_SET0x00020000 0x00020000
890#define FREEBSD_STATUS_CAN_CANCEL_IMMED0x00040000 0x00040000
891#define FREEBSD_STATUS_DOING_CALLBACK0x00080000 0x00080000
892
893static int * const usb_xferstatus_fields[] = {
894 &hf_usb_xferstatus_open,
895 &hf_usb_xferstatus_transferring,
896 &hf_usb_xferstatus_did_dma_delay,
897 &hf_usb_xferstatus_did_close,
898 &hf_usb_xferstatus_draining,
899 &hf_usb_xferstatus_started,
900 &hf_usb_xferstatus_bw_reclaimed,
901 &hf_usb_xferstatus_control_xfr,
902 &hf_usb_xferstatus_control_hdr,
903 &hf_usb_xferstatus_control_act,
904 &hf_usb_xferstatus_control_stall,
905 &hf_usb_xferstatus_short_frames_ok,
906 &hf_usb_xferstatus_short_xfer_ok,
907 &hf_usb_xferstatus_bdma_enable,
908 &hf_usb_xferstatus_bdma_no_post_sync,
909 &hf_usb_xferstatus_bdma_setup,
910 &hf_usb_xferstatus_isochronous_xfr,
911 &hf_usb_xferstatus_curr_dma_set,
912 &hf_usb_xferstatus_can_cancel_immed,
913 &hf_usb_xferstatus_doing_callback,
914 NULL((void*)0)
915};
916
917/* USB errors */
918#define FREEBSD_ERR_NORMAL_COMPLETION0 0
919#define FREEBSD_ERR_PENDING_REQUESTS1 1
920#define FREEBSD_ERR_NOT_STARTED2 2
921#define FREEBSD_ERR_INVAL3 3
922#define FREEBSD_ERR_NOMEM4 4
923#define FREEBSD_ERR_CANCELLED5 5
924#define FREEBSD_ERR_BAD_ADDRESS6 6
925#define FREEBSD_ERR_BAD_BUFSIZE7 7
926#define FREEBSD_ERR_BAD_FLAG8 8
927#define FREEBSD_ERR_NO_CALLBACK9 9
928#define FREEBSD_ERR_IN_USE10 10
929#define FREEBSD_ERR_NO_ADDR11 11
930#define FREEBSD_ERR_NO_PIPE12 12
931#define FREEBSD_ERR_ZERO_NFRAMES13 13
932#define FREEBSD_ERR_ZERO_MAXP14 14
933#define FREEBSD_ERR_SET_ADDR_FAILED15 15
934#define FREEBSD_ERR_NO_POWER16 16
935#define FREEBSD_ERR_TOO_DEEP17 17
936#define FREEBSD_ERR_IOERROR18 18
937#define FREEBSD_ERR_NOT_CONFIGURED19 19
938#define FREEBSD_ERR_TIMEOUT20 20
939#define FREEBSD_ERR_SHORT_XFER21 21
940#define FREEBSD_ERR_STALLED22 22
941#define FREEBSD_ERR_INTERRUPTED23 23
942#define FREEBSD_ERR_DMA_LOAD_FAILED24 24
943#define FREEBSD_ERR_BAD_CONTEXT25 25
944#define FREEBSD_ERR_NO_ROOT_HUB26 26
945#define FREEBSD_ERR_NO_INTR_THREAD27 27
946#define FREEBSD_ERR_NOT_LOCKED28 28
947
948static const value_string usb_freebsd_err_vals[] = {
949 {FREEBSD_ERR_NORMAL_COMPLETION0, "Normal completion"},
950 {FREEBSD_ERR_PENDING_REQUESTS1, "Pending requests"},
951 {FREEBSD_ERR_NOT_STARTED2, "Not started"},
952 {FREEBSD_ERR_INVAL3, "Invalid"},
953 {FREEBSD_ERR_NOMEM4, "No memory"},
954 {FREEBSD_ERR_CANCELLED5, "Cancelled"},
955 {FREEBSD_ERR_BAD_ADDRESS6, "Bad address"},
956 {FREEBSD_ERR_BAD_BUFSIZE7, "Bad buffer size"},
957 {FREEBSD_ERR_BAD_FLAG8, "Bad flag"},
958 {FREEBSD_ERR_NO_CALLBACK9, "No callback"},
959 {FREEBSD_ERR_IN_USE10, "In use"},
960 {FREEBSD_ERR_NO_ADDR11, "No address"},
961 {FREEBSD_ERR_NO_PIPE12, "No pipe"},
962 {FREEBSD_ERR_ZERO_NFRAMES13, "Number of frames is zero"},
963 {FREEBSD_ERR_ZERO_MAXP14, "MAXP is zero"},
964 {FREEBSD_ERR_SET_ADDR_FAILED15, "Set address failed"},
965 {FREEBSD_ERR_NO_POWER16, "No power"},
966 {FREEBSD_ERR_TOO_DEEP17, "Too deep"},
967 {FREEBSD_ERR_IOERROR18, "I/O error"},
968 {FREEBSD_ERR_NOT_CONFIGURED19, "Not configured"},
969 {FREEBSD_ERR_TIMEOUT20, "Timeout"},
970 {FREEBSD_ERR_SHORT_XFER21, "Short transfer"},
971 {FREEBSD_ERR_STALLED22, "Stalled"},
972 {FREEBSD_ERR_INTERRUPTED23, "Interrupted"},
973 {FREEBSD_ERR_DMA_LOAD_FAILED24, "DMA load failed"},
974 {FREEBSD_ERR_BAD_CONTEXT25, "Bad context"},
975 {FREEBSD_ERR_NO_ROOT_HUB26, "No root hub"},
976 {FREEBSD_ERR_NO_INTR_THREAD27, "No interrupt thread"},
977 {FREEBSD_ERR_NOT_LOCKED28, "Not locked"},
978 {0, NULL((void*)0)}
979};
980
981/* USB speeds */
982#define FREEBSD_SPEED_VARIABLE0 0
983#define FREEBSD_SPEED_LOW1 1
984#define FREEBSD_SPEED_FULL2 2
985#define FREEBSD_SPEED_HIGH3 3
986#define FREEBSD_SPEED_SUPER4 4
987
988static const value_string usb_freebsd_speed_vals[] = {
989 {FREEBSD_SPEED_VARIABLE0, "Variable"},
990 {FREEBSD_SPEED_LOW1, "Low"},
991 {FREEBSD_SPEED_FULL2, "Full"},
992 {FREEBSD_SPEED_HIGH3, "High"},
993 {FREEBSD_SPEED_SUPER4, "Super"},
994 {0, NULL((void*)0)}
995};
996
997/* Frame flags */
998#define FREEBSD_FRAMEFLAG_READ0x00000001 0x00000001
999#define FREEBSD_FRAMEFLAG_DATA_FOLLOWS0x00000002 0x00000002
1000
1001static int * const usb_frame_flags_fields[] = {
1002 &hf_usb_frame_flags_read,
1003 &hf_usb_frame_flags_data_follows,
1004 NULL((void*)0)
1005};
1006
1007static const value_string usb_linux_urb_type_vals[] = {
1008 {URB_SUBMIT'S', "URB_SUBMIT"},
1009 {URB_COMPLETE'C', "URB_COMPLETE"},
1010 {URB_ERROR'E', "URB_ERROR"},
1011 {0, NULL((void*)0)}
1012};
1013
1014static const value_string usb_linux_transfer_type_vals[] = {
1015 {URB_CONTROL0x2, "URB_CONTROL"},
1016 {URB_ISOCHRONOUS0x0, "URB_ISOCHRONOUS"},
1017 {URB_INTERRUPT0x1, "URB_INTERRUPT"},
1018 {URB_BULK0x3, "URB_BULK"},
1019 {0, NULL((void*)0)}
1020};
1021
1022static const value_string usb_transfer_type_and_direction_vals[] = {
1023 {URB_CONTROL0x2, "URB_CONTROL out"},
1024 {URB_ISOCHRONOUS0x0, "URB_ISOCHRONOUS out"},
1025 {URB_INTERRUPT0x1, "URB_INTERRUPT out"},
1026 {URB_BULK0x3, "URB_BULK out"},
1027 {URB_CONTROL0x2 | URB_TRANSFER_IN0x80, "URB_CONTROL in"},
1028 {URB_ISOCHRONOUS0x0 | URB_TRANSFER_IN0x80, "URB_ISOCHRONOUS in"},
1029 {URB_INTERRUPT0x1 | URB_TRANSFER_IN0x80, "URB_INTERRUPT in"},
1030 {URB_BULK0x3 | URB_TRANSFER_IN0x80, "URB_BULK in"},
1031 {0, NULL((void*)0)}
1032};
1033
1034static const value_string usb_endpoint_direction_vals[] = {
1035 {0, "OUT"},
1036 {1, "IN"},
1037 {0, NULL((void*)0)}
1038};
1039
1040static const range_string usb_setup_flag_rvals[] = {
1041 {0, 0, "relevant"},
1042 {1, 255, "not relevant"},
1043 {0, 0, NULL((void*)0)}
1044};
1045
1046static const range_string usb_data_flag_rvals[] = {
1047 {0, 0, "present"},
1048 {1, 255, "not present"},
1049 {0, 0, NULL((void*)0)}
1050};
1051
1052/*
1053 * Standard descriptor types.
1054 *
1055 * all class specific descriptor types were removed from this list
1056 * a descriptor type is not globally unique
1057 * dissectors for the USB classes should provide their own value string
1058 * and pass it to dissect_usb_descriptor_header()
1059 *
1060 */
1061#define USB_DT_DEVICE1 1
1062#define USB_DT_CONFIG2 2
1063#define USB_DT_STRING3 3
1064#define USB_DT_INTERFACE4 4
1065#define USB_DT_ENDPOINT5 5
1066#define USB_DT_DEVICE_QUALIFIER6 6
1067#define USB_DT_OTHER_SPEED_CONFIG7 7
1068#define USB_DT_INTERFACE_POWER8 8
1069/* these are from a minor usb 2.0 revision (ECN) */
1070#define USB_DT_OTG9 9
1071#define USB_DT_DEBUG10 10
1072#define USB_DT_INTERFACE_ASSOCIATION11 11
1073/* these are from usb 3.0 specification */
1074#define USB_DT_BOS0x0F 0x0F
1075#define USB_DT_DEVICE_CAPABILITY0x10 0x10
1076#define USB_DT_SUPERSPEED_EP_COMPANION0x30 0x30
1077/* these are from usb 3.1 specification */
1078#define USB_DT_SUPERSPEED_ISO_EP_COMPANION0x31 0x31
1079
1080/* There are only Standard Descriptor Types, Class-specific types are
1081 provided by "usb.descriptor" descriptors table*/
1082static const value_string std_descriptor_type_vals[] = {
1083 {USB_DT_DEVICE1, "DEVICE"},
1084 {USB_DT_CONFIG2, "CONFIGURATION"},
1085 {USB_DT_STRING3, "STRING"},
1086 {USB_DT_INTERFACE4, "INTERFACE"},
1087 {USB_DT_ENDPOINT5, "ENDPOINT"},
1088 {USB_DT_DEVICE_QUALIFIER6, "DEVICE QUALIFIER"},
1089 {USB_DT_OTHER_SPEED_CONFIG7, "OTHER SPEED CONFIG"},
1090 {USB_DT_INTERFACE_POWER8, "INTERFACE POWER"},
1091 {USB_DT_OTG9, "OTG"},
1092 {USB_DT_DEBUG10, "DEBUG"},
1093 {USB_DT_INTERFACE_ASSOCIATION11, "INTERFACE ASSOCIATION"},
1094 {USB_DT_BOS0x0F, "BOS"},
1095 {USB_DT_DEVICE_CAPABILITY0x10, "DEVICE CAPABILITY"},
1096 {USB_DT_SUPERSPEED_EP_COMPANION0x30, "SUPERSPEED USB ENDPOINT COMPANION"},
1097 {USB_DT_SUPERSPEED_ISO_EP_COMPANION0x31, "SUPERSPEED PLUS ISOCHRONOUS ENDPOINT COMPANION"},
1098 {0,NULL((void*)0)}
1099};
1100static value_string_ext std_descriptor_type_vals_ext =
1101 VALUE_STRING_EXT_INIT(std_descriptor_type_vals){ _try_val_to_str_ext_init, 0, (sizeof (std_descriptor_type_vals
) / sizeof ((std_descriptor_type_vals)[0]))-1, std_descriptor_type_vals
, "std_descriptor_type_vals", ((void*)0) }
;
1102
1103/*
1104 * Feature selectors.
1105 * Per USB 3.1 spec, Table 9-7
1106 */
1107#define USB_FS_ENDPOINT_HALT0 0
1108#define USB_FS_FUNCTION_SUSPEND0 0 /* same as ENDPOINT_HALT */
1109#define USB_FS_DEVICE_REMOTE_WAKEUP1 1
1110#define USB_FS_TEST_MODE2 2
1111#define USB_FS_B_HNP_ENABLE3 3
1112#define USB_FS_A_HNP_SUPPORT4 4
1113#define USB_FS_A_ALT_HNP_SUPPORT5 5
1114#define USB_FS_WUSB_DEVICE6 6
1115#define USB_FS_U1_ENABLE48 48
1116#define USB_FS_U2_ENABLE49 49
1117#define USB_FS_LTM_ENABLE50 50
1118#define USB_FS_B3_NTF_HOST_REL51 51
1119#define USB_FS_B3_RSP_ENABLE52 52
1120#define USB_FS_LDM_ENABLE53 53
1121
1122static const value_string usb_endpoint_feature_selector_vals[] = {
1123 {USB_FS_ENDPOINT_HALT0, "ENDPOINT HALT"},
1124 {0, NULL((void*)0)}
1125};
1126
1127static const value_string usb_interface_feature_selector_vals[] = {
1128 {USB_FS_FUNCTION_SUSPEND0, "FUNCTION SUSPEND"},
1129 {0, NULL((void*)0)}
1130};
1131
1132static const value_string usb_device_feature_selector_vals[] = {
1133 {USB_FS_DEVICE_REMOTE_WAKEUP1, "DEVICE REMOTE WAKEUP"},
1134 {USB_FS_TEST_MODE2, "TEST MODE"},
1135 {USB_FS_B_HNP_ENABLE3, "B HNP ENABLE"},
1136 {USB_FS_A_HNP_SUPPORT4, "A HNP SUPPORT"},
1137 {USB_FS_A_ALT_HNP_SUPPORT5, "A ALT HNP SUPPORT"},
1138 {USB_FS_WUSB_DEVICE6, "WUSB DEVICE"},
1139 {USB_FS_U1_ENABLE48, "U1 ENABLE"},
1140 {USB_FS_U2_ENABLE49, "U2 ENABLE"},
1141 {USB_FS_LTM_ENABLE50, "LTM ENABLE"},
1142 {USB_FS_B3_NTF_HOST_REL51, "B3 NTF HOST REL"},
1143 {USB_FS_B3_RSP_ENABLE52, "B3 RSP ENABLE"},
1144 {USB_FS_LDM_ENABLE53, "LDM ENABLE"},
1145 {0, NULL((void*)0)}
1146};
1147
1148
1149/* the transfer type in the endpoint descriptor, i.e. the type of the endpoint
1150 (this is not the same as the URB transfer type) */
1151#define USB_EP_CONTROL0x00 0x00
1152#define USB_EP_ISOCHRONOUS0x01 0x01
1153#define USB_EP_BULK0x02 0x02
1154#define USB_EP_INTERRUPT0x03 0x03
1155
1156static const value_string usb_bmAttributes_transfer_vals[] = {
1157 {USB_EP_CONTROL0x00, "Control-Transfer"},
1158 {USB_EP_ISOCHRONOUS0x01, "Isochronous-Transfer"},
1159 {USB_EP_BULK0x02, "Bulk-Transfer"},
1160 {USB_EP_INTERRUPT0x03, "Interrupt-Transfer"},
1161 {0, NULL((void*)0)}
1162};
1163
1164static const value_string usb_bmAttributes_sync_vals[] = {
1165 {0x00, "No Sync"},
1166 {0x01, "Asynchronous"},
1167 {0x02, "Adaptive"},
1168 {0x03, "Synchronous"},
1169 {0, NULL((void*)0)}
1170};
1171
1172static const value_string usb_bmAttributes_behaviour_vals[] = {
1173 {0x00, "Data-Endpoint"},
1174 {0x01, "Explicit Feedback-Endpoint"},
1175 {0x02, "Implicit Feedback-Data-Endpoint"},
1176 {0x03, "Reserved"},
1177 {0, NULL((void*)0)}
1178};
1179
1180static const value_string usb_wMaxPacketSize_slots_vals[] = {
1181 {0x00, "1"},
1182 {0x01, "2"},
1183 {0x02, "3"},
1184 {0x03, "Reserved"},
1185 {0, NULL((void*)0)}
1186};
1187
1188/* USBPcap versions up to 1.4.1.0 captures USB control as 2 or 3 packets:
1189 * * SETUP with 8 bytes of Setup data
1190 * * DATA with optional data (either OUT or IN)
1191 * * STATUS without any USB payload, only the pseudoheader
1192 *
1193 * USBPcap versions 1.5.0.0 and up captures USB control as 2 packets:
1194 * * SETUP with 8 bytes of Setup data and optional DATA OUT
1195 * * COMPLETE with optional DATA IN
1196 *
1197 * The SETUP/COMPLETE matches the way control transfers are captured by
1198 * usbmon on Linux.
1199 */
1200#define USB_CONTROL_STAGE_SETUP0x00 0x00
1201#define USB_CONTROL_STAGE_DATA0x01 0x01
1202#define USB_CONTROL_STAGE_STATUS0x02 0x02
1203#define USB_CONTROL_STAGE_COMPLETE0x03 0x03
1204
1205static const value_string usb_control_stage_vals[] = {
1206 {USB_CONTROL_STAGE_SETUP0x00, "Setup"},
1207 {USB_CONTROL_STAGE_DATA0x01, "Data"},
1208 {USB_CONTROL_STAGE_STATUS0x02, "Status"},
1209 {USB_CONTROL_STAGE_COMPLETE0x03, "Complete"},
1210 {0, NULL((void*)0)}
1211};
1212
1213/* Extra URB code to indicate relevant USB IRPs that don't directly
1214 * have any matching USB transfer.
1215 */
1216#define USBPCAP_URB_IRP_INFO0xFE 0xFE
1217
1218static const value_string win32_usb_transfer_type_vals[] = {
1219 {URB_CONTROL0x2, "URB_CONTROL"},
1220 {URB_ISOCHRONOUS0x0, "URB_ISOCHRONOUS"},
1221 {URB_INTERRUPT0x1, "URB_INTERRUPT"},
1222 {URB_BULK0x3, "URB_BULK"},
1223 {USBPCAP_URB_IRP_INFO0xFE, "USB IRP Info"},
1224 {0, NULL((void*)0)}
1225};
1226
1227static const value_string win32_urb_function_vals[] = {
1228 {0x0000, "URB_FUNCTION_SELECT_CONFIGURATION"},
1229 {0x0001, "URB_FUNCTION_SELECT_INTERFACE"},
1230 {0x0002, "URB_FUNCTION_ABORT_PIPE"},
1231 {0x0003, "URB_FUNCTION_TAKE_FRAME_LENGTH_CONTROL"},
1232 {0x0004, "URB_FUNCTION_RELEASE_FRAME_LENGTH_CONTROL"},
1233 {0x0005, "URB_FUNCTION_GET_FRAME_LENGTH"},
1234 {0x0006, "URB_FUNCTION_SET_FRAME_LENGTH"},
1235 {0x0007, "URB_FUNCTION_GET_CURRENT_FRAME_NUMBER"},
1236 {0x0008, "URB_FUNCTION_CONTROL_TRANSFER"},
1237 {0x0009, "URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER"},
1238 {0x000A, "URB_FUNCTION_ISOCH_TRANSFER"},
1239 {0x000B, "URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE"},
1240 {0x000C, "URB_FUNCTION_SET_DESCRIPTOR_TO_DEVICE"},
1241 {0x000D, "URB_FUNCTION_SET_FEATURE_TO_DEVICE"},
1242 {0x000E, "URB_FUNCTION_SET_FEATURE_TO_INTERFACE"},
1243 {0x000F, "URB_FUNCTION_SET_FEATURE_TO_ENDPOINT"},
1244 {0x0010, "URB_FUNCTION_CLEAR_FEATURE_TO_DEVICE"},
1245 {0x0011, "URB_FUNCTION_CLEAR_FEATURE_TO_INTERFACE"},
1246 {0x0012, "URB_FUNCTION_CLEAR_FEATURE_TO_ENDPOINT"},
1247 {0x0013, "URB_FUNCTION_GET_STATUS_FROM_DEVICE"},
1248 {0x0014, "URB_FUNCTION_GET_STATUS_FROM_INTERFACE"},
1249 {0x0015, "URB_FUNCTION_GET_STATUS_FROM_ENDPOINT"},
1250 {0x0016, "URB_FUNCTION_RESERVED_0X0016"},
1251 {0x0017, "URB_FUNCTION_VENDOR_DEVICE"},
1252 {0x0018, "URB_FUNCTION_VENDOR_INTERFACE"},
1253 {0x0019, "URB_FUNCTION_VENDOR_ENDPOINT"},
1254 {0x001A, "URB_FUNCTION_CLASS_DEVICE"},
1255 {0x001B, "URB_FUNCTION_CLASS_INTERFACE"},
1256 {0x001C, "URB_FUNCTION_CLASS_ENDPOINT"},
1257 {0x001D, "URB_FUNCTION_RESERVE_0X001D"},
1258 {0x001E, "URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL"},
1259 {0x001F, "URB_FUNCTION_CLASS_OTHER"},
1260 {0x0020, "URB_FUNCTION_VENDOR_OTHER"},
1261 {0x0021, "URB_FUNCTION_GET_STATUS_FROM_OTHER"},
1262 {0x0022, "URB_FUNCTION_CLEAR_FEATURE_TO_OTHER"},
1263 {0x0023, "URB_FUNCTION_SET_FEATURE_TO_OTHER"},
1264 {0x0024, "URB_FUNCTION_GET_DESCRIPTOR_FROM_ENDPOINT"},
1265 {0x0025, "URB_FUNCTION_SET_DESCRIPTOR_TO_ENDPOINT"},
1266 {0x0026, "URB_FUNCTION_GET_CONFIGURATION"},
1267 {0x0027, "URB_FUNCTION_GET_INTERFACE"},
1268 {0x0028, "URB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE"},
1269 {0x0029, "URB_FUNCTION_SET_DESCRIPTOR_TO_INTERFACE"},
1270 {0x002A, "URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR"},
1271 {0x002B, "URB_FUNCTION_RESERVE_0X002B"},
1272 {0x002C, "URB_FUNCTION_RESERVE_0X002C"},
1273 {0x002D, "URB_FUNCTION_RESERVE_0X002D"},
1274 {0x002E, "URB_FUNCTION_RESERVE_0X002E"},
1275 {0x002F, "URB_FUNCTION_RESERVE_0X002F"},
1276 {0x0030, "URB_FUNCTION_SYNC_RESET_PIPE"},
1277 {0x0031, "URB_FUNCTION_SYNC_CLEAR_STALL"},
1278 {0x0032, "URB_FUNCTION_CONTROL_TRANSFER_EX"},
1279 {0x0033, "URB_FUNCTION_RESERVE_0X0033"},
1280 {0x0034, "URB_FUNCTION_RESERVE_0X0034"},
1281 {0, NULL((void*)0)}
1282};
1283static value_string_ext win32_urb_function_vals_ext = VALUE_STRING_EXT_INIT(win32_urb_function_vals){ _try_val_to_str_ext_init, 0, (sizeof (win32_urb_function_vals
) / sizeof ((win32_urb_function_vals)[0]))-1, win32_urb_function_vals
, "win32_urb_function_vals", ((void*)0) }
;
1284
1285static const value_string win32_usbd_status_vals[] = {
1286 {0x00000000, "USBD_STATUS_SUCCESS"},
1287 {0x40000000, "USBD_STATUS_PENDING"},
1288
1289 {0x80000200, "USBD_STATUS_INVALID_URB_FUNCTION"},
1290 {0x80000300, "USBD_STATUS_INVALID_PARAMETER"},
1291 {0x80000400, "USBD_STATUS_ERROR_BUSY"},
1292 {0x80000600, "USBD_STATUS_INVALID_PIPE_HANDLE"},
1293 {0x80000700, "USBD_STATUS_NO_BANDWIDTH"},
1294 {0x80000800, "USBD_STATUS_INTERNAL_HC_ERROR"},
1295 {0x80000900, "USBD_STATUS_ERROR_SHORT_TRANSFER"},
1296
1297 {0xC0000001, "USBD_STATUS_CRC"},
1298 {0xC0000002, "USBD_STATUS_BTSTUFF"},
1299 {0xC0000003, "USBD_STATUS_DATA_TOGGLE_MISMATCH"},
1300 {0xC0000004, "USBD_STATUS_STALL_PID"},
1301 {0xC0000005, "USBD_STATUS_DEV_NOT_RESPONDING"},
1302 {0xC0000006, "USBD_STATUS_PID_CHECK_FAILURE"},
1303 {0xC0000007, "USBD_STATUS_UNEXPECTED_PID"},
1304 {0xC0000008, "USBD_STATUS_DATA_OVERRUN"},
1305 {0xC0000009, "USBD_STATUS_DATA_UNDERRUN"},
1306 {0xC000000A, "USBD_STATUS_RESERVED1"},
1307 {0xC000000B, "USBD_STATUS_RESERVED2"},
1308 {0xC000000C, "USBD_STATUS_BUFFER_OVERRUN"},
1309 {0xC000000D, "USBD_STATUS_BUFFER_UNDERRUN"},
1310 {0xC000000F, "USBD_STATUS_NOT_ACCESSED"},
1311 {0xC0000010, "USBD_STATUS_FIFO"},
1312 {0xC0000011, "USBD_STATUS_XACT_ERROR"},
1313 {0xC0000012, "USBD_STATUS_BABBLE_DETECTED"},
1314 {0xC0000013, "USBD_STATUS_DATA_BUFFER_ERROR"},
1315 {0xC0000030, "USBD_STATUS_ENDPOINT_HALTED"},
1316
1317 {0xC0000A00, "USBD_STATUS_BAD_START_FRAME"},
1318 {0xC0000B00, "USBD_STATUS_ISOCH_REQUEST_FAILED"},
1319 {0xC0000C00, "USBD_STATUS_FRAME_CONTROL_OWNED"},
1320 {0xC0000D00, "USBD_STATUS_FRAME_CONTROL_NOT_OWNED"},
1321 {0xC0000E00, "USBD_STATUS_NOT_SUPPORTED"},
1322 {0xC0000F00, "USBD_STATUS_INVALID_CONFIGURATION_DESCRIPTOR"},
1323 {0xC0001000, "USBD_STATUS_INSUFFICIENT_RESOURCES"},
1324 {0xC0002000, "USBD_STATUS_SET_CONFIG_FAILED"},
1325 {0xC0003000, "USBD_STATUS_BUFFER_TOO_SMALL"},
1326 {0xC0004000, "USBD_STATUS_INTERFACE_NOT_FOUND"},
1327 {0xC0005000, "USBD_STATUS_INVALID_PIPE_FLAGS"},
1328 {0xC0006000, "USBD_STATUS_TIMEOUT"},
1329 {0xC0007000, "USBD_STATUS_DEVICE_GONE"},
1330 {0xC0008000, "USBD_STATUS_STATUS_NOT_MAPPED"},
1331 {0xC0009000, "USBD_STATUS_HUB_INTERNAL_ERROR"},
1332 {0xC0010000, "USBD_STATUS_CANCELED"},
1333 {0xC0020000, "USBD_STATUS_ISO_NOT_ACCESSED_BY_HW"},
1334 {0xC0030000, "USBD_STATUS_ISO_TD_ERROR"},
1335 {0xC0040000, "USBD_STATUS_ISO_NA_LATE_USBPORT"},
1336 {0xC0050000, "USBD_STATUS_ISO_NOT_ACCESSED_LATE"},
1337 {0xC0100000, "USBD_STATUS_BAD_DESCRIPTOR"},
1338 {0xC0100001, "USBD_STATUS_BAD_DESCRIPTOR_BLEN"},
1339 {0xC0100002, "USBD_STATUS_BAD_DESCRIPTOR_TYPE"},
1340 {0xC0100003, "USBD_STATUS_BAD_INTERFACE_DESCRIPTOR"},
1341 {0xC0100004, "USBD_STATUS_BAD_ENDPOINT_DESCRIPTOR"},
1342 {0xC0100005, "USBD_STATUS_BAD_INTERFACE_ASSOC_DESCRIPTOR"},
1343 {0xC0100006, "USBD_STATUS_BAD_CONFIG_DESC_LENGTH"},
1344 {0xC0100007, "USBD_STATUS_BAD_NUMBER_OF_INTERFACES"},
1345 {0xC0100008, "USBD_STATUS_BAD_NUMBER_OF_ENDPOINTS"},
1346 {0xC0100009, "USBD_STATUS_BAD_ENDPOINT_ADDRESS"},
1347 {0, NULL((void*)0)}
1348};
1349static value_string_ext win32_usbd_status_vals_ext = VALUE_STRING_EXT_INIT(win32_usbd_status_vals){ _try_val_to_str_ext_init, 0, (sizeof (win32_usbd_status_vals
) / sizeof ((win32_usbd_status_vals)[0]))-1, win32_usbd_status_vals
, "win32_usbd_status_vals", ((void*)0) }
;
1350
1351static const value_string win32_usb_info_direction_vals[] = {
1352 {0, "FDO -> PDO"},
1353 {1, "PDO -> FDO"},
1354 {0, NULL((void*)0)}
1355};
1356
1357static const value_string usb_cdc_protocol_vals[] = {
1358 {0x00, "No class specific protocol required"},
1359 {0x01, "AT Commands: V.250 etc"},
1360 {0x02, "AT Commands defined by PCCA-101"},
1361 {0x03, "AT Commands defined by PCCA-101 & Annex O"},
1362 {0x04, "AT Commands defined by GSM 07.07"},
1363 {0x05, "AT Commands defined by 3GPP 27.007"},
1364 {0x06, "AT Commands defined by TIA for CDMA"},
1365 {0x07, "Ethernet Emulation Model"},
1366 {0xFE, "External Protocol: Commands defined by Command Set Functional Descriptor"},
1367 {0xFF, "Vendor-specific"},
1368 {0, NULL((void*)0)}
1369};
1370static value_string_ext usb_cdc_protocol_vals_ext = VALUE_STRING_EXT_INIT(usb_cdc_protocol_vals){ _try_val_to_str_ext_init, 0, (sizeof (usb_cdc_protocol_vals
) / sizeof ((usb_cdc_protocol_vals)[0]))-1, usb_cdc_protocol_vals
, "usb_cdc_protocol_vals", ((void*)0) }
;
1371
1372static const value_string usb_cdc_data_protocol_vals[] = {
1373 {0x00, "No class specific protocol required"},
1374 {0x01, "Network Transfer Block"},
1375 {0x02, "Network Transfer Block (IP + DSS)"},
1376 {0x30, "Physical interface protocol for ISDN BRI"},
1377 {0x31, "HDLC"},
1378 {0x32, "Transparent"},
1379 {0x50, "Management protocol for Q.921 data link protocol"},
1380 {0x51, "Data link protocol for Q.931"},
1381 {0x52, "TEI-multiplexor for Q.921 data link protocol"},
1382 {0x90, "Data compression procedures"},
1383 {0x91, "Euro-ISDN protocol control"},
1384 {0x92, "V.24 rate adaptation to ISDN"},
1385 {0x93, "CAPI Commands"},
1386 {0xFE, "The protocol(s) are described using a Protocol Unit Functional Descriptors on Communications Class Interface"},
1387 {0xFF, "Vendor-specific"},
1388 {0, NULL((void*)0)}
1389};
1390static value_string_ext usb_cdc_data_protocol_vals_ext = VALUE_STRING_EXT_INIT(usb_cdc_data_protocol_vals){ _try_val_to_str_ext_init, 0, (sizeof (usb_cdc_data_protocol_vals
) / sizeof ((usb_cdc_data_protocol_vals)[0]))-1, usb_cdc_data_protocol_vals
, "usb_cdc_data_protocol_vals", ((void*)0) }
;
1391
1392static const value_string usb_hid_subclass_vals[] = {
1393 {0, "No Subclass"},
1394 {1, "Boot Interface"},
1395 {0, NULL((void*)0)}
1396};
1397static value_string_ext usb_hid_subclass_vals_ext = VALUE_STRING_EXT_INIT(usb_hid_subclass_vals){ _try_val_to_str_ext_init, 0, (sizeof (usb_hid_subclass_vals
) / sizeof ((usb_hid_subclass_vals)[0]))-1, usb_hid_subclass_vals
, "usb_hid_subclass_vals", ((void*)0) }
;
1398
1399static const value_string usb_hid_boot_protocol_vals[] = {
1400 {0, "None"},
1401 {1, "Keyboard"},
1402 {2, "Mouse"},
1403 {0, NULL((void*)0)}
1404};
1405static value_string_ext usb_hid_boot_protocol_vals_ext = VALUE_STRING_EXT_INIT(usb_hid_boot_protocol_vals){ _try_val_to_str_ext_init, 0, (sizeof (usb_hid_boot_protocol_vals
) / sizeof ((usb_hid_boot_protocol_vals)[0]))-1, usb_hid_boot_protocol_vals
, "usb_hid_boot_protocol_vals", ((void*)0) }
;
1406
1407static const value_string usb_misc_subclass_vals[] = {
1408 {0x03, "Cable Based Association Framework"},
1409 {0x04, "RNDIS"},
1410 {IF_SUBCLASS_MISC_U3V0x05, "USB3 Vision"},
1411 {0x06, "Stream Transport Efficient Protocol"},
1412 {0, NULL((void*)0)}
1413};
1414static value_string_ext usb_misc_subclass_vals_ext = VALUE_STRING_EXT_INIT(usb_misc_subclass_vals){ _try_val_to_str_ext_init, 0, (sizeof (usb_misc_subclass_vals
) / sizeof ((usb_misc_subclass_vals)[0]))-1, usb_misc_subclass_vals
, "usb_misc_subclass_vals", ((void*)0) }
;
1415
1416
1417static const value_string usb_app_subclass_vals[] = {
1418 {0x01, "Device Firmware Upgrade"},
1419 {0x02, "IRDA Bridge"},
1420 {0x03, "USB Test and Measurement Device"},
1421 {0, NULL((void*)0)}
1422};
1423static value_string_ext usb_app_subclass_vals_ext = VALUE_STRING_EXT_INIT(usb_app_subclass_vals){ _try_val_to_str_ext_init, 0, (sizeof (usb_app_subclass_vals
) / sizeof ((usb_app_subclass_vals)[0]))-1, usb_app_subclass_vals
, "usb_app_subclass_vals", ((void*)0) }
;
1424
1425
1426static const value_string usb_app_dfu_protocol_vals[] = {
1427 {0x01, "Runtime protocol"},
1428 {0x02, "DFU mode protocol"},
1429 {0, NULL((void*)0)}
1430};
1431static value_string_ext usb_app_dfu_protocol_vals_ext = VALUE_STRING_EXT_INIT(usb_app_dfu_protocol_vals){ _try_val_to_str_ext_init, 0, (sizeof (usb_app_dfu_protocol_vals
) / sizeof ((usb_app_dfu_protocol_vals)[0]))-1, usb_app_dfu_protocol_vals
, "usb_app_dfu_protocol_vals", ((void*)0) }
;
1432
1433static const value_string usb_app_irda_protocol_vals[] = {
1434 {0x00, "IRDA Bridge device"},
1435 {0, NULL((void*)0)}
1436};
1437static value_string_ext usb_app_irda_protocol_vals_ext = VALUE_STRING_EXT_INIT(usb_app_irda_protocol_vals){ _try_val_to_str_ext_init, 0, (sizeof (usb_app_irda_protocol_vals
) / sizeof ((usb_app_irda_protocol_vals)[0]))-1, usb_app_irda_protocol_vals
, "usb_app_irda_protocol_vals", ((void*)0) }
;
1438
1439static const value_string usb_app_usb_test_and_measurement_protocol_vals[] = {
1440 {0x00, "USB Test and Measurement Device"},
1441 {0x01, "USB Test and Measurement Device conforming to the USBTMC USB488 Subclass Specification"},
1442 {0, NULL((void*)0)}
1443};
1444static value_string_ext usb_app_usb_test_and_measurement_protocol_vals_ext = VALUE_STRING_EXT_INIT(usb_app_usb_test_and_measurement_protocol_vals){ _try_val_to_str_ext_init, 0, (sizeof (usb_app_usb_test_and_measurement_protocol_vals
) / sizeof ((usb_app_usb_test_and_measurement_protocol_vals)[
0]))-1, usb_app_usb_test_and_measurement_protocol_vals, "usb_app_usb_test_and_measurement_protocol_vals"
, ((void*)0) }
;
1445
1446/* macOS */
1447
1448/* Request Type */
1449#define DARWIN_IO_SUBMIT0 0
1450#define DARWIN_IO_COMPLETE1 1
1451
1452
1453static const value_string usb_darwin_request_type_vals[] = {
1454 {DARWIN_IO_SUBMIT0, "SUBMIT"},
1455 {DARWIN_IO_COMPLETE1, "COMPLETE"},
1456 {0, NULL((void*)0)}
1457};
1458
1459/* Transfer type */
1460static const value_string usb_darwin_endpoint_type_vals[] = {
1461 {USB_EP_CONTROL0x00, "Control"},
1462 {USB_EP_ISOCHRONOUS0x01, "Isochronous"},
1463 {USB_EP_BULK0x02, "Bulk"},
1464 {USB_EP_INTERRUPT0x03, "Interrupt"},
1465 {0, NULL((void*)0)}
1466};
1467
1468/* USB speeds */
1469#define DARWIN_SPEED_LOW0 0
1470#define DARWIN_SPEED_FULL1 1
1471#define DARWIN_SPEED_HIGH2 2
1472#define DARWIN_SPEED_SUPER3 3
1473#define DARWIN_SPEED_SUPERPLUS4 4
1474
1475static const value_string usb_darwin_speed_vals[] = {
1476 {DARWIN_SPEED_LOW0, "Low"},
1477 {DARWIN_SPEED_FULL1, "Full"},
1478 {DARWIN_SPEED_HIGH2, "High"},
1479 {DARWIN_SPEED_SUPER3, "Super"},
1480 {DARWIN_SPEED_SUPERPLUS4, "Super+"},
1481 {0, NULL((void*)0)}
1482};
1483
1484static const value_string darwin_usb_status_vals[] = {
1485 {0x00000000, "kIOReturnSuccess"},
1486 {0xe00002bc, "kIOReturnError"},
1487 {0xe00002bd, "kIOReturnNoMemory"},
1488 {0xe00002be, "kIOReturnNoResources"},
1489 {0xe00002bf, "kIOReturnIPCError"},
1490 {0xe00002c0, "kIOReturnNoDevice"},
1491 {0xe00002c1, "kIOReturnNotPrivileged"},
1492 {0xe00002c2, "kIOReturnBadArgument"},
1493 {0xe00002c3, "kIOReturnLockedRead"},
1494 {0xe00002c4, "kIOReturnLockedWrite"},
1495 {0xe00002c5, "kIOReturnExclusiveAccess"},
1496 {0xe00002c6, "kIOReturnBadMessageID"},
1497 {0xe00002c7, "kIOReturnUnsupported"},
1498 {0xe00002c8, "kIOReturnVMError"},
1499 {0xe00002c9, "kIOReturnInternalError"},
1500 {0xe00002ca, "kIOReturnIOError"},
1501
1502 {0xe00002cc, "kIOReturnCannotLock"},
1503 {0xe00002cd, "kIOReturnNotOpen"},
1504 {0xe00002ce, "kIOReturnNotReadable"},
1505 {0xe00002cf, "kIOReturnNotWritable"},
1506 {0xe00002d0, "kIOReturnNotAligned"},
1507 {0xe00002d1, "kIOReturnBadMedia"},
1508 {0xe00002d2, "kIOReturnStillOpen"},
1509 {0xe00002d3, "kIOReturnRLDError"},
1510 {0xe00002d4, "kIOReturnDMAError"},
1511 {0xe00002d5, "kIOReturnBusy"},
1512 {0xe00002d6, "kIOReturnTimeout"},
1513 {0xe00002d7, "kIOReturnOffline"},
1514 {0xe00002d8, "kIOReturnNotReady"},
1515 {0xe00002d9, "kIOReturnNotAttached"},
1516 {0xe00002da, "kIOReturnNoChannels"},
1517 {0xe00002db, "kIOReturnNoSpace"},
1518
1519 {0xe00002dd, "kIOReturnPortExists"},
1520 {0xe00002de, "kIOReturnCannotWire"},
1521 {0xe00002df, "kIOReturnNoInterrupt"},
1522 {0xe00002e0, "kIOReturnNoFrames"},
1523 {0xe00002e1, "kIOReturnMessageTooLarge"},
1524 {0xe00002e2, "kIOReturnNotPermitted"},
1525 {0xe00002e3, "kIOReturnNoPower"},
1526 {0xe00002e4, "kIOReturnNoMedia"},
1527 {0xe00002e5, "kIOReturnUnformattedMedia"},
1528 {0xe00002e6, "kIOReturnUnsupportedMode"},
1529 {0xe00002e7, "kIOReturnUnderrun"},
1530 {0xe00002e8, "kIOReturnOverrun"},
1531 {0xe00002e9, "kIOReturnDeviceError"},
1532 {0xe00002ea, "kIOReturnNoCompletion"},
1533 {0xe00002eb, "kIOReturnAborted"},
1534 {0xe00002ec, "kIOReturnNoBandwidth"},
1535 {0xe00002ed, "kIOReturnNotResponding"},
1536 {0xe00002ee, "kIOReturnIsoTooOld"},
1537 {0xe00002ef, "kIOReturnIsoTooNew"},
1538 {0xe00002f0, "kIOReturnNotFound"},
1539 {0, NULL((void*)0)}
1540};
1541
1542static const uint32_t darwin_endpoint_to_linux[] =
1543{
1544 URB_CONTROL0x2,
1545 URB_ISOCHRONOUS0x0,
1546 URB_BULK0x3,
1547 URB_INTERRUPT0x1,
1548 URB_UNKNOWN0xFF
1549};
1550
1551static value_string_ext usb_darwin_status_vals_ext = VALUE_STRING_EXT_INIT(darwin_usb_status_vals){ _try_val_to_str_ext_init, 0, (sizeof (darwin_usb_status_vals
) / sizeof ((darwin_usb_status_vals)[0]))-1, darwin_usb_status_vals
, "darwin_usb_status_vals", ((void*)0) }
;
1552
1553
1554static const value_string netmon_event_id_vals[] = {
1555 {1, "USBPORT_ETW_EVENT_HC_ADD USBPORT_ETW_EVENT_HC_ADD"},
1556 {2, "USBPORT_ETW_EVENT_HC_REMOVAL USBPORT_ETW_EVENT_HC_REMOVAL"},
1557 {3, "USBPORT_ETW_EVENT_HC_INFORMATION USBPORT_ETW_EVENT_HC_INFORMATION"},
1558 {4, "USBPORT_ETW_EVENT_HC_START USBPORT_ETW_EVENT_HC_START"},
1559 {5, "USBPORT_ETW_EVENT_HC_STOP USBPORT_ETW_EVENT_HC_STOP"},
1560 {6, "USBPORT_ETW_EVENT_HC_SUSPEND USBPORT_ETW_EVENT_HC_SUSPEND"},
1561 {7, "USBPORT_ETW_EVENT_HC_RESUME USBPORT_ETW_EVENT_HC_RESUME"},
1562 {8, "USBPORT_ETW_EVENT_HC_ASYNC_SCHEDULE_ENABLE"},
1563 {9, "USBPORT_ETW_EVENT_HC_ASYNC_SCHEDULE_DISABLE"},
1564 {10, "USBPORT_ETW_EVENT_HC_PERIODIC_SCHEDULE_ENABLE"},
1565 {11, "USBPORT_ETW_EVENT_HC_PERIODIC_SCHEDULE_DISABLE"},
1566 {12, "USBPORT_ETW_EVENT_DEVICE_CREATE"},
1567 {13, "USBPORT_ETW_EVENT_DEVICE_INITIALIZE"},
1568 {14, "USBPORT_ETW_EVENT_DEVICE_REMOVAL"},
1569 {15, "USBPORT_ETW_EVENT_DEVICE_INFORMATION"},
1570 {16, "USBPORT_ETW_EVENT_DEVICE_IDLE_STATE_SET"},
1571 {17, "USBPORT_ETW_EVENT_DEVICE_IDLE_STATE_CLEAR"},
1572 {18, "USBPORT_ETW_EVENT_ENDPOINT_OPEN"},
1573 {19, "USBPORT_ETW_EVENT_ENDPOINT_CLOSE USBPORT_ETW_EVENT_ENDPOINT_CLOSE"},
1574 {20, "USBPORT_ETW_EVENT_ENDPOINT_INFORMATION"},
1575 {21, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_SELECT_CONFIGURATION"},
1576 {22, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_SELECT_INTERFACE"},
1577 {23, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_GET_CURRENT_FRAME_NUMBER"},
1578 {24, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_CONTROL_TRANSFER"},
1579 {25, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_CONTROL_TRANSFER_EX"},
1580 {26, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER"},
1581 {27, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_ISOCH_TRANSFER"},
1582 {28, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE"},
1583 {29, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_SET_DESCRIPTOR_TO_DEVICE"},
1584 {30, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_GET_DESCRIPTOR_FROM_ENDPOINT"},
1585 {31, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_SET_DESCRIPTOR_TO_ENDPOINT"},
1586 {32, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE"},
1587 {33, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_SET_DESCRIPTOR_TO_INTERFACE"},
1588 {34, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_SET_FEATURE_TO_DEVICE"},
1589 {35, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_SET_FEATURE_TO_INTERFACE"},
1590 {36, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_SET_FEATURE_TO_ENDPOINT"},
1591 {37, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_CLEAR_FEATURE_TO_DEVICE"},
1592 {38, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_CLEAR_FEATURE_TO_INTERFACE"},
1593 {39, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_CLEAR_FEATURE_TO_ENDPOINT"},
1594 {40, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_CLEAR_FEATURE_TO_OTHER"},
1595 {41, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_SET_FEATURE_TO_OTHER"},
1596 {42, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_GET_STATUS_FROM_DEVICE"},
1597 {43, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_GET_STATUS_FROM_INTERFACE"},
1598 {44, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_GET_STATUS_FROM_ENDPOINT"},
1599 {45, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_GET_STATUS_FROM_OTHER"},
1600 {46, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_VENDOR_DEVICE"},
1601 {47, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_VENDOR_INTERFACE"},
1602 {48, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_VENDOR_ENDPOINT"},
1603 {49, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_CLASS_DEVICE"},
1604 {50, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_CLASS_INTERFACE"},
1605 {51, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_CLASS_ENDPOINT"},
1606 {52, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_CLASS_OTHER"},
1607 {53, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_VENDOR_OTHER"},
1608 {54, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_ABORT_PIPE"},
1609 {55, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL"},
1610 {56, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_SYNC_RESET_PIPE"},
1611 {57, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_SYNC_CLEAR_STALL"},
1612 {58, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_GET_CONFIGURATION"},
1613 {59, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_GET_INTERFACE"},
1614 {60, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR"},
1615 {61, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_TAKE_FRAME_LENGTH_CONTROL"},
1616 {62, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_RELEASE_FRAME_LENGTH_CONTROL"},
1617 {63, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_GET_FRAME_LENGTH"},
1618 {64, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_SET_FRAME_LENGTH"},
1619 {65, "USBPORT_ETW_EVENT_DISPATCH_URB_FUNCTION_RESERVED"},
1620 {66, "USBPORT_ETW_EVENT_COMPLETE_URB_FUNCTION_CONTROL_TRANSFER"},
1621 {67, "USBPORT_ETW_EVENT_COMPLETE_URB_FUNCTION_CONTROL_TRANSFER_EX"},
1622 {68, "USBPORT_ETW_EVENT_COMPLETE_URB_FUNCTION_CONTROL_TRANSFER_DATA"},
1623 {69, "USBPORT_ETW_EVENT_COMPLETE_URB_FUNCTION_CONTROL_TRANSFER_EX_DATA"},
1624 {70, "USBPORT_ETW_EVENT_COMPLETE_URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER"},
1625 {71, "USBPORT_ETW_EVENT_COMPLETE_URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER_DATA"},
1626 {72, "USBPORT_ETW_EVENT_COMPLETE_URB_FUNCTION_ISOCH_TRANSFER"},
1627 {73, "USBPORT_ETW_EVENT_COMPLETE_URB_FUNCTION_ISOCH_TRANSFER_DATA"},
1628 {74, "USBPORT_ETW_EVENT_INTERNAL_URB_FUNCTION_CONTROL_TRANSFER"},
1629 {75, "USBPORT_ETW_EVENT_COMPLETE_INTERNAL_URB_FUNCTION_CONTROL_TRANSFER"},
1630 {76, "USBPORT_ETW_EVENT_COMPLETE_INTERNAL_URB_FUNCTION_CONTROL_TRANSFER_DATA"},
1631 {77, "USBPORT_ETW_EVENT_COMPLETE_URB_FUNCTION_ABORT_PIPE"},
1632 {78, "USBPORT_ETW_EVENT_DISPATCH_URB_INVALID_HEADER_LENGTH_WARNING"},
1633 {79, "USBPORT_ETW_EVENT_DISPATCH_URB_INVALID_FUNCTION"},
1634 {80, "USBPORT_ETW_EVENT_DISPATCH_URB_INVALID_HEADER_LENGTH"},
1635 {81, "USBPORT_ETW_EVENT_DISPATCH_URB_INVALID_DEVICE_HANDLE"},
1636 {82, "USBPORT_ETW_EVENT_DISPATCH_URB_INVALID_FUNCTION_NOT_SUPPORTED"},
1637 {83, "USBPORT_ETW_EVENT_DISPATCH_URB_INVALID_FUNCTION_RESERVED"},
1638 {84, "USBPORT_ETW_EVENT_DISPATCH_URB_INVALID_DUE_TO_HC_SUSPEND"},
1639 {85, "USBPORT_ETW_EVENT_DISPATCH_URB_INVALID_URB_LINK"},
1640 {86, "USBPORT_ETW_EVENT_DISPATCH_URB_INVALID_PIPE_HANDLE"},
1641 {87, "USBPORT_ETW_EVENT_DISPATCH_URB_INVALID_ZERO_BW_PIPE_HANDLE"},
1642 {88, "USBPORT_ETW_EVENT_DISPATCH_URB_NOP_ZERO_BW_PIPE_HANDLE_REQUEST"},
1643 {89, "USBPORT_ETW_EVENT_DISPATCH_URB_INVALID_CONTROL_TRANSFER_ENDPOINT"},
1644 {90, "USBPORT_ETW_EVENT_DISPATCH_URB_INVALID_CONTROL_TRANSFER_BUFFER_LENGTH"},
1645 {91, "USBPORT_ETW_EVENT_DISPATCH_URB_INVALID_BULK_OR_INTERRUPT_TRANSFER_ENDPOINT"},
1646 {92, "USBPORT_ETW_EVENT_DISPATCH_URB_INVALID_BULK_OR_INTERRUPT_TRANSFER_BUFFER_LENGTH"},
1647 {93, "USBPORT_ETW_EVENT_DISPATCH_URB_INVALID_ISOCHRONOUS_TRANSFER_ENDPOINT"},
1648 {94, "USBPORT_ETW_EVENT_DISPATCH_URB_INVALID_NULL_TRANSFER_BUFFER_AND_MDL"},
1649 {95, "USBPORT_ETW_EVENT_DISPATCH_URB_INVALID_NON_NULL_TRANSFER_BUFFER_MDL"},
1650 {96, "USBPORT_ETW_EVENT_DISPATCH_URB_ALLOCATE_MDL_FAILURE"},
1651 {97, "USBPORT_ETW_EVENT_DISPATCH_URB_ALLOCATE_TRANSFER_CONTEXT_FAILURE"},
1652 {98, "USBPORT_ETW_EVENT_DISPATCH_URB_NOP_ROOTHUB_PIPE_HANDLE_REQUEST"},
1653 {99, "USBPORT_ETW_EVENT_DISPATCH_URB_INVALID_ISOCHRONOUS_ZERO_LENGTH"},
1654 {100, "USBPORT_ETW_EVENT_DISPATCH_URB_INVALID_ISOCHRONOUS_NUM_PACKETS"},
1655 {101, "USBPORT_ETW_EVENT_DISPATCH_URB_INVALID_ISOCHRONOUS_START_FRAME"},
1656 {102, "USBPORT_ETW_EVENT_IRP_CANCEL"},
1657 {103, "USBPORT_ETW_EVENT_USBUSER_OP_RAW_RESET_PORT_DISPATCH"},
1658 {104, "USBPORT_ETW_EVENT_USBUSER_OP_RAW_RESET_PORT_STATUS1"},
1659 {105, "USBPORT_ETW_EVENT_USBUSER_OP_RAW_RESET_PORT_STATUS2"},
1660 {106, "USBPORT_ETW_EVENT_USBUSER_OP_RAW_RESET_PORT_STATUS3"},
1661 {107, "USBPORT_ETW_EVENT_USBUSER_OP_RAW_RESET_PORT_COMPLETE"},
1662 {108, "USBPORT_ETW_EVENT_USBUSER_OP_SEND_ONE_PACKET_DISPATCH"},
1663 {109, "USBPORT_ETW_EVENT_USBUSER_OP_SEND_ONE_PACKET_DISPATCH_DATA"},
1664 {110, "USBPORT_ETW_EVENT_USBUSER_OP_SEND_ONE_PACKET_TIMEOUT"},
1665 {111, "USBPORT_ETW_EVENT_USBUSER_OP_SEND_ONE_PACKET_COMPLETE"},
1666 {112, "USBPORT_ETW_EVENT_USBUSER_OP_SEND_ONE_PACKET_COMPLETE_DATA"},
1667 {113, "USBPORT_ETW_EVENT_CODE_EXECUTION_TIME"},
1668 {114, "USBPORT_ETW_EVENT_PUT_SGLIST_EXECUTION_TIME"},
1669 {115, "USBPORT_ETW_EVENT_BUILD_SGLIST_EXECUTION_TIME"},
1670 {1024, "USBPORT_ETW_EVENT_HC_EHCI_MINIPORT_START_DISPATCH"},
1671 {1025, "USBPORT_ETW_EVENT_HC_EHCI_MINIPORT_START_COMPLETE"},
1672 {1026, "USBPORT_ETW_EVENT_HC_EHCI_MINIPORT_START_COMPLETE_ERROR_1"},
1673 {1027, "USBPORT_ETW_EVENT_HC_EHCI_MINIPORT_START_COMPLETE_ERROR_2"},
1674 {1028, "USBPORT_ETW_EVENT_HC_EHCI_MINIPORT_START_COMPLETE_ERROR_3"},
1675 {1029, "USBPORT_ETW_EVENT_HC_EHCI_MINIPORT_START_COMPLETE_ERROR_4"},
1676 {1030, "USBPORT_ETW_EVENT_HC_EHCI_MINIPORT_START_COMPLETE_ERROR_5"},
1677 {1031, "USBPORT_ETW_EVENT_HC_EHCI_MINIPORT_STOP_DISPATCH"},
1678 {1032, "USBPORT_ETW_EVENT_HC_EHCI_MINIPORT_STOP_COMPLETE"},
1679 {1033, "USBPORT_ETW_EVENT_HC_EHCI_MINIPORT_SUSPEND_DISPATCH"},
1680 {1034, "USBPORT_ETW_EVENT_HC_EHCI_MINIPORT_SUSPEND_COMPLETE"},
1681 {1035, "USBPORT_ETW_EVENT_HC_EHCI_MINIPORT_RESUME_DISPATCH"},
1682 {1036, "USBPORT_ETW_EVENT_HC_EHCI_MINIPORT_RESUME_COMPLETE"},
1683 {1037, "USBPORT_ETW_EVENT_HC_EHCI_MINIPORT_RESUME_COMPLETE_ERROR_1"},
1684 {1038, "USBPORT_ETW_EVENT_HC_EHCI_MINIPORT_RESUME_COMPLETE_ERROR_2"},
1685 {1039, "USBPORT_ETW_EVENT_HC_EHCI_MINIPORT_RESUME_COMPLETE_ERROR_3"},
1686 {1040, "USBPORT_ETW_EVENT_HC_EHCI_MINIPORT_RESUME_COMPLETE_ERROR_4"},
1687 {1041, "USBPORT_ETW_EVENT_HC_EHCI_MINIPORT_RESUME_COMPLETE_ERROR_5"},
1688 {1042, "USBPORT_ETW_EVENT_HC_EHCI_MINIPORT_RESUME_COMPLETE_ERROR_6"},
1689 {2048, "USBPORT_ETW_EVENT_HC_OHCI_MINIPORT_START_DISPATCH"},
1690 {2049, "USBPORT_ETW_EVENT_HC_OHCI_MINIPORT_START_COMPLETE"},
1691 {2050, "USBPORT_ETW_EVENT_HC_OHCI_MINIPORT_START_COMPLETE_ERROR_1"},
1692 {2051, "USBPORT_ETW_EVENT_HC_OHCI_MINIPORT_START_COMPLETE_ERROR_2"},
1693 {2052, "USBPORT_ETW_EVENT_HC_OHCI_MINIPORT_START_COMPLETE_ERROR_3"},
1694 {2053, "USBPORT_ETW_EVENT_HC_OHCI_MINIPORT_START_COMPLETE_ERROR_4"},
1695 {2054, "USBPORT_ETW_EVENT_HC_OHCI_MINIPORT_START_COMPLETE_ERROR_5"},
1696 {2055, "USBPORT_ETW_EVENT_HC_OHCI_MINIPORT_STOP_DISPATCH"},
1697 {2056, "USBPORT_ETW_EVENT_HC_OHCI_MINIPORT_STOP_COMPLETE"},
1698 {2057, "USBPORT_ETW_EVENT_HC_OHCI_MINIPORT_SUSPEND_DISPATCH"},
1699 {2058, "USBPORT_ETW_EVENT_HC_OHCI_MINIPORT_SUSPEND_COMPLETE"},
1700 {2059, "USBPORT_ETW_EVENT_HC_OHCI_MINIPORT_RESUME_DISPATCH"},
1701 {2060, "USBPORT_ETW_EVENT_HC_OHCI_MINIPORT_RESUME_COMPLETE"},
1702 {2061, "USBPORT_ETW_EVENT_HC_OHCI_MINIPORT_RESUME_COMPLETE_ERROR_1"},
1703 {2062, "USBPORT_ETW_EVENT_HC_OHCI_MINIPORT_RESUME_COMPLETE_ERROR_2"},
1704 {2063, "USBPORT_ETW_EVENT_HC_OHCI_MINIPORT_RESUME_COMPLETE_ERROR_3"},
1705 {2064, "USBPORT_ETW_EVENT_HC_OHCI_MINIPORT_RESUME_COMPLETE_ERROR_4"},
1706 {2065, "USBPORT_ETW_EVENT_HC_OHCI_MINIPORT_RESUME_COMPLETE_ERROR_5"},
1707 {3072, "USBPORT_ETW_EVENT_HC_UHCI_MINIPORT_START_DISPATCH"},
1708 {3073, "USBPORT_ETW_EVENT_HC_UHCI_MINIPORT_START_COMPLETE"},
1709 {3074, "USBPORT_ETW_EVENT_HC_UHCI_MINIPORT_START_COMPLETE_ERROR_1"},
1710 {3075, "USBPORT_ETW_EVENT_HC_UHCI_MINIPORT_START_COMPLETE_ERROR_2"},
1711 {3076, "USBPORT_ETW_EVENT_HC_UHCI_MINIPORT_START_COMPLETE_ERROR_3"},
1712 {3077, "USBPORT_ETW_EVENT_HC_UHCI_MINIPORT_START_COMPLETE_ERROR_4"},
1713 {3078, "USBPORT_ETW_EVENT_HC_UHCI_MINIPORT_STOP_DISPATCH"},
1714 {3079, "USBPORT_ETW_EVENT_HC_UHCI_MINIPORT_STOP_COMPLETE"},
1715 {3080, "USBPORT_ETW_EVENT_HC_UHCI_MINIPORT_SUSPEND_DISPATCH"},
1716 {3081, "USBPORT_ETW_EVENT_HC_UHCI_MINIPORT_SUSPEND_COMPLETE"},
1717 {3082, "USBPORT_ETW_EVENT_HC_UHCI_MINIPORT_RESUME_DISPATCH"},
1718 {3083, "USBPORT_ETW_EVENT_HC_UHCI_MINIPORT_RESUME_COMPLETE"},
1719 {3084, "USBPORT_ETW_EVENT_HC_UHCI_MINIPORT_RESUME_COMPLETE_ERROR_1"},
1720 {3085, "USBPORT_ETW_EVENT_HC_UHCI_MINIPORT_RESUME_COMPLETE_ERROR_2"},
1721 {3086, "USBPORT_ETW_EVENT_HC_UHCI_MINIPORT_RESUME_COMPLETE_ERROR_3"},
1722 {3087, "USBPORT_ETW_EVENT_HC_UHCI_MINIPORT_RESUME_COMPLETE_ERROR_4"},
1723 {3088, "USBPORT_ETW_EVENT_HC_UHCI_MINIPORT_RESUME_COMPLETE_ERROR_5"},
1724 {3089, "USBPORT_ETW_EVENT_RTPM_TRANSITION"},
1725 {3090, "USBPORT_ETW_EVENT_DISPATCH_WAIT_WAKE"},
1726 {3091, "USBPORT_ETW_EVENT_COMPLETE_WAIT_WAKE"},
1727 {0, NULL((void*)0)}
1728};
1729static value_string_ext netmon_event_id_vals_ext = VALUE_STRING_EXT_INIT(netmon_event_id_vals){ _try_val_to_str_ext_init, 0, (sizeof (netmon_event_id_vals)
/ sizeof ((netmon_event_id_vals)[0]))-1, netmon_event_id_vals
, "netmon_event_id_vals", ((void*)0) }
;
1730
1731static const value_string netmon_urb_function_vals[] = {
1732 {0x0000, "SELECT_CONFIGURATION"},
1733 {0x0001, "SELECT_INTERFACE"},
1734 {0x0002, "ABORT_PIPE"},
1735 {0x0003, "TAKE_FRAME_LENGTH_CONTROL"},
1736 {0x0004, "RELEASE_FRAME_LENGTH_CONTROL"},
1737 {0x0005, "GET_FRAME_LENGTH"},
1738 {0x0006, "SET_FRAME_LENGTH"},
1739 {0x0007, "GET_CURRENT_FRAME_NUMBER"},
1740 {0x0008, "CONTROL_TRANSFER"},
1741 {0x0009, "BULK_OR_INTERRUPT_TRANSFER"},
1742 {0x000A, "ISOCH_TRANSFER"},
1743 {0x000B, "GET_DESCRIPTOR_FROM_DEVICE"},
1744 {0x000C, "SET_DESCRIPTOR_TO_DEVICE"},
1745 {0x000D, "SET_FEATURE_TO_DEVICE"},
1746 {0x000E, "SET_FEATURE_TO_INTERFACE"},
1747 {0x000F, "SET_FEATURE_TO_ENDPOINT"},
1748 {0x0010, "CLEAR_FEATURE_TO_DEVICE"},
1749 {0x0011, "CLEAR_FEATURE_TO_INTERFACE"},
1750 {0x0012, "CLEAR_FEATURE_TO_ENDPOINT"},
1751 {0x0013, "GET_STATUS_FROM_DEVICE"},
1752 {0x0014, "GET_STATUS_FROM_INTERFACE"},
1753 {0x0015, "GET_STATUS_FROM_ENDPOINT"},
1754 {0x0016, "RESERVED"},
1755 {0x0017, "VENDOR_DEVICE"},
1756 {0x0018, "VENDOR_INTERFACE"},
1757 {0x0019, "VENDOR_ENDPOINT"},
1758 {0x001A, "CLASS_DEVICE"},
1759 {0x001B, "CLASS_INTERFACE"},
1760 {0x001C, "CLASS_ENDPOINT"},
1761 {0x001D, "RESERVE_0X001D"},
1762 {0x001E, "SYNC_RESET_PIPE_AND_CLEAR_STALL"},
1763 {0x001F, "CLASS_OTHER"},
1764 {0x0020, "VENDOR_OTHER"},
1765 {0x0021, "GET_STATUS_FROM_OTHER"},
1766 {0x0022, "CLEAR_FEATURE_TO_OTHER"},
1767 {0x0023, "SET_FEATURE_TO_OTHER"},
1768 {0x0024, "GET_DESCRIPTOR_FROM_ENDPOINT"},
1769 {0x0025, "SET_DESCRIPTOR_TO_ENDPOINT"},
1770 {0x0026, "GET_CONFIGURATION"},
1771 {0x0027, "GET_INTERFACE"},
1772 {0x0028, "GET_DESCRIPTOR_FROM_INTERFACE"},
1773 {0x0029, "SET_DESCRIPTOR_TO_INTERFACE"},
1774 {0x002A, "GET_MS_FEATURE_DESCRIPTOR"},
1775 {0x0030, "SYNC_RESET_PIPE"},
1776 {0x0031, "SYNC_CLEAR_STALL"},
1777 {0x0032, "CONTROL_TRANSFER_EX"},
1778 {0x0035, "OPEN_STATIC_STREAMS"},
1779 {0x0036, "CLOSE_STATIC_STREAMS"},
1780 {0x0037, "BULK_OR_INTERRUPT_TRANSFER_USING_CHAINED_MDL"},
1781 {0x0038, "ISOCH_TRANSFER_USING_CHAINED_MDL"},
1782 {0, NULL((void*)0)}
1783};
1784static value_string_ext netmon_urb_function_vals_ext = VALUE_STRING_EXT_INIT(netmon_urb_function_vals){ _try_val_to_str_ext_init, 0, (sizeof (netmon_urb_function_vals
) / sizeof ((netmon_urb_function_vals)[0]))-1, netmon_urb_function_vals
, "netmon_urb_function_vals", ((void*)0) }
;
1785
1786
1787void proto_register_usb(void);
1788void proto_reg_handoff_usb(void);
1789
1790/* USB address handling */
1791static int usb_addr_to_str(const address* addr, char *buf, int buf_len _U___attribute__((unused)))
1792{
1793 const uint8_t *addrp = (const uint8_t *)addr->data;
1794
1795 if(pletohu32(&addrp[0])==0xffffffff){
1796 (void) g_strlcpy(buf, "host", buf_len);
1797 } else {
1798 snprintf(buf, buf_len, "%u.%u.%u", pletohu16(&addrp[8]),
1799 pletohu32(&addrp[0]), pletohu32(&addrp[4]) & 0x0f);
1800 }
1801
1802 return (int)(strlen(buf)+1);
1803}
1804
1805static int usb_addr_str_len(const address* addr _U___attribute__((unused)))
1806{
1807 return 50;
1808}
1809
1810
1811/* This keys provide information for DecodeBy and other dissector via
1812 per packet data: p_get_proto_data()/p_add_proto_data() */
1813#define USB_BUS_ID0 0
1814#define USB_DEVICE_ADDRESS1 1
1815#define USB_VENDOR_ID2 2
1816#define USB_PRODUCT_ID3 3
1817#define USB_DEVICE_CLASS4 4
1818#define USB_DEVICE_SUBCLASS5 5
1819#define USB_DEVICE_PROTOCOL6 6
1820
1821static void
1822usb_device_prompt(packet_info *pinfo, char* result)
1823{
1824 snprintf(result, MAX_DECODE_AS_PROMPT_LEN200, "Bus ID %u \nDevice Address %u\nas ",
1825 GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, proto_usb, USB_BUS_ID))((guint) (gulong) (p_get_proto_data(pinfo->pool, pinfo, proto_usb
, 0)))
,
1826 GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, proto_usb, USB_DEVICE_ADDRESS))((guint) (gulong) (p_get_proto_data(pinfo->pool, pinfo, proto_usb
, 1)))
);
1827}
1828
1829static void *
1830usb_device_value(packet_info *pinfo)
1831{
1832 uint32_t value = GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, proto_usb, USB_BUS_ID))((guint) (gulong) (p_get_proto_data(pinfo->pool, pinfo, proto_usb
, 0)))
<< 16;
1833 value |= GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, proto_usb, USB_DEVICE_ADDRESS))((guint) (gulong) (p_get_proto_data(pinfo->pool, pinfo, proto_usb
, 1)))
;
1834 return GUINT_TO_POINTER(value)((gpointer) (gulong) (value));
1835}
1836
1837static void
1838usb_product_prompt(packet_info *pinfo, char* result)
1839{
1840 snprintf(result, MAX_DECODE_AS_PROMPT_LEN200, "Vendor ID 0x%04x \nProduct ID 0x%04x\nas ",
1841 GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, proto_usb, USB_VENDOR_ID))((guint) (gulong) (p_get_proto_data(pinfo->pool, pinfo, proto_usb
, 2)))
,
1842 GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, proto_usb, USB_PRODUCT_ID))((guint) (gulong) (p_get_proto_data(pinfo->pool, pinfo, proto_usb
, 3)))
);
1843}
1844
1845static void *
1846usb_product_value(packet_info *pinfo)
1847{
1848 uint32_t value = GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, proto_usb, USB_VENDOR_ID))((guint) (gulong) (p_get_proto_data(pinfo->pool, pinfo, proto_usb
, 2)))
<< 16;
1849 value |= GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, proto_usb, USB_PRODUCT_ID))((guint) (gulong) (p_get_proto_data(pinfo->pool, pinfo, proto_usb
, 3)))
;
1850 return GUINT_TO_POINTER(value)((gpointer) (gulong) (value));
1851}
1852
1853static void
1854usb_protocol_prompt(packet_info *pinfo, char* result)
1855{
1856 snprintf(result, MAX_DECODE_AS_PROMPT_LEN200, "Class ID 0x%04x \nSubclass ID 0x%04x\nProtocol 0x%04x\nas ",
1857 GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, proto_usb, USB_DEVICE_CLASS))((guint) (gulong) (p_get_proto_data(pinfo->pool, pinfo, proto_usb
, 4)))
,
1858 GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, proto_usb, USB_DEVICE_SUBCLASS))((guint) (gulong) (p_get_proto_data(pinfo->pool, pinfo, proto_usb
, 5)))
,
1859 GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, proto_usb, USB_DEVICE_PROTOCOL))((guint) (gulong) (p_get_proto_data(pinfo->pool, pinfo, proto_usb
, 6)))
);
1860}
1861
1862static void *
1863usb_protocol_value(packet_info *pinfo)
1864{
1865 uint32_t value = GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, proto_usb, USB_DEVICE_CLASS))((guint) (gulong) (p_get_proto_data(pinfo->pool, pinfo, proto_usb
, 4)))
<< 16;
1866 value |= GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, proto_usb, USB_DEVICE_SUBCLASS))((guint) (gulong) (p_get_proto_data(pinfo->pool, pinfo, proto_usb
, 5)))
<< 8;
1867 value |= GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, proto_usb, USB_DEVICE_PROTOCOL))((guint) (gulong) (p_get_proto_data(pinfo->pool, pinfo, proto_usb
, 6)))
;
1868 return GUINT_TO_POINTER(value)((gpointer) (gulong) (value));
1869}
1870
1871static build_valid_func usb_product_da_build_value[1] = {usb_product_value};
1872static decode_as_value_t usb_product_da_values = {usb_product_prompt, 1, usb_product_da_build_value};
1873static decode_as_t usb_product_da = {
1874 "usb", "usb.product",
1875 1, 0, &usb_product_da_values, NULL((void*)0), NULL((void*)0),
1876 decode_as_default_populate_list, decode_as_default_reset,
1877 decode_as_default_change, NULL((void*)0), NULL((void*)0), NULL((void*)0) };
1878
1879static build_valid_func usb_device_da_build_value[1] = {usb_device_value};
1880static decode_as_value_t usb_device_da_values = {usb_device_prompt, 1, usb_device_da_build_value};
1881static decode_as_t usb_device_da = {
1882 "usb", "usb.device",
1883 1, 0, &usb_device_da_values, NULL((void*)0), NULL((void*)0),
1884 decode_as_default_populate_list, decode_as_default_reset,
1885 decode_as_default_change, NULL((void*)0), NULL((void*)0), NULL((void*)0) };
1886
1887static build_valid_func usb_protocol_da_build_value[1] = {usb_protocol_value};
1888static decode_as_value_t usb_protocol_da_values = {usb_protocol_prompt, 1, usb_protocol_da_build_value};
1889static decode_as_t usb_protocol_da = {
1890 "usb", "usb.protocol",
1891 1, 0, &usb_protocol_da_values, NULL((void*)0), NULL((void*)0),
1892 decode_as_default_populate_list, decode_as_default_reset,
1893 decode_as_default_change, NULL((void*)0), NULL((void*)0), NULL((void*)0) };
1894
1895
1896static usb_conv_info_t *
1897get_usb_conv_info(conversation_t *conversation)
1898{
1899 usb_conv_info_t *usb_conv_info;
1900
1901 /* do we have conversation specific data ? */
1902 usb_conv_info = (usb_conv_info_t *)conversation_get_proto_data(conversation, proto_usb);
1903 if (!usb_conv_info) {
1904 /* no not yet so create some */
1905 usb_conv_info = wmem_new0(wmem_file_scope(), usb_conv_info_t)((usb_conv_info_t*)wmem_alloc0((wmem_file_scope()), sizeof(usb_conv_info_t
)))
;
1906 usb_conv_info->interfaceClass = IF_CLASS_UNKNOWN0xffff;
1907 usb_conv_info->interfaceSubclass = IF_SUBCLASS_UNKNOWN0xffff;
1908 usb_conv_info->interfaceProtocol = IF_PROTOCOL_UNKNOWN0xffff;
1909 usb_conv_info->deviceVendor = DEV_VENDOR_UNKNOWN0x0000;
1910 usb_conv_info->deviceProduct = DEV_PRODUCT_UNKNOWN0xfffffff;
1911 usb_conv_info->deviceVersion = DEV_VERSION_UNKNOWN0xffff;
1912 usb_conv_info->alt_settings = wmem_array_new(wmem_file_scope(), sizeof(usb_alt_setting_t));
1913 usb_conv_info->transactions = wmem_tree_new(wmem_file_scope());
1914 usb_conv_info->descriptor_transfer_type = URB_UNKNOWN0xFF;
1915 usb_conv_info->max_packet_size = 0;
1916
1917 conversation_add_proto_data(conversation, proto_usb, usb_conv_info);
1918 }
1919
1920 return usb_conv_info;
1921}
1922
1923
1924/* urb_info_t contains some components that are valid only for one specific packet
1925 clear_usb_conv_tmp_data() clears these components, it should be called
1926 before we dissect a new packet */
1927static void clear_usb_conv_tmp_data(urb_info_t *urb)
1928{
1929 /* caller must have checked that urb!= NULL */
1930
1931 urb->direction = P2P_DIR_UNKNOWN-1;
1932 urb->transfer_type = URB_UNKNOWN0xFF;
1933 urb->is_request = false0;
1934 urb->is_setup = false0;
1935 urb->setup_requesttype = 0;
1936 urb->speed = USB_SPEED_UNKNOWN;
1937
1938 /* when we parse the configuration, interface and endpoint
1939 descriptors, we store the current interface class in endpoint 0's
1940 conversation
1941
1942 this must be cleared since endpoint 0 does not belong to any
1943 interface class
1944
1945 we used to clear these info in dissect_usb_configuration_descriptor()
1946 this doesn't work when the descriptor parsing throws an exception */
1947
1948 if (urb->conv
7.1
Field 'conv' is non-null
&& (urb->endpoint == 0)) {
8
Assuming field 'endpoint' is not equal to 0
9
Taking false branch
1949 urb->conv->interfaceClass = IF_CLASS_UNKNOWN0xffff;
1950 urb->conv->interfaceSubclass = IF_SUBCLASS_UNKNOWN0xffff;
1951 urb->conv->interfaceProtocol = IF_PROTOCOL_UNKNOWN0xffff;
1952 }
1953}
10
Returning without writing to 'urb->conv'
1954
1955static conversation_t *
1956get_usb_conversation(packet_info *pinfo,
1957 address *src_addr, address *dst_addr,
1958 uint32_t src_endpoint, uint32_t dst_endpoint)
1959{
1960 conversation_t *conversation;
1961
1962 /*
1963 * Do we have a conversation for this connection?
1964 */
1965 conversation = find_conversation(pinfo->num,
1966 src_addr, dst_addr,
1967 conversation_pt_to_conversation_type(pinfo->ptype),
1968 src_endpoint, dst_endpoint, 0);
1969 if (conversation) {
1970 return conversation;
1971 }
1972
1973 /* We don't yet have a conversation, so create one. */
1974 conversation = conversation_new(pinfo->num,
1975 src_addr, dst_addr,
1976 conversation_pt_to_conversation_type(pinfo->ptype),
1977 src_endpoint, dst_endpoint, 0);
1978 return conversation;
1979}
1980
1981/* Fetch or create usb_conv_info for a specified interface. */
1982usb_conv_info_t *
1983get_usb_iface_conv_info(packet_info *pinfo, uint8_t interface_num)
1984{
1985 conversation_t *conversation;
1986 uint32_t if_port;
1987
1988 if_port = GUINT32_TO_LE(INTERFACE_PORT | interface_num)((guint32) (0x80000000 | interface_num));
1989
1990 if (pinfo->srcport == NO_ENDPOINT0xffffffff) {
1991 conversation = get_usb_conversation(pinfo, &pinfo->src, &pinfo->dst, pinfo->srcport, if_port);
1992 } else {
1993 conversation = get_usb_conversation(pinfo, &pinfo->src, &pinfo->dst, if_port, pinfo->destport);
1994 }
1995
1996 return get_usb_conv_info(conversation);
1997}
1998
1999/* Fetch usb_conv_info for specified endpoint, return NULL if not found */
2000usb_conv_info_t *
2001get_existing_usb_ep_conv_info(packet_info* pinfo, uint16_t bus_id, uint16_t device_address, int endpoint)
2002{
2003 usb_address_t *src_addr = wmem_new0(pinfo->pool, usb_address_t)((usb_address_t*)wmem_alloc0((pinfo->pool), sizeof(usb_address_t
)))
,
2004 *dst_addr = wmem_new0(pinfo->pool, usb_address_t)((usb_address_t*)wmem_alloc0((pinfo->pool), sizeof(usb_address_t
)))
;
2005 address src, dst;
2006 conversation_t *conversation;
2007 usb_conv_info_t *usb_conv_info = NULL((void*)0);
2008
2009 src_addr->bus_id = GUINT16_TO_LE(bus_id)((guint16) (bus_id));
2010 src_addr->device = GUINT16_TO_LE(device_address)((guint16) (device_address));
2011 src_addr->endpoint = GUINT32_TO_LE(endpoint)((guint32) (endpoint));
2012
2013 dst_addr->bus_id = GUINT16_TO_LE(bus_id)((guint16) (bus_id));
2014 dst_addr->device = 0xffffffff;
2015 dst_addr->endpoint = NO_ENDPOINT0xffffffff;
2016
2017 set_address(&src, usb_address_type, USB_ADDR_LEN(sizeof(usb_address_t)), (char *)src_addr);
2018 set_address(&dst, usb_address_type, USB_ADDR_LEN(sizeof(usb_address_t)), (char *)dst_addr);
2019
2020 conversation = find_conversation(pinfo->num, &src, &dst,
2021 conversation_pt_to_conversation_type(PT_USB),
2022 src_addr->endpoint, dst_addr->endpoint, 0);
2023 if (conversation) {
2024 usb_conv_info = (usb_conv_info_t *)conversation_get_proto_data(conversation, proto_usb);
2025 }
2026 return usb_conv_info;
2027}
2028
2029static const char* usb_conv_get_filter_type(conv_item_t* conv, conv_filter_type_e filter)
2030{
2031 if ((filter == CONV_FT_SRC_ADDRESS) && (conv->src_address.type == usb_address_type))
2032 return "usb.src";
2033
2034 if ((filter == CONV_FT_DST_ADDRESS) && (conv->dst_address.type == usb_address_type))
2035 return "usb.dst";
2036
2037 if ((filter == CONV_FT_ANY_ADDRESS) && (conv->src_address.type == usb_address_type))
2038 return "usb.addr";
2039
2040 return CONV_FILTER_INVALID"INVALID";
2041}
2042
2043static ct_dissector_info_t usb_ct_dissector_info = {&usb_conv_get_filter_type};
2044
2045static tap_packet_status
2046usb_conversation_packet(void *pct, packet_info *pinfo, epan_dissect_t *edt _U___attribute__((unused)), const void *vip _U___attribute__((unused)), tap_flags_t flags)
2047{
2048 conv_hash_t *hash = (conv_hash_t*) pct;
2049 hash->flags = flags;
2050
2051 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);
2052
2053 return TAP_PACKET_REDRAW;
2054}
2055
2056static const char* usb_endpoint_get_filter_type(endpoint_item_t* endpoint, conv_filter_type_e filter)
2057{
2058 if ((filter == CONV_FT_ANY_ADDRESS) && (endpoint->myaddress.type == usb_address_type))
2059 return "usb.addr";
2060
2061 return CONV_FILTER_INVALID"INVALID";
2062}
2063
2064static const char*
2065usb_col_filter_str(const address* addr _U___attribute__((unused)), bool_Bool is_src)
2066{
2067 return is_src ? "usb.src" : "usb.dst";
2068}
2069
2070static et_dissector_info_t usb_endpoint_dissector_info = {&usb_endpoint_get_filter_type};
2071
2072static tap_packet_status
2073usb_endpoint_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U___attribute__((unused)), const void *vip _U___attribute__((unused)), tap_flags_t flags)
2074{
2075 conv_hash_t *hash = (conv_hash_t*) pit;
2076 hash->flags = flags;
2077
2078 /* Take two "add" passes per packet, adding for each direction, ensures that all
2079 packets are counted properly (even if address is sending to itself)
2080 XXX - this could probably be done more efficiently inside endpoint_table */
2081 add_endpoint_table_data(hash, &pinfo->src, 0, true1, 1, pinfo->fd->pkt_len, &usb_endpoint_dissector_info, ENDPOINT_NONECONVERSATION_NONE);
2082 add_endpoint_table_data(hash, &pinfo->dst, 0, false0, 1, pinfo->fd->pkt_len, &usb_endpoint_dissector_info, ENDPOINT_NONECONVERSATION_NONE);
2083
2084 return TAP_PACKET_REDRAW;
2085}
2086
2087/* SETUP dissectors */
2088
2089
2090/*
2091 * These dissectors are used to dissect the setup part and the data
2092 * for URB_CONTROL_INPUT / CLEAR FEATURE
2093 */
2094
2095
2096/* 9.4.1 */
2097static int
2098dissect_usb_setup_clear_feature_request(packet_info *pinfo _U___attribute__((unused)), proto_tree *tree,
2099 tvbuff_t *tvb, int offset,
2100 urb_info_t *urb)
2101{
2102 uint8_t recip;
2103
2104 if (urb) {
2105 recip = USB_RECIPIENT(urb->usb_trans_info->setup.requesttype)((urb->usb_trans_info->setup.requesttype) & 0x1F);
2106
2107 /* feature selector, zero/interface/endpoint */
2108 switch (recip) {
2109 case RQT_SETUP_RECIPIENT_DEVICE0:
2110 proto_tree_add_item(tree, hf_usb_device_wFeatureSelector, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
2111 offset += 2;
2112 proto_tree_add_item(tree, hf_usb_index, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
2113 break;
2114
2115 case RQT_SETUP_RECIPIENT_INTERFACE1:
2116 proto_tree_add_item(tree, hf_usb_interface_wFeatureSelector, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
2117 offset += 2;
2118 proto_tree_add_item(tree, hf_usb_wInterface, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
2119 break;
2120
2121 case RQT_SETUP_RECIPIENT_ENDPOINT2:
2122 proto_tree_add_item(tree, hf_usb_endpoint_wFeatureSelector, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
2123 offset += 2;
2124 proto_tree_add_item(tree, hf_usb_wEndpoint, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
2125 break;
2126
2127 case RQT_SETUP_RECIPIENT_OTHER3:
2128 default:
2129 proto_tree_add_item(tree, hf_usb_value, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
2130 offset += 2;
2131 proto_tree_add_item(tree, hf_usb_index, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
2132 break;
2133 }
2134 } else {
2135 /* No conversation information, so recipient type is unknown */
2136 proto_tree_add_item(tree, hf_usb_value, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
2137 offset += 2;
2138 proto_tree_add_item(tree, hf_usb_index, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
2139 }
2140 offset += 2;
2141
2142 /* length */
2143 proto_tree_add_item(tree, hf_usb_length, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
2144 offset += 2;
2145
2146 return offset;
2147}
2148
2149static int
2150dissect_usb_setup_clear_feature_response(packet_info *pinfo _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)),
2151 tvbuff_t *tvb _U___attribute__((unused)), int offset,
2152 urb_info_t *urb _U___attribute__((unused)))
2153{
2154 return offset;
2155}
2156
2157
2158/*
2159 * These dissectors are used to dissect the setup part and the data
2160 * for URB_CONTROL_INPUT / GET CONFIGURATION
2161 */
2162
2163
2164/* 9.4.2 */
2165static int
2166dissect_usb_setup_get_configuration_response(packet_info *pinfo _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)),
2167 tvbuff_t *tvb _U___attribute__((unused)), int offset,
2168 urb_info_t *urb _U___attribute__((unused)))
2169{
2170 proto_tree_add_item(tree, hf_usb_bConfigurationValue, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2171 offset += 1;
2172
2173 return offset;
2174}
2175
2176
2177/*
2178 * These dissectors are used to dissect the setup part and the data
2179 * for URB_CONTROL_INPUT / GET DESCRIPTOR
2180 */
2181
2182proto_item * dissect_usb_descriptor_header(proto_tree *tree,
2183 tvbuff_t *tvb, int offset,
2184 value_string_ext *type_val_str)
2185{
2186 uint8_t desc_type;
2187 proto_item *length_item;
2188
2189
2190 length_item = proto_tree_add_item(tree, hf_usb_bLength,
2191 tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2192 offset++;
2193
2194 desc_type = tvb_get_uint8(tvb, offset);
2195 /* if the caller provided no class specific value string, we're
2196 * using the standard descriptor types */
2197 if (!type_val_str)
2198 type_val_str = &std_descriptor_type_vals_ext;
2199
2200 proto_tree_add_uint_format_value(tree, hf_usb_bDescriptorType,
2201 tvb, offset, 1, desc_type, "0x%02x (%s)", desc_type,
2202 val_to_str_ext_const(desc_type, type_val_str, "unknown"));
2203
2204 return length_item;
2205}
2206
2207static void
2208dissect_max_packet_size0(packet_info *pinfo, proto_tree *tree,
2209 tvbuff_t *tvb, int offset,
2210 urb_info_t *urb, bool_Bool other_speed)
2211{
2212 proto_item *item;
2213 uint32_t max_packet_size;
2214 unsigned int sanitized_max_packet_size;
2215 usb_speed_t speed = urb->speed;
2216
2217 item = proto_tree_add_item_ret_uint(tree, hf_usb_bMaxPacketSize0, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000, &max_packet_size);
2218 if (other_speed) {
2219 if (speed == USB_SPEED_FULL)
2220 speed = USB_SPEED_HIGH;
2221 else if (speed == USB_SPEED_HIGH)
2222 speed = USB_SPEED_FULL;
2223 }
2224 sanitized_max_packet_size = sanitize_usb_max_packet_size(ENDPOINT_TYPE_CONTROL0, speed, max_packet_size);
2225 if (sanitized_max_packet_size != max_packet_size) {
2226 expert_add_info_format(pinfo, item, &ei_usb_invalid_max_packet_size0,
2227 "%s endpoint zero max packet size cannot be %u, using %d instead.",
2228 try_val_to_str(speed, usb_speed_vals), max_packet_size, sanitized_max_packet_size);
2229 }
2230}
2231
2232/* 9.6.2 */
2233static int
2234dissect_usb_device_qualifier_descriptor(packet_info *pinfo, proto_tree *parent_tree,
2235 tvbuff_t *tvb, int offset,
2236 urb_info_t *urb)
2237{
2238 proto_item *item;
2239 proto_tree *tree;
2240 proto_item *nitem;
2241 int old_offset = offset;
2242 uint32_t protocol;
2243 const char *description;
2244
2245 tree = proto_tree_add_subtree(parent_tree, tvb, offset, -1, ett_descriptor_device, &item, "DEVICE QUALIFIER DESCRIPTOR");
2246
2247 dissect_usb_descriptor_header(tree, tvb, offset, NULL((void*)0));
2248 offset += 2;
2249
2250 /* bcdUSB */
2251 proto_tree_add_item(tree, hf_usb_bcdUSB, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
2252 offset += 2;
2253
2254 protocol = tvb_get_ntoh24(tvb, offset);
2255 description = val_to_str_ext_const(protocol, &usb_protocols_ext, "");
2256
2257 /* bDeviceClass */
2258 proto_tree_add_item(tree, hf_usb_bDeviceClass, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2259 offset += 1;
2260
2261 /* bDeviceSubClass */
2262 proto_tree_add_item(tree, hf_usb_bDeviceSubClass, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2263 offset += 1;
2264
2265 /* bDeviceProtocol */
2266 nitem = proto_tree_add_item(tree, hf_usb_bDeviceProtocol, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2267 if (*description)
2268 proto_item_append_text(nitem, " (%s)", description);
2269 offset += 1;
2270
2271 if (!pinfo->fd->visited) {
2272 unsigned k_bus_id;
2273 unsigned k_device_address;
2274 unsigned k_frame_number;
2275 wmem_tree_key_t key[4];
2276 device_protocol_data_t *device_protocol_data;
2277
2278 k_frame_number = pinfo->num;
2279 k_device_address = urb->device_address;
2280 k_bus_id = urb->bus_id;
2281
2282 key[0].length = 1;
2283 key[0].key = &k_device_address;
2284 key[1].length = 1;
2285 key[1].key = &k_bus_id;
2286 key[2].length = 1;
2287 key[2].key = &k_frame_number;
2288 key[3].length = 0;
2289 key[3].key = NULL((void*)0);
2290
2291 device_protocol_data = wmem_new(wmem_file_scope(), device_protocol_data_t)((device_protocol_data_t*)wmem_alloc((wmem_file_scope()), sizeof
(device_protocol_data_t)))
;
2292 device_protocol_data->protocol = protocol;
2293 device_protocol_data->bus_id = urb->bus_id;
2294 device_protocol_data->device_address = urb->device_address;
2295 wmem_tree_insert32_array(device_to_protocol_table, key, device_protocol_data);
2296 }
2297
2298 /* bMaxPacketSize0 */
2299 dissect_max_packet_size0(pinfo, tree, tvb, offset, urb, true1);
2300 offset += 1;
2301
2302 /* bNumConfigurations */
2303 proto_tree_add_item(tree, hf_usb_bNumConfigurations, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2304 offset += 1;
2305
2306 /* one reserved byte */
2307 offset += 1;
2308
2309 proto_item_set_len(item, offset-old_offset);
2310
2311 return offset;
2312}
2313
2314/* 9.6.1 */
2315static int
2316dissect_usb_device_descriptor(packet_info *pinfo, proto_tree *parent_tree,
2317 tvbuff_t *tvb, int offset,
2318 urb_info_t *urb)
2319{
2320 proto_item *item;
2321 proto_tree *tree;
2322 proto_item *nitem;
2323 int old_offset = offset;
2324 uint32_t protocol;
2325 const char *description;
2326 uint32_t vendor_id;
2327 uint32_t product;
2328 uint16_t product_id;
2329
2330 tree = proto_tree_add_subtree(parent_tree, tvb, offset, -1, ett_descriptor_device, &item, "DEVICE DESCRIPTOR");
2331
2332 dissect_usb_descriptor_header(tree, tvb, offset, NULL((void*)0));
2333 offset += 2;
2334
2335 /* bcdUSB */
2336 proto_tree_add_item(tree, hf_usb_bcdUSB, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
2337 offset += 2;
2338
2339 protocol = tvb_get_ntoh24(tvb, offset);
2340 description = val_to_str_ext_const(protocol, &usb_protocols_ext, "");
2341
2342 /* bDeviceClass */
2343 proto_tree_add_item(tree, hf_usb_bDeviceClass, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2344 offset += 1;
2345
2346 /* bDeviceSubClass */
2347 proto_tree_add_item(tree, hf_usb_bDeviceSubClass, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2348 offset += 1;
2349
2350 /* bDeviceProtocol */
2351 nitem = proto_tree_add_item(tree, hf_usb_bDeviceProtocol, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2352 if (*description)
2353 proto_item_append_text(nitem, " (%s)", description);
2354 offset += 1;
2355
2356 /* bMaxPacketSize0 */
2357 dissect_max_packet_size0(pinfo, tree, tvb, offset, urb, false0);
2358 offset += 1;
2359
2360 /* if request was only for the first 8 bytes */
2361 /* per 5.5.3 of USB2.0 Spec */
2362 if (8 == urb->usb_trans_info->setup.wLength) {
2363 proto_item_set_len(item, offset-old_offset);
2364 return offset;
2365 }
2366
2367 /* idVendor */
2368 proto_tree_add_item_ret_uint(tree, hf_usb_idVendor, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000, &vendor_id);
2369 urb->conv->deviceVendor = (uint16_t)vendor_id;
2370 offset += 2;
2371
2372 /* idProduct */
2373 product_id = tvb_get_letohs(tvb, offset);
2374 urb->conv->deviceProduct = product_id;
2375 product = (uint16_t)vendor_id << 16 | product_id;
2376
2377 proto_tree_add_uint_format_value(tree, hf_usb_idProduct, tvb, offset, 2, product_id, "%s (0x%04x)",
2378 val_to_str_ext_const(product, &ext_usb_products_vals, "Unknown"),
2379 product_id);
2380 offset += 2;
2381
2382 /* bcdDevice */
2383 urb->conv->deviceVersion = tvb_get_letohs(tvb, offset);
2384 proto_tree_add_item(tree, hf_usb_bcdDevice, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
2385 offset += 2;
2386
2387 if (!pinfo->fd->visited) {
2388 unsigned k_bus_id;
2389 unsigned k_device_address;
2390 unsigned k_frame_number;
2391 wmem_tree_key_t key[4];
2392 device_product_data_t *device_product_data;
2393 device_protocol_data_t *device_protocol_data;
2394
2395 k_frame_number = pinfo->num;
2396 k_device_address = urb->device_address;
2397 k_bus_id = urb->bus_id;
2398
2399 key[0].length = 1;
2400 key[0].key = &k_device_address;
2401 key[1].length = 1;
2402 key[1].key = &k_bus_id;
2403 key[2].length = 1;
2404 key[2].key = &k_frame_number;
2405 key[3].length = 0;
2406 key[3].key = NULL((void*)0);
2407
2408 device_product_data = wmem_new(wmem_file_scope(), device_product_data_t)((device_product_data_t*)wmem_alloc((wmem_file_scope()), sizeof
(device_product_data_t)))
;
2409 device_product_data->vendor = vendor_id;
2410 device_product_data->product = product_id;
2411 device_product_data->device = urb->conv->deviceVersion;
2412 device_product_data->bus_id = urb->bus_id;
2413 device_product_data->device_address = urb->device_address;
2414 wmem_tree_insert32_array(device_to_product_table, key, device_product_data);
2415
2416 device_protocol_data = wmem_new(wmem_file_scope(), device_protocol_data_t)((device_protocol_data_t*)wmem_alloc((wmem_file_scope()), sizeof
(device_protocol_data_t)))
;
2417 device_protocol_data->protocol = protocol;
2418 device_protocol_data->bus_id = urb->bus_id;
2419 device_protocol_data->device_address = urb->device_address;
2420
2421 wmem_tree_insert32_array(device_to_protocol_table, key, device_protocol_data);
2422 }
2423
2424 /* iManufacturer */
2425 proto_tree_add_item(tree, hf_usb_iManufacturer, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2426 offset += 1;
2427
2428 /* iProduct */
2429 proto_tree_add_item(tree, hf_usb_iProduct, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2430 offset += 1;
2431
2432 /* iSerialNumber */
2433 urb->conv->iSerialNumber = tvb_get_uint8(tvb, offset);
2434 proto_tree_add_item(tree, hf_usb_iSerialNumber, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2435 offset += 1;
2436
2437 /* bNumConfigurations */
2438 proto_tree_add_item(tree, hf_usb_bNumConfigurations, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2439 offset += 1;
2440
2441 proto_item_set_len(item, offset-old_offset);
2442
2443 return offset;
2444}
2445
2446/* 9.6.7 */
2447static int
2448dissect_usb_string_descriptor(packet_info *pinfo _U___attribute__((unused)), proto_tree *parent_tree,
2449 tvbuff_t *tvb, int offset,
2450 urb_info_t *urb)
2451{
2452 proto_item *item;
2453 proto_tree *tree;
2454 int old_offset = offset;
2455 uint8_t len;
2456 proto_item *len_item;
2457 usb_trans_info_t *usb_trans_info;
2458
2459 usb_trans_info = urb->usb_trans_info;
2460
2461 tree = proto_tree_add_subtree(parent_tree, tvb, offset, -1, ett_descriptor_device, &item, "STRING DESCRIPTOR");
2462
2463 len = tvb_get_uint8(tvb, offset);
2464 /* The USB spec says that the languages / the string are UTF16 and not
2465 0-terminated, i.e. the length field must contain an even number */
2466 if (len & 0x1) {
2467 /* bLength */
2468 len_item = proto_tree_add_item(tree, hf_usb_bLength, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2469 expert_add_info(pinfo, len_item, &ei_usb_bLength_even);
2470
2471 /* bDescriptorType */
2472 proto_tree_add_item(tree, hf_usb_bDescriptorType, tvb, offset+1, 1, ENC_LITTLE_ENDIAN0x80000000);
2473 }
2474 else
2475 len_item = dissect_usb_descriptor_header(tree, tvb, offset, NULL((void*)0));
2476 offset += 2;
2477
2478 /* Report an error, and give up, if the length is < 2 */
2479 if (len < 2) {
2480 expert_add_info(pinfo, len_item, &ei_usb_bLength_too_short);
2481 return offset;
2482 }
2483
2484 if (!usb_trans_info->u.get_descriptor.usb_index) {
2485 /* list of languages */
2486 while (offset >= old_offset && len > (offset - old_offset)) {
2487 /* wLANGID */
2488 proto_tree_add_item(tree, hf_usb_wLANGID, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
2489 offset+=2;
2490 }
2491 } else {
2492 /* UTF-16 string */
2493 /* handle case of host requesting only substring */
2494 uint8_t len_str = MIN(len-2, usb_trans_info->setup.wLength -2)(((len-2) < (usb_trans_info->setup.wLength -2)) ? (len-
2) : (usb_trans_info->setup.wLength -2))
;
2495 proto_tree_add_item(tree, hf_usb_bString, tvb, offset, len_str, ENC_UTF_160x00000004 | ENC_LITTLE_ENDIAN0x80000000);
2496 offset += len_str;
2497 }
2498
2499 proto_item_set_len(item, offset-old_offset);
2500
2501 return offset;
2502}
2503
2504
2505
2506/* 9.6.5 */
2507static int
2508dissect_usb_interface_descriptor(packet_info *pinfo, proto_tree *parent_tree,
2509 tvbuff_t *tvb, int offset,
2510 urb_info_t *urb)
2511{
2512 proto_item *item;
2513 proto_tree *tree;
2514 const char *class_str = NULL((void*)0);
2515 int old_offset = offset;
2516 uint8_t len;
2517 uint8_t interface_num;
2518 uint8_t alt_setting;
2519 usb_trans_info_t *usb_trans_info;
2520
2521 usb_trans_info = urb->usb_trans_info;
2522
2523 tree = proto_tree_add_subtree(parent_tree, tvb, offset, -1, ett_descriptor_device, &item, "INTERFACE DESCRIPTOR");
2524
2525 len = tvb_get_uint8(tvb, offset);
2526 dissect_usb_descriptor_header(tree, tvb, offset, NULL((void*)0));
2527 offset += 2;
2528
2529 /* bInterfaceNumber */
2530 interface_num = tvb_get_uint8(tvb, offset);
2531 proto_tree_add_item(tree, hf_usb_bInterfaceNumber, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2532 urb->conv->interfaceNum = interface_num;
2533 offset += 1;
2534
2535 /* bAlternateSetting */
2536 proto_tree_add_item_ret_uint8(tree, hf_usb_bAlternateSetting, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000, &alt_setting);
2537 offset += 1;
2538
2539 /* bNumEndpoints */
2540 proto_tree_add_item(tree, hf_usb_bNumEndpoints, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2541 offset += 1;
2542
2543 /* bInterfaceClass */
2544 proto_tree_add_item(tree, hf_usb_bInterfaceClass, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2545 /* save the class so we can access it later in the endpoint descriptor */
2546 urb->conv->interfaceClass = tvb_get_uint8(tvb, offset);
2547
2548 class_str = val_to_str_ext(pinfo->pool, urb->conv->interfaceClass, &usb_class_vals_ext, "unknown (0x%X)");
2549 proto_item_append_text(item, " (%u.%u): class %s", interface_num, alt_setting, class_str);
2550
2551 if (!pinfo->fd->visited) {
2552 usb_alt_setting_t alternate_setting;
2553
2554 /* Register conversation for this interface in case CONTROL messages are sent to it */
2555 usb_trans_info->interface_info = get_usb_iface_conv_info(pinfo, interface_num);
2556 usb_trans_info->interface_info->config_desc_frame_num = pinfo->num;
2557
2558 alternate_setting.altSetting = alt_setting;
2559 alternate_setting.interfaceClass = tvb_get_uint8(tvb, offset);
2560 alternate_setting.interfaceSubclass = tvb_get_uint8(tvb, offset+1);
2561 alternate_setting.interfaceProtocol = tvb_get_uint8(tvb, offset+2);
2562 alternate_setting.interfaceNum = interface_num;
2563 wmem_array_append_one(usb_trans_info->interface_info->alt_settings, alternate_setting)wmem_array_append((usb_trans_info->interface_info->alt_settings
), &(alternate_setting), 1)
;
2564
2565 if (alt_setting == 0) {
2566 /* By default let's assume alternate setting 0 will be used */
2567
2568 usb_trans_info->interface_info->interfaceClass = alternate_setting.interfaceClass;
2569 usb_trans_info->interface_info->interfaceSubclass = alternate_setting.interfaceSubclass;
2570 usb_trans_info->interface_info->interfaceProtocol = alternate_setting.interfaceProtocol;
2571 usb_trans_info->interface_info->interfaceNum = alternate_setting.interfaceNum;
2572 usb_trans_info->interface_info->deviceVendor = urb->conv->deviceVendor;
2573 usb_trans_info->interface_info->deviceProduct = urb->conv->deviceProduct;
2574 usb_trans_info->interface_info->deviceVersion = urb->conv->deviceVersion;
2575 }
2576 }
2577 offset += 1;
2578
2579 /* bInterfaceSubClass */
2580 switch (urb->conv->interfaceClass) {
2581 case IF_CLASS_AUDIO0x01:
2582 proto_tree_add_item(tree, hf_usb_bInterfaceSubClass_audio, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2583 break;
2584 case IF_CLASS_COMMUNICATIONS0x02:
2585 proto_tree_add_item(tree, hf_usb_bInterfaceSubClass_cdc, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2586 break;
2587 case IF_CLASS_MASS_STORAGE0x08:
2588 proto_tree_add_item(tree, hf_usb_bInterfaceSubClass_massstorage, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2589 break;
2590 case IF_CLASS_HID0x03:
2591 proto_tree_add_item(tree, hf_usb_bInterfaceSubClass_hid, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2592 break;
2593 case IF_CLASS_MISCELLANEOUS0xef:
2594 proto_tree_add_item(tree, hf_usb_bInterfaceSubClass_misc, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2595 break;
2596 case IF_CLASS_APPLICATION_SPECIFIC0xfe:
2597 proto_tree_add_item(tree, hf_usb_bInterfaceSubClass_app, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2598 break;
2599 default:
2600 proto_tree_add_item(tree, hf_usb_bInterfaceSubClass, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2601 }
2602
2603 /* save the subclass so we can access it later in class-specific descriptors */
2604 urb->conv->interfaceSubclass = tvb_get_uint8(tvb, offset);
2605 offset += 1;
2606
2607 /* bInterfaceProtocol */
2608 switch (urb->conv->interfaceClass) {
2609 case IF_CLASS_COMMUNICATIONS0x02:
2610 proto_tree_add_item(tree, hf_usb_bInterfaceProtocol_cdc, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2611 break;
2612 case IF_CLASS_MASS_STORAGE0x08:
2613 proto_tree_add_item(tree, hf_usb_bInterfaceProtocol_massstorage, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2614 break;
2615 case IF_CLASS_CDC_DATA0x0a:
2616 proto_tree_add_item(tree, hf_usb_bInterfaceProtocol_cdc_data, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2617 break;
2618 case IF_CLASS_APPLICATION_SPECIFIC0xfe:
2619 switch (urb->conv->interfaceSubclass) {
2620 case 0x01:
2621 proto_tree_add_item(tree, hf_usb_bInterfaceProtocol_app_dfu, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2622 break;
2623 case 0x02:
2624 proto_tree_add_item(tree, hf_usb_bInterfaceProtocol_app_irda, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2625 break;
2626 case 0x03:
2627 proto_tree_add_item(tree, hf_usb_bInterfaceProtocol_app_usb_test_and_measurement, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2628 break;
2629 default:
2630 proto_tree_add_item(tree, hf_usb_bInterfaceProtocol, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2631 }
2632 break;
2633 case IF_CLASS_HID0x03:
2634 if (urb->conv->interfaceSubclass == 1) {
2635 proto_tree_add_item(tree, hf_usb_bInterfaceProtocol_hid_boot, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2636 break;
2637 }
2638
2639 proto_tree_add_item(tree, hf_usb_bInterfaceProtocol, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2640
2641 break;
2642 default:
2643 proto_tree_add_item(tree, hf_usb_bInterfaceProtocol, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2644 }
2645
2646 urb->conv->interfaceProtocol = tvb_get_uint8(tvb, offset);
2647 offset += 1;
2648
2649 /* iInterface */
2650 proto_tree_add_item(tree, hf_usb_iInterface, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2651 offset += 1;
2652
2653 proto_item_set_len(item, len);
2654
2655 if (offset < old_offset+len) {
2656 /* skip unknown records */
2657 offset = old_offset + len;
2658 }
2659
2660 return offset;
2661}
2662
2663/* 9.6.6 */
2664const true_false_string tfs_endpoint_direction = {
2665 "IN Endpoint",
2666 "OUT Endpoint"
2667};
2668
2669void dissect_usb_endpoint_address(proto_tree *tree, tvbuff_t *tvb, int offset)
2670{
2671 proto_item *endpoint_item;
2672 proto_tree *endpoint_tree;
2673 uint8_t endpoint;
2674
2675 endpoint_item = proto_tree_add_item(tree, hf_usb_bEndpointAddress, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2676 endpoint_tree = proto_item_add_subtree(endpoint_item, ett_configuration_bEndpointAddress);
2677
2678 endpoint = tvb_get_uint8(tvb, offset);
2679 proto_tree_add_item(endpoint_tree, hf_usb_bEndpointAddress_direction, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2680 proto_item_append_text(endpoint_item, " %s", (endpoint&0x80)?"IN":"OUT");
2681 proto_tree_add_item(endpoint_tree, hf_usb_bEndpointAddress_number, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2682 proto_item_append_text(endpoint_item, " Endpoint:%d", endpoint&0x0f);
2683}
2684
2685unsigned int
2686sanitize_usb_max_packet_size(uint8_t ep_type, usb_speed_t speed,
2687 unsigned int max_packet_size)
2688{
2689 unsigned int sanitized_ep_size = USB_MPS_EP_SIZE(max_packet_size)((max_packet_size) & 0x07FF);
2690 unsigned int sanitized_adtnl = USB_MPS_ADDNL(max_packet_size)(((max_packet_size) & 0x1800) >> 11);
2691 switch (speed) {
2692 case USB_SPEED_LOW:
2693 sanitized_adtnl = 0;
2694 switch (ep_type) {
2695 case ENDPOINT_TYPE_CONTROL0:
2696 /* 8 is the only allowed value */
2697 sanitized_ep_size = 8;
2698 break;
2699 case ENDPOINT_TYPE_INTERRUPT3:
2700 if (max_packet_size > 8)
2701 sanitized_ep_size = 8;
2702 break;
2703 default:
2704 /* Not allowed */
2705 break;
2706 }
2707 break;
2708 case USB_SPEED_FULL:
2709 sanitized_adtnl = 0;
2710 switch (ep_type) {
2711 case ENDPOINT_TYPE_CONTROL0:
2712 case ENDPOINT_TYPE_BULK2:
2713 /* Allowed values are: 8, 16, 32 and 64 */
2714 if (max_packet_size > 32)
2715 sanitized_ep_size = 64;
2716 else if (max_packet_size > 16)
2717 sanitized_ep_size = 32;
2718 else if (max_packet_size > 8)
2719 sanitized_ep_size = 16;
2720 else
2721 sanitized_ep_size = 8;
2722 break;
2723 case ENDPOINT_TYPE_INTERRUPT3:
2724 if (max_packet_size > 64)
2725 sanitized_ep_size = 64;
2726 break;
2727 case ENDPOINT_TYPE_ISOCHRONOUS1:
2728 if (max_packet_size > 1023)
2729 sanitized_ep_size = 1023;
2730 break;
2731 default:
2732 break;
2733 }
2734 break;
2735 case USB_SPEED_HIGH:
2736 switch (ep_type) {
2737 case ENDPOINT_TYPE_CONTROL0:
2738 sanitized_adtnl = 0;
2739 /* 64 is the only allowed value */
2740 sanitized_ep_size = 64;
2741 break;
2742 case ENDPOINT_TYPE_BULK2:
2743 sanitized_adtnl = 0;
2744 /* 512 is the only allowed value */
2745 sanitized_ep_size = 512;
2746 break;
2747 case ENDPOINT_TYPE_INTERRUPT3:
2748 case ENDPOINT_TYPE_ISOCHRONOUS1:
2749 /* If endpoint max packet size is out of range for high-bandwidth
2750 * endpoint, treat the endpoint as a standard one.
2751 */
2752 if ((sanitized_adtnl > 2) ||
2753 ((sanitized_adtnl == 2) && (max_packet_size < 683)) ||
2754 ((sanitized_adtnl == 1) && (max_packet_size < 513)))
2755 sanitized_adtnl = 0;
2756 if (max_packet_size > 1024)
2757 sanitized_ep_size = 1024;
2758 break;
2759 default:
2760 break;
2761 }
2762 break;
2763 case USB_SPEED_UNKNOWN:
2764 default:
2765 break;
2766 }
2767
2768 return USB_MPS(sanitized_ep_size, sanitized_adtnl)(((sanitized_adtnl) << 11) | (sanitized_ep_size));
2769}
2770
2771static char *usb_max_packet_size_str(wmem_allocator_t* allocator, unsigned int max_packet_size)
2772{
2773 unsigned int ep_size = USB_MPS_EP_SIZE(max_packet_size)((max_packet_size) & 0x07FF);
2774 unsigned int addnl = USB_MPS_ADDNL(max_packet_size)(((max_packet_size) & 0x1800) >> 11);
2775
2776 if (addnl == 1 || addnl == 2) {
2777 return wmem_strdup_printf(allocator, "%u * %u = %u",
2778 addnl + 1, ep_size, (addnl + 1) * ep_size);
2779 } else {
2780 return wmem_strdup_printf(allocator, "%u", ep_size);
2781 }
2782}
2783
2784int
2785dissect_usb_endpoint_descriptor(packet_info *pinfo, proto_tree *parent_tree,
2786 tvbuff_t *tvb, int offset,
2787 urb_info_t *urb,
2788 uint8_t *out_ep_type, usb_speed_t speed)
2789{
2790 proto_item *item;
2791 proto_tree *tree;
2792 proto_item *ep_attrib_item;
2793 proto_tree *ep_attrib_tree;
2794 proto_item *ep_type_item;
2795 proto_item *ep_pktsize_item;
2796 proto_tree *ep_pktsize_tree;
2797 int old_offset = offset;
2798 uint8_t endpoint;
2799 uint8_t ep_type;
2800 uint8_t len;
2801 uint32_t max_packet_size;
2802 char *max_packet_size_str;
2803 unsigned int sanitized_max_packet_size;
2804 usb_trans_info_t *usb_trans_info = NULL((void*)0);
2805 conversation_t *conversation = NULL((void*)0);
2806
2807 if (urb)
2808 usb_trans_info = urb->usb_trans_info;
2809
2810 tree = proto_tree_add_subtree(parent_tree, tvb, offset, -1, ett_descriptor_device, &item, "ENDPOINT DESCRIPTOR");
2811
2812 len = tvb_get_uint8(tvb, offset);
2813 dissect_usb_descriptor_header(tree, tvb, offset, NULL((void*)0));
2814 offset += 2;
2815
2816 endpoint = tvb_get_uint8(tvb, offset);
2817 dissect_usb_endpoint_address(tree, tvb, offset);
2818 offset += 1;
2819
2820 /* Together with class from the interface descriptor we know what kind
2821 * of class the device at endpoint is.
2822 * Make sure a conversation exists for this endpoint and attach a
2823 * usb_conv_into_t structure to it.
2824 *
2825 * All endpoints for the same interface descriptor share the same
2826 * usb_conv_info structure.
2827 */
2828 if ((!pinfo->fd->visited) && usb_trans_info && usb_trans_info->interface_info) {
2829 if (pinfo->destport == NO_ENDPOINT0xffffffff) {
2830 address tmp_addr;
2831 usb_address_t *usb_addr = wmem_new0(pinfo->pool, usb_address_t)((usb_address_t*)wmem_alloc0((pinfo->pool), sizeof(usb_address_t
)))
;
2832
2833 /* packet is sent from a USB device's endpoint 0 to the host
2834 * replace endpoint 0 with the endpoint of this descriptor
2835 * and find the corresponding conversation
2836 */
2837 usb_addr->bus_id = ((const usb_address_t *)(pinfo->src.data))->bus_id;
2838 usb_addr->device = ((const usb_address_t *)(pinfo->src.data))->device;
2839 usb_addr->endpoint = GUINT32_TO_LE(endpoint)((guint32) (endpoint));
2840 set_address(&tmp_addr, usb_address_type, USB_ADDR_LEN(sizeof(usb_address_t)), (char *)usb_addr);
2841 conversation = get_usb_conversation(pinfo, &tmp_addr, &pinfo->dst, usb_addr->endpoint, pinfo->destport);
2842 }
2843
2844 if (conversation) {
2845 usb_trans_info->interface_endpoint = endpoint;
2846 conversation_add_proto_data(conversation, proto_usb, usb_trans_info->interface_info);
2847 }
2848 }
2849
2850 /* bmAttributes */
2851 ep_type = ENDPOINT_TYPE(tvb_get_uint8(tvb, offset))((tvb_get_uint8(tvb, offset)) & 0x03);
2852 if (out_ep_type) {
2853 *out_ep_type = ep_type;
2854 }
2855
2856 ep_attrib_item = proto_tree_add_item(tree, hf_usb_bmAttributes, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2857 ep_attrib_tree = proto_item_add_subtree(ep_attrib_item, ett_endpoint_bmAttributes);
2858
2859 ep_type_item = proto_tree_add_item(ep_attrib_tree, hf_usb_bEndpointAttributeTransfer, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2860 if (ep_type==USB_EP_ISOCHRONOUS0x01) {
2861 proto_tree_add_item(ep_attrib_tree, hf_usb_bEndpointAttributeSynchonisation, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2862 proto_tree_add_item(ep_attrib_tree, hf_usb_bEndpointAttributeBehaviour, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2863 }
2864
2865 /* At Low-Speed, only control and interrupt transfers are allowed */
2866 if ((speed == USB_SPEED_LOW) && !((ep_type == USB_EP_CONTROL0x00) || (ep_type == USB_EP_INTERRUPT0x03))) {
2867 expert_add_info(pinfo, ep_type_item, &ei_usb_invalid_endpoint_type);
2868 }
2869 offset += 1;
2870
2871 /* wMaxPacketSize */
2872 max_packet_size = tvb_get_uint16(tvb, offset, ENC_LITTLE_ENDIAN0x80000000);
2873 max_packet_size_str = usb_max_packet_size_str(pinfo->pool, max_packet_size);
2874 ep_pktsize_item = proto_tree_add_uint_format_value(tree, hf_usb_wMaxPacketSize,
2875 tvb, offset, 2, max_packet_size, "%s", max_packet_size_str);
2876 ep_pktsize_tree = proto_item_add_subtree(ep_pktsize_item, ett_endpoint_wMaxPacketSize);
2877 if ((ep_type == ENDPOINT_TYPE_INTERRUPT3) || (ep_type == ENDPOINT_TYPE_ISOCHRONOUS1)) {
2878 proto_tree_add_item(ep_pktsize_tree, hf_usb_wMaxPacketSize_slots, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
2879 }
2880 proto_tree_add_item(ep_pktsize_tree, hf_usb_wMaxPacketSize_size, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
2881 sanitized_max_packet_size = sanitize_usb_max_packet_size(ep_type, speed, max_packet_size);
2882 if (sanitized_max_packet_size != max_packet_size) {
2883 expert_add_info_format(pinfo, ep_pktsize_item, &ei_usb_invalid_max_packet_size,
2884 "%s %s endpoint max packet size cannot be %s, using %s instead.",
2885 try_val_to_str(speed, usb_speed_vals), try_val_to_str(ep_type, usb_bmAttributes_transfer_vals),
2886 max_packet_size_str, usb_max_packet_size_str(pinfo->pool, sanitized_max_packet_size));
2887 max_packet_size = sanitized_max_packet_size;
2888 }
2889 offset+=2;
2890
2891 if (conversation) {
2892 usb_conv_info_t* endpoint_conv_info = get_usb_conv_info(conversation);
2893 uint8_t transfer_type;
2894
2895 switch(ep_type) {
2896 case ENDPOINT_TYPE_CONTROL0:
2897 transfer_type = URB_CONTROL0x2;
2898 break;
2899 case ENDPOINT_TYPE_ISOCHRONOUS1:
2900 transfer_type = URB_ISOCHRONOUS0x0;
2901 break;
2902 case ENDPOINT_TYPE_BULK2:
2903 transfer_type = URB_BULK0x3;
2904 break;
2905 case ENDPOINT_TYPE_INTERRUPT3:
2906 transfer_type = URB_INTERRUPT0x1;
2907 break;
2908 default:
2909 transfer_type = URB_UNKNOWN0xFF;
2910 break;
2911 }
2912 endpoint_conv_info->descriptor_transfer_type = transfer_type;
2913 endpoint_conv_info->max_packet_size = max_packet_size;
2914 }
2915
2916 /* bInterval */
2917 proto_tree_add_item(tree, hf_usb_bInterval, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2918 offset += 1;
2919
2920 /* bRefresh and bSynchAddress are present only in the Audio 1.0
2921 * Endpoint Descriptors, so observe the descriptor size */
2922 if (urb && urb->conv && (urb->conv->interfaceClass == IF_CLASS_AUDIO0x01)
2923 && (len >= 9)) {
2924 proto_tree_add_item(tree, hf_usb_audio_bRefresh, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2925 offset += 1;
2926
2927 proto_tree_add_item(tree, hf_usb_audio_bSynchAddress, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2928 offset += 1;
2929 }
2930
2931 proto_item_set_len(item, len);
2932
2933 if (offset < old_offset+len) {
2934 /* mark unknown records as undecoded */
2935 proto_tree_add_expert(tree, pinfo, &ei_usb_undecoded, tvb, offset, old_offset + len - offset);
2936 offset = old_offset + len;
2937 }
2938
2939 return offset;
2940}
2941
2942static int
2943dissect_usb_endpoint_companion_descriptor(packet_info *pinfo, proto_tree *parent_tree,
2944 tvbuff_t *tvb, int offset,
2945 urb_info_t *urb _U___attribute__((unused)),
2946 uint8_t ep_type)
2947{
2948 proto_item *item;
2949 proto_tree *tree;
2950 proto_item *ep_attrib_item;
2951 proto_tree *ep_attrib_tree;
2952 int old_offset = offset;
2953 uint8_t len;
2954
2955 tree = proto_tree_add_subtree(parent_tree, tvb, offset, -1, ett_descriptor_device, &item, "SUPERSPEED ENDPOINT COMPANION DESCRIPTOR");
2956
2957 len = tvb_get_uint8(tvb, offset);
2958 dissect_usb_descriptor_header(tree, tvb, offset, NULL((void*)0));
2959 offset += 2;
2960
2961 /* bMaxBurst */
2962 proto_tree_add_item(tree, hf_usb_bMaxBurst, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2963 offset += 1;
2964
2965 /* bmAttributes */
2966 ep_attrib_item = proto_tree_add_item(tree, hf_usb_bmAttributes, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2967 switch (ep_type) {
2968 case ENDPOINT_TYPE_CONTROL0:
2969 break;
2970 case ENDPOINT_TYPE_ISOCHRONOUS1:
2971 ep_attrib_tree = proto_item_add_subtree(ep_attrib_item, ett_endpoint_bmAttributes);
2972 proto_tree_add_item(ep_attrib_tree, hf_usb_bSSEndpointAttributeIsoMult, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2973 break;
2974 case ENDPOINT_TYPE_BULK2:
2975 ep_attrib_tree = proto_item_add_subtree(ep_attrib_item, ett_endpoint_bmAttributes);
2976 proto_tree_add_item(ep_attrib_tree, hf_usb_bSSEndpointAttributeBulkMaxStreams, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
2977 break;
2978 case ENDPOINT_TYPE_INTERRUPT3:
2979 break;
2980 default:
2981 expert_add_info(pinfo, ep_attrib_item, &ei_usb_ss_ep_companion_before_ep);
2982 break;
2983 }
2984 offset += 1;
2985
2986 /* wBytesPerInterval */
2987 proto_tree_add_item(tree, hf_usb_wBytesPerInterval, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
2988 offset += 2;
2989
2990 proto_item_set_len(item, len);
2991
2992 if (offset < old_offset + len) {
2993 /* mark unknown records as undecoded */
2994 proto_tree_add_expert(tree, pinfo, &ei_usb_undecoded, tvb, offset, old_offset + len - offset);
2995 offset = old_offset + len;
2996 }
2997
2998 return offset;
2999}
3000
3001/* ECN */
3002static int
3003dissect_usb_interface_assn_descriptor(packet_info *pinfo _U___attribute__((unused)), proto_tree *parent_tree,
3004 tvbuff_t *tvb, int offset,
3005 urb_info_t *urb _U___attribute__((unused)))
3006{
3007 proto_item *item;
3008 proto_tree *tree;
3009 int old_offset = offset;
3010
3011 tree = proto_tree_add_subtree(parent_tree, tvb, offset, -1, ett_descriptor_device, &item, "INTERFACE ASSOCIATION DESCRIPTOR");
3012
3013 dissect_usb_descriptor_header(tree, tvb, offset, NULL((void*)0));
3014 offset += 2;
3015
3016 /* bFirstInterface */
3017 proto_tree_add_item(tree, hf_usb_bFirstInterface, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
3018 offset += 1;
3019
3020 /* bInterfaceCount */
3021 proto_tree_add_item(tree, hf_usb_bInterfaceCount, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
3022 offset += 1;
3023
3024 /* bFunctionClass */
3025 proto_tree_add_item(tree, hf_usb_bFunctionClass, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
3026 offset += 1;
3027
3028 /* bFunctionSubclass */
3029 proto_tree_add_item(tree, hf_usb_bFunctionSubClass, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
3030 offset += 1;
3031
3032 /* bFunctionProtocol */
3033 proto_tree_add_item(tree, hf_usb_bFunctionProtocol, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
3034 offset += 1;
3035
3036 /* iFunction */
3037 proto_tree_add_item(tree, hf_usb_iFunction, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
3038 offset += 1;
3039
3040 proto_item_set_len(item, offset-old_offset);
3041
3042 return offset;
3043}
3044
3045int
3046dissect_usb_unknown_descriptor(packet_info *pinfo _U___attribute__((unused)), proto_tree *parent_tree,
3047 tvbuff_t *tvb, int offset,
3048 urb_info_t *urb _U___attribute__((unused)))
3049{
3050 proto_item *item;
3051 proto_tree *tree;
3052 uint8_t bLength;
3053
3054 tree = proto_tree_add_subtree(parent_tree, tvb, offset, -1, ett_descriptor_device, &item, "UNKNOWN DESCRIPTOR");
3055
3056 bLength = tvb_get_uint8(tvb, offset);
3057 dissect_usb_descriptor_header(tree, tvb, offset, NULL((void*)0));
3058 offset += bLength;
3059
3060 proto_item_set_len(item, bLength);
3061
3062 return offset;
3063}
3064
3065/* 9.6.3 */
3066static const true_false_string tfs_mustbeone = {
3067 "Must be 1 for USB 1.1 and higher",
3068 "FIXME: Is this a USB 1.0 device"
3069};
3070static const true_false_string tfs_selfpowered = {
3071 "This device is SELF-POWERED",
3072 "This device is powered from the USB bus"
3073};
3074static const true_false_string tfs_remotewakeup = {
3075 "This device supports REMOTE WAKEUP",
3076 "This device does NOT support remote wakeup"
3077};
3078static int
3079dissect_usb_configuration_descriptor(packet_info *pinfo _U___attribute__((unused)), proto_tree *parent_tree,
3080 tvbuff_t *tvb, int offset,
3081 urb_info_t *urb, usb_speed_t speed)
3082{
3083 proto_item *item;
3084 proto_tree *tree;
3085 int old_offset = offset;
3086 uint16_t len;
3087 proto_item *flags_item;
3088 proto_tree *flags_tree;
3089 uint8_t flags;
3090 uint8_t last_ep_type = ENDPOINT_TYPE_NOT_SET255;
3091 proto_item *power_item;
3092 uint8_t power;
3093 bool_Bool truncation_expected;
3094 usb_trans_info_t *usb_trans_info;
3095
3096 usb_trans_info = urb->usb_trans_info;
3097
3098 urb->conv->interfaceClass = IF_CLASS_UNKNOWN0xffff;
3099 urb->conv->interfaceSubclass = IF_SUBCLASS_UNKNOWN0xffff;
3100 urb->conv->interfaceProtocol = IF_PROTOCOL_UNKNOWN0xffff;
3101
3102 tree = proto_tree_add_subtree(parent_tree, tvb, offset, -1, ett_descriptor_device, &item, "CONFIGURATION DESCRIPTOR");
3103
3104 dissect_usb_descriptor_header(tree, tvb, offset, NULL((void*)0));
3105 offset += 2;
3106
3107 /* wTotalLength */
3108 proto_tree_add_item_ret_uint16(tree, hf_usb_wTotalLength, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000, &len);
3109 offset+=2;
3110
3111 /* bNumInterfaces */
3112 proto_tree_add_item(tree, hf_usb_bNumInterfaces, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
3113 offset += 1;
3114
3115 /* bConfigurationValue */
3116 proto_tree_add_item(tree, hf_usb_bConfigurationValue, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
3117 offset += 1;
3118
3119 /* iConfiguration */
3120 proto_tree_add_item(tree, hf_usb_iConfiguration, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
3121 offset += 1;
3122
3123 /* bmAttributes */
3124 flags_item = proto_tree_add_item(tree, hf_usb_configuration_bmAttributes, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
3125 flags_tree = proto_item_add_subtree(flags_item, ett_configuration_bmAttributes);
3126
3127 flags = tvb_get_uint8(tvb, offset);
3128 proto_tree_add_item(flags_tree, hf_usb_configuration_legacy10buspowered, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
3129 proto_tree_add_item(flags_tree, hf_usb_configuration_selfpowered, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
3130 proto_item_append_text(flags_item, " %sSELF-POWERED", (flags&0x40)?"":"NOT ");
3131 proto_tree_add_item(flags_tree, hf_usb_configuration_remotewakeup, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
3132 proto_item_append_text(flags_item, " %sREMOTE-WAKEUP", (flags&0x20)?"":"NO ");
3133 offset += 1;
3134
3135 /* bMaxPower */
3136 power_item = proto_tree_add_item(tree, hf_usb_bMaxPower, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
3137 power = tvb_get_uint8(tvb, offset);
3138 proto_item_append_text(power_item, " (%dmA)", power*2);
3139 offset += 1;
3140
3141 /* initialize interface_info to NULL */
3142 usb_trans_info->interface_info = NULL((void*)0);
3143
3144 truncation_expected = (usb_trans_info->setup.wLength < len);
3145
3146 /* decode any additional interface and endpoint descriptors */
3147 while(len>(offset-old_offset)) {
3148 uint8_t next_type;
3149 uint8_t next_len = 0;
3150 int remaining_tvb, remaining_len;
3151 tvbuff_t *next_tvb = NULL((void*)0);
3152
3153 /* Handle truncated descriptors appropriately */
3154 remaining_tvb = tvb_reported_length_remaining(tvb, offset);
3155 if (remaining_tvb > 0) {
3156 next_len = tvb_get_uint8(tvb, offset);
3157 remaining_len = len - (offset - old_offset);
3158 if ((next_len < 3) || (next_len > remaining_len)) {
3159 proto_tree_add_expert_format(parent_tree, pinfo, &ei_usb_desc_length_invalid,
3160 tvb, offset, 1, "Invalid descriptor length: %u", next_len);
3161 item = NULL((void*)0);
3162 break;
3163 }
3164 }
3165
3166 if ((remaining_tvb == 0) || (next_len > remaining_tvb)) {
3167 if (truncation_expected)
3168 break;
3169 }
3170
3171 next_type = tvb_get_uint8(tvb, offset+1);
3172 switch(next_type) {
3173 case USB_DT_INTERFACE4:
3174 offset = dissect_usb_interface_descriptor(pinfo, parent_tree, tvb, offset, urb);
3175 break;
3176 case USB_DT_ENDPOINT5:
3177 offset = dissect_usb_endpoint_descriptor(pinfo, parent_tree, tvb, offset, urb, &last_ep_type, speed);
3178 break;
3179 case USB_DT_INTERFACE_ASSOCIATION11:
3180 offset = dissect_usb_interface_assn_descriptor(pinfo, parent_tree, tvb, offset, urb);
3181 break;
3182 case USB_DT_SUPERSPEED_EP_COMPANION0x30:
3183 offset = dissect_usb_endpoint_companion_descriptor(pinfo, parent_tree, tvb, offset, urb, last_ep_type);
3184 break;
3185 default:
3186 next_tvb = tvb_new_subset_length(tvb, offset, next_len);
3187 if (dissector_try_uint_with_data(usb_descriptor_dissector_table, urb->conv->interfaceClass, next_tvb, pinfo, parent_tree, true1, urb)) {
3188 offset += next_len;
3189 } else {
3190 offset = dissect_usb_unknown_descriptor(pinfo, parent_tree, tvb, offset, urb);
3191 }
3192 break;
3193 /* was: return offset; */
3194 }
3195 }
3196
3197 proto_item_set_len(item, offset-old_offset);
3198
3199 return offset;
3200}
3201
3202/* https://wicg.github.io/webusb/#webusb-platform-capability-descriptor */
3203static int
3204dissect_webusb_platform_descriptor(packet_info *pinfo _U___attribute__((unused)), proto_tree *tree,
3205 tvbuff_t *tvb, int offset,
3206 urb_info_t *urb _U___attribute__((unused)))
3207{
3208 proto_tree_add_item(tree, hf_usb_webusb_bcdVersion, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
3209 offset += 2;
3210
3211 proto_tree_add_item(tree, hf_usb_webusb_bVendorCode, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
3212 offset += 1;
3213
3214 proto_tree_add_item(tree, hf_usb_webusb_iLandingPage, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
3215 offset += 1;
3216
3217 return offset;
3218}
3219
3220/* Microsoft OS 2.0 Descriptors Specification */
3221static int
3222dissect_msos20_platform_descriptor(packet_info *pinfo _U___attribute__((unused)), proto_tree *tree,
3223 tvbuff_t *tvb, int offset,
3224 urb_info_t *urb _U___attribute__((unused)))
3225{
3226 proto_tree_add_item(tree, hf_usb_msos20_dwWindowsVersion, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
3227 offset += 4;
3228
3229 proto_tree_add_item(tree, hf_usb_msos20_wMSOSDescriptorSetTotalLength, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
3230 offset += 2;
3231
3232 proto_tree_add_item(tree, hf_usb_msos20_bMS_VendorCode, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
3233 offset += 1;
3234
3235 proto_tree_add_item(tree, hf_usb_msos20_bAltEnumCode, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
3236 offset += 1;
3237
3238 return offset;
3239}
3240
3241static struct {
3242 e_guid_t uuid;
3243 const char *text;
3244 int (*dissect)(packet_info *pinfo, proto_tree *tree,
3245 tvbuff_t *tvb, int offset,
3246 urb_info_t *urb);
3247} bos_platform_uuids[] = {
3248 { {0x3408b638, 0x09a9, 0x47a0, {0x8b, 0xfd, 0xa0, 0x76, 0x88, 0x15, 0xb6, 0x65}},
3249 "WebUSB Platform Capability descriptor",
3250 dissect_webusb_platform_descriptor },
3251
3252 { {0xd8dd60df, 0x4589, 0x4cc7, {0x9c, 0xd2, 0x65, 0x9d, 0x9e, 0x64, 0x8a, 0x9f}},
3253 "Microsoft OS 2.0 Platform Capability descriptor",
3254 dissect_msos20_platform_descriptor },
3255};
3256
3257/* USB 3.2 Specification Table 9-13. Format of a Device Capability Descriptor */
3258static int
3259dissect_usb_device_capability_descriptor(packet_info *pinfo, proto_tree *tree,
3260 tvbuff_t *tvb, int offset,
3261 urb_info_t *urb)
3262{
3263 uint8_t cap_type;
3264 const char *cap_text;
3265 e_guid_t uuid;
3266 unsigned int i;
3267
3268 proto_tree_add_item(tree, hf_usb_bDevCapabilityType, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
3269 cap_type = tvb_get_uint8(tvb, offset);
3270 offset += 1;
3271
3272 cap_text = try_val_to_str_ext(cap_type, &usb_capability_vals_ext);
3273
3274 if (cap_type == BOS_CAP_USB_20_EXTENSION0x02) {
3275 /* USB 2.0 ECN Errata for Link Power Management */
3276 static int * const usb20ext_fields[] = {
3277 &hf_usb_usb20ext_LPM,
3278 &hf_usb_usb20ext_BESL_HIRD,
3279 &hf_usb_usb20ext_baseline_BESL_valid,
3280 &hf_usb_usb20ext_deep_BESL_valid,
3281 &hf_usb_usb20ext_baseline_BESL,
3282 &hf_usb_usb20ext_deep_BESL,
3283 NULL((void*)0)
3284 };
3285
3286 proto_tree_add_bitmask_with_flags(tree, tvb, offset, hf_usb_usb20ext_bmAttributes,
3287 ett_usb20ext_bmAttributes, usb20ext_fields, ENC_LITTLE_ENDIAN0x80000000, BMT_NO_APPEND0x01);
3288 offset += 4;
3289 } else if (cap_type == BOS_CAP_PLATFORM0x05) {
3290 proto_tree_add_item(tree, hf_usb_bReserved, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
3291 offset += 1;
3292
3293 tvb_get_letohguid(tvb, offset, &uuid);
3294 proto_tree_add_guid(tree, hf_usb_PlatformCapabilityUUID, tvb, offset, 16, &uuid);
3295 offset += 16;
3296
3297 for (i = 0; i < array_length(bos_platform_uuids)(sizeof (bos_platform_uuids) / sizeof (bos_platform_uuids)[0]
)
; i++) {
3298 if (guid_cmp(&bos_platform_uuids[i].uuid, &uuid) == 0) {
3299 offset = bos_platform_uuids[i].dissect(pinfo, tree, tvb, offset, urb);
3300 cap_text = bos_platform_uuids[i].text;
3301 break;
3302 }
3303 }
3304 } else if (cap_type == BOS_CAP_SUPERSPEED_USB0x03) {
3305 /* USB 3.2 Specification 9.6.2.2 SuperSpeed USB Device Capability */
3306 static int * const usb_ss_bmAttributes_fields[] = {
3307 &hf_usb_ss_bmAttributes_reserved0,
3308 &hf_usb_ss_bmAttributes_LTM,
3309 &hf_usb_ss_bmAttributes_reserved7_2,
3310 NULL((void*)0)
3311 };
3312 static int * const usb_ss_wSpeedSupported_fields[] = {
3313 &hf_usb_ss_wSpeedSupported_LS,
3314 &hf_usb_ss_wSpeedSupported_FS,
3315 &hf_usb_ss_wSpeedSupported_HS,
3316 &hf_usb_ss_wSpeedSupported_Gen1,
3317 &hf_usb_ss_wSpeedSupported_reserved,
3318 NULL((void*)0)
3319 };
3320
3321 proto_tree_add_bitmask(tree, tvb, offset, hf_usb_ss_bmAttributes,
3322 ett_ss_bmAttributes, usb_ss_bmAttributes_fields, ENC_LITTLE_ENDIAN0x80000000);
3323 offset += 1;
3324 proto_tree_add_bitmask(tree, tvb, offset, hf_usb_ss_wSpeedSupported,
3325 ett_ss_wSpeedSupported, usb_ss_wSpeedSupported_fields, ENC_LITTLE_ENDIAN0x80000000);
3326 offset += 2;
3327 proto_tree_add_item(tree, hf_usb_ss_bFunctionalitySupport, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
3328 offset += 1;
3329 proto_tree_add_item(tree, hf_usb_ss_bU1DevExitLat, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
3330 offset += 1;
3331 proto_tree_add_item(tree, hf_usb_ss_wU2DevExitLat, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
3332 offset += 2;
3333 }
3334
3335 if (cap_text) {
3336 proto_item_append_text(tree, ": %s", cap_text);
3337 }
3338
3339 return offset;
3340}
3341
3342/* USB 3.2 Specification 9.6.2 Binary Device Object Store (BOS) */
3343static int
3344dissect_usb_bos_descriptor(packet_info *pinfo, proto_tree *parent_tree,
3345 tvbuff_t *tvb, int offset,
3346 urb_info_t *urb)
3347{
3348 proto_item *item;
3349 proto_tree *tree;
3350 int old_offset = offset;
3351 uint16_t total_len;
3352 usb_trans_info_t *usb_trans_info;
3353
3354 usb_trans_info = urb->usb_trans_info;
3355
3356 tree = proto_tree_add_subtree(parent_tree, tvb, offset, -1, ett_descriptor_device, &item, "BOS DESCRIPTOR");
3357
3358 dissect_usb_descriptor_header(tree, tvb, offset, NULL((void*)0));
3359 offset += 2;
3360
3361 /* wTotalLength */
3362 proto_tree_add_item_ret_uint16(tree, hf_usb_wTotalLength, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000, &total_len);
3363 offset += 2;
3364
3365 proto_tree_add_item(tree, hf_usb_bNumDeviceCaps, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
3366 offset += 1;
3367
3368 if (offset - old_offset >= usb_trans_info->setup.wLength) {
3369 /* Do not report the most common case where host finds out about
3370 * wTotalLength by requesting just BOS descriptor as Malformed Packet.
3371 * TODO: Generic handling of "host requested too few bytes" (which is
3372 * perfectly fine, but complicates dissection) because host is allowed
3373 * to request any number of bytes.
3374 */
3375 return offset;
3376 }
3377
3378 /* Dissect capabilities */
3379 while (total_len > (offset - old_offset)) {
3380 proto_item *desc_item;
3381 int prev_offset = offset;
3382 uint8_t desc_len, desc_type;
3383
3384 tree = proto_tree_add_subtree(parent_tree, tvb, offset, -1, ett_descriptor_device, &desc_item, "DEVICE CAPABILITY DESCRIPTOR");
3385
3386 item = proto_tree_add_item(tree, hf_usb_bLength, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
3387 desc_len = tvb_get_uint8(tvb, offset);
3388 offset += 1;
3389 if (desc_len < 3) {
3390 expert_add_info_format(pinfo, item, &ei_usb_bLength_too_short, "Invalid Length (must be 3 or larger)");
3391 break;
3392 }
3393
3394 item = proto_tree_add_item(tree, hf_usb_bDescriptorType, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
3395 desc_type = tvb_get_uint8(tvb, offset);
3396 offset += 1;
3397 if (desc_type == USB_DT_DEVICE_CAPABILITY0x10) {
3398 tvbuff_t *desc_tvb = tvb_new_subset_length(tvb, offset, desc_len - 2);
3399 offset += dissect_usb_device_capability_descriptor(pinfo, tree, desc_tvb, 0, urb);
3400 } else {
3401 expert_add_info(pinfo, item, &ei_usb_unexpected_desc_type);
3402 /* Already reported unexpected type, do not mark rest as undecoded */
3403 offset = prev_offset + desc_len;
3404 }
3405
3406 if (offset < prev_offset + desc_len) {
3407 proto_tree_add_expert(tree, pinfo, &ei_usb_undecoded, tvb, offset, prev_offset + desc_len - offset);
3408 offset = prev_offset + desc_len;
3409 }
3410 proto_item_set_len(item, offset - prev_offset);
3411 }
3412
3413 proto_item_set_len(item, offset - old_offset);
3414
3415 return offset;
3416}
3417
3418/* 9.4.3 */
3419static int
3420dissect_usb_setup_get_descriptor_request(packet_info *pinfo, proto_tree *tree,
3421 tvbuff_t *tvb, int offset,
3422 urb_info_t *urb)
3423{
3424 usb_trans_info_t *usb_trans_info, trans_info;
3425
3426 if (urb)
3427 usb_trans_info = urb->usb_trans_info;
3428 else
3429 usb_trans_info = &trans_info;
3430
3431 /* descriptor index */
3432 proto_tree_add_item(tree, hf_usb_descriptor_index, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
3433 usb_trans_info->u.get_descriptor.usb_index = tvb_get_uint8(tvb, offset);
3434 offset += 1;
3435
3436 /* descriptor type */
3437 proto_tree_add_item(tree, hf_usb_bDescriptorType, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
3438 usb_trans_info->u.get_descriptor.type = tvb_get_uint8(tvb, offset);
3439 offset += 1;
3440 col_append_fstr(pinfo->cinfo, COL_INFO, " %s",
3441 val_to_str_ext(pinfo->pool, usb_trans_info->u.get_descriptor.type, &std_descriptor_type_vals_ext, "Unknown type %u"));
3442
3443 /* language id */
3444 proto_tree_add_item(tree, hf_usb_language_id, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
3445 offset+=2;
3446
3447 /* length */
3448 proto_tree_add_item(tree, hf_usb_length, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
3449 offset += 2;
3450
3451 return offset;
3452}
3453
3454static int
3455dissect_usb_setup_get_descriptor_response(packet_info *pinfo, proto_tree *tree,
3456 tvbuff_t *tvb, int offset,
3457 urb_info_t *urb)
3458{
3459 usb_trans_info_t *usb_trans_info;
3460 usb_speed_t speed;
3461
3462 usb_trans_info = urb->usb_trans_info;
3463 speed = urb->speed;
3464
3465 col_append_fstr(pinfo->cinfo, COL_INFO, " %s",
3466 val_to_str_ext(pinfo->pool, usb_trans_info->u.get_descriptor.type, &std_descriptor_type_vals_ext, "Unknown type %u"));
3467
3468 switch(usb_trans_info->u.get_descriptor.type) {
3469 case USB_DT_INTERFACE4:
3470 case USB_DT_ENDPOINT5:
3471 /* an interface or an endpoint descriptor can only be accessed
3472 as part of a configuration descriptor */
3473 break;
3474 case USB_DT_DEVICE1:
3475 offset = dissect_usb_device_descriptor(pinfo, tree, tvb, offset, urb);
3476 break;
3477 case USB_DT_OTHER_SPEED_CONFIG7:
3478 /* USB 2.0 Specification: 9.2.6.6 Speed Dependent Descriptors */
3479 if (speed == USB_SPEED_FULL)
3480 speed = USB_SPEED_HIGH;
3481 else if (speed == USB_SPEED_HIGH)
3482 speed = USB_SPEED_FULL;
3483 /* fall-through */
3484 case USB_DT_CONFIG2:
3485 offset = dissect_usb_configuration_descriptor(pinfo, tree, tvb, offset, urb, speed);
3486 break;
3487 case USB_DT_STRING3:
3488 offset = dissect_usb_string_descriptor(pinfo, tree, tvb, offset, urb);
3489 break;
3490 case USB_DT_DEVICE_QUALIFIER6:
3491 offset = dissect_usb_device_qualifier_descriptor(pinfo, tree, tvb, offset, urb);
3492 break;
3493 case USB_DT_BOS0x0F:
3494 offset = dissect_usb_bos_descriptor(pinfo, tree, tvb, offset, urb);
3495 break;
3496 default:
3497 /* XXX dissect the descriptor coming back from the device */
3498 {
3499 unsigned len = tvb_reported_length_remaining(tvb, offset);
3500 proto_tree_add_bytes_format(tree, hf_usb_get_descriptor_resp_generic, tvb, offset, len, NULL((void*)0),
3501 "GET DESCRIPTOR Response data (unknown descriptor type %u): %s",
3502 usb_trans_info->u.get_descriptor.type,
3503 tvb_bytes_to_str(pinfo->pool, tvb, offset, len));
3504 offset = offset + len;
3505 }
3506 break;
3507 }
3508
3509 return offset;
3510}
3511
3512
3513/*
3514 * These dissectors are used to dissect the setup part and the data
3515 * for URB_CONTROL_INPUT / GET INTERFACE
3516 */
3517
3518
3519/* 9.4.4 */
3520static int
3521dissect_usb_setup_get_interface_request(packet_info *pinfo _U___attribute__((unused)), proto_tree *tree,
3522 tvbuff_t *tvb, int offset,
3523 urb_info_t *urb _U___attribute__((unused)))
3524{
3525 /* zero */
3526 proto_tree_add_item(tree, hf_usb_value, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
3527 offset += 2;
3528
3529 /* interface */
3530 proto_tree_add_item(tree, hf_usb_wInterface, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
3531 offset += 2;
3532
3533 /* length */
3534 proto_tree_add_item(tree, hf_usb_length, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
3535 offset += 2;
3536
3537 return offset;
3538}
3539
3540static int
3541dissect_usb_setup_get_interface_response(packet_info *pinfo _U___attribute__((unused)), proto_tree *tree,
3542 tvbuff_t *tvb, int offset,
3543 urb_info_t *urb _U___attribute__((unused)))
3544{
3545 /* alternate setting */
3546 proto_tree_add_item(tree, hf_usb_bAlternateSetting, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
3547 offset += 1;
3548
3549 return offset;
3550}
3551
3552
3553/*
3554 * These dissectors are used to dissect the setup part and the data
3555 * for URB_CONTROL_INPUT / GET STATUS
3556 */
3557
3558
3559/* 9.4.5 */
3560static int
3561dissect_usb_setup_get_status_request(packet_info *pinfo _U___attribute__((unused)), proto_tree *tree,
3562 tvbuff_t *tvb, int offset,
3563 urb_info_t *urb _U___attribute__((unused)))
3564{
3565 /* zero */
3566 proto_tree_add_item(tree, hf_usb_value, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
3567 offset += 2;
3568
3569 /* zero/interface/endpoint */
3570 if (urb) {
3571 uint8_t recip;
3572
3573 recip = USB_RECIPIENT(urb->usb_trans_info->setup.requesttype)((urb->usb_trans_info->setup.requesttype) & 0x1F);
3574
3575 switch (recip) {
3576 case RQT_SETUP_RECIPIENT_INTERFACE1:
3577 proto_tree_add_item(tree, hf_usb_wInterface, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
3578 break;
3579
3580 case RQT_SETUP_RECIPIENT_ENDPOINT2:
3581 proto_tree_add_item(tree, hf_usb_wEndpoint, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
3582 break;
3583
3584 case RQT_SETUP_RECIPIENT_DEVICE0:
3585 case RQT_SETUP_RECIPIENT_OTHER3:
3586 default:
3587 proto_tree_add_item(tree, hf_usb_index, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
3588 break;
3589 }
3590 } else {
3591 proto_tree_add_item(tree, hf_usb_index, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
3592 }
3593 offset += 2;
3594
3595 /* length */
3596 proto_tree_add_item(tree, hf_usb_length, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
3597 offset += 2;
3598
3599 return offset;
3600}
3601
3602static int
3603dissect_usb_setup_get_status_response(packet_info *pinfo _U___attribute__((unused)), proto_tree *tree,
3604 tvbuff_t *tvb, int offset,
3605 urb_info_t *urb _U___attribute__((unused)))
3606{
3607 /* status */
3608 /* XXX - show bits */
3609 proto_tree_add_item(tree, hf_usb_wStatus, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
3610 offset += 2;
3611
3612 return offset;
3613}
3614
3615
3616/*
3617 * These dissectors are used to dissect the setup part and the data
3618 * for URB_CONTROL_INPUT / SET ADDRESS
3619 */
3620
3621
3622/* 9.4.6 */
3623static int
3624dissect_usb_setup_set_address_request(packet_info *pinfo _U___attribute__((unused)), proto_tree *tree,
3625 tvbuff_t *tvb, int offset,
3626 urb_info_t *urb _U___attribute__((unused)))
3627{
3628 /* device address */
3629 proto_tree_add_item(tree, hf_usb_device_address, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
3630 offset += 2;
3631
3632 /* zero */
3633 proto_tree_add_item(tree, hf_usb_index, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
3634 offset += 2;
3635
3636 /* zero */
3637 proto_tree_add_item(tree, hf_usb_length, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
3638 offset += 2;
3639
3640 return offset;
3641}
3642
3643static int
3644dissect_usb_setup_set_address_response(packet_info *pinfo _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)),
3645 tvbuff_t *tvb _U___attribute__((unused)), int offset,
3646 urb_info_t *urb _U___attribute__((unused)))
3647{
3648 return offset;
3649}
3650
3651
3652/*
3653 * These dissectors are used to dissect the setup part and the data
3654 * for URB_CONTROL_INPUT / SET CONFIGURATION
3655 */
3656
3657
3658/* 9.4.7 */
3659static int
3660dissect_usb_setup_set_configuration_request(packet_info *pinfo _U___attribute__((unused)), proto_tree *tree,
3661 tvbuff_t *tvb, int offset,
3662 urb_info_t *urb _U___attribute__((unused)))
3663{
3664 /* configuration value */
3665 proto_tree_add_item(tree, hf_usb_bConfigurationValue, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
3666 offset += 2;
3667
3668 /* zero */
3669 proto_tree_add_item(tree, hf_usb_index, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
3670 offset += 2;
3671
3672 /* zero */
3673 proto_tree_add_item(tree, hf_usb_length, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
3674 offset += 2;
3675
3676 return offset;
3677}
3678
3679static int
3680dissect_usb_setup_set_configuration_response(packet_info *pinfo _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)),
3681 tvbuff_t *tvb _U___attribute__((unused)), int offset,
3682 urb_info_t *urb _U___attribute__((unused)))
3683{
3684 return offset;
3685}
3686
3687
3688/*
3689 * These dissectors are used to dissect the setup part and the data
3690 * for URB_CONTROL_INPUT / SET FEATURE
3691 */
3692
3693
3694/* 9.4.9 */
3695static int
3696dissect_usb_setup_set_feature_request(packet_info *pinfo _U___attribute__((unused)), proto_tree *tree,
3697 tvbuff_t *tvb, int offset,
3698 urb_info_t *urb)
3699{
3700 uint8_t recip;
3701
3702 if (urb) {
3703 recip = USB_RECIPIENT(urb->usb_trans_info->setup.requesttype)((urb->usb_trans_info->setup.requesttype) & 0x1F);
3704
3705 /* feature selector, zero/interface/endpoint */
3706 switch (recip) {
3707 case RQT_SETUP_RECIPIENT_DEVICE0:
3708 proto_tree_add_item(tree, hf_usb_device_wFeatureSelector, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
3709 offset += 2;
3710 proto_tree_add_item(tree, hf_usb_index, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
3711 break;
3712
3713 case RQT_SETUP_RECIPIENT_INTERFACE1:
3714 proto_tree_add_item(tree, hf_usb_interface_wFeatureSelector, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
3715 offset += 2;
3716 proto_tree_add_item(tree, hf_usb_wInterface, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
3717 break;
3718
3719 case RQT_SETUP_RECIPIENT_ENDPOINT2:
3720 proto_tree_add_item(tree, hf_usb_endpoint_wFeatureSelector, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
3721 offset += 2;
3722 proto_tree_add_item(tree, hf_usb_wEndpoint, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
3723 break;
3724
3725 case RQT_SETUP_RECIPIENT_OTHER3:
3726 default:
3727 proto_tree_add_item(tree, hf_usb_value, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
3728 offset += 2;
3729 proto_tree_add_item(tree, hf_usb_index, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
3730 break;
3731 }
3732 } else {
3733 /* No conversation information, so recipient type is unknown */
3734 proto_tree_add_item(tree, hf_usb_value, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
3735 offset += 2;
3736 proto_tree_add_item(tree, hf_usb_index, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
3737 }
3738 offset += 2;
3739
3740 /* zero */
3741 proto_tree_add_item(tree, hf_usb_length, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
3742 offset += 2;
3743
3744 return offset;
3745}
3746
3747static int
3748dissect_usb_setup_set_feature_response(packet_info *pinfo _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)),
3749 tvbuff_t *tvb _U___attribute__((unused)), int offset,
3750 urb_info_t *urb _U___attribute__((unused)))
3751{
3752 return offset;
3753}
3754
3755
3756/*
3757 * These dissectors are used to dissect the setup part and the data
3758 * for URB_CONTROL_INPUT / SET INTERFACE
3759 */
3760
3761
3762/* 9.4.10 */
3763static int
3764dissect_usb_setup_set_interface_request(packet_info *pinfo, proto_tree *tree,
3765 tvbuff_t *tvb, int offset,
3766 urb_info_t *urb _U___attribute__((unused)))
3767{
3768 uint8_t alt_setting, interface_num;
3769
3770 /* alternate setting */
3771 alt_setting = tvb_get_uint8(tvb, offset);
3772 proto_tree_add_uint(tree, hf_usb_bAlternateSetting, tvb, offset, 2, alt_setting);
3773 offset += 2;
3774
3775 /* interface */
3776 interface_num = tvb_get_uint8(tvb, offset);
3777 proto_tree_add_uint(tree, hf_usb_wInterface, tvb, offset, 2, interface_num);
3778 offset += 2;
3779
3780 /* zero */
3781 proto_tree_add_item(tree, hf_usb_length, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
3782 offset += 2;
3783
3784 if (!PINFO_FD_VISITED(pinfo)((pinfo)->fd->visited)) {
3785 unsigned i, count;
3786 usb_conv_info_t *iface_conv_info = get_usb_iface_conv_info(pinfo, interface_num);
3787
3788 /* update the conversation info with the selected alternate setting */
3789 count = wmem_array_get_count(iface_conv_info->alt_settings);
3790 for (i = 0; i < count; i++) {
3791 usb_alt_setting_t *alternate_setting = (usb_alt_setting_t *)wmem_array_index(iface_conv_info->alt_settings, i);
3792
3793 if (alternate_setting->altSetting == alt_setting) {
3794 iface_conv_info->interfaceClass = alternate_setting->interfaceClass;
3795 iface_conv_info->interfaceSubclass = alternate_setting->interfaceSubclass;
3796 iface_conv_info->interfaceProtocol = alternate_setting->interfaceProtocol;
3797 iface_conv_info->interfaceNum = alternate_setting->interfaceNum;
3798 break;
3799 }
3800 }
3801 }
3802
3803 return offset;
3804}
3805
3806static int
3807dissect_usb_setup_set_interface_response(packet_info *pinfo _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)),
3808 tvbuff_t *tvb _U___attribute__((unused)), int offset,
3809 urb_info_t *urb _U___attribute__((unused)))
3810{
3811 return offset;
3812}
3813
3814
3815/*
3816 * These dissectors are used to dissect the setup part and the data
3817 * for URB_CONTROL_INPUT / SYNCH FRAME
3818 */
3819
3820
3821/* 9.4.11 */
3822static int
3823dissect_usb_setup_synch_frame_request(packet_info *pinfo _U___attribute__((unused)), proto_tree *tree,
3824 tvbuff_t *tvb, int offset,
3825 urb_info_t *urb _U___attribute__((unused)))
3826{
3827 /* zero */
3828 proto_tree_add_item(tree, hf_usb_value, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
3829 offset += 2;
3830
3831 /* endpoint */
3832 proto_tree_add_item(tree, hf_usb_wEndpoint, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
3833 offset += 2;
3834
3835 /* two */
3836 proto_tree_add_item(tree, hf_usb_length, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
3837 offset += 2;
3838
3839 return offset;
3840}
3841
3842static int
3843dissect_usb_setup_synch_frame_response(packet_info *pinfo _U___attribute__((unused)), proto_tree *tree _U___attribute__((unused)),
3844 tvbuff_t *tvb _U___attribute__((unused)), int offset,
3845 urb_info_t *urb _U___attribute__((unused)))
3846{
3847 /* frame number */
3848 proto_tree_add_item(tree, hf_usb_wFrameNumber, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
3849 offset += 2;
3850
3851 return offset;
3852}
3853
3854/* Dissector used for unknown USB setup request/responses */
3855static int
3856dissect_usb_setup_generic(packet_info *pinfo _U___attribute__((unused)), proto_tree *tree ,
3857 tvbuff_t *tvb, int offset,
3858 urb_info_t *urb _U___attribute__((unused)))
3859{
3860
3861 proto_tree_add_item(tree, hf_usb_value, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
3862 offset += 2;
3863 proto_tree_add_item(tree, hf_usb_index, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
3864 offset += 2;
3865 proto_tree_add_item(tree, hf_usb_length, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
3866 offset += 2;
3867
3868 return offset;
3869}
3870
3871
3872
3873typedef int (*usb_setup_dissector)(packet_info *pinfo, proto_tree *tree,
3874 tvbuff_t *tvb, int offset,
3875 urb_info_t *urb);
3876
3877typedef struct _usb_setup_dissector_table_t {
3878 uint8_t request;
3879 usb_setup_dissector dissector;
3880
3881} usb_setup_dissector_table_t;
3882static const usb_setup_dissector_table_t setup_request_dissectors[] = {
3883 {USB_SETUP_GET_STATUS0, dissect_usb_setup_get_status_request},
3884 {USB_SETUP_CLEAR_FEATURE1, dissect_usb_setup_clear_feature_request},
3885 {USB_SETUP_SET_FEATURE3, dissect_usb_setup_set_feature_request},
3886 {USB_SETUP_SET_ADDRESS5, dissect_usb_setup_set_address_request},
3887 {USB_SETUP_GET_DESCRIPTOR6, dissect_usb_setup_get_descriptor_request},
3888 {USB_SETUP_SET_CONFIGURATION9, dissect_usb_setup_set_configuration_request},
3889 {USB_SETUP_GET_INTERFACE10, dissect_usb_setup_get_interface_request},
3890 {USB_SETUP_SET_INTERFACE11, dissect_usb_setup_set_interface_request},
3891 {USB_SETUP_SYNCH_FRAME12, dissect_usb_setup_synch_frame_request},
3892 {0, NULL((void*)0)}
3893};
3894
3895static const usb_setup_dissector_table_t setup_response_dissectors[] = {
3896 {USB_SETUP_GET_STATUS0, dissect_usb_setup_get_status_response},
3897 {USB_SETUP_CLEAR_FEATURE1, dissect_usb_setup_clear_feature_response},
3898 {USB_SETUP_SET_FEATURE3, dissect_usb_setup_set_feature_response},
3899 {USB_SETUP_SET_ADDRESS5, dissect_usb_setup_set_address_response},
3900 {USB_SETUP_GET_DESCRIPTOR6, dissect_usb_setup_get_descriptor_response},
3901 {USB_SETUP_GET_CONFIGURATION8, dissect_usb_setup_get_configuration_response},
3902 {USB_SETUP_SET_CONFIGURATION9, dissect_usb_setup_set_configuration_response},
3903 {USB_SETUP_GET_INTERFACE10, dissect_usb_setup_get_interface_response},
3904 {USB_SETUP_SET_INTERFACE11, dissect_usb_setup_set_interface_response},
3905 {USB_SETUP_SYNCH_FRAME12, dissect_usb_setup_synch_frame_response},
3906 {0, NULL((void*)0)}
3907};
3908
3909static const value_string setup_request_names_vals[] = {
3910 {USB_SETUP_GET_STATUS0, "GET STATUS"},
3911 {USB_SETUP_CLEAR_FEATURE1, "CLEAR FEATURE"},
3912 {USB_SETUP_SET_FEATURE3, "SET FEATURE"},
3913 {USB_SETUP_SET_ADDRESS5, "SET ADDRESS"},
3914 {USB_SETUP_GET_DESCRIPTOR6, "GET DESCRIPTOR"},
3915 {USB_SETUP_SET_DESCRIPTOR7, "SET DESCRIPTOR"},
3916 {USB_SETUP_GET_CONFIGURATION8, "GET CONFIGURATION"},
3917 {USB_SETUP_SET_CONFIGURATION9, "SET CONFIGURATION"},
3918 {USB_SETUP_GET_INTERFACE10, "GET INTERFACE"},
3919 {USB_SETUP_SET_INTERFACE11, "SET INTERFACE"},
3920 {USB_SETUP_SYNCH_FRAME12, "SYNCH FRAME"},
3921 {USB_SETUP_SET_SEL48, "SET SEL"},
3922 {USB_SETUP_SET_ISOCH_DELAY49, "SET ISOCH DELAY"},
3923 {0, NULL((void*)0)}
3924};
3925static value_string_ext setup_request_names_vals_ext = VALUE_STRING_EXT_INIT(setup_request_names_vals){ _try_val_to_str_ext_init, 0, (sizeof (setup_request_names_vals
) / sizeof ((setup_request_names_vals)[0]))-1, setup_request_names_vals
, "setup_request_names_vals", ((void*)0) }
;
3926
3927
3928static const true_false_string tfs_bmrequesttype_direction = {
3929 "Device-to-host",
3930 "Host-to-device"
3931};
3932
3933static const value_string bmrequesttype_type_vals[] = {
3934 {RQT_SETUP_TYPE_STANDARD0, "Standard"},
3935 {RQT_SETUP_TYPE_CLASS1, "Class"},
3936 {RQT_SETUP_TYPE_VENDOR2, "Vendor"},
3937 {0, NULL((void*)0)}
3938};
3939
3940static const value_string bmrequesttype_recipient_vals[] = {
3941 {RQT_SETUP_RECIPIENT_DEVICE0, "Device" },
3942 {RQT_SETUP_RECIPIENT_INTERFACE1, "Interface" },
3943 {RQT_SETUP_RECIPIENT_ENDPOINT2, "Endpoint" },
3944 {RQT_SETUP_RECIPIENT_OTHER3, "Other" },
3945 {0, NULL((void*)0) }
3946};
3947
3948/* Dissector used for standard usb setup requests */
3949static int
3950dissect_usb_standard_setup_request(packet_info *pinfo, proto_tree *tree ,
3951 tvbuff_t *tvb, urb_info_t *urb,
3952 usb_trans_info_t *usb_trans_info)
3953{
3954 unsigned offset = 0;
3955 const usb_setup_dissector_table_t *tmp;
3956 usb_setup_dissector dissector;
3957
3958 proto_tree_add_item(tree, hf_usb_request, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
3959 offset += 1;
3960
3961 col_add_fstr(pinfo->cinfo, COL_INFO, "%s Request",
3962 val_to_str_ext(pinfo->pool, usb_trans_info->setup.request, &setup_request_names_vals_ext, "Unknown type %x"));
3963
3964 dissector = NULL((void*)0);
3965 for(tmp = setup_request_dissectors;tmp->dissector;tmp++) {
3966 if (tmp->request == usb_trans_info->setup.request) {
3967 dissector = tmp->dissector;
3968 break;
3969 }
3970 }
3971
3972 if (!dissector) {
3973 dissector = &dissect_usb_setup_generic;
3974 }
3975
3976 offset = dissector(pinfo, tree, tvb, offset, urb);
3977
3978 return offset;
3979
3980}
3981
3982/* Dissector used for standard usb setup responses */
3983static int
3984dissect_usb_standard_setup_response(packet_info *pinfo, proto_tree *tree,
3985 tvbuff_t *tvb, int offset,
3986 urb_info_t *urb)
3987{
3988 const usb_setup_dissector_table_t *tmp;
3989 usb_setup_dissector dissector;
3990 int length_remaining;
3991
3992
3993 col_add_fstr(pinfo->cinfo, COL_INFO, "%s Response",
3994 val_to_str_ext(pinfo->pool, urb->usb_trans_info->setup.request,
3995 &setup_request_names_vals_ext, "Unknown type %x"));
3996
3997 dissector = NULL((void*)0);
3998 for(tmp = setup_response_dissectors;tmp->dissector;tmp++) {
3999 if (tmp->request == urb->usb_trans_info->setup.request) {
4000 dissector = tmp->dissector;
4001 break;
4002 }
4003 }
4004
4005 length_remaining = tvb_reported_length_remaining(tvb, offset);
4006
4007 if (length_remaining <= 0)
4008 return offset;
4009
4010 if (dissector) {
4011 offset = dissector(pinfo, tree, tvb, offset, urb);
4012 } else {
4013 proto_tree_add_item(tree, hf_usb_control_response_generic,
4014 tvb, offset, length_remaining, ENC_NA0x00000000);
4015 offset += length_remaining;
4016 }
4017
4018 return offset;
4019}
4020
4021
4022static void
4023usb_tap_queue_packet(packet_info *pinfo, uint8_t urb_type,
4024 urb_info_t *urb)
4025{
4026 usb_tap_data_t *tap_data;
4027
4028 tap_data = wmem_new(pinfo->pool, usb_tap_data_t)((usb_tap_data_t*)wmem_alloc((pinfo->pool), sizeof(usb_tap_data_t
)))
;
4029 tap_data->urb_type = urb_type;
4030 tap_data->transfer_type = (uint8_t)(urb->transfer_type);
4031 tap_data->urb = urb;
4032 tap_data->trans_info = urb->usb_trans_info;
4033
4034 tap_queue_packet(usb_tap, pinfo, tap_data);
34
Value assigned to field 'transfer_type', which participates in a condition later
4035}
4036
4037
4038static bool_Bool
4039is_usb_standard_setup_request(usb_trans_info_t *usb_trans_info)
4040{
4041 uint8_t type, recip;
4042
4043 type = USB_TYPE(usb_trans_info->setup.requesttype)(((usb_trans_info->setup.requesttype) & (0x03 <<
5)) >> 5)
;
4044 recip = USB_RECIPIENT(usb_trans_info->setup.requesttype)((usb_trans_info->setup.requesttype) & 0x1F);
4045
4046 if (type != RQT_SETUP_TYPE_STANDARD0)
4047 return false0;
4048
4049 /* the USB standards defines the GET_DESCRIPTOR request only as a
4050 request to a device
4051 if it's not aimed at a device, it's a non-standard request that
4052 should be handled by a class-specific dissector */
4053 if (usb_trans_info->setup.request == USB_SETUP_GET_DESCRIPTOR6 &&
4054 recip != RQT_SETUP_RECIPIENT_DEVICE0) {
4055 return false0;
4056 }
4057
4058 return true1;
4059}
4060
4061
4062static int
4063try_dissect_next_protocol(proto_tree *tree, tvbuff_t *next_tvb, packet_info *pinfo,
4064 urb_info_t *urb, uint8_t urb_type, proto_tree *urb_tree,
4065 proto_tree *setup_tree)
4066{
4067 int ret;
4068 wmem_tree_key_t key[4];
4069 uint32_t k_frame_number;
4070 uint32_t k_device_address;
4071 uint32_t k_bus_id;
4072 usb_trans_info_t *usb_trans_info;
4073 heur_dtbl_entry_t *hdtbl_entry;
4074 heur_dissector_list_t heur_subdissector_list = NULL((void*)0);
4075 dissector_table_t usb_dissector_table = NULL((void*)0);
4076 proto_item *sub_item;
4077 device_product_data_t *device_product_data;
4078 device_protocol_data_t *device_protocol_data;
4079 uint8_t ctrl_recip;
4080 /* if we select the next dissector based on a class,
4081 this is the (device or interface) class we're using */
4082 uint32_t usb_class;
4083 uint32_t protocol;
4084 uint8_t transfer_type;
4085 bool_Bool use_setup_tree = false0;
4086
4087 if (!urb
43.1
'urb' is non-null
) {
44
Taking false branch
4088 /*
4089 * Not enough information to choose the next protocol.
4090 * XXX - is there something we can still do here?
4091 */
4092 if (tvb_reported_length(next_tvb) > 0)
4093 call_data_dissector(next_tvb, pinfo, tree);
4094
4095 return tvb_captured_length(next_tvb);
4096 }
4097
4098 /* try dissect by "usb.device" */
4099 ret = dissector_try_uint_with_data(device_to_dissector,
45
Value assigned to field 'conv'
4100 (uint32_t)(urb->bus_id<<16 | urb->device_address),
4101 next_tvb, pinfo, tree, true1, urb);
4102 if (ret)
46
Assuming 'ret' is 0
47
Taking false branch
4103 return ret;
4104
4105 k_frame_number = pinfo->num;
4106 k_device_address = urb->device_address;
4107 k_bus_id = urb->bus_id;
4108
4109 key[0].length = 1;
4110 key[0].key = &k_device_address;
4111 key[1].length = 1;
4112 key[1].key = &k_bus_id;
4113 key[2].length = 1;
4114 key[2].key = &k_frame_number;
4115 key[3].length = 0;
4116 key[3].key = NULL((void*)0);
4117
4118 /* try dissect by "usb.protocol" */
4119 device_protocol_data = (device_protocol_data_t *)wmem_tree_lookup32_array_le(device_to_protocol_table, key);
4120
4121 if (device_protocol_data &&
48
Assuming 'device_protocol_data' is null
4122 device_protocol_data->bus_id == urb->bus_id &&
4123 device_protocol_data->device_address == urb->device_address) {
4124 ret = dissector_try_uint_with_data(protocol_to_dissector,
4125 (uint32_t)device_protocol_data->protocol,
4126 next_tvb, pinfo, tree, true1, urb);
4127 if (ret)
4128 return ret;
4129 }
4130
4131 device_product_data = (device_product_data_t *)wmem_tree_lookup32_array_le(device_to_product_table, key);
4132
4133 if (device_product_data && device_product_data->bus_id == urb->bus_id &&
49
Assuming 'device_product_data' is null
4134 device_product_data->device_address == urb->device_address) {
4135 ret = dissector_try_uint_with_data(product_to_dissector,
4136 (uint32_t)(device_product_data->vendor<<16 | device_product_data->product),
4137 next_tvb, pinfo, tree, true1, urb);
4138 if (ret)
4139 return ret;
4140 }
4141
4142 transfer_type = urb->transfer_type;
4143 if (transfer_type == URB_UNKNOWN0xFF)
50
Assuming 'transfer_type' is not equal to URB_UNKNOWN
51
Taking false branch
4144 transfer_type = urb->conv->descriptor_transfer_type;
4145
4146 switch(transfer_type) {
52
Control jumps to the 'default' case at line 4240
4147 case URB_BULK0x3:
4148 heur_subdissector_list = heur_bulk_subdissector_list;
4149 usb_dissector_table = usb_bulk_dissector_table;
4150 break;
4151
4152 case URB_INTERRUPT0x1:
4153 heur_subdissector_list = heur_interrupt_subdissector_list;
4154 usb_dissector_table = usb_interrupt_dissector_table;
4155 break;
4156
4157 case URB_CONTROL0x2:
4158 usb_trans_info = urb->usb_trans_info;
4159 if (!usb_trans_info)
4160 break;
4161
4162 /* for standard control requests and responses, there's no
4163 need to query dissector tables */
4164 if (is_usb_standard_setup_request(usb_trans_info))
4165 break;
4166
4167 /* When dissecting requests, and Setup Data tree is created,
4168 pass it to next dissector instead of parent. */
4169 if (urb->is_request && setup_tree)
4170 use_setup_tree = true1;
4171
4172 ctrl_recip = USB_RECIPIENT(usb_trans_info->setup.requesttype)((usb_trans_info->setup.requesttype) & 0x1F);
4173
4174 if (ctrl_recip == RQT_SETUP_RECIPIENT_INTERFACE1) {
4175 uint8_t interface_num = usb_trans_info->setup.wIndex & 0xff;
4176 urb_info_t *new_urb = wmem_new(pinfo->pool, urb_info_t)((urb_info_t*)wmem_alloc((pinfo->pool), sizeof(urb_info_t)
))
;
4177
4178 memcpy(new_urb, urb, sizeof(urb_info_t));
4179 urb = new_urb;
4180
4181 heur_subdissector_list = heur_control_subdissector_list;
4182 usb_dissector_table = usb_control_dissector_table;
4183
4184 urb->conv = get_usb_iface_conv_info(pinfo, interface_num);
4185 urb->usb_trans_info = usb_trans_info;
4186 urb->endpoint = NO_ENDPOINT8((uint8_t)(0xffffffff& (255)));
4187 }
4188 else if (ctrl_recip == RQT_SETUP_RECIPIENT_ENDPOINT2) {
4189 address endpoint_addr;
4190 int endpoint;
4191 uint32_t src_endpoint, dst_endpoint;
4192 conversation_t *conversation;
4193 urb_info_t *new_urb = wmem_new(pinfo->pool, urb_info_t)((urb_info_t*)wmem_alloc((pinfo->pool), sizeof(urb_info_t)
))
;
4194
4195 memcpy(new_urb, urb, sizeof(urb_info_t));
4196 urb = new_urb;
4197
4198 heur_subdissector_list = heur_control_subdissector_list;
4199 usb_dissector_table = usb_control_dissector_table;
4200
4201 endpoint = usb_trans_info->setup.wIndex & 0xff;
4202
4203 if (urb->is_request) {
4204 usb_address_t *dst_addr = wmem_new0(pinfo->pool, usb_address_t)((usb_address_t*)wmem_alloc0((pinfo->pool), sizeof(usb_address_t
)))
;
4205 dst_addr->bus_id = urb->bus_id;
4206 dst_addr->device = urb->device_address;
4207 dst_addr->endpoint = dst_endpoint = GUINT32_TO_LE(endpoint)((guint32) (endpoint));
4208 set_address(&endpoint_addr, usb_address_type, USB_ADDR_LEN(sizeof(usb_address_t)), (char *)dst_addr);
4209
4210 conversation = get_usb_conversation(pinfo, &pinfo->src, &endpoint_addr, pinfo->srcport, dst_endpoint);
4211 }
4212 else {
4213 usb_address_t *src_addr = wmem_new0(pinfo->pool, usb_address_t)((usb_address_t*)wmem_alloc0((pinfo->pool), sizeof(usb_address_t
)))
;
4214 src_addr->bus_id = urb->bus_id;
4215 src_addr->device = urb->device_address;
4216 src_addr->endpoint = src_endpoint = GUINT32_TO_LE(endpoint)((guint32) (endpoint));
4217 set_address(&endpoint_addr, usb_address_type, USB_ADDR_LEN(sizeof(usb_address_t)), (char *)src_addr);
4218
4219 conversation = get_usb_conversation(pinfo, &endpoint_addr, &pinfo->dst, src_endpoint, pinfo->destport);
4220 }
4221
4222 urb->conv = get_usb_conv_info(conversation);
4223 urb->usb_trans_info = usb_trans_info;
4224 }
4225 else {
4226 /* the recipient is "device" or "other" or "reserved"
4227 there's no way for us to determine the interfaceClass
4228 we set the usb_dissector_table anyhow as some
4229 dissectors register for control messages to
4230 IF_CLASS_UNKNOWN (this should be fixed) */
4231 heur_subdissector_list = heur_control_subdissector_list;
4232 usb_dissector_table = usb_control_dissector_table;
4233 }
4234
4235 usb_tap_queue_packet(pinfo, urb_type, urb);
4236 sub_item = proto_tree_add_uint(urb_tree, hf_usb_bInterfaceClass, next_tvb, 0, 0, urb->conv->interfaceClass);
4237 proto_item_set_generated(sub_item);
4238 break;
4239
4240 default:
4241 break;
4242 }
4243
4244 if (urb
52.1
'urb' is non-null
&& urb->conv
&& pinfo->fd &&
53
Assuming field 'conv' is null
54
Assuming pointer value is null
4245 urb->conv->interfaceClass != IF_CLASS_UNKNOWN0xffff &&
4246 urb->conv->config_desc_frame_num != 0) {
4247 mark_frame_as_depended_upon(pinfo->fd, urb->conv->config_desc_frame_num);
4248 }
4249
4250 /* try "usb.protocol" on interface level */
4251 protocol = (urb->conv->interfaceClass & 0xFF) << 16 |
55
Access to field 'interfaceClass' results in a dereference of a null pointer (loaded from field 'conv')
4252 (urb->conv->interfaceSubclass & 0xFF) << 8 |
4253 (urb->conv->interfaceProtocol & 0xFF);
4254 ret = dissector_try_uint_with_data(protocol_to_dissector, protocol,
4255 next_tvb, pinfo, tree, true1, urb);
4256 if (ret)
4257 return ret;
4258
4259 if (try_heuristics && heur_subdissector_list) {
4260 bool_Bool dissector_found = dissector_try_heuristic(heur_subdissector_list,
4261 next_tvb, pinfo, use_setup_tree ? setup_tree : tree, &hdtbl_entry, urb);
4262 if (dissector_found)
4263 return tvb_captured_length(next_tvb);
4264 }
4265
4266 if (usb_dissector_table) {
4267 /* we prefer the interface class unless it says we should refer
4268 to the device class
4269 XXX - use the device class if the interface class is unknown */
4270 if (urb->conv->interfaceClass == IF_CLASS_DEVICE0x00) {
4271 usb_class = (urb->device_protocol>>16) & 0xFF;
4272 }
4273 else {
4274 usb_class = urb->conv->interfaceClass;
4275 }
4276
4277 ret = dissector_try_uint_with_data(usb_dissector_table, usb_class,
4278 next_tvb, pinfo, use_setup_tree ? setup_tree : tree, true1, urb);
4279 if (ret)
4280 return ret;
4281
4282 /* try protocol specific dissector if there is one */
4283 usb_class = USB_PROTOCOL_KEY(urb->conv->interfaceClass,(1u << 31 | (urb->conv->interfaceClass & 0xff
) << 16 | (urb->conv->interfaceSubclass & 0xff
) << 8 | (urb->conv->interfaceProtocol & 0xff
))
4284 urb->conv->interfaceSubclass,(1u << 31 | (urb->conv->interfaceClass & 0xff
) << 16 | (urb->conv->interfaceSubclass & 0xff
) << 8 | (urb->conv->interfaceProtocol & 0xff
))
4285 urb->conv->interfaceProtocol)(1u << 31 | (urb->conv->interfaceClass & 0xff
) << 16 | (urb->conv->interfaceSubclass & 0xff
) << 8 | (urb->conv->interfaceProtocol & 0xff
))
;
4286 ret = dissector_try_uint_with_data(usb_dissector_table, usb_class,
4287 next_tvb, pinfo, use_setup_tree ? setup_tree : tree, true1, urb);
4288 if (ret)
4289 return ret;
4290 }
4291
4292 return 0;
4293}
4294
4295
4296static int
4297dissect_usb_setup_response(packet_info *pinfo, proto_tree *tree,
4298 tvbuff_t *tvb, int offset,
4299 uint8_t urb_type, urb_info_t *urb)
4300{
4301 proto_tree *parent;
4302 tvbuff_t *next_tvb = NULL((void*)0);
4303 int length_remaining;
4304
4305 parent = proto_tree_get_parent_tree(tree);
4306
4307 if (urb) {
4308 if (urb->usb_trans_info && is_usb_standard_setup_request(urb->usb_trans_info)) {
4309 offset = dissect_usb_standard_setup_response(pinfo, parent, tvb, offset, urb);
4310 }
4311 else {
4312 next_tvb = tvb_new_subset_remaining(tvb, offset);
4313 offset += try_dissect_next_protocol(parent, next_tvb, pinfo, urb, urb_type, tree, NULL((void*)0));
4314
4315 length_remaining = tvb_reported_length_remaining(tvb, offset);
4316 if (length_remaining > 0) {
4317 proto_tree_add_item(parent, hf_usb_control_response_generic,
4318 tvb, offset, length_remaining, ENC_NA0x00000000);
4319 offset += length_remaining;
4320 }
4321 }
4322 }
4323 else {
4324 /* no matching request available */
4325 length_remaining = tvb_reported_length_remaining(tvb, offset);
4326 if (length_remaining > 0) {
4327 proto_tree_add_item(parent, hf_usb_control_response_generic, tvb,
4328 offset, length_remaining, ENC_NA0x00000000);
4329 offset += length_remaining;
4330 }
4331 }
4332
4333 return offset;
4334}
4335
4336
4337static int
4338dissect_usb_bmrequesttype(proto_tree *parent_tree, tvbuff_t *tvb, int offset, uint8_t *byte)
4339{
4340 uint64_t val;
4341
4342 static int * const bmRequestType_bits[] = {
4343 &hf_usb_bmRequestType_direction,
4344 &hf_usb_bmRequestType_type,
4345 &hf_usb_bmRequestType_recipient,
4346 NULL((void*)0)
4347 };
4348
4349 proto_tree_add_bitmask_with_flags_ret_uint64(parent_tree, tvb, offset, hf_usb_bmRequestType, ett_usb_setup_bmrequesttype,
4350 bmRequestType_bits, ENC_LITTLE_ENDIAN0x80000000, BMT_NO_APPEND0x01, &val);
4351 *byte = (uint8_t) val;
4352
4353 return ++offset;
4354}
4355
4356int
4357dissect_urb_transfer_flags(tvbuff_t *tvb, int offset, proto_tree* tree, int hf, int endian)
4358{
4359 proto_tree_add_bitmask(tree, tvb, offset, hf, ett_transfer_flags, transfer_flags_fields, endian);
4360 return 4;
4361}
4362
4363static int
4364dissect_linux_usb_pseudo_header_ext(tvbuff_t *tvb, int offset,
4365 packet_info *pinfo _U___attribute__((unused)),
4366 proto_tree *tree)
4367{
4368 proto_tree_add_item(tree, hf_usb_urb_interval, tvb, offset, 4, ENC_HOST_ENDIAN0x80000000);
4369 offset += 4;
4370 proto_tree_add_item(tree, hf_usb_urb_start_frame, tvb, offset, 4, ENC_HOST_ENDIAN0x80000000);
4371 offset += 4;
4372 dissect_urb_transfer_flags(tvb, offset, tree, hf_usb_urb_copy_of_transfer_flags, ENC_HOST_ENDIAN0x80000000);
4373 offset += 4;
4374 proto_tree_add_item(tree, hf_usb_iso_numdesc, tvb, offset, 4, ENC_HOST_ENDIAN0x80000000);
4375 offset += 4;
4376
4377 return offset;
4378}
4379
4380
4381/* Dissector used for usb setup requests */
4382static int
4383dissect_usb_setup_request(packet_info *pinfo, proto_tree *tree,
4384 tvbuff_t *tvb, int offset,
4385 uint8_t urb_type, urb_info_t *urb,
4386 usb_header_t header_type, uint64_t usb_id)
4387{
4388 int setup_offset;
4389 int req_type;
4390 int ret = 0;
4391 proto_tree *parent, *setup_tree;
4392 usb_trans_info_t *usb_trans_info, trans_info;
4393 tvbuff_t *next_tvb, *data_tvb = NULL((void*)0);
4394 uint8_t bm_request_type;
4395
4396 /* we should do the NULL check in all non-static functions */
4397 if (urb)
4398 usb_trans_info = urb->usb_trans_info;
4399 else
4400 usb_trans_info = &trans_info;
4401
4402 parent = proto_tree_get_parent_tree(tree);
4403
4404 setup_tree = proto_tree_add_subtree(parent, tvb, offset, 8, ett_usb_setup_hdr, NULL((void*)0), "Setup Data");
4405
4406 req_type = USB_TYPE(tvb_get_uint8(tvb, offset))(((tvb_get_uint8(tvb, offset)) & (0x03 << 5)) >>
5)
;
4407 usb_trans_info->setup.requesttype = tvb_get_uint8(tvb, offset);
4408 if (urb) {
4409 urb->setup_requesttype = tvb_get_uint8(tvb, offset);
4410 if (req_type != RQT_SETUP_TYPE_CLASS1)
4411 usb_tap_queue_packet(pinfo, urb_type, urb);
4412 }
4413
4414 offset = dissect_usb_bmrequesttype(setup_tree, tvb, offset, &bm_request_type);
4415
4416 /* as we're going through the data, we build a next_tvb that
4417 contains the the setup packet without the request type
4418 and request-specific data
4419 all subsequent dissection routines work on this tvb */
4420
4421 setup_offset = offset;
4422 usb_trans_info->setup.request = tvb_get_uint8(tvb, offset);
4423 offset++;
4424 usb_trans_info->setup.wValue = tvb_get_letohs(tvb, offset);
4425 offset += 2;
4426 usb_trans_info->setup.wIndex = tvb_get_letohs(tvb, offset);
4427 offset += 2;
4428 usb_trans_info->setup.wLength = tvb_get_letohs(tvb, offset);
4429 offset += 2;
4430
4431 if (header_type == USB_HEADER_LINUX_64_BYTES) {
4432 offset = dissect_linux_usb_pseudo_header_ext(tvb, offset, pinfo, tree);
4433 } else if (header_type == USB_HEADER_USBPCAP) {
4434 if ((bm_request_type & 0x80) == 0 &&
4435 usb_trans_info->setup.wLength > 0 &&
4436 tvb_reported_length_remaining(tvb, offset) == 0) {
4437 /* UPBPcap older than 1.5.0.0 packet, save setup data
4438 and do not call subdissector */
4439 if (!PINFO_FD_VISITED(pinfo)((pinfo)->fd->visited)) {
4440 wmem_tree_key_t key[3];
4441 usbpcap_setup_data_t *setup_data = wmem_new(wmem_file_scope(), usbpcap_setup_data_t)((usbpcap_setup_data_t*)wmem_alloc((wmem_file_scope()), sizeof
(usbpcap_setup_data_t)))
;
4442 setup_data->usb_id = usb_id;
4443 tvb_memcpy(tvb, setup_data->setup_data, setup_offset-1, 8);
4444 key[0].length = 2;
4445 key[0].key = (uint32_t *)&usb_id;
4446 key[1].length = 1;
4447 key[1].key = &pinfo->num;
4448 key[2].length = 0;
4449 key[2].key = NULL((void*)0);
4450 wmem_tree_insert32_array(usbpcap_setup_data, key, setup_data);
4451 }
4452 proto_tree_add_item(setup_tree, hf_usb_request_unknown_class, tvb, setup_offset, 1, ENC_LITTLE_ENDIAN0x80000000);
4453 dissect_usb_setup_generic(pinfo, setup_tree, tvb, setup_offset+1, urb);
4454 return offset;
4455 }
4456 }
4457
4458
4459 if (tvb_captured_length_remaining(tvb, offset) > 0) {
4460 next_tvb = tvb_new_composite();
4461 tvb_composite_append(next_tvb, tvb_new_subset_length(tvb, setup_offset, 7));
4462
4463 data_tvb = tvb_new_subset_remaining(tvb, offset);
4464 tvb_composite_append(next_tvb, data_tvb);
4465 offset += tvb_captured_length(data_tvb);
4466 tvb_composite_finalize(next_tvb);
4467 add_new_data_source(pinfo, next_tvb, "USB Control");
4468 } else {
4469 next_tvb = tvb_new_subset_length(tvb, setup_offset, 7);
4470 }
4471
4472 /* at this point, offset contains the number of bytes that we
4473 dissected */
4474
4475 if (is_usb_standard_setup_request(usb_trans_info)) {
4476 /* there's no point in checking the return value as there's no
4477 fallback for standard setup requests */
4478 ret = dissect_usb_standard_setup_request(pinfo, setup_tree,
4479 next_tvb, urb, usb_trans_info);
4480 }
4481 else {
4482 /* no standard request - pass it on to class-specific dissectors */
4483 ret = try_dissect_next_protocol(
4484 parent, next_tvb, pinfo, urb, urb_type, tree, setup_tree);
4485 if (ret <= 0) {
4486 /* no class-specific dissector could handle it,
4487 dissect it as generic setup request */
4488 proto_tree_add_item(setup_tree, hf_usb_request_unknown_class,
4489 next_tvb, 0, 1, ENC_LITTLE_ENDIAN0x80000000);
4490 ret = dissect_usb_setup_generic(pinfo, setup_tree,
4491 next_tvb, 1, urb);
4492 }
4493 /* at this point, non-standard request has been dissected */
4494 }
4495
4496 if (data_tvb) {
4497 int data_tvb_offset = MAX(0, ret - 7)(((0) > (ret - 7)) ? (0) : (ret - 7));
4498 if (tvb_captured_length_remaining(data_tvb, data_tvb_offset) > 0) {
4499 proto_tree_add_item(parent, hf_usb_data_fragment, data_tvb, data_tvb_offset, -1, ENC_NA0x00000000);
4500 }
4501 }
4502
4503 return offset;
4504}
4505
4506
4507/* dissect the linux-specific USB pseudo header and fill the conversation struct
4508 return the number of dissected bytes */
4509static int
4510dissect_linux_usb_pseudo_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
4511 urb_info_t *urb, uint64_t *urb_id)
4512{
4513 uint8_t transfer_type;
4514 uint8_t endpoint_byte;
4515 uint8_t transfer_type_and_direction;
4516 uint8_t urb_type;
4517 uint32_t flag;
4518 uint32_t bus_id;
4519
4520 *urb_id = tvb_get_uint64(tvb, 0, ENC_HOST_ENDIAN0x80000000);
4521 proto_tree_add_uint64(tree, hf_usb_urb_id, tvb, 0, 8, *urb_id);
4522
4523 /* show the urb type of this URB as string and as a character */
4524 urb_type = tvb_get_uint8(tvb, 8);
4525 urb->is_request = (urb_type==URB_SUBMIT'S');
4526 proto_tree_add_uint(tree, hf_usb_linux_urb_type, tvb, 8, 1, urb_type);
4527 proto_tree_add_item_ret_uint8(tree, hf_usb_linux_transfer_type, tvb, 9, 1, ENC_LITTLE_ENDIAN0x80000000, &transfer_type);
4528
4529 urb->transfer_type = transfer_type;
4530
4531 endpoint_byte = tvb_get_uint8(tvb, 10); /* direction bit | endpoint */
4532 urb->endpoint = endpoint_byte;
4533 if (endpoint_byte & URB_TRANSFER_IN0x80)
4534 urb->direction = P2P_DIR_RECV1;
4535 else
4536 urb->direction = P2P_DIR_SENT0;
4537
4538 transfer_type_and_direction = (transfer_type & 0x7F) | (endpoint_byte & 0x80);
4539 col_append_str(pinfo->cinfo, COL_INFO,
4540 val_to_str(pinfo->pool, transfer_type_and_direction, usb_transfer_type_and_direction_vals, "Unknown type %x"));
4541
4542 proto_tree_add_bitmask(tree, tvb, 10, hf_usb_endpoint_address, ett_usb_endpoint, usb_endpoint_fields, ENC_NA0x00000000);
4543 proto_tree_add_item(tree, hf_usb_device_address, tvb, 11, 1, ENC_LITTLE_ENDIAN0x80000000);
4544 urb->device_address = (uint16_t)tvb_get_uint8(tvb, 11);
4545
4546 proto_tree_add_item_ret_uint(tree, hf_usb_bus_id, tvb, 12, 2, ENC_HOST_ENDIAN0x80000000, &bus_id);
4547 urb->bus_id = (uint16_t) bus_id;
4548
4549 /* Right after the pseudo header we always have
4550 * sizeof(struct usb_device_setup_hdr) bytes. The content of these
4551 * bytes only have meaning in case setup_flag == 0.
4552 */
4553 proto_tree_add_item_ret_uint(tree, hf_usb_setup_flag, tvb, 14, 1, ENC_ASCII0x00000000, &flag);
4554 if (flag == 0) {
4555 urb->is_setup = true1;
4556 if (urb->transfer_type!=URB_CONTROL0x2)
4557 proto_tree_add_expert(tree, pinfo, &ei_usb_invalid_setup, tvb, 14, 1);
4558 } else {
4559 urb->is_setup = false0;
4560 }
4561
4562 proto_tree_add_item(tree, hf_usb_data_flag, tvb, 15, 1, ENC_ASCII0x00000000);
4563
4564 proto_tree_add_item(tree, hf_usb_urb_ts_sec, tvb, 16, 8, ENC_HOST_ENDIAN0x80000000);
4565 proto_tree_add_item(tree, hf_usb_urb_ts_usec, tvb, 24, 4, ENC_HOST_ENDIAN0x80000000);
4566 proto_tree_add_item(tree, hf_usb_urb_status, tvb, 28, 4, ENC_HOST_ENDIAN0x80000000);
4567 proto_tree_add_item(tree, hf_usb_urb_len, tvb, 32, 4, ENC_HOST_ENDIAN0x80000000);
4568 proto_tree_add_item(tree, hf_usb_urb_data_len, tvb, 36, 4, ENC_HOST_ENDIAN0x80000000);
4569
4570 return 40;
4571}
4572
4573/* dissect the usbpcap_buffer_packet_header and fill the conversation struct
4574 this function does not handle the transfer-specific headers
4575 return the number of bytes processed */
4576static int
4577dissect_usbpcap_buffer_packet_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
4578 urb_info_t *urb, uint32_t *win32_data_len, uint64_t *irp_id)
4579{
4580 proto_item *item;
4581 uint32_t function_code;
4582 uint8_t transfer_type;
4583 uint8_t endpoint_byte;
4584 uint8_t transfer_type_and_direction;
4585 uint8_t tmp_val8;
4586
4587 proto_tree_add_item(tree, hf_usb_win32_header_len, tvb, 0, 2, ENC_LITTLE_ENDIAN0x80000000);
4588 *irp_id = tvb_get_uint64(tvb, 2, ENC_LITTLE_ENDIAN0x80000000);
4589 proto_tree_add_uint64(tree, hf_usb_irp_id, tvb, 2, 8, *irp_id);
4590 proto_tree_add_item(tree, hf_usb_usbd_status, tvb, 10, 4, ENC_LITTLE_ENDIAN0x80000000);
4591 proto_tree_add_item_ret_uint(tree, hf_usb_function, tvb, 14, 2, ENC_LITTLE_ENDIAN0x80000000, &function_code);
4592
4593 proto_tree_add_bitmask(tree, tvb, 16, hf_usb_info, ett_usb_usbpcap_info, usb_usbpcap_info_fields, ENC_LITTLE_ENDIAN0x80000000);
4594 tmp_val8 = tvb_get_uint8(tvb, 16);
4595 /* TODO: Handle errors */
4596 if (tmp_val8 & 0x01) {
4597 urb->is_request = false0;
4598 } else {
4599 urb->is_request = true1;
4600 }
4601
4602 proto_tree_add_item(tree, hf_usb_bus_id, tvb, 17, 2, ENC_LITTLE_ENDIAN0x80000000);
4603 urb->bus_id = tvb_get_letohs(tvb, 17);
4604
4605 proto_tree_add_item(tree, hf_usb_win32_device_address, tvb, 19, 2, ENC_LITTLE_ENDIAN0x80000000);
4606 urb->device_address = tvb_get_letohs(tvb, 19);
4607
4608 endpoint_byte = tvb_get_uint8(tvb, 21);
4609 urb->direction = endpoint_byte&URB_TRANSFER_IN0x80 ? P2P_DIR_RECV1 : P2P_DIR_SENT0;
4610 urb->endpoint = endpoint_byte;
4611 proto_tree_add_bitmask(tree, tvb, 21, hf_usb_endpoint_address, ett_usb_endpoint, usb_endpoint_fields, ENC_LITTLE_ENDIAN0x80000000);
4612
4613 transfer_type = tvb_get_uint8(tvb, 22);
4614 urb->transfer_type = transfer_type;
4615 item = proto_tree_add_item(tree, hf_usb_win32_transfer_type, tvb, 22, 1, ENC_LITTLE_ENDIAN0x80000000);
4616 if (transfer_type == URB_UNKNOWN0xFF) {
4617 expert_add_info(pinfo, item, &ei_usb_usbpcap_unknown_urb);
4618 }
4619
4620 /* Workaround bug in captures created with USBPcap earlier than 1.3.0.0 */
4621 if ((endpoint_byte == 0x00) && (transfer_type == URB_CONTROL0x2) && (tvb_get_uint8(tvb, 27) == USB_CONTROL_STAGE_DATA0x01)) {
4622 urb->is_request = true1;
4623 }
4624
4625 if (transfer_type != USBPCAP_URB_IRP_INFO0xFE) {
4626 transfer_type_and_direction = (transfer_type & 0x7F) | (endpoint_byte & 0x80);
4627 col_append_str(pinfo->cinfo, COL_INFO,
4628 val_to_str(pinfo->pool, transfer_type_and_direction, usb_transfer_type_and_direction_vals, "Unknown type %x"));
4629 } else {
4630 col_append_str(pinfo->cinfo, COL_INFO,
4631 val_to_str_ext(pinfo->pool, function_code, &win32_urb_function_vals_ext, "Unknown function %x"));
4632 }
4633
4634 *win32_data_len = tvb_get_letohl(tvb, 23);
4635 proto_tree_add_item(tree, hf_usb_win32_data_len, tvb, 23, 4, ENC_LITTLE_ENDIAN0x80000000);
4636
4637 /* by default, we assume it's no setup packet
4638 the correct values will be set when we parse the control header */
4639 urb->is_setup = false0;
4640 urb->setup_requesttype = 0;
4641
4642 /* we don't handle the transfer-specific headers here */
4643 return 27;
4644}
4645
4646
4647static int
4648dissect_darwin_buffer_packet_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
4649 urb_info_t *urb, uint64_t *id)
4650{
4651 uint8_t transfer_type;
4652 uint8_t request_type;
4653 uint8_t endpoint_byte;
4654 uint8_t transfer_type_and_direction;
4655 uint8_t header_length;
4656
4657 proto_tree_add_item(tree, hf_usb_darwin_bcd_version, tvb, 0, 2, ENC_LITTLE_ENDIAN0x80000000);
4658
4659 header_length = tvb_get_uint8(tvb, 2);
4660 proto_tree_add_item(tree, hf_usb_darwin_header_len, tvb, 2, 1, ENC_LITTLE_ENDIAN0x80000000);
4661
4662 request_type = tvb_get_uint8(tvb, 3);
4663 urb->is_request = (request_type == DARWIN_IO_SUBMIT0);
4664 proto_tree_add_uint(tree, hf_usb_darwin_request_type, tvb, 3, 1, request_type);
4665
4666 proto_tree_add_item(tree, hf_usb_darwin_io_len, tvb, 4, 4, ENC_LITTLE_ENDIAN0x80000000);
4667
4668 proto_tree_add_item(tree, hf_usb_darwin_io_status, tvb, 8, 4, ENC_LITTLE_ENDIAN0x80000000);
4669
4670 proto_tree_add_item(tree, hf_usb_darwin_iso_num_packets, tvb, 12, 4, ENC_LITTLE_ENDIAN0x80000000);
4671
4672 *id = tvb_get_uint64(tvb, 16, ENC_LITTLE_ENDIAN0x80000000);
4673 proto_tree_add_uint64(tree, hf_usb_darwin_io_id, tvb, 16, 8, *id);
4674
4675 proto_tree_add_item(tree, hf_usb_darwin_device_location, tvb, 24, 4, ENC_LITTLE_ENDIAN0x80000000);
4676 urb->bus_id = tvb_get_letohl(tvb, 24) >> 24;
4677
4678 proto_tree_add_item(tree, hf_usb_darwin_speed, tvb, 28, 1, ENC_LITTLE_ENDIAN0x80000000);
4679
4680 urb->device_address = (uint16_t)tvb_get_uint8(tvb, 29);
4681 proto_tree_add_uint(tree, hf_usb_darwin_device_address, tvb, 29, 1, urb->device_address);
4682
4683 endpoint_byte = tvb_get_uint8(tvb, 30); /* direction bit | endpoint */
4684 urb->endpoint = endpoint_byte;
4685 if (endpoint_byte & URB_TRANSFER_IN0x80) {
4686 urb->direction = P2P_DIR_RECV1;
4687 }
4688 else {
4689 urb->direction = P2P_DIR_SENT0;
4690 }
4691 proto_tree_add_uint(tree, hf_usb_darwin_endpoint_address, tvb, 30, 1, endpoint_byte);
4692 proto_tree_add_bitmask(tree, tvb, 30, hf_usb_endpoint_number, ett_usb_endpoint, usb_endpoint_fields, ENC_LITTLE_ENDIAN0x80000000);
4693
4694 transfer_type = MIN(tvb_get_uint8(tvb, 31), G_N_ELEMENTS(darwin_endpoint_to_linux) - 1)(((tvb_get_uint8(tvb, 31)) < ((sizeof (darwin_endpoint_to_linux
) / sizeof ((darwin_endpoint_to_linux)[0])) - 1)) ? (tvb_get_uint8
(tvb, 31)) : ((sizeof (darwin_endpoint_to_linux) / sizeof ((darwin_endpoint_to_linux
)[0])) - 1))
;
4695 urb->transfer_type = darwin_endpoint_to_linux[transfer_type];
4696 proto_tree_add_uint(tree, hf_usb_darwin_endpoint_type, tvb, 31, 1, transfer_type);
4697
4698 transfer_type_and_direction = (darwin_endpoint_to_linux[transfer_type] & 0x7F) | (endpoint_byte & 0x80);
4699 col_append_str(pinfo->cinfo, COL_INFO,
4700 val_to_str(pinfo->pool, transfer_type_and_direction, usb_transfer_type_and_direction_vals, "Unknown type %x"));
4701 col_append_str(pinfo->cinfo, COL_INFO, urb->is_request == true1 ? " (submitted)" : " (completed)");
4702
4703 urb->is_setup = false0;
4704 if ((urb->is_request == true1) && (urb->transfer_type == URB_CONTROL0x2)) {
4705 urb->is_setup = true1;
4706 }
4707
4708 urb->setup_requesttype = 0;
4709
4710 /* we don't handle the transfer-specific headers here */
4711 return header_length;
4712}
4713
4714/* Set the usb_address_t fields based on the direction of the urb */
4715static void
4716usb_set_addr(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, uint16_t bus_id, uint16_t device_address,
4717 int endpoint, bool_Bool req)
4718{
4719 proto_item *sub_item;
4720 usb_address_t *src_addr = wmem_new0(pinfo->pool, usb_address_t)((usb_address_t*)wmem_alloc0((pinfo->pool), sizeof(usb_address_t
)))
,
4721 *dst_addr = wmem_new0(pinfo->pool, usb_address_t)((usb_address_t*)wmem_alloc0((pinfo->pool), sizeof(usb_address_t
)))
;
4722 const char *str_src_addr;
4723 const char *str_dst_addr;
4724
4725 if (req) {
4726 /* request */
4727 src_addr->device = 0xffffffff;
4728 src_addr->endpoint = NO_ENDPOINT0xffffffff;
4729 dst_addr->device = GUINT16_TO_LE(device_address)((guint16) (device_address));
4730 dst_addr->endpoint = GUINT32_TO_LE(endpoint)((guint32) (endpoint));
4731 } else {
4732 /* response */
4733 src_addr->device = GUINT16_TO_LE(device_address)((guint16) (device_address));
4734 src_addr->endpoint = GUINT32_TO_LE(endpoint)((guint32) (endpoint));
4735 dst_addr->device = 0xffffffff;
4736 dst_addr->endpoint = NO_ENDPOINT0xffffffff;
4737 }
4738 src_addr->bus_id = GUINT16_TO_LE(bus_id)((guint16) (bus_id));
4739 dst_addr->bus_id = GUINT16_TO_LE(bus_id)((guint16) (bus_id));
4740
4741 set_address(&pinfo->net_src, usb_address_type, USB_ADDR_LEN(sizeof(usb_address_t)), (char *)src_addr);
4742 copy_address_shallow(&pinfo->src, &pinfo->net_src);
4743 set_address(&pinfo->net_dst, usb_address_type, USB_ADDR_LEN(sizeof(usb_address_t)), (char *)dst_addr);
4744 copy_address_shallow(&pinfo->dst, &pinfo->net_dst);
4745
4746 pinfo->ptype = PT_USB;
4747 pinfo->srcport = src_addr->endpoint;
4748 pinfo->destport = dst_addr->endpoint;
4749 /* sent/received is from the perspective of the USB host */
4750 pinfo->p2p_dir = req ? P2P_DIR_SENT0 : P2P_DIR_RECV1;
4751
4752 str_src_addr = address_to_str(pinfo->pool, &pinfo->src);
4753 str_dst_addr = address_to_str(pinfo->pool, &pinfo->dst);
4754
4755 sub_item = proto_tree_add_string(tree, hf_usb_src, tvb, 0, 0, str_src_addr);
4756 proto_item_set_generated(sub_item);
4757
4758 sub_item = proto_tree_add_string(tree, hf_usb_addr, tvb, 0, 0, str_src_addr);
4759 proto_item_set_hidden(sub_item);
4760
4761 sub_item = proto_tree_add_string(tree, hf_usb_dst, tvb, 0, 0, str_dst_addr);
4762 proto_item_set_generated(sub_item);
4763
4764 sub_item = proto_tree_add_string(tree, hf_usb_addr, tvb, 0, 0, str_dst_addr);
4765 proto_item_set_hidden(sub_item);
4766}
4767
4768
4769/* Gets the transfer info for a given packet
4770 * Generates transfer info if none exists yet
4771 * Also adds request/response info to the tree for the given packet */
4772static usb_trans_info_t
4773*usb_get_trans_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
4774 usb_header_t header_type, urb_info_t *urb, uint64_t usb_id)
4775{
4776 usb_trans_info_t *usb_trans_info;
4777 proto_item *ti;
4778 nstime_t t, deltat;
4779 wmem_tree_key_t key[3];
4780
4781 /* request/response matching so we can keep track of transaction specific
4782 * data.
4783 */
4784 key[0].length = 2;
4785 key[0].key = (uint32_t *)&usb_id;
4786 key[1].length = 1;
4787 key[1].key = &pinfo->num;
4788 key[2].length = 0;
4789 key[2].key = NULL((void*)0);
4790
4791 if (urb->is_request
24.1
Field 'is_request' is false
) {
25
Taking false branch
4792 /* this is a request */
4793 usb_trans_info = (usb_trans_info_t *)wmem_tree_lookup32_array(urb->conv->transactions, key);
4794 if (!usb_trans_info) {
4795 usb_trans_info = wmem_new0(wmem_file_scope(), usb_trans_info_t)((usb_trans_info_t*)wmem_alloc0((wmem_file_scope()), sizeof(usb_trans_info_t
)))
;
4796 usb_trans_info->request_in = pinfo->num;
4797 usb_trans_info->req_time = pinfo->abs_ts;
4798 usb_trans_info->header_type = header_type;
4799 usb_trans_info->usb_id = usb_id;
4800
4801 wmem_tree_insert32_array(urb->conv->transactions, key, usb_trans_info);
4802 }
4803
4804 if (usb_trans_info->response_in) {
4805 ti = proto_tree_add_uint(tree, hf_usb_response_in, tvb, 0, 0, usb_trans_info->response_in);
4806 proto_item_set_generated(ti);
4807 }
4808
4809 } else {
4810 /* this is a response */
4811 if (pinfo->fd->visited) {
26
Assuming field 'visited' is 0
27
Taking false branch
4812 usb_trans_info = (usb_trans_info_t *)wmem_tree_lookup32_array(urb->conv->transactions, key);
4813
4814 } else {
4815 usb_trans_info = (usb_trans_info_t *)wmem_tree_lookup32_array_le(urb->conv->transactions, key);
4816 if (usb_trans_info) {
28
Assuming 'usb_trans_info' is null
4817 if (usb_trans_info->usb_id == usb_id) {
4818 if (usb_trans_info->response_in == 0) {
4819 /* USBPcap generates 2 frames for response; store the first one */
4820 usb_trans_info->response_in = pinfo->num;
4821 }
4822 wmem_tree_insert32_array(urb->conv->transactions, key, usb_trans_info);
4823 } else {
4824 usb_trans_info = NULL((void*)0);
4825 }
4826 }
4827 }
4828
4829 if (usb_trans_info
28.1
'usb_trans_info' is null
&& usb_trans_info->request_in) {
4830
4831 ti = proto_tree_add_uint(tree, hf_usb_request_in, tvb, 0, 0, usb_trans_info->request_in);
4832 proto_item_set_generated(ti);
4833
4834 if (pinfo->fd) {
4835 uint8_t transfer_type = urb->transfer_type;
4836 if (transfer_type == URB_UNKNOWN0xFF)
4837 transfer_type = urb->conv->descriptor_transfer_type;
4838 if (transfer_type == URB_CONTROL0x2)
4839 mark_frame_as_depended_upon(pinfo->fd, usb_trans_info->request_in);
4840 }
4841
4842 t = pinfo->abs_ts;
4843 nstime_delta(&deltat, &t, &usb_trans_info->req_time);
4844 ti = proto_tree_add_time(tree, hf_usb_time, tvb, 0, 0, &deltat);
4845 proto_item_set_generated(ti);
4846 }
4847 }
4848
4849 return usb_trans_info;
29
Returning without writing to 'urb->transfer_type', which participates in a condition later
30
Returning without writing to 'urb->conv'
4850}
4851
4852
4853/* dissect a group of isochronous packets inside an usb packet in
4854 usbpcap format */
4855#define MAX_ISO_PACKETS100000 100000 // Arbitrary
4856static int
4857dissect_usbpcap_iso_packets(packet_info *pinfo _U___attribute__((unused)), proto_tree *urb_tree, uint8_t urb_type,
4858 tvbuff_t *tvb, int offset, uint32_t win32_data_len, urb_info_t *urb)
4859{
4860 uint32_t i;
4861 uint32_t num_packets;
4862 int data_start_offset;
4863 proto_item *num_packets_ti, *urb_tree_ti;
4864
4865 proto_tree_add_item(urb_tree, hf_usb_win32_iso_start_frame, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
4866 offset += 4;
4867
4868 num_packets_ti = proto_tree_add_item_ret_uint(urb_tree, hf_usb_win32_iso_num_packets, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000, &num_packets);
4869 offset += 4;
4870
4871 proto_tree_add_item(urb_tree, hf_usb_win32_iso_error_count, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
4872 offset += 4;
4873
4874 if (num_packets > MAX_ISO_PACKETS100000) {
4875 expert_add_info_format(pinfo, num_packets_ti, &ei_usb_bad_length, "Too many isochronous transfer packets (%u)", num_packets);
4876 return tvb_captured_length(tvb);
4877 }
4878
4879 data_start_offset = offset + 12 * num_packets;
4880 urb_tree_ti = proto_tree_get_parent(urb_tree);
4881 proto_item_set_len(urb_tree_ti, data_start_offset);
4882
4883 for (i = 0; i < num_packets; i++) {
4884 uint32_t this_offset;
4885 uint32_t next_offset;
4886 uint32_t iso_len;
4887 proto_item *iso_packet_ti, *ti;
4888 proto_tree *iso_packet_tree;
4889
4890 iso_packet_ti = proto_tree_add_protocol_format(
4891 proto_tree_get_root(urb_tree), proto_usb,
4892 tvb, offset, 12, "USB isochronous packet");
4893 iso_packet_tree = proto_item_add_subtree(iso_packet_ti, ett_usb_win32_iso_packet);
4894
4895 this_offset = tvb_get_letohl(tvb, offset);
4896 if (num_packets - i == 1) {
4897 /* this is the last packet */
4898 next_offset = win32_data_len;
4899 } else {
4900 /* there is next packet */
4901 next_offset = tvb_get_letohl(tvb, offset + 12);
4902 }
4903
4904 if (next_offset > this_offset) {
4905 iso_len = next_offset - this_offset;
4906 } else {
4907 iso_len = 0;
4908 }
4909
4910 /* If this packet does not contain isochronous data, do not try to display it */
4911 if (!((urb->is_request && urb->direction==P2P_DIR_SENT0) ||
4912 (!urb->is_request && urb->direction==P2P_DIR_RECV1))) {
4913 iso_len = 0;
4914 }
4915
4916 proto_tree_add_item(iso_packet_tree, hf_usb_win32_iso_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
4917 offset += 4;
4918
4919 ti = proto_tree_add_item(iso_packet_tree, hf_usb_win32_iso_length, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
4920 if (urb->direction==P2P_DIR_SENT0) {
4921 /* Isochronous OUT transfer */
4922 proto_item_append_text(ti, " (not used)");
4923 } else {
4924 /* Isochronous IN transfer.
4925 * Length field is being set by host controller.
4926 */
4927 if (urb->is_request) {
4928 /* Length was not yet set */
4929 proto_item_append_text(ti, " (irrelevant)");
4930 } else {
4931 /* Length was set and (should be) valid */
4932 proto_item_append_text(ti, " (relevant)");
4933 iso_len = tvb_get_letohl(tvb, offset);
4934 }
4935 }
4936 offset += 4;
4937
4938 ti = proto_tree_add_item(iso_packet_tree, hf_usb_win32_iso_status, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
4939 if (urb_type == URB_SUBMIT'S') {
4940 proto_item_append_text(ti, " (irrelevant)");
4941 } else {
4942 proto_item_append_text(ti, " (relevant)");
4943 }
4944 offset += 4;
4945
4946 if (iso_len && data_start_offset + this_offset + iso_len <= tvb_captured_length(tvb)) {
4947 proto_tree_add_item(iso_packet_tree, hf_usb_iso_data, tvb, (int)(data_start_offset + this_offset), (int)iso_len, ENC_NA0x00000000);
4948 proto_tree_set_appendix(iso_packet_tree, tvb, data_start_offset + this_offset, iso_len);
4949 }
4950 }
4951
4952 if ((urb->is_request && urb->direction==P2P_DIR_SENT0) ||
4953 (!urb->is_request && urb->direction==P2P_DIR_RECV1)) {
4954 /* We have dissected all the isochronous data */
4955 offset += win32_data_len;
4956 }
4957
4958 return offset;
4959}
4960
4961
4962static int
4963dissect_linux_usb_iso_transfer(packet_info *pinfo _U___attribute__((unused)), proto_tree *urb_tree,
4964 usb_header_t header_type, tvbuff_t *tvb, int offset,
4965 urb_info_t *urb)
4966{
4967 uint32_t iso_numdesc = 0;
4968 proto_item *tii;
4969 uint32_t i;
4970 unsigned data_base;
4971 int32_t iso_status;
4972 uint32_t iso_off = 0;
4973 uint32_t iso_len = 0;
4974
4975 tii = proto_tree_add_uint(urb_tree, hf_usb_bInterfaceClass, tvb, offset, 0, urb->conv->interfaceClass);
4976 proto_item_set_generated(tii);
4977
4978 /* All fields which belong to Linux usbmon headers are in host-endian
4979 * byte order. The fields coming from the USB communication are in little
4980 * endian format (see usb_20.pdf, chapter 8.1 Byte/Bit ordering).
4981 *
4982 * When a capture file is transferred to a host with different endianness
4983 * than packet was captured then the necessary swapping happens in
4984 * wiretap/pcap-common.c, pcap_byteswap_linux_usb_pseudoheader().
4985 */
4986
4987 /* iso urbs on linux can't possibly contain a setup packet
4988 see mon_bin_event() in the linux kernel */
4989
4990 proto_tree_add_item(urb_tree, hf_usb_iso_error_count, tvb, offset, 4, ENC_HOST_ENDIAN0x80000000);
4991 offset += 4;
4992
4993 proto_tree_add_item_ret_uint(urb_tree, hf_usb_iso_numdesc, tvb, offset, 4, ENC_HOST_ENDIAN0x80000000, &iso_numdesc);
4994 offset += 4;
4995
4996 if (header_type == USB_HEADER_LINUX_64_BYTES) {
4997 offset = dissect_linux_usb_pseudo_header_ext(tvb, offset, pinfo, urb_tree);
4998 }
4999
5000 data_base = offset + iso_numdesc*16;
5001 for (i = 0; i<iso_numdesc; i++) {
5002 proto_item *iso_desc_ti;
5003 proto_tree *iso_desc_tree;
5004
5005 iso_desc_ti = proto_tree_add_protocol_format(urb_tree, proto_usb, tvb, offset,
5006 16, "USB isodesc %u", i);
5007 iso_desc_tree = proto_item_add_subtree(iso_desc_ti, ett_usb_isodesc);
5008
5009 proto_tree_add_item_ret_int(iso_desc_tree, hf_usb_iso_status, tvb, offset, 4, ENC_HOST_ENDIAN0x80000000, &iso_status);
5010 proto_item_append_text(iso_desc_ti, " [%s]", val_to_str_ext(pinfo->pool, (uint32_t)iso_status, &linux_negative_errno_vals_ext, "Error %d"));
5011 offset += 4;
5012
5013 proto_tree_add_item_ret_uint(iso_desc_tree, hf_usb_iso_off, tvb, offset, 4, ENC_HOST_ENDIAN0x80000000, &iso_off);
5014 offset += 4;
5015
5016 proto_tree_add_item_ret_uint(iso_desc_tree, hf_usb_iso_len, tvb, offset, 4, ENC_HOST_ENDIAN0x80000000, &iso_len);
5017 if (iso_len != 0)
5018 proto_item_append_text(iso_desc_ti, " (%u bytes)", iso_len);
5019 offset += 4;
5020
5021 /* Show the ISO data if we captured them and either the status
5022 is OK or the packet is sent from host to device.
5023 The Linux kernel sets the status field in outgoing isochronous
5024 URBs to -EXDEV and fills the data part with valid data.
5025 */
5026 if ((pinfo->p2p_dir==P2P_DIR_SENT0 || !iso_status) &&
5027 iso_len && data_base + iso_off + iso_len <= tvb_captured_length(tvb)) {
5028 proto_tree_add_item(iso_desc_tree, hf_usb_iso_data, tvb, data_base + iso_off, iso_len, ENC_NA0x00000000);
5029 proto_tree_set_appendix(iso_desc_tree, tvb, data_base+iso_off, iso_len);
5030 }
5031
5032 proto_tree_add_item(iso_desc_tree, hf_usb_iso_pad, tvb, offset, 4, ENC_HOST_ENDIAN0x80000000);
5033 offset += 4;
5034 }
5035
5036 /* we jump to the end of the last iso data chunk
5037 this assumes that the iso data starts immediately after the
5038 iso descriptors
5039 we have to use the offsets from the last iso descriptor, we can't keep
5040 track of the offset ourselves as there may be gaps
5041 between data packets in the transfer buffer */
5042 return data_base+iso_off+iso_len;
5043}
5044
5045static int
5046dissect_usbip_iso_transfer(packet_info *pinfo _U___attribute__((unused)), proto_tree *urb_tree,
5047 tvbuff_t *tvb, int offset, uint32_t iso_numdesc, uint32_t desc_offset,
5048 urb_info_t *urb)
5049{
5050 proto_item *tii;
5051 uint32_t i;
5052 unsigned data_base;
5053 uint32_t iso_off = 0;
5054 uint32_t iso_len = 0;
5055
5056 tii = proto_tree_add_uint(urb_tree, hf_usb_bInterfaceClass, tvb, offset, 0, urb->conv->interfaceClass);
5057 proto_item_set_generated(tii);
5058
5059 /* All fields which belong to usbip are in big-endian byte order.
5060 * unlike the linux kernel, the usb isoc descriptor is appended at
5061 * the end of the isoc data. We have to reassemble the pdus and jump
5062 * to the end (actual_length) and the remaining data is the isoc
5063 * descriptor.
5064 */
5065
5066 data_base = offset;
5067 for (i = 0; i<iso_numdesc; i++) {
5068 proto_item *iso_desc_ti;
5069 proto_tree *iso_desc_tree;
5070 int32_t iso_status;
5071
5072 iso_desc_ti = proto_tree_add_protocol_format(urb_tree, proto_usb, tvb, desc_offset,
5073 16, "USB isodesc %u", i);
5074 iso_desc_tree = proto_item_add_subtree(iso_desc_ti, ett_usb_isodesc);
5075
5076 proto_tree_add_item_ret_uint(iso_desc_tree, hf_usb_iso_off, tvb, desc_offset, 4, ENC_BIG_ENDIAN0x00000000, &iso_off);
5077 desc_offset += 4;
5078
5079 proto_tree_add_item(iso_desc_tree, hf_usb_iso_len, tvb, desc_offset, 4, ENC_BIG_ENDIAN0x00000000);
5080 desc_offset += 4;
5081
5082 proto_tree_add_item_ret_uint(iso_desc_tree, hf_usb_iso_actual_len, tvb, desc_offset, 4, ENC_BIG_ENDIAN0x00000000, &iso_len);
5083 desc_offset += 4;
5084
5085 proto_tree_add_item_ret_int(iso_desc_tree, hf_usb_iso_status, tvb, desc_offset, 4, ENC_BIG_ENDIAN0x00000000, &iso_status);
5086 proto_item_append_text(iso_desc_ti, " [%s]", val_to_str_ext(pinfo->pool, iso_status, &linux_negative_errno_vals_ext, "Error %d"));
5087 desc_offset += 4;
5088
5089 if (iso_len > 0)
5090 proto_item_append_text(iso_desc_ti, " (%u bytes)", iso_len);
5091
5092 /* Show the ISO data if we captured them and either the status
5093 is OK or the packet is sent from host to device.
5094 The Linux kernel sets the status field in outgoing isochronous
5095 URBs to -EXDEV and fills the data part with valid data.
5096 */
5097 if ((pinfo->p2p_dir==P2P_DIR_SENT0 || !iso_status) &&
5098 iso_len && data_base + iso_off + iso_len <= tvb_reported_length(tvb)) {
5099 proto_tree_add_item(iso_desc_tree, hf_usb_iso_data, tvb, (unsigned) data_base + iso_off, iso_len, ENC_NA0x00000000);
5100 proto_tree_set_appendix(iso_desc_tree, tvb, data_base + iso_off, iso_len);
5101 }
5102 }
5103 return desc_offset;
5104}
5105
5106static int
5107dissect_darwin_usb_iso_transfer(packet_info *pinfo _U___attribute__((unused)), proto_tree *tree, usb_header_t header_type _U___attribute__((unused)),
5108 uint8_t urb_type _U___attribute__((unused)), tvbuff_t *tvb, int32_t offset, urb_info_t *urb)
5109{
5110 uint32_t frame_length;
5111 uint32_t frame_header_length;
5112 uint32_t status;
5113 uint32_t iso_tree_start;
5114 uint32_t i;
5115 uint32_t iso_numdesc;
5116 uint32_t len;
5117 proto_item *tii;
5118
5119 len = (int32_t)tvb_captured_length(tvb);
5120 len -= offset;
5121
5122 tii = proto_tree_add_uint(tree, hf_usb_bInterfaceClass, tvb, offset, 0, urb->conv->interfaceClass);
5123 proto_item_set_generated(tii);
5124
5125 status = tvb_get_uint32(tvb, 8, ENC_LITTLE_ENDIAN0x80000000);
5126 iso_numdesc = tvb_get_uint32(tvb, 12, ENC_LITTLE_ENDIAN0x80000000);
5127
5128 iso_tree_start = offset;
5129 for (i = 0; (i < iso_numdesc) && (len > 8 /* header len + frame len */); i++) {
5130 proto_item *iso_desc_ti;
5131 proto_tree *iso_desc_tree;
5132
5133 /* Fetch ISO descriptor fields stored in little-endian byte order. */
5134 frame_header_length = tvb_get_uint32(tvb, offset, ENC_LITTLE_ENDIAN0x80000000);
5135 frame_length = tvb_get_uint32(tvb, offset + 4, ENC_LITTLE_ENDIAN0x80000000);
5136
5137 if ((len < frame_header_length) || (frame_header_length < 20)) {
5138 break;
5139 }
5140
5141 iso_desc_ti = proto_tree_add_protocol_format(tree, proto_usb, tvb, offset,
5142 20, "Frame %u", i);
5143
5144 iso_desc_tree = proto_item_add_subtree(iso_desc_ti, ett_usb_isodesc);
5145
5146 proto_tree_add_item(iso_desc_tree, hf_usb_darwin_iso_frame_number, tvb, offset + 12, 8, ENC_LITTLE_ENDIAN0x80000000);
5147
5148 proto_tree_add_item(iso_desc_tree, hf_usb_iso_len, tvb, offset + 4, 4, ENC_LITTLE_ENDIAN0x80000000);
5149
5150 if (urb->is_request == false0) {
5151 proto_tree_add_item(iso_desc_tree, hf_usb_darwin_iso_timestamp, tvb, offset + 20, 8, ENC_LITTLE_ENDIAN0x80000000);
5152 proto_tree_add_item_ret_uint(iso_desc_tree, hf_usb_darwin_iso_status, tvb, offset + 8, 4, ENC_LITTLE_ENDIAN0x80000000, &status);
5153
5154 proto_item_append_text(iso_desc_ti, " [%s]", val_to_str_ext(pinfo->pool, status, &usb_darwin_status_vals_ext, "Error %d"));
5155
5156 /* Data */
5157 if (frame_length > len) {
5158 frame_length = len;
5159 }
5160
5161 proto_tree_add_item(iso_desc_tree, hf_usb_iso_data, tvb, offset + frame_header_length, frame_length, ENC_NA0x00000000);
5162 proto_tree_set_appendix(iso_desc_tree, tvb, iso_tree_start, offset - iso_tree_start);
5163
5164 len -= frame_length;
5165 offset += frame_length;
5166 }
5167
5168 /* Padding to align the next header */
5169 offset += frame_header_length;
5170 offset = WS_ROUNDUP_4(offset)(((offset) + ((unsigned)(4U-1U))) & (~((unsigned)(4U-1U))
))
;
5171 iso_tree_start = offset;
5172
5173 len -= frame_header_length;
5174 }
5175
5176 return offset;
5177}
5178
5179static int
5180dissect_usb_payload(tvbuff_t *tvb, packet_info *pinfo,
5181 proto_tree *parent, proto_tree *tree,
5182 urb_info_t *urb, uint8_t urb_type,
5183 int offset, uint16_t device_address)
5184{
5185 wmem_tree_key_t key[4];
5186 uint32_t k_frame_number;
5187 uint32_t k_device_address;
5188 uint32_t k_bus_id;
5189 device_product_data_t *device_product_data = NULL((void*)0);
5190 device_protocol_data_t *device_protocol_data = NULL((void*)0);
5191 tvbuff_t *next_tvb = NULL((void*)0);
5192
5193 k_frame_number = pinfo->num;
5194 k_device_address = device_address;
5195 k_bus_id = urb->bus_id;
5196
5197 key[0].length = 1;
5198 key[0].key = &k_device_address;
5199 key[1].length = 1;
5200 key[1].key = &k_bus_id;
5201 key[2].length = 1;
5202 key[2].key = &k_frame_number;
5203 key[3].length = 0;
5204 key[3].key = NULL((void*)0);
5205
5206 device_product_data = (device_product_data_t *) wmem_tree_lookup32_array_le(device_to_product_table, key);
5207 if (device_product_data && device_product_data->bus_id == urb->bus_id &&
5208 device_product_data->device_address == device_address) {
5209 p_add_proto_data(pinfo->pool, pinfo, proto_usb, USB_VENDOR_ID2, GUINT_TO_POINTER((unsigned)device_product_data->vendor)((gpointer) (gulong) ((unsigned)device_product_data->vendor
))
);
5210 p_add_proto_data(pinfo->pool, pinfo, proto_usb, USB_PRODUCT_ID3, GUINT_TO_POINTER((unsigned)device_product_data->product)((gpointer) (gulong) ((unsigned)device_product_data->product
))
);
5211 urb->conv->deviceVendor = device_product_data->vendor;
5212 urb->conv->deviceProduct = device_product_data->product;
5213 urb->conv->deviceVersion = device_product_data->device;
5214 }
5215
5216 device_protocol_data = (device_protocol_data_t *) wmem_tree_lookup32_array_le(device_to_protocol_table, key);
5217 if (device_protocol_data && device_protocol_data->bus_id == urb->bus_id &&
5218 device_protocol_data->device_address == device_address) {
5219 p_add_proto_data(pinfo->pool, pinfo, proto_usb, USB_DEVICE_CLASS4, GUINT_TO_POINTER(device_protocol_data->protocol >> 16)((gpointer) (gulong) (device_protocol_data->protocol >>
16))
);
5220 p_add_proto_data(pinfo->pool, pinfo, proto_usb, USB_DEVICE_SUBCLASS5, GUINT_TO_POINTER((device_protocol_data->protocol >> 8) & 0xFF)((gpointer) (gulong) ((device_protocol_data->protocol >>
8) & 0xFF))
);
5221 p_add_proto_data(pinfo->pool, pinfo, proto_usb, USB_DEVICE_PROTOCOL6, GUINT_TO_POINTER(device_protocol_data->protocol & 0xFF)((gpointer) (gulong) (device_protocol_data->protocol &
0xFF))
);
5222 urb->device_protocol = device_protocol_data->protocol;
5223 }
5224
5225 p_add_proto_data(pinfo->pool, pinfo, proto_usb, USB_BUS_ID0, GUINT_TO_POINTER((unsigned)urb->bus_id)((gpointer) (gulong) ((unsigned)urb->bus_id)));
5226 p_add_proto_data(pinfo->pool, pinfo, proto_usb, USB_DEVICE_ADDRESS1, GUINT_TO_POINTER((unsigned)device_address)((gpointer) (gulong) ((unsigned)device_address)));
5227
5228 if (tvb_captured_length_remaining(tvb, offset) > 0) {
5229 next_tvb = tvb_new_subset_remaining(tvb, offset);
5230 offset += try_dissect_next_protocol(parent, next_tvb, pinfo, urb, urb_type, tree, NULL((void*)0));
5231 }
5232
5233 if (tvb_captured_length_remaining(tvb, offset) > 0) {
5234 /* There is still leftover capture data to add (padding?) */
5235 proto_tree_add_item(parent, hf_usb_capdata, tvb, offset, -1, ENC_NA0x00000000);
5236 }
5237
5238 return offset;
5239}
5240
5241static int dissect_freebsd_usb_pseudo_header(tvbuff_t *tvb, packet_info *pinfo,
5242 proto_tree *tree,
5243 urb_info_t *urb) {
5244 uint8_t freebsd_urb_type;
5245 uint8_t freebsd_transfer_type;
5246 uint8_t endpoint_byte;
5247 uint8_t freebsd_speed;
5248 uint8_t transfer_type_and_direction;
5249
5250 proto_tree_add_item(tree, hf_usb_totlen, tvb, 0, 4, ENC_LITTLE_ENDIAN0x80000000);
5251 proto_tree_add_item(tree, hf_usb_busunit, tvb, 4, 4, ENC_LITTLE_ENDIAN0x80000000);
5252 urb->bus_id = (uint16_t)tvb_get_letohl(tvb, 4);
5253
5254 proto_tree_add_item(tree, hf_usb_address, tvb, 8, 1, ENC_LITTLE_ENDIAN0x80000000);
5255 proto_tree_add_item(tree, hf_usb_device_address, tvb, 8, 1, ENC_LITTLE_ENDIAN0x80000000);
5256 urb->device_address = (uint16_t)tvb_get_uint8(tvb, 8);
5257
5258 proto_tree_add_item(tree, hf_usb_mode, tvb, 9, 1, ENC_LITTLE_ENDIAN0x80000000);
5259
5260 proto_tree_add_item_ret_uint8(tree, hf_usb_freebsd_urb_type, tvb, 10, 1, ENC_LITTLE_ENDIAN0x80000000, &freebsd_urb_type);
5261 urb->is_request = (freebsd_urb_type == FREEBSD_URB_SUBMIT0);
14
Assuming 'freebsd_urb_type' is not equal to FREEBSD_URB_SUBMIT
5262
5263 proto_tree_add_item_ret_uint8(tree, hf_usb_freebsd_transfer_type, tvb, 11, 1, ENC_LITTLE_ENDIAN0x80000000, &freebsd_transfer_type);
5264 switch (freebsd_transfer_type) {
15
Control jumps to the 'default' case at line 5277
5265 case FREEBSD_URB_ISOCHRONOUS1:
5266 urb->transfer_type = URB_ISOCHRONOUS0x0;
5267 break;
5268 case FREEBSD_URB_INTERRUPT3:
5269 urb->transfer_type = URB_INTERRUPT0x1;
5270 break;
5271 case FREEBSD_URB_CONTROL0:
5272 urb->transfer_type = URB_CONTROL0x2;
5273 break;
5274 case FREEBSD_URB_BULK2:
5275 urb->transfer_type = URB_BULK0x3;
5276 break;
5277 default:
5278 urb->transfer_type = URB_UNKNOWN0xFF;
5279 break;
16
Execution continues on line 5282
5280 }
5281
5282 proto_tree_add_bitmask(tree, tvb, 12, hf_usb_xferflags, ett_usb_xferflags,
5283 usb_xferflags_fields, ENC_LITTLE_ENDIAN0x80000000);
5284 proto_tree_add_bitmask(tree, tvb, 16, hf_usb_xferstatus, ett_usb_xferstatus,
5285 usb_xferstatus_fields, ENC_LITTLE_ENDIAN0x80000000);
5286 proto_tree_add_item(tree, hf_usb_error, tvb, 20, 4, ENC_LITTLE_ENDIAN0x80000000);
5287 proto_tree_add_item(tree, hf_usb_interval, tvb, 24, 4, ENC_LITTLE_ENDIAN0x80000000);
5288 proto_tree_add_item(tree, hf_usb_nframes, tvb, 28, 4, ENC_LITTLE_ENDIAN0x80000000);
5289 proto_tree_add_item(tree, hf_usb_packet_size, tvb, 32, 4, ENC_LITTLE_ENDIAN0x80000000);
5290 proto_tree_add_item(tree, hf_usb_packet_count, tvb, 36, 4, ENC_LITTLE_ENDIAN0x80000000);
5291
5292 endpoint_byte = tvb_get_uint8(tvb, 40);
5293 urb->endpoint = endpoint_byte;
5294 urb->direction =
5295 (endpoint_byte & URB_TRANSFER_IN0x80) ? P2P_DIR_RECV1 : P2P_DIR_SENT0;
17
Assuming the condition is false
18
'?' condition is false
5296 proto_tree_add_bitmask(tree, tvb, 40, hf_usb_endpoint_address,
5297 ett_usb_endpoint, usb_endpoint_fields, ENC_NA0x00000000);
5298
5299 freebsd_speed = tvb_get_uint8(tvb, 44);
5300 proto_tree_add_item(tree, hf_usb_speed, tvb, 44, 1, ENC_LITTLE_ENDIAN0x80000000);
5301 switch (freebsd_speed) {
19
Control jumps to the 'default' case at line 5311
5302 case FREEBSD_SPEED_LOW1:
5303 urb->speed = USB_SPEED_LOW;
5304 break;
5305 case FREEBSD_SPEED_FULL2:
5306 urb->speed = USB_SPEED_FULL;
5307 break;
5308 case FREEBSD_SPEED_HIGH3:
5309 urb->speed = USB_SPEED_HIGH;
5310 break;
5311 default:
5312 urb->speed = USB_SPEED_UNKNOWN;
5313 break;
20
Execution continues on line 5316
5314 }
5315
5316 urb->is_setup = false0;
5317
5318 transfer_type_and_direction =
5319 (urb->transfer_type & 0x7F) | (endpoint_byte & 0x80);
5320 col_append_str(pinfo->cinfo, COL_INFO,
5321 val_to_str(pinfo->pool, transfer_type_and_direction,
5322 usb_transfer_type_and_direction_vals,
5323 "Unknown type %x"));
5324
5325 return 128;
21
Returning without writing to 'urb->conv'
5326}
5327
5328static int dissect_freebsd_usb_frames(proto_tree *tree, tvbuff_t *tvb,
5329 int offset, packet_info *pinfo,
5330 proto_tree *parent, urb_info_t *urb,
5331 uint8_t urb_type) {
5332 uint32_t nframes = tvb_get_letohl(tvb, 28);
5333 uint32_t i;
5334
5335 for (i = 0; i < nframes; i++) {
39
Assuming 'i' is < 'nframes'
40
Loop condition is true. Entering loop body
5336 proto_item *ti;
5337 proto_tree *frame_tree;
5338 uint32_t framelen;
5339 uint64_t frameflags;
5340
5341 frame_tree = proto_tree_add_subtree_format(tree, tvb, offset, -1,
5342 ett_usb_frame, &ti,
5343 "Frame %u", i);
5344 proto_tree_add_item_ret_uint(frame_tree, hf_usb_frame_length,
5345 tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000,
5346 &framelen);
5347 offset += 4;
5348 proto_tree_add_bitmask_ret_uint64(frame_tree, tvb, offset,
5349 hf_usb_frame_flags,
5350 ett_usb_frame_flags,
5351 usb_frame_flags_fields,
5352 ENC_LITTLE_ENDIAN0x80000000, &frameflags);
5353 offset += 4;
5354 if (frameflags & FREEBSD_FRAMEFLAG_DATA_FOLLOWS0x00000002) {
41
Assuming the condition is true
42
Taking true branch
5355 tvbuff_t *frame_tvb = tvb_new_subset_length(tvb, offset, framelen);
5356 int dissected = try_dissect_next_protocol(
43
Calling 'try_dissect_next_protocol'
5357 parent, frame_tvb, pinfo, urb, urb_type, frame_tree, NULL((void*)0));
5358 if ((unsigned)dissected < framelen) {
5359 proto_tree_add_item(frame_tree, hf_usb_frame_data, tvb,
5360 offset + dissected, framelen - dissected,
5361 ENC_NA0x00000000);
5362 }
5363 offset += WS_ROUNDUP_4(framelen)(((framelen) + ((unsigned)(4U-1U))) & (~((unsigned)(4U-1U
))))
;
5364 }
5365 proto_item_set_end(ti, tvb, offset);
5366 }
5367 return offset;
5368}
5369
5370/* Build a flat TVB from all frame payloads (frames with
5371 * FREEBSD_FRAMEFLAG_DATA_FOLLOWS). Frame header fields (length + flags) are
5372 * added to their per-frame subtrees in tree. Raw payload bytes are shown under
5373 * each frame subtree via hf_usb_frame_data. Returns the offset past the last
5374 * frame and, via *out_tvb, a single TVB covering all concatenated payloads
5375 * (NULL when no frame carried data). */
5376static int freebsd_collect_frame_data(proto_tree *tree, tvbuff_t *tvb,
5377 int offset, packet_info *pinfo,
5378 tvbuff_t **out_tvb) {
5379 uint32_t nframes = tvb_get_letohl(tvb, 28);
5380 tvbuff_t *assembled = NULL((void*)0);
5381 tvbuff_t *composite = NULL((void*)0);
5382 unsigned data_frame_count = 0;
5383 uint32_t i;
5384
5385 for (i = 0; i < nframes; i++) {
5386 proto_item *ti;
5387 proto_tree *frame_tree;
5388 uint32_t framelen;
5389 uint64_t frameflags;
5390
5391 frame_tree = proto_tree_add_subtree_format(tree, tvb, offset, -1,
5392 ett_usb_frame, &ti,
5393 "Frame %u", i);
5394 proto_tree_add_item_ret_uint(frame_tree, hf_usb_frame_length,
5395 tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000,
5396 &framelen);
5397 offset += 4;
5398 proto_tree_add_bitmask_ret_uint64(frame_tree, tvb, offset,
5399 hf_usb_frame_flags,
5400 ett_usb_frame_flags,
5401 usb_frame_flags_fields,
5402 ENC_LITTLE_ENDIAN0x80000000, &frameflags);
5403 offset += 4;
5404 if (frameflags & FREEBSD_FRAMEFLAG_DATA_FOLLOWS0x00000002) {
5405 tvbuff_t *chunk = tvb_new_subset_length(tvb, offset, framelen);
5406 proto_tree_add_item(frame_tree, hf_usb_frame_data, tvb, offset,
5407 framelen, ENC_NA0x00000000);
5408 if (data_frame_count == 0) {
5409 assembled = chunk;
5410 } else {
5411 if (data_frame_count == 1) {
5412 composite = tvb_new_composite();
5413 tvb_composite_append(composite, assembled);
5414 }
5415 tvb_composite_append(composite, chunk);
5416 }
5417 data_frame_count++;
5418 offset += WS_ROUNDUP_4(framelen)(((framelen) + ((unsigned)(4U-1U))) & (~((unsigned)(4U-1U
))))
;
5419 }
5420 proto_item_set_end(ti, tvb, offset);
5421 }
5422
5423 if (data_frame_count > 1) {
5424 tvb_composite_finalize(composite);
5425 add_new_data_source(pinfo, composite, "FreeBSD USB payload");
5426 assembled = composite;
5427 }
5428
5429 *out_tvb = assembled;
5430 return offset;
5431}
5432
5433/* Routes a FreeBSD control SUBMIT through dissect_usb_setup_request when
5434 * FREEBSD_STATUS_CONTROL_HDR is set in xferstatus (SETUP stage) so that
5435 * the 8-byte USB setup packet is decoded and the transaction is recorded for
5436 * response matching. All frame payloads are assembled into a single TVB
5437 * before the subdissector is called, preventing malformed-packet errors
5438 * when response data spans multiple frames. */
5439static int dissect_freebsd_usb_control_request(
5440 proto_tree *tree, tvbuff_t *tvb, int offset, packet_info *pinfo,
5441 proto_tree *parent, urb_info_t *urb, uint8_t urb_type, uint64_t usb_id) {
5442 uint32_t xferstatus = tvb_get_letohl(tvb, 16);
5443 bool_Bool is_setup = (xferstatus & FREEBSD_STATUS_CONTROL_HDR0x00000100) != 0;
5444 tvbuff_t *assembled = NULL((void*)0);
5445
5446 offset = freebsd_collect_frame_data(tree, tvb, offset, pinfo, &assembled);
5447
5448 if (assembled != NULL((void*)0)) {
5449 if (is_setup) {
5450 /* SETUP stage: assembled TVB begins with the 8-byte USB setup
5451 * packet (possibly followed by OUT data in later frames).
5452 * dissect_usb_setup_request records the transaction so that the
5453 * matching COMPLETE can be decoded via dissect_usb_setup_response.
5454 */
5455 dissect_usb_setup_request(pinfo, tree, assembled, 0, urb_type, urb,
5456 USB_HEADER_FREEBSD, usb_id);
5457 } else {
5458 /* DATA stage: no setup packet header, pass straight to the
5459 * normal payload path. */
5460 int dissected = try_dissect_next_protocol(
5461 parent, assembled, pinfo, urb, urb_type, tree, NULL((void*)0));
5462 if (dissected < (int)tvb_captured_length(assembled)) {
5463 proto_tree_add_item(tree, hf_usb_frame_data, assembled,
5464 dissected, -1, ENC_NA0x00000000);
5465 }
5466 }
5467 }
5468 return offset;
5469}
5470
5471/* Routes a FreeBSD control COMPLETE through dissect_usb_setup_response so
5472 * that standard responses (GET_DESCRIPTOR etc.) are decoded via
5473 * dissect_usb_standard_setup_response and class/vendor responses reach
5474 * try_dissect_next_protocol. All frame payloads are assembled into a
5475 * single TVB before calling the subdissector so that responses spanning
5476 * multiple frames do not trigger malformed-packet errors. */
5477static int
5478dissect_freebsd_usb_control_response(proto_tree *tree, tvbuff_t *tvb, int offset,
5479 packet_info *pinfo,
5480 urb_info_t *urb, uint8_t urb_type)
5481{
5482 tvbuff_t *assembled = NULL((void*)0);
5483
5484 offset = freebsd_collect_frame_data(tree, tvb, offset, pinfo, &assembled);
5485
5486 if (assembled != NULL((void*)0)) {
5487 dissect_usb_setup_response(pinfo, tree, assembled, 0, urb_type, urb);
5488 }
5489 return offset;
5490}
5491
5492static int dissect_freebsd_usb(tvbuff_t *tvb, packet_info *pinfo,
5493 proto_tree *parent, void *data _U___attribute__((unused))) {
5494 dissect_usb_common(tvb, pinfo, parent, USB_HEADER_FREEBSD, NULL((void*)0));
5495 return tvb_captured_length(tvb);
5496}
5497
5498static int
5499netmon_HostController2(proto_tree *tree, tvbuff_t *tvb, unsigned offset, uint16_t flags)
5500{
5501 proto_tree *host_tree;
5502
5503 host_tree = proto_tree_add_subtree(tree, tvb, offset, (flags & EVENT_HEADER_FLAG_64_BIT_HEADER0x0040) ? 20 : 16, ett_usbport_host_controller, NULL((void*)0), "HostController");
5504 netmon_etl_field(host_tree, tvb, &offset, hf_usbport_device_object, flags);
5505
5506 proto_tree_add_item(host_tree, hf_usbport_pci_bus, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
5507 offset += 4;
5508 proto_tree_add_item(host_tree, hf_usbport_pci_device, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
5509 offset += 2;
5510 proto_tree_add_item(host_tree, hf_usbport_pci_function, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
5511 offset += 2;
5512 proto_tree_add_item(host_tree, hf_usbport_pci_vendor_id, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
5513 offset += 2;
5514 proto_tree_add_item(host_tree, hf_usbport_pci_device_id, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
5515 offset += 2;
5516
5517 return offset;
5518}
5519
5520static int
5521netmon_UsbPortPath(proto_tree *tree, tvbuff_t *tvb, unsigned offset, packet_info *pinfo)
5522{
5523 proto_item *path_item, *depth_item;
5524 proto_tree *path_tree;
5525 uint32_t path_depth, path0, path1, path2, path3, path4, path5;
5526
5527 path_tree = proto_tree_add_subtree(tree, tvb, offset, 28, ett_usbport_path, &path_item, "PortPath: ");
5528 depth_item = proto_tree_add_item_ret_uint(path_tree, hf_usbport_port_path_depth, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000, &path_depth);
5529 offset += 4;
5530 proto_tree_add_item_ret_uint(path_tree, hf_usbport_port_path0, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000, &path0);
5531 offset += 4;
5532 proto_tree_add_item_ret_uint(path_tree, hf_usbport_port_path1, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000, &path1);
5533 offset += 4;
5534 proto_tree_add_item_ret_uint(path_tree, hf_usbport_port_path2, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000, &path2);
5535 offset += 4;
5536 proto_tree_add_item_ret_uint(path_tree, hf_usbport_port_path3, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000, &path3);
5537 offset += 4;
5538 proto_tree_add_item_ret_uint(path_tree, hf_usbport_port_path4, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000, &path4);
5539 offset += 4;
5540 proto_tree_add_item_ret_uint(path_tree, hf_usbport_port_path5, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000, &path5);
5541 offset += 4;
5542 if (path_depth == 0) {
5543 proto_item_append_text(path_item, "-");
5544 }
5545 if (path_depth > 0) {
5546 proto_item_append_text(path_item, "%d", path0);
5547 }
5548 if (path_depth > 1) {
5549 proto_item_append_text(path_item, ",%d", path1);
5550 }
5551 if (path_depth > 2) {
5552 proto_item_append_text(path_item, ",%d", path2);
5553 }
5554 if (path_depth > 3) {
5555 proto_item_append_text(path_item, ",%d", path3);
5556 }
5557 if (path_depth > 4) {
5558 proto_item_append_text(path_item, ",%d", path4);
5559 }
5560 if (path_depth > 5) {
5561 proto_item_append_text(path_item, ",%d", path5);
5562 }
5563 if (path_depth > 6) {
5564 expert_add_info(pinfo, depth_item, &ei_usbport_invalid_path_depth);
5565 }
5566
5567 return offset;
5568}
5569
5570static int
5571netmon_fid_USBPORT_Device(proto_tree *tree, tvbuff_t *tvb, unsigned offset, uint16_t flags, packet_info *pinfo)
5572{
5573 proto_item *device_item;
5574 proto_tree *device_tree;
5575
5576 device_tree = proto_tree_add_subtree(tree, tvb, offset, 4, ett_usbport_device, &device_item, "Device");
5577 netmon_etl_field(device_tree, tvb, &offset, hf_usbport_device_handle, flags);
5578 proto_tree_add_item(device_tree, hf_usb_idVendor, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
5579 offset += 2;
5580 proto_tree_add_item(device_tree, hf_usb_idProduct, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
5581 offset += 2;
5582 offset = netmon_UsbPortPath(device_tree, tvb, offset, pinfo);
5583 proto_tree_add_item(device_tree, hf_usbport_device_speed, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
5584 offset += 4;
5585 proto_tree_add_item(device_tree, hf_usb_device_address, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
5586 offset += 4;
5587
5588 return offset;
5589}
5590
5591static int
5592netmon_fid_USBPORT_Endpoint(proto_tree *tree, tvbuff_t *tvb, unsigned offset, uint16_t flags)
5593{
5594 proto_tree *endpoint_tree;
5595
5596 endpoint_tree = proto_tree_add_subtree(tree, tvb, offset, (flags & EVENT_HEADER_FLAG_64_BIT_HEADER0x0040) ? 24 : 12, ett_usbport_endpoint, NULL((void*)0), "Endpoint");
5597 netmon_etl_field(endpoint_tree, tvb, &offset, hf_usbport_endpoint, flags);
5598 netmon_etl_field(endpoint_tree, tvb, &offset, hf_usbport_pipehandle, flags);
5599 netmon_etl_field(endpoint_tree, tvb, &offset, hf_usbport_device_handle, flags);
5600
5601 return offset;
5602}
5603
5604static int
5605netmon_fid_USBPORT_Endpoint_Descriptor(proto_tree *tree, tvbuff_t *tvb, unsigned offset)
5606{
5607 proto_tree *endpoint_desc_tree;
5608
5609 endpoint_desc_tree = proto_tree_add_subtree(tree, tvb, offset, 7, ett_usbport_endpoint_desc, NULL((void*)0), "Endpoint Descriptor");
5610 proto_tree_add_item(endpoint_desc_tree, hf_usbport_endpoint_desc_length, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
5611 offset += 1;
5612 proto_tree_add_item(endpoint_desc_tree, hf_usbport_endpoint_desc_type, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
5613 offset += 1;
5614 proto_tree_add_item(endpoint_desc_tree, hf_usbport_endpoint_address, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
5615 offset += 1;
5616 proto_tree_add_item(endpoint_desc_tree, hf_usbport_bm_attributes, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
5617 offset += 1;
5618 proto_tree_add_item(endpoint_desc_tree, hf_usbport_max_packet_size, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
5619 offset += 2;
5620 proto_tree_add_item(endpoint_desc_tree, hf_usbport_interval, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
5621 offset += 1;
5622
5623 return offset;
5624}
5625
5626static int
5627netmon_URB(proto_tree *tree, tvbuff_t *tvb, unsigned offset, uint16_t flags)
5628{
5629 proto_item *urb_item;
5630 proto_tree *urb_tree;
5631 uint32_t func;
5632 int i, start_offset = offset;
5633
5634 urb_tree = proto_tree_add_subtree(tree, tvb, offset, 8, ett_usbport_urb, &urb_item, "URB");
5635 proto_tree_add_item(urb_tree, hf_usbport_urb_header_length, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
5636 offset += 2;
5637 proto_tree_add_item_ret_uint(urb_tree, hf_usbport_urb_header_function, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000, &func);
5638 proto_item_append_text(urb_item, ": %s", val_to_str_ext_const(func, &netmon_urb_function_vals_ext, "Unknown"));
5639 offset += 2;
5640 proto_tree_add_item(urb_tree, hf_usbport_urb_header_status, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
5641 offset += 4;
5642 netmon_etl_field(urb_tree, tvb, &offset, hf_usbport_urb_header_usbddevice_handle, flags);
5643 netmon_etl_field(urb_tree, tvb, &offset, hf_usbport_urb_header_usbdflags, flags);
5644
5645 switch (func)
5646 {
5647 case 0x0000:
5648 netmon_etl_field(urb_tree, tvb, &offset, hf_usbport_urb_configuration_desc, flags);
5649 netmon_etl_field(urb_tree, tvb, &offset, hf_usbport_urb_configuration_handle, flags);
5650 break;
5651 case 0x0008: //URB_FUNCTION_CONTROL_TRANSFER
5652 case 0x0009: //URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER
5653 case 0x000A: //URB_FUNCTION_ISOCH_TRANSFER
5654 case 0x000B: //URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE
5655 case 0x000C: //URB_FUNCTION_SET_DESCRIPTOR_TO_DEVICE
5656 case 0x000D: //URB_FUNCTION_SET_FEATURE_TO_DEVICE
5657 case 0x000E: //URB_FUNCTION_SET_FEATURE_TO_INTERFACE
5658 case 0x000F: //URB_FUNCTION_SET_FEATURE_TO_ENDPOINT
5659 case 0x0010: //URB_FUNCTION_CLEAR_FEATURE_TO_DEVICE
5660 case 0x0011: //URB_FUNCTION_CLEAR_FEATURE_TO_INTERFACE
5661 case 0x0012: //URB_FUNCTION_CLEAR_FEATURE_TO_ENDPOINT
5662 case 0x0013: //URB_FUNCTION_GET_STATUS_FROM_DEVICE
5663 case 0x0014: //URB_FUNCTION_GET_STATUS_FROM_INTERFACE
5664 case 0x0015: //URB_FUNCTION_GET_STATUS_FROM_ENDPOINT
5665 case 0x0017: //URB_FUNCTION_VENDOR_DEVICE
5666 case 0x0018: //URB_FUNCTION_VENDOR_INTERFACE
5667 case 0x0019: //URB_FUNCTION_VENDOR_ENDPOINT
5668 case 0x001A: //URB_FUNCTION_CLASS_DEVICE
5669 case 0x001B: //URB_FUNCTION_CLASS_INTERFACE
5670 case 0x001C: //URB_FUNCTION_CLASS_ENDPOINT
5671 case 0x001F: //URB_FUNCTION_CLASS_OTHER
5672 case 0x0020: //URB_FUNCTION_VENDOR_OTHER
5673 case 0x0021: //URB_FUNCTION_GET_STATUS_FROM_OTHER
5674 case 0x0022: //URB_FUNCTION_CLEAR_FEATURE_TO_OTHER
5675 case 0x0023: //URB_FUNCTION_SET_FEATURE_TO_OTHER
5676 case 0x0024: //URB_FUNCTION_GET_DESCRIPTOR_FROM_ENDPOINT
5677 case 0x0025: //URB_FUNCTION_SET_DESCRIPTOR_TO_ENDPOINT
5678 case 0x0026: //URB_FUNCTION_GET_CONFIGURATION
5679 case 0x0027: //URB_FUNCTION_GET_INTERFACE
5680 case 0x0028: //URB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE
5681 case 0x0029: //URB_FUNCTION_SET_DESCRIPTOR_TO_INTERFACE
5682 case 0x002A: //URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR
5683 case 0x0032: //URB_FUNCTION_CONTROL_TRANSFER_EX
5684 case 0x0037: //URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER_USING_CHAINED_MDL
5685 case 0x0038: //URB_FUNCTION_ISOCH_TRANSFER_USING_CHAINED_MDL
5686 netmon_etl_field(urb_tree, tvb, &offset, hf_usbport_urb_pipe_handle, flags);
5687 proto_tree_add_bitmask(urb_tree, tvb, offset, hf_usbport_urb_xferflags, ett_usb_xferflags,
5688 usb_xferflags_fields, ENC_LITTLE_ENDIAN0x80000000);
5689 offset += 4;
5690 proto_tree_add_item(urb_tree, hf_usbport_urb_transfer_buffer_length, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
5691 offset += 4;
5692 netmon_etl_field(urb_tree, tvb, &offset, hf_usbport_urb_transfer_buffer, flags);
5693 netmon_etl_field(urb_tree, tvb, &offset, hf_usbport_urb_transfer_buffer_mdl, flags);
5694 netmon_etl_field(urb_tree, tvb, &offset, hf_usbport_urb_reserved_mbz, flags);
5695 for (i = 0; i < 8; i++)
5696 {
5697 netmon_etl_field(urb_tree, tvb, &offset, hf_usbport_urb_reserved_hcd, flags);
5698 }
5699 break;
5700
5701 case 0x0002: //URB_FUNCTION_ABORT_PIPE
5702 case 0x001E: //URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL
5703 case 0x0030: //URB_FUNCTION_SYNC_RESET_PIPE
5704 case 0x0031: //URB_FUNCTION_SYNC_CLEAR_STALL
5705 case 0x0036: //URB_FUNCTION_CLOSE_STATIC_STREAMS
5706 netmon_etl_field(urb_tree, tvb, &offset, hf_usbport_urb_pipe_handle, flags);
5707 proto_tree_add_item(urb_tree, hf_usbport_urb_reserved, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
5708 offset += 4;
5709 break;
5710 }
5711
5712 proto_item_set_len(urb_item, offset-start_offset);
5713 return offset;
5714}
5715
5716#define USBPORT_KEYWORD_DIAGNOSTIC0x0000000000000001UL UINT64_C(0x0000000000000001)0x0000000000000001UL
5717#define USBPORT_KEYWORD_POWER_DIAGNOSTICS0x0000000000000002UL UINT64_C(0x0000000000000002)0x0000000000000002UL
5718#define USBPORT_KEYWORD_PERF_DIAGNOSTICS0x0000000000000004UL UINT64_C(0x0000000000000004)0x0000000000000004UL
5719#define USBPORT_KEYWORD_RESERVED10xFFFFFFFFFFFFFFF8UL UINT64_C(0xFFFFFFFFFFFFFFF8)0xFFFFFFFFFFFFFFF8UL
5720
5721static int
5722dissect_netmon_usb_port(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent, void* data)
5723{
5724 proto_item *ti, *generated;
5725 proto_tree *usb_port_tree;
5726 unsigned offset = 0;
5727 struct netmon_provider_id_data *provider_id_data = (struct netmon_provider_id_data*)data;
5728 static int * const keyword_fields[] = {
5729 &hf_usbport_keyword_diagnostic,
5730 &hf_usbport_keyword_power_diagnostics,
5731 &hf_usbport_keyword_perf_diagnostics,
5732 &hf_usbport_keyword_reserved1,
5733 NULL((void*)0)
5734 };
5735
5736 DISSECTOR_ASSERT(provider_id_data != NULL)((void) ((provider_id_data != ((void*)0)) ? (void)0 : (proto_report_dissector_bug
("%s:%u: failed assertion \"%s\"", "epan/dissectors/packet-usb.c"
, 5736, "provider_id_data != ((void*)0)"))))
;
5737
5738 col_set_str(pinfo->cinfo, COL_PROTOCOL, "USBPort");
5739 col_clear(pinfo->cinfo, COL_INFO);
5740
5741 ti = proto_tree_add_item(parent, proto_usbport, tvb, 0, -1, ENC_NA0x00000000);
5742 usb_port_tree = proto_item_add_subtree(ti, ett_usbport);
5743
5744 generated = proto_tree_add_uint(usb_port_tree, hf_usbport_event_id, tvb, 0, 0, provider_id_data->event_id);
5745 proto_item_set_generated(generated);
5746 generated = proto_tree_add_bitmask_value(usb_port_tree, tvb, 0, hf_usbport_keyword, ett_usbport_keyword, keyword_fields, provider_id_data->keyword);
5747 proto_item_set_generated(generated);
5748
5749 switch (provider_id_data->event_id)
5750 {
5751 case 71:
5752 offset = netmon_HostController2(usb_port_tree, tvb, offset, provider_id_data->event_flags);
5753 offset = netmon_fid_USBPORT_Device(usb_port_tree, tvb, offset, provider_id_data->event_flags, pinfo);
5754 offset = netmon_fid_USBPORT_Endpoint(usb_port_tree, tvb, offset, provider_id_data->event_flags);
5755 offset = netmon_fid_USBPORT_Endpoint_Descriptor(usb_port_tree, tvb, offset);
5756 netmon_etl_field(usb_port_tree, tvb, &offset, hf_usbport_irp, provider_id_data->event_flags);
5757 netmon_etl_field(usb_port_tree, tvb, &offset, hf_usbport_urb, provider_id_data->event_flags);
5758 offset = netmon_URB(usb_port_tree, tvb, offset, provider_id_data->event_flags);
5759 proto_tree_add_item(usb_port_tree, hf_usbport_urb_transfer_data, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
5760 break;
5761 }
5762
5763 return tvb_captured_length(tvb);
5764}
5765
5766void
5767dissect_usb_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent,
5768 usb_header_t header_type, void *extra_data)
5769{
5770 int offset = 0;
5771 int endpoint;
5772 uint8_t urb_type;
5773 uint32_t win32_data_len = 0;
5774 uint32_t iso_numdesc = 0;
5775 uint32_t desc_offset = 0;
5776 uint32_t location = 0;
5777 proto_item *urb_tree_ti;
5778 proto_tree *tree;
5779 proto_item *item;
5780 urb_info_t *urb;
5781 conversation_t *conversation;
5782 uint16_t device_address;
5783 uint16_t bus_id;
5784 uint8_t usbpcap_control_stage = 0;
5785 uint64_t usb_id;
5786 struct mausb_header *ma_header = NULL((void*)0);
5787 struct usbip_header *ip_header = NULL((void*)0);
5788 usb_pseudo_urb_t *pseudo_urb = NULL((void*)0);
5789
5790 /* the goal is to get the conversation struct as early as possible
5791 and store all status values in this struct
5792 at first, we read the fields required to create/identify
5793 the right conversation struct */
5794 switch (header_type) {
1
Control jumps to 'case USB_HEADER_FREEBSD:' at line 5856
5795
5796 case USB_HEADER_LINUX_48_BYTES:
5797 case USB_HEADER_LINUX_64_BYTES:
5798 urb_type = tvb_get_uint8(tvb, 8);
5799 endpoint = tvb_get_uint8(tvb, 10);
5800 device_address = (uint16_t)tvb_get_uint8(tvb, 11);
5801 bus_id = tvb_get_letohs(tvb, 12);
5802 break;
5803
5804 case USB_HEADER_USBPCAP:
5805 urb_type = tvb_get_uint8(tvb, 16) & 0x01 ? URB_COMPLETE'C' : URB_SUBMIT'S';
5806 device_address = tvb_get_letohs(tvb, 19);
5807 endpoint = tvb_get_uint8(tvb, 21);
5808 if ((endpoint == 0x00) && (tvb_get_uint8(tvb, 22) == URB_CONTROL0x2) &&
5809 (tvb_get_uint8(tvb, 27) == USB_CONTROL_STAGE_DATA0x01)) {
5810 /* USBPcap before 1.3.0.0 DATA OUT packet (the info at offset 16 is wrong) */
5811 urb_type = URB_SUBMIT'S';
5812 }
5813 bus_id = tvb_get_letohs(tvb, 17);
5814 break;
5815
5816 case USB_HEADER_MAUSB:
5817 ma_header = (struct mausb_header *) extra_data;
5818 urb_type = mausb_is_from_host(ma_header) ? URB_SUBMIT'S' : URB_COMPLETE'C';
5819 device_address = mausb_ep_handle_dev_addr(ma_header->handle);
5820 endpoint = mausb_ep_handle_ep_num(ma_header->handle);
5821 bus_id = mausb_ep_handle_bus_num(ma_header->handle);
5822 if (mausb_ep_handle_ep_d(ma_header->handle)) {
5823 /* IN endpoint */
5824 endpoint |= 0x80;
5825 }
5826 break;
5827
5828 case USB_HEADER_USBIP:
5829 ip_header = (struct usbip_header *) extra_data;
5830 urb_type = tvb_get_ntohl(tvb, 0) == 1 ? URB_SUBMIT'S' : URB_COMPLETE'C';
5831 device_address = ip_header->devid;
5832 bus_id = ip_header->busid;
5833 endpoint = ip_header->ep;
5834 if (ip_header->dir == 1) {
5835 /* IN endpoint */
5836 endpoint |= 0x80;
5837 }
5838 break;
5839
5840 case USB_HEADER_DARWIN:
5841 urb_type = tvb_get_uint8(tvb, 3) ? URB_COMPLETE'C' : URB_SUBMIT'S';
5842 endpoint = tvb_get_uint8(tvb, 30);
5843 device_address = (uint16_t)tvb_get_uint8(tvb, 29);
5844 location = tvb_get_letohl(tvb, 24);
5845 bus_id = location >> 24;
5846 break;
5847
5848 case USB_HEADER_PSEUDO_URB:
5849 pseudo_urb = (usb_pseudo_urb_t *) extra_data;
5850 urb_type = pseudo_urb->from_host ? URB_SUBMIT'S' : URB_COMPLETE'C';
5851 device_address = pseudo_urb->device_address;
5852 endpoint = pseudo_urb->endpoint;
5853 bus_id = pseudo_urb->bus_id;
5854 break;
5855
5856 case USB_HEADER_FREEBSD:
5857 urb_type = tvb_get_uint8(tvb, 10) == FREEBSD_URB_COMPLETE1 ? URB_COMPLETE'C'
2
Assuming the condition is false
3
'?' condition is false
5858 : URB_SUBMIT'S';
5859 endpoint = tvb_get_uint8(tvb, 40);
5860 device_address = (uint16_t)tvb_get_uint8(tvb, 8);
5861 bus_id = (uint16_t)tvb_get_letohl(tvb, 4);
5862 break;
4
Execution continues on line 5868
5863
5864 default:
5865 return; /* invalid USB pseudo header */
5866 }
5867
5868 col_set_str(pinfo->cinfo, COL_PROTOCOL, "USB");
5869 urb_tree_ti = proto_tree_add_protocol_format(parent, proto_usb, tvb, 0, -1, "USB URB");
5870 tree = proto_item_add_subtree(urb_tree_ti, ett_usb_hdr);
5871
5872 if (endpoint == 0x80) {
5
Assuming 'endpoint' is not equal to 128
6
Taking false branch
5873 /* Control endpoint is only bidirectional endpoint, use 0 to look up
5874 * correct conversation.
5875 */
5876 endpoint = 0;
5877 }
5878
5879 usb_set_addr(tree, tvb, pinfo, bus_id, device_address, endpoint,
5880 (urb_type == URB_SUBMIT'S'));
5881
5882 conversation = get_usb_conversation(pinfo, &pinfo->src, &pinfo->dst, pinfo->srcport, pinfo->destport);
5883 urb = wmem_new0(pinfo->pool, urb_info_t)((urb_info_t*)wmem_alloc0((pinfo->pool), sizeof(urb_info_t
)))
;
5884 urb->conv = get_usb_conv_info(conversation);
5885 urb->endpoint = endpoint;
5886 clear_usb_conv_tmp_data(urb);
7
Calling 'clear_usb_conv_tmp_data'
11
Returning from 'clear_usb_conv_tmp_data'
5887
5888
5889 switch (header_type) {
12
Control jumps to 'case USB_HEADER_FREEBSD:' at line 5943
5890
5891 case USB_HEADER_LINUX_48_BYTES:
5892 case USB_HEADER_LINUX_64_BYTES:
5893 proto_item_set_len(urb_tree_ti, (header_type == USB_HEADER_LINUX_64_BYTES) ? 64 : 48);
5894 offset = dissect_linux_usb_pseudo_header(tvb, pinfo, tree, urb, &usb_id);
5895 break;
5896
5897 case USB_HEADER_USBPCAP:
5898 offset = dissect_usbpcap_buffer_packet_header(tvb, pinfo, tree, urb, &win32_data_len, &usb_id);
5899 /* the length that we're setting here might have to be corrected
5900 if there's a transfer-specific pseudo-header following */
5901 proto_item_set_len(urb_tree_ti, offset);
5902 break;
5903
5904 case USB_HEADER_MAUSB:
5905 /* MA USB header gets dissected earlier, just set conversation variables */
5906 offset = MAUSB_DPH_LENGTH20;
5907 mausb_set_urb_info(urb, ma_header);
5908 usb_id = 0;
5909 break;
5910
5911 case USB_HEADER_USBIP:
5912 iso_numdesc = tvb_get_ntohl(tvb, 0x20);
5913 urb->transfer_type = endpoint == 0 ? URB_CONTROL0x2 : (iso_numdesc != 0xffffffff ? URB_ISOCHRONOUS0x0 : URB_UNKNOWN0xFF);
5914 urb->direction = ip_header->dir == USBIP_DIR_OUT0x00 ? P2P_DIR_SENT0 : P2P_DIR_RECV1;
5915 urb->is_setup = endpoint == 0 ? (tvb_get_ntoh64(tvb, 0x28) != UINT64_C(0)0UL) : false0;
5916 urb->is_request = (urb_type==URB_SUBMIT'S');
5917 offset = urb->is_setup ? USBIP_HEADER_WITH_SETUP_LEN0x28 : USBIP_HEADER_LEN0x30;
5918
5919 /* The ISOC descriptor is located at the end of the isoc frame behind the isoc data. */
5920 if ((urb->is_request && urb->direction == USBIP_DIR_OUT0x00) ||
5921 (!urb->is_request && urb->direction == USBIP_DIR_IN0x01)) {
5922 desc_offset += tvb_get_ntohl(tvb, 0x18);
5923 }
5924
5925 desc_offset += offset;
5926 usb_id = 0;
5927 break;
5928
5929 case USB_HEADER_DARWIN:
5930 offset = dissect_darwin_buffer_packet_header(tvb, pinfo, tree, urb, &usb_id);
5931 proto_item_set_len(urb_tree_ti, offset);
5932 break;
5933
5934 case USB_HEADER_PSEUDO_URB:
5935 urb->transfer_type = pseudo_urb->transfer_type;
5936 urb->direction = pseudo_urb->from_host ? P2P_DIR_SENT0 : P2P_DIR_RECV1;
5937 urb->is_setup = pseudo_urb->from_host && (pseudo_urb->transfer_type == URB_CONTROL0x2);
5938 urb->is_request = pseudo_urb->from_host;
5939 urb->speed = pseudo_urb->speed;
5940 usb_id = 0;
5941 break;
5942
5943 case USB_HEADER_FREEBSD:
5944 proto_item_set_len(urb_tree_ti, 128);
5945 offset = dissect_freebsd_usb_pseudo_header(tvb, pinfo, tree, urb);
13
Calling 'dissect_freebsd_usb_pseudo_header'
22
Returning from 'dissect_freebsd_usb_pseudo_header'
5946 usb_id = 0;
5947 break;
5948
5949 default:
5950 usb_id = 0;
5951 break;
5952 }
5953
5954 urb->usb_trans_info = usb_get_trans_info(tvb, pinfo, tree, header_type, urb, usb_id);
23
Execution continues on line 5954
24
Calling 'usb_get_trans_info'
31
Returning from 'usb_get_trans_info'
5955
5956 if (urb->transfer_type
31.1
Field 'transfer_type' is not equal to URB_CONTROL
!= URB_CONTROL0x2) {
32
Taking true branch
5957 usb_tap_queue_packet(pinfo, urb_type, urb);
33
Calling 'usb_tap_queue_packet'
35
Returning from 'usb_tap_queue_packet'
5958 }
5959
5960 switch(urb->transfer_type) {
36
Control jumps to the 'default' case at line 6166
5961 case URB_BULK0x3:
5962 case URB_INTERRUPT0x1:
5963 item = proto_tree_add_uint(tree, hf_usb_bInterfaceClass, tvb, 0, 0, urb->conv->interfaceClass);
5964 proto_item_set_generated(item);
5965
5966 switch (header_type) {
5967
5968 case USB_HEADER_LINUX_48_BYTES:
5969 case USB_HEADER_LINUX_64_BYTES:
5970 /* bulk and interrupt transfers never contain a setup packet */
5971 proto_tree_add_item(tree, hf_usb_urb_unused_setup_header, tvb, offset, 8, ENC_NA0x00000000);
5972 offset += 8;
5973 if (header_type == USB_HEADER_LINUX_64_BYTES) {
5974 offset = dissect_linux_usb_pseudo_header_ext(tvb, offset, pinfo, tree);
5975 }
5976 break;
5977
5978 case USB_HEADER_USBPCAP:
5979 break;
5980
5981 case USB_HEADER_MAUSB:
5982 break;
5983
5984 case USB_HEADER_USBIP:
5985 break;
5986
5987 case USB_HEADER_DARWIN:
5988 break;
5989
5990 case USB_HEADER_PSEUDO_URB:
5991 break;
5992
5993 case USB_HEADER_FREEBSD:
5994 offset = dissect_freebsd_usb_frames(tree, tvb, offset, pinfo,
5995 parent, urb, urb_type);
5996 break;
5997 }
5998 break;
5999
6000 case URB_CONTROL0x2:
6001 if (header_type == USB_HEADER_USBPCAP) {
6002 proto_tree_add_item(tree, hf_usb_win32_control_stage, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
6003 usbpcap_control_stage = tvb_get_uint8(tvb, offset);
6004 offset++;
6005 proto_item_set_len(urb_tree_ti, offset);
6006 if (usbpcap_control_stage == USB_CONTROL_STAGE_SETUP0x00) {
6007 urb->is_setup = true1;
6008 } else if (usbpcap_control_stage == USB_CONTROL_STAGE_DATA0x01 && urb_type == URB_SUBMIT'S') {
6009 /* USBPcap before 1.5.0.0 */
6010 wmem_tree_key_t key[3];
6011 key[0].length = 2;
6012 key[0].key = (uint32_t *)&usb_id;
6013 key[1].length = 1;
6014 key[1].key = &pinfo->num;
6015 key[2].length = 0;
6016 key[2].key = NULL((void*)0);
6017 usbpcap_setup_data_t *setup_data = (usbpcap_setup_data_t *)wmem_tree_lookup32_array_le(usbpcap_setup_data, key);
6018 if (setup_data && setup_data->usb_id == usb_id) {
6019 tvbuff_t *reassembled_tvb = tvb_new_composite();
6020 tvb_composite_append(reassembled_tvb, tvb_new_child_real_data(tvb, setup_data->setup_data, 8, 8));
6021 tvb_composite_append(reassembled_tvb, tvb_new_subset_remaining(tvb, offset));
6022 tvb_composite_finalize(reassembled_tvb);
6023 add_new_data_source(pinfo, reassembled_tvb, "USBPcap reassembled setup");
6024 urb->is_setup = true1;
6025 tvb = reassembled_tvb;
6026 offset = 0;
6027 }
6028 }
6029 }
6030
6031 if (urb->is_request) {
6032 if (urb->is_setup) {
6033 offset = dissect_usb_setup_request(pinfo, tree, tvb, offset, urb_type,
6034 urb, header_type, usb_id);
6035
6036 } else {
6037 switch (header_type) {
6038
6039 case USB_HEADER_LINUX_48_BYTES:
6040 case USB_HEADER_LINUX_64_BYTES:
6041 proto_tree_add_item(tree, hf_usb_urb_unused_setup_header, tvb, offset, 8, ENC_NA0x00000000);
6042 offset += 8;
6043 if (header_type == USB_HEADER_LINUX_64_BYTES) {
6044 offset = dissect_linux_usb_pseudo_header_ext(tvb, offset, pinfo, tree);
6045 }
6046 break;
6047
6048 case USB_HEADER_USBPCAP:
6049 break;
6050
6051 case USB_HEADER_MAUSB:
6052 break;
6053
6054 case USB_HEADER_USBIP:
6055 break;
6056
6057 case USB_HEADER_DARWIN:
6058 break;
6059
6060 case USB_HEADER_PSEUDO_URB:
6061 break;
6062
6063 case USB_HEADER_FREEBSD:
6064 offset = dissect_freebsd_usb_control_request(
6065 tree, tvb, offset, pinfo, parent, urb, urb_type,
6066 usb_id);
6067 break;
6068 }
6069 }
6070 } else {
6071 /* this is a response */
6072
6073 switch (header_type) {
6074
6075 case USB_HEADER_LINUX_48_BYTES:
6076 case USB_HEADER_LINUX_64_BYTES:
6077 /* Skip setup header - it's never applicable for responses */
6078 proto_tree_add_item(tree, hf_usb_urb_unused_setup_header, tvb, offset, 8, ENC_NA0x00000000);
6079 offset += 8;
6080 if (header_type == USB_HEADER_LINUX_64_BYTES) {
6081 offset = dissect_linux_usb_pseudo_header_ext(tvb, offset, pinfo, tree);
6082 }
6083 break;
6084
6085 case USB_HEADER_USBPCAP:
6086 /* Check if this is status stage */
6087 if ((urb->usb_trans_info) &&
6088 (usbpcap_control_stage == USB_CONTROL_STAGE_STATUS0x02)) {
6089 const char *description;
6090 if (USB_TYPE(urb->usb_trans_info->setup.requesttype)(((urb->usb_trans_info->setup.requesttype) & (0x03 <<
5)) >> 5)
== RQT_SETUP_TYPE_STANDARD0) {
6091 description = val_to_str_ext(pinfo->pool, urb->usb_trans_info->setup.request,
6092 &setup_request_names_vals_ext, "Unknown type %x") ;
6093 } else {
6094 description = "URB_CONTROL";
6095 }
6096 col_add_fstr(pinfo->cinfo, COL_INFO, "%s status", description);
6097 /* There is no data to dissect */
6098 return;
6099 }
6100 break;
6101
6102 case USB_HEADER_MAUSB:
6103 break;
6104
6105 case USB_HEADER_USBIP:
6106 break;
6107
6108 case USB_HEADER_DARWIN:
6109 break;
6110
6111 case USB_HEADER_PSEUDO_URB:
6112 break;
6113
6114 case USB_HEADER_FREEBSD:
6115 dissect_freebsd_usb_control_response(tree, tvb, offset,
6116 pinfo, urb,
6117 urb_type);
6118 /* FreeBSD already fully handled the assembled frame data;
6119 * don't call dissect_usb_setup_response on the original tvb
6120 * or subdissectors (e.g. USBHUB) will be invoked again on
6121 * residual/padding bytes → "Malformed Packet". */
6122 return;
6123 }
6124
6125 offset = dissect_usb_setup_response(pinfo, tree, tvb, offset,
6126 urb_type, urb);
6127 }
6128 break;
6129 case URB_ISOCHRONOUS0x0:
6130 switch (header_type) {
6131
6132 case USB_HEADER_LINUX_48_BYTES:
6133 case USB_HEADER_LINUX_64_BYTES:
6134 offset = dissect_linux_usb_iso_transfer(pinfo, tree, header_type,
6135 tvb, offset, urb);
6136 break;
6137
6138 case USB_HEADER_USBPCAP:
6139 offset = dissect_usbpcap_iso_packets(pinfo, tree,
6140 urb_type, tvb, offset, win32_data_len, urb);
6141 break;
6142
6143 case USB_HEADER_MAUSB:
6144 break;
6145
6146 case USB_HEADER_USBIP:
6147 offset = dissect_usbip_iso_transfer(pinfo, tree,
6148 tvb, offset, iso_numdesc, desc_offset, urb);
6149 break;
6150
6151 case USB_HEADER_DARWIN:
6152 offset = dissect_darwin_usb_iso_transfer(pinfo, tree, header_type,
6153 urb_type, tvb, offset, urb);
6154 break;
6155
6156 case USB_HEADER_PSEUDO_URB:
6157 break;
6158
6159 case USB_HEADER_FREEBSD:
6160 offset = dissect_freebsd_usb_frames(tree, tvb, offset, pinfo,
6161 parent, urb, urb_type);
6162 break;
6163 }
6164 break;
6165
6166 default:
6167 /* unknown transfer type */
6168 switch (header_type) {
37
Control jumps to 'case USB_HEADER_FREEBSD:' at line 6193
6169 case USB_HEADER_LINUX_48_BYTES:
6170 case USB_HEADER_LINUX_64_BYTES:
6171 proto_tree_add_item(tree, hf_usb_urb_unused_setup_header, tvb, offset, 8, ENC_NA0x00000000);
6172 offset += 8;
6173 if (header_type == USB_HEADER_LINUX_64_BYTES) {
6174 offset = dissect_linux_usb_pseudo_header_ext(tvb, offset, pinfo, tree);
6175 }
6176 break;
6177
6178 case USB_HEADER_USBPCAP:
6179 break;
6180
6181 case USB_HEADER_MAUSB:
6182 break;
6183
6184 case USB_HEADER_USBIP:
6185 break;
6186
6187 case USB_HEADER_DARWIN:
6188 break;
6189
6190 case USB_HEADER_PSEUDO_URB:
6191 break;
6192
6193 case USB_HEADER_FREEBSD:
6194 offset = dissect_freebsd_usb_frames(tree, tvb, offset, pinfo,
38
Calling 'dissect_freebsd_usb_frames'
6195 parent, urb, urb_type);
6196 break;
6197 }
6198 break;
6199 }
6200
6201 dissect_usb_payload(tvb, pinfo, parent, tree, urb, urb_type,
6202 offset, device_address);
6203}
6204
6205static int
6206dissect_linux_usb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent, void* data _U___attribute__((unused)))
6207{
6208 dissect_usb_common(tvb, pinfo, parent, USB_HEADER_LINUX_48_BYTES, NULL((void*)0));
6209 return tvb_captured_length(tvb);
6210}
6211
6212static int
6213dissect_linux_usb_mmapped(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent, void* data _U___attribute__((unused)))
6214{
6215 dissect_usb_common(tvb, pinfo, parent, USB_HEADER_LINUX_64_BYTES, NULL((void*)0));
6216 return tvb_captured_length(tvb);
6217}
6218
6219
6220static int
6221dissect_win32_usb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent, void* data _U___attribute__((unused)))
6222{
6223 dissect_usb_common(tvb, pinfo, parent, USB_HEADER_USBPCAP, NULL((void*)0));
6224 return tvb_captured_length(tvb);
6225}
6226
6227static int
6228dissect_darwin_usb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent, void* data _U___attribute__((unused)))
6229{
6230 dissect_usb_common(tvb, pinfo, parent, USB_HEADER_DARWIN, NULL((void*)0));
6231 return tvb_captured_length(tvb);
6232}
6233
6234void
6235proto_register_usb(void)
6236{
6237 module_t *usb_module;
6238 static hf_register_info hf[] = {
6239
6240 /* USB packet pseudoheader members */
6241
6242 { &hf_usb_totlen,
6243 { "Total length", "usb.totlen",
6244 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
6245 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6246
6247 { &hf_usb_busunit,
6248 { "Host controller unit number", "usb.busunit",
6249 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
6250 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6251
6252 { &hf_usb_address,
6253 { "USB device index", "usb.address",
6254 FT_UINT8, BASE_DEC, NULL((void*)0), 0x0,
6255 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6256
6257 { &hf_usb_mode,
6258 { "Mode of transfer", "usb.transfer_mode",
6259 FT_UINT8, BASE_DEC, VALS(usb_freebsd_transfer_mode_vals)((0 ? (const struct _value_string*)0 : ((usb_freebsd_transfer_mode_vals
))))
, 0x0,
6260 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6261
6262 { &hf_usb_freebsd_urb_type,
6263 { "URB type", "usb.freebsd_type",
6264 FT_UINT8, BASE_DEC, VALS(usb_freebsd_urb_type_vals)((0 ? (const struct _value_string*)0 : ((usb_freebsd_urb_type_vals
))))
, 0x0,
6265 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6266
6267 { &hf_usb_freebsd_transfer_type,
6268 { "URB transfer type", "usb.freebsd_transfer_type",
6269 FT_UINT8, BASE_HEX, VALS(usb_freebsd_transfer_type_vals)((0 ? (const struct _value_string*)0 : ((usb_freebsd_transfer_type_vals
))))
, 0x0,
6270 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6271
6272 { &hf_usb_xferflags,
6273 { "Transfer flags", "usb.xferflags",
6274 FT_UINT32, BASE_HEX, NULL((void*)0), 0x0,
6275 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6276
6277 { &hf_usb_xferflags_force_short_xfer,
6278 { "Force short transfer", "usb.xferflags.force_short_xfer",
6279 FT_BOOLEAN, 32, NULL((void*)0), FREEBSD_FLAG_FORCE_SHORT_XFER0x00000001,
6280 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6281
6282 { &hf_usb_xferflags_short_xfer_ok,
6283 { "Short transfer OK", "usb.xferflags.short_xfer_ok",
6284 FT_BOOLEAN, 32, NULL((void*)0), FREEBSD_FLAG_SHORT_XFER_OK0x00000002,
6285 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6286
6287 { &hf_usb_xferflags_short_frames_ok,
6288 { "Short frames OK", "usb.xferflags.short_frames_ok",
6289 FT_BOOLEAN, 32, NULL((void*)0), FREEBSD_FLAG_SHORT_FRAMES_OK0x00000004,
6290 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6291
6292 { &hf_usb_xferflags_pipe_bof,
6293 { "Pipe BOF", "usb.xferflags.pipe_bof",
6294 FT_BOOLEAN, 32, NULL((void*)0), FREEBSD_FLAG_PIPE_BOF0x00000008,
6295 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6296
6297 { &hf_usb_xferflags_proxy_buffer,
6298 { "Proxy buffer", "usb.xferflags.proxy_buffer",
6299 FT_BOOLEAN, 32, NULL((void*)0), FREEBSD_FLAG_PROXY_BUFFER0x00000010,
6300 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6301
6302 { &hf_usb_xferflags_ext_buffer,
6303 { "External buffer", "usb.xferflags.ext_buffer",
6304 FT_BOOLEAN, 32, NULL((void*)0), FREEBSD_FLAG_EXT_BUFFER0x00000020,
6305 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6306
6307 { &hf_usb_xferflags_manual_status,
6308 { "Manual status", "usb.xferflags.manual_status",
6309 FT_BOOLEAN, 32, NULL((void*)0), FREEBSD_FLAG_MANUAL_STATUS0x00000040,
6310 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6311
6312 { &hf_usb_xferflags_no_pipe_ok,
6313 { "No pipe OK", "usb.xferflags.no_pipe_ok",
6314 FT_BOOLEAN, 32, NULL((void*)0), FREEBSD_FLAG_NO_PIPE_OK0x00000080,
6315 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6316
6317 { &hf_usb_xferflags_stall_pipe,
6318 { "Stall pipe", "usb.xferflags.stall_pipe",
6319 FT_BOOLEAN, 32, NULL((void*)0), FREEBSD_FLAG_STALL_PIPE0x00000100,
6320 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6321
6322 { &hf_usb_xferstatus,
6323 { "Transfer status", "usb.xferstatus",
6324 FT_UINT32, BASE_HEX, NULL((void*)0), 0x0,
6325 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6326
6327 { &hf_usb_xferstatus_open,
6328 { "Pipe has been opened", "usb.xferstatus.open",
6329 FT_BOOLEAN, 32, NULL((void*)0), FREEBSD_STATUS_OPEN0x00000001,
6330 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6331
6332 { &hf_usb_xferstatus_transferring,
6333 { "Transfer in progress", "usb.xferstatus.transferring",
6334 FT_BOOLEAN, 32, NULL((void*)0), FREEBSD_STATUS_TRANSFERRING0x00000002,
6335 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6336
6337 { &hf_usb_xferstatus_did_dma_delay,
6338 { "Waited for hardware DMA", "usb.xferstatus.did_dma_delay",
6339 FT_BOOLEAN, 32, NULL((void*)0), FREEBSD_STATUS_DID_DMA_DELAY0x00000004,
6340 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6341
6342 { &hf_usb_xferstatus_did_close,
6343 { "Transfer closed", "usb.xferstatus.did_close",
6344 FT_BOOLEAN, 32, NULL((void*)0), FREEBSD_STATUS_DID_CLOSE0x00000008,
6345 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6346
6347 { &hf_usb_xferstatus_draining,
6348 { "Draining transfer", "usb.xferstatus.draining",
6349 FT_BOOLEAN, 32, NULL((void*)0), FREEBSD_STATUS_DRAINING0x00000010,
6350 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6351
6352 { &hf_usb_xferstatus_started,
6353 { "Transfer started", "usb.xferstatus.started",
6354 FT_BOOLEAN, 32, NULL((void*)0), FREEBSD_STATUS_STARTED0x00000020,
6355 "Whether the transfer is started or stopped", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6356
6357 { &hf_usb_xferstatus_bw_reclaimed,
6358 { "Bandwidth reclaimed", "usb.xferstatus.bw_reclaimed",
6359 FT_BOOLEAN, 32, NULL((void*)0), FREEBSD_STATUS_BW_RECLAIMED0x00000040,
6360 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6361
6362 { &hf_usb_xferstatus_control_xfr,
6363 { "Control transfer", "usb.xferstatus.control_xfr",
6364 FT_BOOLEAN, 32, NULL((void*)0), FREEBSD_STATUS_CONTROL_XFR0x00000080,
6365 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6366
6367 { &hf_usb_xferstatus_control_hdr,
6368 { "Control header being sent", "usb.xferstatus.control_hdr",
6369 FT_BOOLEAN, 32, NULL((void*)0), FREEBSD_STATUS_CONTROL_HDR0x00000100,
6370 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6371
6372 { &hf_usb_xferstatus_control_act,
6373 { "Control transfer active", "usb.xferstatus.control_act",
6374 FT_BOOLEAN, 32, NULL((void*)0), FREEBSD_STATUS_CONTROL_ACT0x00000200,
6375 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6376
6377 { &hf_usb_xferstatus_control_stall,
6378 { "Control transfer should be stalled", "usb.xferstatus.control_stall",
6379 FT_BOOLEAN, 32, NULL((void*)0), FREEBSD_STATUS_CONTROL_STALL0x00000400,
6380 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6381
6382 { &hf_usb_xferstatus_short_frames_ok,
6383 { "Short frames OK", "usb.xferstatus.short_frames_ok",
6384 FT_BOOLEAN, 32, NULL((void*)0), FREEBSD_STATUS_SHORT_FRAMES_OK0x00000800,
6385 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6386
6387 { &hf_usb_xferstatus_short_xfer_ok,
6388 { "Short transfer OK", "usb.xferstatus.short_xfer_ok",
6389 FT_BOOLEAN, 32, NULL((void*)0), FREEBSD_STATUS_SHORT_XFER_OK0x00001000,
6390 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6391
6392 { &hf_usb_xferstatus_bdma_enable,
6393 { "BUS-DMA enabled", "usb.xferstatus.bdma_enable",
6394 FT_BOOLEAN, 32, NULL((void*)0), FREEBSD_STATUS_BDMA_ENABLE0x00002000,
6395 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6396
6397 { &hf_usb_xferstatus_bdma_no_post_sync,
6398 { "BUS-DMA post sync op not done", "usb.xferstatus.bdma_no_post_sync",
6399 FT_BOOLEAN, 32, NULL((void*)0), FREEBSD_STATUS_BDMA_NO_POST_SYNC0x00004000,
6400 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6401
6402 { &hf_usb_xferstatus_bdma_setup,
6403 { "BUS-DMA set up", "usb.xferstatus.bdma_setup",
6404 FT_BOOLEAN, 32, NULL((void*)0), FREEBSD_STATUS_BDMA_SETUP0x00008000,
6405 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6406
6407 { &hf_usb_xferstatus_isochronous_xfr,
6408 { "Isochronous transfer", "usb.xferstatus.isochronous_xfr",
6409 FT_BOOLEAN, 32, NULL((void*)0), FREEBSD_STATUS_ISOCHRONOUS_XFR0x00010000,
6410 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6411
6412 { &hf_usb_xferstatus_curr_dma_set,
6413 { "Current DMA set", "usb.xferstatus.curr_dma_set",
6414 FT_UINT32, BASE_DEC, NULL((void*)0), FREEBSD_STATUS_CURR_DMA_SET0x00020000,
6415 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6416
6417 { &hf_usb_xferstatus_can_cancel_immed,
6418 { "Transfer can be cancelled immediately", "usb.xferstatus.can_cancel_immed",
6419 FT_BOOLEAN, 32, NULL((void*)0), FREEBSD_STATUS_CAN_CANCEL_IMMED0x00040000,
6420 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6421
6422 { &hf_usb_xferstatus_doing_callback,
6423 { "Executing the callback", "usb.xferstatus.doing_callback",
6424 FT_BOOLEAN, 32, NULL((void*)0), FREEBSD_STATUS_DOING_CALLBACK0x00080000,
6425 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6426
6427 { &hf_usb_error,
6428 { "Error", "usb.error",
6429 FT_UINT32, BASE_DEC, VALS(usb_freebsd_err_vals)((0 ? (const struct _value_string*)0 : ((usb_freebsd_err_vals
))))
, 0x0,
6430 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6431
6432 { &hf_usb_interval,
6433 { "Interval", "usb.interval",
6434 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
6435 "Interval (ms)", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6436
6437 { &hf_usb_nframes,
6438 { "Number of following frames", "usb.nframes",
6439 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
6440 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6441
6442 { &hf_usb_packet_size,
6443 { "Packet size used", "usb.packet_size",
6444 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
6445 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6446
6447 { &hf_usb_packet_count,
6448 { "Packet count used", "usb.packet_count",
6449 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
6450 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6451
6452 { &hf_usb_speed,
6453 { "Speed", "usb.speed",
6454 FT_UINT8, BASE_DEC, VALS(usb_freebsd_speed_vals)((0 ? (const struct _value_string*)0 : ((usb_freebsd_speed_vals
))))
, 0x0,
6455 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6456
6457 { &hf_usb_frame_length,
6458 { "Frame length", "usb.frame.length",
6459 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
6460 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6461
6462 { &hf_usb_frame_flags,
6463 { "Frame flags", "usb.frame.flags",
6464 FT_UINT32, BASE_HEX, NULL((void*)0), 0x0,
6465 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6466
6467 { &hf_usb_frame_flags_read,
6468 { "Data direction is read", "usb.frame.read",
6469 FT_BOOLEAN, 32, NULL((void*)0), FREEBSD_FRAMEFLAG_READ0x00000001,
6470 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6471
6472 { &hf_usb_frame_flags_data_follows,
6473 { "Frame contains data", "usb.frame.data_follows",
6474 FT_BOOLEAN, 32, NULL((void*)0), FREEBSD_FRAMEFLAG_DATA_FOLLOWS0x00000002,
6475 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6476
6477 { &hf_usb_frame_data,
6478 { "Frame data", "usb.frame.data",
6479 FT_BYTES, BASE_NONE, NULL((void*)0), 0x0,
6480 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6481
6482 { &hf_usb_urb_id,
6483 { "URB id", "usb.urb_id",
6484 FT_UINT64, BASE_HEX, NULL((void*)0), 0x0,
6485 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6486
6487 { &hf_usb_linux_urb_type,
6488 { "URB type", "usb.urb_type",
6489 FT_CHAR, BASE_HEX, VALS(usb_linux_urb_type_vals)((0 ? (const struct _value_string*)0 : ((usb_linux_urb_type_vals
))))
, 0x0,
6490 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6491
6492 { &hf_usb_linux_transfer_type,
6493 { "URB transfer type", "usb.transfer_type",
6494 FT_UINT8, BASE_HEX, VALS(usb_linux_transfer_type_vals)((0 ? (const struct _value_string*)0 : ((usb_linux_transfer_type_vals
))))
, 0x0,
6495 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6496
6497 { &hf_usb_endpoint_address,
6498 { "Endpoint", "usb.endpoint_address",
6499 FT_UINT8, BASE_HEX, NULL((void*)0), 0x0,
6500 "USB endpoint address", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6501
6502 { &hf_usb_endpoint_direction,
6503 { "Direction", "usb.endpoint_address.direction",
6504 FT_UINT8, BASE_DEC, VALS(usb_endpoint_direction_vals)((0 ? (const struct _value_string*)0 : ((usb_endpoint_direction_vals
))))
, 0x80,
6505 "USB endpoint direction", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6506
6507 { &hf_usb_endpoint_number,
6508 { "Endpoint number", "usb.endpoint_address.number",
6509 FT_UINT8, BASE_DEC, NULL((void*)0), 0x0F,
6510 "USB endpoint number", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6511
6512 { &hf_usb_device_address,
6513 { "Device", "usb.device_address",
6514 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
6515 "USB device address", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6516
6517 { &hf_usb_bus_id,
6518 { "URB bus id", "usb.bus_id",
6519 FT_UINT16, BASE_DEC, NULL((void*)0), 0x0,
6520 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6521
6522 { &hf_usb_setup_flag,
6523 { "Device setup request", "usb.setup_flag",
6524 FT_CHAR, BASE_HEX|BASE_RANGE_STRING0x00000100, RVALS(usb_setup_flag_rvals)((0 ? (const struct _range_string*)0 : ((usb_setup_flag_rvals
))))
, 0x0,
6525 "USB device setup request is relevant (0) or not", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6526
6527 { &hf_usb_data_flag,
6528 { "Data", "usb.data_flag",
6529 FT_CHAR, BASE_HEX|BASE_RANGE_STRING0x00000100, RVALS(usb_data_flag_rvals)((0 ? (const struct _range_string*)0 : ((usb_data_flag_rvals)
)))
, 0x0,
6530 "USB data is present (0) or not", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6531
6532 { &hf_usb_urb_ts_sec,
6533 { "URB sec", "usb.urb_ts_sec",
6534 FT_UINT64, BASE_DEC, NULL((void*)0), 0x0,
6535 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6536
6537 { &hf_usb_urb_ts_usec,
6538 { "URB usec", "usb.urb_ts_usec",
6539 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
6540 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6541
6542 { &hf_usb_urb_status,
6543 { "URB status", "usb.urb_status",
6544 FT_INT32, BASE_DEC|BASE_EXT_STRING0x00000200, &linux_negative_errno_vals_ext, 0x0,
6545 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6546
6547 { &hf_usb_urb_len,
6548 { "URB length [bytes]", "usb.urb_len",
6549 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
6550 "URB length in bytes", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6551
6552 { &hf_usb_urb_data_len,
6553 { "Data length [bytes]", "usb.data_len",
6554 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
6555 "URB data length in bytes", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6556
6557 { &hf_usb_urb_unused_setup_header,
6558 { "Unused Setup Header",
6559 "usb.unused_setup_header", FT_NONE, BASE_NONE,
6560 NULL((void*)0), 0x0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6561
6562 { &hf_usb_urb_interval,
6563 { "Interval",
6564 "usb.interval", FT_UINT32, BASE_DEC,
6565 NULL((void*)0), 0x0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6566
6567 { &hf_usb_urb_start_frame,
6568 { "Start frame",
6569 "usb.start_frame", FT_UINT32, BASE_DEC,
6570 NULL((void*)0), 0x0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6571
6572 { &hf_usb_urb_copy_of_transfer_flags,
6573 { "Copy of Transfer Flags",
6574 "usb.copy_of_transfer_flags", FT_UINT32, BASE_HEX,
6575 NULL((void*)0), 0x0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6576
6577 { &hf_short_not_ok,
6578 { "Short not OK",
6579 "usb.transfer_flags.short_not_ok", FT_BOOLEAN, 32,
6580 NULL((void*)0), URB_SHORT_NOT_OK0x00000001, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6581
6582 { &hf_iso_asap,
6583 { "ISO ASAP",
6584 "usb.transfer_flags.iso_asap", FT_BOOLEAN, 32,
6585 NULL((void*)0), URB_ISO_ASAP0x00000002, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6586
6587 { &hf_no_transfer_dma_map,
6588 { "No transfer DMA map",
6589 "usb.transfer_flags.no_transfer_dma_map", FT_BOOLEAN, 32,
6590 NULL((void*)0), URB_NO_TRANSFER_DMA_MAP0x00000004, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6591
6592 { &hf_no_fsbr,
6593 { "No FSBR",
6594 "usb.transfer_flags.no_fsbr", FT_BOOLEAN, 32,
6595 NULL((void*)0), URB_NO_FSBR0x00000020, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6596
6597 { &hf_zero_packet,
6598 { "Zero Packet", "usb.transfer_flags.zero_packet", FT_BOOLEAN, 32,
6599 NULL((void*)0), URB_ZERO_PACKET0x00000040, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6600
6601 { &hf_no_interrupt,
6602 { "No Interrupt", "usb.transfer_flags.no_interrupt", FT_BOOLEAN, 32,
6603 NULL((void*)0), URB_NO_INTERRUPT0x00000080, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6604
6605 { &hf_free_buffer,
6606 { "Free Buffer", "usb.transfer_flags.free_buffer", FT_BOOLEAN, 32,
6607 NULL((void*)0), URB_FREE_BUFFER0x00000100, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6608
6609 { &hf_dir_in,
6610 { "Dir IN", "usb.transfer_flags.dir_in", FT_BOOLEAN, 32,
6611 NULL((void*)0), URB_DIR_IN0x00000200, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6612
6613 { &hf_dma_map_single,
6614 { "DMA Map Single", "usb.transfer_flags.dma_map_single", FT_BOOLEAN, 32,
6615 NULL((void*)0), URB_DMA_MAP_SINGLE0x00010000, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6616
6617 { &hf_dma_map_page,
6618 { "DMA Map Page", "usb.transfer_flags.dma_map_page", FT_BOOLEAN, 32,
6619 NULL((void*)0), URB_DMA_MAP_PAGE0x00020000, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6620
6621 { &hf_dma_map_sg,
6622 { "DMA Map SG", "usb.transfer_flags.dma_map_sg", FT_BOOLEAN, 32,
6623 NULL((void*)0), URB_DMA_MAP_SG0x00040000, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6624
6625 { &hf_map_local,
6626 { "Map Local", "usb.transfer_flags.map_local", FT_BOOLEAN, 32,
6627 NULL((void*)0), URB_MAP_LOCAL0x00080000, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6628
6629 { &hf_setup_map_single,
6630 { "Setup Map Single", "usb.transfer_flags.setup_map_single", FT_BOOLEAN, 32,
6631 NULL((void*)0), URB_SETUP_MAP_SINGLE0x00100000, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6632
6633 { &hf_setup_map_local,
6634 { "Setup Map Local", "usb.transfer_flags.setup_map_local", FT_BOOLEAN, 32,
6635 NULL((void*)0), URB_SETUP_MAP_LOCAL0x00200000, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6636
6637 { &hf_dma_sg_combined,
6638 { "DMA S-G Combined", "usb.transfer_flags.dma_sg_combined", FT_BOOLEAN, 32,
6639 NULL((void*)0), URB_DMA_SG_COMBINED0x00400000, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6640
6641 { &hf_aligned_temp_buffer,
6642 { "Aligned Temp Buffer", "usb.transfer_flags.aligned_temp_buffer", FT_BOOLEAN, 32,
6643 NULL((void*)0), URB_ALIGNED_TEMP_BUFFER0x00800000, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6644
6645 /* Win32 USBPcap pseudoheader */
6646 { &hf_usb_win32_header_len,
6647 { "USBPcap pseudoheader length", "usb.usbpcap_header_len",
6648 FT_UINT16, BASE_DEC, NULL((void*)0), 0x0,
6649 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6650
6651 { &hf_usb_irp_id,
6652 { "IRP ID", "usb.irp_id",
6653 FT_UINT64, BASE_HEX, NULL((void*)0), 0x0,
6654 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6655
6656 { &hf_usb_usbd_status,
6657 { "IRP USBD_STATUS", "usb.usbd_status",
6658 FT_UINT32, BASE_HEX | BASE_EXT_STRING0x00000200, &win32_usbd_status_vals_ext, 0x0,
6659 "USB request status value", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6660
6661 { &hf_usb_function,
6662 { "URB Function", "usb.function",
6663 FT_UINT16, BASE_HEX|BASE_EXT_STRING0x00000200, &win32_urb_function_vals_ext, 0x0,
6664 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6665
6666 { &hf_usb_info,
6667 { "IRP information", "usb.irp_info",
6668 FT_UINT8, BASE_HEX, NULL((void*)0), 0x0,
6669 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6670
6671 { &hf_usb_usbpcap_info_reserved,
6672 { "Reserved", "usb.irp_info.reserved",
6673 FT_UINT8, BASE_HEX, NULL((void*)0), 0xFE,
6674 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6675
6676 { &hf_usb_usbpcap_info_direction,
6677 { "Direction", "usb.irp_info.direction",
6678 FT_UINT8, BASE_HEX, VALS(win32_usb_info_direction_vals)((0 ? (const struct _value_string*)0 : ((win32_usb_info_direction_vals
))))
, 0x01,
6679 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6680
6681 { &hf_usb_win32_device_address,
6682 { "Device address", "usb.device_address",
6683 FT_UINT16, BASE_DEC, NULL((void*)0), 0x0,
6684 "Windows USB device address", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6685
6686 { &hf_usb_win32_transfer_type,
6687 { "URB transfer type", "usb.transfer_type",
6688 FT_UINT8, BASE_HEX, VALS(win32_usb_transfer_type_vals)((0 ? (const struct _value_string*)0 : ((win32_usb_transfer_type_vals
))))
, 0x0,
6689 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } },
6690
6691 { &hf_usb_win32_data_len,
6692 { "Packet Data Length", "usb.data_len",
6693 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
6694 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6695
6696 { &hf_usb_win32_control_stage,
6697 { "Control transfer stage", "usb.control_stage",
6698 FT_UINT8, BASE_DEC, VALS(usb_control_stage_vals)((0 ? (const struct _value_string*)0 : ((usb_control_stage_vals
))))
, 0x0,
6699 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6700
6701 { &hf_usb_win32_iso_start_frame,
6702 { "Isochronous transfer start frame", "usb.win32.iso_frame",
6703 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
6704 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6705
6706 { &hf_usb_win32_iso_num_packets,
6707 { "Isochronous transfer number of packets", "usb.win32.iso_num_packets",
6708 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
6709 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6710
6711 { &hf_usb_win32_iso_error_count,
6712 { "Isochronous transfer error count", "usb.win32.iso_error_count",
6713 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
6714 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6715
6716 { &hf_usb_win32_iso_offset,
6717 { "ISO Data offset", "usb.win32.iso_offset",
6718 FT_UINT32, BASE_HEX, NULL((void*)0), 0x0,
6719 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6720
6721 { &hf_usb_win32_iso_length,
6722 { "ISO Data length", "usb.win32.iso_data_len",
6723 FT_UINT32, BASE_HEX, NULL((void*)0), 0x0,
6724 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6725
6726 { &hf_usb_win32_iso_status,
6727 { "ISO USBD status", "usb.win32.iso_status",
6728 FT_UINT32, BASE_HEX | BASE_EXT_STRING0x00000200, &win32_usbd_status_vals_ext, 0x0,
6729 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6730
6731 /* macOS usbdump pseudoheader */
6732 { &hf_usb_darwin_bcd_version,
6733 { "Darwin header bcdVersion", "usb.darwin.bcdVersion",
6734 FT_UINT16, BASE_HEX, NULL((void*)0), 0x0,
6735 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6736
6737 { &hf_usb_darwin_header_len,
6738 { "Darwin header length", "usb.darwin.header_len",
6739 FT_UINT8, BASE_DEC, NULL((void*)0), 0x0,
6740 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6741
6742 { &hf_usb_darwin_request_type,
6743 { "Request type", "usb.darwin.request_type",
6744 FT_UINT8, BASE_DEC, VALS(usb_darwin_request_type_vals)((0 ? (const struct _value_string*)0 : ((usb_darwin_request_type_vals
))))
, 0x0,
6745 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6746
6747 { &hf_usb_darwin_io_len,
6748 { "I/O length [bytes]", "usb.darwin.io_len",
6749 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
6750 "Request length in bytes", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6751
6752 { &hf_usb_darwin_io_status,
6753 { "Request status", "usb.darwin.io_status",
6754 FT_UINT32, BASE_HEX | BASE_EXT_STRING0x00000200, &usb_darwin_status_vals_ext, 0x0,
6755 "USB request status", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6756
6757 { &hf_usb_darwin_iso_num_packets,
6758 { "Isochronous transfer number of frames", "usb.darwin.io_frame_count",
6759 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
6760 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6761
6762 { &hf_usb_darwin_io_id,
6763 { "I/O ID", "usb.darwin.io_id",
6764 FT_UINT64, BASE_HEX, NULL((void*)0), 0x0,
6765 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6766
6767 { &hf_usb_darwin_device_location,
6768 { "Device location ID", "usb.darwin.location_id",
6769 FT_UINT32, BASE_HEX, NULL((void*)0), 0x0,
6770 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6771
6772 { &hf_usb_darwin_speed,
6773 { "Device speed", "usb.darwin_device_speed",
6774 FT_UINT8, BASE_DEC, VALS(usb_darwin_speed_vals)((0 ? (const struct _value_string*)0 : ((usb_darwin_speed_vals
))))
, 0x0,
6775 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6776
6777 { &hf_usb_darwin_device_address,
6778 { "USB device index", "usb.darwin.device_address",
6779 FT_UINT8, BASE_DEC, NULL((void*)0), 0x0,
6780 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6781
6782 { &hf_usb_darwin_endpoint_address,
6783 { "Endpoint address", "usb.darwin.endpoint_address",
6784 FT_UINT8, BASE_HEX, NULL((void*)0), 0x0,
6785 "Endpoint address and direction", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6786
6787 { &hf_usb_darwin_endpoint_type,
6788 { "Endpoint transfer type", "usb.darwin.endpoint_type",
6789 FT_UINT8, BASE_DEC, VALS(usb_darwin_endpoint_type_vals)((0 ? (const struct _value_string*)0 : ((usb_darwin_endpoint_type_vals
))))
, 0x0,
6790 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6791
6792 { &hf_usb_darwin_iso_status,
6793 { "Frame status", "usb.darwin.iso.status",
6794 FT_UINT32, BASE_HEX | BASE_EXT_STRING0x00000200, &usb_darwin_status_vals_ext, 0x0,
6795 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6796
6797 { &hf_usb_darwin_iso_timestamp,
6798 { "Frame timestamp", "usb.darwin.iso.timestamp",
6799 FT_UINT64, BASE_HEX, NULL((void*)0), 0x0,
6800 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6801
6802 { &hf_usb_darwin_iso_frame_number,
6803 { "Frame number", "usb.darwin.iso.frame_number",
6804 FT_UINT64, BASE_HEX, NULL((void*)0), 0x0,
6805 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6806
6807 { &hf_usb_bmRequestType,
6808 { "bmRequestType", "usb.bmRequestType",
6809 FT_UINT8, BASE_HEX, NULL((void*)0), 0x0,
6810 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6811
6812 /* Only used when response type cannot be determined */
6813 { &hf_usb_control_response_generic,
6814 { "CONTROL response data", "usb.control.Response",
6815 FT_BYTES, BASE_NONE, NULL((void*)0), 0x0,
6816 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6817
6818 { &hf_usb_request,
6819 { "bRequest", "usb.setup.bRequest",
6820 FT_UINT8, BASE_DEC | BASE_EXT_STRING0x00000200, &setup_request_names_vals_ext, 0x0,
6821 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6822
6823 /* Same as hf_usb_request but no descriptive text */
6824 { &hf_usb_request_unknown_class,
6825 { "bRequest", "usb.setup.bRequest",
6826 FT_UINT8, BASE_DEC, NULL((void*)0), 0x0,
6827 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6828
6829 { &hf_usb_value,
6830 { "wValue", "usb.setup.wValue",
6831 FT_UINT16, BASE_HEX, NULL((void*)0), 0x0,
6832 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6833
6834 { &hf_usb_index,
6835 { "wIndex", "usb.setup.wIndex",
6836 FT_UINT16, BASE_DEC_HEX, NULL((void*)0), 0x0,
6837 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6838
6839 { &hf_usb_length,
6840 { "wLength", "usb.setup.wLength",
6841 FT_UINT16, BASE_DEC, NULL((void*)0), 0x0,
6842 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6843
6844 { &hf_usb_device_wFeatureSelector,
6845 { "wFeatureSelector", "usb.setup.wFeatureSelector",
6846 FT_UINT16, BASE_DEC, VALS(usb_device_feature_selector_vals)((0 ? (const struct _value_string*)0 : ((usb_device_feature_selector_vals
))))
, 0x0,
6847 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6848
6849 { &hf_usb_interface_wFeatureSelector,
6850 { "wFeatureSelector", "usb.setup.wFeatureSelector",
6851 FT_UINT16, BASE_DEC, VALS(usb_interface_feature_selector_vals)((0 ? (const struct _value_string*)0 : ((usb_interface_feature_selector_vals
))))
, 0x0,
6852 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6853
6854 { &hf_usb_endpoint_wFeatureSelector,
6855 { "wFeatureSelector", "usb.setup.wFeatureSelector",
6856 FT_UINT16, BASE_DEC, VALS(usb_endpoint_feature_selector_vals)((0 ? (const struct _value_string*)0 : ((usb_endpoint_feature_selector_vals
))))
, 0x0,
6857 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6858
6859 { &hf_usb_wInterface,
6860 { "wInterface", "usb.setup.wInterface",
6861 FT_UINT16, BASE_DEC, NULL((void*)0), 0x0,
6862 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6863
6864 { &hf_usb_wEndpoint,
6865 { "wEndpoint", "usb.setup.wEndpoint",
6866 FT_UINT16, BASE_DEC, NULL((void*)0), 0x0,
6867 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6868
6869 { &hf_usb_wStatus,
6870 { "wStatus", "usb.setup.wStatus",
6871 FT_UINT16, BASE_HEX, NULL((void*)0), 0x0,
6872 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6873
6874 { &hf_usb_wFrameNumber,
6875 { "wFrameNumber", "usb.setup.wFrameNumber",
6876 FT_UINT16, BASE_DEC, NULL((void*)0), 0x0,
6877 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6878
6879 /* --------------------------------- */
6880 { &hf_usb_iso_error_count, /* host endian byte order */
6881 { "ISO error count", "usb.iso.error_count",
6882 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
6883 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6884
6885 { &hf_usb_iso_numdesc,
6886 { "Number of ISO descriptors", "usb.iso.numdesc",
6887 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
6888 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6889
6890 /* fields of struct mon_bin_isodesc from linux/drivers/usb/mon/mon_bin.c */
6891 { &hf_usb_iso_status,
6892 { "Status", "usb.iso.iso_status",
6893 FT_INT32, BASE_DEC|BASE_EXT_STRING0x00000200, &linux_negative_errno_vals_ext, 0x0,
6894 "ISO descriptor status", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6895
6896 { &hf_usb_iso_off,
6897 { "Offset [bytes]", "usb.iso.iso_off",
6898 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
6899 "ISO data offset in bytes starting from the end of the last ISO descriptor", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6900
6901 { &hf_usb_iso_len,
6902 { "Length [bytes]", "usb.iso.iso_len",
6903 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
6904 "ISO data length in bytes", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6905
6906 { &hf_usb_iso_actual_len,
6907 { "Actual Length [bytes]", "usb.iso.iso_actual_len",
6908 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
6909 "ISO data actual length in bytes", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6910
6911 { &hf_usb_iso_pad, /* host endian byte order */
6912 { "Padding", "usb.iso.pad",
6913 FT_UINT32, BASE_HEX, NULL((void*)0), 0x0,
6914 "Padding field of ISO descriptor structure", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6915
6916 { &hf_usb_iso_data,
6917 {"ISO Data", "usb.iso.data",
6918 FT_BYTES, BASE_NONE, NULL((void*)0), 0x0,
6919 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6920 /* --------------------------------- */
6921#if 0
6922 { &hf_usb_data_len,
6923 {"Application Data Length", "usb.data.length",
6924 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
6925 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6926#endif
6927
6928 { &hf_usb_capdata,
6929 {"Leftover Capture Data", "usb.capdata",
6930 FT_BYTES, BASE_NONE, NULL((void*)0), 0x0,
6931 "Padding added by the USB capture system", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6932
6933 { &hf_usb_bmRequestType_direction,
6934 { "Direction", "usb.bmRequestType.direction",
6935 FT_BOOLEAN, 8, TFS(&tfs_bmrequesttype_direction)((0 ? (const struct true_false_string*)0 : ((&tfs_bmrequesttype_direction
))))
, USB_DIR_IN0x80,
6936 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6937
6938 { &hf_usb_bmRequestType_type,
6939 { "Type", "usb.bmRequestType.type",
6940 FT_UINT8, BASE_HEX, VALS(bmrequesttype_type_vals)((0 ? (const struct _value_string*)0 : ((bmrequesttype_type_vals
))))
, USB_TYPE_MASK(0x03 << 5),
6941 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6942
6943 { &hf_usb_bmRequestType_recipient,
6944 { "Recipient", "usb.bmRequestType.recipient",
6945 FT_UINT8, BASE_HEX, VALS(bmrequesttype_recipient_vals)((0 ? (const struct _value_string*)0 : ((bmrequesttype_recipient_vals
))))
, 0x1f,
6946 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6947
6948 { &hf_usb_bDescriptorType,
6949 { "bDescriptorType", "usb.bDescriptorType",
6950 FT_UINT8, BASE_HEX|BASE_EXT_STRING0x00000200, &std_descriptor_type_vals_ext, 0x0,
6951 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6952
6953 /* Only used when descriptor type cannot be determined */
6954 { &hf_usb_get_descriptor_resp_generic,
6955 { "GET DESCRIPTOR Response data", "usb.getDescriptor.Response",
6956 FT_BYTES, BASE_NONE, NULL((void*)0), 0x0,
6957 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6958
6959 { &hf_usb_descriptor_index,
6960 { "Descriptor Index", "usb.DescriptorIndex",
6961 FT_UINT8, BASE_HEX, NULL((void*)0), 0x0,
6962 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6963
6964 { &hf_usb_language_id,
6965 { "Language Id", "usb.LanguageId",
6966 FT_UINT16, BASE_HEX|BASE_EXT_STRING0x00000200,&usb_langid_vals_ext, 0x0,
6967 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6968
6969 { &hf_usb_bLength,
6970 { "bLength", "usb.bLength",
6971 FT_UINT8, BASE_DEC, NULL((void*)0), 0x0,
6972 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6973
6974 { &hf_usb_bcdUSB,
6975 { "bcdUSB", "usb.bcdUSB",
6976 FT_UINT16, BASE_HEX, NULL((void*)0), 0x0,
6977 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6978
6979 { &hf_usb_bDeviceClass,
6980 { "bDeviceClass", "usb.bDeviceClass",
6981 FT_UINT8, BASE_HEX|BASE_EXT_STRING0x00000200, &usb_class_vals_ext, 0x0,
6982 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6983
6984 { &hf_usb_bDeviceSubClass,
6985 { "bDeviceSubClass", "usb.bDeviceSubClass",
6986 FT_UINT8, BASE_DEC, NULL((void*)0), 0x0,
6987 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6988
6989 { &hf_usb_bDeviceProtocol,
6990 { "bDeviceProtocol", "usb.bDeviceProtocol",
6991 FT_UINT8, BASE_DEC, NULL((void*)0), 0x0,
6992 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6993
6994 { &hf_usb_bMaxPacketSize0,
6995 { "bMaxPacketSize0", "usb.bMaxPacketSize0",
6996 FT_UINT8, BASE_DEC, NULL((void*)0), 0x0,
6997 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
6998
6999 { &hf_usb_idVendor,
7000 { "idVendor", "usb.idVendor",
7001 FT_UINT16, BASE_HEX | BASE_EXT_STRING0x00000200, &ext_usb_vendors_vals, 0x0,
7002 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7003
7004 { &hf_usb_idProduct,
7005 { "idProduct", "usb.idProduct",
7006 FT_UINT16, BASE_HEX, NULL((void*)0), 0x0,
7007 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7008
7009 { &hf_usb_bcdDevice,
7010 { "bcdDevice", "usb.bcdDevice",
7011 FT_UINT16, BASE_HEX, NULL((void*)0), 0x0,
7012 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7013
7014 { &hf_usb_iManufacturer,
7015 { "iManufacturer", "usb.iManufacturer",
7016 FT_UINT8, BASE_DEC, NULL((void*)0), 0x0,
7017 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7018
7019 { &hf_usb_iProduct,
7020 { "iProduct", "usb.iProduct",
7021 FT_UINT8, BASE_DEC, NULL((void*)0), 0x0,
7022 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7023
7024 { &hf_usb_iSerialNumber,
7025 { "iSerialNumber", "usb.iSerialNumber",
7026 FT_UINT8, BASE_DEC, NULL((void*)0), 0x0,
7027 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7028
7029 { &hf_usb_bNumConfigurations,
7030 { "bNumConfigurations", "usb.bNumConfigurations",
7031 FT_UINT8, BASE_DEC, NULL((void*)0), 0x0,
7032 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7033
7034 { &hf_usb_wLANGID,
7035 { "wLANGID", "usb.wLANGID",
7036 FT_UINT16, BASE_HEX|BASE_EXT_STRING0x00000200,&usb_langid_vals_ext, 0x0,
7037 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7038
7039 { &hf_usb_bString,
7040 { "bString", "usb.bString",
7041 FT_STRING, BASE_NONE, NULL((void*)0), 0x0,
7042 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7043
7044 { &hf_usb_bInterfaceNumber,
7045 { "bInterfaceNumber", "usb.bInterfaceNumber",
7046 FT_UINT8, BASE_DEC, NULL((void*)0), 0x0,
7047 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7048
7049 { &hf_usb_bAlternateSetting,
7050 { "bAlternateSetting", "usb.bAlternateSetting",
7051 FT_UINT8, BASE_DEC, NULL((void*)0), 0x0,
7052 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7053
7054 { &hf_usb_bNumEndpoints,
7055 { "bNumEndpoints", "usb.bNumEndpoints",
7056 FT_UINT8, BASE_DEC, NULL((void*)0), 0x0,
7057 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7058
7059 { &hf_usb_bInterfaceClass,
7060 { "bInterfaceClass", "usb.bInterfaceClass",
7061 FT_UINT8, BASE_HEX|BASE_EXT_STRING0x00000200, &usb_class_vals_ext, 0x0,
7062 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7063
7064 { &hf_usb_bInterfaceSubClass,
7065 { "bInterfaceSubClass", "usb.bInterfaceSubClass",
7066 FT_UINT8, BASE_HEX, NULL((void*)0), 0x0,
7067 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7068
7069 { &hf_usb_bInterfaceSubClass_audio,
7070 { "bInterfaceSubClass", "usb.bInterfaceSubClass",
7071 FT_UINT8, BASE_HEX | BASE_EXT_STRING0x00000200, &ext_usb_audio_subclass_vals, 0x0,
7072 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7073
7074 { &hf_usb_bInterfaceSubClass_cdc,
7075 { "bInterfaceSubClass", "usb.bInterfaceSubClass",
7076 FT_UINT8, BASE_HEX | BASE_EXT_STRING0x00000200, &ext_usb_com_subclass_vals, 0x0,
7077 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7078
7079 { &hf_usb_bInterfaceSubClass_massstorage ,
7080 { "bInterfaceSubClass", "usb.bInterfaceSubClass",
7081 FT_UINT8, BASE_HEX | BASE_EXT_STRING0x00000200, &ext_usb_massstorage_subclass_vals, 0x0,
7082 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7083
7084 { &hf_usb_bInterfaceSubClass_hid,
7085 { "bInterfaceSubClass", "usb.bInterfaceSubClass",
7086 FT_UINT8, BASE_HEX | BASE_EXT_STRING0x00000200, &usb_hid_subclass_vals_ext, 0x0,
7087 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7088
7089 { &hf_usb_bInterfaceSubClass_misc,
7090 { "bInterfaceSubClass", "usb.bInterfaceSubClass",
7091 FT_UINT8, BASE_HEX | BASE_EXT_STRING0x00000200, &usb_misc_subclass_vals_ext, 0x0,
7092 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7093
7094 { &hf_usb_bInterfaceSubClass_app,
7095 { "bInterfaceSubClass", "usb.bInterfaceSubClass",
7096 FT_UINT8, BASE_HEX | BASE_EXT_STRING0x00000200, &usb_app_subclass_vals_ext, 0x0,
7097 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7098
7099 { &hf_usb_bInterfaceProtocol,
7100 { "bInterfaceProtocol", "usb.bInterfaceProtocol",
7101 FT_UINT8, BASE_HEX, NULL((void*)0), 0x0,
7102 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7103
7104 { &hf_usb_bInterfaceProtocol_cdc,
7105 { "bInterfaceProtocol", "usb.bInterfaceProtocol",
7106 FT_UINT8, BASE_HEX | BASE_EXT_STRING0x00000200, &usb_cdc_protocol_vals_ext, 0x0,
7107 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7108
7109 { &hf_usb_bInterfaceProtocol_massstorage,
7110 { "bInterfaceProtocol", "usb.bInterfaceProtocol",
7111 FT_UINT8, BASE_HEX | BASE_EXT_STRING0x00000200, &usb_massstorage_protocol_vals_ext, 0x0,
7112 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7113
7114 { &hf_usb_bInterfaceProtocol_cdc_data,
7115 { "bInterfaceProtocol", "usb.bInterfaceProtocol",
7116 FT_UINT8, BASE_HEX | BASE_EXT_STRING0x00000200, &usb_cdc_data_protocol_vals_ext, 0x0,
7117 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7118
7119 { &hf_usb_bInterfaceProtocol_hid_boot,
7120 { "bInterfaceProtocol", "usb.bInterfaceProtocol",
7121 FT_UINT8, BASE_HEX | BASE_EXT_STRING0x00000200, &usb_hid_boot_protocol_vals_ext, 0x0,
7122 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7123
7124 { &hf_usb_bInterfaceProtocol_app_dfu,
7125 { "bInterfaceProtocol", "usb.bInterfaceProtocol",
7126 FT_UINT8, BASE_HEX | BASE_EXT_STRING0x00000200, &usb_app_dfu_protocol_vals_ext, 0x0,
7127 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7128
7129 { &hf_usb_bInterfaceProtocol_app_irda,
7130 { "bInterfaceProtocol", "usb.bInterfaceProtocol",
7131 FT_UINT8, BASE_HEX | BASE_EXT_STRING0x00000200, &usb_app_irda_protocol_vals_ext, 0x0,
7132 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7133
7134 { &hf_usb_bInterfaceProtocol_app_usb_test_and_measurement,
7135 { "bInterfaceProtocol", "usb.bInterfaceProtocol",
7136 FT_UINT8, BASE_HEX | BASE_EXT_STRING0x00000200, &usb_app_usb_test_and_measurement_protocol_vals_ext, 0x0,
7137 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7138
7139
7140 { &hf_usb_iInterface,
7141 { "iInterface", "usb.iInterface",
7142 FT_UINT8, BASE_DEC, NULL((void*)0), 0x0,
7143 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7144
7145 { &hf_usb_bEndpointAddress,
7146 { "bEndpointAddress", "usb.bEndpointAddress",
7147 FT_UINT8, BASE_HEX, NULL((void*)0), 0x0,
7148 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7149
7150 { &hf_usb_configuration_bmAttributes,
7151 { "Configuration bmAttributes", "usb.configuration.bmAttributes",
7152 FT_UINT8, BASE_HEX, NULL((void*)0), 0x0,
7153 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7154
7155 { &hf_usb_bmAttributes,
7156 { "bmAttributes", "usb.bmAttributes",
7157 FT_UINT8, BASE_HEX, NULL((void*)0), 0x0,
7158 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7159
7160 { &hf_usb_bEndpointAttributeTransfer,
7161 { "Transfertype", "usb.bmAttributes.transfer",
7162 FT_UINT8, BASE_HEX, VALS(usb_bmAttributes_transfer_vals)((0 ? (const struct _value_string*)0 : ((usb_bmAttributes_transfer_vals
))))
, 0x03,
7163 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7164
7165 { &hf_usb_bEndpointAttributeSynchonisation,
7166 { "Synchronisationtype", "usb.bmAttributes.sync",
7167 FT_UINT8, BASE_HEX, VALS(usb_bmAttributes_sync_vals)((0 ? (const struct _value_string*)0 : ((usb_bmAttributes_sync_vals
))))
, 0x0c,
7168 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7169
7170 { &hf_usb_bEndpointAttributeBehaviour,
7171 { "Behaviourtype", "usb.bmAttributes.behaviour",
7172 FT_UINT8, BASE_HEX, VALS(usb_bmAttributes_behaviour_vals)((0 ? (const struct _value_string*)0 : ((usb_bmAttributes_behaviour_vals
))))
, 0x30,
7173 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7174
7175 { &hf_usb_wMaxPacketSize,
7176 { "wMaxPacketSize", "usb.wMaxPacketSize",
7177 FT_UINT16, BASE_DEC, NULL((void*)0), 0x0,
7178 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7179
7180 { &hf_usb_wMaxPacketSize_size,
7181 { "Maximum Packet Size", "usb.wMaxPacketSize.size",
7182 FT_UINT16, BASE_DEC, NULL((void*)0), 0x07FF,
7183 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7184
7185 { &hf_usb_wMaxPacketSize_slots,
7186 { "Transactions per microframe", "usb.wMaxPacketSize.slots",
7187 FT_UINT16, BASE_DEC, VALS(usb_wMaxPacketSize_slots_vals)((0 ? (const struct _value_string*)0 : ((usb_wMaxPacketSize_slots_vals
))))
, (3<<11),
7188 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7189
7190 { &hf_usb_bInterval,
7191 { "bInterval", "usb.bInterval",
7192 FT_UINT8, BASE_DEC, NULL((void*)0), 0x0,
7193 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7194
7195 { &hf_usb_bMaxBurst,
7196 { "bMaxBurst", "usb.bMaxBurst",
7197 FT_UINT8, BASE_DEC, NULL((void*)0), 0x0,
7198 "Valid values are from 0 to 15. For control endpoints this value shall be 0.", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7199
7200 { &hf_usb_audio_bRefresh,
7201 { "bRefresh", "usb.audio.bRefresh",
7202 FT_UINT8, BASE_DEC, NULL((void*)0), 0x00,
7203 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7204
7205 { &hf_usb_audio_bSynchAddress,
7206 { "bSynchAddress", "usb.audio.bSynchAddress",
7207 FT_UINT8, BASE_DEC, NULL((void*)0), 0x00,
7208 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7209
7210 { &hf_usb_bSSEndpointAttributeBulkMaxStreams,
7211 { "MaxStreams", "usb.bmAttributes.MaxStreams",
7212 FT_UINT8, BASE_DEC, NULL((void*)0), 0x0F,
7213 "Number of streams = 2 to the power MaxStreams", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7214
7215 { &hf_usb_bSSEndpointAttributeIsoMult,
7216 { "Mult", "usb.bmAttributes.Mult",
7217 FT_UINT8, BASE_DEC, NULL((void*)0), 0x03,
7218 "Maximum number of packets = bMaxBurst * (Mult + 1)", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } },
7219
7220 { &hf_usb_wBytesPerInterval,
7221 { "wBytesPerInterval", "usb.wBytesPerInterval",
7222 FT_UINT16, BASE_DEC, NULL((void*)0), 0x0,
7223 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) } },
7224
7225 { &hf_usb_wTotalLength,
7226 { "wTotalLength", "usb.wTotalLength",
7227 FT_UINT16, BASE_DEC, NULL((void*)0), 0x0,
7228 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7229
7230 { &hf_usb_bNumInterfaces,
7231 { "bNumInterfaces", "usb.bNumInterfaces",
7232 FT_UINT8, BASE_DEC, NULL((void*)0), 0x0,
7233 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7234
7235 { &hf_usb_bConfigurationValue,
7236 { "bConfigurationValue", "usb.bConfigurationValue",
7237 FT_UINT8, BASE_DEC, NULL((void*)0), 0x0,
7238 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7239
7240 { &hf_usb_iConfiguration,
7241 { "iConfiguration", "usb.iConfiguration",
7242 FT_UINT8, BASE_DEC, NULL((void*)0), 0x0,
7243 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7244
7245 { &hf_usb_bMaxPower,
7246 { "bMaxPower", "usb.bMaxPower",
7247 FT_UINT8, BASE_DEC, NULL((void*)0), 0x0,
7248 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7249
7250 { &hf_usb_configuration_legacy10buspowered,
7251 { "Must be 1", "usb.configuration.legacy10buspowered",
7252 FT_BOOLEAN, 8, TFS(&tfs_mustbeone)((0 ? (const struct true_false_string*)0 : ((&tfs_mustbeone
))))
, 0x80,
7253 "Legacy USB 1.0 bus powered", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7254
7255 { &hf_usb_configuration_selfpowered,
7256 { "Self-Powered", "usb.configuration.selfpowered",
7257 FT_BOOLEAN, 8, TFS(&tfs_selfpowered)((0 ? (const struct true_false_string*)0 : ((&tfs_selfpowered
))))
, 0x40,
7258 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7259
7260 { &hf_usb_configuration_remotewakeup,
7261 { "Remote Wakeup", "usb.configuration.remotewakeup",
7262 FT_BOOLEAN, 8, TFS(&tfs_remotewakeup)((0 ? (const struct true_false_string*)0 : ((&tfs_remotewakeup
))))
, 0x20,
7263 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7264
7265 { &hf_usb_bEndpointAddress_number,
7266 { "Endpoint Number", "usb.bEndpointAddress.number",
7267 FT_UINT8, BASE_HEX, NULL((void*)0), 0x0f,
7268 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7269
7270 { &hf_usb_bEndpointAddress_direction,
7271 { "Direction", "usb.bEndpointAddress.direction",
7272 FT_BOOLEAN, 8, TFS(&tfs_endpoint_direction)((0 ? (const struct true_false_string*)0 : ((&tfs_endpoint_direction
))))
, 0x80,
7273 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7274
7275 { &hf_usb_request_in,
7276 { "Request in", "usb.request_in",
7277 FT_FRAMENUM, BASE_NONE, FRAMENUM_TYPE(FT_FRAMENUM_REQUEST)((gpointer) (glong) (FT_FRAMENUM_REQUEST)), 0,
7278 "The request to this packet is in this packet", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7279
7280 { &hf_usb_time,
7281 { "Time from request", "usb.time",
7282 FT_RELATIVE_TIME, BASE_NONE, NULL((void*)0), 0,
7283 "Time between Request and Response for USB cmds", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7284
7285 { &hf_usb_response_in,
7286 { "Response in", "usb.response_in",
7287 FT_FRAMENUM, BASE_NONE, FRAMENUM_TYPE(FT_FRAMENUM_RESPONSE)((gpointer) (glong) (FT_FRAMENUM_RESPONSE)), 0,
7288 "The response to this packet is in this packet", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7289
7290 { &hf_usb_bFirstInterface,
7291 { "bFirstInterface", "usb.bFirstInterface",
7292 FT_UINT8, BASE_DEC, NULL((void*)0), 0x0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7293
7294 { &hf_usb_bInterfaceCount,
7295 { "bInterfaceCount",
7296 "usb.bInterfaceCount", FT_UINT8, BASE_DEC,
7297 NULL((void*)0), 0x0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7298
7299 { &hf_usb_bFunctionClass,
7300 { "bFunctionClass", "usb.bFunctionClass",
7301 FT_UINT8, BASE_HEX|BASE_EXT_STRING0x00000200, &usb_class_vals_ext, 0x0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7302
7303 { &hf_usb_bFunctionSubClass,
7304 { "bFunctionSubClass",
7305 "usb.bFunctionSubClass", FT_UINT8, BASE_HEX,
7306 NULL((void*)0), 0x0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7307
7308 { &hf_usb_bFunctionProtocol,
7309 { "bFunctionProtocol", "usb.bFunctionProtocol",
7310 FT_UINT8, BASE_HEX, NULL((void*)0), 0x0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7311
7312 { &hf_usb_iFunction,
7313 { "iFunction",
7314 "usb.iFunction", FT_UINT8, BASE_DEC,
7315 NULL((void*)0), 0x0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7316
7317 { &hf_usb_bNumDeviceCaps,
7318 { "bNumDeviceCaps", "usb.bNumDeviceCaps",
7319 FT_UINT8, BASE_DEC, NULL((void*)0), 0x0,
7320 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7321
7322 { &hf_usb_bDevCapabilityType,
7323 { "bDevCapabilityType", "usb.bDevCapabilityType",
7324 FT_UINT8, BASE_HEX|BASE_EXT_STRING0x00000200, &usb_capability_vals_ext, 0x0,
7325 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7326
7327 { &hf_usb_usb20ext_bmAttributes,
7328 { "bmAttributes", "usb.usb20ext.bmAttributes",
7329 FT_UINT32, BASE_HEX, NULL((void*)0), 0x0,
7330 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7331
7332 { &hf_usb_usb20ext_LPM,
7333 { "LPM", "usb.usb20ext.bmAttributes.LPM",
7334 FT_BOOLEAN, 32, NULL((void*)0), 0x00000002,
7335 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7336
7337 { &hf_usb_usb20ext_BESL_HIRD,
7338 { "BESL & Alternate HIRD", "usb.usb20ext.bmAttributes.BESL",
7339 FT_BOOLEAN, 32, NULL((void*)0), 0x00000004,
7340 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7341
7342 { &hf_usb_usb20ext_baseline_BESL_valid,
7343 { "Baseline BESL valid", "usb.usb20ext.bmAttributes.baseline_BESL_valid",
7344 FT_BOOLEAN, 32, NULL((void*)0), 0x00000008,
7345 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7346
7347 { &hf_usb_usb20ext_deep_BESL_valid,
7348 { "Deep BESL valid", "usb.usb20ext.bmAttributes.deep_BESL_valid",
7349 FT_BOOLEAN, 32, NULL((void*)0), 0x00000010,
7350 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7351
7352 { &hf_usb_usb20ext_baseline_BESL,
7353 { "Recommended Baseline BESL", "usb.usb20ext.bmAttributes.baseline_BESL",
7354 FT_UINT32, BASE_CUSTOM, CF_FUNC(usb_lpm_besl_str)((const void *) (size_t) (usb_lpm_besl_str)), 0x00000F00,
7355 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7356
7357 { &hf_usb_usb20ext_deep_BESL,
7358 { "Recommended Deep BESL", "usb.usb20ext.bmAttributes.deep_BESL",
7359 FT_UINT32, BASE_CUSTOM, CF_FUNC(usb_lpm_besl_str)((const void *) (size_t) (usb_lpm_besl_str)), 0x0000F000,
7360 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7361
7362 { &hf_usb_bReserved,
7363 { "bReserved", "usb.bReserved",
7364 FT_UINT8, BASE_DEC, NULL((void*)0), 0x0,
7365 "This field is reserved and shall be set to zero", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7366
7367 { &hf_usb_PlatformCapabilityUUID,
7368 { "PlatformCapabilityUUID", "usb.PlatformCapabilityUUID",
7369 FT_GUID, BASE_NONE, NULL((void*)0), 0x0,
7370 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7371
7372 { &hf_usb_webusb_bcdVersion,
7373 { "bcdVersion", "usb.webusb.bcdVersion",
7374 FT_UINT16, BASE_HEX, NULL((void*)0), 0x0,
7375 "WebUSB descriptor version", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7376
7377 { &hf_usb_webusb_bVendorCode,
7378 { "bVendorCode", "usb.webusb.bVendorCode",
7379 FT_UINT8, BASE_DEC, NULL((void*)0), 0x0,
7380 "bRequest value for WebUSB", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7381
7382 { &hf_usb_webusb_iLandingPage,
7383 { "iLandingPage", "usb.webusb.iLandingPage",
7384 FT_UINT8, BASE_DEC, NULL((void*)0), 0x0,
7385 "URL for landing page", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7386
7387 { &hf_usb_msos20_dwWindowsVersion,
7388 { "dwWindowsVersion", "usb.msos20.dwWindowsVersion",
7389 FT_UINT32, BASE_HEX, NULL((void*)0), 0x0,
7390 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7391
7392 { &hf_usb_msos20_wMSOSDescriptorSetTotalLength,
7393 { "wMSOSDescriptorSetTotalLength", "usb.msos20.wMSOSDescriptorSetTotalLength",
7394 FT_UINT16, BASE_DEC, NULL((void*)0), 0x0,
7395 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7396
7397 { &hf_usb_msos20_bMS_VendorCode,
7398 { "bMS_VendorCode", "usb.msos20.bMS_VendorCode",
7399 FT_UINT8, BASE_DEC, NULL((void*)0), 0x0,
7400 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7401
7402 { &hf_usb_msos20_bAltEnumCode,
7403 { "bAltEnumCode", "usb.msos20.bAltEnumCode",
7404 FT_UINT8, BASE_DEC, NULL((void*)0), 0x0,
7405 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7406
7407 { &hf_usb_data_fragment,
7408 { "Data Fragment",
7409 "usb.data_fragment", FT_BYTES, BASE_NONE,
7410 NULL((void*)0), 0x0, NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7411 { &hf_usb_src,
7412 { "Source", "usb.src",
7413 FT_STRING, BASE_NONE, NULL((void*)0), 0x0,
7414 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7415 },
7416 { &hf_usb_dst,
7417 { "Destination", "usb.dst",
7418 FT_STRING, BASE_NONE, NULL((void*)0), 0x0,
7419 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7420 },
7421 { &hf_usb_addr,
7422 { "Source or Destination", "usb.addr",
7423 FT_STRING, BASE_NONE, NULL((void*)0), 0x0,
7424 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7425 },
7426 { &hf_usb_ss_bmAttributes,
7427 { "bmAttributes", "usb.ss.bmAttributes",
7428 FT_UINT8, BASE_HEX, NULL((void*)0), 0x0,
7429 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7430 { &hf_usb_ss_bmAttributes_reserved0,
7431 { "Reserved", "usb.ss.bmAttributes.reserved0",
7432 FT_BOOLEAN, 8, TFS(&tfs_usb_ss_bmAttributes_reserved0)((0 ? (const struct true_false_string*)0 : ((&tfs_usb_ss_bmAttributes_reserved0
))))
, 0x01,
7433 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7434 { &hf_usb_ss_bmAttributes_LTM,
7435 { "LTM", "usb.ss.bmAttributes.LTM",
7436 FT_BOOLEAN, 8, NULL((void*)0), 0x02,
7437 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7438 { &hf_usb_ss_bmAttributes_reserved7_2,
7439 { "Reserved", "usb.ss.bmAttributes.reserved7_2",
7440 FT_UINT8, BASE_HEX, NULL((void*)0), 0xFC,
7441 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7442 { &hf_usb_ss_wSpeedSupported,
7443 { "wSpeedSupported", "usb.ss.wSpeedSupported",
7444 FT_UINT16, BASE_HEX, NULL((void*)0), 0x0,
7445 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7446 { &hf_usb_ss_wSpeedSupported_LS,
7447 { SS_SPEED_SUPPORTED_STR_LS"low-speed", "usb.ss.wSpeedSupported.LS",
7448 FT_BOOLEAN, 16, NULL((void*)0), 1 << SS_SPEED_SUPPORTED_BIT_LS0,
7449 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7450 { &hf_usb_ss_wSpeedSupported_FS,
7451 { SS_SPEED_SUPPORTED_STR_FS"full-speed", "usb.ss.wSpeedSupported.FS",
7452 FT_BOOLEAN, 16, NULL((void*)0), 1 << SS_SPEED_SUPPORTED_BIT_FS1,
7453 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7454 { &hf_usb_ss_wSpeedSupported_HS,
7455 { SS_SPEED_SUPPORTED_STR_HS"high-speed", "usb.ss.wSpeedSupported.HS",
7456 FT_BOOLEAN, 16, NULL((void*)0), 1 << SS_SPEED_SUPPORTED_BIT_HS2,
7457 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7458 { &hf_usb_ss_wSpeedSupported_Gen1,
7459 { SS_SPEED_SUPPORTED_STR_GEN1"Gen 1 speed", "usb.ss.wSpeedSupported.Gen1",
7460 FT_BOOLEAN, 16, NULL((void*)0), 1 << SS_SPEED_SUPPORTED_BIT_GEN13,
7461 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7462 { &hf_usb_ss_wSpeedSupported_reserved,
7463 { "Reserved", "usb.ss.wSpeedSupported.reserved",
7464 FT_UINT16, BASE_HEX, NULL((void*)0), 0xFFF0,
7465 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7466 { &hf_usb_ss_bFunctionalitySupport,
7467 { "bFunctionalitySupport", "usb.ss.bFunctionalitySupport",
7468 FT_UINT8, BASE_HEX|BASE_EXT_STRING0x00000200, &usb_ss_bFunctionalitySupport_vals_ext, 0x0,
7469 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7470 { &hf_usb_ss_bU1DevExitLat,
7471 { "bU1DevExitLat", "usb.ss.bU1DevExitLat",
7472 FT_UINT8, BASE_DEC|BASE_UNIT_STRING0x00001000, UNS(&units_microseconds)((0 ? (const struct unit_name_string*)0 : ((&units_microseconds
))))
, 0x0,
7473 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7474 { &hf_usb_ss_wU2DevExitLat,
7475 { "wU2DevExitLat", "usb.ss.wU2DevExitLat",
7476 FT_UINT16, BASE_DEC|BASE_UNIT_STRING0x00001000, UNS(&units_microseconds)((0 ? (const struct unit_name_string*)0 : ((&units_microseconds
))))
, 0x0,
7477 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }},
7478 };
7479
7480 static hf_register_info hf_usbport[] = {
7481 { &hf_usbport_event_id,
7482 { "Event ID", "usbport.event_id",
7483 FT_UINT32, BASE_DEC_HEX|BASE_EXT_STRING0x00000200, &netmon_event_id_vals_ext, 0x0,
7484 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7485 },
7486 { &hf_usbport_device_object,
7487 { "Device Object", "usbport.device_object",
7488 FT_UINT64, BASE_HEX, NULL((void*)0), 0x0,
7489 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7490 },
7491 { &hf_usbport_pci_bus,
7492 { "PCI Bus", "usbport.pci_bus",
7493 FT_UINT32, BASE_DEC_HEX, NULL((void*)0), 0x0,
7494 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7495 },
7496 { &hf_usbport_pci_device,
7497 { "PCI Bus", "usbport.pci_device",
7498 FT_UINT16, BASE_DEC_HEX, NULL((void*)0), 0x0,
7499 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7500 },
7501 { &hf_usbport_pci_function,
7502 { "PCI Function", "usbport.pci_function",
7503 FT_UINT16, BASE_DEC_HEX, NULL((void*)0), 0x0,
7504 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7505 },
7506 { &hf_usbport_pci_vendor_id,
7507 { "PCI Vendor ID", "usbport.pci_vendor_id",
7508 FT_UINT16, BASE_DEC_HEX, NULL((void*)0), 0x0,
7509 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7510 },
7511 { &hf_usbport_pci_device_id,
7512 { "PCI Device ID", "usbport.pci_device_id",
7513 FT_UINT16, BASE_DEC_HEX, NULL((void*)0), 0x0,
7514 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7515 },
7516 { &hf_usbport_port_path_depth,
7517 { "Path Depth", "usbport.port_path_depth",
7518 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
7519 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7520 },
7521 { &hf_usbport_port_path0,
7522 { "Path0", "usbport.port_path0",
7523 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
7524 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7525 },
7526 { &hf_usbport_port_path1,
7527 { "Path1", "usbport.port_path1",
7528 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
7529 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7530 },
7531 { &hf_usbport_port_path2,
7532 { "Path2", "usbport.port_path2",
7533 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
7534 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7535 },
7536 { &hf_usbport_port_path3,
7537 { "Path3", "usbport.port_path3",
7538 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
7539 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7540 },
7541 { &hf_usbport_port_path4,
7542 { "Path4", "usbport.port_path4",
7543 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
7544 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7545 },
7546 { &hf_usbport_port_path5,
7547 { "Path5", "usbport.port_path5",
7548 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
7549 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7550 },
7551 { &hf_usbport_device_handle,
7552 { "Device Handle", "usbport.device_handle",
7553 FT_UINT64, BASE_HEX, NULL((void*)0), 0x0,
7554 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7555 },
7556 { &hf_usbport_device_speed,
7557 { "Device Speed", "usbport.device_speed",
7558 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
7559 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7560 },
7561 { &hf_usbport_endpoint,
7562 { "Endpoint", "usbport.endpoint",
7563 FT_UINT64, BASE_HEX, NULL((void*)0), 0x0,
7564 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7565 },
7566 { &hf_usbport_pipehandle,
7567 { "Pipe Handle", "usbport.pipehandle",
7568 FT_UINT64, BASE_HEX, NULL((void*)0), 0x0,
7569 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7570 },
7571 { &hf_usbport_endpoint_desc_length,
7572 { "Length", "usbport.endpoint_desc_length",
7573 FT_UINT8, BASE_DEC, NULL((void*)0), 0x0,
7574 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7575 },
7576 { &hf_usbport_endpoint_desc_type,
7577 { "Description Type", "usbport.endpoint_desc_type",
7578 FT_UINT8, BASE_DEC, NULL((void*)0), 0x0,
7579 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7580 },
7581 { &hf_usbport_endpoint_address,
7582 { "Endpoint Address", "usbport.endpoint_address",
7583 FT_UINT8, BASE_HEX, NULL((void*)0), 0x0,
7584 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7585 },
7586 { &hf_usbport_bm_attributes,
7587 { "bmAttributes", "usbport.bm_attributes",
7588 FT_UINT8, BASE_DEC_HEX, NULL((void*)0), 0x0,
7589 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7590 },
7591 { &hf_usbport_max_packet_size,
7592 { "Max Packet Size", "usbport.max_packet_size",
7593 FT_UINT16, BASE_DEC, NULL((void*)0), 0x0,
7594 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7595 },
7596 { &hf_usbport_interval,
7597 { "Interval", "usbport.interval",
7598 FT_UINT8, BASE_DEC, NULL((void*)0), 0x0,
7599 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7600 },
7601 { &hf_usbport_irp,
7602 { "IRP", "usbport.irp",
7603 FT_UINT64, BASE_HEX, NULL((void*)0), 0x0,
7604 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7605 },
7606 { &hf_usbport_urb,
7607 { "URB", "usbport.urb",
7608 FT_UINT64, BASE_HEX, NULL((void*)0), 0x0,
7609 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7610 },
7611 { &hf_usbport_urb_transfer_data,
7612 { "URB Transfer data", "usbport.urb_transfer_data",
7613 FT_UINT_BYTES, BASE_NONE, NULL((void*)0), 0x0,
7614 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7615 },
7616 { &hf_usbport_urb_header_length,
7617 { "URB Header Length", "usbport.urb_header_length",
7618 FT_UINT16, BASE_DEC, NULL((void*)0), 0x0,
7619 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7620 },
7621 { &hf_usbport_urb_header_function,
7622 { "URB Header Function", "usbport.urb_header_function",
7623 FT_UINT16, BASE_DEC|BASE_EXT_STRING0x00000200, &netmon_urb_function_vals_ext, 0x0,
7624 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7625 },
7626 { &hf_usbport_urb_header_status,
7627 { "URB Header Status", "usbport.urb_header_status",
7628 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
7629 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7630 },
7631 { &hf_usbport_urb_header_usbddevice_handle,
7632 { "URB Header Device Handle", "usbport.urb_header_usbddevice_handle",
7633 FT_UINT64, BASE_HEX, NULL((void*)0), 0x0,
7634 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7635 },
7636 { &hf_usbport_urb_header_usbdflags,
7637 { "URB Header Flags", "usbport.urb_header_usbdflags",
7638 FT_UINT64, BASE_HEX, NULL((void*)0), 0x0,
7639 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7640 },
7641 { &hf_usbport_urb_configuration_desc,
7642 { "URB Configuration Description", "usbport.urb_configuration_desc",
7643 FT_UINT64, BASE_HEX, NULL((void*)0), 0x0,
7644 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7645 },
7646 { &hf_usbport_urb_configuration_handle,
7647 { "URB Configuration Handle", "usbport.urb_configuration_handle",
7648 FT_UINT64, BASE_HEX, NULL((void*)0), 0x0,
7649 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7650 },
7651 { &hf_usbport_urb_pipe_handle,
7652 { "URB Pipe Handle", "usbport.urb_pipe_handle",
7653 FT_UINT64, BASE_HEX, NULL((void*)0), 0x0,
7654 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7655 },
7656 { &hf_usbport_urb_xferflags,
7657 { "URB Transfer Flags", "usbport.urb_xferflags",
7658 FT_UINT32, BASE_HEX, NULL((void*)0), 0x0,
7659 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7660 },
7661 { &hf_usbport_urb_transfer_buffer_length,
7662 { "URB Transfer Buffer Length", "usbport.urb_transfer_buffer_length",
7663 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
7664 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7665 },
7666 { &hf_usbport_urb_transfer_buffer,
7667 { "URB Transfer Buffer", "usbport.urb_transfer_buffer",
7668 FT_UINT64, BASE_HEX, NULL((void*)0), 0x0,
7669 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7670 },
7671 { &hf_usbport_urb_transfer_buffer_mdl,
7672 { "URB Transfer Buffer MDL", "usbport.urb_transfer_buffer_mdl",
7673 FT_UINT64, BASE_HEX, NULL((void*)0), 0x0,
7674 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7675 },
7676 { &hf_usbport_urb_reserved_mbz,
7677 { "URB Reserved MBZ", "usbport.urb_reserved_mbz",
7678 FT_UINT64, BASE_HEX, NULL((void*)0), 0x0,
7679 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7680 },
7681 { &hf_usbport_urb_reserved_hcd,
7682 { "URB Reserved HCD", "usbport.urb_reserved_hcd",
7683 FT_UINT64, BASE_HEX, NULL((void*)0), 0x0,
7684 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7685 },
7686 { &hf_usbport_urb_reserved,
7687 { "URB Reserved", "usbport.urb_reserved",
7688 FT_UINT32, BASE_HEX, NULL((void*)0), 0x0,
7689 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7690 },
7691 { &hf_usbport_keyword,
7692 { "Keyword", "usbport.keyword",
7693 FT_UINT64, BASE_HEX, NULL((void*)0), 0x0,
7694 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7695 },
7696 { &hf_usbport_keyword_diagnostic,
7697 { "USBPORT_ETW_KEYWORD_DIAGNOSTIC", "usbport.keyword.diagnostic",
7698 FT_BOOLEAN, 64, NULL((void*)0), USBPORT_KEYWORD_DIAGNOSTIC0x0000000000000001UL,
7699 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7700 },
7701 { &hf_usbport_keyword_power_diagnostics,
7702 { "USBPORT_ETW_KEYWORD_POWER_DIAGNOSTICS", "usbport.keyword.power_diagnostics",
7703 FT_BOOLEAN, 64, NULL((void*)0), USBPORT_KEYWORD_POWER_DIAGNOSTICS0x0000000000000002UL,
7704 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7705 },
7706 { &hf_usbport_keyword_perf_diagnostics,
7707 { "USBPORT_ETW_KEYWORD_PERF_DIAGNOSTICS", "usbport.keyword.perf_diagnostics",
7708 FT_BOOLEAN, 64, NULL((void*)0), USBPORT_KEYWORD_PERF_DIAGNOSTICS0x0000000000000004UL,
7709 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7710 },
7711 { &hf_usbport_keyword_reserved1,
7712 { "Reserved1", "usbport.keyword.reserved1",
7713 FT_UINT64, BASE_HEX, NULL((void*)0), USBPORT_KEYWORD_RESERVED10xFFFFFFFFFFFFFFF8UL,
7714 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
7715 },
7716 };
7717
7718 static int *usb_ett[] = {
7719 &ett_usb_hdr,
7720 &ett_usb_setup_hdr,
7721 &ett_usb_isodesc,
7722 &ett_usb_win32_iso_packet,
7723 &ett_usb_endpoint,
7724 &ett_usb_xferflags,
7725 &ett_usb_xferstatus,
7726 &ett_usb_frame,
7727 &ett_usb_frame_flags,
7728 &ett_usb_setup_bmrequesttype,
7729 &ett_usb_usbpcap_info,
7730 &ett_descriptor_device,
7731 &ett_configuration_bmAttributes,
7732 &ett_configuration_bEndpointAddress,
7733 &ett_endpoint_bmAttributes,
7734 &ett_endpoint_wMaxPacketSize,
7735 &ett_transfer_flags,
7736 &ett_usb20ext_bmAttributes,
7737 &ett_ss_bmAttributes,
7738 &ett_ss_wSpeedSupported,
7739 };
7740
7741 static int *usbport_ett[] = {
7742 &ett_usbport,
7743 &ett_usbport_host_controller,
7744 &ett_usbport_path,
7745 &ett_usbport_device,
7746 &ett_usbport_endpoint,
7747 &ett_usbport_endpoint_desc,
7748 &ett_usbport_urb,
7749 &ett_usbport_keyword,
7750 };
7751
7752 static ei_register_info ei[] = {
7753 { &ei_usb_undecoded, { "usb.undecoded", PI_UNDECODED0x05000000, PI_WARN0x00600000, "Not dissected yet (report to wireshark.org)", EXPFILL0, ((void*)0), 0, ((void*)0), {0, {((void*)0), ((void*)0), FT_NONE
, BASE_NONE, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE
, -1, ((void*)0)}}
}},
7754 { &ei_usb_bLength_even, { "usb.bLength.even", PI_PROTOCOL0x09000000, PI_WARN0x00600000, "Invalid STRING DESCRIPTOR Length (must be even)", EXPFILL0, ((void*)0), 0, ((void*)0), {0, {((void*)0), ((void*)0), FT_NONE
, BASE_NONE, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE
, -1, ((void*)0)}}
}},
7755 { &ei_usb_bLength_too_short, { "usb.bLength.too_short", PI_MALFORMED0x07000000, PI_ERROR0x00800000, "Invalid STRING DESCRIPTOR Length (must be 2 or larger)", EXPFILL0, ((void*)0), 0, ((void*)0), {0, {((void*)0), ((void*)0), FT_NONE
, BASE_NONE, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE
, -1, ((void*)0)}}
}},
7756 { &ei_usb_desc_length_invalid, { "usb.desc_length.invalid", PI_MALFORMED0x07000000, PI_ERROR0x00800000, "Invalid descriptor length", EXPFILL0, ((void*)0), 0, ((void*)0), {0, {((void*)0), ((void*)0), FT_NONE
, BASE_NONE, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE
, -1, ((void*)0)}}
}},
7757 { &ei_usb_invalid_setup, { "usb.setup.invalid", PI_MALFORMED0x07000000, PI_ERROR0x00800000, "Only control URBs may contain a setup packet", EXPFILL0, ((void*)0), 0, ((void*)0), {0, {((void*)0), ((void*)0), FT_NONE
, BASE_NONE, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE
, -1, ((void*)0)}}
}},
7758 { &ei_usb_ss_ep_companion_before_ep, { "usb.bmAttributes.invalid_order", PI_MALFORMED0x07000000, PI_ERROR0x00800000, "SuperSpeed Endpoint Companion must come after Endpoint Descriptor", EXPFILL0, ((void*)0), 0, ((void*)0), {0, {((void*)0), ((void*)0), FT_NONE
, BASE_NONE, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE
, -1, ((void*)0)}}
}},
7759 { &ei_usb_usbpcap_unknown_urb, { "usb.usbpcap.unknown_urb", PI_MALFORMED0x07000000, PI_ERROR0x00800000, "USBPcap did not recognize URB Function code (report to desowin.org/USBPcap)", EXPFILL0, ((void*)0), 0, ((void*)0), {0, {((void*)0), ((void*)0), FT_NONE
, BASE_NONE, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE
, -1, ((void*)0)}}
}},
7760 { &ei_usb_bad_length, { "usb.bad_length", PI_MALFORMED0x07000000, PI_ERROR0x00800000, "Invalid length", EXPFILL0, ((void*)0), 0, ((void*)0), {0, {((void*)0), ((void*)0), FT_NONE
, BASE_NONE, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE
, -1, ((void*)0)}}
}},
7761 { &ei_usb_invalid_max_packet_size, { "usb.wMaxPacketSize.invalid", PI_PROTOCOL0x09000000, PI_WARN0x00600000, "Invalid Max Packet Size", EXPFILL0, ((void*)0), 0, ((void*)0), {0, {((void*)0), ((void*)0), FT_NONE
, BASE_NONE, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE
, -1, ((void*)0)}}
}},
7762 { &ei_usb_invalid_max_packet_size0, { "usb.bMaxPacketSize0.invalid", PI_PROTOCOL0x09000000, PI_WARN0x00600000, "Invalid Max Packet Size", EXPFILL0, ((void*)0), 0, ((void*)0), {0, {((void*)0), ((void*)0), FT_NONE
, BASE_NONE, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE
, -1, ((void*)0)}}
}},
7763 { &ei_usb_invalid_endpoint_type, { "usb.bmAttributes.transfer.invalid", PI_PROTOCOL0x09000000, PI_WARN0x00600000, "Transfer type not allowed at Low-Speed", EXPFILL0, ((void*)0), 0, ((void*)0), {0, {((void*)0), ((void*)0), FT_NONE
, BASE_NONE, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE
, -1, ((void*)0)}}
}},
7764 { &ei_usb_unexpected_desc_type, { "usb.bDescriptorType.unexpected", PI_MALFORMED0x07000000, PI_ERROR0x00800000, "Unexpected descriptor type", EXPFILL0, ((void*)0), 0, ((void*)0), {0, {((void*)0), ((void*)0), FT_NONE
, BASE_NONE, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE
, -1, ((void*)0)}}
}},
7765 };
7766 static ei_register_info ei_usbport[] = {
7767 { &ei_usbport_invalid_path_depth, { "usbport.path_depth.invalid", PI_PROTOCOL0x09000000, PI_WARN0x00600000, "Invalid path depth", EXPFILL0, ((void*)0), 0, ((void*)0), {0, {((void*)0), ((void*)0), FT_NONE
, BASE_NONE, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE
, -1, ((void*)0)}}
}},
7768 };
7769
7770 expert_module_t *expert_usb, *expert_usbport;
7771
7772 proto_usb = proto_register_protocol("USB", "USB", "usb");
7773 proto_usbport = proto_register_protocol("USBPort", "USBPort", "usbport");
7774
7775 proto_register_field_array(proto_usb, hf, array_length(hf)(sizeof (hf) / sizeof (hf)[0]));
7776 proto_register_field_array(proto_usbport, hf_usbport, array_length(hf_usbport)(sizeof (hf_usbport) / sizeof (hf_usbport)[0]));
7777 proto_register_subtree_array(usb_ett, array_length(usb_ett)(sizeof (usb_ett) / sizeof (usb_ett)[0]));
7778 proto_register_subtree_array(usbport_ett, array_length(usbport_ett)(sizeof (usbport_ett) / sizeof (usbport_ett)[0]));
7779
7780 expert_usb = expert_register_protocol(proto_usb);
7781 expert_register_field_array(expert_usb, ei, array_length(ei)(sizeof (ei) / sizeof (ei)[0]));
7782 expert_usbport = expert_register_protocol(proto_usbport);
7783 expert_register_field_array(expert_usbport, ei_usbport, array_length(ei_usbport)(sizeof (ei_usbport) / sizeof (ei_usbport)[0]));
7784
7785 device_to_product_table = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope());
7786 device_to_protocol_table = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope());
7787 usbpcap_setup_data = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope());
7788 device_to_dissector = register_dissector_table("usb.device", "USB device", proto_usb, FT_UINT32, BASE_HEX);
7789 protocol_to_dissector = register_dissector_table("usb.protocol", "USB protocol", proto_usb, FT_UINT32, BASE_HEX);
7790 product_to_dissector = register_dissector_table("usb.product", "USB product", proto_usb, FT_UINT32, BASE_HEX);
7791
7792 usb_bulk_dissector_table = register_dissector_table("usb.bulk",
7793 "USB bulk endpoint", proto_usb, FT_UINT32, BASE_HEX);
7794 heur_bulk_subdissector_list = register_heur_dissector_list_with_description("usb.bulk", "USB bulk fallback", proto_usb);
7795 usb_control_dissector_table = register_dissector_table("usb.control",
7796 "USB control endpoint", proto_usb, FT_UINT32, BASE_HEX);
7797 heur_control_subdissector_list = register_heur_dissector_list_with_description("usb.control", "USB control fallback", proto_usb);
7798 usb_interrupt_dissector_table = register_dissector_table("usb.interrupt",
7799 "USB interrupt endpoint", proto_usb, FT_UINT32, BASE_HEX);
7800 heur_interrupt_subdissector_list = register_heur_dissector_list_with_description("usb.interrupt", "USB interrupt fallback", proto_usb);
7801 usb_descriptor_dissector_table = register_dissector_table("usb.descriptor",
7802 "USB descriptor", proto_usb, FT_UINT8, BASE_DEC);
7803
7804 usb_module = prefs_register_protocol(proto_usb, NULL((void*)0));
7805 prefs_register_bool_preference(usb_module, "try_heuristics",
7806 "Try heuristic sub-dissectors",
7807 "Try to decode a packet using a heuristic sub-dissector before "
7808 "attempting to dissect the packet using the \"usb.bulk\", \"usb.interrupt\" or "
7809 "\"usb.control\" dissector tables.", &try_heuristics);
7810
7811 usb_tap = register_tap("usb");
7812
7813 register_decode_as(&usb_protocol_da);
7814 register_decode_as(&usb_product_da);
7815 register_decode_as(&usb_device_da);
7816
7817 linux_usb_handle = register_dissector("usb_linux", dissect_linux_usb, proto_usb);
7818 linux_usb_mmapped_handle = register_dissector("usb_linux_mmapped", dissect_linux_usb_mmapped, proto_usb);
7819 win32_usb_handle = register_dissector("usb_win32", dissect_win32_usb, proto_usb);
7820 freebsd_usb_handle = register_dissector("usb_freebsd", dissect_freebsd_usb, proto_usb);
7821 darwin_usb_handle = register_dissector("usb_darwin", dissect_darwin_usb, proto_usb);
7822 netmon_usb_port_handle = register_dissector("usb_netmon", dissect_netmon_usb_port, proto_usbport);
7823
7824 usb_address_type = address_type_dissector_register("AT_USB", "USB Address", usb_addr_to_str, usb_addr_str_len, NULL((void*)0), usb_col_filter_str, NULL((void*)0), NULL((void*)0), NULL((void*)0));
7825
7826 register_conversation_table(proto_usb, true1, usb_conversation_packet, usb_endpoint_packet);
7827}
7828
7829void
7830proto_reg_handoff_usb(void)
7831{
7832 static guid_key usb_port_key = {{ 0xc88a4ef5, 0xd048, 0x4013, { 0x94, 0x08, 0xe0, 0x4b, 0x7d, 0xb2, 0x81, 0x4a }}, 0 };
7833
7834 dissector_add_uint("wtap_encap", WTAP_ENCAP_USB_LINUX95, linux_usb_handle);
7835 dissector_add_uint("wtap_encap", WTAP_ENCAP_USB_LINUX_MMAPPED115, linux_usb_mmapped_handle);
7836 dissector_add_uint("wtap_encap", WTAP_ENCAP_USBPCAP152, win32_usb_handle);
7837 dissector_add_uint("wtap_encap", WTAP_ENCAP_USB_FREEBSD92, freebsd_usb_handle);
7838 dissector_add_uint("wtap_encap", WTAP_ENCAP_USB_DARWIN182, darwin_usb_handle);
7839
7840 dissector_add_guid( "netmon.provider_id", &usb_port_key, netmon_usb_port_handle);
7841}
7842
7843/*
7844 * Editor modelines - https://www.wireshark.org/tools/modelines.html
7845 *
7846 * Local variables:
7847 * c-basic-offset: 4
7848 * tab-width: 8
7849 * indent-tabs-mode: nil
7850 * End:
7851 *
7852 * vi: set shiftwidth=4 tabstop=8 expandtab:
7853 * :indentSize=4:tabSize=8:noTabs=true:
7854 */