forked from osmocom/wireshark
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>
This commit is contained in:
parent
58bbfa5ee3
commit
164af0050d
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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*/
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue