summaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-usb.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:14:33 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:14:33 +0000
commit9f153fbfec0fb9c9ce38e749a7c6f4a5e115d4e9 (patch)
tree2784370cda9bbf2da9114d70f05399c0b229d28c /epan/dissectors/packet-usb.h
parentAdding debian version 4.2.6-1. (diff)
downloadwireshark-9f153fbfec0fb9c9ce38e749a7c6f4a5e115d4e9.tar.xz
wireshark-9f153fbfec0fb9c9ce38e749a7c6f4a5e115d4e9.zip
Merging upstream version 4.4.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'epan/dissectors/packet-usb.h')
-rw-r--r--epan/dissectors/packet-usb.h134
1 files changed, 79 insertions, 55 deletions
diff --git a/epan/dissectors/packet-usb.h b/epan/dissectors/packet-usb.h
index 6d9de0b3..18cbb576 100644
--- a/epan/dissectors/packet-usb.h
+++ b/epan/dissectors/packet-usb.h
@@ -10,14 +10,17 @@
#ifndef __PACKET_USB_H__
#define __PACKET_USB_H__
+#include <epan/packet_info.h>
+#include <epan/proto.h>
+#include <epan/tvbuff.h>
#include <epan/value_string.h>
-#include <epan/wmem_scopes.h>
-#include <epan/conversation.h>
+#include <epan/tfs.h>
+#include <wsutil/nstime.h>
typedef struct _usb_address_t {
- guint32 device;
- guint32 endpoint;
- guint16 bus_id;
+ uint32_t device;
+ uint32_t endpoint;
+ uint16_t bus_id;
} usb_address_t;
#define USB_ADDR_LEN (sizeof(usb_address_t))
@@ -28,6 +31,7 @@ typedef struct _usb_address_t {
typedef struct _usb_conv_info_t usb_conv_info_t;
+typedef struct _urb_info_t urb_info_t;
/* Wireshark specific (i.e. numeric values are arbitrary) enum representing
* USB device speed.
@@ -54,35 +58,35 @@ typedef enum {
((type) == USB_HEADER_LINUX_48_BYTES || (type) == USB_HEADER_LINUX_64_BYTES)
typedef struct _usb_pseudo_urb_t {
- gboolean from_host;
- guint8 transfer_type;
- guint8 device_address;
- guint8 endpoint;
- guint16 bus_id;
+ bool from_host;
+ uint8_t transfer_type;
+ uint8_t device_address;
+ uint8_t endpoint;
+ uint16_t bus_id;
usb_speed_t speed;
} usb_pseudo_urb_t;
/* there is one such structure for each request/response */
typedef struct _usb_trans_info_t {
- guint32 request_in;
- guint32 response_in;
+ uint32_t request_in;
+ uint32_t response_in;
nstime_t req_time;
usb_header_t header_type;
/* Valid only for SETUP transactions */
struct _usb_setup {
- guint8 requesttype;
- guint8 request;
- guint16 wValue;
- guint16 wIndex;
- guint16 wLength;
+ uint8_t requesttype;
+ uint8_t request;
+ uint16_t wValue;
+ uint16_t wIndex;
+ uint16_t wLength;
} setup;
/* Valid only during GET DESCRIPTOR transactions */
union {
struct {
- guint8 type;
- guint8 usb_index;
+ uint8_t type;
+ uint8_t usb_index;
} get_descriptor;
} u;
@@ -94,9 +98,10 @@ typedef struct _usb_trans_info_t {
* once we know the endpoint.
* Valid only during GET CONFIGURATION response.
*/
+ uint8_t interface_endpoint;
usb_conv_info_t *interface_info;
- guint64 usb_id;
+ uint64_t usb_id;
} usb_trans_info_t;
enum usb_conv_class_data_type {
@@ -106,35 +111,25 @@ enum usb_conv_class_data_type {
USB_CONV_VIDEO,
USB_CONV_MASS_STORAGE_BOT,
USB_CONV_MASS_STORAGE_UASP,
+ USB_CONV_CDC_DATA,
};
/* Conversation Structure
* there is one such structure for each device/endpoint conversation */
struct _usb_conv_info_t {
- guint16 bus_id;
- guint16 device_address;
- guint8 endpoint;
- gint direction;
- guint8 transfer_type; /* transfer type from URB */
- guint8 descriptor_transfer_type; /* transfer type lifted from the configuration descriptor */
- guint16 max_packet_size; /* max packet size from configuration descriptor */
- guint32 device_protocol;
- gboolean is_request;
- gboolean is_setup;
- guint8 setup_requesttype;
- usb_speed_t speed;
-
- guint16 interfaceClass; /* Interface Descriptor - class */
- guint16 interfaceSubclass; /* Interface Descriptor - subclass */
- guint16 interfaceProtocol; /* Interface Descriptor - protocol */
- guint8 interfaceNum; /* Most recent interface number */
-
- guint16 deviceVendor; /* Device Descriptor - USB Vendor ID */
- guint32 deviceProduct; /* Device Descriptor - USB Product ID - MSBs only for encoding unknown */
- guint16 deviceVersion; /* Device Descriptor - USB device version number BCD */
- guint8 iSerialNumber; /* Device Descriptor - iSerialNumber (0 if no serial number available) */
+ uint8_t descriptor_transfer_type; /* transfer type lifted from the configuration descriptor */
+ uint16_t max_packet_size; /* max packet size from configuration descriptor */
+
+ uint16_t interfaceClass; /* Interface Descriptor - class */
+ uint16_t interfaceSubclass; /* Interface Descriptor - subclass */
+ uint16_t interfaceProtocol; /* Interface Descriptor - protocol */
+ uint8_t interfaceNum; /* Most recent interface number */
+
+ uint16_t deviceVendor; /* Device Descriptor - USB Vendor ID */
+ uint32_t deviceProduct; /* Device Descriptor - USB Product ID - MSBs only for encoding unknown */
+ uint16_t deviceVersion; /* Device Descriptor - USB device version number BCD */
+ uint8_t iSerialNumber; /* Device Descriptor - iSerialNumber (0 if no serial number available) */
wmem_tree_t *transactions;
- usb_trans_info_t *usb_trans_info; /* pointer to the current transaction */
void *class_data; /* private class/id decode data */
enum usb_conv_class_data_type class_data_type;
@@ -142,11 +137,29 @@ struct _usb_conv_info_t {
wmem_array_t *alt_settings;
};
+/* URB data lifetime is limited to packet scope */
+struct _urb_info_t {
+ uint16_t bus_id;
+ uint16_t device_address;
+ uint8_t endpoint;
+ int direction;
+ uint8_t transfer_type; /* transfer type from URB */
+ uint32_t device_protocol;
+ bool is_request;
+ bool is_setup;
+ uint8_t setup_requesttype;
+ usb_speed_t speed;
+
+ usb_trans_info_t *usb_trans_info; /* pointer to the current transaction */
+
+ usb_conv_info_t *conv;
+};
+
/* This is what a tap will tap */
typedef struct _usb_tap_data_t {
- guint8 urb_type;
- guint8 transfer_type;
- usb_conv_info_t *conv_info;
+ uint8_t urb_type;
+ uint8_t transfer_type;
+ urb_info_t *urb;
usb_trans_info_t *trans_info;
} usb_tap_data_t;
@@ -155,7 +168,7 @@ typedef struct _usb_tap_data_t {
#define NO_ENDPOINT 0xffffffff
/* the 8bit version of NO_ENDPOINT, it's used in usb_conv_info_t
0xff would be an invalid endpoint number (reserved bits are 1) */
-#define NO_ENDPOINT8 ((guint8)(NO_ENDPOINT& G_MAXUINT8))
+#define NO_ENDPOINT8 ((uint8_t)(NO_ENDPOINT& UINT8_MAX))
/*
* Values from the Linux USB pseudo-header.
@@ -196,6 +209,11 @@ typedef struct _usb_tap_data_t {
#define IF_CLASS_VIDEO 0x0e
#define IF_CLASS_PERSONAL_HEALTHCARE 0x0f
#define IF_CLASS_AUDIO_VIDEO 0x10
+#define IF_CLASS_BILLBOARD 0x11
+#define IF_CLASS_USB_C_BRIDGE 0x12
+#define IF_CLASS_BULK_DISPLAY_PROTO 0x13
+#define IF_CLASS_MCTP_USB_EP 0x14
+#define IF_CLASS_I3C 0x3c
#define IF_CLASS_DIAGNOSTIC_DEVICE 0xdc
#define IF_CLASS_WIRELESS_CONTROLLER 0xe0
#define IF_CLASS_MISCELLANEOUS 0xef
@@ -251,6 +269,12 @@ typedef struct _usb_tap_data_t {
#define ENDPOINT_TYPE_INTERRUPT 3
#define ENDPOINT_TYPE_NOT_SET 255
+/* wMaxPacketSize */
+#define USB_MPS_EP_SIZE(max_packet_size) ((max_packet_size) & 0x07FF)
+#define USB_MPS_ADDNL(max_packet_size) (((max_packet_size) & 0x1800) >> 11)
+#define USB_MPS(ep_size, addnl) (((addnl) << 11) | (ep_size))
+#define USB_MPS_TPL(max_packet_size) \
+ ((USB_MPS_ADDNL(max_packet_size) + 1) * USB_MPS_EP_SIZE(max_packet_size))
#define USB_SETUP_GET_STATUS 0
#define USB_SETUP_CLEAR_FEATURE 1
@@ -297,9 +321,9 @@ extern const true_false_string tfs_endpoint_direction;
extern value_string_ext usb_class_vals_ext;
-usb_conv_info_t *get_usb_iface_conv_info(packet_info *pinfo, guint8 interface_num);
-usb_conv_info_t *get_existing_usb_ep_conv_info(packet_info *pinfo, guint16 bus_id,
- guint16 device_address, int endpoint);
+usb_conv_info_t *get_usb_iface_conv_info(packet_info *pinfo, uint8_t interface_num);
+usb_conv_info_t *get_existing_usb_ep_conv_info(packet_info *pinfo, uint16_t bus_id,
+ uint16_t device_address, int endpoint);
proto_item * dissect_usb_descriptor_header(proto_tree *tree,
tvbuff_t *tvb, int offset,
@@ -308,19 +332,19 @@ proto_item * dissect_usb_descriptor_header(proto_tree *tree,
void dissect_usb_endpoint_address(proto_tree *tree, tvbuff_t *tvb, int offset);
unsigned int
-sanitize_usb_max_packet_size(guint8 ep_type, usb_speed_t speed,
+sanitize_usb_max_packet_size(uint8_t ep_type, usb_speed_t speed,
unsigned int max_packet_size);
int
dissect_usb_endpoint_descriptor(packet_info *pinfo, proto_tree *parent_tree,
tvbuff_t *tvb, int offset,
- usb_conv_info_t *usb_conv_info,
- guint8 *out_ep_type, usb_speed_t speed);
+ urb_info_t *urb,
+ uint8_t *out_ep_type, usb_speed_t speed);
int
dissect_usb_unknown_descriptor(packet_info *pinfo _U_, proto_tree *parent_tree,
tvbuff_t *tvb, int offset,
- usb_conv_info_t *usb_conv_info _U_);
+ urb_info_t *urb _U_);
int
dissect_urb_transfer_flags(tvbuff_t *tvb, int offset, proto_tree* tree, int hf, int endian);
@@ -331,7 +355,7 @@ void
dissect_usb_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent,
usb_header_t header_type, void *extra_data);
-void usb_lpm_besl_str(gchar *buf, guint32 value);
+void usb_lpm_besl_str(char *buf, uint32_t value);
#endif