diff options
author | Sean O. Stalley <sean.stalley@intel.com> | 2014-06-04 16:41:41 -0700 |
---|---|---|
committer | Alexis La Goutte <alexis.lagoutte@gmail.com> | 2014-06-05 05:47:37 +0000 |
commit | c49fcec9a669a7808fa913745bb6619c7223378f (patch) | |
tree | aa8347433820832ada54a5c1692cf19ab4b63b8e /epan | |
parent | 5c03010926f4e793fd0575e4d91f865535395a9c (diff) | |
download | wireshark-c49fcec9a669a7808fa913745bb6619c7223378f.tar.gz |
Moved dissection of standard setup responses to own function
Standard USB setup responses are now handled by a seperate function.
Before, dissection was handled in the dissect_usb_common().
This is part of an effort to make dissect_usb_common() more modular
so that code can be shared between the USB & the MAUSB dissector.
Change-Id: Ibfbcd915d8cef881a6ae0f0312e5a8070984f465
Reviewed-on: https://code.wireshark.org/review/1968
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Diffstat (limited to 'epan')
-rw-r--r-- | epan/dissectors/packet-usb.c | 64 |
1 files changed, 38 insertions, 26 deletions
diff --git a/epan/dissectors/packet-usb.c b/epan/dissectors/packet-usb.c index d8707c712a..f455947fd0 100644 --- a/epan/dissectors/packet-usb.c +++ b/epan/dissectors/packet-usb.c @@ -2426,6 +2426,41 @@ dissect_usb_standard_setup_request(packet_info *pinfo, proto_tree *tree , } +/* Dissector used for standard usb setup responses */ +static int +dissect_usb_standard_setup_response(packet_info *pinfo, proto_tree *tree, + tvbuff_t *tvb, int offset, + usb_conv_info_t *usb_conv_info) +{ + const usb_setup_dissector_table_t *tmp; + usb_setup_dissector dissector; + + + col_add_fstr(pinfo->cinfo, COL_INFO, "%s Response", + val_to_str_ext(usb_conv_info->usb_trans_info->setup.request, + &setup_request_names_vals_ext, "Unknown type %x")); + + dissector = NULL; + for(tmp = setup_response_dissectors;tmp->dissector;tmp++) { + if (tmp->request == usb_conv_info->usb_trans_info->setup.request) { + dissector = tmp->dissector; + break; + } + } + + 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_length_remaining(tvb, offset); + } + } + + return offset; +} + + static gint try_dissect_next_protocol(proto_tree *tree, proto_tree *parent, tvbuff_t *next_tvb, gint offset, packet_info *pinfo, usb_conv_info_t *usb_conv_info, gint type_2, guint8 urb_type, @@ -2935,8 +2970,6 @@ dissect_usb_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent, case URB_CONTROL: { - const usb_setup_dissector_table_t *tmp; - usb_setup_dissector dissector; proto_item *ti = NULL; proto_tree *setup_tree = NULL; @@ -3055,30 +3088,9 @@ dissect_usb_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent, switch (type_2) { case RQT_SETUP_TYPE_STANDARD: - /* - * This is a standard response which is managed by this - * dissector - */ - col_add_fstr(pinfo->cinfo, COL_INFO, "%s Response", - val_to_str_ext(usb_conv_info->usb_trans_info->setup.request, - &setup_request_names_vals_ext, "Unknown type %x")); - - dissector = NULL; - for(tmp = setup_response_dissectors;tmp->dissector;tmp++) { - if (tmp->request == usb_conv_info->usb_trans_info->setup.request) { - dissector = tmp->dissector; - break; - } - } - - if (dissector) { - offset = dissector(pinfo, parent, tvb, offset, usb_conv_info); - } else { - if (tvb_reported_length_remaining(tvb, offset) != 0) { - proto_tree_add_text(parent, tvb, offset, -1, "CONTROL response data"); - offset += tvb_length_remaining(tvb, offset); - } - } + /* This is a standard response */ + offset = dissect_usb_standard_setup_response(pinfo, parent, tvb, + offset, usb_conv_info); break; default: /* Try to find a non-standard specific dissector */ |