Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-hci_mon.c
blob35cf90ea85803157bbc0e4d884e0387c80b34c43
1 /* packet-hci_mon.c
2 * Routines for Bluetooth Linux Monitor 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 * SPDX-License-Identifier: GPL-2.0-or-later
13 #include "config.h"
15 #include <epan/packet.h>
16 #include <epan/prefs.h>
17 #include <epan/expert.h>
18 #include <wiretap/wtap.h>
20 #include "packet-bluetooth.h"
22 static int proto_hci_mon;
24 static int hf_adapter_id;
25 static int hf_opcode;
26 static int hf_type;
27 static int hf_bus;
28 static int hf_bd_addr;
29 static int hf_name;
30 static int hf_manufacturer;
31 static int hf_system_note;
32 static int hf_priority;
33 static int hf_ident_length;
34 static int hf_ident;
35 static int hf_message;
36 static int hf_cookie;
37 static int hf_format;
38 static int hf_version;
39 static int hf_revision;
40 static int hf_flags;
41 static int hf_flags_trusted_socket;
42 static int hf_command_length;
43 static int hf_command;
44 static int hf_event;
46 static int ett_hci_mon;
47 static int ett_flags;
49 static expert_field ei_unknown_data;
51 static wmem_tree_t *adapter_to_disconnect_in_frame;
53 static dissector_handle_t hci_mon_handle;
54 static dissector_handle_t bthci_cmd_handle;
55 static dissector_handle_t bthci_evt_handle;
56 static dissector_handle_t bthci_acl_handle;
57 static dissector_handle_t bthci_sco_handle;
58 static dissector_handle_t bthci_iso_handle;
60 #define OPCODE_NEW_INDEX 0
61 #define OPCODE_DELETE_INDEX 1
62 #define OPCODE_HCI_COMMAND_PKT 2
63 #define OPCODE_HCI_EVENT_PKT 3
64 #define OPCODE_ACL_TX_PACKET 4
65 #define OPCODE_ACL_RX_PACKET 5
66 #define OPCODE_SCO_TX_PACKET 6
67 #define OPCODE_SCO_RX_PACKET 7
68 #define OPCODE_OPEN_INDEX 8
69 #define OPCODE_CLOSE_INDEX 9
70 #define OPCODE_INDEX_INFO 10
71 #define OPCODE_VENDOR_DIAGNOSTIC 11
72 #define OPCODE_SYSTEM_NOTE 12
73 #define OPCODE_USER_LOGGING 13
74 #define OPCODE_CONTROL_OPEN 14
75 #define OPCODE_CONTROL_CLOSE 15
76 #define OPCODE_CONTROL_COMMAND 16
77 #define OPCODE_CONTROL_EVENT 17
78 #define OPCODE_ISO_TX_PACKET 18
79 #define OPCODE_ISO_RX_PACKET 19
81 static const value_string opcode_vals[] = {
82 { OPCODE_NEW_INDEX, "New Index" },
83 { OPCODE_DELETE_INDEX, "Delete Index" },
84 { OPCODE_HCI_COMMAND_PKT, "HCI Command Packet" },
85 { OPCODE_HCI_EVENT_PKT, "HCI Event Packet" },
86 { OPCODE_ACL_TX_PACKET, "ACL Tx Packet" },
87 { OPCODE_ACL_RX_PACKET, "ACL Rx Packet" },
88 { OPCODE_SCO_TX_PACKET, "SCO Tx Packet" },
89 { OPCODE_SCO_RX_PACKET, "SCO Rx Packet" },
90 { OPCODE_OPEN_INDEX, "Open Index" },
91 { OPCODE_CLOSE_INDEX, "Close Index" },
92 { OPCODE_INDEX_INFO, "Index Info" },
93 { OPCODE_VENDOR_DIAGNOSTIC, "Vendor Diagnostic" },
94 { OPCODE_SYSTEM_NOTE, "System Note" },
95 { OPCODE_USER_LOGGING, "User Logging" },
96 { OPCODE_CONTROL_OPEN, "Control Open" },
97 { OPCODE_CONTROL_CLOSE, "Control Close" },
98 { OPCODE_CONTROL_COMMAND, "Control Command" },
99 { OPCODE_CONTROL_EVENT, "Control Event" },
100 { OPCODE_ISO_TX_PACKET, "ISO Tx Packet" },
101 { OPCODE_ISO_RX_PACKET, "ISO Rx Packet" },
102 { 0, NULL }
104 value_string_ext(hci_mon_opcode_vals_ext) = VALUE_STRING_EXT_INIT(opcode_vals);
106 static const value_string type_vals[] = {
107 { 0x00, "Virtual" },
108 { 0x01, "USB" },
109 { 0x02, "PC Card" },
110 { 0x03, "UART" },
111 { 0x04, "RS232" },
112 { 0x05, "PCI" },
113 { 0x06, "SDIO" },
114 { 0x00, NULL }
116 static value_string_ext(type_vals_ext) = VALUE_STRING_EXT_INIT(type_vals);
118 static const value_string bus_vals[] = {
119 { 0x00, "BR/EDR" },
120 { 0x01, "AMP" },
121 { 0x00, NULL }
123 static value_string_ext(bus_vals_ext) = VALUE_STRING_EXT_INIT(bus_vals);
125 #define CTRL_OPEN_RAW 0x0000
126 #define CTRL_OPEN_USER 0x0001
127 #define CTRL_OPEN_CONTROL 0x0002
129 static const value_string format_vals[] = {
130 { CTRL_OPEN_RAW, "Rqw" },
131 { CTRL_OPEN_USER, "User" },
132 { CTRL_OPEN_CONTROL, "Control" },
133 { 0x00, NULL }
135 static value_string_ext(format_vals_ext) = VALUE_STRING_EXT_INIT(format_vals);
137 static const value_string priority_vals[] = {
138 { 0, "EMERG" },
139 { 1, "ALERT" },
140 { 2, "CRIT" },
141 { 3, "ERR" },
142 { 4, "WARNING" },
143 { 5, "NOTICE" },
144 { 6, "INFO" },
145 { 7, "DEBUG" },
146 { 0, NULL }
148 static value_string_ext(priority_vals_ext) = VALUE_STRING_EXT_INIT(priority_vals);
150 #define EVENT_COMMAND_COMPLETE 0x0001
151 #define EVENT_COMMAND_STATUS 0x0002
152 #define EVENT_CONTROLLER_ERROR 0x0003
153 #define EVENT_INDEX_ADDED 0x0004
154 #define EVENT_INDEX_REMOVED 0x0005
155 #define EVENT_NEW_SETTINGS 0x0006
156 #define EVENT_CLASS_OF_DEVICE_CHANGED 0x0007
157 #define EVENT_LOCAL_NAME_CHANGED 0x0008
158 #define EVENT_NEW_LINK_KEY 0x0009
159 #define EVENT_NEW_LONG_TERM_KEY 0x000a
160 #define EVENT_DEVICE_CONNECTED 0x000b
161 #define EVENT_DEVICE_DISCONNECTED 0x000c
162 #define EVENT_CONNECT_FAILED 0x000d
163 #define EVENT_PIN_CODE_REQUEST 0x000e
164 #define EVENT_USER_CONFIRMATION_REQUEST 0x000f
165 #define EVENT_USER_PASSKEY_REQUEST 0x0010
166 #define EVENT_AUTHENTICAION_FAILED 0x0011
167 #define EVENT_DEVICE_FOUND 0x0012
168 #define EVENT_DISCOVERING 0x0013
169 #define EVENT_DEVICE_BLOCKED 0x0014
170 #define EVENT_DEVICE_UNBLOCKED 0x0015
171 #define EVENT_DEVICE_UNPAIRED 0x0016
172 #define EVENT_PASSKEY_NOTIFY 0x0017
173 #define EVENT_NEW_IRK 0x0018
174 #define EVENT_NEW_CSRK 0x0019
175 #define EVENT_DEVICE_ADDED 0x001a
176 #define EVENT_DEVICE_REMOVED 0x001b
177 #define EVENT_NEW_CONNECTION_PARAMETER 0x001c
178 #define EVENT_UNCONFIGURED_INDEX_ADDED 0x001d
179 #define EVENT_UNCONFIGURED_INDEX_REMOVED 0x001e
180 #define EVENT_NEW_CONFIGURATION_OPTIONS 0x001f
181 #define EVENT_EXTENDED_INDEX_ADDED 0x0020
182 #define EVENT_EXTENDED_INDEX_REMOVED 0x0021
183 #define EVENT_LOCAL_OUT_OF_BAND_DATA_UPDATED 0x0022
184 #define EVENT_ADVERTISING_ADDED 0x0023
185 #define EVENT_ADVERTISING_REMOVED 0x0024
186 #define EVENT_EXTENDED_INFO_CHANGED 0x0025
187 #define EVENT_PHY_CONFIGURATION_CHANGED 0x0026
189 static const value_string event_vals[] = {
190 { EVENT_COMMAND_COMPLETE, "Command complete" },
191 { EVENT_COMMAND_STATUS, "Command status" },
192 { EVENT_CONTROLLER_ERROR, "Controller error" },
193 { EVENT_INDEX_ADDED, "Index added" },
194 { EVENT_INDEX_REMOVED, "Index removed" },
195 { EVENT_NEW_SETTINGS, "New settings" },
196 { EVENT_CLASS_OF_DEVICE_CHANGED, "Class of device changed" },
197 { EVENT_LOCAL_NAME_CHANGED, "Local name changed" },
198 { EVENT_NEW_LINK_KEY, "New link key" },
199 { EVENT_NEW_LONG_TERM_KEY, "New long-term key" },
200 { EVENT_DEVICE_CONNECTED, "Device connected" },
201 { EVENT_DEVICE_DISCONNECTED, "Device disconnected" },
202 { EVENT_CONNECT_FAILED, "Connect failed" },
203 { EVENT_PIN_CODE_REQUEST, "PIN code request" },
204 { EVENT_USER_CONFIRMATION_REQUEST, "User confirmation request" },
205 { EVENT_USER_PASSKEY_REQUEST, "User passkey request" },
206 { EVENT_AUTHENTICAION_FAILED, "Authentication failed" },
207 { EVENT_DEVICE_FOUND, "Device found" },
208 { EVENT_DISCOVERING, "Discovering" },
209 { EVENT_DEVICE_BLOCKED, "Device blocked" },
210 { EVENT_DEVICE_UNBLOCKED, "Device unblocked" },
211 { EVENT_DEVICE_UNPAIRED, "Device unpaired" },
212 { EVENT_PASSKEY_NOTIFY, "Passkey notify" },
213 { EVENT_NEW_IRK, "New IRK" },
214 { EVENT_NEW_CSRK, "New CSRK" },
215 { EVENT_DEVICE_ADDED, "Device added" },
216 { EVENT_DEVICE_REMOVED, "Device removed" },
217 { EVENT_NEW_CONNECTION_PARAMETER, "New connection parameter" },
218 { EVENT_UNCONFIGURED_INDEX_ADDED, "Unconfigured index added" },
219 { EVENT_UNCONFIGURED_INDEX_REMOVED, "Unconfigured index removed" },
220 { EVENT_NEW_CONFIGURATION_OPTIONS, "New configuration options" },
221 { EVENT_EXTENDED_INDEX_ADDED, "Extended index added" },
222 { EVENT_EXTENDED_INDEX_REMOVED, "Extended index removed" },
223 { EVENT_LOCAL_OUT_OF_BAND_DATA_UPDATED, "Local out-of-band data updated" },
224 { EVENT_ADVERTISING_ADDED, "Advertising added" },
225 { EVENT_ADVERTISING_REMOVED, "Advertising removed" },
226 { EVENT_EXTENDED_INFO_CHANGED, "Extended info changed" },
227 { EVENT_PHY_CONFIGURATION_CHANGED, "PHY configuration changed" },
228 { 0x00, NULL }
230 static value_string_ext(event_vals_ext) = VALUE_STRING_EXT_INIT(event_vals);
232 void proto_register_hci_mon(void);
233 void proto_reg_handoff_hci_mon(void);
235 static int
236 dissect_hci_mon(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
238 proto_tree *hci_mon_item;
239 proto_item *hci_mon_tree;
240 proto_item *sub_item;
241 int offset = 0;
242 uint16_t opcode;
243 uint16_t adapter_id;
244 bluetooth_data_t *bluetooth_data;
245 tvbuff_t *next_tvb;
246 uint32_t *adapter_disconnect_in_frame;
247 wmem_tree_t *subtree;
248 wmem_tree_key_t key[4];
249 uint32_t k_interface_id;
250 uint32_t k_adapter_id;
251 uint32_t k_frame_number;
252 uint32_t ident_length;
253 uint32_t command_length;
254 static int * const flags_fields[] = {
255 &hf_flags_trusted_socket,
256 NULL
259 bluetooth_data = (bluetooth_data_t *) data;
262 * XXX - the raw data sent to a Bluetooth monitor socket has a 6-byte
263 * header, the last 2 bytes of which are a big-endian length field,
264 * giving the length of the payload.
266 * Somehow, the length field disappears.
268 DISSECTOR_ASSERT(bluetooth_data->previous_protocol_data_type == BT_PD_BTMON);
269 adapter_id = bluetooth_data->previous_protocol_data.btmon->adapter_id;
270 opcode = bluetooth_data->previous_protocol_data.btmon->opcode;
272 if (opcode == 0x00 || opcode == 0x01)
273 pinfo->p2p_dir = P2P_DIR_RECV;
274 else if (opcode % 2)
275 pinfo->p2p_dir = P2P_DIR_RECV;
276 else
277 pinfo->p2p_dir = P2P_DIR_SENT;
279 hci_mon_item = proto_tree_add_item(tree, proto_hci_mon, tvb, offset, -1, ENC_NA);
280 hci_mon_tree = proto_item_add_subtree(hci_mon_item, ett_hci_mon);
282 col_set_str(pinfo->cinfo, COL_PROTOCOL, "HCI_MON");
284 if (opcode == 0x00 || opcode == 0x01)
285 col_set_str(pinfo->cinfo, COL_INFO, "Info ");
286 else switch (pinfo->p2p_dir) {
288 case P2P_DIR_SENT:
289 col_set_str(pinfo->cinfo, COL_INFO, "Sent ");
290 break;
292 case P2P_DIR_RECV:
293 col_set_str(pinfo->cinfo, COL_INFO, "Rcvd ");
294 break;
296 default:
297 col_set_str(pinfo->cinfo, COL_INFO, "UnknownDirection ");
298 break;
301 sub_item = proto_tree_add_uint(hci_mon_tree, hf_adapter_id, tvb, offset, 0, adapter_id);
302 proto_item_set_generated(sub_item);
304 sub_item = proto_tree_add_uint(hci_mon_tree, hf_opcode, tvb, offset, 0, opcode);
305 proto_item_set_generated(sub_item);
307 col_append_fstr(pinfo->cinfo, COL_INFO, "Adapter Id: %u, Opcode: %s",
308 adapter_id, val_to_str_ext(opcode, &hci_mon_opcode_vals_ext, "Unknown (%u)"));
310 bluetooth_data->adapter_id = adapter_id;
312 k_interface_id = bluetooth_data->interface_id;
313 k_adapter_id = adapter_id;
314 k_frame_number = pinfo->num;
316 key[0].length = 1;
317 key[0].key = &k_interface_id;
318 key[1].length = 1;
319 key[1].key = &k_adapter_id;
321 if (!pinfo->fd->visited && opcode == 0x01) { /* Delete Index */
322 uint32_t *disconnect_in_frame;
324 key[2].length = 1;
325 key[2].key = &k_frame_number;
326 key[3].length = 0;
327 key[3].key = NULL;
329 disconnect_in_frame = wmem_new(wmem_file_scope(), uint32_t);
331 if (disconnect_in_frame) {
332 *disconnect_in_frame = pinfo->num;
334 wmem_tree_insert32_array(adapter_to_disconnect_in_frame, key, disconnect_in_frame);
338 key[2].length = 0;
339 key[2].key = NULL;
341 subtree = (wmem_tree_t *) wmem_tree_lookup32_array(adapter_to_disconnect_in_frame, key);
342 adapter_disconnect_in_frame = (subtree) ? (uint32_t *) wmem_tree_lookup32_le(subtree, k_frame_number) : NULL;
343 if (adapter_disconnect_in_frame) {
344 bluetooth_data->adapter_disconnect_in_frame = adapter_disconnect_in_frame;
345 } else {
346 bluetooth_data->adapter_disconnect_in_frame = &bluetooth_max_disconnect_in_frame;
349 pinfo->ptype = PT_BLUETOOTH;
351 next_tvb = tvb_new_subset_remaining(tvb, offset);
353 switch(opcode) {
354 case OPCODE_NEW_INDEX:
355 proto_tree_add_item(hci_mon_tree, hf_bus, tvb, offset, 1, ENC_BIG_ENDIAN);
356 offset += 1;
358 proto_tree_add_item(hci_mon_tree, hf_type, tvb, offset, 1, ENC_BIG_ENDIAN);
359 offset += 1;
361 offset = dissect_bd_addr(hf_bd_addr, pinfo, hci_mon_tree, tvb, offset, true, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL);
363 proto_tree_add_item(hci_mon_tree, hf_name, tvb, offset, 8, ENC_NA | ENC_ASCII);
364 offset += 8;
366 break;
367 case OPCODE_DELETE_INDEX:
368 /* No parameters */
370 break;
371 case OPCODE_HCI_COMMAND_PKT:
372 call_dissector_with_data(bthci_cmd_handle, next_tvb, pinfo, tree, bluetooth_data);
373 offset = tvb_reported_length(tvb);
375 break;
376 case OPCODE_HCI_EVENT_PKT:
377 call_dissector_with_data(bthci_evt_handle, next_tvb, pinfo, tree, bluetooth_data);
378 offset = tvb_reported_length(tvb);
380 break;
381 case OPCODE_ACL_TX_PACKET:
382 case OPCODE_ACL_RX_PACKET:
383 call_dissector_with_data(bthci_acl_handle, next_tvb, pinfo, tree, bluetooth_data);
384 offset = tvb_reported_length(tvb);
386 break;
387 case OPCODE_SCO_TX_PACKET:
388 case OPCODE_SCO_RX_PACKET:
389 call_dissector_with_data(bthci_sco_handle, next_tvb, pinfo, tree, bluetooth_data);
390 offset = tvb_reported_length(tvb);
392 break;
394 case OPCODE_OPEN_INDEX:
395 /* No parameters */
397 break;
399 case OPCODE_CLOSE_INDEX:
400 /* No parameters */
402 break;
404 case OPCODE_INDEX_INFO:
405 offset = dissect_bd_addr(hf_bd_addr, pinfo, hci_mon_tree, tvb, offset, true, bluetooth_data->interface_id, bluetooth_data->adapter_id, NULL);
407 proto_tree_add_item(hci_mon_tree, hf_manufacturer, tvb, offset, 2, ENC_LITTLE_ENDIAN);
408 offset += 2;
410 break;
412 case OPCODE_VENDOR_DIAGNOSTIC:
413 /* XXX - what are the parameters, if any? */
415 break;
417 case OPCODE_SYSTEM_NOTE:
419 * XXX - NUL-terminated, so that you always have a NUL at the
420 * end of the message?
422 * Or is it data from userland, which might or might not be
423 * NUL-terminated?
425 * We make it FT_STRINGZPAD, just in case.
427 proto_tree_add_item(hci_mon_tree, hf_system_note, tvb, offset, tvb_reported_length_remaining(tvb, offset), ENC_NA | ENC_ASCII);
428 offset = tvb_reported_length(tvb);
430 break;
432 case OPCODE_USER_LOGGING:
433 proto_tree_add_item(hci_mon_tree, hf_priority, tvb, offset, 1, ENC_NA);
434 offset += 1;
436 proto_tree_add_item_ret_uint(hci_mon_tree, hf_ident_length, tvb, offset, 1, ENC_NA, &ident_length);
437 offset += 1;
439 proto_tree_add_item(hci_mon_tree, hf_ident, tvb, offset, ident_length, ENC_NA | ENC_ASCII);
440 offset += ident_length;
442 proto_tree_add_item(hci_mon_tree, hf_message, tvb, offset, tvb_reported_length_remaining(tvb, offset), ENC_NA | ENC_ASCII);
443 offset = tvb_reported_length(tvb);
445 break;
447 case OPCODE_CONTROL_OPEN:
448 proto_tree_add_item(hci_mon_tree, hf_cookie, tvb, offset, 4, ENC_LITTLE_ENDIAN);
449 offset += 4;
451 proto_tree_add_item(hci_mon_tree, hf_format, tvb, offset, 2, ENC_LITTLE_ENDIAN);
452 offset += 2;
454 proto_tree_add_item(hci_mon_tree, hf_version, tvb, offset, 1, ENC_NA);
455 proto_tree_add_item(hci_mon_tree, hf_revision, tvb, offset + 1, 2, ENC_LITTLE_ENDIAN);
456 offset += 3;
458 proto_tree_add_bitmask(hci_mon_tree, tvb, offset, hf_flags, ett_flags,
459 flags_fields, ENC_LITTLE_ENDIAN);
460 offset += 4;
462 proto_tree_add_item_ret_uint(hci_mon_tree, hf_command_length, tvb, offset, 1, ENC_NA, &command_length);
463 offset += 1;
466 * XXX - null-padded? We assume so; the Linux kernel code, as of
467 * the 5.3 kernel, always copies TASK_COMM_LEN bytes and sets the
468 * command length to TASK_COMM_LEN.
470 proto_tree_add_item(hci_mon_tree, hf_command, tvb, offset, command_length, ENC_NA | ENC_ASCII);
471 offset += command_length;
473 break;
475 case OPCODE_CONTROL_CLOSE:
476 proto_tree_add_item(hci_mon_tree, hf_cookie, tvb, offset, 4, ENC_LITTLE_ENDIAN);
477 offset += 4;
479 break;
481 case OPCODE_CONTROL_COMMAND:
482 proto_tree_add_item(hci_mon_tree, hf_cookie, tvb, offset, 4, ENC_LITTLE_ENDIAN);
483 offset += 4;
485 /* XXX - different field for this opcode? */
486 proto_tree_add_item(hci_mon_tree, hf_opcode, tvb, offset, 2, ENC_LITTLE_ENDIAN);
487 offset += 2;
489 break;
491 case OPCODE_CONTROL_EVENT:
492 proto_tree_add_item(hci_mon_tree, hf_cookie, tvb, offset, 4, ENC_LITTLE_ENDIAN);
493 offset += 4;
495 proto_tree_add_item(hci_mon_tree, hf_event, tvb, offset, 2, ENC_LITTLE_ENDIAN);
496 offset += 2;
498 /* XXX - dissect the payload of the event */
500 break;
502 case OPCODE_ISO_TX_PACKET:
503 case OPCODE_ISO_RX_PACKET:
504 call_dissector_with_data(bthci_iso_handle, next_tvb, pinfo, tree, bluetooth_data);
505 offset = tvb_reported_length(tvb);
507 break;
510 if (tvb_reported_length_remaining(tvb, offset) > 0) {
511 proto_tree_add_expert(hci_mon_tree, pinfo, &ei_unknown_data, tvb, offset, tvb_reported_length_remaining(tvb, offset));
512 offset = tvb_reported_length(tvb);
515 /* NOTE: Oops... HCI_MON have special packet with length 0, but there is a pseudo-header with certain infos,
516 mark it as dissected */
517 if (opcode == 0x01)
518 return 1;
520 return offset;
523 void
524 proto_register_hci_mon(void)
526 module_t *module;
527 expert_module_t *expert_module;
529 static hf_register_info hf[] = {
530 { &hf_adapter_id,
531 { "Adapter ID", "hci_mon.adapter_id",
532 FT_UINT16, BASE_DEC, NULL, 0x00,
533 NULL, HFILL }
535 { &hf_opcode,
536 { "Opcode", "hci_mon.opcode",
537 FT_UINT16, BASE_DEC | BASE_EXT_STRING, &hci_mon_opcode_vals_ext, 0x00,
538 NULL, HFILL }
540 { &hf_type,
541 { "Type", "hci_mon.type",
542 FT_UINT8, BASE_HEX | BASE_EXT_STRING, &type_vals_ext, 0x00,
543 NULL, HFILL }
545 { &hf_bus,
546 { "Bus", "hci_mon.bus",
547 FT_UINT8, BASE_HEX | BASE_EXT_STRING, &bus_vals_ext, 0x00,
548 NULL, HFILL }
550 { &hf_bd_addr,
551 { "BD_ADDR", "hci_mon.bd_addr",
552 FT_ETHER, BASE_NONE, NULL, 0x0,
553 NULL, HFILL}
555 { &hf_name,
556 { "Adapter Name", "hci_mon.adapter_name",
557 FT_STRING, BASE_NONE, NULL, 0x0,
558 NULL, HFILL}
560 { &hf_manufacturer,
561 { "Manufacturer", "hci_mon.manufacturer",
562 FT_UINT16, BASE_HEX, NULL, 0x0,
563 NULL, HFILL }
565 { &hf_system_note,
566 { "System Note", "hci_mon.system_note",
567 FT_STRINGZPAD, BASE_NONE, NULL, 0x0,
568 NULL, HFILL}
570 { &hf_priority,
571 { "Priority", "hci_mon.priority",
572 FT_UINT8, BASE_DEC | BASE_EXT_STRING, &priority_vals_ext, 0x0,
573 NULL, HFILL}
575 { &hf_ident_length,
576 { "Ident Length", "hci_mon.ident_length",
577 FT_UINT8, BASE_DEC, NULL, 0x0,
578 NULL, HFILL}
580 { &hf_ident,
581 { "Ident", "hci_mon.ident",
582 FT_STRING, BASE_NONE, NULL, 0x0,
583 NULL, HFILL}
585 { &hf_message,
586 { "Message", "hci_mon.message",
587 FT_STRING, BASE_NONE, NULL, 0x0,
588 NULL, HFILL}
590 { &hf_cookie,
591 { "Cookie", "hci_mon.cookie",
592 FT_UINT32, BASE_HEX, NULL, 0x0,
593 NULL, HFILL}
595 { &hf_format,
596 { "Format", "hci_mon.format",
597 FT_UINT16, BASE_HEX | BASE_EXT_STRING, &format_vals_ext, 0x00,
598 NULL, HFILL}
600 { &hf_version,
601 { "Version", "hci_mon.version",
602 FT_UINT8, BASE_DEC, NULL, 0x00,
603 NULL, HFILL}
605 { &hf_revision,
606 { "Revision", "hci_mon.version_minor",
607 FT_UINT16, BASE_DEC, NULL, 0x00,
608 NULL, HFILL}
610 { &hf_flags,
611 { "Flags", "hci_mon.flags",
612 FT_UINT32, BASE_HEX, NULL, 0x0,
613 NULL, HFILL}
615 { &hf_flags_trusted_socket,
616 { "Trusted Socket", "hci_mon.flags.trusted_socket",
617 FT_BOOLEAN, 32, NULL, 0x00000001,
618 NULL, HFILL}
620 { &hf_command_length,
621 { "Command Length", "hci_mon.command_length",
622 FT_UINT8, BASE_DEC, NULL, 0x0,
623 NULL, HFILL}
625 { &hf_command,
626 { "Command", "hci_mon.command",
627 FT_STRINGZPAD, BASE_NONE, NULL, 0x0,
628 NULL, HFILL}
630 { &hf_event,
631 { "Event", "hci_mon.event",
632 FT_UINT16, BASE_HEX | BASE_EXT_STRING, &event_vals_ext, 0x0,
633 NULL, HFILL}
637 static ei_register_info ei[] = {
638 { &ei_unknown_data, { "hci_mon.unknown_data", PI_PROTOCOL, PI_WARN, "Unknown data", EXPFILL }},
641 static int *ett[] = {
642 &ett_hci_mon,
643 &ett_flags
646 proto_hci_mon = proto_register_protocol("Bluetooth Linux Monitor Transport", "HCI_MON", "hci_mon");
647 proto_register_field_array(proto_hci_mon, hf, array_length(hf));
648 proto_register_subtree_array(ett, array_length(ett));
649 hci_mon_handle = register_dissector("hci_mon", dissect_hci_mon, proto_hci_mon);
651 expert_module = expert_register_protocol(proto_hci_mon);
652 expert_register_field_array(expert_module, ei, array_length(ei));
654 adapter_to_disconnect_in_frame = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope());
656 module = prefs_register_protocol_subtree("Bluetooth", proto_hci_mon, NULL);
657 prefs_register_static_text_preference(module, "bthci_mon.version",
658 "Bluetooth Linux Monitor Transport introduced in BlueZ 5.x",
659 "Version of protocol supported by this dissector.");
662 void
663 proto_reg_handoff_hci_mon(void)
665 bthci_cmd_handle = find_dissector_add_dependency("bthci_cmd", proto_hci_mon);
666 bthci_evt_handle = find_dissector_add_dependency("bthci_evt", proto_hci_mon);
667 bthci_acl_handle = find_dissector_add_dependency("bthci_acl", proto_hci_mon);
668 bthci_sco_handle = find_dissector_add_dependency("bthci_sco", proto_hci_mon);
669 bthci_iso_handle = find_dissector_add_dependency("bthci_iso", proto_hci_mon);
671 dissector_add_uint("bluetooth.encap", WTAP_ENCAP_BLUETOOTH_LINUX_MONITOR, hci_mon_handle);
675 * Editor modelines - https://www.wireshark.org/tools/modelines.html
677 * Local variables:
678 * c-basic-offset: 4
679 * tab-width: 8
680 * indent-tabs-mode: nil
681 * End:
683 * vi: set shiftwidth=4 tabstop=8 expandtab:
684 * :indentSize=4:tabSize=8:noTabs=true: