10#ifndef __PACKET_USB_H__
11#define __PACKET_USB_H__
25#define USB_ADDR_LEN (sizeof(usb_address_t))
30#define INTERFACE_PORT 0x80000000
48 USB_HEADER_LINUX_48_BYTES,
49 USB_HEADER_LINUX_64_BYTES,
54 USB_HEADER_PSEUDO_URB,
58#define USB_HEADER_IS_LINUX(type) \
59 ((type) == USB_HEADER_LINUX_48_BYTES || (type) == USB_HEADER_LINUX_64_BYTES)
63 uint8_t transfer_type;
64 uint8_t device_address;
75 usb_header_t header_type;
102 uint8_t interface_endpoint;
103 usb_conv_info_t *interface_info;
108enum usb_conv_class_data_type {
109 USB_CONV_UNKNOWN = 0,
113 USB_CONV_MASS_STORAGE_BOT,
114 USB_CONV_MASS_STORAGE_UASP,
122 uint8_t descriptor_transfer_type;
123 uint16_t max_packet_size;
125 uint16_t interfaceClass;
126 uint16_t interfaceSubclass;
127 uint16_t interfaceProtocol;
128 uint8_t interfaceNum;
130 uint16_t deviceVendor;
131 uint32_t deviceProduct;
132 uint16_t deviceVersion;
133 uint8_t iSerialNumber;
137 enum usb_conv_class_data_type class_data_type;
138 uint32_t config_desc_frame_num;
146 uint16_t device_address;
149 uint8_t transfer_type;
150 uint32_t device_protocol;
153 uint8_t setup_requesttype;
156 usb_trans_info_t *usb_trans_info;
158 usb_conv_info_t *conv;
164 uint8_t transfer_type;
166 usb_trans_info_t *trans_info;
171#define NO_ENDPOINT 0xffffffff
174#define NO_ENDPOINT8 ((uint8_t)(NO_ENDPOINT& UINT8_MAX))
183#define URB_SUBMIT 'S'
184#define URB_COMPLETE 'C'
190#define URB_ISOCHRONOUS 0x0
191#define URB_INTERRUPT 0x1
192#define URB_CONTROL 0x2
194#define URB_UNKNOWN 0xFF
196#define URB_TRANSFER_IN 0x80
200#define IF_CLASS_DEVICE 0x00
201#define IF_CLASS_AUDIO 0x01
202#define IF_CLASS_COMMUNICATIONS 0x02
203#define IF_CLASS_HID 0x03
204#define IF_CLASS_PHYSICAL 0x05
205#define IF_CLASS_IMAGE 0x06
206#define IF_CLASS_PRINTER 0x07
207#define IF_CLASS_MASS_STORAGE 0x08
208#define IF_CLASS_HUB 0x09
209#define IF_CLASS_CDC_DATA 0x0a
210#define IF_CLASS_SMART_CARD 0x0b
211#define IF_CLASS_CONTENT_SECURITY 0x0d
212#define IF_CLASS_VIDEO 0x0e
213#define IF_CLASS_PERSONAL_HEALTHCARE 0x0f
214#define IF_CLASS_AUDIO_VIDEO 0x10
215#define IF_CLASS_BILLBOARD 0x11
216#define IF_CLASS_USB_C_BRIDGE 0x12
217#define IF_CLASS_BULK_DISPLAY_PROTO 0x13
218#define IF_CLASS_MCTP_USB_EP 0x14
219#define IF_CLASS_I3C 0x3c
220#define IF_CLASS_DIAGNOSTIC_DEVICE 0xdc
221#define IF_CLASS_WIRELESS_CONTROLLER 0xe0
222#define IF_CLASS_MISCELLANEOUS 0xef
223#define IF_CLASS_APPLICATION_SPECIFIC 0xfe
224#define IF_CLASS_VENDOR_SPECIFIC 0xff
226#define IF_CLASS_UNKNOWN 0xffff
227#define IF_SUBCLASS_UNKNOWN 0xffff
228#define IF_PROTOCOL_UNKNOWN 0xffff
229#define DEV_VENDOR_UNKNOWN 0x0000
230#define DEV_PRODUCT_UNKNOWN 0xfffffff
231#define DEV_VERSION_UNKNOWN 0xffff
233#define IF_SUBCLASS_MISC_U3V 0x05
235#define IF_SUBCLASS_APP_DFU 0x01
237#define IF_PROTOCOL_DFU_RUNTIME 0x01
238#define IF_PROTOCOL_DFU_MODE 0x02
247#define USB_PROTOCOL_KEY(class, subclass, protocol) \
248 (1u << 31 | (class & 0xff) << 16 | (subclass & 0xff) << 8 | (protocol & 0xff))
252#define USB_DIR_IN 0x80
254#define USB_TYPE_MASK (0x03 << 5)
255#define USB_TYPE(type) (((type) & USB_TYPE_MASK) >> 5)
256#define RQT_SETUP_TYPE_STANDARD 0
257#define RQT_SETUP_TYPE_CLASS 1
258#define RQT_SETUP_TYPE_VENDOR 2
260#define USB_RECIPIENT_MASK 0x1F
261#define USB_RECIPIENT(type) ((type) & USB_RECIPIENT_MASK)
262#define RQT_SETUP_RECIPIENT_DEVICE 0
263#define RQT_SETUP_RECIPIENT_INTERFACE 1
264#define RQT_SETUP_RECIPIENT_ENDPOINT 2
265#define RQT_SETUP_RECIPIENT_OTHER 3
268#define ENDPOINT_TYPE(ep_attrib) ((ep_attrib) & 0x03)
269#define ENDPOINT_TYPE_CONTROL 0
270#define ENDPOINT_TYPE_ISOCHRONOUS 1
271#define ENDPOINT_TYPE_BULK 2
272#define ENDPOINT_TYPE_INTERRUPT 3
273#define ENDPOINT_TYPE_NOT_SET 255
276#define USB_MPS_EP_SIZE(max_packet_size) ((max_packet_size) & 0x07FF)
277#define USB_MPS_ADDNL(max_packet_size) (((max_packet_size) & 0x1800) >> 11)
278#define USB_MPS(ep_size, addnl) (((addnl) << 11) | (ep_size))
279#define USB_MPS_TPL(max_packet_size) \
280 ((USB_MPS_ADDNL(max_packet_size) + 1) * USB_MPS_EP_SIZE(max_packet_size))
282#define USB_SETUP_GET_STATUS 0
283#define USB_SETUP_CLEAR_FEATURE 1
284#define USB_SETUP_SET_FEATURE 3
285#define USB_SETUP_SET_ADDRESS 5
286#define USB_SETUP_GET_DESCRIPTOR 6
287#define USB_SETUP_SET_DESCRIPTOR 7
288#define USB_SETUP_GET_CONFIGURATION 8
289#define USB_SETUP_SET_CONFIGURATION 9
290#define USB_SETUP_GET_INTERFACE 10
291#define USB_SETUP_SET_INTERFACE 11
292#define USB_SETUP_SYNCH_FRAME 12
293#define USB_SETUP_SET_SEL 48
294#define USB_SETUP_SET_ISOCH_DELAY 49
297#define URB_SHORT_NOT_OK 0x00000001
298#define URB_ISO_ASAP 0x00000002
300#define URB_NO_TRANSFER_DMA_MAP 0x00000004
301#define URB_NO_FSBR 0x00000020
302#define URB_ZERO_PACKET 0x00000040
303#define URB_NO_INTERRUPT 0x00000080
305#define URB_FREE_BUFFER 0x00000100
308#define URB_DIR_IN 0x00000200
310#define URB_DIR_MASK URB_DIR_IN
312#define URB_DMA_MAP_SINGLE 0x00010000
313#define URB_DMA_MAP_PAGE 0x00020000
314#define URB_DMA_MAP_SG 0x00040000
315#define URB_MAP_LOCAL 0x00080000
316#define URB_SETUP_MAP_SINGLE 0x00100000
317#define URB_SETUP_MAP_LOCAL 0x00200000
318#define URB_DMA_SG_COMBINED 0x00400000
319#define URB_ALIGNED_TEMP_BUFFER 0x00800000
325extern value_string_ext usb_class_vals_ext;
326extern value_string_ext usb_langid_vals_ext;
327extern value_string_ext ext_usb_audio_subclass_vals;
328extern value_string_ext ext_usb_massstorage_subclass_vals;
329extern value_string_ext ext_usb_com_subclass_vals;
330extern value_string_ext usb_massstorage_protocol_vals_ext;
333usb_conv_info_t *get_usb_iface_conv_info(
packet_info *pinfo, uint8_t interface_num);
334usb_conv_info_t *get_existing_usb_ep_conv_info(
packet_info *pinfo, uint16_t bus_id,
335 uint16_t device_address,
int endpoint);
337proto_item * dissect_usb_descriptor_header(proto_tree *tree,
338 tvbuff_t *tvb,
int offset,
339 value_string_ext *type_val_str);
341void dissect_usb_endpoint_address(proto_tree *tree, tvbuff_t *tvb,
int offset);
344sanitize_usb_max_packet_size(uint8_t ep_type, usb_speed_t speed,
345 unsigned int max_packet_size);
348dissect_usb_endpoint_descriptor(
packet_info *pinfo, proto_tree *parent_tree,
349 tvbuff_t *tvb,
int offset,
351 uint8_t *out_ep_type, usb_speed_t speed);
354dissect_usb_unknown_descriptor(
packet_info *pinfo _U_, proto_tree *parent_tree,
355 tvbuff_t *tvb,
int offset,
356 urb_info_t *urb _U_);
359dissect_urb_transfer_flags(tvbuff_t *tvb,
int offset, proto_tree* tree,
int hf,
int endian);
364dissect_usb_common(tvbuff_t *tvb,
packet_info *pinfo, proto_tree *parent,
365 usb_header_t header_type,
void *extra_data);
367void usb_lpm_besl_str(
char *buf, uint32_t value);
struct _packet_info packet_info
Represents the metadata and indexing information for a single captured frame.
proto_node proto_item
Definition proto.h:927
struct _wmem_array_t wmem_array_t
Opaque type representing a dynamically resizable array in the wmem system.
Definition wmem_array.h:42
struct _wmem_tree_t wmem_tree_t
Opaque type representing a red-black tree in the wmem system.
Definition wmem_tree.h:49
Definition packet-usb.h:144
Definition packet-usb.h:20
Definition packet-usb.h:121
Definition packet-usb.h:61
Definition packet-usb.h:162
Definition packet-usb.h:78
Definition packet-usb.h:71