2008-02-03 21:11:53 +00:00
|
|
|
/* packet-hci_h1.c
|
2014-03-03 11:12:03 +00:00
|
|
|
* Routines for the Bluetooth HCI H1 dissection
|
2008-02-03 21:11:53 +00:00
|
|
|
*
|
|
|
|
* 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
|
2012-06-28 23:18:38 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2008-02-03 21:11:53 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <epan/packet.h>
|
2013-11-29 20:53:00 +00:00
|
|
|
#include <wiretap/wtap.h>
|
2008-02-03 21:11:53 +00:00
|
|
|
|
2014-12-12 10:24:44 +00:00
|
|
|
#include "packet-bluetooth.h"
|
2008-02-03 21:11:53 +00:00
|
|
|
|
|
|
|
static int proto_hci_h1 = -1;
|
2013-06-20 16:31:53 +00:00
|
|
|
|
2008-02-03 21:11:53 +00:00
|
|
|
static int hf_hci_h1_direction = -1;
|
|
|
|
|
|
|
|
static gint ett_hci_h1 = -1;
|
|
|
|
|
|
|
|
static dissector_table_t hci_h1_table;
|
2014-03-03 11:12:03 +00:00
|
|
|
|
|
|
|
static dissector_handle_t hci_h1_handle;
|
2008-02-03 21:11:53 +00:00
|
|
|
static dissector_handle_t data_handle;
|
|
|
|
|
|
|
|
static const value_string hci_h1_type_vals[] = {
|
2013-06-20 16:31:53 +00:00
|
|
|
{BTHCI_CHANNEL_COMMAND, "HCI Command"},
|
|
|
|
{BTHCI_CHANNEL_ACL, "ACL Data"},
|
|
|
|
{BTHCI_CHANNEL_SCO, "SCO Data"},
|
|
|
|
{BTHCI_CHANNEL_EVENT, "HCI Event"},
|
|
|
|
{0, NULL }
|
2008-02-03 21:11:53 +00:00
|
|
|
};
|
|
|
|
static const value_string hci_h1_direction_vals[] = {
|
2013-06-20 16:31:53 +00:00
|
|
|
{-1, "Unknown"},
|
|
|
|
{0, "Sent"},
|
|
|
|
{1, "Rcvd"},
|
|
|
|
{0, NULL}
|
2008-02-03 21:11:53 +00:00
|
|
|
};
|
|
|
|
|
2013-03-19 13:51:52 +00:00
|
|
|
void proto_register_hci_h1(void);
|
|
|
|
void proto_reg_handoff_hci_h1(void);
|
|
|
|
|
2013-11-02 19:20:04 +00:00
|
|
|
static gint
|
2014-12-12 10:24:44 +00:00
|
|
|
dissect_hci_h1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
|
2008-02-03 21:11:53 +00:00
|
|
|
{
|
2014-12-12 10:24:44 +00:00
|
|
|
guint8 type;
|
|
|
|
tvbuff_t *next_tvb;
|
|
|
|
proto_item *ti = NULL;
|
|
|
|
proto_tree *hci_h1_tree = NULL;
|
|
|
|
bluetooth_data_t *bluetooth_data;
|
|
|
|
|
|
|
|
bluetooth_data = (bluetooth_data_t *) data;
|
2013-06-20 16:31:53 +00:00
|
|
|
|
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "HCI");
|
|
|
|
|
|
|
|
col_clear(pinfo->cinfo, COL_INFO);
|
|
|
|
|
2015-06-16 03:23:24 +00:00
|
|
|
DISSECTOR_ASSERT(bluetooth_data->previous_protocol_data_type == BT_PD_BTHCI);
|
|
|
|
type = bluetooth_data->previous_protocol_data.bthci->channel;
|
2013-06-20 16:31:53 +00:00
|
|
|
|
|
|
|
if (tree) {
|
|
|
|
ti = proto_tree_add_item(tree, proto_hci_h1, tvb, 0, 0, ENC_NA);
|
|
|
|
hci_h1_tree = proto_item_add_subtree(ti, ett_hci_h1);
|
|
|
|
|
|
|
|
if(pinfo->p2p_dir == P2P_DIR_SENT ||
|
|
|
|
pinfo->p2p_dir == P2P_DIR_RECV)
|
|
|
|
proto_item_append_text(hci_h1_tree, " %s %s",
|
|
|
|
val_to_str(pinfo->p2p_dir,
|
|
|
|
hci_h1_direction_vals, "Unknown: %d"),
|
|
|
|
val_to_str(type,
|
|
|
|
hci_h1_type_vals,
|
|
|
|
"Unknown 0x%02x"));
|
|
|
|
else
|
|
|
|
proto_item_append_text(hci_h1_tree, " %s",
|
|
|
|
val_to_str(type,
|
|
|
|
hci_h1_type_vals,
|
|
|
|
"Unknown 0x%02x"));
|
|
|
|
}
|
|
|
|
|
|
|
|
if(pinfo->p2p_dir == P2P_DIR_SENT ||
|
|
|
|
pinfo->p2p_dir == P2P_DIR_RECV)
|
|
|
|
col_add_fstr(pinfo->cinfo, COL_INFO, "%s %s",
|
|
|
|
val_to_str(pinfo->p2p_dir,
|
|
|
|
hci_h1_direction_vals, "Unknown: %d"),
|
|
|
|
val_to_str(type, hci_h1_type_vals,
|
|
|
|
"Unknown 0x%02x"));
|
|
|
|
else
|
|
|
|
col_add_fstr(pinfo->cinfo, COL_INFO, "%s",
|
|
|
|
val_to_str(type, hci_h1_type_vals,
|
|
|
|
"Unknown 0x%02x"));
|
|
|
|
|
|
|
|
ti = proto_tree_add_int(hci_h1_tree, hf_hci_h1_direction, tvb, 0, 0, pinfo->p2p_dir);
|
|
|
|
PROTO_ITEM_SET_GENERATED(ti);
|
|
|
|
|
|
|
|
next_tvb = tvb_new_subset_remaining(tvb, 0);
|
2014-12-12 10:24:44 +00:00
|
|
|
if (!dissector_try_uint_new(hci_h1_table, type, next_tvb, pinfo, tree, TRUE, bluetooth_data)) {
|
2013-06-20 16:31:53 +00:00
|
|
|
call_dissector(data_handle, next_tvb, pinfo, tree);
|
|
|
|
}
|
|
|
|
|
2015-02-26 13:38:57 +00:00
|
|
|
return tvb_reported_length(tvb);
|
2008-02-03 21:11:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_register_hci_h1(void)
|
|
|
|
{
|
2013-06-20 16:31:53 +00:00
|
|
|
static hf_register_info hf[] = {
|
|
|
|
{ &hf_hci_h1_direction,
|
|
|
|
{ "Direction", "hci_h1.direction",
|
|
|
|
FT_INT8, BASE_DEC, VALS(hci_h1_direction_vals), 0x0,
|
|
|
|
"HCI Packet Direction Sent/Rcvd/Unknown", HFILL }
|
|
|
|
}
|
|
|
|
};
|
2008-02-03 21:11:53 +00:00
|
|
|
|
2013-06-20 16:31:53 +00:00
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_hci_h1,
|
|
|
|
};
|
2008-02-03 21:11:53 +00:00
|
|
|
|
2013-06-20 16:31:53 +00:00
|
|
|
proto_hci_h1 = proto_register_protocol("Bluetooth HCI H1",
|
|
|
|
"HCI_H1", "hci_h1");
|
2008-02-03 21:11:53 +00:00
|
|
|
|
2014-03-03 11:12:03 +00:00
|
|
|
hci_h1_handle = new_register_dissector("hci_h1", dissect_hci_h1, proto_hci_h1);
|
2008-02-03 21:11:53 +00:00
|
|
|
|
2013-06-20 16:31:53 +00:00
|
|
|
proto_register_field_array(proto_hci_h1, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
2008-02-03 21:11:53 +00:00
|
|
|
|
2013-06-20 16:31:53 +00:00
|
|
|
hci_h1_table = register_dissector_table("hci_h1.type",
|
2015-10-29 13:23:55 +00:00
|
|
|
"HCI h1 pdu type", FT_UINT8, BASE_HEX, DISSECTOR_TABLE_NOT_ALLOW_DUPLICATE);
|
2008-02-03 21:11:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_reg_handoff_hci_h1(void)
|
|
|
|
{
|
2013-06-20 16:31:53 +00:00
|
|
|
data_handle = find_dissector("data");
|
2014-03-03 11:12:03 +00:00
|
|
|
|
2014-12-12 10:24:44 +00:00
|
|
|
dissector_add_uint("bluetooth.encap", WTAP_ENCAP_BLUETOOTH_HCI, hci_h1_handle);
|
2008-02-03 21:11:53 +00:00
|
|
|
}
|
|
|
|
|
2013-06-20 16:31:53 +00:00
|
|
|
/*
|
|
|
|
* 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:
|
|
|
|
*/
|