2 * Routines for the Bluetooth HCI H1 dissection
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
8 * SPDX-License-Identifier: GPL-2.0-or-later
13 #include <epan/packet.h>
14 #include <wiretap/wtap.h>
16 #include "packet-bluetooth.h"
18 static int proto_hci_h1
;
20 static int hf_hci_h1_direction
;
22 static int ett_hci_h1
;
24 static dissector_table_t hci_h1_table
;
26 static dissector_handle_t hci_h1_handle
;
28 static const value_string hci_h1_type_vals
[] = {
29 {BTHCI_CHANNEL_COMMAND
, "HCI Command"},
30 {BTHCI_CHANNEL_ACL
, "ACL Data"},
31 {BTHCI_CHANNEL_SCO
, "SCO Data"},
32 {BTHCI_CHANNEL_EVENT
, "HCI Event"},
33 {BTHCI_CHANNEL_ISO
, "ISO Data"},
36 static const value_string hci_h1_direction_vals
[] = {
43 void proto_register_hci_h1(void);
44 void proto_reg_handoff_hci_h1(void);
47 dissect_hci_h1(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data
)
51 proto_item
*ti
= NULL
;
52 proto_tree
*hci_h1_tree
= NULL
;
53 bluetooth_data_t
*bluetooth_data
;
55 bluetooth_data
= (bluetooth_data_t
*) data
;
57 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "HCI");
59 col_clear(pinfo
->cinfo
, COL_INFO
);
61 DISSECTOR_ASSERT(bluetooth_data
->previous_protocol_data_type
== BT_PD_BTHCI
);
62 type
= bluetooth_data
->previous_protocol_data
.bthci
->channel
;
65 ti
= proto_tree_add_item(tree
, proto_hci_h1
, tvb
, 0, 0, ENC_NA
);
66 hci_h1_tree
= proto_item_add_subtree(ti
, ett_hci_h1
);
68 if(pinfo
->p2p_dir
== P2P_DIR_SENT
||
69 pinfo
->p2p_dir
== P2P_DIR_RECV
)
70 proto_item_append_text(hci_h1_tree
, " %s %s",
71 val_to_str(pinfo
->p2p_dir
,
72 hci_h1_direction_vals
, "Unknown: %d"),
77 proto_item_append_text(hci_h1_tree
, " %s",
83 if(pinfo
->p2p_dir
== P2P_DIR_SENT
||
84 pinfo
->p2p_dir
== P2P_DIR_RECV
)
85 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "%s %s",
86 val_to_str(pinfo
->p2p_dir
,
87 hci_h1_direction_vals
, "Unknown: %d"),
88 val_to_str(type
, hci_h1_type_vals
,
91 col_add_str(pinfo
->cinfo
, COL_INFO
,
92 val_to_str(type
, hci_h1_type_vals
,
95 ti
= proto_tree_add_int(hci_h1_tree
, hf_hci_h1_direction
, tvb
, 0, 0, pinfo
->p2p_dir
);
96 proto_item_set_generated(ti
);
98 next_tvb
= tvb_new_subset_remaining(tvb
, 0);
99 if (!dissector_try_uint_with_data(hci_h1_table
, type
, next_tvb
, pinfo
, tree
, true, bluetooth_data
)) {
100 call_data_dissector(next_tvb
, pinfo
, tree
);
103 return tvb_reported_length(tvb
);
108 proto_register_hci_h1(void)
110 static hf_register_info hf
[] = {
111 { &hf_hci_h1_direction
,
112 { "Direction", "hci_h1.direction",
113 FT_INT8
, BASE_DEC
, VALS(hci_h1_direction_vals
), 0x0,
114 "HCI Packet Direction Sent/Rcvd/Unknown", HFILL
}
118 static int *ett
[] = {
122 proto_hci_h1
= proto_register_protocol("Bluetooth HCI H1",
125 hci_h1_handle
= register_dissector("hci_h1", dissect_hci_h1
, proto_hci_h1
);
127 proto_register_field_array(proto_hci_h1
, hf
, array_length(hf
));
128 proto_register_subtree_array(ett
, array_length(ett
));
130 hci_h1_table
= register_dissector_table("hci_h1.type",
131 "HCI h1 pdu type", proto_hci_h1
, FT_UINT8
, BASE_HEX
);
135 proto_reg_handoff_hci_h1(void)
137 dissector_add_uint("bluetooth.encap", WTAP_ENCAP_BLUETOOTH_HCI
, hci_h1_handle
);
141 * Editor modelines - https://www.wireshark.org/tools/modelines.html
146 * indent-tabs-mode: nil
149 * vi: set shiftwidth=4 tabstop=8 expandtab:
150 * :indentSize=4:tabSize=8:noTabs=true: