register a dissector for HID class specific descriptors
authorMartin Kaiser <wireshark@kaiser.cx>
Tue, 27 Aug 2013 07:40:50 +0000 (07:40 -0000)
committerMartin Kaiser <wireshark@kaiser.cx>
Tue, 27 Aug 2013 07:40:50 +0000 (07:40 -0000)
start dissecting the HID descriptor

svn path=/trunk/; revision=51528

epan/dissectors/packet-usb-hid.c
epan/dissectors/packet-usb-hid.h
epan/dissectors/packet-usb.c

index 15f9f99699a4dd33915fa7716e9096d49bfa3c81..b5189ab47638a91c8396b4795556f907c3cfe4ae 100644 (file)
@@ -86,6 +86,7 @@ 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 int hf_usb_hid_request = -1;
 static int hf_usb_hid_value = -1;
@@ -797,6 +798,31 @@ dissect_usb_hid_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi
     return TRUE;
 }
 
+
+static gint
+dissect_usb_hid_descriptors(tvbuff_t *tvb, packet_info *pinfo _U_,
+        proto_tree *tree, void *data _U_)
+{
+    guint8      type;
+    proto_item *ti;
+    proto_tree *desc_tree;
+
+    type = tvb_get_guint8(tvb, 1);
+
+    /* for now, we only handle the HID descriptor here */
+    if (type != USB_DT_HID)
+        return 0;
+
+    ti = proto_tree_add_text(tree,
+            tvb, 0, tvb_reported_length(tvb), "HID DESCRIPTOR");
+    desc_tree = proto_item_add_subtree(ti, ett_usb_hid_descriptor);
+
+    dissect_usb_descriptor_header(desc_tree, tvb, 0);
+
+    return tvb_reported_length(tvb);
+}
+
+
 void
 proto_register_usb_hid(void)
 {
@@ -1041,7 +1067,8 @@ proto_register_usb_hid(void)
     static gint *usb_hid_subtrees[] = {
         &ett_usb_hid_report,
         &ett_usb_hid_item_header,
-        &ett_usb_hid_wValue
+        &ett_usb_hid_wValue,
+        &ett_usb_hid_descriptor
     };
 
     proto_usb_hid = proto_register_protocol("USB HID", "USBHID", "usbhid");
@@ -1051,10 +1078,13 @@ proto_register_usb_hid(void)
 
 void
 proto_reg_handoff_usb_hid(void) {
-    dissector_handle_t usb_hid_control_handle;
+    dissector_handle_t usb_hid_control_handle, usb_hid_descr_handle;
 
     usb_hid_control_handle = new_create_dissector_handle(dissect_usb_hid_control, proto_usb_hid);
     dissector_add_uint("usb.control", IF_CLASS_HID, usb_hid_control_handle);
+
+    usb_hid_descr_handle = new_create_dissector_handle(dissect_usb_hid_descriptors, proto_usb_hid);
+    dissector_add_uint("usb.descriptor", IF_CLASS_HID, usb_hid_descr_handle);
 }
 
 /*
index b7c0fde24956e4be5c61a5274fbc7198e7862c15..c25940f5796811e5ab41f032c1bbedef85fcc30b 100644 (file)
@@ -23,6 +23,9 @@
 #ifndef __PACKET_USB_HID_H__
 #define __PACKET_USB_HID_H__
 
+/* HID class specific descriptor types */
+#define USB_DT_HID 33
+
 int
 dissect_usb_hid_get_report_descriptor(packet_info *pinfo _U_, proto_tree *parent_tree, tvbuff_t *tvb, int offset, usb_trans_info_t *usb_trans_info _U_, usb_conv_info_t *usb_conv_info _U_);
 
index ad3abd895c517c266172ad146d7369895ab71f2b..6fad0be1465ebc014d1271c6538ff6fb77ff2213 100644 (file)
@@ -500,7 +500,6 @@ extern value_string_ext ext_usb_products_vals;
 #define USB_DT_BOS                            15
 #define USB_DT_DEVICE_CAPABILITY              16
 #define USB_DT_WIRELESS_ENDPOINT_COMP         17
-#define USB_DT_HID                            33
 #define USB_DT_RPIPE                          34
 #define USB_DT_SUPERSPEED_ENDPOINT_COMPANION  48