aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Quantin <pascal.quantin@gmail.com>2014-08-26 12:05:49 +0200
committerPascal Quantin <pascal.quantin@gmail.com>2014-08-26 12:09:12 +0000
commitff59722529bd3f9acbe6a234375dea59def2b48e (patch)
treea57e610d5cd573bf0ae456d702b861a451963d16
parent7836a714ab31791fdde46492154ba559a7103a8b (diff)
USB: get rid of the remaining proto_tree_add_text instances
Change-Id: I6acaa32745e32ec5728874549e420468499d9b24 Reviewed-on: https://code.wireshark.org/review/3860 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
-rw-r--r--epan/dissectors/packet-usb.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/epan/dissectors/packet-usb.c b/epan/dissectors/packet-usb.c
index 5a63a06623..05b2aeb731 100644
--- a/epan/dissectors/packet-usb.c
+++ b/epan/dissectors/packet-usb.c
@@ -113,6 +113,7 @@ static int hf_usb_bmRequestType_direction = -1;
static int hf_usb_bmRequestType_type = -1;
static int hf_usb_bmRequestType_recipient = -1;
static int hf_usb_bDescriptorType = -1;
+static int hf_usb_get_descriptor_resp_generic = -1;
static int hf_usb_descriptor_index = -1;
static int hf_usb_language_id = -1;
static int hf_usb_bLength = -1;
@@ -2079,10 +2080,14 @@ dissect_usb_setup_get_descriptor_response(packet_info *pinfo, proto_tree *tree,
/* else fall through as default/unknown */
default:
/* XXX dissect the descriptor coming back from the device */
- proto_tree_add_text(tree, tvb, offset, -1,
- "GET DESCRIPTOR data (unknown descriptor type %u)",
- usb_trans_info->u.get_descriptor.type);
- offset = tvb_reported_length(tvb);
+ {
+ guint len = tvb_reported_length_remaining(tvb, offset);
+ proto_tree_add_bytes_format(tree, hf_usb_get_descriptor_resp_generic, tvb, offset, len, NULL,
+ "GET DESCRIPTOR Response data (unknown descriptor type %u): %s",
+ usb_trans_info->u.get_descriptor.type,
+ tvb_bytes_to_ep_str(tvb, offset, len));
+ offset = offset + len;
+ }
break;
}
@@ -2524,9 +2529,11 @@ dissect_usb_standard_setup_response(packet_info *pinfo, proto_tree *tree,
if (dissector) {
offset = dissector(pinfo, tree, tvb, offset, usb_conv_info);
} else {
- if (tvb_reported_length_remaining(tvb, offset) != 0) {
- proto_tree_add_text(tree, tvb, offset, -1, "CONTROL response data");
- offset += tvb_reported_length_remaining(tvb, offset);
+ gint length_remaining = tvb_reported_length_remaining(tvb, offset);
+ if (length_remaining > 0) {
+ proto_tree_add_item(tree, hf_usb_control_response_generic,
+ tvb, offset, length_remaining, ENC_NA);
+ offset += length_remaining;
}
}
@@ -3893,6 +3900,12 @@ proto_register_usb(void)
FT_UINT8, BASE_HEX, NULL, 0x0,
NULL, HFILL }},
+ /* Only used when descriptor type cannot be determined */
+ { &hf_usb_get_descriptor_resp_generic,
+ { "GET DESCRIPTOR Response data", "usb.getDescriptor.Response",
+ FT_BYTES, BASE_NONE, NULL, 0x0,
+ NULL, HFILL }},
+
{ &hf_usb_descriptor_index,
{ "Descriptor Index", "usb.DescriptorIndex",
FT_UINT8, BASE_HEX, NULL, 0x0,