2 * Routines for the Bluetooth HCI h1 dissection
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 #include <epan/packet.h>
31 #include "packet-hci_h1.h"
34 static int proto_hci_h1 = -1;
35 static int hf_hci_h1_type = -1;
36 static int hf_hci_h1_direction = -1;
38 static gint ett_hci_h1 = -1;
40 static dissector_table_t hci_h1_table;
41 static dissector_handle_t data_handle;
44 static const value_string hci_h1_type_vals[] = {
45 {BTHCI_CHANNEL_COMMAND, "HCI Command"},
46 {BTHCI_CHANNEL_ACL, "ACL Data"},
47 {BTHCI_CHANNEL_SCO, "SCO Data"},
48 {BTHCI_CHANNEL_EVENT, "HCI Event"},
51 static const value_string hci_h1_direction_vals[] = {
58 dissect_hci_h1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
63 proto_tree *hci_h1_tree=NULL;
65 if(check_col(pinfo->cinfo, COL_PROTOCOL))
66 col_set_str(pinfo->cinfo, COL_PROTOCOL, "HCI");
68 if(check_col(pinfo->cinfo, COL_INFO))
69 col_clear(pinfo->cinfo, COL_INFO);
71 type = pinfo->pseudo_header->bthci.channel;
74 ti = proto_tree_add_item(tree, proto_hci_h1, tvb, 0, 1, FALSE);
75 hci_h1_tree = proto_item_add_subtree(ti, ett_hci_h1);
78 if(check_col(pinfo->cinfo, COL_INFO)){
79 col_add_fstr(pinfo->cinfo, COL_INFO, "%s %s",pinfo->p2p_dir==P2P_DIR_SENT?"Sent":"Rcvd",val_to_str(type, hci_h1_type_vals, "Unknown 0x%02x"));
81 ti=proto_tree_add_uint(hci_h1_tree, hf_hci_h1_direction, tvb, 0, 0, pinfo->p2p_dir);
82 PROTO_ITEM_SET_GENERATED(ti);
83 proto_item_append_text(hci_h1_tree, " %s %s", val_to_str(pinfo->p2p_dir, hci_h1_direction_vals, "0x%02x"), val_to_str(type, hci_h1_type_vals, "Unknown 0x%02x"));
85 next_tvb = tvb_new_subset(tvb, 0, -1, -1);
86 if(!dissector_try_port(hci_h1_table, type, next_tvb, pinfo, tree)) {
87 call_dissector(data_handle, next_tvb, pinfo, tree);
93 proto_register_hci_h1(void)
95 static hf_register_info hf[] = {
97 { "HCI Packet Type", "hci_h1.type",
98 FT_UINT8, BASE_HEX, VALS(hci_h1_type_vals), 0x0,
99 "HCI Packet Type", HFILL }},
101 { &hf_hci_h1_direction,
102 { "Direction", "hci_h1.direction",
103 FT_UINT8, BASE_HEX, VALS(hci_h1_direction_vals), 0x0,
104 "HCI Packet Direction Sent/Rcvd", HFILL }},
108 static gint *ett[] = {
112 proto_hci_h1 = proto_register_protocol("Bluetooth HCI",
115 register_dissector("hci_h1", dissect_hci_h1, proto_hci_h1);
117 proto_register_field_array(proto_hci_h1, hf, array_length(hf));
118 proto_register_subtree_array(ett, array_length(ett));
120 hci_h1_table = register_dissector_table("hci_h1.type",
121 "HCI h1 pdu type", FT_UINT8, BASE_HEX);
125 proto_reg_handoff_hci_h1(void)
127 dissector_handle_t hci_h1_handle;
129 data_handle = find_dissector("data");
130 hci_h1_handle = find_dissector("hci_h1");
131 dissector_add("wtap_encap", WTAP_ENCAP_BLUETOOTH_HCI, hci_h1_handle);