2009-04-24 08:14:36 +00:00
|
|
|
/* packet-packetlogger.c
|
|
|
|
* Routines for Apple's PacketLogger Types
|
|
|
|
*
|
|
|
|
* Copyright 2009, Stig Bjorlykke <stig@bjorlykke.org>
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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 22:56:06 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2009-04-24 08:14:36 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <epan/packet.h>
|
2013-11-29 20:53:00 +00:00
|
|
|
#include <wiretap/wtap.h>
|
2009-04-24 08:14:36 +00:00
|
|
|
|
2014-12-20 21:23:59 +00:00
|
|
|
#include "packet-bluetooth.h"
|
2014-12-12 10:24:44 +00:00
|
|
|
|
2013-12-14 12:45:57 +00:00
|
|
|
void proto_register_packetlogger(void);
|
|
|
|
void proto_reg_handoff_packetlogger(void);
|
|
|
|
|
2009-04-24 08:14:36 +00:00
|
|
|
#define PNAME "PacketLogger"
|
|
|
|
#define PSNAME "PKTLOG"
|
|
|
|
#define PFNAME "packetlogger"
|
|
|
|
|
|
|
|
static int proto_packetlogger = -1;
|
|
|
|
|
|
|
|
static int hf_type = -1;
|
|
|
|
static int hf_info = -1;
|
|
|
|
|
|
|
|
static gint ett_packetlogger = -1;
|
|
|
|
|
2013-08-05 18:09:43 +00:00
|
|
|
static dissector_handle_t packetlogger_handle;
|
|
|
|
static dissector_table_t hci_h1_table;
|
|
|
|
|
|
|
|
static dissector_handle_t data_handle;
|
|
|
|
|
2009-04-24 08:14:36 +00:00
|
|
|
#define PKT_HCI_COMMAND 0x00
|
|
|
|
#define PKT_HCI_EVENT 0x01
|
|
|
|
#define PKT_SENT_ACL_DATA 0x02
|
|
|
|
#define PKT_RECV_ACL_DATA 0x03
|
2014-06-15 17:42:59 +00:00
|
|
|
#define PKT_LMP_SEND 0x0A
|
|
|
|
#define PKT_LMP_RECV 0x0B
|
2010-07-14 20:24:38 +00:00
|
|
|
#define PKT_POWER 0xFB
|
|
|
|
#define PKT_NOTE 0xFC
|
2009-04-24 08:14:36 +00:00
|
|
|
#define PKT_NEW_CONTROLLER 0xFE
|
|
|
|
|
|
|
|
static const value_string type_vals[] = {
|
|
|
|
{ PKT_HCI_COMMAND, "HCI Command" },
|
|
|
|
{ PKT_HCI_EVENT, "HCI Event" },
|
|
|
|
{ PKT_SENT_ACL_DATA, "Sent ACL Data" },
|
|
|
|
{ PKT_RECV_ACL_DATA, "Recv ACL Data" },
|
2014-06-15 17:42:59 +00:00
|
|
|
{ PKT_LMP_SEND, "Sent LMP Data" },
|
|
|
|
{ PKT_LMP_RECV, "Recv LMP Data" },
|
2010-07-14 20:24:38 +00:00
|
|
|
{ PKT_POWER, "Power" },
|
|
|
|
{ PKT_NOTE, "Note" },
|
2009-04-24 08:14:36 +00:00
|
|
|
{ PKT_NEW_CONTROLLER, "New Controller" },
|
|
|
|
{ 0, NULL }
|
|
|
|
};
|
|
|
|
|
2014-12-12 10:24:44 +00:00
|
|
|
static int dissect_packetlogger(tvbuff_t *tvb, packet_info *pinfo,
|
|
|
|
proto_tree *tree, void *data)
|
2009-04-24 08:14:36 +00:00
|
|
|
{
|
2014-12-12 10:24:44 +00:00
|
|
|
proto_tree *packetlogger_tree = NULL;
|
|
|
|
tvbuff_t *next_tvb;
|
|
|
|
proto_item *ti = NULL;
|
|
|
|
guint8 pl_type;
|
|
|
|
gint len;
|
|
|
|
bluetooth_data_t *bluetooth_data;
|
|
|
|
|
|
|
|
bluetooth_data = (bluetooth_data_t *) data;
|
2009-04-24 08:14:36 +00:00
|
|
|
|
|
|
|
col_set_str (pinfo->cinfo, COL_PROTOCOL, PSNAME);
|
|
|
|
col_clear (pinfo->cinfo, COL_INFO);
|
|
|
|
|
2011-07-19 18:48:31 +00:00
|
|
|
ti = proto_tree_add_item (tree, proto_packetlogger, tvb, 0, -1, ENC_NA);
|
2009-04-24 08:14:36 +00:00
|
|
|
packetlogger_tree = proto_item_add_subtree (ti, ett_packetlogger);
|
|
|
|
|
|
|
|
pl_type = tvb_get_guint8 (tvb, 0);
|
2011-07-19 10:51:12 +00:00
|
|
|
proto_tree_add_item (packetlogger_tree, hf_type, tvb, 0, 1, ENC_BIG_ENDIAN);
|
2009-04-24 08:14:36 +00:00
|
|
|
proto_item_append_text (ti, " %s", val_to_str (pl_type, type_vals, "Unknown 0x%02x"));
|
|
|
|
|
2014-06-19 17:18:16 +00:00
|
|
|
len = tvb_length_remaining (tvb, 1);
|
2014-06-06 14:35:50 +00:00
|
|
|
next_tvb = tvb_new_subset_remaining (tvb, 1);
|
2009-04-24 08:14:36 +00:00
|
|
|
|
|
|
|
if (pl_type <= PKT_RECV_ACL_DATA) {
|
|
|
|
/* HCI H1 packages */
|
|
|
|
switch (pl_type) {
|
|
|
|
case PKT_HCI_COMMAND:
|
|
|
|
pinfo->pseudo_header->bthci.channel = BTHCI_CHANNEL_COMMAND;
|
|
|
|
pinfo->pseudo_header->bthci.sent = P2P_DIR_SENT;
|
|
|
|
pinfo->p2p_dir = P2P_DIR_SENT;
|
|
|
|
break;
|
|
|
|
case PKT_HCI_EVENT:
|
|
|
|
pinfo->pseudo_header->bthci.channel = BTHCI_CHANNEL_EVENT;
|
|
|
|
pinfo->pseudo_header->bthci.sent = P2P_DIR_RECV;
|
|
|
|
pinfo->p2p_dir = P2P_DIR_RECV;
|
|
|
|
break;
|
|
|
|
case PKT_SENT_ACL_DATA:
|
|
|
|
pinfo->pseudo_header->bthci.channel = BTHCI_CHANNEL_ACL;
|
|
|
|
pinfo->pseudo_header->bthci.sent = P2P_DIR_SENT;
|
|
|
|
pinfo->p2p_dir = P2P_DIR_SENT;
|
|
|
|
break;
|
|
|
|
case PKT_RECV_ACL_DATA:
|
|
|
|
pinfo->pseudo_header->bthci.channel = BTHCI_CHANNEL_ACL;
|
|
|
|
pinfo->pseudo_header->bthci.sent = P2P_DIR_RECV;
|
|
|
|
pinfo->p2p_dir = P2P_DIR_RECV;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
pinfo->pseudo_header->bthci.channel = pl_type;
|
|
|
|
pinfo->pseudo_header->bthci.sent = P2P_DIR_UNKNOWN;
|
|
|
|
pinfo->p2p_dir = P2P_DIR_UNKNOWN;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
proto_item_set_len (ti, 1);
|
|
|
|
|
|
|
|
col_add_fstr (pinfo->cinfo, COL_INFO, "%s", val_to_str(pl_type, type_vals, "Unknown 0x%02x"));
|
2014-12-12 10:24:44 +00:00
|
|
|
if (!dissector_try_uint_new(hci_h1_table, pinfo->pseudo_header->bthci.channel,
|
|
|
|
next_tvb, pinfo, tree, TRUE, bluetooth_data)) {
|
2009-04-24 08:14:36 +00:00
|
|
|
call_dissector (data_handle, next_tvb, pinfo, tree);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* PacketLogger data */
|
|
|
|
switch (pl_type) {
|
2010-07-14 20:24:38 +00:00
|
|
|
case PKT_POWER:
|
|
|
|
case PKT_NOTE:
|
2009-04-24 08:14:36 +00:00
|
|
|
case PKT_NEW_CONTROLLER:
|
2011-10-15 18:46:26 +00:00
|
|
|
proto_tree_add_item (packetlogger_tree, hf_info, next_tvb, 0, len, ENC_ASCII|ENC_NA);
|
2010-07-14 20:24:38 +00:00
|
|
|
col_add_fstr (pinfo->cinfo, COL_INFO, "%s", tvb_format_stringzpad_wsp (next_tvb, 0, len));
|
2009-04-24 08:14:36 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
call_dissector (data_handle, next_tvb, pinfo, tree);
|
|
|
|
col_add_fstr (pinfo->cinfo, COL_INFO, "Unknown 0x%02x", pl_type);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-12-12 10:24:44 +00:00
|
|
|
|
|
|
|
return tvb_captured_length(tvb);
|
2009-04-24 08:14:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void proto_register_packetlogger (void)
|
|
|
|
{
|
|
|
|
static hf_register_info hf[] = {
|
|
|
|
{ &hf_type,
|
|
|
|
{ "Type", "packetlogger.type", FT_UINT8, BASE_HEX, VALS(type_vals), 0x0, NULL, HFILL } },
|
|
|
|
{ &hf_info,
|
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
|
|
|
{ "Info", "packetlogger.info", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL } },
|
2009-04-24 08:14:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_packetlogger
|
|
|
|
};
|
|
|
|
|
|
|
|
proto_packetlogger = proto_register_protocol (PNAME, PSNAME, PFNAME);
|
2013-08-05 18:09:43 +00:00
|
|
|
|
2014-12-12 10:24:44 +00:00
|
|
|
packetlogger_handle = new_register_dissector (PFNAME, dissect_packetlogger, proto_packetlogger);
|
2013-10-13 19:56:52 +00:00
|
|
|
|
2009-04-24 08:14:36 +00:00
|
|
|
proto_register_field_array (proto_packetlogger, hf, array_length (hf));
|
|
|
|
proto_register_subtree_array (ett, array_length (ett));
|
|
|
|
}
|
|
|
|
|
|
|
|
void proto_reg_handoff_packetlogger (void)
|
|
|
|
{
|
|
|
|
hci_h1_table = find_dissector_table("hci_h1.type");
|
|
|
|
data_handle = find_dissector("data");
|
2014-12-12 10:24:44 +00:00
|
|
|
dissector_add_uint ("bluetooth.encap", WTAP_ENCAP_PACKETLOGGER, packetlogger_handle);
|
2009-04-24 08:14:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Editor modelines
|
|
|
|
*
|
|
|
|
* Local Variables:
|
|
|
|
* c-basic-offset: 2
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
2011-09-21 17:49:11 +00:00
|
|
|
* ex: set shiftwidth=2 tabstop=8 expandtab:
|
2009-07-23 17:46:09 +00:00
|
|
|
* :indentSize=2:tabSize=8:noTabs=true:
|
2009-04-24 08:14:36 +00:00
|
|
|
*/
|