From 7102a06811ab63e0433ac91ad242e02c5668d259 Mon Sep 17 00:00:00 2001 From: Michal Labedzki Date: Wed, 13 May 2015 17:33:28 +0200 Subject: [PATCH] Qt/Bluetooth: Add Devices dialogue Please found it under Bluetooth menu. It shows all devices found in logs, not only connected, all that its address can be found in logs. Show if device is local (in most cases: capturing on it side) and manufacturer and LMP version what should answer the question what version of Bluetooth is used by Bluetooth device chip. Also firmware version. Change-Id: I32e3b7100cdebcaa850b6541de0ab89dff41c0e1 Reviewed-on: https://code.wireshark.org/review/8901 Petri-Dish: Michal Labedzki Tested-by: Petri Dish Buildbot Tested-by: Michal Labedzki Reviewed-by: Michal Labedzki --- debian/libwireshark0.symbols | 5 +- docbook/release-notes.asciidoc | 7 + epan/dissectors/packet-bluetooth.c | 19 +- epan/dissectors/packet-bluetooth.h | 42 ++- epan/dissectors/packet-btatt.c | 2 +- epan/dissectors/packet-bthci_cmd.c | 169 +++++------ epan/dissectors/packet-bthci_cmd.h | 4 + epan/dissectors/packet-bthci_evt.c | 350 +++++++++++++++++----- epan/dissectors/packet-bthci_evt.h | 11 + epan/dissectors/packet-bthci_vendor.c | 8 +- epan/dissectors/packet-btle.c | 16 +- epan/dissectors/packet-btobex.c | 47 +-- epan/dissectors/packet-btsmp.c | 17 +- epan/dissectors/packet-hci_mon.c | 2 +- ui/qt/CMakeLists.txt | 3 + ui/qt/Makefile.am | 2 + ui/qt/Makefile.common | 4 + ui/qt/Wireshark.pro | 3 + ui/qt/bluetooth_devices_dialog.cpp | 412 ++++++++++++++++++++++++++ ui/qt/bluetooth_devices_dialog.h | 105 +++++++ ui/qt/bluetooth_devices_dialog.ui | 210 +++++++++++++ ui/qt/main_window.h | 1 + ui/qt/main_window.ui | 6 + ui/qt/main_window_slots.cpp | 11 + 24 files changed, 1248 insertions(+), 208 deletions(-) create mode 100644 ui/qt/bluetooth_devices_dialog.cpp create mode 100644 ui/qt/bluetooth_devices_dialog.h create mode 100644 ui/qt/bluetooth_devices_dialog.ui diff --git a/debian/libwireshark0.symbols b/debian/libwireshark0.symbols index 87dce3a70b..b04268b16e 100644 --- a/debian/libwireshark0.symbols +++ b/debian/libwireshark0.symbols @@ -70,10 +70,13 @@ libwireshark.so.0 libwireshark0 #MINVER# ber_decode_as@Base 1.9.1 ber_decode_as_foreach@Base 1.9.1 ber_set_filename@Base 1.9.1 + bluetooth_company_id_vals_ext@Base 1.99.6 + bluetooth_uuid_custom@Base 1.99.2 bluetooth_uuid_vals@Base 1.99.2 bluetooth_uuid_vals_ext@Base 1.99.2 - bluetooth_uuid_custom@Base 1.99.2 bssgp_cause_vals_ext@Base 1.9.1 + bthci_evt_hci_version@Base 1.99.6 + bthci_evt_lmp_version@Base 1.99.6 build_column_format_array@Base 1.9.1 build_follow_conv_filter@Base 1.12.0~rc1 build_follow_index_filter@Base 1.12.0~rc1 diff --git a/docbook/release-notes.asciidoc b/docbook/release-notes.asciidoc index c49c106cd5..12200be2b8 100644 --- a/docbook/release-notes.asciidoc +++ b/docbook/release-notes.asciidoc @@ -21,6 +21,13 @@ used for troubleshooting, analysis, development and education. === New and Updated Features +The following features are new (or have been significantly updated) +since version 1.99.6: + +* Qt port: + +** The Bluetooth Devices dialog has been added. + The following features are new (or have been significantly updated) since version 1.99.4 and 1.99.5: diff --git a/epan/dissectors/packet-bluetooth.c b/epan/dissectors/packet-bluetooth.c index c89dd492a0..60031c7d43 100644 --- a/epan/dissectors/packet-bluetooth.c +++ b/epan/dissectors/packet-bluetooth.c @@ -60,6 +60,7 @@ static wmem_tree_t *localhost_bdaddr = NULL; static wmem_tree_t *hci_vendors = NULL; static int bluetooth_tap = -1; +int bluetooth_device_tap = -1; const value_string bluetooth_uuid_vals[] = { /* Protocol Identifiers - https://www.bluetooth.org/en-us/specification/assigned-numbers/service-discovery */ @@ -1025,7 +1026,9 @@ void proto_reg_handoff_bluetooth(void); gint -dissect_bd_addr(gint hf_bd_addr, proto_tree *tree, tvbuff_t *tvb, gint offset, guint8 *bdaddr) +dissect_bd_addr(gint hf_bd_addr, packet_info *pinfo, proto_tree *tree, + tvbuff_t *tvb, gint offset, gboolean is_local_bd_addr, + guint32 interface_id, guint32 adapter_id, guint8 *bdaddr) { guint8 bd_addr[6]; @@ -1039,6 +1042,19 @@ dissect_bd_addr(gint hf_bd_addr, proto_tree *tree, tvbuff_t *tvb, gint offset, g proto_tree_add_ether(tree, hf_bd_addr, tvb, offset, 6, bd_addr); offset += 6; + if (have_tap_listener(bluetooth_device_tap)) { + bluetooth_device_tap_t *tap_device; + + tap_device = wmem_new(wmem_packet_scope(), bluetooth_device_tap_t); + tap_device->interface_id = interface_id; + tap_device->adapter_id = adapter_id; + memcpy(tap_device->bd_addr, bd_addr, 6); + tap_device->has_bd_addr = TRUE; + tap_device->is_local = is_local_bd_addr; + tap_device->type = BLUETOOTH_DEVICE_BD_ADDR; + tap_queue_packet(bluetooth_device_tap, pinfo, tap_device); + } + if (bdaddr) memcpy(bdaddr, bd_addr, 6); @@ -1403,6 +1419,7 @@ proto_register_bluetooth(void) hci_vendor_table = register_dissector_table("bluetooth.vendor", "HCI Vendor", FT_UINT16, BASE_HEX); bluetooth_tap = register_tap("bluetooth"); + bluetooth_device_tap = register_tap("bluetooth.device"); register_conversation_table(proto_bluetooth, TRUE, bluetooth_conversation_packet, bluetooth_hostlist_packet); } diff --git a/epan/dissectors/packet-bluetooth.h b/epan/dissectors/packet-bluetooth.h index 69e7a02965..b072173140 100644 --- a/epan/dissectors/packet-bluetooth.h +++ b/epan/dissectors/packet-bluetooth.h @@ -183,15 +183,51 @@ typedef struct _bluetooth_uuid_custom { const gchar *name; } bluetooth_uuid_custom_t; +enum bluetooth_device_type { + BLUETOOTH_DEVICE_BD_ADDR, + BLUETOOTH_DEVICE_NAME, + BLUETOOTH_DEVICE_LOCAL_ADAPTER, + BLUETOOTH_DEVICE_LOCAL_VERSION, + BLUETOOTH_DEVICE_REMOTE_VERSION +}; + +typedef struct _bluetooth_device_tap_t { + guint32 interface_id; + guint32 adapter_id; + + gboolean is_local; + gboolean has_bd_addr; + guint8 bd_addr[6]; + enum bluetooth_device_type type; + union { + char *name; + struct { + guint8 hci_version; + guint16 hci_revision; + guint8 lmp_version; + guint16 lmp_subversion; + guint16 manufacturer; + } local_version; + struct { + guint8 lmp_version; + guint16 lmp_subversion; + guint16 manufacturer; + } remote_version; + } data; +} bluetooth_device_tap_t; + +extern int bluetooth_device_tap; + WS_DLL_PUBLIC const value_string bluetooth_uuid_vals[]; WS_DLL_PUBLIC const bluetooth_uuid_custom_t bluetooth_uuid_custom[]; WS_DLL_PUBLIC value_string_ext bluetooth_uuid_vals_ext; -extern value_string_ext bluetooth_company_id_vals_ext; +WS_DLL_PUBLIC value_string_ext bluetooth_company_id_vals_ext; extern guint32 max_disconnect_in_frame; -extern gint dissect_bd_addr(gint hf_bd_addr, proto_tree *tree, tvbuff_t *tvb, - gint offset, guint8 *bdaddr); +extern gint dissect_bd_addr(gint hf_bd_addr, packet_info *pinfo, proto_tree *tree, + tvbuff_t *tvb, gint offset, gboolean is_local_bd_addr, + guint32 interface_id, guint32 adapter_id, guint8 *bdaddr); extern bluetooth_uuid_t get_uuid(tvbuff_t *tvb, gint offset, gint size); extern gchar *print_uuid(bluetooth_uuid_t *uuid); diff --git a/epan/dissectors/packet-btatt.c b/epan/dissectors/packet-btatt.c index abc649d004..73d8a649a6 100644 --- a/epan/dissectors/packet-btatt.c +++ b/epan/dissectors/packet-btatt.c @@ -2012,7 +2012,7 @@ dissect_attribute_value(proto_tree *tree, proto_item *patron_item, packet_info * break; case 0x2A03: /* Reconnection Address */ - offset = dissect_bd_addr(hf_btatt_reconnection_address, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_btatt_reconnection_address, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); break; case 0x2A04: /* Peripheral Preferred Connection Parameters */ diff --git a/epan/dissectors/packet-bthci_cmd.c b/epan/dissectors/packet-bthci_cmd.c index 1d013659ee..fd62920a4e 100644 --- a/epan/dissectors/packet-bthci_cmd.c +++ b/epan/dissectors/packet-bthci_cmd.c @@ -37,6 +37,7 @@ #include #include #include +#include #include "packet-bluetooth.h" #include "packet-bthci_cmd.h" @@ -1572,7 +1573,7 @@ dissect_link_control_cmd(tvbuff_t *tvb, int offset, packet_info *pinfo, { guint8 bd_addr[6]; - offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, tree, tvb, offset, bd_addr); + offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, bd_addr); proto_tree_add_item(tree, hf_bthci_cmd_packet_type_2dh1, tvb, offset, 2, ENC_LITTLE_ENDIAN); proto_tree_add_item(tree, hf_bthci_cmd_packet_type_3dh1, tvb, offset, 2, ENC_LITTLE_ENDIAN); @@ -1657,14 +1658,14 @@ dissect_link_control_cmd(tvbuff_t *tvb, int offset, packet_info *pinfo, break; case 0x0008: /* Create Connection Cancel Request */ - offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); break; case 0x0009: /* Accept Connection Request */ { guint8 bd_addr[6]; guint8 role; - offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, tree, tvb, offset, bd_addr); + offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, bd_addr); proto_tree_add_item(tree, hf_bthci_cmd_role, tvb, offset, 1, ENC_LITTLE_ENDIAN); role = tvb_get_guint8(tvb, offset); @@ -1713,25 +1714,25 @@ dissect_link_control_cmd(tvbuff_t *tvb, int offset, packet_info *pinfo, break; case 0x000a: /* Reject Connection Request */ - offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); proto_tree_add_item(tree, hf_bthci_cmd_reason, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset++; break; case 0x000b: /* Link Key Request Reply */ - offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); proto_tree_add_item(tree, hf_bthci_cmd_link_key, tvb, offset, 16, ENC_NA); offset+=16; break; case 0x000c: /* Link Key Request Negative Reply */ - offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); break; case 0x000d: /* PIN Code Request Reply */ - offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); proto_tree_add_item(tree, hf_bthci_cmd_pin_code_length ,tvb, offset, 1, ENC_LITTLE_ENDIAN); offset++; @@ -1740,7 +1741,7 @@ dissect_link_control_cmd(tvbuff_t *tvb, int offset, packet_info *pinfo, break; case 0x000e: /* PIN Code Request Negative Reply */ - offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); break; case 0x000f: /* Change Connection Packet Type */ @@ -1779,7 +1780,7 @@ dissect_link_control_cmd(tvbuff_t *tvb, int offset, packet_info *pinfo, break; case 0x0019: /* Remote Name Request */ - offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); proto_tree_add_item(tree, hf_bthci_cmd_page_scan_repetition_mode, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset++; @@ -1795,7 +1796,7 @@ dissect_link_control_cmd(tvbuff_t *tvb, int offset, packet_info *pinfo, break; case 0x001a: /* Remote Name Request Cancel */ - offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); break; case 0x001c: /* Read Remote Extended Features */ @@ -1811,7 +1812,7 @@ dissect_link_control_cmd(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree_add_item(tree, hf_bthci_cmd_connection_handle, tvb, offset, 2, ENC_LITTLE_ENDIAN); offset+=2; } else { - offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); } proto_tree_add_item(tree, hf_bthci_cmd_transmit_bandwidth, tvb, offset, 4, ENC_LITTLE_ENDIAN); @@ -1847,7 +1848,7 @@ dissect_link_control_cmd(tvbuff_t *tvb, int offset, packet_info *pinfo, offset+=2; break; case 0x002a: /* Reject Synchronous Connection Request */ - offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); proto_tree_add_item(tree, hf_bthci_cmd_reason, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset++; @@ -1863,7 +1864,7 @@ dissect_link_control_cmd(tvbuff_t *tvb, int offset, packet_info *pinfo, break; case 0x002b: /* IO Capability Response */ - offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); proto_tree_add_item(tree, hf_bthci_cmd_io_capability, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset++; @@ -1874,7 +1875,7 @@ dissect_link_control_cmd(tvbuff_t *tvb, int offset, packet_info *pinfo, break; case 0x0034: /* IO Capability Request Negative Reply */ - offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); proto_tree_add_item(tree, hf_bthci_cmd_reason, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset++; break; @@ -1883,18 +1884,18 @@ dissect_link_control_cmd(tvbuff_t *tvb, int offset, packet_info *pinfo, case 0x002d: /* User Confirmation Request Negative Reply */ case 0x002f: /* User Passkey Request Negative Reply */ case 0x0033: /* Remote OOB Data Request Negative Reply */ - offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); break; case 0x002e: /* User Passkey Request Reply */ - offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); proto_tree_add_item(tree, hf_bthci_cmd_passkey, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset+=4; break; case 0x0030: /* Remote OOB Data Request Reply */ - offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); proto_tree_add_item(tree, hf_bthci_cmd_hash_c, tvb, offset, 16, ENC_NA); offset+=16; @@ -1975,7 +1976,7 @@ dissect_link_control_cmd(tvbuff_t *tvb, int offset, packet_info *pinfo, } static int -dissect_link_policy_cmd(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, guint16 cmd_ocf) +dissect_link_policy_cmd(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, guint16 cmd_ocf, bluetooth_data_t *bluetooth_data) { proto_item *item; guint16 timeout; @@ -2047,7 +2048,7 @@ dissect_link_policy_cmd(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto break; case 0x000b: /* Switch Role */ - offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); proto_tree_add_item(tree, hf_bthci_cmd_role, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset++; @@ -2121,7 +2122,8 @@ dissect_link_policy_cmd(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto static int dissect_host_controller_baseband_cmd(tvbuff_t *tvb, int offset, packet_info *pinfo, - proto_tree *tree, guint16 cmd_ocf, bluetooth_data_t *bluetooth_data) + proto_tree *tree, guint16 cmd_ocf, bluetooth_data_t *bluetooth_data, + bthci_cmd_data_t *bthci_cmd_data) { proto_item *item; guint16 timeout; @@ -2214,7 +2216,7 @@ dissect_host_controller_baseband_cmd(tvbuff_t *tvb, int offset, packet_info *pin break; case 0x02: - offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); break; default: @@ -2245,7 +2247,7 @@ dissect_host_controller_baseband_cmd(tvbuff_t *tvb, int offset, packet_info *pin break; case 0x02: - offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); proto_tree_add_item(tree, hf_bthci_cmd_auto_acc_flag, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset++; @@ -2269,7 +2271,7 @@ dissect_host_controller_baseband_cmd(tvbuff_t *tvb, int offset, packet_info *pin break; case 0x000d: /* Read Stored Link Key */ - offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); proto_tree_add_item(tree, hf_bthci_cmd_read_all_flag, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset++; @@ -2281,14 +2283,14 @@ dissect_host_controller_baseband_cmd(tvbuff_t *tvb, int offset, packet_info *pin offset += 1; for (i = 0; i < num8; i++) { - offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); proto_tree_add_item(tree, hf_bthci_cmd_link_key, tvb, offset, 16, ENC_NA); offset += 16; } break; case 0x0012: /* Delete Stored Link Key */ - offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); proto_tree_add_item(tree, hf_bthci_cmd_delete_all_flag, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset++; @@ -2296,35 +2298,8 @@ dissect_host_controller_baseband_cmd(tvbuff_t *tvb, int offset, packet_info *pin case 0x0013: /* Change Local Name */ proto_tree_add_item(tree, hf_bthci_cmd_device_name, tvb, offset, 248, ENC_UTF_8 | ENC_NA); - if (!pinfo->fd->flags.visited) { - wmem_tree_key_t key[4]; - guint32 k_interface_id; - guint32 k_adapter_id; - guint32 k_frame_number; - gchar *name; - localhost_name_entry_t *localhost_name_entry; - - k_interface_id = bluetooth_data->interface_id; - k_adapter_id = bluetooth_data->adapter_id; - k_frame_number = pinfo->fd->num; - - name = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 248, ENC_UTF_8); - - key[0].length = 1; - key[0].key = &k_interface_id; - key[1].length = 1; - key[1].key = &k_adapter_id; - key[2].length = 1; - key[2].key = &k_frame_number; - key[3].length = 0; - key[3].key = NULL; - - localhost_name_entry = (localhost_name_entry_t *) wmem_new(wmem_file_scope(), localhost_name_entry_t); - localhost_name_entry->interface_id = k_interface_id; - localhost_name_entry->adapter_id = k_adapter_id; - localhost_name_entry->name = wmem_strdup(wmem_file_scope(), name); - - wmem_tree_insert32_array(bluetooth_data->localhost_name, key, localhost_name_entry); + if (!pinfo->fd->flags.visited && bthci_cmd_data) { + bthci_cmd_data->data.name = tvb_get_string_enc(wmem_file_scope(), tvb, offset, 248, ENC_UTF_8); } offset += 248; break; @@ -2550,7 +2525,7 @@ dissect_host_controller_baseband_cmd(tvbuff_t *tvb, int offset, packet_info *pin proto_tree_add_item(tree, hf_bthci_cmd_fec_required, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset++; - call_dissector(btcommon_eir_handle, tvb_new_subset_length(tvb, offset, 240), pinfo, tree); + call_dissector_with_data(btcommon_eir_handle, tvb_new_subset_length(tvb, offset, 240), pinfo, tree, bluetooth_data); save_local_device_name_from_eir_ad(tvb, offset, pinfo, 240, bluetooth_data); offset += 240; break; @@ -2583,7 +2558,7 @@ dissect_host_controller_baseband_cmd(tvbuff_t *tvb, int offset, packet_info *pin break; case 0x0060: /* Send Keypress Notification */ - offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); proto_tree_add_item(tree, hf_bthci_cmd_notification_type, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset++; @@ -2875,7 +2850,7 @@ dissect_le_cmd(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, break; case 0x0005: /* LE Set Random Address */ - offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); break; case 0x0006: /* LE Set Advertising Parameters */ @@ -2891,7 +2866,7 @@ dissect_le_cmd(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, offset++; proto_tree_add_item(tree, hf_bthci_cmd_le_direct_address_type, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset++; - offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); proto_tree_add_item(tree, hf_bthci_cmd_le_advts_channel_map_1, tvb, offset, 1, ENC_LITTLE_ENDIAN); proto_tree_add_item(tree, hf_bthci_cmd_le_advts_channel_map_2, tvb, offset, 1, ENC_LITTLE_ENDIAN); proto_tree_add_item(tree, hf_bthci_cmd_le_advts_channel_map_3, tvb, offset, 1, ENC_LITTLE_ENDIAN); @@ -2905,7 +2880,7 @@ dissect_le_cmd(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, proto_tree_add_item(tree, hf_bthci_cmd_le_data_length, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset++; - call_dissector(btcommon_ad_handle, tvb_new_subset_length(tvb, offset, 31), pinfo, tree); + call_dissector_with_data(btcommon_ad_handle, tvb_new_subset_length(tvb, offset, 31), pinfo, tree, bluetooth_data); save_local_device_name_from_eir_ad(tvb, offset, pinfo, 31, bluetooth_data); offset += 31; break; @@ -2948,7 +2923,7 @@ dissect_le_cmd(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, offset++; proto_tree_add_item(tree, hf_bthci_cmd_le_peer_address_type, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset++; - offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); proto_tree_add_item(tree, hf_bthci_cmd_le_own_address_type, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset++; item = proto_tree_add_item(tree, hf_bthci_cmd_le_con_interval_min, tvb, offset, 2, ENC_LITTLE_ENDIAN); @@ -2975,7 +2950,7 @@ dissect_le_cmd(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, case 0x0012: /* LE Remove Device From White List */ proto_tree_add_item(tree, hf_bthci_cmd_le_address_type, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset++; - offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_cmd_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); break; case 0x0013: /* LE Connection Update */ @@ -3096,7 +3071,7 @@ dissect_bthci_cmd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat guint32 adapter_id; guint32 frame_number; wmem_tree_key_t key[5]; - bthci_cmd_data_t *bthci_cmd_data; + bthci_cmd_data_t *bthci_cmd_data = NULL; proto_tree *sub_item; wmem_tree_t *subtree; @@ -3147,6 +3122,17 @@ dissect_bthci_cmd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat ocf = opcode & 0x03ff; ogf = (guint8) (opcode >> 10); + if (!pinfo->fd->flags.visited && bluetooth_data) { + bthci_cmd_data = (bthci_cmd_data_t *) wmem_new(wmem_file_scope(), bthci_cmd_data_t); + bthci_cmd_data->opcode = opcode; + bthci_cmd_data->command_in_frame = frame_number; + bthci_cmd_data->command_abs_ts = pinfo->fd->abs_ts; + bthci_cmd_data->pending_in_frame = max_disconnect_in_frame; + bthci_cmd_data->pending_abs_ts = pinfo->fd->abs_ts; + bthci_cmd_data->response_in_frame = max_disconnect_in_frame; + bthci_cmd_data->response_abs_ts = pinfo->fd->abs_ts; + } + if (ogf == HCI_OGF_VENDOR_SPECIFIC) proto_item_append_text(ti_cmd," - %s", val_to_str_ext(opcode, &bthci_cmd_opcode_vals_ext, "Vendor Command 0x%04x")); else @@ -3215,11 +3201,11 @@ dissect_bthci_cmd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat break; case HCI_OGF_LINK_POLICY: - offset = dissect_link_policy_cmd(tvb, offset, pinfo, bthci_cmd_tree, ocf); + offset = dissect_link_policy_cmd(tvb, offset, pinfo, bthci_cmd_tree, ocf, bluetooth_data); break; case HCI_OGF_HOST_CONTROLLER: - offset = dissect_host_controller_baseband_cmd(tvb, offset, pinfo, bthci_cmd_tree, ocf, bluetooth_data); + offset = dissect_host_controller_baseband_cmd(tvb, offset, pinfo, bthci_cmd_tree, ocf, bluetooth_data, bthci_cmd_data); break; case HCI_OGF_INFORMATIONAL: @@ -3245,7 +3231,7 @@ dissect_bthci_cmd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat } } - if (!pinfo->fd->flags.visited && bluetooth_data) { + if (!pinfo->fd->flags.visited && bluetooth_data && bthci_cmd_data) { key[0].length = 1; key[0].key = &interface_id; key[1].length = 1; @@ -3257,15 +3243,6 @@ dissect_bthci_cmd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat key[4].length = 0; key[4].key = NULL; - bthci_cmd_data = (bthci_cmd_data_t *) wmem_new(wmem_file_scope(), bthci_cmd_data_t); - bthci_cmd_data->opcode = opcode; - bthci_cmd_data->command_in_frame = frame_number; - bthci_cmd_data->command_abs_ts = pinfo->fd->abs_ts; - bthci_cmd_data->pending_in_frame = max_disconnect_in_frame; - bthci_cmd_data->pending_abs_ts = pinfo->fd->abs_ts; - bthci_cmd_data->response_in_frame = max_disconnect_in_frame; - bthci_cmd_data->response_abs_ts = pinfo->fd->abs_ts; - wmem_tree_insert32_array(bthci_cmds, key, bthci_cmd_data); } @@ -4883,7 +4860,7 @@ proto_reg_handoff_bthci_cmd(void) static gint -dissect_eir_ad_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +dissect_eir_ad_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, bluetooth_data_t *bluetooth_data) { proto_item *entry_item; proto_tree *entry_tree; @@ -4894,6 +4871,9 @@ dissect_eir_ad_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) guint8 data_size; gint64 end_offset; guint i_uuid; + gboolean has_bd_addr = FALSE; + guint8 bd_addr[6]; + guint8 *name = NULL; data_size = tvb_reported_length(tvb); @@ -5002,8 +4982,10 @@ dissect_eir_ad_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) case 0x08: /* Device Name (shortened) */ case 0x09: /* Device Name */ - proto_tree_add_item(entry_tree, hf_btcommon_eir_ad_name, tvb, offset, length, ENC_ASCII | ENC_NA); + proto_tree_add_item(entry_tree, hf_btcommon_eir_ad_name, tvb, offset, length, ENC_UTF_8 | ENC_NA); proto_item_append_text(entry_item, ": %s", tvb_format_text(tvb,offset, length)); + if (!name || type == 0x09) + name = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, length, ENC_UTF_8); offset += length; break; @@ -5061,8 +5043,8 @@ dissect_eir_ad_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) break; case 0x0C: /* BD_ADDR */ /* From CSS v3.pdf */ - offset = dissect_bd_addr(hf_btcommon_eir_ad_bd_addr, tree, tvb, offset, NULL); - + offset = dissect_bd_addr(hf_btcommon_eir_ad_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, bd_addr); + has_bd_addr = TRUE; break; case 0x0D: /* Class Of Device */ @@ -5176,7 +5158,7 @@ dissect_eir_ad_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) case 0x18: /* Random Target Address */ end_offset = offset + length; while (offset < end_offset) { - offset = dissect_bd_addr(hf_btcommon_eir_ad_bd_addr, entry_tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_btcommon_eir_ad_bd_addr, pinfo, entry_tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); } break; @@ -5198,7 +5180,7 @@ dissect_eir_ad_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree_add_item(entry_tree, hf_btcommon_eir_ad_le_bd_addr_type, tvb, offset, 1, ENC_NA); offset += 1; - offset = dissect_bd_addr(hf_btcommon_eir_ad_bd_addr, entry_tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_btcommon_eir_ad_bd_addr, pinfo, entry_tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); break; case 0x1C: /* LE Role */ @@ -5267,6 +5249,25 @@ dissect_eir_ad_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) offset = tvb_reported_length(tvb); } + if (has_bd_addr && name && have_tap_listener(bluetooth_device_tap)) { + bluetooth_device_tap_t *tap_device; + + tap_device = wmem_new(wmem_packet_scope(), bluetooth_device_tap_t); + if (bluetooth_data) { + tap_device->interface_id = bluetooth_data->interface_id; + tap_device->adapter_id = bluetooth_data->adapter_id; + } else { + tap_device->interface_id = HCI_INTERFACE_DEFAULT; + tap_device->adapter_id = HCI_ADAPTER_DEFAULT; + } + memcpy(tap_device->bd_addr, bd_addr, 6); + tap_device->has_bd_addr = TRUE; + tap_device->is_local = FALSE; + tap_device->type = BLUETOOTH_DEVICE_NAME; + tap_device->data.name = name; + tap_queue_packet(bluetooth_device_tap, pinfo, tap_device); + } + return offset + data_size; } @@ -5375,7 +5376,7 @@ dissect_btcommon_cod(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, vo } static gint -dissect_btcommon_ad(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) +dissect_btcommon_ad(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) { proto_item *main_item; proto_tree *main_tree; @@ -5383,11 +5384,11 @@ dissect_btcommon_ad(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *d main_item = proto_tree_add_item(tree, hf_btcommon_eir_ad_advertising_data, tvb, 0, -1, ENC_NA); main_tree = proto_item_add_subtree(main_item, ett_eir_ad); - return dissect_eir_ad_data(tvb, pinfo, main_tree); + return dissect_eir_ad_data(tvb, pinfo, main_tree, (bluetooth_data_t *) data); } static gint -dissect_btcommon_eir(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) +dissect_btcommon_eir(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) { proto_item *main_item; proto_tree *main_tree; @@ -5395,7 +5396,7 @@ dissect_btcommon_eir(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void * main_item = proto_tree_add_item(tree, hf_btcommon_eir_ad_extended_inquiry_response_data, tvb, 0, -1, ENC_NA); main_tree = proto_item_add_subtree(main_item, ett_eir_ad); - return dissect_eir_ad_data(tvb, pinfo, main_tree); + return dissect_eir_ad_data(tvb, pinfo, main_tree, (bluetooth_data_t *) data); } static gint diff --git a/epan/dissectors/packet-bthci_cmd.h b/epan/dissectors/packet-bthci_cmd.h index c9d3dd4f96..bcb6c5b7dd 100644 --- a/epan/dissectors/packet-bthci_cmd.h +++ b/epan/dissectors/packet-bthci_cmd.h @@ -59,6 +59,10 @@ typedef struct _bthci_cmd_data_t { nstime_t pending_abs_ts; guint32 response_in_frame; nstime_t response_abs_ts; + + union { + gchar *name; + } data; } bthci_cmd_data_t; extern wmem_tree_t *bthci_cmds; diff --git a/epan/dissectors/packet-bthci_evt.c b/epan/dissectors/packet-bthci_evt.c index c827b72324..e4a00a9964 100644 --- a/epan/dissectors/packet-bthci_evt.c +++ b/epan/dissectors/packet-bthci_evt.c @@ -37,10 +37,12 @@ #include #include #include +#include #include "packet-bluetooth.h" #include "packet-bthci_sco.h" #include "packet-bthci_cmd.h" +#include "packet-bthci_evt.h" static dissector_handle_t bthci_cmd_handle; static dissector_handle_t bthci_evt_handle; @@ -79,7 +81,7 @@ static int hf_bthci_evt_remote_name = -1; static int hf_bthci_evt_encryption_enable = -1; static int hf_bthci_evt_key_flag = -1; static int hf_bthci_evt_vers_nr = -1; -static int hf_bthci_evt_hci_vers_nr = -1; +static int hf_bthci_bthci_evt_hci_version = -1; static int hf_bthci_evt_hci_revision = -1; static int hf_bthci_evt_comp_id = -1; static int hf_bthci_evt_sub_vers_nr = -1; @@ -510,7 +512,7 @@ static const value_string evt_key_flag[] = { }; /* Taken from https://www.bluetooth.org/Technical/AssignedNumbers/link_manager.htm */ -static const value_string evt_lmp_vers_nr[] = { +const value_string bthci_evt_lmp_version[] = { {0x00, "1.0b"}, {0x01, "1.1"}, {0x02, "1.2"}, @@ -526,7 +528,7 @@ static const value_string evt_lmp_vers_nr[] = { /* Taken from https://www.bluetooth.org/Technical/AssignedNumbers/hci.htm * (requires a login/password) */ -static const value_string evt_hci_vers_nr[] = { +const value_string bthci_evt_hci_version[] = { {0x00, "1.0b"}, {0x01, "1.1"}, {0x02, "1.2"}, @@ -833,7 +835,7 @@ dissect_bthci_evt_connect_complete(tvbuff_t *tvb, int offset, packet_info *pinfo proto_tree_add_item(tree, hf_bthci_evt_connection_handle, tvb, offset, 2, ENC_LITTLE_ENDIAN); offset += 2; - offset = dissect_bd_addr(hf_bthci_evt_bd_addr, tree, tvb, offset, bd_addr); + offset = dissect_bd_addr(hf_bthci_evt_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, bd_addr); if (!pinfo->fd->flags.visited && bluetooth_data != NULL && status == 0x00) { wmem_tree_key_t key[5]; guint32 k_interface_id; @@ -890,9 +892,9 @@ dissect_bthci_evt_connect_complete(tvbuff_t *tvb, int offset, packet_info *pinfo } static int -dissect_bthci_evt_connect_request(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree) +dissect_bthci_evt_connect_request(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, bluetooth_data_t *bluetooth_data) { - offset = dissect_bd_addr(hf_bthci_evt_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_evt_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); call_dissector(btcommon_cod_handle, tvb_new_subset_length(tvb, offset, 3), pinfo, tree); offset += 3; @@ -1076,25 +1078,25 @@ dissect_bthci_evt_lmp_features(tvbuff_t *tvb, int offset, packet_info *pinfo _U_ } static int -dissect_bthci_evt_pin_code_request(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) +dissect_bthci_evt_pin_code_request(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, bluetooth_data_t *bluetooth_data) { - offset = dissect_bd_addr(hf_bthci_evt_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_evt_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); return offset; } static int -dissect_bthci_evt_link_key_request(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) +dissect_bthci_evt_link_key_request(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, bluetooth_data_t *bluetooth_data) { - offset = dissect_bd_addr(hf_bthci_evt_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_evt_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); return offset; } static int -dissect_bthci_evt_link_key_notification(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) +dissect_bthci_evt_link_key_notification(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, bluetooth_data_t *bluetooth_data) { - offset = dissect_bd_addr(hf_bthci_evt_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_evt_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); proto_tree_add_item(tree, hf_bthci_evt_link_key, tvb, offset, 16, ENC_NA); offset += 16; @@ -1106,7 +1108,7 @@ dissect_bthci_evt_link_key_notification(tvbuff_t *tvb, int offset, packet_info * } static int -dissect_bthci_evt_return_link_keys(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) +dissect_bthci_evt_return_link_keys(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, bluetooth_data_t *bluetooth_data) { guint8 evt_num_keys; @@ -1115,7 +1117,7 @@ dissect_bthci_evt_return_link_keys(tvbuff_t *tvb, int offset, packet_info *pinfo offset += 1; while (evt_num_keys--) { - offset = dissect_bd_addr(hf_bthci_evt_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_evt_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); proto_tree_add_item(tree, hf_bthci_evt_link_key, tvb, offset, 16, ENC_NA); offset += 16; @@ -1148,7 +1150,7 @@ dissect_bthci_evt_remote_name_req_complete(tvbuff_t *tvb, int offset, proto_tree_add_item(tree, hf_bthci_evt_status, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; - offset = dissect_bd_addr(hf_bthci_evt_bd_addr, tree, tvb, offset, bd_addr); + offset = dissect_bd_addr(hf_bthci_evt_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, bd_addr); proto_tree_add_item(tree, hf_bthci_evt_remote_name, tvb, offset, 248, ENC_UTF_8|ENC_NA); if (!pinfo->fd->flags.visited && bluetooth_data != NULL) { @@ -1188,13 +1190,33 @@ dissect_bthci_evt_remote_name_req_complete(tvbuff_t *tvb, int offset, wmem_tree_insert32_array(bluetooth_data->bdaddr_to_name, key, device_name); } + + if (have_tap_listener(bluetooth_device_tap)) { + bluetooth_device_tap_t *tap_device; + + tap_device = wmem_new(wmem_packet_scope(), bluetooth_device_tap_t); + if (bluetooth_data) { + tap_device->interface_id = bluetooth_data->interface_id; + tap_device->adapter_id = bluetooth_data->adapter_id; + } else { + tap_device->interface_id = HCI_INTERFACE_DEFAULT; + tap_device->adapter_id = HCI_ADAPTER_DEFAULT; + } + memcpy(tap_device->bd_addr, bd_addr, 6); + tap_device->has_bd_addr = TRUE; + tap_device->is_local = FALSE; + tap_device->type = BLUETOOTH_DEVICE_NAME; + tap_device->data.name = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 248, ENC_UTF_8); + tap_queue_packet(bluetooth_device_tap, pinfo, tap_device); + } + offset += 248; return offset; } static int -dissect_bthci_evt_read_remote_version_information_complete(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) +dissect_bthci_evt_read_remote_version_information_complete(tvbuff_t *tvb, int offset, packet_info *pinfo, bluetooth_data_t *bluetooth_data, proto_tree *tree) { proto_tree_add_item(tree, hf_bthci_evt_status, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; @@ -1211,6 +1233,61 @@ dissect_bthci_evt_read_remote_version_information_complete(tvbuff_t *tvb, int of proto_tree_add_item(tree, hf_bthci_evt_sub_vers_nr, tvb, offset, 2, ENC_LITTLE_ENDIAN); offset += 2; + if (have_tap_listener(bluetooth_device_tap)) { + wmem_tree_t *subtree; + wmem_tree_key_t key[4]; + guint32 interface_id; + guint32 adapter_id; + guint32 connection_handle; + remote_bdaddr_t *remote_bdaddr; + bluetooth_device_tap_t *tap_device; + guint8 lmp_version; + guint16 lmp_subversion; + guint16 manufacturer; + + lmp_version = tvb_get_guint8(tvb, offset - 5); + manufacturer = tvb_get_letohs(tvb, offset - 4); + lmp_subversion = tvb_get_letohs(tvb, offset - 2); + + interface_id = bluetooth_data->interface_id; + adapter_id = bluetooth_data->adapter_id; + connection_handle = tvb_get_guint16(tvb, offset - 7, ENC_LITTLE_ENDIAN) & 0x0fff; + + key[0].length = 1; + key[0].key = &interface_id; + key[1].length = 1; + key[1].key = &adapter_id; + key[2].length = 1; + key[2].key = &connection_handle; + key[3].length = 0; + key[3].key = NULL; + + subtree = (wmem_tree_t *) wmem_tree_lookup32_array(bluetooth_data->chandle_to_bdaddr, key); + remote_bdaddr = (subtree) ? (remote_bdaddr_t *) wmem_tree_lookup32_le(subtree, pinfo->fd->num) : NULL; + + tap_device = wmem_new(wmem_packet_scope(), bluetooth_device_tap_t); + tap_device->type = BLUETOOTH_DEVICE_REMOTE_VERSION; + if (bluetooth_data) { + tap_device->interface_id = bluetooth_data->interface_id; + tap_device->adapter_id = bluetooth_data->adapter_id; + } else { + tap_device->interface_id = HCI_INTERFACE_DEFAULT; + tap_device->adapter_id = HCI_ADAPTER_DEFAULT; + } + + if (remote_bdaddr) { + tap_device->has_bd_addr = TRUE; + memcpy(tap_device->bd_addr, remote_bdaddr->bd_addr, 6); + } else { + tap_device->has_bd_addr = FALSE; + } + tap_device->is_local = FALSE; + tap_device->data.remote_version.lmp_version = lmp_version; + tap_device->data.remote_version.lmp_subversion = lmp_subversion; + tap_device->data.remote_version.manufacturer = manufacturer; + tap_queue_packet(bluetooth_device_tap, pinfo, tap_device); + } + return offset; } @@ -1302,7 +1379,7 @@ dissect_bthci_evt_mode_change(tvbuff_t *tvb, int offset, packet_info *pinfo, } static int -dissect_bthci_evt_role_change(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, +dissect_bthci_evt_role_change(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, bluetooth_data_t *bluetooth_data) { guint8 bd_addr[6]; @@ -1313,7 +1390,7 @@ dissect_bthci_evt_role_change(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, status = tvb_get_guint8(tvb, offset); offset += 1; - offset = dissect_bd_addr(hf_bthci_evt_bd_addr, tree, tvb, offset, bd_addr); + offset = dissect_bd_addr(hf_bthci_evt_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, bd_addr); proto_tree_add_item(tree, hf_bthci_evt_role, tvb, offset, 1, ENC_LITTLE_ENDIAN); role = tvb_get_guint8(tvb, offset); @@ -1600,9 +1677,9 @@ dissect_bthci_evt_command_status(tvbuff_t *tvb, int offset, packet_info *pinfo, } static int -dissect_bthci_evt_page_scan_mode_change(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) +dissect_bthci_evt_page_scan_mode_change(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, bluetooth_data_t *bluetooth_data) { - offset = dissect_bd_addr(hf_bthci_evt_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_evt_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); proto_tree_add_item(tree, hf_bthci_evt_page_scan_mode, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; @@ -1611,9 +1688,9 @@ dissect_bthci_evt_page_scan_mode_change(tvbuff_t *tvb, int offset, packet_info * } static int -dissect_bthci_evt_page_scan_repetition_mode_change(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) +dissect_bthci_evt_page_scan_repetition_mode_change(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, bluetooth_data_t *bluetooth_data) { - offset = dissect_bd_addr(hf_bthci_evt_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_evt_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); proto_tree_add_item(tree, hf_bthci_evt_page_scan_repetition_mode, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; @@ -1623,7 +1700,7 @@ dissect_bthci_evt_page_scan_repetition_mode_change(tvbuff_t *tvb, int offset, pa static int dissect_bthci_evt_inquire_result_with_rssi(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, guint8 *bd_addr) + packet_info *pinfo, proto_tree *tree, bluetooth_data_t *bluetooth_data, guint8 *bd_addr) { guint8 num, evt_num_responses; @@ -1632,7 +1709,7 @@ dissect_bthci_evt_inquire_result_with_rssi(tvbuff_t *tvb, int offset, offset += 1; for (num = 0; num < evt_num_responses; num++) { - offset = dissect_bd_addr(hf_bthci_evt_bd_addr, tree, tvb, offset, (num == 0) ? bd_addr : NULL); + offset = dissect_bd_addr(hf_bthci_evt_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, (num == 0) ? bd_addr : NULL); proto_tree_add_item(tree, hf_bthci_evt_page_scan_repetition_mode, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; @@ -1655,17 +1732,17 @@ dissect_bthci_evt_inquire_result_with_rssi(tvbuff_t *tvb, int offset, } static int -dissect_bthci_evt_io_capability_request(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) +dissect_bthci_evt_io_capability_request(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, bluetooth_data_t *bluetooth_data) { - offset = dissect_bd_addr(hf_bthci_evt_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_evt_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); return offset; } static int -dissect_bthci_evt_io_capability_response(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) +dissect_bthci_evt_io_capability_response(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, bluetooth_data_t *bluetooth_data) { - offset = dissect_bd_addr(hf_bthci_evt_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_evt_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); proto_tree_add_item(tree, hf_bthci_evt_io_capability, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; @@ -1680,9 +1757,9 @@ dissect_bthci_evt_io_capability_response(tvbuff_t *tvb, int offset, packet_info } static int -dissect_bthci_evt_user_confirmation_request(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) +dissect_bthci_evt_user_confirmation_request(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, bluetooth_data_t *bluetooth_data) { - offset = dissect_bd_addr(hf_bthci_evt_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_evt_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); proto_tree_add_item(tree, hf_bthci_evt_numeric_value, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; @@ -1691,36 +1768,36 @@ dissect_bthci_evt_user_confirmation_request(tvbuff_t *tvb, int offset, packet_in } static int -dissect_bthci_evt_user_passkey_request(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) +dissect_bthci_evt_user_passkey_request(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, bluetooth_data_t *bluetooth_data) { - offset = dissect_bd_addr(hf_bthci_evt_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_evt_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); return offset; } static int -dissect_bthci_evt_remote_oob_data_request(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) +dissect_bthci_evt_remote_oob_data_request(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, bluetooth_data_t *bluetooth_data) { - offset = dissect_bd_addr(hf_bthci_evt_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_evt_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); return offset; } static int -dissect_bthci_evt_simple_pairing_complete(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) +dissect_bthci_evt_simple_pairing_complete(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, bluetooth_data_t *bluetooth_data) { proto_tree_add_item(tree, hf_bthci_evt_status, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; - offset = dissect_bd_addr(hf_bthci_evt_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_evt_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); return offset; } static int -dissect_bthci_evt_user_passkey_notification(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) +dissect_bthci_evt_user_passkey_notification(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, bluetooth_data_t *bluetooth_data) { - offset = dissect_bd_addr(hf_bthci_evt_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_evt_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); proto_tree_add_item(tree, hf_bthci_evt_passkey, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; @@ -1729,9 +1806,9 @@ dissect_bthci_evt_user_passkey_notification(tvbuff_t *tvb, int offset, packet_in } static int -dissect_bthci_evt_keypress_notification(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) +dissect_bthci_evt_keypress_notification(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, bluetooth_data_t *bluetooth_data) { - offset = dissect_bd_addr(hf_bthci_evt_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_evt_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); proto_tree_add_item(tree, hf_bthci_evt_notification_type, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; @@ -1740,9 +1817,9 @@ dissect_bthci_evt_keypress_notification(tvbuff_t *tvb, int offset, packet_info * } static int -dissect_bthci_evt_remote_host_sup_feat_notification(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree) +dissect_bthci_evt_remote_host_sup_feat_notification(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, bluetooth_data_t *bluetooth_data) { - offset = dissect_bd_addr(hf_bthci_evt_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_evt_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); offset = dissect_bthci_evt_lmp_features(tvb, offset, pinfo, tree, 0); return offset; @@ -1781,7 +1858,7 @@ dissect_bthci_evt_le_meta(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree_add_item(tree, hf_bthci_evt_le_peer_address_type, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; - offset = dissect_bd_addr(hf_bthci_evt_bd_addr, tree, tvb, offset, bd_addr); + offset = dissect_bd_addr(hf_bthci_evt_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, bd_addr); item = proto_tree_add_item(tree, hf_bthci_evt_le_con_interval, tvb, offset, 2, ENC_LITTLE_ENDIAN); proto_item_append_text(item, " (%g msec)", tvb_get_letohs(tvb, offset)*1.25); @@ -1852,7 +1929,7 @@ dissect_bthci_evt_le_meta(tvbuff_t *tvb, int offset, packet_info *pinfo, offset += 1; proto_tree_add_item(tree, hf_bthci_evt_le_peer_address_type, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; - offset = dissect_bd_addr(hf_bthci_evt_bd_addr, tree, tvb, offset, bd_addr); + offset = dissect_bd_addr(hf_bthci_evt_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, bd_addr); length = tvb_get_guint8(tvb, offset); proto_tree_add_item(tree, hf_bthci_evt_data_length, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; @@ -2071,7 +2148,7 @@ dissect_bthci_evt_amp_status_change(tvbuff_t *tvb, int offset, packet_info *pinf static int dissect_bthci_evt_command_complete(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *main_tree, proto_tree *tree, - wmem_list_t *opcode_list, bluetooth_data_t *bluetooth_data) + wmem_list_t *opcode_list, bluetooth_data_t *bluetooth_data, guint32 *out_opcode) { proto_item *ti_opcode; proto_tree *opcode_tree; @@ -2096,6 +2173,8 @@ dissect_bthci_evt_command_complete(tvbuff_t *tvb, int offset, opcode = tvb_get_letohs(tvb, offset); ogf = opcode >> 10; + if (out_opcode) + *out_opcode = opcode; interface_id = bluetooth_data->interface_id; adapter_id = bluetooth_data->adapter_id; @@ -2230,6 +2309,7 @@ dissect_bthci_evt_command_complete(tvbuff_t *tvb, int offset, /* This is a list of Commands that all return status and BD_ADDR */ case 0x1009: /* Read BD_ADDR */ local_addr = TRUE; + /* FALLTHROUGH */ case 0x0408: /* Create Connection Cancel */ case 0x040b: /* Link Key Request Reply */ @@ -2249,7 +2329,7 @@ dissect_bthci_evt_command_complete(tvbuff_t *tvb, int offset, proto_tree_add_item(tree, hf_bthci_evt_status, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; - offset = dissect_bd_addr(hf_bthci_evt_bd_addr, tree, tvb, offset, bd_addr); + offset = dissect_bd_addr(hf_bthci_evt_bd_addr, pinfo, tree, tvb, offset, local_addr, bluetooth_data->interface_id, bluetooth_data->adapter_id, bd_addr); if (!pinfo->fd->flags.visited && bluetooth_data != NULL && local_addr) { localhost_bdaddr_entry_t *localhost_bdaddr_entry; @@ -2273,6 +2353,24 @@ dissect_bthci_evt_command_complete(tvbuff_t *tvb, int offset, wmem_tree_insert32_array(bluetooth_data->localhost_bdaddr, key, localhost_bdaddr_entry); } + if (local_addr && have_tap_listener(bluetooth_device_tap)) { + bluetooth_device_tap_t *tap_device; + + tap_device = wmem_new(wmem_packet_scope(), bluetooth_device_tap_t); + if (bluetooth_data) { + tap_device->interface_id = bluetooth_data->interface_id; + tap_device->adapter_id = bluetooth_data->adapter_id; + } else { + tap_device->interface_id = HCI_INTERFACE_DEFAULT; + tap_device->adapter_id = HCI_ADAPTER_DEFAULT; + } + memcpy(tap_device->bd_addr, bd_addr, 6); + tap_device->has_bd_addr = TRUE; + tap_device->is_local = TRUE; + tap_device->type = BLUETOOTH_DEVICE_LOCAL_ADAPTER; + tap_queue_packet(bluetooth_device_tap, pinfo, tap_device); + } + break; /* This is a list of Commands that all return status and connection_handle */ @@ -2441,10 +2539,11 @@ dissect_bthci_evt_command_complete(tvbuff_t *tvb, int offset, case 0x0c14: /* Read Local Name */ proto_tree_add_item(tree, hf_bthci_evt_status, tvb, offset, 1, ENC_LITTLE_ENDIAN); + status = tvb_get_guint8(tvb, offset); offset += 1; proto_tree_add_item(tree, hf_bthci_evt_device_name, tvb, offset, 248, ENC_UTF_8|ENC_NA); - if (!pinfo->fd->flags.visited && bluetooth_data != NULL) { + if (status == STATUS_SUCCESS && !pinfo->fd->flags.visited && bluetooth_data != NULL) { gchar *name; localhost_name_entry_t *localhost_name_entry; @@ -2466,6 +2565,24 @@ dissect_bthci_evt_command_complete(tvbuff_t *tvb, int offset, wmem_tree_insert32_array(bluetooth_data->localhost_name, key, localhost_name_entry); } + + if (status == STATUS_SUCCESS && have_tap_listener(bluetooth_device_tap)) { + bluetooth_device_tap_t *tap_device; + + tap_device = wmem_new(wmem_packet_scope(), bluetooth_device_tap_t); + if (bluetooth_data) { + tap_device->interface_id = bluetooth_data->interface_id; + tap_device->adapter_id = bluetooth_data->adapter_id; + } else { + tap_device->interface_id = HCI_INTERFACE_DEFAULT; + tap_device->adapter_id = HCI_ADAPTER_DEFAULT; + } + tap_device->has_bd_addr = FALSE; + tap_device->is_local = TRUE; + tap_device->type = BLUETOOTH_DEVICE_NAME; + tap_device->data.name = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 248, ENC_UTF_8); + tap_queue_packet(bluetooth_device_tap, pinfo, tap_device); + } offset += 248; break; @@ -2737,7 +2854,7 @@ dissect_bthci_evt_command_complete(tvbuff_t *tvb, int offset, status = tvb_get_guint8(tvb, offset); offset += 1; - proto_tree_add_item(tree, hf_bthci_evt_hci_vers_nr, tvb, offset, 1, ENC_LITTLE_ENDIAN); + proto_tree_add_item(tree, hf_bthci_bthci_evt_hci_version, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; hci_revision_item = proto_tree_add_item(tree, hf_bthci_evt_hci_revision, tvb, offset, 2, ENC_LITTLE_ENDIAN); @@ -2766,11 +2883,32 @@ dissect_bthci_evt_command_complete(tvbuff_t *tvb, int offset, key[2].key = NULL; hci_vendor_data = (hci_vendor_data_t *) wmem_tree_lookup32_array(bluetooth_data->hci_vendors, key); - - hci_revision = tvb_get_letohs(tvb, offset - 7); - manufacturer = tvb_get_letohs(tvb, offset - 4); + hci_revision = tvb_get_letohs(tvb, offset - 7); + manufacturer = tvb_get_letohs(tvb, offset - 4); lmp_subversion = tvb_get_letohs(tvb, offset - 2); + if (have_tap_listener(bluetooth_device_tap)) { + bluetooth_device_tap_t *tap_device; + guint8 hci_version; + guint8 lmp_version; + + hci_version = tvb_get_guint8(tvb, offset - 8); + lmp_version = tvb_get_guint8(tvb, offset - 5); + + tap_device = wmem_new(wmem_packet_scope(), bluetooth_device_tap_t); + tap_device->type = BLUETOOTH_DEVICE_LOCAL_VERSION; + tap_device->interface_id = interface_id; + tap_device->adapter_id = adapter_id; + tap_device->has_bd_addr = FALSE; + tap_device->is_local = TRUE; + tap_device->data.local_version.hci_version = hci_version; + tap_device->data.local_version.hci_revision = hci_revision; + tap_device->data.local_version.lmp_version = lmp_version; + tap_device->data.local_version.lmp_subversion = lmp_subversion; + tap_device->data.local_version.manufacturer = manufacturer; + tap_queue_packet(bluetooth_device_tap, pinfo, tap_device); + } + if (hci_vendor_data) { proto_tree *sub_tree; proto_item *sub_item; @@ -3283,7 +3421,7 @@ dissect_bthci_evt_sync_connection_complete(tvbuff_t *tvb, int offset, connection_handle = tvb_get_letohs(tvb, offset) & 0x0FFF; offset += 2; - offset = dissect_bd_addr(hf_bthci_evt_bd_addr, tree, tvb, offset, bd_addr); + offset = dissect_bd_addr(hf_bthci_evt_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, bd_addr); proto_tree_add_item(tree, hf_bthci_evt_sync_link_type, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; @@ -3494,7 +3632,7 @@ dissect_bthci_evt_link_supervision_timeout_changed(tvbuff_t *tvb, int offset, pa } static int -dissect_bthci_evt_inquire_result(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree) +dissect_bthci_evt_inquire_result(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, bluetooth_data_t *bluetooth_data) { guint8 num, evt_num_responses; @@ -3503,7 +3641,7 @@ dissect_bthci_evt_inquire_result(tvbuff_t *tvb, int offset, packet_info *pinfo, offset += 1; for (num = 0; num < evt_num_responses; num++) { - offset = dissect_bd_addr(hf_bthci_evt_bd_addr, tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bthci_evt_bd_addr, pinfo, tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); proto_tree_add_item(tree, hf_bthci_evt_page_scan_repetition_mode, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; @@ -3540,6 +3678,7 @@ dissect_bthci_evt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat wmem_list_frame_t *opcode_list_frame; bthci_cmd_data_t *lastest_bthci_cmd_data = NULL; opcode_list_data_t *opcode_list_data; + guint32 opcode = G_MAXUINT32; /* Reject the packet if data is NULL */ if (data == NULL) @@ -3604,7 +3743,7 @@ dissect_bthci_evt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat break; case 0x02: /* Inquiry result event */ - offset = dissect_bthci_evt_inquire_result(tvb, offset, pinfo, bthci_evt_tree); + offset = dissect_bthci_evt_inquire_result(tvb, offset, pinfo, bthci_evt_tree, bluetooth_data); break; case 0x03: /* Connection Complete */ @@ -3616,7 +3755,7 @@ dissect_bthci_evt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat break; case 0x04: /* Connection Request */ - offset = dissect_bthci_evt_connect_request(tvb, offset, pinfo, bthci_evt_tree); + offset = dissect_bthci_evt_connect_request(tvb, offset, pinfo, bthci_evt_tree, bluetooth_data); break; case 0x05: /* Disconnection Complete */ @@ -3654,7 +3793,7 @@ dissect_bthci_evt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat break; case 0x0c: /* Read Remote Version Information Complete */ - offset = dissect_bthci_evt_read_remote_version_information_complete(tvb, offset, pinfo, bthci_evt_tree); + offset = dissect_bthci_evt_read_remote_version_information_complete(tvb, offset, pinfo, bluetooth_data, bthci_evt_tree); add_opcode(opcode_list, 0x41D, COMMAND_STATUS_NORMAL); /* Read Remote Version Information */ break; @@ -3663,7 +3802,7 @@ dissect_bthci_evt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat break; case 0x0e: /* Command Complete */ - offset = dissect_bthci_evt_command_complete(tvb, offset, pinfo, tree, bthci_evt_tree, opcode_list, bluetooth_data); + offset = dissect_bthci_evt_command_complete(tvb, offset, pinfo, tree, bthci_evt_tree, opcode_list, bluetooth_data, &opcode); add_opcode(opcode_list, 0x0429, COMMAND_STATUS_NORMAL); /* Accept Synchronous Connection Request */ break; @@ -3695,19 +3834,19 @@ dissect_bthci_evt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat break; case 0x15: /* Return Link Keys */ - offset = dissect_bthci_evt_return_link_keys(tvb, offset, pinfo, bthci_evt_tree); + offset = dissect_bthci_evt_return_link_keys(tvb, offset, pinfo, bthci_evt_tree, bluetooth_data); break; case 0x16: /* PIN Code Request */ - offset = dissect_bthci_evt_pin_code_request(tvb, offset, pinfo, bthci_evt_tree); + offset = dissect_bthci_evt_pin_code_request(tvb, offset, pinfo, bthci_evt_tree, bluetooth_data); break; case 0x17: /* Link Key Request */ - offset = dissect_bthci_evt_link_key_request(tvb, offset, pinfo, bthci_evt_tree); + offset = dissect_bthci_evt_link_key_request(tvb, offset, pinfo, bthci_evt_tree, bluetooth_data); break; case 0x18: /* Link Key Notification */ - offset = dissect_bthci_evt_link_key_notification(tvb, offset, pinfo, bthci_evt_tree); + offset = dissect_bthci_evt_link_key_notification(tvb, offset, pinfo, bthci_evt_tree, bluetooth_data); break; case 0x19: /* Loopback Command */ @@ -3736,11 +3875,11 @@ dissect_bthci_evt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat break; case 0x1f: /* Page Scan Mode Change */ - offset = dissect_bthci_evt_page_scan_mode_change(tvb, offset, pinfo, bthci_evt_tree); + offset = dissect_bthci_evt_page_scan_mode_change(tvb, offset, pinfo, bthci_evt_tree, bluetooth_data); break; case 0x20: /* Page Scan Repetition Mode Change */ - offset = dissect_bthci_evt_page_scan_repetition_mode_change(tvb, offset, pinfo, bthci_evt_tree); + offset = dissect_bthci_evt_page_scan_repetition_mode_change(tvb, offset, pinfo, bthci_evt_tree, bluetooth_data); break; case 0x21: /* Flow Specification Complete */ @@ -3748,7 +3887,7 @@ dissect_bthci_evt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat break; case 0x22: /* Inquiry Result with RSSI */ - offset = dissect_bthci_evt_inquire_result_with_rssi(tvb, offset, pinfo, bthci_evt_tree, NULL); + offset = dissect_bthci_evt_inquire_result_with_rssi(tvb, offset, pinfo, bthci_evt_tree, bluetooth_data, NULL); break; case 0x23: /* Read Remote Extended Features Complete */ @@ -3775,7 +3914,7 @@ dissect_bthci_evt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat case 0x2f: /* Extended Inquiry Result */ previous_offset = offset; - offset = dissect_bthci_evt_inquire_result_with_rssi(tvb, offset, pinfo, bthci_evt_tree, bd_addr); + offset = dissect_bthci_evt_inquire_result_with_rssi(tvb, offset, pinfo, bthci_evt_tree, bluetooth_data, bd_addr); call_dissector(btcommon_eir_handle, tvb_new_subset_length(tvb, offset, 240), pinfo, bthci_evt_tree); save_remote_device_name(tvb, offset, pinfo, 240, (offset - previous_offset <= 1) ? NULL : bd_addr, bluetooth_data); @@ -3789,27 +3928,27 @@ dissect_bthci_evt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat break; case 0x31: /* IO Capability Request */ - offset = dissect_bthci_evt_io_capability_request(tvb, offset, pinfo, bthci_evt_tree); + offset = dissect_bthci_evt_io_capability_request(tvb, offset, pinfo, bthci_evt_tree, bluetooth_data); break; case 0x32: /* IO Capability Response */ - offset = dissect_bthci_evt_io_capability_response(tvb, offset, pinfo, bthci_evt_tree); + offset = dissect_bthci_evt_io_capability_response(tvb, offset, pinfo, bthci_evt_tree, bluetooth_data); break; case 0x33: /* User Confirmation Request */ - offset = dissect_bthci_evt_user_confirmation_request(tvb, offset, pinfo, bthci_evt_tree); + offset = dissect_bthci_evt_user_confirmation_request(tvb, offset, pinfo, bthci_evt_tree, bluetooth_data); break; case 0x34: /* User Passkey Request */ - offset = dissect_bthci_evt_user_passkey_request(tvb, offset, pinfo, bthci_evt_tree); + offset = dissect_bthci_evt_user_passkey_request(tvb, offset, pinfo, bthci_evt_tree, bluetooth_data); break; case 0x35: /* Remote OOB Data Request */ - offset = dissect_bthci_evt_remote_oob_data_request(tvb, offset, pinfo, bthci_evt_tree); + offset = dissect_bthci_evt_remote_oob_data_request(tvb, offset, pinfo, bthci_evt_tree, bluetooth_data); break; case 0x36: /* Simple Pairing Complete */ - offset = dissect_bthci_evt_simple_pairing_complete(tvb, offset, pinfo, bthci_evt_tree); + offset = dissect_bthci_evt_simple_pairing_complete(tvb, offset, pinfo, bthci_evt_tree, bluetooth_data); break; case 0x38: /* Link Supervision Timeout Changed */ @@ -3821,15 +3960,15 @@ dissect_bthci_evt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat break; case 0x3b: /* Enhanced Flush Complete */ - offset = dissect_bthci_evt_user_passkey_notification(tvb, offset, pinfo, bthci_evt_tree); + offset = dissect_bthci_evt_user_passkey_notification(tvb, offset, pinfo, bthci_evt_tree, bluetooth_data); break; case 0x3c: /* Enhanced Flush Complete */ - offset = dissect_bthci_evt_keypress_notification(tvb, offset, pinfo, bthci_evt_tree); + offset = dissect_bthci_evt_keypress_notification(tvb, offset, pinfo, bthci_evt_tree, bluetooth_data); break; case 0x3d: /* Remote Host Supported Features Notification */ - offset = dissect_bthci_evt_remote_host_sup_feat_notification(tvb, offset, pinfo, bthci_evt_tree); + offset = dissect_bthci_evt_remote_host_sup_feat_notification(tvb, offset, pinfo, bthci_evt_tree, bluetooth_data); break; case 0x3e: /* LE Meta */ @@ -3934,7 +4073,6 @@ dissect_bthci_evt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat offset += tvb_reported_length_remaining(tvb, offset); break; } - } opcode_list_frame = wmem_list_head(opcode_list); @@ -3943,7 +4081,6 @@ dissect_bthci_evt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat wmem_tree_key_t key[4]; guint32 interface_id; guint32 adapter_id; - guint32 opcode; guint32 frame_number; bthci_cmd_data_t *bthci_cmd_data; wmem_tree_t *subtree; @@ -4016,6 +4153,59 @@ dissect_bthci_evt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat frame_number = pinfo->fd->num; + if (opcode != G_MAXUINT32 && opcode >> 10 != HCI_OGF_VENDOR_SPECIFIC) { + guint8 status; + + switch(opcode) { + case 0x0c13: /* Change Local Name */ + status = tvb_get_guint8(tvb, 5); + + if (status == STATUS_SUCCESS && have_tap_listener(bluetooth_device_tap)) { + bluetooth_device_tap_t *tap_device; + + tap_device = wmem_new(wmem_packet_scope(), bluetooth_device_tap_t); + if (bluetooth_data) { + tap_device->interface_id = bluetooth_data->interface_id; + tap_device->adapter_id = bluetooth_data->adapter_id; + } else { + tap_device->interface_id = HCI_INTERFACE_DEFAULT; + tap_device->adapter_id = HCI_ADAPTER_DEFAULT; + } + tap_device->has_bd_addr = FALSE; + tap_device->is_local = TRUE; + tap_device->type = BLUETOOTH_DEVICE_NAME; + tap_device->data.name = lastest_bthci_cmd_data->data.name; + tap_queue_packet(bluetooth_device_tap, pinfo, tap_device); + } + if (status == STATUS_SUCCESS && !pinfo->fd->flags.visited && bluetooth_data) { + localhost_name_entry_t *localhost_name_entry; + wmem_tree_key_t key[4]; + guint32 interface_id; + guint32 adapter_id; + + interface_id = bluetooth_data->interface_id; + adapter_id = bluetooth_data->adapter_id; + + key[0].length = 1; + key[0].key = &interface_id; + key[1].length = 1; + key[1].key = &adapter_id; + key[2].length = 1; + key[2].key = &frame_number; + key[3].length = 0; + key[3].key = NULL; + + localhost_name_entry = (localhost_name_entry_t *) wmem_new(wmem_file_scope(), localhost_name_entry_t); + localhost_name_entry->interface_id = interface_id; + localhost_name_entry->adapter_id = adapter_id; + localhost_name_entry->name = lastest_bthci_cmd_data->data.name; + + wmem_tree_insert32_array(bluetooth_data->localhost_name, key, localhost_name_entry); + } + break; + } + } + if (!pinfo->fd->flags.visited && opcode_list_data->command_status == COMMAND_STATUS_PENDING && lastest_bthci_cmd_data->pending_in_frame == max_disconnect_in_frame) { lastest_bthci_cmd_data->pending_in_frame = frame_number; @@ -4231,12 +4421,12 @@ proto_register_bthci_evt(void) }, { &hf_bthci_evt_vers_nr, { "LMP Version", "bthci_evt.lmp_vers_nr", - FT_UINT8, BASE_HEX, VALS(evt_lmp_vers_nr), 0x0, + FT_UINT8, BASE_HEX, VALS(bthci_evt_lmp_version), 0x0, "Version of the Current LMP", HFILL } }, - { &hf_bthci_evt_hci_vers_nr, + { &hf_bthci_bthci_evt_hci_version, { "HCI Version", "bthci_evt.hci_vers_nr", - FT_UINT8, BASE_HEX, VALS(evt_hci_vers_nr), 0x0, + FT_UINT8, BASE_HEX, VALS(bthci_evt_hci_version), 0x0, "Version of the Current HCI", HFILL } }, { &hf_bthci_evt_hci_revision, diff --git a/epan/dissectors/packet-bthci_evt.h b/epan/dissectors/packet-bthci_evt.h index 5df9dad563..402c8121d3 100644 --- a/epan/dissectors/packet-bthci_evt.h +++ b/epan/dissectors/packet-bthci_evt.h @@ -24,6 +24,17 @@ extern value_string_ext bthci_evt_evt_code_vals_ext; +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +WS_DLL_PUBLIC const value_string bthci_evt_lmp_version[]; +WS_DLL_PUBLIC const value_string bthci_evt_hci_version[]; + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + #endif /* diff --git a/epan/dissectors/packet-bthci_vendor.c b/epan/dissectors/packet-bthci_vendor.c index d2fbcc43da..62e82d4425 100644 --- a/epan/dissectors/packet-bthci_vendor.c +++ b/epan/dissectors/packet-bthci_vendor.c @@ -401,7 +401,7 @@ dissect_bthci_vendor_broadcom(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre switch(ocf) { case 0x0001: /* Write BDADDR */ - offset = dissect_bd_addr(hf_bd_addr, main_tree, tvb, offset, bd_addr); + offset = dissect_bd_addr(hf_bd_addr, pinfo, main_tree, tvb, offset, TRUE, bluetooth_data->interface_id, bluetooth_data->adapter_id, bd_addr); /* TODO: This is command, but in respose (event Command Complete) there is a status for that, so write bdaddr can fail, but we store bdaddr as valid for now... */ @@ -582,12 +582,12 @@ dissect_bthci_vendor_broadcom(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre proto_tree_add_item(main_tree, hf_le_multi_advertising_address_type, tvb, offset, 1, ENC_NA); offset += 1; - offset = dissect_bd_addr(hf_bd_addr, main_tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bd_addr, pinfo, main_tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); proto_tree_add_item(main_tree, hf_le_multi_advertising_address_type, tvb, offset, 1, ENC_NA); offset += 1; - offset = dissect_bd_addr(hf_bd_addr, main_tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bd_addr, pinfo, main_tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); proto_tree_add_bitmask(main_tree, tvb, offset, hf_le_multi_advertising_channel_map, ett_channel_map, hfx_le_multi_advertising_channel_map, ENC_NA); offset += 1; @@ -613,7 +613,7 @@ dissect_bthci_vendor_broadcom(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre break; case 0x04: /* Set Random Address */ - offset = dissect_bd_addr(hf_bd_addr, main_tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bd_addr, pinfo, main_tree, tvb, offset, FALSE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); proto_tree_add_item(main_tree, hf_le_multi_advertising_instance_id, tvb, offset, 1, ENC_NA); offset += 1; diff --git a/epan/dissectors/packet-btle.c b/epan/dissectors/packet-btle.c index 91fd6d7f8d..08eaed3739 100644 --- a/epan/dissectors/packet-btle.c +++ b/epan/dissectors/packet-btle.c @@ -444,7 +444,7 @@ dissect_btle(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) case 0x00: /* ADV_IND */ case 0x02: /* ADV_NONCONN_IND */ case 0x06: /* ADV_SCAN_IND */ - offset = dissect_bd_addr(hf_advertising_address, btle_tree, tvb, offset, src_bd_addr); + offset = dissect_bd_addr(hf_advertising_address, pinfo, btle_tree, tvb, offset, TRUE, interface_id, adapter_id, src_bd_addr); SET_ADDRESS(&pinfo->net_src, AT_ETHER, 6, src_bd_addr); COPY_ADDRESS_SHALLOW(&pinfo->dl_src, &pinfo->net_src); @@ -475,8 +475,8 @@ dissect_btle(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) break; case 0x01: /* ADV_DIRECT_IND */ - offset = dissect_bd_addr(hf_advertising_address, btle_tree, tvb, offset, src_bd_addr); - offset = dissect_bd_addr(hf_initiator_addresss, btle_tree, tvb, offset, dst_bd_addr); + offset = dissect_bd_addr(hf_advertising_address, pinfo, btle_tree, tvb, offset, TRUE, interface_id, adapter_id, src_bd_addr); + offset = dissect_bd_addr(hf_initiator_addresss, pinfo, btle_tree, tvb, offset, FALSE, interface_id, adapter_id, dst_bd_addr); SET_ADDRESS(&pinfo->net_src, AT_ETHER, 6, src_bd_addr); COPY_ADDRESS_SHALLOW(&pinfo->dl_src, &pinfo->net_src); @@ -500,8 +500,8 @@ dissect_btle(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) break; case 0x03: /* SCAN_REQ */ - offset = dissect_bd_addr(hf_scanning_address, btle_tree, tvb, offset, src_bd_addr); - offset = dissect_bd_addr(hf_advertising_address, btle_tree, tvb, offset, dst_bd_addr); + offset = dissect_bd_addr(hf_scanning_address, pinfo, btle_tree, tvb, offset, TRUE, interface_id, adapter_id, src_bd_addr); + offset = dissect_bd_addr(hf_advertising_address, pinfo, btle_tree, tvb, offset, FALSE, interface_id, adapter_id, dst_bd_addr); SET_ADDRESS(&pinfo->net_src, AT_ETHER, 6, src_bd_addr); COPY_ADDRESS_SHALLOW(&pinfo->dl_src, &pinfo->net_src); @@ -525,7 +525,7 @@ dissect_btle(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) break; case 0x04: /* SCAN_RSP */ - offset = dissect_bd_addr(hf_advertising_address, btle_tree, tvb, offset, src_bd_addr); + offset = dissect_bd_addr(hf_advertising_address, pinfo, btle_tree, tvb, offset, TRUE, interface_id, adapter_id, src_bd_addr); SET_ADDRESS(&pinfo->net_src, AT_ETHER, 6, src_bd_addr); COPY_ADDRESS_SHALLOW(&pinfo->dl_src, &pinfo->net_src); @@ -559,8 +559,8 @@ dissect_btle(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) break; case 0x05: /* CONNECT_REQ */ - offset = dissect_bd_addr(hf_initiator_addresss, btle_tree, tvb, offset, src_bd_addr); - offset = dissect_bd_addr(hf_advertising_address, btle_tree, tvb, offset, dst_bd_addr); + offset = dissect_bd_addr(hf_initiator_addresss, pinfo, btle_tree, tvb, offset, FALSE, interface_id, adapter_id, src_bd_addr); + offset = dissect_bd_addr(hf_advertising_address, pinfo, btle_tree, tvb, offset, TRUE, interface_id, adapter_id, dst_bd_addr); SET_ADDRESS(&pinfo->net_src, AT_ETHER, 6, src_bd_addr); COPY_ADDRESS_SHALLOW(&pinfo->dl_src, &pinfo->net_src); diff --git a/epan/dissectors/packet-btobex.c b/epan/dissectors/packet-btobex.c index 79bb01461c..f8ea016a41 100644 --- a/epan/dissectors/packet-btobex.c +++ b/epan/dissectors/packet-btobex.c @@ -1778,6 +1778,28 @@ dissect_headers(proto_tree *tree, tvbuff_t *tvb, int offset, packet_info *pinfo, guint32 value; guint8 tag; gchar *str = NULL; + guint32 interface_id; + guint32 adapter_id; + guint32 chandle; + guint32 channel; + + if (is_obex_over_l2cap) { + btl2cap_data_t *l2cap_data; + + l2cap_data = (btl2cap_data_t *) data; + interface_id = l2cap_data->interface_id; + adapter_id = l2cap_data->adapter_id; + chandle = l2cap_data->chandle; + channel = l2cap_data->cid; + } else { + btrfcomm_data_t *rfcomm_data; + + rfcomm_data = (btrfcomm_data_t *) data; + interface_id = rfcomm_data->interface_id; + adapter_id = rfcomm_data->adapter_id; + chandle = rfcomm_data->chandle; + channel = rfcomm_data->dlci >> 1; + } if (tvb_reported_length_remaining(tvb, offset) > 0) { proto_item *hdrs; @@ -2017,10 +2039,7 @@ dissect_headers(proto_tree *tree, tvbuff_t *tvb, int offset, packet_info *pinfo, col_append_fstr(pinfo->cinfo, COL_INFO, " - %s", target_vals[i].strptr); if (!pinfo->fd->flags.visited) { obex_profile_data_t *obex_profile_data; - guint32 interface_id; - guint32 adapter_id; - guint32 chandle; - guint32 channel; + wmem_tree_key_t key[6]; guint32 k_interface_id; guint32 k_adapter_id; @@ -2028,24 +2047,6 @@ dissect_headers(proto_tree *tree, tvbuff_t *tvb, int offset, packet_info *pinfo, guint32 k_chandle; guint32 k_channel; - if (is_obex_over_l2cap) { - btl2cap_data_t *l2cap_data; - - l2cap_data = (btl2cap_data_t *) data; - interface_id = l2cap_data->interface_id; - adapter_id = l2cap_data->adapter_id; - chandle = l2cap_data->chandle; - channel = l2cap_data->cid; - } else { - btrfcomm_data_t *rfcomm_data; - - rfcomm_data = (btrfcomm_data_t *) data; - interface_id = rfcomm_data->interface_id; - adapter_id = rfcomm_data->adapter_id; - chandle = rfcomm_data->chandle; - channel = rfcomm_data->dlci >> 1; - } - k_interface_id = interface_id; k_adapter_id = adapter_id; k_chandle = chandle; @@ -2129,7 +2130,7 @@ dissect_headers(proto_tree *tree, tvbuff_t *tvb, int offset, packet_info *pinfo, switch (tag) { case 0x00: /* Device Address */ if (sub_parameter_length == 6) { - offset = dissect_bd_addr(hf_sender_bd_addr, parameter_tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_sender_bd_addr, pinfo, parameter_tree, tvb, offset, FALSE, interface_id, adapter_id, NULL); } else { proto_tree_add_item(parameter_tree, hf_session_parameter_data, tvb, offset, sub_parameter_length, ENC_NA); diff --git a/epan/dissectors/packet-btsmp.c b/epan/dissectors/packet-btsmp.c index 6fba3038d8..9fe5057c25 100644 --- a/epan/dissectors/packet-btsmp.c +++ b/epan/dissectors/packet-btsmp.c @@ -180,12 +180,25 @@ dissect_btsmp_key_dist(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree } static int -dissect_btsmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) +dissect_btsmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) { int offset = 0; proto_item *ti; proto_tree *st; guint8 opcode; + btl2cap_data_t *l2cap_data; + guint32 interface_id; + guint32 adapter_id; + + l2cap_data = (btl2cap_data_t *) data; + + if (l2cap_data) { + interface_id = l2cap_data->interface_id; + adapter_id = l2cap_data->adapter_id; + } else { + interface_id = HCI_INTERFACE_DEFAULT; + adapter_id = HCI_ADAPTER_DEFAULT; + } ti = proto_tree_add_item(tree, proto_btsmp, tvb, 0, tvb_captured_length(tvb), ENC_NA); st = proto_item_add_subtree(ti, ett_btsmp); @@ -271,7 +284,7 @@ dissect_btsmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U proto_tree_add_item(st, hf_address_type, tvb, offset, 1, ENC_NA); offset += 1; - offset = dissect_bd_addr(hf_bd_addr, st, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bd_addr, pinfo, st, tvb, offset, FALSE, interface_id, adapter_id, NULL); break; case 0x0a: /* Signing Information */ diff --git a/epan/dissectors/packet-hci_mon.c b/epan/dissectors/packet-hci_mon.c index ce0a089148..d803739a2b 100644 --- a/epan/dissectors/packet-hci_mon.c +++ b/epan/dissectors/packet-hci_mon.c @@ -199,7 +199,7 @@ dissect_hci_mon(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) proto_tree_add_item(hci_mon_tree, hf_type, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; - offset = dissect_bd_addr(hf_bd_addr, hci_mon_tree, tvb, offset, NULL); + offset = dissect_bd_addr(hf_bd_addr, pinfo, hci_mon_tree, tvb, offset, TRUE, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL); proto_tree_add_item(hci_mon_tree, hf_name, tvb, offset, 8, ENC_NA | ENC_ASCII); offset += 8; diff --git a/ui/qt/CMakeLists.txt b/ui/qt/CMakeLists.txt index 8a534b9bca..712c02e250 100644 --- a/ui/qt/CMakeLists.txt +++ b/ui/qt/CMakeLists.txt @@ -24,6 +24,7 @@ set(WIRESHARK_QT_HEADERS about_dialog.h bluetooth_att_server_attributes_dialog.h + bluetooth_devices_dialog.h accordion_frame.h byte_view_tab.h byte_view_text.h @@ -142,6 +143,7 @@ set(WIRESHARK_QT_SRC about_dialog.cpp accordion_frame.cpp bluetooth_att_server_attributes_dialog.cpp + bluetooth_devices_dialog.cpp byte_view_tab.cpp byte_view_text.cpp capture_file.cpp @@ -263,6 +265,7 @@ set(WIRESHARK_QT_FILES set(WIRESHARK_QT_UI about_dialog.ui bluetooth_att_server_attributes_dialog.ui + bluetooth_devices_dialog.ui capture_file_properties_dialog.ui capture_interfaces_dialog.ui capture_preferences_frame.ui diff --git a/ui/qt/Makefile.am b/ui/qt/Makefile.am index a0e2bc7055..1205b77f79 100644 --- a/ui/qt/Makefile.am +++ b/ui/qt/Makefile.am @@ -124,6 +124,8 @@ about_dialog.cpp about_dialog.h: ui_about_dialog.h bluetooth_att_server_attributes_dialog.cpp bluetooth_att_server_attributes_dialog.h: ui_bluetooth_att_server_attributes_dialog.h +bluetooth_devices_dialog.cpp bluetooth_devices_dialog.h: ui_bluetooth_devices_dialog.h + capture_file_properties_dialog.cpp capture_file_properties_dialog.h: ui_capture_file_properties_dialog.h capture_interfaces_dialog.cpp capture_interfaces_dialog.h: ui_capture_interfaces_dialog.h diff --git a/ui/qt/Makefile.common b/ui/qt/Makefile.common index a0396784a9..ac1335bf53 100644 --- a/ui/qt/Makefile.common +++ b/ui/qt/Makefile.common @@ -31,6 +31,7 @@ GENERATED_HEADER_FILES = NODIST_GENERATED_HEADER_FILES = \ ui_about_dialog.h \ ui_bluetooth_att_server_attributes_dialog.h \ + ui_bluetooth_devices_dialog.h \ ui_capture_file_properties_dialog.h \ ui_capture_interfaces_dialog.h \ ui_capture_preferences_frame.h \ @@ -125,6 +126,7 @@ MOC_HDRS = \ about_dialog.h \ accordion_frame.h \ bluetooth_att_server_attributes_dialog.h \ + bluetooth_devices_dialog.h \ byte_view_tab.h \ byte_view_text.h \ capture_file.h \ @@ -225,6 +227,7 @@ MOC_HDRS = \ UI_FILES = \ about_dialog.ui \ bluetooth_att_server_attributes_dialog.ui \ + bluetooth_devices_dialog.ui \ capture_file_properties_dialog.ui \ capture_interfaces_dialog.ui \ capture_preferences_frame.ui \ @@ -335,6 +338,7 @@ WIRESHARK_QT_SRC = \ about_dialog.cpp \ accordion_frame.cpp \ bluetooth_att_server_attributes_dialog.cpp \ + bluetooth_devices_dialog.cpp \ byte_view_tab.cpp \ byte_view_text.cpp \ capture_file.cpp \ diff --git a/ui/qt/Wireshark.pro b/ui/qt/Wireshark.pro index 4267e98601..9da9457968 100644 --- a/ui/qt/Wireshark.pro +++ b/ui/qt/Wireshark.pro @@ -207,6 +207,7 @@ HEADERS_WS_C = \ FORMS += \ about_dialog.ui \ bluetooth_att_server_attributes_dialog.ui \ + bluetooth_devices_dialog.ui \ capture_file_properties_dialog.ui \ capture_interfaces_dialog.ui \ capture_preferences_frame.ui \ @@ -269,6 +270,7 @@ HEADERS += $$HEADERS_WS_C \ about_dialog.h \ accordion_frame.h \ bluetooth_att_server_attributes_dialog.h \ + bluetooth_devices_dialog.h \ capture_file_properties_dialog.h \ capture_interfaces_dialog.h \ capture_preferences_frame.h \ @@ -613,6 +615,7 @@ SOURCES += \ about_dialog.cpp \ accordion_frame.cpp \ bluetooth_att_server_attributes_dialog.cpp \ + bluetooth_devices_dialog.cpp \ byte_view_tab.cpp \ byte_view_text.cpp \ capture_file.cpp \ diff --git a/ui/qt/bluetooth_devices_dialog.cpp b/ui/qt/bluetooth_devices_dialog.cpp new file mode 100644 index 0000000000..73efe791bb --- /dev/null +++ b/ui/qt/bluetooth_devices_dialog.cpp @@ -0,0 +1,412 @@ +/* bluetooth_devices_dialog.cpp + * + * Wireshark - Network traffic analyzer + * By Gerald Combs + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "bluetooth_devices_dialog.h" +#include "ui_bluetooth_devices_dialog.h" + +#include "epan/epan.h" +#include "epan/addr_resolv.h" +#include "epan/to_str.h" +#include "epan/epan_dissect.h" +#include "epan/dissectors/packet-bluetooth.h" +#include "epan/dissectors/packet-bthci_evt.h" + +#include "ui/simple_dialog.h" + +#include +#include +#include +#include +#include + +static const int column_number_bd_addr = 0; +static const int column_number_bd_addr_oui = 1; +static const int column_number_name = 2; +static const int column_number_lmp_version = 3; +static const int column_number_lmp_subversion = 4; +static const int column_number_manufacturer = 5; +static const int column_number_hci_version = 6; +static const int column_number_hci_revision = 7; +static const int column_number_is_local_adapter = 8; + +typedef struct _item_data_t { + guint32 interface_id; + guint32 adapter_id; + guint32 frame_number; +} item_data_t; + +Q_DECLARE_METATYPE(item_data_t *) + +static gboolean +bluetooth_device_tap_packet(void *tapinfo_ptr, packet_info *pinfo, epan_dissect_t *edt, const void* data) +{ + bluetooth_devices_tapinfo_t *tapinfo = (bluetooth_devices_tapinfo_t *) tapinfo_ptr; + + if (tapinfo->tap_packet) + tapinfo->tap_packet(tapinfo, pinfo, edt, data); + + return TRUE; +} + +static void +bluetooth_device_tap_reset(void *tapinfo_ptr) +{ + bluetooth_devices_tapinfo_t *tapinfo = (bluetooth_devices_tapinfo_t *) tapinfo_ptr; + + if (tapinfo->tap_reset) + tapinfo->tap_reset(tapinfo); +} + + +static void +bluetooth_devices_tap(void *data) +{ + GString *error_string; + + error_string = register_tap_listener("bluetooth.device", data, NULL, + 0, + bluetooth_device_tap_reset, + bluetooth_device_tap_packet, + NULL + ); + + if (error_string != NULL) { + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, + "%s", error_string->str); + g_string_free(error_string, TRUE); + } +} + + +BluetoothDevicesDialog::BluetoothDevicesDialog(QWidget &parent, CaptureFile &cf) : + WiresharkDialog(parent, cf), + ui(new Ui::BluetoothDevicesDialog) +{ + ui->setupUi(this); + resize(parent.width() * 4 / 5, parent.height() * 2 / 3); + + connect(ui->tableTreeWidget, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(tableContextMenu(const QPoint &))); + connect(ui->interfaceComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(interfaceCurrentIndexChanged(int))); + connect(ui->showInformationStepsCheckBox, SIGNAL(stateChanged(int)), this, SLOT(showInformationStepsChanged(int))); + + ui->tableTreeWidget->sortByColumn(column_number_bd_addr, Qt::AscendingOrder); + + context_menu_.addActions(QList() << ui->actionCopy_Cell); + context_menu_.addActions(QList() << ui->actionCopy_Rows); + context_menu_.addActions(QList() << ui->actionCopy_All); + context_menu_.addActions(QList() << ui->actionSave_as_image); + + tapinfo_.tap_packet = tapPacket; + tapinfo_.tap_reset = tapReset; + tapinfo_.ui = this; + + bluetooth_devices_tap(&tapinfo_); + + cap_file_.retapPackets(); +} + + +BluetoothDevicesDialog::~BluetoothDevicesDialog() +{ + delete ui; + + remove_tap_listener(&tapinfo_); +} + + +void BluetoothDevicesDialog::captureFileClosing() +{ + remove_tap_listener(&tapinfo_); + + ui->interfaceComboBox->setEnabled(FALSE); + ui->showInformationStepsCheckBox->setEnabled(FALSE); + + WiresharkDialog::captureFileClosing(); +} + + +void BluetoothDevicesDialog::changeEvent(QEvent *event) +{ + if (0 != event) + { + switch (event->type()) + { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } + } + QDialog::changeEvent(event); +} + + +void BluetoothDevicesDialog::tableContextMenu(const QPoint &pos) +{ + context_menu_.exec(ui->tableTreeWidget->viewport()->mapToGlobal(pos)); +} + + +void BluetoothDevicesDialog::on_actionCopy_Cell_triggered() +{ + QClipboard *clipboard = QApplication::clipboard(); + QString copy; + + copy = QString(ui->tableTreeWidget->currentItem()->text(ui->tableTreeWidget->currentColumn())); + + clipboard->setText(copy); +} + + +void BluetoothDevicesDialog::on_actionCopy_Rows_triggered() +{ + QClipboard *clipboard = QApplication::clipboard(); + QString copy; + QList items; + QList::iterator i_item; + + items = ui->tableTreeWidget->selectedItems(); + + for (i_item = items.begin(); i_item != items.end(); ++i_item) { + copy += QString("%1 %2 %3 %4 %5 %6 %7 %8 %9\n") + .arg((*i_item)->text(column_number_bd_addr), -20) + .arg((*i_item)->text(column_number_bd_addr_oui), -20) + .arg((*i_item)->text(column_number_name), -30) + .arg((*i_item)->text(column_number_lmp_version), -20) + .arg((*i_item)->text(column_number_lmp_subversion), -20) + .arg((*i_item)->text(column_number_manufacturer), -30) + .arg((*i_item)->text(column_number_hci_version), -20) + .arg((*i_item)->text(column_number_hci_revision), -20) + .arg((*i_item)->text(column_number_is_local_adapter), -20); + } + + clipboard->setText(copy); +} + +void BluetoothDevicesDialog::tapReset(void *tapinfo_ptr ) +{ + bluetooth_devices_tapinfo_t *tapinfo = (bluetooth_devices_tapinfo_t *) tapinfo_ptr; + BluetoothDevicesDialog *bluetooth_devices_dialog = static_cast(tapinfo->ui); + + + bluetooth_devices_dialog->ui->tableTreeWidget->clear(); +} + +gboolean BluetoothDevicesDialog::tapPacket(void *tapinfo_ptr, packet_info *pinfo, epan_dissect_t *, const void *data) +{ + bluetooth_devices_tapinfo_t *tapinfo = static_cast(tapinfo_ptr); + BluetoothDevicesDialog *dialog = static_cast(tapinfo->ui); + bluetooth_device_tap_t *tap_device = static_cast(const_cast(data)); + QString bd_addr; + QString bd_addr_oui; + QString name; + const gchar *manuf; + QTreeWidgetItem *item = NULL; + + if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID) { + gchar *interface; + const char *interface_name; + + interface_name = epan_get_interface_name(pinfo->epan, pinfo->phdr->interface_id); + interface = wmem_strdup_printf(wmem_packet_scope(), "%u: %s", pinfo->phdr->interface_id, interface_name); + + if (dialog->ui->interfaceComboBox->findText(interface) == -1) + dialog->ui->interfaceComboBox->addItem(interface); + + if (interface && dialog->ui->interfaceComboBox->currentIndex() > 0) { + if (dialog->ui->interfaceComboBox->currentText() != interface) + return TRUE; + } + } + + if (tap_device->has_bd_addr) { + bd_addr.sprintf("%02x:%02x:%02x:%02x:%02x:%02x", tap_device->bd_addr[0], tap_device->bd_addr[1], tap_device->bd_addr[2], tap_device->bd_addr[3], tap_device->bd_addr[4], tap_device->bd_addr[5]); + + manuf = get_ether_name(tap_device->bd_addr); + if (manuf) { + int pos; + + bd_addr_oui = QString(manuf); + pos = bd_addr_oui.indexOf('_'); + if (pos < 0) { + manuf = NULL; + } else { + bd_addr_oui.remove(pos, bd_addr_oui.size()); + } + } + + if (!manuf) + bd_addr_oui = ""; + } + + if (dialog->ui->showInformationStepsCheckBox->checkState() != Qt::Checked) { + QTreeWidgetItemIterator i_item(dialog->ui->tableTreeWidget); + + while (*i_item) { + QTreeWidgetItem *current_item = static_cast(*i_item); + item_data_t *item_data = current_item->data(0, Qt::UserRole).value(); + + if ((tap_device->has_bd_addr && current_item->text(column_number_bd_addr) == bd_addr) || + (tap_device->is_local && + item_data->interface_id == tap_device->interface_id && + item_data->adapter_id == tap_device->adapter_id && + !current_item->text(column_number_is_local_adapter).isEmpty())) { + item = current_item; + break; + } + i_item += 1; + } + } + + if (!item) { + item = new QTreeWidgetItem(dialog->ui->tableTreeWidget); + item->setText(column_number_bd_addr, bd_addr); + item->setText(column_number_bd_addr_oui, bd_addr_oui); + if (tap_device->is_local) { + item->setText(column_number_is_local_adapter, tr("true")); + } + + item_data_t *item_data = wmem_new(wmem_file_scope(), item_data_t); + item_data->interface_id = tap_device->interface_id; + item_data->adapter_id = tap_device->adapter_id; + item_data->frame_number = pinfo->fd->num; + item->setData(0, Qt::UserRole, QVariant::fromValue(item_data)); + } + + if (tap_device->type == BLUETOOTH_DEVICE_BD_ADDR) { + item->setText(column_number_bd_addr, bd_addr); + item->setText(column_number_bd_addr_oui, bd_addr_oui); + } + + if (tap_device->type == BLUETOOTH_DEVICE_NAME) + item->setText(column_number_name, tap_device->data.name); + + if (tap_device->type == BLUETOOTH_DEVICE_LOCAL_ADAPTER) + item->setText(column_number_is_local_adapter, tr("true")); + + if (tap_device->type == BLUETOOTH_DEVICE_LOCAL_VERSION) { + item->setText(column_number_hci_version, val_to_str_const(tap_device->data.local_version.hci_version, bthci_evt_hci_version, "Unknown 0x%02x")); + item->setText(column_number_hci_revision, QString("").sprintf("%u", tap_device->data.local_version.hci_revision)); + item->setText(column_number_lmp_version, val_to_str_const(tap_device->data.local_version.lmp_version, bthci_evt_lmp_version, "Unknown 0x%02x")); + item->setText(column_number_lmp_subversion, QString("").sprintf("%u", tap_device->data.local_version.lmp_subversion)); + item->setText(column_number_manufacturer, val_to_str_ext_const(tap_device->data.local_version.manufacturer, &bluetooth_company_id_vals_ext, "Unknown 0x%04x")); + } + if (tap_device->type == BLUETOOTH_DEVICE_REMOTE_VERSION) { + item->setText(column_number_lmp_version, val_to_str_const(tap_device->data.remote_version.lmp_version, bthci_evt_lmp_version, "Unknown 0x%02x")); + item->setText(column_number_lmp_subversion, QString("").sprintf("%u", tap_device->data.remote_version.lmp_subversion)); + item->setText(column_number_manufacturer, val_to_str_ext_const(tap_device->data.remote_version.manufacturer, &bluetooth_company_id_vals_ext, "Unknown 0x%04x")); + } + + for (int i = 0; i < dialog->ui->tableTreeWidget->columnCount(); i++) { + dialog->ui->tableTreeWidget->resizeColumnToContents(i); + } + + return TRUE; +} + +void BluetoothDevicesDialog::interfaceCurrentIndexChanged(int) +{ + cap_file_.retapPackets(); +} + +void BluetoothDevicesDialog::showInformationStepsChanged(int) +{ + cap_file_.retapPackets(); +} + +void BluetoothDevicesDialog::on_tableTreeWidget_itemActivated(QTreeWidgetItem *item, int) +{ + if (!cap_file_.isValid()) + return; + + item_data_t *item_data = item->data(0, Qt::UserRole).value(); + + emit goToPacket(item_data->frame_number); + +} + +void BluetoothDevicesDialog::on_actionCopy_All_triggered() +{ + QClipboard *clipboard = QApplication::clipboard(); + QString copy; + QTreeWidgetItemIterator i_item(ui->tableTreeWidget); + + copy += QString("%1 %2 %3 %4 %5 %6 %7 %8 %9\n") + .arg(ui->tableTreeWidget->headerItem()->text(column_number_bd_addr), -20) + .arg(ui->tableTreeWidget->headerItem()->text(column_number_bd_addr_oui), -20) + .arg(ui->tableTreeWidget->headerItem()->text(column_number_name), -30) + .arg(ui->tableTreeWidget->headerItem()->text(column_number_lmp_version), -20) + .arg(ui->tableTreeWidget->headerItem()->text(column_number_lmp_subversion), -20) + .arg(ui->tableTreeWidget->headerItem()->text(column_number_manufacturer), -30) + .arg(ui->tableTreeWidget->headerItem()->text(column_number_hci_version), -20) + .arg(ui->tableTreeWidget->headerItem()->text(column_number_hci_revision), -20) + .arg(ui->tableTreeWidget->headerItem()->text(column_number_is_local_adapter), -20); + + while (*i_item) { + QTreeWidgetItem *item = static_cast(*i_item); + copy += QString("%1 %2 %3 %4 %5 %6 %7 %8 %9\n") + .arg(item->text(column_number_bd_addr), -20) + .arg(item->text(column_number_bd_addr_oui), -20) + .arg(item->text(column_number_name), -30) + .arg(item->text(column_number_lmp_version), -20) + .arg(item->text(column_number_lmp_subversion), -20) + .arg(item->text(column_number_manufacturer), -30) + .arg(item->text(column_number_hci_version), -20) + .arg(item->text(column_number_hci_revision), -20) + .arg(item->text(column_number_is_local_adapter), -20); + i_item += 1; + } + + clipboard->setText(copy); +} + +void BluetoothDevicesDialog::on_actionSave_as_image_triggered() +{ + QPixmap image; + + QString fileName = QFileDialog::getSaveFileName(this, tr("Save Table Image"), + "bluetooth_devices_table.png", + tr("PNG Image (*.png)")); + + if (fileName.isEmpty()) return; + + image = QPixmap::grabWidget(ui->tableTreeWidget); + image.save(fileName, "PNG"); +} + +void BluetoothDevicesDialog::on_buttonBox_clicked(QAbstractButton *button _U_) +{ +/* if (button == foo_button_) */ +} + +/* + * Editor modelines + * + * Local Variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * ex: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ diff --git a/ui/qt/bluetooth_devices_dialog.h b/ui/qt/bluetooth_devices_dialog.h new file mode 100644 index 0000000000..e33328d988 --- /dev/null +++ b/ui/qt/bluetooth_devices_dialog.h @@ -0,0 +1,105 @@ +/* bluetooth_devices_dialog.h + * + * Wireshark - Network traffic analyzer + * By Gerald Combs + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef BLUETOOTH_DEVICES_DIALOG_H +#define BLUETOOTH_DEVICES_DIALOG_H + +#include "config.h" + +#include + +#include "wireshark_dialog.h" +#include "cfile.h" + +#include "epan/tap.h" + +#include + +class QAbstractButton; +class QPushButton; +class QTreeWidgetItem; + +typedef struct _bluetooth_devices_tapinfo_t { + tap_reset_cb tap_reset; + tap_packet_cb tap_packet; + void *ui; +} bluetooth_devices_tapinfo_t; + +namespace Ui { +class BluetoothDevicesDialog; +} + +class BluetoothDevicesDialog : public WiresharkDialog +{ + Q_OBJECT + +public: + explicit BluetoothDevicesDialog(QWidget &parent, CaptureFile &cf); + ~BluetoothDevicesDialog(); + +public slots: + +signals: + void updateFilter(QString &filter, bool force = false); + void captureFileChanged(capture_file *cf); + void goToPacket(int packet_num); + +protected: + +protected slots: + void changeEvent(QEvent* event); + +private: + Ui::BluetoothDevicesDialog *ui; + + bluetooth_devices_tapinfo_t tapinfo_; + QMenu context_menu_; + + static void tapReset(void *tapinfo_ptr); + static gboolean tapPacket(void *tapinfo_ptr, packet_info *pinfo, epan_dissect_t *, const void *data); + +private slots: + void captureFileClosing(); + void on_tableTreeWidget_itemActivated(QTreeWidgetItem *item, int); + void on_buttonBox_clicked(QAbstractButton *button); + void on_actionCopy_Cell_triggered(); + void on_actionCopy_Rows_triggered(); + void on_actionCopy_All_triggered(); + void on_actionSave_as_image_triggered(); + void tableContextMenu(const QPoint &pos); + void interfaceCurrentIndexChanged(int index); + void showInformationStepsChanged(int state); +}; + +#endif // BLUETOOTH_DEVICES_DIALOG_H + +/* + * Editor modelines + * + * Local Variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * ex: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ diff --git a/ui/qt/bluetooth_devices_dialog.ui b/ui/qt/bluetooth_devices_dialog.ui new file mode 100644 index 0000000000..e3a9dbe242 --- /dev/null +++ b/ui/qt/bluetooth_devices_dialog.ui @@ -0,0 +1,210 @@ + + + BluetoothDevicesDialog + + + + 0 + 0 + 880 + 477 + + + + + 0 + 0 + + + + Bluetooth Devices + + + + + + Qt::CustomContextMenu + + + QAbstractItemView::ExtendedSelection + + + Qt::ElideMiddle + + + false + + + false + + + true + + + false + + + false + + + true + + + + BD_ADDR + + + + + OUI + + + + + Name + + + + + LMP Version + + + + + LMP Subversion + + + + + Manufacturer + + + + + HCI Version + + + + + HCI Revision + + + + + Is Local Adapter + + + + + + + + -1 + + + QLayout::SetDefaultConstraint + + + 0 + + + + + + 0 + 0 + + + + + 350 + 0 + + + + + All Interfaces + + + + + + + + Show information steps + + + false + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Close + + + + + + + Copy Cell + + + + + Copy Rows + + + + + Copy All + + + + + Save as image + + + + + + + buttonBox + accepted() + BluetoothDevicesDialog + accept() + + + 374 + 407 + + + 374 + 214 + + + + + buttonBox + rejected() + BluetoothDevicesDialog + reject() + + + 374 + 407 + + + 374 + 214 + + + + + diff --git a/ui/qt/main_window.h b/ui/qt/main_window.h index cb50134d78..37431d4b61 100644 --- a/ui/qt/main_window.h +++ b/ui/qt/main_window.h @@ -485,6 +485,7 @@ private slots: void on_actionTelephonySipFlows_triggered(); void on_actionATT_Server_Attributes_triggered(); + void on_actionDevices_triggered(); void externalMenuItem_triggered(); diff --git a/ui/qt/main_window.ui b/ui/qt/main_window.ui index d0d8171e1f..de8489c108 100644 --- a/ui/qt/main_window.ui +++ b/ui/qt/main_window.ui @@ -528,6 +528,7 @@ &Bluetooth + @@ -2290,6 +2291,11 @@ Devices + + + Devices + + Services diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp index 200bd2704e..f24516c040 100644 --- a/ui/qt/main_window_slots.cpp +++ b/ui/qt/main_window_slots.cpp @@ -75,6 +75,7 @@ #include "about_dialog.h" #include "bluetooth_att_server_attributes_dialog.h" +#include "bluetooth_devices_dialog.h" #include "capture_file_dialog.h" #include "capture_file_properties_dialog.h" #include "coloring_rules_dialog.h" @@ -2805,6 +2806,16 @@ void MainWindow::on_actionATT_Server_Attributes_triggered() bluetooth_att_sever_attributes_dialog->show(); } +void MainWindow::on_actionDevices_triggered() +{ + BluetoothDevicesDialog *bluetooth_devices_dialog = new BluetoothDevicesDialog(*this, capture_file_); + connect(bluetooth_devices_dialog, SIGNAL(goToPacket(int)), + packet_list_, SLOT(goToPacket(int))); + connect(bluetooth_devices_dialog, SIGNAL(updateFilter(QString&, bool)), + this, SLOT(filterPackets(QString&, bool))); + bluetooth_devices_dialog->show(); +} + // Help Menu void MainWindow::on_actionHelpContents_triggered() {