aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorMichal Labedzki <michal.labedzki@tieto.com>2015-05-04 12:54:29 +0200
committerMichal Labedzki <michal.labedzki@tieto.com>2015-05-18 07:09:15 +0000
commit72ea3b1ca2294bf30154296ed7ce2e61f9a84346 (patch)
tree7dd0982c3b178829aaccd262d60b8ed753df2996 /epan
parentf169900be9510bc3acc78b6df7b0ff69fd9c1ddb (diff)
Bluetooth: SCO: Add Stream Number generated field
It is used to distinguish SCO streams. Stream Number increase any time when new SCO connection is created. Change-Id: I6cf68914112980cdbad345e52469bf2baf214551 Reviewed-on: https://code.wireshark.org/review/8510 Reviewed-by: Michal Labedzki <michal.labedzki@tieto.com>
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/packet-bthci_evt.c40
-rw-r--r--epan/dissectors/packet-bthci_sco.c27
-rw-r--r--epan/dissectors/packet-bthci_sco.h44
3 files changed, 102 insertions, 9 deletions
diff --git a/epan/dissectors/packet-bthci_evt.c b/epan/dissectors/packet-bthci_evt.c
index 6210d7dc1b..0ff9be9931 100644
--- a/epan/dissectors/packet-bthci_evt.c
+++ b/epan/dissectors/packet-bthci_evt.c
@@ -39,6 +39,7 @@
#include <epan/decode_as.h>
#include "packet-bluetooth.h"
+#include "packet-bthci_sco.h"
static dissector_handle_t bthci_cmd_handle;
static dissector_handle_t bthci_evt_handle;
@@ -3258,19 +3259,22 @@ 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;
- chandle_session_t *chandle_session;
+ 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;
+ bthci_sco_stream_number_t *sco_stream_number;
+ guint32 stream_number;
k_interface_id = bluetooth_data->interface_id;
k_adapter_id = bluetooth_data->adapter_id;
k_connection_handle = connection_handle;
k_frame_number = pinfo->fd->num;
+ /* chandle to bdaddr */
key[0].length = 1;
key[0].key = &k_interface_id;
key[1].length = 1;
@@ -3290,10 +3294,32 @@ dissect_bthci_evt_sync_connection_complete(tvbuff_t *tvb, int offset,
wmem_tree_insert32_array(bluetooth_data->chandle_to_bdaddr, key, remote_bdaddr);
+ /* chandle session */
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);
+
+ /* stream number */
+ key[2].length = 0;
+ key[2].key = NULL;
+
+ subtree = (wmem_tree_t *) wmem_tree_lookup32_array(bthci_sco_stream_numbers, key);
+ sco_stream_number = (subtree) ? (bthci_sco_stream_number_t *) wmem_tree_lookup32_le(subtree, pinfo->fd->num) : NULL;
+ if (!sco_stream_number) {
+ stream_number = 1;
+ } else {
+ stream_number = sco_stream_number->stream_number + 1;
+ }
+
+ key[2].length = 1;
+ key[2].key = &frame_number;
+ key[3].length = 0;
+ key[3].key = NULL;
+
+ sco_stream_number = (bthci_sco_stream_number_t *) wmem_new(wmem_file_scope(), bthci_sco_stream_number_t);
+ sco_stream_number->stream_number = stream_number;
+ wmem_tree_insert32_array(bthci_sco_stream_numbers, key, sco_stream_number);
}
return offset;
diff --git a/epan/dissectors/packet-bthci_sco.c b/epan/dissectors/packet-bthci_sco.c
index 014d5afbfe..4f2883ebff 100644
--- a/epan/dissectors/packet-bthci_sco.c
+++ b/epan/dissectors/packet-bthci_sco.c
@@ -30,20 +30,25 @@
#include <epan/addr_resolv.h>
#include "packet-bluetooth.h"
+#include "packet-bthci_sco.h"
/* Initialize the protocol and registered fields */
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;
+static int hf_bthci_sco_connect_in = -1;
+static int hf_bthci_sco_disconnect_in = -1;
+static int hf_bthci_sco_stream_number = -1;
+
/* Initialize the subtree pointers */
static gint ett_bthci_sco = -1;
+wmem_tree_t *bthci_sco_stream_numbers = NULL;
+
static dissector_handle_t bthci_sco_handle;
static const value_string packet_status_vals[] = {
@@ -82,6 +87,7 @@ dissect_bthci_sco(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void
chandle_session_t *chandle_session;
wmem_tree_t *subtree;
proto_item *sub_item;
+ bthci_sco_stream_number_t *sco_stream_number;
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);
@@ -119,6 +125,12 @@ dissect_bthci_sco(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void
key[0].key = &k_interface_id;
key[1].length = 1;
key[1].key = &k_adapter_id;
+ key[2].length = 0;
+ key[2].key = NULL;
+
+ subtree = (wmem_tree_t *) wmem_tree_lookup32_array(bthci_sco_stream_numbers, key);
+ sco_stream_number = (subtree) ? (bthci_sco_stream_number_t *) wmem_tree_lookup32_le(subtree, pinfo->fd->num) : NULL;
+
key[2].length = 1;
key[2].key = &k_connection_handle;
key[3].length = 0;
@@ -265,6 +277,10 @@ dissect_bthci_sco(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void
PROTO_ITEM_SET_GENERATED(sub_item);
}
}
+ if (sco_stream_number) {
+ sub_item = proto_tree_add_uint(bthci_sco_tree, hf_bthci_sco_stream_number, tvb, 0, 0, sco_stream_number->stream_number);
+ PROTO_ITEM_SET_GENERATED(sub_item);
+ }
return tvb_reported_length(tvb);
}
@@ -299,6 +315,11 @@ proto_register_bthci_sco(void)
FT_FRAMENUM, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
+ { &hf_bthci_sco_stream_number,
+ { "Stream Number", "bthci_sco.stream_number",
+ FT_UINT32, BASE_DEC, NULL, 0x00,
+ NULL, HFILL }
+ },
{ &hf_bthci_sco_length,
{ "Data Total Length", "bthci_sco.length",
FT_UINT8, BASE_DEC, NULL, 0x0,
@@ -320,6 +341,8 @@ proto_register_bthci_sco(void)
proto_bthci_sco = proto_register_protocol("Bluetooth HCI SCO Packet", "HCI_SCO", "bthci_sco");
bthci_sco_handle = new_register_dissector("bthci_sco", dissect_bthci_sco, proto_bthci_sco);
+ bthci_sco_stream_numbers = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope());
+
/* Required function calls to register the header fields and subtrees used */
proto_register_field_array(proto_bthci_sco, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
diff --git a/epan/dissectors/packet-bthci_sco.h b/epan/dissectors/packet-bthci_sco.h
new file mode 100644
index 0000000000..031365ca73
--- /dev/null
+++ b/epan/dissectors/packet-bthci_sco.h
@@ -0,0 +1,44 @@
+/* packet-bthci_sco.h
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * 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 __PACKET_BTHCI_SCO_H__
+#define __PACKET_BTHCI_SCO_H__
+
+extern wmem_tree_t *bthci_sco_stream_numbers;
+
+typedef struct _bthci_sco_stream_number_t {
+ guint32 stream_number;
+} bthci_sco_stream_number_t;
+
+#endif
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */