Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-hci_h1.c
blob3b3883c51a4e9b6e2119ecd24905c1b87319b753
1 /* packet-hci_h1.c
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
9 */
11 #include "config.h"
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"},
34 {0, NULL }
36 static const value_string hci_h1_direction_vals[] = {
37 {-1, "Unknown"},
38 {0, "Sent"},
39 {1, "Rcvd"},
40 {0, NULL}
43 void proto_register_hci_h1(void);
44 void proto_reg_handoff_hci_h1(void);
46 static int
47 dissect_hci_h1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
49 uint8_t type;
50 tvbuff_t *next_tvb;
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;
64 if (tree) {
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"),
73 val_to_str(type,
74 hci_h1_type_vals,
75 "Unknown 0x%02x"));
76 else
77 proto_item_append_text(hci_h1_tree, " %s",
78 val_to_str(type,
79 hci_h1_type_vals,
80 "Unknown 0x%02x"));
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,
89 "Unknown 0x%02x"));
90 else
91 col_add_str(pinfo->cinfo, COL_INFO,
92 val_to_str(type, hci_h1_type_vals,
93 "Unknown 0x%02x"));
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);
107 void
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[] = {
119 &ett_hci_h1,
122 proto_hci_h1 = proto_register_protocol("Bluetooth HCI H1",
123 "HCI_H1", "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);
134 void
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
143 * Local variables:
144 * c-basic-offset: 4
145 * tab-width: 8
146 * indent-tabs-mode: nil
147 * End:
149 * vi: set shiftwidth=4 tabstop=8 expandtab:
150 * :indentSize=4:tabSize=8:noTabs=true: