diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-09-19 04:14:53 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-09-19 04:14:53 +0000 |
commit | a86c5f7cae7ec9a3398300555a0b644689d946a1 (patch) | |
tree | 39fe4b107c71174fd1e8a8ceb9a4d2aa14116248 /epan/dissectors/packet-usb-hid.c | |
parent | Releasing progress-linux version 4.2.6-1~progress7.99u1. (diff) | |
download | wireshark-a86c5f7cae7ec9a3398300555a0b644689d946a1.tar.xz wireshark-a86c5f7cae7ec9a3398300555a0b644689d946a1.zip |
Merging upstream version 4.4.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | epan/dissectors/packet-usb-hid.c | 1123 |
1 files changed, 591 insertions, 532 deletions
diff --git a/epan/dissectors/packet-usb-hid.c b/epan/dissectors/packet-usb-hid.c index 9a402ee8..0b83b772 100644 --- a/epan/dissectors/packet-usb-hid.c +++ b/epan/dissectors/packet-usb-hid.c @@ -31,140 +31,140 @@ static dissector_handle_t usb_hid_interrupt_handle; static dissector_handle_t usb_hid_descr_handle; /* protocols and header fields */ -static int proto_usb_hid = -1; -static int hf_usb_hid_item_bSize = -1; -static int hf_usb_hid_item_bType = -1; -static int hf_usb_hid_mainitem_bTag = -1; -static int hf_usb_hid_globalitem_bTag = -1; -static int hf_usb_hid_localitem_bTag = -1; -static int hf_usb_hid_longitem_bTag = -1; -static int hf_usb_hid_item_bDataSize = -1; -static int hf_usb_hid_item_bLongItemTag = -1; -static int hf_usb_hid_item_unk_data = -1; - -static int hf_usb_hid_mainitem_bit0 = -1; -static int hf_usb_hid_mainitem_bit1 = -1; -static int hf_usb_hid_mainitem_bit2 = -1; -static int hf_usb_hid_mainitem_bit3 = -1; -static int hf_usb_hid_mainitem_bit4 = -1; -static int hf_usb_hid_mainitem_bit5 = -1; -static int hf_usb_hid_mainitem_bit6 = -1; -static int hf_usb_hid_mainitem_bit7 = -1; -static int hf_usb_hid_mainitem_bit7_input = -1; -static int hf_usb_hid_mainitem_bit8 = -1; -static int hf_usb_hid_mainitem_colltype = -1; - -static int hf_usb_hid_globalitem_usage = -1; -static int hf_usb_hid_globalitem_log_min = -1; -static int hf_usb_hid_globalitem_log_max = -1; -static int hf_usb_hid_globalitem_phy_min = -1; -static int hf_usb_hid_globalitem_phy_max = -1; -static int hf_usb_hid_globalitem_unit_exp = -1; -static int hf_usb_hid_globalitem_unit_sys = -1; -static int hf_usb_hid_globalitem_unit_len = -1; -static int hf_usb_hid_globalitem_unit_mass = -1; -static int hf_usb_hid_globalitem_unit_time = -1; -static int hf_usb_hid_globalitem_unit_temp = -1; -static int hf_usb_hid_globalitem_unit_current = -1; -static int hf_usb_hid_globalitem_unit_brightness = -1; -static int hf_usb_hid_globalitem_report_size = -1; -static int hf_usb_hid_globalitem_report_id = -1; -static int hf_usb_hid_globalitem_report_count = -1; -static int hf_usb_hid_globalitem_push = -1; -static int hf_usb_hid_globalitem_pop = -1; - -static int hf_usb_hid_localitem_usage = -1; -static int hf_usb_hid_localitem_usage_min = -1; -static int hf_usb_hid_localitem_usage_max = -1; -static int hf_usb_hid_localitem_desig_index = -1; -static int hf_usb_hid_localitem_desig_min = -1; -static int hf_usb_hid_localitem_desig_max = -1; -static int hf_usb_hid_localitem_string_index = -1; -static int hf_usb_hid_localitem_string_min = -1; -static int hf_usb_hid_localitem_string_max = -1; -static int hf_usb_hid_localitem_delimiter = -1; - -static gint ett_usb_hid_report = -1; -static gint ett_usb_hid_item_header = -1; -static gint ett_usb_hid_wValue = -1; -static gint ett_usb_hid_descriptor = -1; -static gint ett_usb_hid_data = -1; -static gint ett_usb_hid_unknown_data = -1; -static gint ett_usb_hid_array = -1; - -static int hf_usb_hid_request = -1; -static int hf_usb_hid_value = -1; -static int hf_usb_hid_index = -1; -static int hf_usb_hid_length = -1; -static int hf_usb_hid_report_type = -1; -static int hf_usb_hid_report_id = -1; -static int hf_usb_hid_duration = -1; -static int hf_usb_hid_zero = -1; - -static int hf_usb_hid_bcdHID = -1; -static int hf_usb_hid_bCountryCode = -1; -static int hf_usb_hid_bNumDescriptors = -1; -static int hf_usb_hid_bDescriptorIndex = -1; -static int hf_usb_hid_bDescriptorType = -1; -static int hf_usb_hid_wInterfaceNumber = -1; -static int hf_usb_hid_wDescriptorLength = -1; - -static int hf_usbhid_boot_report_keyboard_modifier_right_gui = -1; -static int hf_usbhid_boot_report_keyboard_modifier_right_alt = -1; -static int hf_usbhid_boot_report_keyboard_modifier_right_shift = -1; -static int hf_usbhid_boot_report_keyboard_modifier_right_ctrl = -1; -static int hf_usbhid_boot_report_keyboard_modifier_left_gui = -1; -static int hf_usbhid_boot_report_keyboard_modifier_left_alt = -1; -static int hf_usbhid_boot_report_keyboard_modifier_left_shift = -1; -static int hf_usbhid_boot_report_keyboard_modifier_left_ctrl = -1; -static int hf_usbhid_boot_report_keyboard_reserved = -1; -static int hf_usbhid_boot_report_keyboard_keycode_1 = -1; -static int hf_usbhid_boot_report_keyboard_keycode_2 = -1; -static int hf_usbhid_boot_report_keyboard_keycode_3 = -1; -static int hf_usbhid_boot_report_keyboard_keycode_4 = -1; -static int hf_usbhid_boot_report_keyboard_keycode_5 = -1; -static int hf_usbhid_boot_report_keyboard_keycode_6 = -1; -static int hf_usbhid_boot_report_keyboard_leds_constants = -1; -static int hf_usbhid_boot_report_keyboard_leds_kana = -1; -static int hf_usbhid_boot_report_keyboard_leds_compose = -1; -static int hf_usbhid_boot_report_keyboard_leds_scroll_lock = -1; -static int hf_usbhid_boot_report_keyboard_leds_caps_lock = -1; -static int hf_usbhid_boot_report_keyboard_leds_num_lock = -1; -static int hf_usbhid_boot_report_mouse_button_8 = -1; -static int hf_usbhid_boot_report_mouse_button_7 = -1; -static int hf_usbhid_boot_report_mouse_button_6 = -1; -static int hf_usbhid_boot_report_mouse_button_5 = -1; -static int hf_usbhid_boot_report_mouse_button_4 = -1; -static int hf_usbhid_boot_report_mouse_button_middle = -1; -static int hf_usbhid_boot_report_mouse_button_right = -1; -static int hf_usbhid_boot_report_mouse_button_left = -1; -static int hf_usbhid_boot_report_mouse_x_displacement = -1; -static int hf_usbhid_boot_report_mouse_y_displacement = -1; -static int hf_usbhid_boot_report_mouse_horizontal_scroll_wheel = -1; -static int hf_usbhid_boot_report_mouse_vertical_scroll_wheel = -1; -static int hf_usbhid_data = -1; -static int hf_usbhid_unknown_data = -1; -static int hf_usbhid_vendor_data = -1; -static int hf_usbhid_report_id = -1; -static int hf_usbhid_padding = -1; -static int hf_usbhid_axis_x = -1; -static int hf_usbhid_axis_y = -1; -static int hf_usbhid_axis_z = -1; -static int hf_usbhid_axis_rx = -1; -static int hf_usbhid_axis_ry = -1; -static int hf_usbhid_axis_rz = -1; -static int hf_usbhid_axis_slider = -1; -static int hf_usbhid_axis_vx = -1; -static int hf_usbhid_axis_vy = -1; -static int hf_usbhid_axis_vz = -1; -static int hf_usbhid_axis_vbrx = -1; -static int hf_usbhid_axis_vbry = -1; -static int hf_usbhid_axis_vbrz = -1; -static int hf_usbhid_axis_vno = -1; -static int hf_usbhid_button = -1; -static int hf_usbhid_key = -1; -static int hf_usbhid_array = -1; -static int hf_usbhid_array_usage = -1; +static int proto_usb_hid; +static int hf_usb_hid_item_bSize; +static int hf_usb_hid_item_bType; +static int hf_usb_hid_mainitem_bTag; +static int hf_usb_hid_globalitem_bTag; +static int hf_usb_hid_localitem_bTag; +static int hf_usb_hid_longitem_bTag; +static int hf_usb_hid_item_bDataSize; +static int hf_usb_hid_item_bLongItemTag; +static int hf_usb_hid_item_unk_data; + +static int hf_usb_hid_mainitem_bit0; +static int hf_usb_hid_mainitem_bit1; +static int hf_usb_hid_mainitem_bit2; +static int hf_usb_hid_mainitem_bit3; +static int hf_usb_hid_mainitem_bit4; +static int hf_usb_hid_mainitem_bit5; +static int hf_usb_hid_mainitem_bit6; +static int hf_usb_hid_mainitem_bit7; +static int hf_usb_hid_mainitem_bit7_input; +static int hf_usb_hid_mainitem_bit8; +static int hf_usb_hid_mainitem_colltype; + +static int hf_usb_hid_globalitem_usage; +static int hf_usb_hid_globalitem_log_min; +static int hf_usb_hid_globalitem_log_max; +static int hf_usb_hid_globalitem_phy_min; +static int hf_usb_hid_globalitem_phy_max; +static int hf_usb_hid_globalitem_unit_exp; +static int hf_usb_hid_globalitem_unit_sys; +static int hf_usb_hid_globalitem_unit_len; +static int hf_usb_hid_globalitem_unit_mass; +static int hf_usb_hid_globalitem_unit_time; +static int hf_usb_hid_globalitem_unit_temp; +static int hf_usb_hid_globalitem_unit_current; +static int hf_usb_hid_globalitem_unit_brightness; +static int hf_usb_hid_globalitem_report_size; +static int hf_usb_hid_globalitem_report_id; +static int hf_usb_hid_globalitem_report_count; +static int hf_usb_hid_globalitem_push; +static int hf_usb_hid_globalitem_pop; + +static int hf_usb_hid_localitem_usage; +static int hf_usb_hid_localitem_usage_min; +static int hf_usb_hid_localitem_usage_max; +static int hf_usb_hid_localitem_desig_index; +static int hf_usb_hid_localitem_desig_min; +static int hf_usb_hid_localitem_desig_max; +static int hf_usb_hid_localitem_string_index; +static int hf_usb_hid_localitem_string_min; +static int hf_usb_hid_localitem_string_max; +static int hf_usb_hid_localitem_delimiter; + +static int ett_usb_hid_report; +static int ett_usb_hid_item_header; +static int ett_usb_hid_wValue; +static int ett_usb_hid_descriptor; +static int ett_usb_hid_data; +static int ett_usb_hid_unknown_data; +static int ett_usb_hid_array; + +static int hf_usb_hid_request; +static int hf_usb_hid_value; +static int hf_usb_hid_index; +static int hf_usb_hid_length; +static int hf_usb_hid_report_type; +static int hf_usb_hid_report_id; +static int hf_usb_hid_duration; +static int hf_usb_hid_zero; + +static int hf_usb_hid_bcdHID; +static int hf_usb_hid_bCountryCode; +static int hf_usb_hid_bNumDescriptors; +static int hf_usb_hid_bDescriptorIndex; +static int hf_usb_hid_bDescriptorType; +static int hf_usb_hid_wInterfaceNumber; +static int hf_usb_hid_wDescriptorLength; + +static int hf_usbhid_boot_report_keyboard_modifier_right_gui; +static int hf_usbhid_boot_report_keyboard_modifier_right_alt; +static int hf_usbhid_boot_report_keyboard_modifier_right_shift; +static int hf_usbhid_boot_report_keyboard_modifier_right_ctrl; +static int hf_usbhid_boot_report_keyboard_modifier_left_gui; +static int hf_usbhid_boot_report_keyboard_modifier_left_alt; +static int hf_usbhid_boot_report_keyboard_modifier_left_shift; +static int hf_usbhid_boot_report_keyboard_modifier_left_ctrl; +static int hf_usbhid_boot_report_keyboard_reserved; +static int hf_usbhid_boot_report_keyboard_keycode_1; +static int hf_usbhid_boot_report_keyboard_keycode_2; +static int hf_usbhid_boot_report_keyboard_keycode_3; +static int hf_usbhid_boot_report_keyboard_keycode_4; +static int hf_usbhid_boot_report_keyboard_keycode_5; +static int hf_usbhid_boot_report_keyboard_keycode_6; +static int hf_usbhid_boot_report_keyboard_leds_constants; +static int hf_usbhid_boot_report_keyboard_leds_kana; +static int hf_usbhid_boot_report_keyboard_leds_compose; +static int hf_usbhid_boot_report_keyboard_leds_scroll_lock; +static int hf_usbhid_boot_report_keyboard_leds_caps_lock; +static int hf_usbhid_boot_report_keyboard_leds_num_lock; +static int hf_usbhid_boot_report_mouse_button_8; +static int hf_usbhid_boot_report_mouse_button_7; +static int hf_usbhid_boot_report_mouse_button_6; +static int hf_usbhid_boot_report_mouse_button_5; +static int hf_usbhid_boot_report_mouse_button_4; +static int hf_usbhid_boot_report_mouse_button_middle; +static int hf_usbhid_boot_report_mouse_button_right; +static int hf_usbhid_boot_report_mouse_button_left; +static int hf_usbhid_boot_report_mouse_x_displacement; +static int hf_usbhid_boot_report_mouse_y_displacement; +static int hf_usbhid_boot_report_mouse_horizontal_scroll_wheel; +static int hf_usbhid_boot_report_mouse_vertical_scroll_wheel; +static int hf_usbhid_data; +static int hf_usbhid_unknown_data; +static int hf_usbhid_vendor_data; +static int hf_usbhid_report_id; +static int hf_usbhid_padding; +static int hf_usbhid_axis_x; +static int hf_usbhid_axis_y; +static int hf_usbhid_axis_z; +static int hf_usbhid_axis_rx; +static int hf_usbhid_axis_ry; +static int hf_usbhid_axis_rz; +static int hf_usbhid_axis_slider; +static int hf_usbhid_axis_vx; +static int hf_usbhid_axis_vy; +static int hf_usbhid_axis_vz; +static int hf_usbhid_axis_vbrx; +static int hf_usbhid_axis_vbry; +static int hf_usbhid_axis_vbrz; +static int hf_usbhid_axis_vno; +static int hf_usbhid_button; +static int hf_usbhid_key; +static int hf_usbhid_array; +static int hf_usbhid_array_usage; static const true_false_string tfs_mainitem_bit0 = {"Constant", "Data"}; static const true_false_string tfs_mainitem_bit1 = {"Variable", "Array"}; @@ -181,7 +181,7 @@ struct usb_hid_global_state { unsigned int usage_page; }; -static wmem_tree_t *report_descriptors = NULL; +static wmem_tree_t *report_descriptors; /* local items */ @@ -225,7 +225,7 @@ static wmem_tree_t *report_descriptors = NULL; #define HID_MAIN_NON_LINEAR (1 << 4) /* linear / non linear */ #define HID_MAIN_NO_PREFERRED (1 << 5) /* preferred state / no preferred */ #define HID_MAIN_NULL_STATE (1 << 6) /* no null position / null state */ -#define HID_MAIN_BUFFERED_BYTES (1 << 8) /* bit field / buferred bytes */ +#define HID_MAIN_BUFFERED_BYTES (1 << 8) /* bit field / buffered bytes */ #define HID_MAIN_ARRAY (0 << 1) @@ -245,12 +245,12 @@ typedef struct _hid_field hid_field_t; struct _hid_field { wmem_array_t *usages; - guint32 report_id; /* optional */ - guint32 report_count; - guint32 report_size; - gint32 logical_min; - gint32 logical_max; - guint32 properties; + uint32_t report_id; /* optional */ + uint32_t report_count; + uint32_t report_size; + int32_t logical_min; + int32_t logical_max; + uint32_t properties; hid_field_t *next; }; @@ -259,12 +259,14 @@ struct _hid_field { typedef struct _report_descriptor report_descriptor_t; struct _report_descriptor { - usb_conv_info_t usb_info; + uint16_t bus_id; + uint16_t device_address; + uint8_t interface; int desc_length; - guint8 *desc_body; + uint8_t *desc_body; - gboolean uses_report_id; + bool uses_report_id; wmem_array_t *fields_in; wmem_array_t *fields_out; /* TODO: features */ @@ -451,6 +453,7 @@ static const value_string usb_hid_globalitem_unit_exp_vals[] = { #define HAPTICS_PAGE 0x0E #define PID_PAGE 0x0F #define UNICODE_PAGE 0x10 +#define SOC_PAGE 0x11 #define EYE_AND_HEAD_TRACKER_PAGE 0x12 #define ALPHANUMERIC_DISPLAY_PAGE 0x14 #define SENSOR_PAGE 0x20 @@ -489,6 +492,7 @@ static const value_string usb_hid_item_usage_page_vals[] = { {HAPTICS_PAGE, "Haptics"}, {PID_PAGE, "Physical Interface Device (PID)"}, {UNICODE_PAGE, "Unicode"}, + {SOC_PAGE, "System-on-Chip"}, {EYE_AND_HEAD_TRACKER_PAGE, "Eye and Head Tracker"}, {ALPHANUMERIC_DISPLAY_PAGE, "Alphanumeric Display"}, {SENSOR_PAGE, "Sensor"}, @@ -530,6 +534,7 @@ static const value_string usb_hid_generic_desktop_controls_usage_page_vals[] = { {0x10, "Assistive Control"}, {0x11, "Device Dock"}, {0x12, "Dockable Device"}, + {0x13, "Call State Management Control"}, {0x30, "X"}, {0x31, "Y"}, {0x32, "Z"}, @@ -595,6 +600,7 @@ static const value_string usb_hid_generic_desktop_controls_usage_page_vals[] = { {0xA6, "Application Debugger Break"}, {0xA7, "System Speaker Mute"}, {0xA8, "System Hibernate"}, + {0xA9, "System Microhpone Mute"}, {0xB0, "System Display Invert"}, {0xB1, "System Display Internal"}, {0xB2, "System Display External"}, @@ -622,6 +628,9 @@ static const value_string usb_hid_generic_desktop_controls_usage_page_vals[] = { {0xD4, "Dockable Device Docking State"}, {0xD5, "Dockable Device Display Occlusion"}, {0xD6, "Dockable Device Object Type"}, + {0xE0, "Call Active LED"}, + {0xE1, "Call Mute Toggle"}, + {0xE2, "Call Mute LED"}, {0, NULL} }; static const value_string usb_hid_simulation_control_usage_page_vals[] = { @@ -1104,6 +1113,7 @@ static const value_string usb_hid_led_usage_page_vals[] = { {0x54, "Blue LED Channel"}, {0x55, "Green LED Channel"}, {0x56, "LED Intensity"}, + {0x57, "System Microphone Mute"}, {0x60, "Player Indicator"}, {0x61, "Player 1"}, {0x62, "Player 2"}, @@ -1367,6 +1377,7 @@ static const value_string usb_hid_consumer_usage_page_vals[] = { {0x0D6, "Start or Stop Camera Capture"}, {0x0D7, "Start or Stop Game Broadcast"}, {0x0D8, "Start or Stop Voice Dictation Session"}, + {0x0D9, "Invoke/Dismiss Emoji Picker"}, {0x0E0, "Volume"}, {0x0E1, "Balance"}, {0x0E2, "Mute"}, @@ -1761,6 +1772,8 @@ static const value_string usb_hid_digitizers_usage_page_vals[] = { {0x6B, "Capacitive Heat Map Protocol Version"}, {0x6C, "Capacitive Heat Map Frame Data"}, {0x6D, "Gesture Character Enable"}, + {0x6E, "Transducer Serial Number Part 2"}, + {0x6F, "No Preferred Color"}, {0x70, "Preferred Line Style"}, {0x71, "Preferred Line Style is Locked"}, {0x72, "Ink"}, @@ -1790,6 +1803,8 @@ static const value_string usb_hid_digitizers_usage_page_vals[] = { {0xA3, "Switch Disabled"}, {0xA4, "Switch Unimplemented"}, {0xA5, "Transducer Switches"}, + {0xA6, "Transducer Index Selector"}, + {0xB0, "Button Press Threshold"}, {0, NULL} }; static const value_string usb_hid_haptic_usage_page_vals[] = { @@ -1813,6 +1828,16 @@ static const value_string usb_hid_haptic_usage_page_vals[] = { {0x1005, "Waveform Rumble Continuous"}, {0x1006, "Waveform Press"}, {0x1007, "Waveform Release"}, + {0x1008, "Waveform Hover"}, + {0x1009, "Waveform Success"}, + {0x100A, "Waveform Error"}, + {0x100B, "Waveform Ink Continuous"}, + {0x100C, "Waveform Pencil Continuous"}, + {0x100D, "Waveform Marker Continuous"}, + {0x100E, "Waveform Chisel Marker Continuous"}, + {0x100F, "Waveform Brush Continuous"}, + {0x1010, "Waveform Eraser Continuous"}, + {0x1011, "Waveform Sparkle Continuous"}, {0, NULL} }; static const value_string usb_hid_physical_input_device_usage_page_vals[] = { @@ -1924,6 +1949,20 @@ static const value_string usb_hid_physical_input_device_usage_page_vals[] = { {0xAC, "RAM Pool Available"}, {0, NULL} }; +static const value_string usb_hid_soc_usage_page_vals[] = { + {0x00, "Undefined"}, + {0x01, "SocControl"}, + {0x02, "FirmwareTransfer"}, + {0x03, "FirmwareFileId"}, + {0x04, "FileOffsetInBytes"}, + {0x05, "FileTransferSizeMaxInBytes"}, + {0x06, "FilePayload"}, + {0x07, "FilePayloadSizeInBytes"}, + {0x08, "FilePayloadContainsLastBytes"}, + {0x09, "FileTransferStop"}, + {0x0A, "FileTransferTillEnd"}, + {0, NULL} +}; static const value_string usb_hid_eye_and_head_tracker_usage_page_vals[] = { {0x0000, "Undefined"}, {0x0001, "Eye Tracker"}, @@ -2139,8 +2178,9 @@ static const value_string usb_hid_sensor_usage_page_vals[] = { {0x00B0, "Personal Activity"}, {0x00B1, "Personal Activity: Activity Detection"}, {0x00B2, "Personal Activity: Device Position"}, - {0x00B3, "Personal Activity: Pedometer"}, - {0x00B4, "Personal Activity: Step Detection"}, + {0x00B3, "Personal Activity: Floor Tracker"}, + {0x00B4, "Personal Activity: Pedometer"}, + {0x00B5, "Personal Activity: Step Detection"}, {0x00C0, "Orientation Extended"}, {0x00C1, "Orientation Extended: Geomagnetic Orientation"}, {0x00C2, "Orientation Extended: Magnetometer"}, @@ -2186,6 +2226,7 @@ static const value_string usb_hid_sensor_usage_page_vals[] = { {0x031C, "Property: Flush FIFO Events"}, {0x031D, "Property: Maximum Power Consumption"}, {0x031E, "Property: Is Primary"}, + {0x031F, "Property: Human Presence Detection Type"}, {0x0400, "Data Field: Location"}, {0x0401, "Reserved (Data Field: Location)"}, {0x0402, "Data Field: Altitude Antenna Sea Level"}, @@ -2311,6 +2352,13 @@ static const value_string usb_hid_sensor_usage_page_vals[] = { {0x04BA, "Data Field: Heartbeat Interval"}, {0x04BB, "Data Field: Respiratory Rate"}, {0x04BC, "Data Field: SpO2"}, + {0x04BD, "Data Field: Human Attention Detected"}, + {0x04BE, "Data Field: Human Head Azimuth"}, + {0x04BF, "Data Field: Human Head Altitude"}, + {0x04C0, "Data Field: Human Head Roll"}, + {0x04C1, "Data Field: Human Head Pitch"}, + {0x04C2, "Data Field: Human Head Yaw"}, + {0x04C3, "Data Field: Human Correlation Id"}, {0x04D0, "Data Field: Light"}, {0x04D1, "Data Field: Illuminance"}, {0x04D2, "Data Field: Color Temperature"}, @@ -2494,6 +2542,7 @@ static const value_string usb_hid_sensor_usage_page_vals[] = { {0x0843, "Reporting State: Wake On No Events"}, {0x0844, "Reporting State: Wake On All Events"}, {0x0845, "Reporting State: Wake On Threshold Events"}, + {0x0846, "Reporting State: Anytime"}, {0x0850, "Power State: Undefined"}, {0x0851, "Power State: D0 Full Power"}, {0x0852, "Power State: D1 Low Power"}, @@ -2673,6 +2722,10 @@ static const value_string usb_hid_sensor_usage_page_vals[] = { {0x09B4, "Hinge Fold Type: Unknown"}, {0x09B5, "Hinge Fold Type: Increasing"}, {0x09B6, "Hinge Fold Type: Decreasing"}, + {0x09C0, "Human Presence Detection: Vendor-Defined Non-Biometric"}, + {0x09C1, "Human Presence Detection: Vendor-Defined Biometric"}, + {0x09C2, "Human Presence Detection: Facial Biometric"}, + {0x09C3, "Human Presence Detection: Audio Biometric"}, {0x1000, "Modifier: Change Sensitivity Absolute"}, {0x2000, "Modifier: Maximum"}, {0x3000, "Modifier: Minimum"}, @@ -2781,7 +2834,7 @@ static const value_string usb_hid_medical_instrument_usage_page_vals[] = { {0xA1, "Soft Control Adjust"}, {0, NULL} }; -static const value_string usb_hid_braille_dispaly_usage_page_vals[] = { +static const value_string usb_hid_braille_display_usage_page_vals[] = { {0x000, "Undefined"}, {0x001, "Braille Display"}, {0x002, "Braille Row"}, @@ -3074,7 +3127,7 @@ static const value_string usb_hid_battery_system_usage_page_vals[] = { {0x88, "iDevicename"}, {0x89, "iDeviceChemistery"}, {0x8A, "ManufacturerData"}, - {0x8B, "Rechargable"}, + {0x8B, "Rechargeable"}, {0x8C, "WarningCapacityLimit"}, {0x8D, "CapacityGranularity1"}, {0x8E, "CapacityGranularity2"}, @@ -3102,200 +3155,201 @@ static const value_string usb_hid_battery_system_usage_page_vals[] = { {0, NULL} }; static const value_string usb_hid_barcode_scanner_usage_page_vals[] = { - {0x00, "Undefined"}, - {0x01, "Bar Code Badge Reader"}, - {0x02, "Bar Code Scanner"}, - {0x03, "Dumb Bar Code Scanner"}, - {0x04, "Cordless Scanner Base"}, - {0x05, "Bar Code Scanner Cradle"}, - {0x10, "Attribute Report"}, - {0x11, "Settings Report"}, - {0x12, "Scanned Data Report"}, - {0x13, "Raw Scanned Data Report"}, - {0x14, "Trigger Report"}, - {0x15, "Status Report"}, - {0x16, "UPC/EAN Control Report"}, - {0x17, "EAN 2/3 Label Control Report"}, - {0x18, "Code 39 Control Report"}, - {0x19, "Interleaved 2 of 5 Control Report"}, - {0x1A, "Standard 2 of 5 Control Report"}, - {0x1B, "MSI Plessey Control Report"}, - {0x1C, "Codabar Control Report"}, - {0x1D, "Code 128 Control Report"}, - {0x1E, "Misc 1D Control Report"}, - {0x1F, "2D Control Report"}, - {0x30, "Aiming/Pointer Mode"}, - {0x31, "Bar Code Present Sensor"}, - {0x32, "Class 1A Laser"}, - {0x33, "Class 2 Laser"}, - {0x34, "Heater Present"}, - {0x35, "Contact Scanner"}, - {0x36, "Electronic Article Surveillance Notification"}, - {0x37, "Constant Electronic Article Surveillance"}, - {0x38, "Error Indication"}, - {0x39, "Fixed Beeper"}, - {0x3A, "Good Decode Indication"}, - {0x3B, "Hands Free Scanning"}, - {0x3C, "Intrinsically Safe"}, - {0x3D, "Klasse Eins Laser"}, - {0x3E, "Long Range Scanner"}, - {0x3F, "Mirror Speed Control"}, - {0x40, "Not On File Indication"}, - {0x41, "Programmable Beeper"}, - {0x42, "Triggerless"}, - {0x43, "Wand"}, - {0x44, "Water Resistant"}, - {0x45, "Multi-Range Scanner"}, - {0x46, "Proximity Sensor"}, - {0x4D, "Fragment Decoding"}, - {0x4E, "Scanner Read Confidence"}, - {0x4F, "Data Prefix"}, - {0x50, "Prefix AIMI"}, - {0x51, "Prefix None"}, - {0x52, "Prefix Proprietary"}, - {0x55, "Active Time"}, - {0x56, "Aiming Laser Pattern"}, - {0x57, "Bar Code Present"}, - {0x58, "Beeper State"}, - {0x59, "Laser On Time"}, - {0x5A, "Laser State"}, - {0x5B, "Lockout Time"}, - {0x5C, "Motor State"}, - {0x5D, "Motor Timeout"}, - {0x5E, "Power On Reset Scanner"}, - {0x5F, "Prevent Read of Barcodes"}, - {0x60, "Initiate Barcode Read"}, - {0x61, "Trigger State"}, - {0x62, "Trigger Mode"}, - {0x63, "Trigger Mode Blinking Laser On"}, - {0x64, "Trigger Mode Continuous Laser On"}, - {0x65, "Trigger Mode Laser on while Pulled"}, - {0x66, "Trigger Mode Laser stays on after Trigger release"}, - {0x6D, "Commit Parameters to NVM"}, - {0x6E, "Parameter Scanning"}, - {0x6F, "Parameters Changed"}, - {0x70, "Set parameter default values"}, - {0x75, "Scanner In Cradle"}, - {0x76, "Scanner In Range"}, - {0x7A, "Aim Duration"}, - {0x7B, "Good Read Lamp Duration"}, - {0x7C, "Good Read Lamp Intensity"}, - {0x7D, "Good Read LED"}, - {0x7E, "Good Read Tone Frequency"}, - {0x7F, "Good Read Tone Length"}, - {0x80, "Good Read Tone Volume"}, - {0x82, "No Read Message"}, - {0x83, "Not on File Volume"}, - {0x84, "Powerup Beep"}, - {0x85, "Sound Error Beep"}, - {0x86, "Sound Good Read Beep"}, - {0x87, "Sound Not On File Beep"}, - {0x88, "Good Read When to Write"}, - {0x89, "GRWTI After Decode"}, - {0x8A, "GRWTI Beep/Lamp after transmit"}, - {0x8B, "GRWTI No Beep/Lamp use at all"}, - {0x91, "Bookland EAN"}, - {0x92, "Convert EAN 8 to 13 Type"}, - {0x93, "Convert UPC A to EAN-13"}, - {0x94, "Convert UPC-E to A"}, - {0x95, "EAN-13"}, - {0x96, "EAN-8"}, - {0x97, "EAN-99 128_Mandatory"}, - {0x98, "EAN-99 P5/128_Optional"}, - {0x9A, "UPC/EAN"}, - {0x9B, "UPC/EAN Coupon Code"}, - {0x9C, "UPC/EAN Periodicals"}, - {0x9D, "UPC-A"}, - {0x9E, "UPC-A with 128 Mandatory"}, - {0x9F, "UPC-A with 128 Optional"}, - {0xA0, "UPC-A with P5 Optional"}, - {0xA1, "UPC-E"}, - {0xA2, "UPC-E1"}, - {0xA9, "Periodical"}, - {0xAA, "Periodical Auto-Discriminate + 2"}, - {0xAB, "Periodical Only Decode with + 2"}, - {0xAC, "Periodical Ignore + 2"}, - {0xAD, "Periodical Auto-Discriminate + 5"}, - {0xAE, "Periodical Only Decode with + 5"}, - {0xAF, "Periodical Ignore + 5"}, - {0xB0, "Check"}, - {0xB1, "Check Disable Price"}, - {0xB2, "Check Enable 4 digit Price"}, - {0xB3, "Check Enable 5 digit Price"}, - {0xB4, "Check Enable European 4 digit Price"}, - {0xB5, "Check Enable European 5 digit Price"}, - {0xB7, "EAN Two Label"}, - {0xB8, "EAN Three Label"}, - {0xB9, "EAN 8 Flag Digit 1"}, - {0xBA, "EAN 8 Flag Digit 2"}, - {0xBB, "EAN 8 Flag Digit 3"}, - {0xBC, "EAN 13 Flag Digit 1"}, - {0xBD, "EAN 13 Flag Digit 2"}, - {0xBE, "EAN 13 Flag Digit 3"}, - {0xBF, "Add EAN 2/3 Label Definition"}, - {0xC0, "Clear all EAN 2/3 Label Definitions"}, - {0xC3, "Codabar"}, - {0xC4, "Code 128"}, - {0xC7, "Code 39"}, - {0xC8, "Code 93 "}, - {0xC9, "Full ASCII Conversion"}, - {0xCA, "Interleaved 2 of 5"}, - {0xCB, "Italian Pharmacy Code"}, - {0xCC, "MSI/Plessey"}, - {0xCD, "Standard 2 of 5 IATA"}, - {0xCE, "Standard 2 of 5"}, - {0xD3, "Transmit Start/Stop"}, - {0xD4, "Tri-Optic"}, - {0xD5, "UCC/EAN-128"}, - {0xD6, "Check Digit"}, - {0xD7, "Check Digit Disable"}, - {0xD8, "Check Digit Enable Interleaved 2 of 5 OPCC"}, - {0xD9, "Check Digit Enable Interleaved 2 of 5 USS"}, - {0xDA, "Check Digit Enable Standard 2 of 5 OPCC"}, - {0xDB, "Check Digit Enable Standard 2 of 5 USS"}, - {0xDC, "Check Digit Enable One MSI Plessey"}, - {0xDD, "Check Digit Enable Two MSI Plessey"}, - {0xDE, "Check Digit Codabar Enable"}, - {0xDF, "Check Digit Code 39 Enable"}, - {0xF0, "Transmit Check Digit"}, - {0xF1, "Disable Check Digit Transmit"}, - {0xF2, "Enable Check Digit Transmit"}, - {0xFB, "Symbology Identifier 1"}, - {0xFC, "Symbology Identifier 2"}, - {0xFD, "Symbology Identifier 3"}, - {0xFE, "Decoded Data"}, - {0xFF, "Decode Data Continued"}, - {0x00, "Bar Space Data"}, - {0x01, "Scanner Data Accuracy"}, - {0x02, "Raw Data Polarity"}, - {0x03, "Polarity Inverted Bar Code"}, - {0x04, "Polarity Normal Bar Code"}, - {0x06, "Minimum Length to Decode"}, - {0x07, "Maximum Length to Decode"}, - {0x08, "First Discrete Length to Decode"}, - {0x09, "Second Discrete Length to Decode"}, - {0x0A, "Data Length Method"}, - {0x0B, "DL Method Read any"}, - {0x0C, "DL Method Check in Range"}, - {0x0D, "DL Method Check for Discrete"}, - {0x10, "Aztec Code"}, - {0x11, "BC412"}, - {0x12, "Channel Code"}, - {0x13, "Code 16"}, - {0x14, "Code 32"}, - {0x15, "Code 49"}, - {0x16, "Code One"}, - {0x17, "Colorcode"}, - {0x18, "Data Matrix"}, - {0x19, "MaxiCode"}, - {0x1A, "MicroPDF"}, - {0x1B, "PDF-417"}, - {0x1C, "PosiCode"}, - {0x1D, "QR Code"}, - {0x1E, "SuperCode"}, - {0x1F, "UltraCode"}, - {0x20, "USD-5 (Slug Code)"}, - {0x21, "VeriCode"}, + {0x000, "Undefined"}, + {0x001, "Bar Code Badge Reader"}, + {0x002, "Bar Code Scanner"}, + {0x003, "Dumb Bar Code Scanner"}, + {0x004, "Cordless Scanner Base"}, + {0x005, "Bar Code Scanner Cradle"}, + {0x010, "Attribute Report"}, + {0x011, "Settings Report"}, + {0x012, "Scanned Data Report"}, + {0x013, "Raw Scanned Data Report"}, + {0x014, "Trigger Report"}, + {0x015, "Status Report"}, + {0x016, "UPC/EAN Control Report"}, + {0x017, "EAN 2/3 Label Control Report"}, + {0x018, "Code 39 Control Report"}, + {0x019, "Interleaved 2 of 5 Control Report"}, + {0x01A, "Standard 2 of 5 Control Report"}, + {0x01B, "MSI Plessey Control Report"}, + {0x01C, "Codabar Control Report"}, + {0x01D, "Code 128 Control Report"}, + {0x01E, "Misc 1D Control Report"}, + {0x01F, "2D Control Report"}, + {0x030, "Aiming/Pointer Mode"}, + {0x031, "Bar Code Present Sensor"}, + {0x032, "Class 1A Laser"}, + {0x033, "Class 2 Laser"}, + {0x034, "Heater Present"}, + {0x035, "Contact Scanner"}, + {0x036, "Electronic Article Surveillance Notification"}, + {0x037, "Constant Electronic Article Surveillance"}, + {0x038, "Error Indication"}, + {0x039, "Fixed Beeper"}, + {0x03A, "Good Decode Indication"}, + {0x03B, "Hands Free Scanning"}, + {0x03C, "Intrinsically Safe"}, + {0x03D, "Klasse Eins Laser"}, + {0x03E, "Long Range Scanner"}, + {0x03F, "Mirror Speed Control"}, + {0x040, "Not On File Indication"}, + {0x041, "Programmable Beeper"}, + {0x042, "Triggerless"}, + {0x043, "Wand"}, + {0x044, "Water Resistant"}, + {0x045, "Multi-Range Scanner"}, + {0x046, "Proximity Sensor"}, + {0x04D, "Fragment Decoding"}, + {0x04E, "Scanner Read Confidence"}, + {0x04F, "Data Prefix"}, + {0x050, "Prefix AIMI"}, + {0x051, "Prefix None"}, + {0x052, "Prefix Proprietary"}, + {0x055, "Active Time"}, + {0x056, "Aiming Laser Pattern"}, + {0x057, "Bar Code Present"}, + {0x058, "Beeper State"}, + {0x059, "Laser On Time"}, + {0x05A, "Laser State"}, + {0x05B, "Lockout Time"}, + {0x05C, "Motor State"}, + {0x05D, "Motor Timeout"}, + {0x05E, "Power On Reset Scanner"}, + {0x05F, "Prevent Read of Barcodes"}, + {0x060, "Initiate Barcode Read"}, + {0x061, "Trigger State"}, + {0x062, "Trigger Mode"}, + {0x063, "Trigger Mode Blinking Laser On"}, + {0x064, "Trigger Mode Continuous Laser On"}, + {0x065, "Trigger Mode Laser on while Pulled"}, + {0x066, "Trigger Mode Laser stays on after Trigger release"}, + {0x06D, "Commit Parameters to NVM"}, + {0x06E, "Parameter Scanning"}, + {0x06F, "Parameters Changed"}, + {0x070, "Set parameter default values"}, + {0x075, "Scanner In Cradle"}, + {0x076, "Scanner In Range"}, + {0x07A, "Aim Duration"}, + {0x07B, "Good Read Lamp Duration"}, + {0x07C, "Good Read Lamp Intensity"}, + {0x07D, "Good Read LED"}, + {0x07E, "Good Read Tone Frequency"}, + {0x07F, "Good Read Tone Length"}, + {0x080, "Good Read Tone Volume"}, + {0x082, "No Read Message"}, + {0x083, "Not on File Volume"}, + {0x084, "Powerup Beep"}, + {0x085, "Sound Error Beep"}, + {0x086, "Sound Good Read Beep"}, + {0x087, "Sound Not On File Beep"}, + {0x088, "Good Read When to Write"}, + {0x089, "GRWTI After Decode"}, + {0x08A, "GRWTI Beep/Lamp after transmit"}, + {0x08B, "GRWTI No Beep/Lamp use at all"}, + {0x091, "Bookland EAN"}, + {0x092, "Convert EAN 8 to 13 Type"}, + {0x093, "Convert UPC A to EAN-13"}, + {0x094, "Convert UPC-E to A"}, + {0x095, "EAN-13"}, + {0x096, "EAN-8"}, + {0x097, "EAN-99 128_Mandatory"}, + {0x098, "EAN-99 P5/128_Optional"}, + {0x099, "Enable EAN Two Label"}, + {0x09A, "UPC/EAN"}, + {0x09B, "UPC/EAN Coupon Code"}, + {0x09C, "UPC/EAN Periodicals"}, + {0x09D, "UPC-A"}, + {0x09E, "UPC-A with 128 Mandatory"}, + {0x09F, "UPC-A with 128 Optional"}, + {0x0A0, "UPC-A with P5 Optional"}, + {0x0A1, "UPC-E"}, + {0x0A2, "UPC-E1"}, + {0x0A9, "Periodical"}, + {0x0AA, "Periodical Auto-Discriminate + 2"}, + {0x0AB, "Periodical Only Decode with + 2"}, + {0x0AC, "Periodical Ignore + 2"}, + {0x0AD, "Periodical Auto-Discriminate + 5"}, + {0x0AE, "Periodical Only Decode with + 5"}, + {0x0AF, "Periodical Ignore + 5"}, + {0x0B0, "Check"}, + {0x0B1, "Check Disable Price"}, + {0x0B2, "Check Enable 4 digit Price"}, + {0x0B3, "Check Enable 5 digit Price"}, + {0x0B4, "Check Enable European 4 digit Price"}, + {0x0B5, "Check Enable European 5 digit Price"}, + {0x0B7, "EAN Two Label"}, + {0x0B8, "EAN Three Label"}, + {0x0B9, "EAN 8 Flag Digit 1"}, + {0x0BA, "EAN 8 Flag Digit 2"}, + {0x0BB, "EAN 8 Flag Digit 3"}, + {0x0BC, "EAN 13 Flag Digit 1"}, + {0x0BD, "EAN 13 Flag Digit 2"}, + {0x0BE, "EAN 13 Flag Digit 3"}, + {0x0BF, "Add EAN 2/3 Label Definition"}, + {0x0C0, "Clear all EAN 2/3 Label Definitions"}, + {0x0C3, "Codabar"}, + {0x0C4, "Code 128"}, + {0x0C7, "Code 39"}, + {0x0C8, "Code 93 "}, + {0x0C9, "Full ASCII Conversion"}, + {0x0CA, "Interleaved 2 of 5"}, + {0x0CB, "Italian Pharmacy Code"}, + {0x0CC, "MSI/Plessey"}, + {0x0CD, "Standard 2 of 5 IATA"}, + {0x0CE, "Standard 2 of 5"}, + {0x0D3, "Transmit Start/Stop"}, + {0x0D4, "Tri-Optic"}, + {0x0D5, "UCC/EAN-128"}, + {0x0D6, "Check Digit"}, + {0x0D7, "Check Digit Disable"}, + {0x0D8, "Check Digit Enable Interleaved 2 of 5 OPCC"}, + {0x0D9, "Check Digit Enable Interleaved 2 of 5 USS"}, + {0x0DA, "Check Digit Enable Standard 2 of 5 OPCC"}, + {0x0DB, "Check Digit Enable Standard 2 of 5 USS"}, + {0x0DC, "Check Digit Enable One MSI Plessey"}, + {0x0DD, "Check Digit Enable Two MSI Plessey"}, + {0x0DE, "Check Digit Codabar Enable"}, + {0x0DF, "Check Digit Code 39 Enable"}, + {0x0F0, "Transmit Check Digit"}, + {0x0F1, "Disable Check Digit Transmit"}, + {0x0F2, "Enable Check Digit Transmit"}, + {0x0FB, "Symbology Identifier 1"}, + {0x0FC, "Symbology Identifier 2"}, + {0x0FD, "Symbology Identifier 3"}, + {0x0FE, "Decoded Data"}, + {0x0FF, "Decode Data Continued"}, + {0x100, "Bar Space Data"}, + {0x101, "Scanner Data Accuracy"}, + {0x102, "Raw Data Polarity"}, + {0x103, "Polarity Inverted Bar Code"}, + {0x104, "Polarity Normal Bar Code"}, + {0x106, "Minimum Length to Decode"}, + {0x107, "Maximum Length to Decode"}, + {0x108, "First Discrete Length to Decode"}, + {0x109, "Second Discrete Length to Decode"}, + {0x10A, "Data Length Method"}, + {0x10B, "DL Method Read any"}, + {0x10C, "DL Method Check in Range"}, + {0x10D, "DL Method Check for Discrete"}, + {0x110, "Aztec Code"}, + {0x111, "BC412"}, + {0x112, "Channel Code"}, + {0x113, "Code 16"}, + {0x114, "Code 32"}, + {0x115, "Code 49"}, + {0x116, "Code One"}, + {0x117, "Colorcode"}, + {0x118, "Data Matrix"}, + {0x119, "MaxiCode"}, + {0x11A, "MicroPDF"}, + {0x11B, "PDF-417"}, + {0x11C, "PosiCode"}, + {0x11D, "QR Code"}, + {0x11E, "SuperCode"}, + {0x11F, "UltraCode"}, + {0x120, "USD-5 (Slug Code)"}, + {0x121, "VeriCode"}, {0, NULL} }; static const value_string usb_hid_weighing_devices_usage_page_vals[] = { @@ -3649,10 +3703,10 @@ static const value_string keycode_vals[] = { }; static value_string_ext keycode_vals_ext = VALUE_STRING_EXT_INIT(keycode_vals); -static guint32 -hid_unpack_value(guint8 *data, unsigned int idx, unsigned int size) +static uint32_t +hid_unpack_value(uint8_t *data, unsigned int idx, unsigned int size) { - guint32 value = 0; + uint32_t value = 0; for(unsigned int i = 1; i <= size; i++) value |= data[idx + i] << (8 * (i - 1)); @@ -3660,34 +3714,34 @@ hid_unpack_value(guint8 *data, unsigned int idx, unsigned int size) return value; } -static gboolean -hid_unpack_signed(guint8 *data, unsigned int idx, unsigned int size, gint32 *value) +static bool +hid_unpack_signed(uint8_t *data, unsigned int idx, unsigned int size, int32_t *value) { if (size == 1) - *value = (gint8) hid_unpack_value(data, idx, size); + *value = (int8_t) hid_unpack_value(data, idx, size); else if (size == 2) - *value = (gint16) hid_unpack_value(data, idx, size); + *value = (int16_t) hid_unpack_value(data, idx, size); else if (size == 4) - *value = (gint32) hid_unpack_value(data, idx, size); + *value = (int32_t) hid_unpack_value(data, idx, size); else - return TRUE; + return true; - return FALSE; + return false; } -static gboolean +static bool parse_report_descriptor(report_descriptor_t *rdesc) { hid_field_t field; - guint8 *data = rdesc->desc_body; + uint8_t *data = rdesc->desc_body; unsigned int tag, type, size; - guint8 prefix; - guint32 defined = 0, usage_page = 0, usage = 0, usage_min = 0, usage_max = 0; + uint8_t prefix; + uint32_t defined = 0, usage_page = 0, usage = 0, usage_min = 0, usage_max = 0; wmem_allocator_t *scope = wmem_file_scope(); - gboolean first_item = TRUE; + bool first_item = true; memset(&field, 0, sizeof(field)); - field.usages = wmem_array_new(scope, sizeof(guint32)); + field.usages = wmem_array_new(scope, sizeof(uint32_t)); rdesc->fields_in = wmem_array_new(scope, sizeof(hid_field_t)); rdesc->fields_out = wmem_array_new(scope, sizeof(hid_field_t)); @@ -3716,8 +3770,8 @@ parse_report_descriptor(report_descriptor_t *rdesc) /* new field */ wmem_array_append_one(rdesc->fields_in, field); - field.usages = wmem_array_new(scope, sizeof(guint32)); - first_item = FALSE; + field.usages = wmem_array_new(scope, sizeof(uint32_t)); + first_item = false; /* only keep the global items */ defined &= HID_GLOBAL_MASK; @@ -3732,8 +3786,8 @@ parse_report_descriptor(report_descriptor_t *rdesc) /* new field */ wmem_array_append_one(rdesc->fields_out, field); - field.usages = wmem_array_new(scope, sizeof(guint32)); - first_item = FALSE; + field.usages = wmem_array_new(scope, sizeof(uint32_t)); + first_item = false; defined &= HID_GLOBAL_MASK; break; @@ -3748,7 +3802,7 @@ parse_report_descriptor(report_descriptor_t *rdesc) case USBHID_MAINITEM_TAG_COLLECTION: /* clear usages */ wmem_free(scope, field.usages); - field.usages = wmem_array_new(scope, sizeof(guint32)); + field.usages = wmem_array_new(scope, sizeof(uint32_t)); break; default: @@ -3761,7 +3815,7 @@ parse_report_descriptor(report_descriptor_t *rdesc) { case USBHID_GLOBALITEM_TAG_USAGE_PAGE: usage_page = hid_unpack_value(data, i, size); - if (usage_page > G_MAXUINT16) + if (usage_page > UINT16_MAX) goto err; defined |= HID_USAGE_PAGE; break; @@ -3787,7 +3841,7 @@ parse_report_descriptor(report_descriptor_t *rdesc) if (!first_item && !rdesc->uses_report_id) goto err; - rdesc->uses_report_id = TRUE; + rdesc->uses_report_id = true; field.report_id = hid_unpack_value(data, i, size); defined |= HID_REPORT_ID; @@ -3866,7 +3920,7 @@ parse_report_descriptor(report_descriptor_t *rdesc) /* min and max are inclusive */ wmem_array_grow(field.usages, usage_max - usage_min + 1); - for (guint32 j = usage_min; j <= usage_max; j++) { + for (uint32_t j = usage_min; j <= usage_max; j++) { wmem_array_append_one(field.usages, j); } @@ -3885,7 +3939,7 @@ parse_report_descriptor(report_descriptor_t *rdesc) i += size + 1; } - return TRUE; + return true; err: for (unsigned int j = 0; j < wmem_array_get_count(rdesc->fields_in); j++) @@ -3896,25 +3950,25 @@ err: wmem_free(scope, rdesc->fields_in); wmem_free(scope, rdesc->fields_out); - return FALSE; + return false; } -static gboolean -is_correct_interface(usb_conv_info_t *info1, usb_conv_info_t *info2) +static bool +is_correct_interface(urb_info_t *urb, report_descriptor_t *report) { - return (info1->bus_id == info2->bus_id) && - (info1->device_address == info2->device_address) && - (info1->interfaceNum == info2->interfaceNum); + return (urb->bus_id == report->bus_id) && + (urb->device_address == report->device_address) && + (urb->conv->interfaceNum == report->interface); } /* Returns the report descriptor */ static report_descriptor_t _U_ * -get_report_descriptor(packet_info *pinfo _U_, usb_conv_info_t *usb_info) +get_report_descriptor(packet_info *pinfo _U_, urb_info_t *urb) { - guint32 bus_id = usb_info->bus_id; - guint32 device_address = usb_info->device_address; - guint32 interface = usb_info->interfaceNum; + uint32_t bus_id = urb->bus_id; + uint32_t device_address = urb->device_address; + uint32_t interface = urb->conv->interfaceNum; wmem_tree_key_t key[] = { {1, &bus_id}, {1, &device_address}, @@ -3925,7 +3979,7 @@ get_report_descriptor(packet_info *pinfo _U_, usb_conv_info_t *usb_info) report_descriptor_t *data = NULL; data = (report_descriptor_t*) wmem_tree_lookup32_array_le(report_descriptors, key); - if (data && is_correct_interface(usb_info, &data->usb_info)) + if (data && is_correct_interface(urb, data)) return data; return NULL; @@ -3935,9 +3989,9 @@ get_report_descriptor(packet_info *pinfo _U_, usb_conv_info_t *usb_info) static void insert_report_descriptor(packet_info *pinfo, report_descriptor_t *data) { - guint32 bus_id = data->usb_info.bus_id; - guint32 device_address = data->usb_info.device_address; - guint32 interface = data->usb_info.interfaceNum; + uint32_t bus_id = data->bus_id; + uint32_t device_address = data->device_address; + uint32_t interface = data->interface; wmem_tree_key_t key[] = { {1, &bus_id}, {1, &device_address}, @@ -3951,7 +4005,7 @@ insert_report_descriptor(packet_info *pinfo, report_descriptor_t *data) /* Returns usage page string */ static const char* -get_usage_page_string(guint32 usage_page) +get_usage_page_string(uint32_t usage_page) { const char *str; @@ -3967,8 +4021,8 @@ get_usage_page_string(guint32 usage_page) } /* Returns usage page item string */ -static gchar* -get_usage_page_item_string(wmem_allocator_t *pool, guint32 usage_page, guint32 id) +static char* +get_usage_page_item_string(wmem_allocator_t *pool, uint32_t usage_page, uint32_t id) { const char *str = NULL; const char *fmt_str = NULL; @@ -4029,6 +4083,9 @@ get_usage_page_item_string(wmem_allocator_t *pool, guint32 usage_page, guint32 i case UNICODE_PAGE: fmt_str = "Character U+%04X"; break; + case SOC_PAGE: + str = try_val_to_str(id, usb_hid_soc_usage_page_vals); + break; case EYE_AND_HEAD_TRACKER_PAGE: str = try_val_to_str(id, usb_hid_eye_and_head_tracker_usage_page_vals); break; @@ -4044,7 +4101,7 @@ get_usage_page_item_string(wmem_allocator_t *pool, guint32 usage_page, guint32 i str = try_val_to_str(id, usb_hid_medical_instrument_usage_page_vals); break; case BRAILLE_DISPLAY_PAGE: - str = try_val_to_str(id, usb_hid_braille_dispaly_usage_page_vals); + str = try_val_to_str(id, usb_hid_braille_display_usage_page_vals); break; case LIGHTING_AND_ILLUMINATION_PAGE: str = try_val_to_str(id, usb_hid_lighting_and_illumination_usage_page_vals); @@ -4102,7 +4159,7 @@ static int dissect_usb_hid_report_mainitem_data(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *tvb, int offset, unsigned int bSize, unsigned int bTag) { proto_item *ti = proto_tree_get_parent(tree); - guint32 val = 0; + uint32_t val = 0; switch (bTag) { case USBHID_MAINITEM_TAG_INPUT: @@ -4122,9 +4179,9 @@ dissect_usb_hid_report_mainitem_data(packet_info *pinfo _U_, proto_tree *tree, t if (bSize > 1) proto_tree_add_item(tree, hf_usb_hid_mainitem_bit8, tvb, offset, bSize, ENC_LITTLE_ENDIAN); else - proto_tree_add_boolean_format_value(tree, hf_usb_hid_mainitem_bit8, tvb, offset, 0, FALSE, "Buffered bytes (default, no second byte present)"); + proto_tree_add_boolean_format_value(tree, hf_usb_hid_mainitem_bit8, tvb, offset, 0, false, "Buffered bytes (default, no second byte present)"); - val = tvb_get_guint8(tvb, offset); + val = tvb_get_uint8(tvb, offset); if (val & (1 << 0)) proto_item_append_text(ti, " (Const,"); else @@ -4173,13 +4230,13 @@ dissect_usb_hid_report_globalitem_data(packet_info *pinfo _U_, proto_tree *tree, { const char *str = NULL; proto_item *ti = proto_tree_get_parent(tree); - guint32 val = 0; - gint32 val_sig = 0; + uint32_t val = 0; + int32_t val_sig = 0; switch (bTag) { case USBHID_GLOBALITEM_TAG_USAGE_PAGE: switch (bSize) { - case 1: global->usage_page = tvb_get_guint8(tvb, offset); break; + case 1: global->usage_page = tvb_get_uint8(tvb, offset); break; case 2: global->usage_page = tvb_get_letohs(tvb, offset); break; case 3: global->usage_page = tvb_get_letoh24(tvb, offset); break; case 4: global->usage_page = tvb_get_letohl(tvb, offset); break; @@ -4220,7 +4277,7 @@ dissect_usb_hid_report_globalitem_data(packet_info *pinfo _U_, proto_tree *tree, proto_tree_add_item(tree, hf_usb_hid_globalitem_unit_temp, tvb, offset, bSize, ENC_LITTLE_ENDIAN); proto_tree_add_item(tree, hf_usb_hid_globalitem_unit_current, tvb, offset, bSize, ENC_LITTLE_ENDIAN); proto_tree_add_item(tree, hf_usb_hid_globalitem_unit_brightness, tvb, offset, bSize, ENC_LITTLE_ENDIAN); - proto_item_append_text(ti, " (0x%02x)", tvb_get_guint8(tvb, offset)); + proto_item_append_text(ti, " (0x%02x)", tvb_get_uint8(tvb, offset)); break; case USBHID_GLOBALITEM_TAG_REPORT_SIZE: proto_tree_add_item_ret_uint(tree, hf_usb_hid_globalitem_report_size, tvb, offset, bSize, ENC_LITTLE_ENDIAN, &val); @@ -4261,10 +4318,10 @@ dissect_usb_hid_report_globalitem_data(packet_info *pinfo _U_, proto_tree *tree, static int dissect_usb_hid_report_localitem_data(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, unsigned int bSize, unsigned int bTag, struct usb_hid_global_state *global) { - guint32 id = 0xffff; + uint32_t id = 0xffff; proto_item *ti = proto_tree_get_parent(tree); - gchar *str = NULL; - guint32 val = 0; + char *str = NULL; + uint32_t val = 0; switch (bTag) { case USBHID_LOCALITEM_TAG_USAGE: @@ -4274,7 +4331,7 @@ dissect_usb_hid_report_localitem_data(packet_info *pinfo, proto_tree *tree, tvbu } else { /* Only lower few bits given, need to combine with last global ID */ if (bSize == 1) - id = tvb_get_guint8(tvb, offset); + id = tvb_get_uint8(tvb, offset); else if (bSize == 2) id = tvb_get_ntohs(tvb, offset); str = get_usage_page_item_string(pinfo->pool, global->usage_page, id); @@ -4331,7 +4388,7 @@ dissect_usb_hid_report_localitem_data(packet_info *pinfo, proto_tree *tree, tvbu /* Dissector for individual HID report items. Recursive. */ static int // NOLINTNEXTLINE(misc-no-recursion) -dissect_usb_hid_report_item(packet_info *pinfo _U_, proto_tree *parent_tree, tvbuff_t *tvb, int offset, usb_conv_info_t *usb_conv_info _U_, const struct usb_hid_global_state *global) +dissect_usb_hid_report_item(packet_info *pinfo _U_, proto_tree *parent_tree, tvbuff_t *tvb, int offset, urb_info_t *urb, const struct usb_hid_global_state *global) { proto_item *subitem; proto_tree *tree, *subtree; @@ -4347,7 +4404,7 @@ dissect_usb_hid_report_item(packet_info *pinfo _U_, proto_tree *parent_tree, tvb { old_offset=offset; - tmp = tvb_get_guint8(tvb, offset); + tmp = tvb_get_uint8(tvb, offset); bSize = tmp & USBHID_SIZE_MASK; if (bSize == 3) bSize++; /* 3 == four bytes */ bType = (tmp & USBHID_TYPE_MASK) >> 2; @@ -4381,7 +4438,7 @@ dissect_usb_hid_report_item(packet_info *pinfo _U_, proto_tree *parent_tree, tvb offset++; if ((bType == 3) && (bTag == 16)) { /* Long item */ - bSize = tvb_get_guint8(tvb, offset); + bSize = tvb_get_uint8(tvb, offset); proto_tree_add_item(subtree, hf_usb_hid_item_bDataSize, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset++; proto_tree_add_item(subtree, hf_usb_hid_item_bLongItemTag, tvb, offset, 1, ENC_LITTLE_ENDIAN); @@ -4411,7 +4468,7 @@ dissect_usb_hid_report_item(packet_info *pinfo _U_, proto_tree *parent_tree, tvb if (bTag == USBHID_MAINITEM_TAG_COLLECTION) { /* Begin collection, nest following elements under us */ increment_dissection_depth(pinfo); - offset = dissect_usb_hid_report_item(pinfo, subtree, tvb, offset, usb_conv_info, &cur_global); + offset = dissect_usb_hid_report_item(pinfo, subtree, tvb, offset, urb, &cur_global); decrement_dissection_depth(pinfo); proto_item_set_len(subitem, offset-old_offset); } else if (bTag == USBHID_MAINITEM_TAG_ENDCOLLECTION) { @@ -4425,7 +4482,7 @@ dissect_usb_hid_report_item(packet_info *pinfo _U_, proto_tree *parent_tree, tvb /* Dissector for HID "GET DESCRIPTOR" subtype. */ int -dissect_usb_hid_get_report_descriptor(packet_info *pinfo _U_, proto_tree *parent_tree, tvbuff_t *tvb, int offset, usb_conv_info_t *usb_conv_info) +dissect_usb_hid_get_report_descriptor(packet_info *pinfo _U_, proto_tree *parent_tree, tvbuff_t *tvb, int offset, urb_info_t *urb) { proto_item *item; proto_tree *tree; @@ -4437,16 +4494,18 @@ dissect_usb_hid_get_report_descriptor(packet_info *pinfo _U_, proto_tree *parent item = proto_tree_add_protocol_format(parent_tree, proto_usb_hid, tvb, offset, -1, "HID Report"); tree = proto_item_add_subtree(item, ett_usb_hid_report); - offset = dissect_usb_hid_report_item(pinfo, tree, tvb, offset, usb_conv_info, &initial_global); + offset = dissect_usb_hid_report_item(pinfo, tree, tvb, offset, urb, &initial_global); /* only insert report descriptor the first time we parse it */ - if (!PINFO_FD_VISITED(pinfo) && usb_conv_info) { + if (!PINFO_FD_VISITED(pinfo) && urb && urb->conv) { wmem_allocator_t *scope = wmem_file_scope(); report_descriptor_t *data = wmem_new0(scope, report_descriptor_t); - data->usb_info = *usb_conv_info; + data->bus_id = urb->bus_id; + data->device_address = urb->device_address; + data->interface = urb->conv->interfaceNum; data->desc_length = offset - old_offset; - data->desc_body = (guint8*) tvb_memdup(scope, tvb, old_offset, data->desc_length); + data->desc_body = (uint8_t*) tvb_memdup(scope, tvb, old_offset, data->desc_length); if (parse_report_descriptor(data)) { insert_report_descriptor(pinfo, data); @@ -4463,7 +4522,7 @@ dissect_usb_hid_get_report_descriptor(packet_info *pinfo _U_, proto_tree *parent /* Dissector for HID GET_REPORT request. See USBHID 1.11, Chapter 7.2.1 Get_Report Request */ static void -dissect_usb_hid_get_report(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *tvb, int offset, gboolean is_request, usb_conv_info_t *usb_conv_info _U_) +dissect_usb_hid_get_report(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *tvb, int offset, bool is_request, urb_info_t *urb _U_) { proto_item *item; proto_tree *subtree; @@ -4489,7 +4548,7 @@ dissect_usb_hid_get_report(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *t /* Dissector for HID SET_REPORT request. See USBHID 1.11, Chapter 7.2.2 Set_Report Request */ static void -dissect_usb_hid_set_report(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *tvb, int offset, gboolean is_request, usb_conv_info_t *usb_conv_info _U_) +dissect_usb_hid_set_report(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *tvb, int offset, bool is_request, urb_info_t *urb _U_) { proto_item *item; proto_tree *subtree; @@ -4515,7 +4574,7 @@ dissect_usb_hid_set_report(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *t /* Dissector for HID GET_IDLE request. See USBHID 1.11, Chapter 7.2.3 Get_Idle Request */ static void -dissect_usb_hid_get_idle(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *tvb, int offset, gboolean is_request, usb_conv_info_t *usb_conv_info _U_) +dissect_usb_hid_get_idle(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *tvb, int offset, bool is_request, urb_info_t *urb _U_) { proto_item *item; proto_tree *subtree; @@ -4540,7 +4599,7 @@ dissect_usb_hid_get_idle(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *tvb /* Dissector for HID SET_IDLE request. See USBHID 1.11, Chapter 7.2.4 Set_Idle Request */ static void -dissect_usb_hid_set_idle(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *tvb, int offset, gboolean is_request, usb_conv_info_t *usb_conv_info _U_) +dissect_usb_hid_set_idle(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *tvb, int offset, bool is_request, urb_info_t *urb _U_) { proto_item *item; proto_tree *subtree; @@ -4566,7 +4625,7 @@ dissect_usb_hid_set_idle(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *tvb /* Dissector for HID GET_PROTOCOL request. See USBHID 1.11, Chapter 7.2.5 Get_Protocol Request */ static void -dissect_usb_hid_get_protocol(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *tvb, int offset, gboolean is_request, usb_conv_info_t *usb_conv_info _U_) +dissect_usb_hid_get_protocol(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *tvb, int offset, bool is_request, urb_info_t *urb _U_) { if (!is_request) return; @@ -4583,7 +4642,7 @@ dissect_usb_hid_get_protocol(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t /* Dissector for HID SET_PROTOCOL request. See USBHID 1.11, Chapter 7.2.6 Set_Protocol Request */ static void -dissect_usb_hid_set_protocol(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *tvb, int offset, gboolean is_request, usb_conv_info_t *usb_conv_info _U_) +dissect_usb_hid_set_protocol(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *tvb, int offset, bool is_request, urb_info_t *urb _U_) { if (!is_request) return; @@ -4599,10 +4658,10 @@ dissect_usb_hid_set_protocol(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t } -typedef void (*usb_setup_dissector)(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, gboolean is_request, usb_conv_info_t *usb_conv_info); +typedef void (*usb_setup_dissector)(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, bool is_request, urb_info_t *urb); typedef struct _usb_setup_dissector_table_t { - guint8 request; + uint8_t request; usb_setup_dissector dissector; } usb_setup_dissector_table_t; @@ -4643,13 +4702,13 @@ static const value_string usb_hid_report_type_vals[] = { { 0, NULL } }; -static gint +static int dissect_usb_hid_boot_keyboard_input_report(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { - gint offset = 0; - gboolean shortcut_helper = FALSE; - guint modifier; - guint keycode; + int offset = 0; + bool shortcut_helper = false; + unsigned modifier; + unsigned keycode; proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_modifier_right_gui, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_modifier_right_alt, tvb, offset, 1, ENC_BIG_ENDIAN); @@ -4659,47 +4718,47 @@ dissect_usb_hid_boot_keyboard_input_report(tvbuff_t *tvb, packet_info *pinfo, pr proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_modifier_left_alt, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_modifier_left_shift, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_modifier_left_ctrl, tvb, offset, 1, ENC_BIG_ENDIAN); - modifier = tvb_get_guint8(tvb, offset); + modifier = tvb_get_uint8(tvb, offset); col_append_str(pinfo->cinfo, COL_INFO, " - "); if (modifier & 0x80) { col_append_str(pinfo->cinfo, COL_INFO, "RIGHT GUI"); - shortcut_helper = TRUE; + shortcut_helper = true; } if (modifier & 0x40) { if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + "); col_append_str(pinfo->cinfo, COL_INFO, "RIGHT ALT"); - shortcut_helper = TRUE; + shortcut_helper = true; } if (modifier & 0x20) { if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + "); col_append_str(pinfo->cinfo, COL_INFO, "RIGHT SHIFT"); - shortcut_helper = TRUE; + shortcut_helper = true; } if (modifier & 0x10) { if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + "); col_append_str(pinfo->cinfo, COL_INFO, "RIGHT CTRL"); - shortcut_helper = TRUE; + shortcut_helper = true; } if (modifier & 0x08) { if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + "); col_append_str(pinfo->cinfo, COL_INFO, "LEFT GUI"); - shortcut_helper = TRUE; + shortcut_helper = true; } if (modifier & 0x04) { if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + "); col_append_str(pinfo->cinfo, COL_INFO, "LEFT ALT"); - shortcut_helper = TRUE; + shortcut_helper = true; } if (modifier & 0x02) { if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + "); col_append_str(pinfo->cinfo, COL_INFO, "LEFT SHIFT"); - shortcut_helper = TRUE; + shortcut_helper = true; } if (modifier & 0x01) { if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + "); col_append_str(pinfo->cinfo, COL_INFO, "LEFT CTRL"); - shortcut_helper = TRUE; + shortcut_helper = true; } offset += 1; @@ -4707,78 +4766,78 @@ dissect_usb_hid_boot_keyboard_input_report(tvbuff_t *tvb, packet_info *pinfo, pr offset += 1; proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_keycode_1, tvb, offset, 1, ENC_BIG_ENDIAN); - keycode = tvb_get_guint8(tvb, offset); + keycode = tvb_get_uint8(tvb, offset); offset += 1; if (keycode) { if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + "); col_append_str(pinfo->cinfo, COL_INFO, val_to_str_ext_const(keycode, &keycode_vals_ext, "Unknown")); - shortcut_helper = TRUE; + shortcut_helper = true; } proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_keycode_2, tvb, offset, 1, ENC_BIG_ENDIAN); - keycode = tvb_get_guint8(tvb, offset); + keycode = tvb_get_uint8(tvb, offset); offset += 1; if (keycode) { if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + "); col_append_str(pinfo->cinfo, COL_INFO, val_to_str_ext_const(keycode, &keycode_vals_ext, "Unknown")); - shortcut_helper = TRUE; + shortcut_helper = true; } proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_keycode_3, tvb, offset, 1, ENC_BIG_ENDIAN); - keycode = tvb_get_guint8(tvb, offset); + keycode = tvb_get_uint8(tvb, offset); offset += 1; if (keycode) { if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + "); col_append_str(pinfo->cinfo, COL_INFO, val_to_str_ext_const(keycode, &keycode_vals_ext, "Unknown")); - shortcut_helper = TRUE; + shortcut_helper = true; } proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_keycode_4, tvb, offset, 1, ENC_BIG_ENDIAN); - keycode = tvb_get_guint8(tvb, offset); + keycode = tvb_get_uint8(tvb, offset); offset += 1; if (keycode) { if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + "); col_append_str(pinfo->cinfo, COL_INFO, val_to_str_ext_const(keycode, &keycode_vals_ext, "Unknown")); - shortcut_helper = TRUE; + shortcut_helper = true; } proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_keycode_5, tvb, offset, 1, ENC_BIG_ENDIAN); - keycode = tvb_get_guint8(tvb, offset); + keycode = tvb_get_uint8(tvb, offset); offset += 1; if (keycode) { if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + "); col_append_str(pinfo->cinfo, COL_INFO, val_to_str_ext_const(keycode, &keycode_vals_ext, "Unknown")); - shortcut_helper = TRUE; + shortcut_helper = true; } proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_keycode_6, tvb, offset, 1, ENC_BIG_ENDIAN); - keycode = tvb_get_guint8(tvb, offset); + keycode = tvb_get_uint8(tvb, offset); offset += 1; if (keycode) { if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + "); col_append_str(pinfo->cinfo, COL_INFO, val_to_str_ext_const(keycode, &keycode_vals_ext, "Unknown")); - shortcut_helper = TRUE; + shortcut_helper = true; } - if (shortcut_helper == FALSE) { + if (shortcut_helper == false) { col_append_str(pinfo->cinfo, COL_INFO, "<action key up>"); } return offset; } -static gint +static int dissect_usb_hid_boot_keyboard_output_report(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { - gint offset = 0; - gboolean shortcut_helper = FALSE; - guint leds; + int offset = 0; + bool shortcut_helper = false; + unsigned leds; proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_leds_constants, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_leds_kana, tvb, offset, 1, ENC_BIG_ENDIAN); @@ -4786,47 +4845,47 @@ dissect_usb_hid_boot_keyboard_output_report(tvbuff_t *tvb, packet_info *pinfo, p proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_leds_scroll_lock, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_leds_caps_lock, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_leds_num_lock, tvb, offset, 1, ENC_BIG_ENDIAN); - leds = tvb_get_guint8(tvb, offset); + leds = tvb_get_uint8(tvb, offset); col_append_str(pinfo->cinfo, COL_INFO, " - LEDs: "); if (leds & 0x01) { col_append_str(pinfo->cinfo, COL_INFO, "NumLock"); - shortcut_helper = TRUE; + shortcut_helper = true; } if (leds & 0x02) { if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, ", "); col_append_str(pinfo->cinfo, COL_INFO, "CapsLock"); - shortcut_helper = TRUE; + shortcut_helper = true; } if (leds & 0x04) { if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, ", "); col_append_str(pinfo->cinfo, COL_INFO, "ScrollLock"); - shortcut_helper = TRUE; + shortcut_helper = true; } if (leds & 0x08) { if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, ", "); col_append_str(pinfo->cinfo, COL_INFO, "Compose"); - shortcut_helper = TRUE; + shortcut_helper = true; } if (leds & 0x10) { if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, ", "); col_append_str(pinfo->cinfo, COL_INFO, "Kana"); - shortcut_helper = TRUE; + shortcut_helper = true; } if (leds & 0x20) { if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, ", "); col_append_str(pinfo->cinfo, COL_INFO, "Constant1"); - shortcut_helper = TRUE; + shortcut_helper = true; } if (leds & 0x40) { if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, ", "); col_append_str(pinfo->cinfo, COL_INFO, "Constant2"); - shortcut_helper = TRUE; + shortcut_helper = true; } if (leds & 0x80) { if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, ", "); col_append_str(pinfo->cinfo, COL_INFO, "Constant3"); - /*shortcut_helper = TRUE;*/ + /*shortcut_helper = true;*/ } if (!leds) { col_append_str(pinfo->cinfo, COL_INFO, "none"); @@ -4837,12 +4896,12 @@ dissect_usb_hid_boot_keyboard_output_report(tvbuff_t *tvb, packet_info *pinfo, p return offset; } -static gint +static int dissect_usb_hid_boot_mouse_input_report(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { - gint offset = 0; - gboolean shortcut_helper = FALSE; - guint buttons; + int offset = 0; + bool shortcut_helper = false; + unsigned buttons; proto_tree_add_item(tree, hf_usbhid_boot_report_mouse_button_8, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(tree, hf_usbhid_boot_report_mouse_button_7, tvb, offset, 1, ENC_BIG_ENDIAN); @@ -4852,18 +4911,18 @@ dissect_usb_hid_boot_mouse_input_report(tvbuff_t *tvb, packet_info *pinfo, proto proto_tree_add_item(tree, hf_usbhid_boot_report_mouse_button_middle, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(tree, hf_usbhid_boot_report_mouse_button_right, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(tree, hf_usbhid_boot_report_mouse_button_left, tvb, offset, 1, ENC_BIG_ENDIAN); - buttons = tvb_get_guint8(tvb, offset); + buttons = tvb_get_uint8(tvb, offset); offset += 1; if (buttons) col_append_str(pinfo->cinfo, COL_INFO, " - "); if (buttons & 0x01) { col_append_str(pinfo->cinfo, COL_INFO, "Button LEFT"); - shortcut_helper = TRUE; + shortcut_helper = true; } if (buttons & 0x02) { if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + "); col_append_str(pinfo->cinfo, COL_INFO, "Button RIGHT"); - shortcut_helper = TRUE; + shortcut_helper = true; } if (buttons & 0x04) { if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + "); @@ -4872,28 +4931,28 @@ dissect_usb_hid_boot_mouse_input_report(tvbuff_t *tvb, packet_info *pinfo, proto if (buttons & 0x08) { if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + "); col_append_str(pinfo->cinfo, COL_INFO, "Button 4"); - shortcut_helper = TRUE; + shortcut_helper = true; } if (buttons & 0x10) { if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + "); col_append_str(pinfo->cinfo, COL_INFO, "Button 5"); - shortcut_helper = TRUE; + shortcut_helper = true; } if (buttons & 0x20) { if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + "); col_append_str(pinfo->cinfo, COL_INFO, "Button 6"); - shortcut_helper = TRUE; + shortcut_helper = true; } if (buttons & 0x40) { if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + "); col_append_str(pinfo->cinfo, COL_INFO, "Button 7"); - shortcut_helper = TRUE; + shortcut_helper = true; } if (buttons & 0x80) { if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + "); col_append_str(pinfo->cinfo, COL_INFO, "Button 8"); /* Not necessary, this is the last case where it is used - * shortcut_helper = TRUE; + * shortcut_helper = true; */ } @@ -4925,27 +4984,27 @@ dissect_usb_hid_boot_mouse_input_report(tvbuff_t *tvb, packet_info *pinfo, proto /* dissect a "standard" control message that's sent to an interface */ -static gint +static int dissect_usb_hid_control_std_intf(tvbuff_t *tvb, packet_info *pinfo, - proto_tree *tree, usb_conv_info_t *usb_conv_info) + proto_tree *tree, urb_info_t *urb) { - gint offset = 0; + int offset = 0; usb_trans_info_t *usb_trans_info; - guint8 req; + uint8_t req; - usb_trans_info = usb_conv_info->usb_trans_info; + usb_trans_info = urb->usb_trans_info; /* XXX - can we do some plausibility checks here? */ col_set_str(pinfo->cinfo, COL_PROTOCOL, "USBHID"); - /* we can't use usb_conv_info->is_request since usb_conv_info + /* we can't use urb->is_request since urb was replaced with the interface conversation */ if (usb_trans_info->request_in == pinfo->num) { /* the tvb that we see here is the setup packet without the request type byte */ - req = tvb_get_guint8(tvb, offset); + req = tvb_get_uint8(tvb, offset); if (req != USB_SETUP_GET_DESCRIPTOR) return offset; col_clear(pinfo->cinfo, COL_INFO); @@ -4953,11 +5012,11 @@ dissect_usb_hid_control_std_intf(tvbuff_t *tvb, packet_info *pinfo, offset += 1; proto_tree_add_item(tree, hf_usb_hid_bDescriptorIndex, tvb, offset, 1, ENC_LITTLE_ENDIAN); - usb_trans_info->u.get_descriptor.usb_index = tvb_get_guint8(tvb, offset); + usb_trans_info->u.get_descriptor.usb_index = tvb_get_uint8(tvb, offset); offset += 1; proto_tree_add_item(tree, hf_usb_hid_bDescriptorType, tvb, offset, 1, ENC_LITTLE_ENDIAN); - usb_trans_info->u.get_descriptor.type = tvb_get_guint8(tvb, offset); + usb_trans_info->u.get_descriptor.type = tvb_get_uint8(tvb, offset); col_append_fstr(pinfo->cinfo, COL_INFO, " %s", val_to_str_ext(usb_trans_info->u.get_descriptor.type, &hid_descriptor_type_vals_ext, "Unknown type %u")); @@ -4976,24 +5035,24 @@ dissect_usb_hid_control_std_intf(tvbuff_t *tvb, packet_info *pinfo, val_to_str_ext(usb_trans_info->u.get_descriptor.type, &hid_descriptor_type_vals_ext, "Unknown type %u")); if (usb_trans_info->u.get_descriptor.type == USB_DT_HID_REPORT) - offset = dissect_usb_hid_get_report_descriptor(pinfo, tree, tvb, offset, usb_conv_info); + offset = dissect_usb_hid_get_report_descriptor(pinfo, tree, tvb, offset, urb); } return offset; } /* dissect a class-specific control message that's sent to an interface */ -static gint +static int dissect_usb_hid_control_class_intf(tvbuff_t *tvb, packet_info *pinfo, - proto_tree *tree, usb_conv_info_t *usb_conv_info) + proto_tree *tree, urb_info_t *urb) { usb_trans_info_t *usb_trans_info; - gboolean is_request; + bool is_request; int offset = 0; usb_setup_dissector dissector = NULL; const usb_setup_dissector_table_t *tmp; - usb_trans_info = usb_conv_info->usb_trans_info; + usb_trans_info = urb->usb_trans_info; is_request = (pinfo->srcport==NO_ENDPOINT); @@ -5021,12 +5080,12 @@ dissect_usb_hid_control_class_intf(tvbuff_t *tvb, packet_info *pinfo, offset += 1; } - dissector(pinfo, tree, tvb, offset, is_request, usb_conv_info); + dissector(pinfo, tree, tvb, offset, is_request, urb); return tvb_captured_length(tvb); } /* unpack a HID logical report field */ -static int hid_unpack_logical(tvbuff_t *tvb, int bit_offset, guint32 size, gint32 min, gint32 *val) +static int hid_unpack_logical(tvbuff_t *tvb, int bit_offset, uint32_t size, int32_t min, int32_t *val) { if (size > 32) return -1; @@ -5039,11 +5098,11 @@ static int hid_unpack_logical(tvbuff_t *tvb, int bit_offset, guint32 size, gint3 return 0; } -static gint +static int dissect_usb_hid_int_dynamic_value_variable(tvbuff_t *tvb, proto_tree *tree, hid_field_t *field, int bit_offset, int hf) { - gint32 val = 0; + int32_t val = 0; if (hid_unpack_logical(tvb, bit_offset, field->report_size, field->logical_min, &val)) return -1; @@ -5053,11 +5112,11 @@ dissect_usb_hid_int_dynamic_value_variable(tvbuff_t *tvb, proto_tree *tree, hid_ } /* dissect the Generic Desktop Controls (0x0001) usage page */ -static gint +static int dissect_usb_hid_generic_desktop_controls_page(tvbuff_t *tvb, packet_info _U_ *pinfo, - proto_tree *tree, hid_field_t *field, guint usage, int bit_offset) + proto_tree *tree, hid_field_t *field, unsigned usage, int bit_offset) { - gint ret = 0; + int ret = 0; DISSECTOR_ASSERT(USAGE_PAGE(usage) == GENERIC_DESKTOP_CONTROLS_PAGE); usage = USAGE_ID(usage); @@ -5128,11 +5187,11 @@ dissect_usb_hid_generic_desktop_controls_page(tvbuff_t *tvb, packet_info _U_ *pi } /* dissect the Keyboard/Keypad (0x0007) usage page */ -static gint +static int dissect_usb_hid_keyboard_page(tvbuff_t *tvb, packet_info _U_ *pinfo, - proto_tree *tree, hid_field_t *field, guint32 usage, int bit_offset) + proto_tree *tree, hid_field_t *field, uint32_t usage, int bit_offset) { - gint32 val = 0; + int32_t val = 0; /* the data is a boolean state for the usage (eg. KEY_SHIFT = 1, KEY_CONTROL = 0) */ if (hid_unpack_logical(tvb, bit_offset, field->report_size, field->logical_min, &val)) @@ -5147,11 +5206,11 @@ dissect_usb_hid_keyboard_page(tvbuff_t *tvb, packet_info _U_ *pinfo, } /* dissect the Button (0x0009) usage page */ -static gint +static int dissect_usb_hid_button_page(tvbuff_t *tvb, packet_info _U_ *pinfo, - proto_tree *tree, hid_field_t *field, guint32 usage, int bit_offset) + proto_tree *tree, hid_field_t *field, uint32_t usage, int bit_offset) { - gint32 val = 0; + int32_t val = 0; proto_item *ti; DISSECTOR_ASSERT(USAGE_PAGE(usage) == BUTTON_PAGE); @@ -5177,9 +5236,9 @@ dissect_usb_hid_button_page(tvbuff_t *tvb, packet_info _U_ *pinfo, static void dissect_hid_variable(tvbuff_t* tvb, packet_info _U_* pinfo, proto_tree* tree, hid_field_t* field, - guint32 usage, int bit_offset) + uint32_t usage, int bit_offset) { - gint ret = 0; + int ret = 0; /* vendor data (0xff00 - 0xffff) */ if ((USAGE_PAGE(usage) & 0xff00) == 0xff00) { @@ -5207,7 +5266,7 @@ dissect_hid_variable(tvbuff_t* tvb, packet_info _U_* pinfo, proto_tree* tree, hi } if (ret) { - guint32 val = 0; + uint32_t val = 0; proto_item *ti = proto_tree_add_uint_bits_format_value(tree, hf_usb_hid_localitem_usage, tvb, bit_offset, field->report_size, usage, ENC_LITTLE_ENDIAN, "%s", get_usage_page_item_string(pinfo->pool, USAGE_PAGE(usage), USAGE_ID(usage))); @@ -5216,22 +5275,22 @@ dissect_hid_variable(tvbuff_t* tvb, packet_info _U_* pinfo, proto_tree* tree, hi } } -static gboolean hid_get_usage_from_array(hid_field_t *field, gint32 idx, guint32 *out) +static bool hid_get_usage_from_array(hid_field_t *field, int32_t idx, uint32_t *out) { if ((idx >= field->logical_min) && (idx <= field->logical_max)) { idx -= field->logical_min; - if ((guint32)idx < wmem_array_get_count(field->usages)) { - *out = (*((guint32*) wmem_array_index(field->usages, idx))); - return TRUE; + if ((uint32_t)idx < wmem_array_get_count(field->usages)) { + *out = (*((uint32_t*) wmem_array_index(field->usages, idx))); + return true; } } - return FALSE; + return false; } -static gint +static int dissect_hid_field(tvbuff_t *tvb, packet_info _U_ *pinfo, proto_tree *tree, hid_field_t *field, int bit_offset) { - gint start_offset = bit_offset; + int start_offset = bit_offset; if ((field->properties & HID_MAIN_TYPE) == HID_MAIN_ARRAY) { proto_item *array_ti; @@ -5242,10 +5301,10 @@ dissect_hid_field(tvbuff_t *tvb, packet_info _U_ *pinfo, proto_tree *tree, hid_f array_tree = proto_item_add_subtree(array_ti, ett_usb_hid_array); for(unsigned int j = 0; j < field->report_count; j++) { - guint32 val = 0; - gboolean in_range; + uint32_t val = 0; + bool in_range; if (hid_unpack_logical(tvb, bit_offset, field->report_size, field->logical_min, &val)) { - in_range = FALSE; + in_range = false; } else { in_range = hid_get_usage_from_array(field, val, &val); } @@ -5266,12 +5325,12 @@ dissect_hid_field(tvbuff_t *tvb, packet_info _U_ *pinfo, proto_tree *tree, hid_f count = field->report_count; } for(i = 0; i < count; i++) { - guint32 usage = *((guint32*) wmem_array_index(field->usages, i)); + uint32_t usage = *((uint32_t*) wmem_array_index(field->usages, i)); dissect_hid_variable(tvb, pinfo, tree, field, usage, bit_offset); bit_offset += field->report_size; } if (field->report_count > count) { - gint remaining_bits = (field->report_count - count) * field->report_size; + int remaining_bits = (field->report_count - count) * field->report_size; proto_tree_add_bits_item(tree, hf_usbhid_padding, tvb, bit_offset, remaining_bits, ENC_LITTLE_ENDIAN); bit_offset += remaining_bits; } @@ -5281,23 +5340,23 @@ dissect_hid_field(tvbuff_t *tvb, packet_info _U_ *pinfo, proto_tree *tree, hid_f } /* Dissect USB HID data/reports */ -static gint +static int dissect_usb_hid_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) { - guint offset = 0, hid_bit_offset; + unsigned offset = 0, hid_bit_offset; proto_item *hid_ti; proto_tree *hid_tree; wmem_array_t *fields; - usb_conv_info_t *usb_data = (usb_conv_info_t*) data; + urb_info_t *usb_data = (urb_info_t*) data; report_descriptor_t *rdesc = get_report_descriptor(pinfo, usb_data); - guint remaining = tvb_reported_length_remaining(tvb, offset); + unsigned remaining = tvb_reported_length_remaining(tvb, offset); if (remaining) { hid_ti = proto_tree_add_item(tree, hf_usbhid_data, tvb, offset, -1, ENC_NA); hid_tree = proto_item_add_subtree(hid_ti, ett_usb_hid_data); hid_bit_offset = offset * 8; offset += remaining; - guint8 report_id = tvb_get_bits8(tvb, hid_bit_offset, 8); + uint8_t report_id = tvb_get_bits8(tvb, hid_bit_offset, 8); if (rdesc) { if (rdesc->uses_report_id) { @@ -5336,17 +5395,17 @@ dissect_usb_hid_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void * /* Dissector for HID class-specific control request as defined in * USBHID 1.11, Chapter 7.2. * returns the number of bytes consumed */ -static gint +static int dissect_usb_hid_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) { - usb_conv_info_t *usb_conv_info; + urb_info_t *urb; usb_trans_info_t *usb_trans_info; - guint8 type, recip; + uint8_t type, recip; - usb_conv_info = (usb_conv_info_t *)data; - if (!usb_conv_info) + urb = (urb_info_t *)data; + if (!urb) return 0; - usb_trans_info = usb_conv_info->usb_trans_info; + usb_trans_info = urb->usb_trans_info; if (!usb_trans_info) return 0; @@ -5355,27 +5414,27 @@ dissect_usb_hid_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi if (recip == RQT_SETUP_RECIPIENT_INTERFACE) { if (type == RQT_SETUP_TYPE_STANDARD) - return dissect_usb_hid_control_std_intf(tvb, pinfo, tree, usb_conv_info); + return dissect_usb_hid_control_std_intf(tvb, pinfo, tree, urb); else if (type == RQT_SETUP_TYPE_CLASS) - return dissect_usb_hid_control_class_intf(tvb, pinfo, tree, usb_conv_info); + return dissect_usb_hid_control_class_intf(tvb, pinfo, tree, urb); } return dissect_usb_hid_data(tvb, pinfo, tree, data); } /* dissect a descriptor that is specific to the HID class */ -static gint +static int dissect_usb_hid_class_descriptors(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_) { - guint8 type; - gint offset = 0; + uint8_t type; + int offset = 0; proto_item *ti; proto_tree *desc_tree; - guint8 num_desc; - guint i; + uint8_t num_desc; + unsigned i; - type = tvb_get_guint8(tvb, 1); + type = tvb_get_uint8(tvb, 1); /* for now, we only handle the HID descriptor here */ if (type != USB_DT_HID) @@ -5389,7 +5448,7 @@ dissect_usb_hid_class_descriptors(tvbuff_t *tvb, packet_info *pinfo _U_, offset += 2; proto_tree_add_item(desc_tree, hf_usb_hid_bCountryCode, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset++; - num_desc = tvb_get_guint8(tvb, offset); + num_desc = tvb_get_uint8(tvb, offset); proto_tree_add_item(desc_tree, hf_usb_hid_bNumDescriptors, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset++; for (i=0;i<num_desc;i++) { @@ -5879,11 +5938,11 @@ proto_register_usb_hid(void) NULL, 0x00, NULL, HFILL }}, { &hf_usbhid_button, - { "Button", "usbhid.data.button", FT_BOOLEAN, 1, + { "Button", "usbhid.data.button", FT_BOOLEAN, BASE_NONE, NULL, 0x00, NULL, HFILL }}, { &hf_usbhid_key, - { "Key", "usbhid.data.key.variable", FT_BOOLEAN, 1, + { "Key", "usbhid.data.key.variable", FT_BOOLEAN, BASE_NONE, NULL, 0x00, NULL, HFILL }}, { &hf_usbhid_array, @@ -5891,11 +5950,11 @@ proto_register_usb_hid(void) NULL, 0x00, NULL, HFILL }}, { &hf_usbhid_array_usage, - { "Usage", "usbhid.data.array.usage", FT_BOOLEAN, 1, + { "Usage", "usbhid.data.array.usage", FT_BOOLEAN, BASE_NONE, NULL, 0x00, NULL, HFILL }}, }; - static gint *usb_hid_subtrees[] = { + static int *usb_hid_subtrees[] = { &ett_usb_hid_report, &ett_usb_hid_item_header, &ett_usb_hid_wValue, |