2 * Routines for the Bluetooth HCI H4 dissection
4 * Copyright 2002, Christoph Scholz <scholz@cs.uni-bonn.de>
5 * From: http://affix.sourceforge.net/archive/ethereal_affix-3.patch
7 * Refactored for wireshark checkin
10 * Wireshark - Network traffic analyzer
11 * By Gerald Combs <gerald@wireshark.org>
12 * Copyright 1998 Gerald Combs
14 * SPDX-License-Identifier: GPL-2.0-or-later
19 #include <epan/packet.h>
20 #include <wiretap/wtap.h>
21 #include "packet-bluetooth.h"
23 static int proto_hci_h4
;
24 static int hf_hci_h4_type
;
25 static int hf_hci_h4_direction
;
27 static int ett_hci_h4
;
29 static dissector_handle_t hci_h4_handle
;
31 static dissector_table_t hci_h4_table
;
33 static const value_string hci_h4_type_vals
[] = {
34 {HCI_H4_TYPE_CMD
, "HCI Command"},
35 {HCI_H4_TYPE_ACL
, "ACL Data"},
36 {HCI_H4_TYPE_SCO
, "SCO Data"},
37 {HCI_H4_TYPE_EVT
, "HCI Event"},
38 {HCI_H4_TYPE_ISO
, "ISO Data"},
41 static const value_string hci_h4_direction_vals
[] = {
42 {P2P_DIR_SENT
, "Sent"},
43 {P2P_DIR_RECV
, "Rcvd"},
44 {P2P_DIR_UNKNOWN
, "Unspecified"},
48 void proto_register_hci_h4(void);
49 void proto_reg_handoff_hci_h4(void);
52 dissect_hci_h4(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data
)
56 proto_item
*main_item
;
57 proto_tree
*main_tree
;
59 bluetooth_data_t
*bluetooth_data
;
61 bluetooth_data
= (bluetooth_data_t
*) data
;
63 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "HCI H4");
64 switch (pinfo
->p2p_dir
) {
67 col_set_str(pinfo
->cinfo
, COL_INFO
, "Sent ");
71 col_set_str(pinfo
->cinfo
, COL_INFO
, "Rcvd ");
78 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "Unknown direction %d ",
83 type
= tvb_get_uint8(tvb
, 0);
85 main_item
= proto_tree_add_item(tree
, proto_hci_h4
, tvb
, 0, 1, ENC_NA
);
86 main_tree
= proto_item_add_subtree(main_item
, ett_hci_h4
);
88 sub_item
= proto_tree_add_uint(main_tree
, hf_hci_h4_direction
, tvb
, 0, 0, pinfo
->p2p_dir
);
89 proto_item_set_generated(sub_item
);
91 proto_tree_add_item(main_tree
, hf_hci_h4_type
,
92 tvb
, 0, 1, ENC_LITTLE_ENDIAN
);
93 col_append_str(pinfo
->cinfo
, COL_INFO
,
94 val_to_str(type
, hci_h4_type_vals
, "Unknown HCI packet type 0x%02x"));
96 next_tvb
= tvb_new_subset_remaining(tvb
, 1);
97 if (!dissector_try_uint_with_data(hci_h4_table
, type
, next_tvb
, pinfo
, tree
, true, bluetooth_data
)) {
98 call_data_dissector(next_tvb
, pinfo
, tree
);
106 proto_register_hci_h4(void)
108 static hf_register_info hf
[] = {
110 { "HCI Packet Type", "hci_h4.type",
111 FT_UINT8
, BASE_HEX
, VALS(hci_h4_type_vals
), 0x0,
114 { &hf_hci_h4_direction
,
115 { "Direction", "hci_h4.direction",
116 FT_UINT8
, BASE_HEX
, VALS(hci_h4_direction_vals
), 0x0,
117 "HCI Packet Direction Sent/Rcvd", HFILL
}
121 static int *ett
[] = {
125 proto_hci_h4
= proto_register_protocol("Bluetooth HCI H4", "HCI_H4", "hci_h4");
127 hci_h4_handle
= register_dissector("hci_h4", dissect_hci_h4
, proto_hci_h4
);
129 proto_register_field_array(proto_hci_h4
, hf
, array_length(hf
));
130 proto_register_subtree_array(ett
, array_length(ett
));
132 hci_h4_table
= register_dissector_table("hci_h4.type",
133 "HCI H4 pdu type", proto_hci_h4
, FT_UINT8
, BASE_HEX
);
137 proto_reg_handoff_hci_h4(void)
139 dissector_add_uint("bluetooth.encap", WTAP_ENCAP_BLUETOOTH_H4
, hci_h4_handle
);
140 dissector_add_uint("bluetooth.encap", WTAP_ENCAP_BLUETOOTH_H4_WITH_PHDR
, hci_h4_handle
);
144 * Editor modelines - https://www.wireshark.org/tools/modelines.html
149 * indent-tabs-mode: nil
152 * vi: set shiftwidth=4 tabstop=8 expandtab:
153 * :indentSize=4:tabSize=8:noTabs=true: