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
12 * Wireshark - Network traffic analyzer
13 * By Gerald Combs <gerald@wireshark.org>
14 * Copyright 1998 Gerald Combs
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License
18 * as published by the Free Software Foundation; either version 2
19 * of the License, or (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
35 #include <epan/packet.h>
37 #include "packet-hci_h4.h"
40 static int proto_hci_h4 = -1;
41 static int hf_hci_h4_type = -1;
42 static int hf_hci_h4_direction = -1;
44 static gint ett_hci_h4 = -1;
46 static dissector_table_t hci_h4_table;
47 static dissector_handle_t data_handle;
50 static const value_string hci_h4_type_vals[] = {
51 {HCI_H4_TYPE_CMD, "HCI Command"},
52 {HCI_H4_TYPE_ACL, "ACL Data"},
53 {HCI_H4_TYPE_SCO, "SCO Data"},
54 {HCI_H4_TYPE_EVT, "HCI Event"},
57 static const value_string hci_h4_direction_vals[] = {
64 dissect_hci_h4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
69 proto_tree *hci_h4_tree=NULL;
71 if(check_col(pinfo->cinfo, COL_PROTOCOL))
72 col_set_str(pinfo->cinfo, COL_PROTOCOL, "HCI H4");
74 if(check_col(pinfo->cinfo, COL_INFO))
75 col_clear(pinfo->cinfo, COL_INFO);
77 type = tvb_get_guint8(tvb, 0);
80 ti = proto_tree_add_item(tree, proto_hci_h4, tvb, 0, 1, FALSE);
81 hci_h4_tree = proto_item_add_subtree(ti, ett_hci_h4);
84 if(check_col(pinfo->cinfo, COL_INFO)){
85 col_add_fstr(pinfo->cinfo, COL_INFO, "%s %s",pinfo->p2p_dir==P2P_DIR_SENT?"Sent":"Rcvd",val_to_str(type, hci_h4_type_vals, "Unknown 0x%02x"));
87 ti=proto_tree_add_uint(hci_h4_tree, hf_hci_h4_direction, tvb, 0, 0, pinfo->p2p_dir);
88 PROTO_ITEM_SET_GENERATED(ti);
89 proto_item_append_text(hci_h4_tree, " %s %s", val_to_str(pinfo->p2p_dir, hci_h4_direction_vals, "0x%02x"), val_to_str(type, hci_h4_type_vals, "Unknown 0x%02x"));
91 proto_tree_add_item(hci_h4_tree, hf_hci_h4_type,
94 next_tvb = tvb_new_subset(tvb, 1, -1, -1);
95 if(!dissector_try_port(hci_h4_table, type, next_tvb, pinfo, tree)) {
97 if(check_col(pinfo->cinfo, COL_INFO)){
98 col_add_fstr(pinfo->cinfo, COL_INFO, "Unknown HCI H4 payload type 0x%02x", type);
101 call_dissector(data_handle, next_tvb, pinfo, tree);
107 proto_register_hci_h4(void)
109 static hf_register_info hf[] = {
111 { "HCI Packet Type", "hci_h4.type",
112 FT_UINT8, BASE_HEX, VALS(hci_h4_type_vals), 0x0,
113 "HCI Packet Type", HFILL }},
115 { &hf_hci_h4_direction,
116 { "Direction", "hci_h4.direction",
117 FT_UINT8, BASE_HEX, VALS(hci_h4_direction_vals), 0x0,
118 "HCI Packet Direction Sent/Rcvd", HFILL }},
122 static gint *ett[] = {
126 proto_hci_h4 = proto_register_protocol("Bluetooth HCI H4",
129 register_dissector("hci_h4", dissect_hci_h4, proto_hci_h4);
131 proto_register_field_array(proto_hci_h4, hf, array_length(hf));
132 proto_register_subtree_array(ett, array_length(ett));
134 hci_h4_table = register_dissector_table("hci_h4.type",
135 "HCI H4 pdu type", FT_UINT8, BASE_HEX);
139 proto_reg_handoff_hci_h4(void)
141 dissector_handle_t hci_h4_handle;
143 data_handle = find_dissector("data");
144 hci_h4_handle = find_dissector("hci_h4");
145 dissector_add("wtap_encap", WTAP_ENCAP_BLUETOOTH_H4, hci_h4_handle);