2 * Routines for Bluetooth 3DS dissection
4 * Copyright 2013, Michal Labedzki for Tieto Corporation
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 #include <epan/packet.h>
30 #include <epan/prefs.h>
31 #include <epan/expert.h>
33 #include "packet-btl2cap.h"
34 #include "packet-btsdp.h"
36 static int proto_bt3ds
= -1;
38 static int hf_message_opcode
= -1;
39 static int hf_association_notification
= -1;
40 static int hf_user_request_for_battery_level_display
= -1;
41 static int hf_reserved
= -1;
42 static int hf_battery_level
= -1;
44 static expert_field ei_message_opcode_reserved
= EI_INIT
;
45 static expert_field ei_reserved
= EI_INIT
;
46 static expert_field ei_battery_level_reserved
= EI_INIT
;
47 static expert_field ei_unexpected_data
= EI_INIT
;
49 static gint ett_bt3ds
= -1;
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 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_handle_t b3ds_handle
;
186 b3ds_handle
= find_dissector("bt3ds");
188 dissector_add_uint("btl2cap.service", BTSDP_3D_SYNCHRONIZATION_UUID
, b3ds_handle
);
189 dissector_add_uint("btl2cap.service", BTSDP_3D_DISPLAY_UUID
, b3ds_handle
);
190 dissector_add_uint("btl2cap.service", BTSDP_3D_GLASSES_UUID
, b3ds_handle
);
192 dissector_add_uint("btl2cap.psm", BTL2CAP_PSM_3DS
, b3ds_handle
);
193 dissector_add_handle("btl2cap.cid", b3ds_handle
);
197 * Editor modelines - http://www.wireshark.org/tools/modelines.html
202 * indent-tabs-mode: nil
205 * vi: set shiftwidth=4 tabstop=8 expandtab:
206 * :indentSize=4:tabSize=8:noTabs=true: