Bluetooth: SCO: Add Connect/Disconnect tracking

Change-Id: I4db44628d60ec8ae22b625649e971b344f450ed9
Reviewed-on: https://code.wireshark.org/review/8509
Reviewed-by: Michal Labedzki <michal.labedzki@tieto.com>
This commit is contained in:
Michal Labedzki 2015-05-01 15:13:13 +02:00
parent 586ce7c77e
commit f169900be9
2 changed files with 48 additions and 6 deletions

View File

@ -3258,12 +3258,13 @@ dissect_bthci_evt_sync_connection_complete(tvbuff_t *tvb, int offset,
if (!pinfo->fd->flags.visited && 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 = bluetooth_data->interface_id;
k_adapter_id = bluetooth_data->adapter_id;
@ -3288,6 +3289,11 @@ dissect_bthci_evt_sync_connection_complete(tvbuff_t *tvb, int offset,
memcpy(remote_bdaddr->bd_addr, bd_addr, 6);
wmem_tree_insert32_array(bluetooth_data->chandle_to_bdaddr, 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 = max_disconnect_in_frame;
wmem_tree_insert32_array(bluetooth_data->chandle_sessions, key, chandle_session);
}
return offset;

View File

@ -36,6 +36,8 @@ static int proto_bthci_sco = -1;
static int hf_bthci_sco_reserved = -1;
static int hf_bthci_sco_packet_status = -1;
static int hf_bthci_sco_chandle = -1;
static int hf_bthci_sco_connect_in = -1;
static int hf_bthci_sco_disconnect_in = -1;
static int hf_bthci_sco_length = -1;
static int hf_bthci_sco_data = -1;
@ -77,6 +79,9 @@ dissect_bthci_sco(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void
gint localhost_length;
localhost_bdaddr_entry_t *localhost_bdaddr_entry;
localhost_name_entry_t *localhost_name_entry;
chandle_session_t *chandle_session;
wmem_tree_t *subtree;
proto_item *sub_item;
ti = proto_tree_add_item(tree, proto_bthci_sco, tvb, offset, tvb_captured_length(tvb), ENC_NA);
bthci_sco_tree = proto_item_add_subtree(ti, ett_bthci_sco);
@ -116,6 +121,17 @@ dissect_bthci_sco(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void
key[1].key = &k_adapter_id;
key[2].length = 1;
key[2].key = &k_connection_handle;
key[3].length = 0;
key[3].key = NULL;
subtree = (wmem_tree_t *) wmem_tree_lookup32_array(bluetooth_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)){
chandle_session = NULL;
}
key[3].length = 1;
key[3].key = &k_frame_number;
key[4].length = 0;
@ -240,6 +256,16 @@ dissect_bthci_sco(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void
proto_tree_add_item(bthci_sco_tree, hf_bthci_sco_data, tvb, offset, tvb_reported_length(tvb), ENC_NA);
if (chandle_session) {
sub_item = proto_tree_add_uint(bthci_sco_tree, hf_bthci_sco_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_sco_tree, hf_bthci_sco_disconnect_in, tvb, 0, 0, chandle_session->disconnect_in_frame);
PROTO_ITEM_SET_GENERATED(sub_item);
}
}
return tvb_reported_length(tvb);
}
@ -263,6 +289,16 @@ proto_register_bthci_sco(void)
FT_UINT16, BASE_HEX, NULL, 0x0FFF,
NULL, HFILL }
},
{ &hf_bthci_sco_connect_in,
{ "Connect in frame", "bthci_sco.connect_in",
FT_FRAMENUM, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_bthci_sco_disconnect_in,
{ "Disconnect in frame", "bthci_sco.disconnect_in",
FT_FRAMENUM, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_bthci_sco_length,
{ "Data Total Length", "bthci_sco.length",
FT_UINT8, BASE_DEC, NULL, 0x0,