btatt: Call btatt.handle subdissectors

The BT ATT protocol dissector has a dissector table for the
`btatt.handle` field so that is is possible to register subdissectors.
But registrating the subdissector via `btatt.handle` field has no
effect. Instead, it has to be registered via `bluetooth.uuid` field.

In some cases, the BT ATT dissector doesn't call its subdissectors when
it is registered via `bluetooth.uuid` field: It is when no frame
connects the BT UUID to the handle.

This fix now calls the registered subdissector of the `btatt.handle`
field if any.

As an improvement, duplicate code could be removed for BT GATT
subdissectors because dissect_btgatt() extracts already the UUID from
the short name and then calls dissect_attribute_value().

The BT GATT subdissectors will be shown as subtree as before because its
implementation is in the same file. All other subdissectors will get its
own root tree as it is common for new protocol layers.

Bug: 16371
Change-Id: I99393e51e949a6488014f175c09a44743ce353a2
Reviewed-on: https://code.wireshark.org/review/36176
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Angelos Drossos 2020-02-25 01:49:26 +01:00 committed by Anders Broman
parent d398471cb5
commit 27dc3d1481
1 changed files with 12 additions and 19 deletions

View File

@ -10505,10 +10505,6 @@ dissect_attribute_value(proto_tree *tree, proto_item *patron_item, packet_info *
static gint
btatt_dissect_attribute_handle(guint16 handle, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, btatt_data_t *att_data)
{
proto_item *main_item;
proto_tree *main_tree;
proto_item *patron_item = NULL;
bluetooth_uuid_t uuid;
dissector_handle_t attribute_handler;
const char* attribute_name;
@ -10516,23 +10512,18 @@ btatt_dissect_attribute_handle(guint16 handle, tvbuff_t *tvb, packet_info *pinfo
if (attribute_handler == NULL)
return 0;
main_item = proto_tree_add_item(tree, dissector_handle_get_protocol_index(attribute_handler), tvb, 0, tvb_captured_length(tvb), ENC_NA);
main_tree = proto_item_add_subtree(main_item, ett_btgatt);
attribute_name = dissector_handle_get_dissector_name(attribute_handler); /* abbrev */
DISSECTOR_ASSERT(attribute_name);
attribute_name = dissector_handle_get_short_name(attribute_handler);
if (strlen(attribute_name) > 7) {
uuid.size = 2;
uuid.bt_uuid = (guint16) g_ascii_strtoull(attribute_name + strlen(attribute_name) - 7, NULL, 16);
uuid.data[1] = uuid.bt_uuid & 0xFF;
uuid.data[0] = (uuid.bt_uuid >> 8) & 0xFF;
} else {
uuid.size = 2;
uuid.bt_uuid = 0;
}
return dissect_attribute_value(main_tree, patron_item, pinfo, tvb,
0, tvb_captured_length(tvb), 0, uuid, att_data);
/* For all registered subdissectors except BT GATT subdissectors, retrieve root tree. */
if (0 != strncmp(attribute_name, "btgatt", 6))
tree = proto_tree_get_parent_tree(tree);
/* Note for BT GATT subdissectors:
* It will implicitly call dissect_btgatt() which retrieves the BT UUID
* from its protocol name and then calls dissect_attribute_value().
*/
return dissector_try_uint_new(att_handle_dissector_table, handle, tvb, pinfo, tree, TRUE, att_data);
}
static int
@ -10554,6 +10545,8 @@ dissect_btgatt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
} else {
uuid.size = 2;
uuid.bt_uuid = 0;
uuid.data[1] = 0;
uuid.data[0] = 0;
}
return dissect_attribute_value(main_tree, patron_item, pinfo, tvb,