2006-05-09 09:13:20 +00:00
|
|
|
/* packet-hci_h4.c
|
2006-05-10 07:55:52 +00:00
|
|
|
* Routines for the Bluetooth HCI H4 dissection
|
2006-05-09 09:13:20 +00:00
|
|
|
*
|
|
|
|
* Copyright 2002, Christoph Scholz <scholz@cs.uni-bonn.de>
|
|
|
|
* From: http://affix.sourceforge.net/archive/ethereal_affix-3.patch
|
|
|
|
*
|
2006-05-21 04:49:01 +00:00
|
|
|
* Refactored for wireshark checkin
|
2006-05-09 09:13:20 +00:00
|
|
|
* Ronnie Sahlberg 2006
|
|
|
|
*
|
2006-05-09 14:32:38 +00:00
|
|
|
* $Id$
|
2006-05-09 09:13:20 +00:00
|
|
|
*
|
2006-05-21 04:49:01 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2006-05-09 09:13:20 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2007-10-16 17:19:16 +00:00
|
|
|
*
|
2006-05-09 09:13:20 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2007-10-16 17:19:16 +00:00
|
|
|
*
|
2006-05-09 09:13:20 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2012-06-28 23:18:38 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2006-05-09 09:13:20 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <epan/packet.h>
|
|
|
|
|
|
|
|
#include "packet-hci_h4.h"
|
|
|
|
|
|
|
|
|
|
|
|
static int proto_hci_h4 = -1;
|
|
|
|
static int hf_hci_h4_type = -1;
|
|
|
|
static int hf_hci_h4_direction = -1;
|
|
|
|
|
|
|
|
static gint ett_hci_h4 = -1;
|
|
|
|
|
|
|
|
static dissector_table_t hci_h4_table;
|
|
|
|
static dissector_handle_t data_handle;
|
|
|
|
|
|
|
|
|
|
|
|
static const value_string hci_h4_type_vals[] = {
|
|
|
|
{HCI_H4_TYPE_CMD, "HCI Command"},
|
|
|
|
{HCI_H4_TYPE_ACL, "ACL Data"},
|
|
|
|
{HCI_H4_TYPE_SCO, "SCO Data"},
|
|
|
|
{HCI_H4_TYPE_EVT, "HCI Event"},
|
|
|
|
{0, NULL }
|
|
|
|
};
|
|
|
|
static const value_string hci_h4_direction_vals[] = {
|
2011-02-12 20:59:43 +00:00
|
|
|
{P2P_DIR_SENT, "Sent"},
|
|
|
|
{P2P_DIR_RECV, "Rcvd"},
|
|
|
|
{P2P_DIR_UNKNOWN, "Unspecified"},
|
2006-05-09 09:13:20 +00:00
|
|
|
{0, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
dissect_hci_h4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
|
|
|
guint8 type;
|
|
|
|
tvbuff_t *next_tvb;
|
|
|
|
proto_item *ti=NULL;
|
|
|
|
proto_tree *hci_h4_tree=NULL;
|
|
|
|
|
2009-07-13 17:33:14 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "HCI H4");
|
2011-02-12 19:59:41 +00:00
|
|
|
switch (pinfo->p2p_dir) {
|
|
|
|
|
|
|
|
case P2P_DIR_SENT:
|
|
|
|
col_add_fstr(pinfo->cinfo, COL_INFO, "Sent ");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case P2P_DIR_RECV:
|
|
|
|
col_add_fstr(pinfo->cinfo, COL_INFO, "Rcvd ");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case P2P_DIR_UNKNOWN:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
col_add_fstr(pinfo->cinfo, COL_INFO, "Unknown direction %d ",
|
|
|
|
pinfo->p2p_dir);
|
|
|
|
break;
|
|
|
|
}
|
2006-05-09 09:13:20 +00:00
|
|
|
|
|
|
|
type = tvb_get_guint8(tvb, 0);
|
2007-10-16 17:19:16 +00:00
|
|
|
|
2006-05-09 09:13:20 +00:00
|
|
|
if(tree){
|
2011-10-21 02:10:19 +00:00
|
|
|
ti = proto_tree_add_item(tree, proto_hci_h4, tvb, 0, 1, ENC_NA);
|
2006-05-09 09:13:20 +00:00
|
|
|
hci_h4_tree = proto_item_add_subtree(ti, ett_hci_h4);
|
|
|
|
}
|
|
|
|
|
|
|
|
ti=proto_tree_add_uint(hci_h4_tree, hf_hci_h4_direction, tvb, 0, 0, pinfo->p2p_dir);
|
|
|
|
PROTO_ITEM_SET_GENERATED(ti);
|
|
|
|
|
|
|
|
proto_tree_add_item(hci_h4_tree, hf_hci_h4_type,
|
2011-10-06 03:35:44 +00:00
|
|
|
tvb, 0, 1, ENC_LITTLE_ENDIAN);
|
2011-02-12 19:59:41 +00:00
|
|
|
col_append_fstr(pinfo->cinfo, COL_INFO, "%s",
|
|
|
|
val_to_str(type, hci_h4_type_vals, "Unknown HCI packet type 0x%02x"));
|
2006-05-09 09:13:20 +00:00
|
|
|
|
2009-08-16 12:36:22 +00:00
|
|
|
next_tvb = tvb_new_subset_remaining(tvb, 1);
|
2010-12-20 05:35:29 +00:00
|
|
|
if(!dissector_try_uint(hci_h4_table, type, next_tvb, pinfo, tree)) {
|
2006-05-09 09:13:20 +00:00
|
|
|
call_dissector(data_handle, next_tvb, pinfo, tree);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_register_hci_h4(void)
|
2007-10-16 17:19:16 +00:00
|
|
|
{
|
2006-05-09 09:13:20 +00:00
|
|
|
static hf_register_info hf[] = {
|
|
|
|
{ &hf_hci_h4_type,
|
|
|
|
{ "HCI Packet Type", "hci_h4.type",
|
2007-10-16 17:19:16 +00:00
|
|
|
FT_UINT8, BASE_HEX, VALS(hci_h4_type_vals), 0x0,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
NULL, HFILL }},
|
2006-05-09 09:13:20 +00:00
|
|
|
|
|
|
|
{ &hf_hci_h4_direction,
|
|
|
|
{ "Direction", "hci_h4.direction",
|
2007-10-16 17:19:16 +00:00
|
|
|
FT_UINT8, BASE_HEX, VALS(hci_h4_direction_vals), 0x0,
|
2006-05-09 09:13:20 +00:00
|
|
|
"HCI Packet Direction Sent/Rcvd", HFILL }},
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_hci_h4,
|
|
|
|
};
|
|
|
|
|
2006-05-10 07:55:52 +00:00
|
|
|
proto_hci_h4 = proto_register_protocol("Bluetooth HCI H4",
|
2006-05-09 09:13:20 +00:00
|
|
|
"HCI_H4", "hci_h4");
|
|
|
|
|
|
|
|
register_dissector("hci_h4", dissect_hci_h4, proto_hci_h4);
|
|
|
|
|
|
|
|
proto_register_field_array(proto_hci_h4, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
|
|
|
|
|
|
|
hci_h4_table = register_dissector_table("hci_h4.type",
|
|
|
|
"HCI H4 pdu type", FT_UINT8, BASE_HEX);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_reg_handoff_hci_h4(void)
|
|
|
|
{
|
|
|
|
dissector_handle_t hci_h4_handle;
|
|
|
|
|
|
|
|
data_handle = find_dissector("data");
|
|
|
|
hci_h4_handle = find_dissector("hci_h4");
|
2010-12-20 05:35:29 +00:00
|
|
|
dissector_add_uint("wtap_encap", WTAP_ENCAP_BLUETOOTH_H4, hci_h4_handle);
|
|
|
|
dissector_add_uint("wtap_encap", WTAP_ENCAP_BLUETOOTH_H4_WITH_PHDR, hci_h4_handle);
|
2006-05-09 09:13:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|