diff options
author | Martin Kaiser <wireshark@kaiser.cx> | 2014-08-18 14:56:52 +0200 |
---|---|---|
committer | Martin Kaiser <wireshark@kaiser.cx> | 2014-08-19 20:21:05 +0000 |
commit | d6775dc40ef59bd897b75bcc007dfdfe0e21c104 (patch) | |
tree | 601c08111f511f6000bd9c083eae25122700f526 /epan/dissectors/packet-usb-audio.c | |
parent | 119406192fcd909ae92a8d662ae1096eb9558019 (diff) |
Revert "Revert "create audio-specific part of the usb conversation""
This reverts commit 22e10bea0cbd2b29d6e7b82a3ead3910d71988a2.
Now that the fuzz failures are fixed, we can re-enable the
audio-specific extensions.
Change-Id: Id788e10aaa3dbf289df364f7da9ef01e24ba47f9
Reviewed-on: https://code.wireshark.org/review/3728
Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
Tested-by: Martin Kaiser <wireshark@kaiser.cx>
Diffstat (limited to 'epan/dissectors/packet-usb-audio.c')
-rw-r--r-- | epan/dissectors/packet-usb-audio.c | 62 |
1 files changed, 59 insertions, 3 deletions
diff --git a/epan/dissectors/packet-usb-audio.c b/epan/dissectors/packet-usb-audio.c index 7ce684a1bb..9bee878197 100644 --- a/epan/dissectors/packet-usb-audio.c +++ b/epan/dissectors/packet-usb-audio.c @@ -48,6 +48,9 @@ static int hf_ac_if_hdr_total_len = -1; static int hf_ac_if_hdr_bInCollection = -1; static int hf_ac_if_hdr_if_num = -1; static int hf_as_if_desc_subtype = -1; +static int hf_as_if_gen_term_id = -1; +static int hf_as_if_gen_delay = -1; +static int hf_as_if_gen_format = -1; static int hf_as_ep_desc_subtype = -1; static reassembly_table midi_data_reassembly_table; @@ -136,6 +139,11 @@ static const value_string as_subtype_vals[] = { static value_string_ext as_subtype_vals_ext = VALUE_STRING_EXT_INIT(as_subtype_vals); +typedef struct _audio_conv_info_t { + /* the major version of the USB audio class specification, + taken from the AC header descriptor */ + guint8 ver_major; +} audio_conv_info_t; static int hf_sysex_msg_fragments = -1; static int hf_sysex_msg_fragment = -1; @@ -294,13 +302,14 @@ dissect_usb_midi_event(tvbuff_t *tvb, packet_info *pinfo, body's length) */ static gint dissect_ac_if_hdr_body(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_, - proto_tree *tree, usb_conv_info_t *usb_conv_info _U_) + proto_tree *tree, usb_conv_info_t *usb_conv_info) { gint offset_start; guint16 bcdADC; guint8 ver_major; double ver; guint8 if_in_collection, i; + audio_conv_info_t *audio_conv_info; offset_start = offset; @@ -311,8 +320,14 @@ dissect_ac_if_hdr_body(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_, proto_tree_add_double_format_value(tree, hf_ac_if_hdr_ver, tvb, offset, 2, ver, "%2.2f", ver); - /* XXX - create an audio-specific conversation struct, - store the major version there */ + audio_conv_info = (audio_conv_info_t *)usb_conv_info->class_data; + if(!audio_conv_info) { + audio_conv_info = wmem_new(wmem_file_scope(), audio_conv_info_t); + usb_conv_info->class_data = audio_conv_info; + /* XXX - set reasonable default values for all components + that are not filled in by this function */ + } + audio_conv_info->ver_major = ver_major; offset += 2; /* version 1 refers to the Basic Audio Device specification, @@ -338,6 +353,36 @@ dissect_ac_if_hdr_body(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_, static gint +dissect_as_if_general_body(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_, + proto_tree *tree, usb_conv_info_t *usb_conv_info) +{ + audio_conv_info_t *audio_conv_info; + gint offset_start; + + /* the caller has already checked that usb_conv_info!=NULL */ + audio_conv_info = (audio_conv_info_t *)usb_conv_info->class_data; + if (!audio_conv_info) + return 0; + + offset_start = offset; + + if (audio_conv_info->ver_major==1) { + proto_tree_add_item(tree, hf_as_if_gen_term_id, + tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset++; + proto_tree_add_item(tree, hf_as_if_gen_delay, + tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset++; + proto_tree_add_item(tree, hf_as_if_gen_format, + tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += 2; + } + + return offset-offset_start; +} + + +static gint dissect_usb_audio_descriptor(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) { @@ -410,6 +455,8 @@ dissect_usb_audio_descriptor(tvbuff_t *tvb, packet_info *pinfo, switch(desc_subtype) { case AS_SUBTYPE_GENERAL: + dissect_as_if_general_body(tvb, offset, pinfo, + desc_tree, usb_conv_info); break; default: break; @@ -521,6 +568,15 @@ proto_register_usb_audio(void) { &hf_as_if_desc_subtype, { "Subtype", "usbaudio.as_if_subtype", FT_UINT8, BASE_HEX|BASE_EXT_STRING, &as_subtype_vals_ext, 0x00, "bDescriptorSubtype", HFILL }}, + { &hf_as_if_gen_term_id, + { "Terminal ID", "usbaudio.as_if_gen.bTerminalLink", + FT_UINT8, BASE_DEC, NULL, 0x00, "bTerminalLink", HFILL }}, + { &hf_as_if_gen_delay, + { "Interface delay in frames", "usbaudio.as_if_gen.bDelay", + FT_UINT8, BASE_DEC, NULL, 0x00, "bDelay", HFILL }}, + { &hf_as_if_gen_format, + { "Format", "usbaudio.as_if_gen.wFormatTag", + FT_UINT16, BASE_HEX, NULL, 0x00, "wFormatTag", HFILL }}, { &hf_as_ep_desc_subtype, { "Subtype", "usbaudio.as_ep_subtype", FT_UINT8, BASE_HEX, NULL, 0x00, "bDescriptorSubtype", HFILL }}, |