aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorMichal Labedzki <michal.labedzki@tieto.com>2014-06-02 17:05:31 +0200
committerMichal Labedzki <michal.labedzki@tieto.com>2014-06-22 16:56:31 +0000
commit164af0050dd070109f4aaa5fdd3f23b41ebaa98d (patch)
tree9420e78e5c3bc815dccac097b812438841621bc3 /epan
parent58bbfa5ee3c3e0beaf16585735261d77bfd8dd79 (diff)
Bluetooth: Complete sessions
Some interfaces support multiple Bluetooth adapters with events like add/remove. We must support that to distinquish adapters streams in case that new adapter has the same id that old one. Next one is create session for "Connection Handle", so next layer will now when it is connected and disconnected. This is also used to distinguish streams. Change-Id: I9e062c8e4cc9c033b75f1a596e8351a215169843 Reviewed-on: https://code.wireshark.org/review/2548 Reviewed-by: Michal Labedzki <michal.labedzki@tieto.com>
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/packet-bluetooth-hci.h11
-rw-r--r--epan/dissectors/packet-bthci_acl.c48
-rw-r--r--epan/dissectors/packet-bthci_acl.h8
-rw-r--r--epan/dissectors/packet-bthci_evt.c52
-rw-r--r--epan/dissectors/packet-btl2cap.c25
-rw-r--r--epan/dissectors/packet-hci_h1.c7
-rw-r--r--epan/dissectors/packet-hci_h4.c7
-rw-r--r--epan/dissectors/packet-hci_mon.c67
-rw-r--r--epan/dissectors/packet-hci_usb.c7
9 files changed, 199 insertions, 33 deletions
diff --git a/epan/dissectors/packet-bluetooth-hci.h b/epan/dissectors/packet-bluetooth-hci.h
index 20b388274c..ded3d8eb66 100644
--- a/epan/dissectors/packet-bluetooth-hci.h
+++ b/epan/dissectors/packet-bluetooth-hci.h
@@ -100,14 +100,21 @@ extern const value_string bthci_cmd_notification_types[];
/* localhost_bdaddr: interface_id + adapter_id + frame_number -> bd_addr[6] */
/* localhost_name: interface_id + adapter_id + frame_number -> name */
typedef struct _hci_data_t {
- guint32 interface_id;
- guint32 adapter_id;
+ guint32 interface_id;
+ guint32 adapter_id;
+ guint32 *adapter_disconnect_in_frame;
+ wmem_tree_t *chandle_sessions;
wmem_tree_t *chandle_to_bdaddr_table;
wmem_tree_t *bdaddr_to_name_table;
wmem_tree_t *localhost_bdaddr;
wmem_tree_t *localhost_name;
} hci_data_t;
+typedef struct _chandle_session_t {
+ guint32 connect_in_frame;
+ guint32 disconnect_in_frame;
+} chandle_session_t;
+
typedef struct _remote_bdaddr_t {
guint32 interface_id;
guint32 adapter_id;
diff --git a/epan/dissectors/packet-bthci_acl.c b/epan/dissectors/packet-bthci_acl.c
index 9163706e99..09f927849d 100644
--- a/epan/dissectors/packet-bthci_acl.c
+++ b/epan/dissectors/packet-bthci_acl.c
@@ -44,6 +44,8 @@ static int hf_bthci_acl_length = -1;
static int hf_bthci_acl_data = -1;
static int hf_bthci_acl_continuation_to = -1;
static int hf_bthci_acl_reassembled_in = -1;
+static int hf_bthci_acl_connect_in = -1;
+static int hf_bthci_acl_disconnect_in = -1;
static int hf_bthci_acl_src_bd_addr = -1;
static int hf_bthci_acl_src_name = -1;
static int hf_bthci_acl_dst_bd_addr = -1;
@@ -85,6 +87,9 @@ static const value_string bc_flag_vals[] = {
{ 0, NULL }
};
+static guint32 max_disconnect_in_frame = G_MAXUINT32;
+
+
void proto_register_bthci_acl(void);
void proto_reg_handoff_bthci_acl(void);
@@ -126,6 +131,7 @@ dissect_bthci_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat
const guint8 *dst_bd_addr = &unknown_bd_addr[0];
const gchar *dst_name = "";
const gchar *dst_addr_name = "";
+ chandle_session_t *chandle_session;
/* Reject the packet if data is NULL */
if (data == NULL)
@@ -164,11 +170,10 @@ dissect_bthci_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat
frame_number = pinfo->fd->num;
acl_data = wmem_new(wmem_packet_scope(), bthci_acl_data_t);
- acl_data->interface_id = interface_id;
- acl_data->adapter_id = adapter_id;
- acl_data->chandle = connection_handle;
- acl_data->remote_bd_addr_oui = 0;
- acl_data->remote_bd_addr_id = 0;
+ acl_data->interface_id = interface_id;
+ acl_data->adapter_id = adapter_id;
+ acl_data->adapter_disconnect_in_frame = hci_data->adapter_disconnect_in_frame;
+ acl_data->chandle = connection_handle;
key[0].length = 1;
key[0].key = &interface_id;
@@ -179,6 +184,19 @@ dissect_bthci_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat
key[3].length = 0;
key[3].key = NULL;
+ subtree = (wmem_tree_t *) wmem_tree_lookup32_array(hci_data->chandle_sessions, key);
+ chandle_session = (subtree) ? (chandle_session_t *) wmem_tree_lookup32_le(subtree, pinfo->fd->num) : NULL;
+ if (chandle_session &&
+ chandle_session->connect_in_frame < pinfo->fd->num &&
+ chandle_session->disconnect_in_frame > pinfo->fd->num) {
+ acl_data->disconnect_in_frame = &chandle_session->disconnect_in_frame;
+ } else {
+ acl_data->disconnect_in_frame = &max_disconnect_in_frame;
+ }
+
+ acl_data->remote_bd_addr_oui = 0;
+ acl_data->remote_bd_addr_id = 0;
+
/* remote bdaddr and name */
subtree = (wmem_tree_t *) wmem_tree_lookup32_array(hci_data->chandle_to_bdaddr_table, key);
remote_bdaddr = (subtree) ? (remote_bdaddr_t *) wmem_tree_lookup32_le(subtree, pinfo->fd->num) : NULL;
@@ -399,6 +417,16 @@ dissect_bthci_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat
if (tvb_captured_length_remaining(tvb, offset) > 0)
proto_tree_add_item(bthci_acl_tree, hf_bthci_acl_data, tvb, offset, -1, ENC_NA);
+ if (chandle_session) {
+ sub_item = proto_tree_add_uint(bthci_acl_tree, hf_bthci_acl_connect_in, tvb, 0, 0, chandle_session->connect_in_frame);
+ PROTO_ITEM_SET_GENERATED(sub_item);
+
+ if (chandle_session->disconnect_in_frame < G_MAXUINT32) {
+ sub_item = proto_tree_add_uint(bthci_acl_tree, hf_bthci_acl_disconnect_in, tvb, 0, 0, chandle_session->disconnect_in_frame);
+ PROTO_ITEM_SET_GENERATED(sub_item);
+ }
+ }
+
SET_ADDRESS(&pinfo->net_src, AT_STRINGZ, (int)strlen(src_name) + 1, src_name);
SET_ADDRESS(&pinfo->dl_src, AT_ETHER, 6, src_bd_addr);
SET_ADDRESS(&pinfo->src, AT_STRINGZ, (int)strlen(src_addr_name) + 1, src_addr_name);
@@ -464,6 +492,16 @@ proto_register_bthci_acl(void)
FT_FRAMENUM, BASE_NONE, NULL, 0x0,
"This PDU is reassembled in frame #", HFILL }
},
+ { &hf_bthci_acl_connect_in,
+ { "Connect in frame", "bthci_acl.connect_in",
+ FT_FRAMENUM, BASE_NONE, NULL, 0x0,
+ NULL, HFILL }
+ },
+ { &hf_bthci_acl_disconnect_in,
+ { "Disconnect in frame", "bthci_acl.disconnect_in",
+ FT_FRAMENUM, BASE_NONE, NULL, 0x0,
+ NULL, HFILL }
+ },
{ &hf_bthci_acl_src_bd_addr,
{ "Source BD_ADDR", "bthci_acl.src.bd_addr",
FT_ETHER, BASE_NONE, NULL, 0x0,
diff --git a/epan/dissectors/packet-bthci_acl.h b/epan/dissectors/packet-bthci_acl.h
index 1de39846a1..421475ddd6 100644
--- a/epan/dissectors/packet-bthci_acl.h
+++ b/epan/dissectors/packet-bthci_acl.h
@@ -23,9 +23,11 @@
#define __PACKET_BTHCI_ACL_H__
typedef struct _bthci_acl_data_t {
- guint32 interface_id;
- guint32 adapter_id;
- guint16 chandle; /* only low 12 bits used */
+ guint32 interface_id;
+ guint32 adapter_id;
+ guint32 *adapter_disconnect_in_frame;
+ guint16 chandle; /* only low 12 bits used */
+ guint32 *disconnect_in_frame;
guint32 remote_bd_addr_oui;
guint32 remote_bd_addr_id;
diff --git a/epan/dissectors/packet-bthci_evt.c b/epan/dissectors/packet-bthci_evt.c
index 8faee73fa8..43da826e43 100644
--- a/epan/dissectors/packet-bthci_evt.c
+++ b/epan/dissectors/packet-bthci_evt.c
@@ -985,12 +985,13 @@ dissect_bthci_evt_conn_complete(tvbuff_t *tvb, int offset, packet_info *pinfo,
offset = dissect_bthci_evt_bd_addr(tvb, offset, pinfo, tree, bd_addr);
if (!pinfo->fd->flags.visited && hci_data != NULL && status == 0x00) {
- wmem_tree_key_t key[5];
- guint32 k_interface_id;
- guint32 k_adapter_id;
- guint32 k_connection_handle;
- guint32 k_frame_number;
- remote_bdaddr_t *remote_bdaddr;
+ wmem_tree_key_t key[5];
+ guint32 k_interface_id;
+ guint32 k_adapter_id;
+ guint32 k_connection_handle;
+ guint32 k_frame_number;
+ remote_bdaddr_t *remote_bdaddr;
+ chandle_session_t *chandle_session;
k_interface_id = hci_data->interface_id;
k_adapter_id = hci_data->adapter_id;
@@ -1015,6 +1016,11 @@ dissect_bthci_evt_conn_complete(tvbuff_t *tvb, int offset, packet_info *pinfo,
memcpy(remote_bdaddr->bd_addr, bd_addr, 6);
wmem_tree_insert32_array(hci_data->chandle_to_bdaddr_table, key, remote_bdaddr);
+
+ chandle_session = (chandle_session_t *) wmem_new(wmem_file_scope(), chandle_session_t);
+ chandle_session->connect_in_frame = k_frame_number;
+ chandle_session->disconnect_in_frame = G_MAXUINT32;
+ wmem_tree_insert32_array(hci_data->chandle_sessions, key, chandle_session);
}
@@ -1042,9 +1048,14 @@ dissect_bthci_evt_conn_request(tvbuff_t *tvb, int offset, packet_info *pinfo, pr
}
static int
-dissect_bthci_evt_disconn_complete(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
+dissect_bthci_evt_disconn_complete(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
+ proto_tree *tree, hci_data_t *hci_data)
{
+ guint32 connection_handle;
+ guint8 status;
+
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_connection_handle, tvb, offset, 2, ENC_LITTLE_ENDIAN);
@@ -1053,6 +1064,31 @@ dissect_bthci_evt_disconn_complete(tvbuff_t *tvb, int offset, packet_info *pinfo
proto_tree_add_item(tree, hf_bthci_evt_reason, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
+ if (!pinfo->fd->flags.visited && hci_data != NULL && status == 0x00) {
+ wmem_tree_key_t key[4];
+ guint32 interface_id;
+ guint32 adapter_id;
+ chandle_session_t *chandle_session;
+ wmem_tree_t *subtree;
+
+ interface_id = hci_data->interface_id;
+ adapter_id = hci_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 = &connection_handle;
+ key[3].length = 0;
+ key[3].key = NULL;
+
+ subtree = (wmem_tree_t *) wmem_tree_lookup32_array(hci_data->chandle_sessions, key);
+ chandle_session = (subtree) ? (chandle_session_t *) wmem_tree_lookup32_le(subtree, pinfo->fd->num) : NULL;
+ if (chandle_session && chandle_session->connect_in_frame < pinfo->fd->num)
+ chandle_session->disconnect_in_frame = pinfo->fd->num;
+ }
+
return offset;
}
@@ -3381,7 +3417,7 @@ dissect_bthci_evt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat
break;
case 0x05: /* Disconnection Complete */
- offset = dissect_bthci_evt_disconn_complete(tvb, offset, pinfo, bthci_evt_tree);
+ offset = dissect_bthci_evt_disconn_complete(tvb, offset, pinfo, bthci_evt_tree, hci_data);
break;
case 0x06: /* Authentication Complete */
diff --git a/epan/dissectors/packet-btl2cap.c b/epan/dissectors/packet-btl2cap.c
index f3895c35eb..d0266b01d2 100644
--- a/epan/dissectors/packet-btl2cap.c
+++ b/epan/dissectors/packet-btl2cap.c
@@ -1783,18 +1783,29 @@ dissect_btl2cap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
l2cap_data->interface_id = pinfo->phdr->interface_id;
else
l2cap_data->interface_id = HCI_INTERFACE_DEFAULT;
- l2cap_data->adapter_id = (acl_data) ? acl_data->adapter_id : HCI_ADAPTER_DEFAULT;
- l2cap_data->chandle = (acl_data) ? acl_data->chandle : 0;
+ if (acl_data) {
+ l2cap_data->adapter_id = acl_data->adapter_id;
+ l2cap_data->adapter_disconnect_in_frame = acl_data->adapter_disconnect_in_frame;
+ l2cap_data->chandle = acl_data->chandle;
+ l2cap_data->hci_disconnect_in_frame = acl_data->disconnect_in_frame;
+ l2cap_data->remote_bd_addr_oui = acl_data->remote_bd_addr_oui;
+ l2cap_data->remote_bd_addr_id = acl_data->remote_bd_addr_id;
+ } else {
+ l2cap_data->adapter_id = HCI_ADAPTER_DEFAULT;
+ l2cap_data->adapter_disconnect_in_frame = &max_disconnect_in_frame;
+ l2cap_data->chandle = 0;
+ l2cap_data->hci_disconnect_in_frame = &max_disconnect_in_frame;
+ l2cap_data->remote_bd_addr_oui = 0;
+ l2cap_data->remote_bd_addr_id = 0;
+ }
+
+ l2cap_data->disconnect_in_frame = &max_disconnect_in_frame;
+
l2cap_data->cid = cid;
l2cap_data->local_cid = BTL2CAP_UNKNOWN_CID;
l2cap_data->remote_cid = BTL2CAP_UNKNOWN_CID;
l2cap_data->is_local_psm = FALSE;
l2cap_data->psm = 0;
- l2cap_data->disconnect_in_frame = &max_disconnect_in_frame;
- l2cap_data->hci_disconnect_in_frame = &max_disconnect_in_frame;
- l2cap_data->adapter_disconnect_in_frame = &max_disconnect_in_frame;
- l2cap_data->remote_bd_addr_oui = (acl_data) ? acl_data->remote_bd_addr_oui : 0;
- l2cap_data->remote_bd_addr_id = (acl_data) ? acl_data->remote_bd_addr_id : 0;
if (cid == BTL2CAP_FIXED_CID_SIGNAL || cid == BTL2CAP_FIXED_CID_LE_SIGNAL) {
/* This is a command packet*/
diff --git a/epan/dissectors/packet-hci_h1.c b/epan/dissectors/packet-hci_h1.c
index ebfb3e1f9c..1e2ce5b6dd 100644
--- a/epan/dissectors/packet-hci_h1.c
+++ b/epan/dissectors/packet-hci_h1.c
@@ -40,6 +40,7 @@ static dissector_table_t hci_h1_table;
static dissector_handle_t hci_h1_handle;
static dissector_handle_t data_handle;
+static wmem_tree_t *chandle_sessions = NULL;
static wmem_tree_t *chandle_to_bdaddr_table = NULL;
static wmem_tree_t *bdaddr_to_name_table = NULL;
static wmem_tree_t *localhost_name = NULL;
@@ -59,6 +60,9 @@ static const value_string hci_h1_direction_vals[] = {
{0, NULL}
};
+static guint32 max_disconnect_in_frame = G_MAXUINT32;
+
+
void proto_register_hci_h1(void);
void proto_reg_handoff_hci_h1(void);
@@ -114,6 +118,8 @@ dissect_hci_h1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _
else
hci_data->interface_id = HCI_INTERFACE_DEFAULT;
hci_data->adapter_id = HCI_ADAPTER_DEFAULT;
+ hci_data->adapter_disconnect_in_frame = &max_disconnect_in_frame;
+ hci_data->chandle_sessions = chandle_sessions;
hci_data->chandle_to_bdaddr_table = chandle_to_bdaddr_table;
hci_data->bdaddr_to_name_table = bdaddr_to_name_table;
hci_data->localhost_bdaddr = localhost_bdaddr;
@@ -159,6 +165,7 @@ proto_register_hci_h1(void)
hci_h1_table = register_dissector_table("hci_h1.type",
"HCI h1 pdu type", FT_UINT8, BASE_HEX);
+ chandle_sessions = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope());
chandle_to_bdaddr_table = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); /* adapter, chandle: bdaddr */
bdaddr_to_name_table = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); /* bdaddr: name */
localhost_bdaddr = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); /* adapter, frame: bdaddr */
diff --git a/epan/dissectors/packet-hci_h4.c b/epan/dissectors/packet-hci_h4.c
index 0b734af790..5b2243b784 100644
--- a/epan/dissectors/packet-hci_h4.c
+++ b/epan/dissectors/packet-hci_h4.c
@@ -46,6 +46,7 @@ static dissector_handle_t hci_h4_handle;
static dissector_table_t hci_h4_table;
static dissector_handle_t data_handle;
+static wmem_tree_t *chandle_sessions = NULL;
static wmem_tree_t *chandle_to_bdaddr_table = NULL;
static wmem_tree_t *bdaddr_to_name_table = NULL;
static wmem_tree_t *localhost_name = NULL;
@@ -65,6 +66,9 @@ static const value_string hci_h4_direction_vals[] = {
{0, NULL}
};
+static guint32 max_disconnect_in_frame = G_MAXUINT32;
+
+
void proto_register_hci_h4(void);
void proto_reg_handoff_hci_h4(void);
@@ -110,6 +114,8 @@ dissect_hci_h4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _
else
hci_data->interface_id = HCI_INTERFACE_DEFAULT;
hci_data->adapter_id = HCI_ADAPTER_DEFAULT;
+ hci_data->adapter_disconnect_in_frame = &max_disconnect_in_frame;
+ hci_data->chandle_sessions = chandle_sessions;
hci_data->chandle_to_bdaddr_table = chandle_to_bdaddr_table;
hci_data->bdaddr_to_name_table = bdaddr_to_name_table;
hci_data->localhost_bdaddr = localhost_bdaddr;
@@ -165,6 +171,7 @@ proto_register_hci_h4(void)
hci_h4_table = register_dissector_table("hci_h4.type",
"HCI H4 pdu type", FT_UINT8, BASE_HEX);
+ chandle_sessions = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope());
chandle_to_bdaddr_table = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); /* adapter, chandle: bdaddr */
bdaddr_to_name_table = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); /* bdaddr: name */
localhost_bdaddr = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); /* adapter, frame: bdaddr */
diff --git a/epan/dissectors/packet-hci_mon.c b/epan/dissectors/packet-hci_mon.c
index 210733568e..986dc06e7c 100644
--- a/epan/dissectors/packet-hci_mon.c
+++ b/epan/dissectors/packet-hci_mon.c
@@ -45,6 +45,8 @@ static gint ett_hci_mon = -1;
static expert_field ei_unknown_data = EI_INIT;
+static wmem_tree_t *adapter_to_disconnect_in_frame = NULL;
+static wmem_tree_t *chandle_sessions = NULL;
static wmem_tree_t *chandle_to_bdaddr_table = NULL;
static wmem_tree_t *bdaddr_to_name_table = NULL;
static wmem_tree_t *localhost_name = NULL;
@@ -88,6 +90,8 @@ static const value_string bus_vals[] = {
};
static value_string_ext(bus_vals_ext) = VALUE_STRING_EXT_INIT(bus_vals);
+static guint32 max_disconnect_in_frame = G_MAXUINT32;
+
void proto_register_hci_mon(void);
void proto_reg_handoff_hci_mon(void);
@@ -95,14 +99,20 @@ void proto_reg_handoff_hci_mon(void);
static gint
dissect_hci_mon(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
- proto_tree *hci_mon_item;
- proto_item *hci_mon_tree;
- proto_item *sub_item;
- gint offset = 0;
- guint16 opcode;
- guint16 adapter_id;
- hci_data_t *hci_data;
- tvbuff_t *next_tvb;
+ proto_tree *hci_mon_item;
+ proto_item *hci_mon_tree;
+ proto_item *sub_item;
+ gint offset = 0;
+ guint16 opcode;
+ guint16 adapter_id;
+ hci_data_t *hci_data;
+ tvbuff_t *next_tvb;
+ guint32 *adapter_disconnect_in_frame;
+ wmem_tree_t *subtree;
+ wmem_tree_key_t key[4];
+ guint32 k_interface_id;
+ guint32 k_adapter_id;
+ guint32 k_frame_number;
adapter_id = pinfo->pseudo_header->btmon.adapter_id;
opcode = pinfo->pseudo_header->btmon.opcode;
@@ -145,17 +155,56 @@ dissect_hci_mon(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data
col_append_fstr(pinfo->cinfo, COL_INFO, "Adapter Id: %u, Opcode: %s",
adapter_id, val_to_str_ext_const(opcode, &opcode_vals_ext, "Unknown"));
+
hci_data = (hci_data_t *) wmem_new(wmem_packet_scope(), hci_data_t);
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
hci_data->interface_id = pinfo->phdr->interface_id;
else
hci_data->interface_id = HCI_INTERFACE_DEFAULT;
hci_data->adapter_id = adapter_id;
+ hci_data->chandle_sessions = chandle_sessions;
hci_data->chandle_to_bdaddr_table = chandle_to_bdaddr_table;
hci_data->bdaddr_to_name_table = bdaddr_to_name_table;
hci_data->localhost_bdaddr = localhost_bdaddr;
hci_data->localhost_name = localhost_name;
+ k_interface_id = hci_data->interface_id;
+ k_adapter_id = adapter_id;
+ k_frame_number = pinfo->fd->num;
+
+ key[0].length = 1;
+ key[0].key = &k_interface_id;
+ key[1].length = 1;
+ key[1].key = &k_adapter_id;
+
+ if (!pinfo->fd->flags.visited && opcode == 0x01) { /* Delete Index */
+ guint32 *disconnect_in_frame;
+
+ key[2].length = 1;
+ key[2].key = &k_frame_number;
+ key[3].length = 0;
+ key[3].key = NULL;
+
+ disconnect_in_frame = wmem_new(wmem_file_scope(), guint32);
+
+ if (disconnect_in_frame) {
+ *disconnect_in_frame = pinfo->fd->num;
+
+ wmem_tree_insert32_array(adapter_to_disconnect_in_frame, key, disconnect_in_frame);
+ }
+ }
+
+ key[2].length = 0;
+ key[2].key = NULL;
+
+ subtree = (wmem_tree_t *) wmem_tree_lookup32_array(adapter_to_disconnect_in_frame, key);
+ adapter_disconnect_in_frame = (subtree) ? (guint32 *) wmem_tree_lookup32_le(subtree, k_frame_number) : NULL;
+ if (adapter_disconnect_in_frame) {
+ hci_data->adapter_disconnect_in_frame = adapter_disconnect_in_frame;
+ } else {
+ hci_data->adapter_disconnect_in_frame = &max_disconnect_in_frame;
+ }
+
pinfo->ptype = PT_BLUETOOTH;
next_tvb = tvb_new_subset_remaining(tvb, offset);
@@ -262,6 +311,8 @@ proto_register_hci_mon(void)
&ett_hci_mon,
};
+ adapter_to_disconnect_in_frame = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope());
+ chandle_sessions = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope());
chandle_to_bdaddr_table = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); /* adapter, chandle: bdaddr */
bdaddr_to_name_table = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); /* bdaddr: name */
localhost_bdaddr = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); /* adapter, frame: bdaddr */
diff --git a/epan/dissectors/packet-hci_usb.c b/epan/dissectors/packet-hci_usb.c
index b2789ed1ee..d3b2cd7902 100644
--- a/epan/dissectors/packet-hci_usb.c
+++ b/epan/dissectors/packet-hci_usb.c
@@ -58,6 +58,7 @@ static int hf_msg_fragment_count = -1;
static int hf_msg_reassembled_in = -1;
static int hf_msg_reassembled_length = -1;
+static wmem_tree_t *chandle_sessions = NULL;
static wmem_tree_t *chandle_to_bdaddr_table = NULL;
static wmem_tree_t *bdaddr_to_name_table = NULL;
static wmem_tree_t *localhost_name = NULL;
@@ -108,6 +109,8 @@ static const value_string request_vals[] = {
};
static value_string_ext(request_vals_ext) = VALUE_STRING_EXT_INIT(request_vals);
+static guint32 max_disconnect_in_frame = G_MAXUINT32;
+
void proto_register_hci_usb(void);
void proto_reg_handoff_hci_usb(void);
@@ -176,6 +179,9 @@ dissect_hci_usb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
else
hci_data->interface_id = HCI_INTERFACE_DEFAULT;
hci_data->adapter_id = usb_conv_info->bus_id << 8 | usb_conv_info->device_address;
+/* TODO: adapter disconnect on some USB action, for now do not support adapter disconnection */
+ hci_data->adapter_disconnect_in_frame = &max_disconnect_in_frame;
+ hci_data->chandle_sessions = chandle_sessions;
hci_data->chandle_to_bdaddr_table = chandle_to_bdaddr_table;
hci_data->bdaddr_to_name_table = bdaddr_to_name_table;
hci_data->localhost_bdaddr = localhost_bdaddr;
@@ -376,6 +382,7 @@ proto_register_hci_usb(void)
&addresses_reassembly_table_functions);
fragment_info_table = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope());
+ chandle_sessions = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope());
chandle_to_bdaddr_table = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); /* adapter, chandle: bdaddr */
bdaddr_to_name_table = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); /* bdaddr: name */
localhost_bdaddr = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); /* adapter, frame: bdaddr */