diff options
author | guy <guy@f5534014-38df-0310-8fa8-9805f1628bb7> | 2008-12-17 09:47:43 +0000 |
---|---|---|
committer | guy <guy@f5534014-38df-0310-8fa8-9805f1628bb7> | 2008-12-17 09:47:43 +0000 |
commit | f3b898a637c29c67a29b6d34aa4422acc3cf4cba (patch) | |
tree | 659914a4b8df10cc06928967b34b50b105a03281 /epan/dissectors/packet-usb.c | |
parent | 14a0da693c75309acf9a9a53dac32c568e155f1d (diff) |
Define all the standard request code values from the USB 2.0 spec, and
put them into the setup_request_names_vals value_string.
When processing a response, use the request type value, so we only
dissect standard replies when it's a reply to a standard request.
Display the bRequest value in decimal, as that's how they're specified
in the USB 2.0 spec.
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@27033 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'epan/dissectors/packet-usb.c')
-rw-r--r-- | epan/dissectors/packet-usb.c | 65 |
1 files changed, 47 insertions, 18 deletions
diff --git a/epan/dissectors/packet-usb.c b/epan/dissectors/packet-usb.c index 82ef964993..aedf8d0730 100644 --- a/epan/dissectors/packet-usb.c +++ b/epan/dissectors/packet-usb.c @@ -1133,13 +1133,33 @@ typedef struct _usb_setup_dissector_table_t { guint8 request; usb_setup_dissector dissector; } usb_setup_dissector_table_t; +#define USB_SETUP_GET_STATUS 0 +#define USB_SETUP_CLEAR_FEATURE 1 +#define USB_SETUP_SET_FEATURE 2 +#define USB_SETUP_SET_ADDRESS 5 #define USB_SETUP_GET_DESCRIPTOR 6 +#define USB_SETUP_SET_DESCRIPTOR 7 +#define USB_SETUP_GET_CONFIGURATION 8 +#define USB_SETUP_SET_CONFIGURATION 9 +#define USB_SETUP_GET_INTERFACE 10 +#define USB_SETUP_SET_INTERFACE 11 +#define USB_SETUP_SYNCH_FRAME 12 static const usb_setup_dissector_table_t setup_dissectors[] = { {USB_SETUP_GET_DESCRIPTOR, dissect_usb_setup_get_descriptor}, {0, NULL} }; static const value_string setup_request_names_vals[] = { + {USB_SETUP_GET_STATUS, "GET STATUS"}, + {USB_SETUP_CLEAR_FEATURE, "CLEAR FEATURE"}, + {USB_SETUP_SET_FEATURE, "SET FEATURE"}, + {USB_SETUP_SET_ADDRESS, "SET ADDRESS"}, {USB_SETUP_GET_DESCRIPTOR, "GET DESCRIPTOR"}, + {USB_SETUP_SET_DESCRIPTOR, "SET DESCRIPTOR"}, + {USB_SETUP_GET_CONFIGURATION, "GET CONFIGURATION"}, + {USB_SETUP_SET_CONFIGURATION, "SET CONFIGURATION"}, + {USB_SETUP_GET_INTERFACE, "GET INTERFACE"}, + {USB_SETUP_SET_INTERFACE, "SET INTERFACE"}, + {USB_SETUP_SYNCH_FRAME, "SYNCH FRAME"}, {0, NULL} }; @@ -1558,32 +1578,41 @@ dissect_linux_usb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent) tvbuff_t *next_tvb; /* this is a response */ - if(usb_conv_info->usb_trans_info){ + if(usb_trans_info){ /* Try to find a class specific dissector */ next_tvb=tvb_new_subset(tvb, offset, -1, -1); if(dissector_try_port(usb_control_dissector_table, usb_conv_info->interfaceClass, next_tvb, pinfo, tree)){ return; } - if (check_col(pinfo->cinfo, COL_INFO)) { - col_clear(pinfo->cinfo, COL_INFO); - col_append_fstr(pinfo->cinfo, COL_INFO, "%s Response", - val_to_str(usb_conv_info->usb_trans_info->request, setup_request_names_vals, "Unknown type %x")); - } + type = (usb_trans_info->requesttype & USB_TYPE_MASK) >>5; + switch (type) { - dissector=NULL; - for(tmp=setup_dissectors;tmp->dissector;tmp++){ - if(tmp->request==usb_conv_info->usb_trans_info->request){ - dissector=tmp->dissector; - break; + case RQT_SETUP_TYPE_STANDARD: + /* + * This is a standard reply which is managed by this + * dissector + */ + if (check_col(pinfo->cinfo, COL_INFO)) { + col_clear(pinfo->cinfo, COL_INFO); + col_append_fstr(pinfo->cinfo, COL_INFO, "%s Response", + val_to_str(usb_conv_info->usb_trans_info->request, setup_request_names_vals, "Unknown type %x")); } - } - if(dissector){ - offset = dissector(pinfo, tree, tvb, offset, is_request, usb_conv_info->usb_trans_info, usb_conv_info); - } else { - proto_tree_add_text(tree, tvb, offset, -1, "CONTROL response data"); - offset += tvb_length_remaining(tvb, offset); + dissector=NULL; + for(tmp=setup_dissectors;tmp->dissector;tmp++){ + if(tmp->request==usb_conv_info->usb_trans_info->request){ + dissector=tmp->dissector; + break; + } + } + + if(dissector){ + offset = dissector(pinfo, tree, tvb, offset, is_request, usb_conv_info->usb_trans_info, usb_conv_info); + } else { + proto_tree_add_text(tree, tvb, offset, -1, "CONTROL response data"); + offset += tvb_length_remaining(tvb, offset); + } } } else { /* no matching request available */ @@ -1699,7 +1728,7 @@ proto_register_usb(void) "", HFILL }}, { &hf_usb_request, - { "bRequest", "usb.setup.bRequest", FT_UINT8, BASE_HEX, VALS(setup_request_names_vals), 0x0, + { "bRequest", "usb.setup.bRequest", FT_UINT8, BASE_DEC, VALS(setup_request_names_vals), 0x0, "", HFILL }}, { &hf_usb_value, |