2 * Routines for Bluetooth 3DS dissection
4 * Copyright 2013, Michal Labedzki for Tieto Corporation
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 #include <epan/packet.h>
28 #include <epan/prefs.h>
29 #include <epan/expert.h>
31 #include "packet-btl2cap.h"
32 #include "packet-btsdp.h"
34 static int proto_bt3ds = -1;
36 static int hf_message_opcode = -1;
37 static int hf_association_notification = -1;
38 static int hf_user_request_for_battery_level_display = -1;
39 static int hf_reserved = -1;
40 static int hf_battery_level = -1;
42 static expert_field ei_message_opcode_reserved = EI_INIT;
43 static expert_field ei_reserved = EI_INIT;
44 static expert_field ei_battery_level_reserved = EI_INIT;
45 static expert_field ei_unexpected_data = EI_INIT;
47 static gint ett_bt3ds = -1;
49 static dissector_handle_t b3ds_handle;
51 static const value_string message_opcode_vals[] = {
52 { 0x00, "3DG Connection Announcement" },
56 void proto_register_bt3ds(void);
57 void proto_reg_handoff_bt3ds(void);
60 dissect_bt3ds(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
62 proto_item *main_item;
63 proto_tree *main_tree;
68 main_item = proto_tree_add_item(tree, proto_bt3ds, tvb, offset, -1, ENC_NA);
69 main_tree = proto_item_add_subtree(main_item, ett_bt3ds);
71 col_set_str(pinfo->cinfo, COL_PROTOCOL, "3DS");
73 switch (pinfo->p2p_dir) {
75 col_set_str(pinfo->cinfo, COL_INFO, "Sent ");
78 col_set_str(pinfo->cinfo, COL_INFO, "Rcvd ");
81 col_add_fstr(pinfo->cinfo, COL_INFO, "Unknown direction %d ",
86 sub_item = proto_tree_add_item(main_tree, hf_message_opcode, tvb, offset, 1, ENC_BIG_ENDIAN);
87 value = tvb_get_guint8(tvb, offset);
89 expert_add_info(pinfo, sub_item, &ei_message_opcode_reserved);
92 col_add_fstr(pinfo->cinfo, COL_INFO, "%s", val_to_str_const(value, message_opcode_vals, "Unknown"));
94 sub_item = proto_tree_add_item(main_tree, hf_reserved, tvb, offset, 1, ENC_BIG_ENDIAN);
95 proto_tree_add_item(main_tree, hf_user_request_for_battery_level_display, tvb, offset, 1, ENC_BIG_ENDIAN);
96 proto_tree_add_item(main_tree, hf_association_notification, tvb, offset, 1, ENC_BIG_ENDIAN);
97 value = tvb_get_guint8(tvb, offset) >> 2;
99 expert_add_info(pinfo, sub_item, &ei_reserved);
102 sub_item = proto_tree_add_item(main_tree, hf_battery_level, tvb, offset, 1, ENC_BIG_ENDIAN);
103 value = tvb_get_guint8(tvb, offset);
104 if (value >= 101 && value <= 254)
105 expert_add_info(pinfo, sub_item, &ei_battery_level_reserved);
106 else if (value == 255)
107 proto_item_append_text(sub_item, "Battery Level Reporting Not Supported");
111 if (tvb_length_remaining(tvb, offset) > 0) {
112 proto_tree_add_expert(main_tree, pinfo, &ei_unexpected_data, tvb, offset, -1);
113 offset += tvb_length_remaining(tvb, offset);
121 proto_register_bt3ds(void)
124 expert_module_t *expert_bt3ds;
126 static ei_register_info ei[] = {
127 { &ei_message_opcode_reserved, { "bt3ds.expert.message_opcode.reserved", PI_PROTOCOL, PI_NOTE, "Value is reserved", EXPFILL }},
128 { &ei_reserved, { "bt3ds.expert.reserved", PI_PROTOCOL, PI_NOTE, "Value is reserved", EXPFILL }},
129 { &ei_battery_level_reserved, { "bt3ds.expert.battery_level.reserved", PI_PROTOCOL, PI_NOTE, "Value is reserved", EXPFILL }},
130 { &ei_unexpected_data, { "bt3ds.expert.unexpected_data", PI_PROTOCOL, PI_WARN, "Unexpected data", EXPFILL }}
133 static hf_register_info hf[] = {
134 { &hf_message_opcode,
135 { "Message Opcode", "bt3ds.message_opcode",
136 FT_UINT8, BASE_HEX, VALS(message_opcode_vals), 0x00,
139 { &hf_association_notification,
140 { "Association Notification", "bt3ds.association_notification",
141 FT_BOOLEAN, 8, NULL, 0x01,
144 { &hf_user_request_for_battery_level_display,
145 { "User Request for Battery Level Display", "bt3ds.user_request_for_battery_level_display",
146 FT_BOOLEAN, 8, NULL, 0x02,
150 { "Reserved", "bt3ds.reserved",
151 FT_UINT8, BASE_HEX, NULL, 0xFC,
155 { "Battery Level", "bt3ds.battery_level",
156 FT_UINT8, BASE_DEC, NULL, 0x00,
157 "0-100% of current charge level of battery", HFILL }
161 static gint *ett[] = {
165 proto_bt3ds = proto_register_protocol("Bluetooth 3DS Profile", "BT 3DS", "bt3ds");
166 b3ds_handle = new_register_dissector("bt3ds", dissect_bt3ds, proto_bt3ds);
168 proto_register_field_array(proto_bt3ds, hf, array_length(hf));
169 proto_register_subtree_array(ett, array_length(ett));
171 expert_bt3ds = expert_register_protocol(proto_bt3ds);
172 expert_register_field_array(expert_bt3ds, ei, array_length(ei));
174 module = prefs_register_protocol(proto_bt3ds, NULL);
175 prefs_register_static_text_preference(module, "3ds.version",
176 "Bluetooth Profile 3DS version: 1.0",
177 "Version of profile supported by this dissector.");
182 proto_reg_handoff_bt3ds(void)
184 dissector_add_uint("btl2cap.service", BTSDP_3D_SYNCHRONIZATION_UUID, b3ds_handle);
185 dissector_add_uint("btl2cap.service", BTSDP_3D_DISPLAY_UUID, b3ds_handle);
186 dissector_add_uint("btl2cap.service", BTSDP_3D_GLASSES_UUID, b3ds_handle);
188 dissector_add_uint("btl2cap.psm", BTL2CAP_PSM_3DS, b3ds_handle);
189 dissector_add_handle("btl2cap.cid", b3ds_handle);
193 * Editor modelines - http://www.wireshark.org/tools/modelines.html
198 * indent-tabs-mode: nil
201 * vi: set shiftwidth=4 tabstop=8 expandtab:
202 * :indentSize=4:tabSize=8:noTabs=true: