天嵌二次封装库使用手册  V1.0
mgmt.h
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * BlueZ - Bluetooth protocol stack for Linux
4  *
5  * Copyright (C) 2010 Nokia Corporation
6  * Copyright (C) 2010 Marcel Holtmann <marcel@holtmann.org>
7  *
8  *
9  */
10 
11 #ifndef __packed
12 #define __packed __attribute__((packed))
13 #endif
14 
15 #define MGMT_INDEX_NONE 0xFFFF
16 
17 #define MGMT_STATUS_SUCCESS 0x00
18 #define MGMT_STATUS_UNKNOWN_COMMAND 0x01
19 #define MGMT_STATUS_NOT_CONNECTED 0x02
20 #define MGMT_STATUS_FAILED 0x03
21 #define MGMT_STATUS_CONNECT_FAILED 0x04
22 #define MGMT_STATUS_AUTH_FAILED 0x05
23 #define MGMT_STATUS_NOT_PAIRED 0x06
24 #define MGMT_STATUS_NO_RESOURCES 0x07
25 #define MGMT_STATUS_TIMEOUT 0x08
26 #define MGMT_STATUS_ALREADY_CONNECTED 0x09
27 #define MGMT_STATUS_BUSY 0x0a
28 #define MGMT_STATUS_REJECTED 0x0b
29 #define MGMT_STATUS_NOT_SUPPORTED 0x0c
30 #define MGMT_STATUS_INVALID_PARAMS 0x0d
31 #define MGMT_STATUS_DISCONNECTED 0x0e
32 #define MGMT_STATUS_NOT_POWERED 0x0f
33 #define MGMT_STATUS_CANCELLED 0x10
34 #define MGMT_STATUS_INVALID_INDEX 0x11
35 #define MGMT_STATUS_RFKILLED 0x12
36 #define MGMT_STATUS_ALREADY_PAIRED 0x13
37 #define MGMT_STATUS_PERMISSION_DENIED 0x14
38 
39 struct mgmt_hdr {
40  uint16_t opcode;
41  uint16_t index;
42  uint16_t len;
43 } __packed;
44 #define MGMT_HDR_SIZE 6
45 
46 struct mgmt_tlv {
47  uint16_t type;
48  uint8_t length;
49  uint8_t value[];
50 } __packed;
51 
53  bdaddr_t bdaddr;
54  uint8_t type;
55 } __packed;
56 
57 #define MGMT_OP_READ_VERSION 0x0001
59  uint8_t version;
60  uint16_t revision;
61 } __packed;
62 
63 #define MGMT_OP_READ_COMMANDS 0x0002
65  uint16_t num_commands;
66  uint16_t num_events;
67  uint16_t opcodes[0];
68 } __packed;
69 
70 #define MGMT_OP_READ_INDEX_LIST 0x0003
72  uint16_t num_controllers;
73  uint16_t index[0];
74 } __packed;
75 
76 /* Reserve one extra byte for names in management messages so that they
77  * are always guaranteed to be nul-terminated */
78 #define MGMT_MAX_NAME_LENGTH (248 + 1)
79 #define MGMT_MAX_SHORT_NAME_LENGTH (10 + 1)
80 
81 #define MGMT_SETTING_POWERED 0x00000001
82 #define MGMT_SETTING_CONNECTABLE 0x00000002
83 #define MGMT_SETTING_FAST_CONNECTABLE 0x00000004
84 #define MGMT_SETTING_DISCOVERABLE 0x00000008
85 #define MGMT_SETTING_BONDABLE 0x00000010
86 #define MGMT_SETTING_LINK_SECURITY 0x00000020
87 #define MGMT_SETTING_SSP 0x00000040
88 #define MGMT_SETTING_BREDR 0x00000080
89 #define MGMT_SETTING_HS 0x00000100
90 #define MGMT_SETTING_LE 0x00000200
91 #define MGMT_SETTING_ADVERTISING 0x00000400
92 #define MGMT_SETTING_SECURE_CONN 0x00000800
93 #define MGMT_SETTING_DEBUG_KEYS 0x00001000
94 #define MGMT_SETTING_PRIVACY 0x00002000
95 #define MGMT_SETTING_CONFIGURATION 0x00004000
96 #define MGMT_SETTING_STATIC_ADDRESS 0x00008000
97 #define MGMT_SETTING_PHY_CONFIGURATION 0x00010000
98 #define MGMT_SETTING_WIDEBAND_SPEECH 0x00020000
99 
100 #define MGMT_OP_READ_INFO 0x0004
102  bdaddr_t bdaddr;
103  uint8_t version;
104  uint16_t manufacturer;
105  uint32_t supported_settings;
106  uint32_t current_settings;
107  uint8_t dev_class[3];
108  uint8_t name[MGMT_MAX_NAME_LENGTH];
109  uint8_t short_name[MGMT_MAX_SHORT_NAME_LENGTH];
110 } __packed;
111 
112 struct mgmt_mode {
113  uint8_t val;
114 } __packed;
115 
116 struct mgmt_cod {
117  uint8_t val[3];
118 } __packed;
119 
120 #define MGMT_OP_SET_POWERED 0x0005
121 
122 #define MGMT_OP_SET_DISCOVERABLE 0x0006
124  uint8_t val;
125  uint16_t timeout;
126 } __packed;
127 
128 #define MGMT_OP_SET_CONNECTABLE 0x0007
129 
130 #define MGMT_OP_SET_FAST_CONNECTABLE 0x0008
131 
132 #define MGMT_OP_SET_BONDABLE 0x0009
133 
134 #define MGMT_OP_SET_LINK_SECURITY 0x000A
135 
136 #define MGMT_OP_SET_SSP 0x000B
137 
138 #define MGMT_OP_SET_HS 0x000C
139 
140 #define MGMT_OP_SET_LE 0x000D
141 
142 #define MGMT_OP_SET_DEV_CLASS 0x000E
144  uint8_t major;
145  uint8_t minor;
146 } __packed;
147 
148 #define MGMT_OP_SET_LOCAL_NAME 0x000F
150  uint8_t name[MGMT_MAX_NAME_LENGTH];
151  uint8_t short_name[MGMT_MAX_SHORT_NAME_LENGTH];
152 } __packed;
153 
154 #define MGMT_OP_ADD_UUID 0x0010
156  uint8_t uuid[16];
157  uint8_t svc_hint;
158 } __packed;
159 
160 #define MGMT_OP_REMOVE_UUID 0x0011
162  uint8_t uuid[16];
163 } __packed;
164 
166  struct mgmt_addr_info addr;
167  uint8_t type;
168  uint8_t val[16];
169  uint8_t pin_len;
170 } __packed;
171 
172 #define MGMT_OP_LOAD_LINK_KEYS 0x0012
174  uint8_t debug_keys;
175  uint16_t key_count;
176  struct mgmt_link_key_info keys[0];
177 } __packed;
178 
180  struct mgmt_addr_info addr;
181  uint8_t type;
182  uint8_t central;
183  uint8_t enc_size;
184  uint16_t ediv;
185  uint64_t rand;
186  uint8_t val[16];
187 } __packed;
188 
189 #define MGMT_OP_LOAD_LONG_TERM_KEYS 0x0013
191  uint16_t key_count;
192  struct mgmt_ltk_info keys[0];
193 } __packed;
194 
195 #define MGMT_OP_DISCONNECT 0x0014
197  struct mgmt_addr_info addr;
198 } __packed;
200  struct mgmt_addr_info addr;
201 } __packed;
202 
203 #define MGMT_OP_GET_CONNECTIONS 0x0015
205  uint16_t conn_count;
206  struct mgmt_addr_info addr[0];
207 } __packed;
208 
209 #define MGMT_OP_PIN_CODE_REPLY 0x0016
211  struct mgmt_addr_info addr;
212  uint8_t pin_len;
213  uint8_t pin_code[16];
214 } __packed;
215 
216 #define MGMT_OP_PIN_CODE_NEG_REPLY 0x0017
218  struct mgmt_addr_info addr;
219 } __packed;
220 
221 #define MGMT_OP_SET_IO_CAPABILITY 0x0018
223  uint8_t io_capability;
224 } __packed;
225 
226 #define MGMT_OP_PAIR_DEVICE 0x0019
228  struct mgmt_addr_info addr;
229  uint8_t io_cap;
230 } __packed;
232  struct mgmt_addr_info addr;
233 } __packed;
234 
235 #define MGMT_OP_CANCEL_PAIR_DEVICE 0x001A
236 
237 #define MGMT_OP_UNPAIR_DEVICE 0x001B
239  struct mgmt_addr_info addr;
240  uint8_t disconnect;
241 } __packed;
243  struct mgmt_addr_info addr;
244 } __packed;
245 
246 #define MGMT_OP_USER_CONFIRM_REPLY 0x001C
248  struct mgmt_addr_info addr;
249 } __packed;
251  struct mgmt_addr_info addr;
252 } __packed;
253 
254 #define MGMT_OP_USER_CONFIRM_NEG_REPLY 0x001D
255 
256 #define MGMT_OP_USER_PASSKEY_REPLY 0x001E
258  struct mgmt_addr_info addr;
259  uint32_t passkey;
260 } __packed;
262  struct mgmt_addr_info addr;
263 } __packed;
264 
265 #define MGMT_OP_USER_PASSKEY_NEG_REPLY 0x001F
267  struct mgmt_addr_info addr;
268 } __packed;
269 
270 #define MGMT_OP_READ_LOCAL_OOB_DATA 0x0020
272  uint8_t hash192[16];
273  uint8_t rand192[16];
274  uint8_t hash256[16];
275  uint8_t rand256[16];
276 } __packed;
277 
278 #define MGMT_OP_ADD_REMOTE_OOB_DATA 0x0021
280  struct mgmt_addr_info addr;
281  uint8_t hash192[16];
282  uint8_t rand192[16];
283  uint8_t hash256[16];
284  uint8_t rand256[16];
285 } __packed;
286 
287 #define MGMT_OP_REMOVE_REMOTE_OOB_DATA 0x0022
289  struct mgmt_addr_info addr;
290 } __packed;
291 
292 #define MGMT_OP_START_DISCOVERY 0x0023
294  uint8_t type;
295 } __packed;
296 
297 #define MGMT_OP_STOP_DISCOVERY 0x0024
299  uint8_t type;
300 } __packed;
301 
302 #define MGMT_OP_CONFIRM_NAME 0x0025
304  struct mgmt_addr_info addr;
305  uint8_t name_known;
306 } __packed;
308  struct mgmt_addr_info addr;
309 } __packed;
310 
311 #define MGMT_OP_BLOCK_DEVICE 0x0026
313  struct mgmt_addr_info addr;
314 } __packed;
315 
316 #define MGMT_OP_UNBLOCK_DEVICE 0x0027
318  struct mgmt_addr_info addr;
319 } __packed;
320 
321 #define MGMT_OP_SET_DEVICE_ID 0x0028
323  uint16_t source;
324  uint16_t vendor;
325  uint16_t product;
326  uint16_t version;
327 } __packed;
328 
329 #define MGMT_OP_SET_ADVERTISING 0x0029
330 
331 #define MGMT_OP_SET_BREDR 0x002A
332 
333 #define MGMT_OP_SET_STATIC_ADDRESS 0x002B
335  bdaddr_t bdaddr;
336 } __packed;
337 
338 #define MGMT_OP_SET_SCAN_PARAMS 0x002C
340  uint16_t interval;
341  uint16_t window;
342 } __packed;
343 
344 #define MGMT_OP_SET_SECURE_CONN 0x002D
345 
346 #define MGMT_OP_SET_DEBUG_KEYS 0x002E
347 
349  struct mgmt_addr_info addr;
350  uint8_t val[16];
351 } __packed;
352 
353 #define MGMT_OP_SET_PRIVACY 0x002F
355  uint8_t privacy;
356  uint8_t irk[16];
357 } __packed;
358 
359 #define MGMT_OP_LOAD_IRKS 0x0030
361  uint16_t irk_count;
362  struct mgmt_irk_info irks[0];
363 } __packed;
364 
365 #define MGMT_OP_GET_CONN_INFO 0x0031
367  struct mgmt_addr_info addr;
368 } __packed;
370  struct mgmt_addr_info addr;
371  int8_t rssi;
372  int8_t tx_power;
373  int8_t max_tx_power;
374 } __packed;
375 
376 #define MGMT_OP_GET_CLOCK_INFO 0x0032
378  struct mgmt_addr_info addr;
379 } __packed;
381  struct mgmt_addr_info addr;
382  uint32_t local_clock;
383  uint32_t piconet_clock;
384  uint16_t accuracy;
385 } __packed;
386 
387 #define MGMT_OP_ADD_DEVICE 0x0033
389  struct mgmt_addr_info addr;
390  uint8_t action;
391 } __packed;
393  struct mgmt_addr_info addr;
394 } __packed;
395 
396 #define MGMT_OP_REMOVE_DEVICE 0x0034
398  struct mgmt_addr_info addr;
399 } __packed;
401  struct mgmt_addr_info addr;
402 } __packed;
403 
405  struct mgmt_addr_info addr;
406  uint16_t min_interval;
407  uint16_t max_interval;
408  uint16_t latency;
409  uint16_t timeout;
410 } __packed;
411 
412 #define MGMT_OP_LOAD_CONN_PARAM 0x0035
414  uint16_t param_count;
415  struct mgmt_conn_param params[0];
416 } __packed;
417 
418 #define MGMT_OP_READ_UNCONF_INDEX_LIST 0x0036
420  uint16_t num_controllers;
421  uint16_t index[0];
422 } __packed;
423 
424 #define MGMT_OPTION_EXTERNAL_CONFIG 0x00000001
425 #define MGMT_OPTION_PUBLIC_ADDRESS 0x00000002
426 
427 #define MGMT_OP_READ_CONFIG_INFO 0x0037
429  uint16_t manufacturer;
430  uint32_t supported_options;
431  uint32_t missing_options;
432 } __packed;
433 
434 #define MGMT_OP_SET_EXTERNAL_CONFIG 0x0038
436  uint8_t config;
437 } __packed;
438 
439 #define MGMT_OP_SET_PUBLIC_ADDRESS 0x0039
441  bdaddr_t bdaddr;
442 } __packed;
443 
444 #define MGMT_OP_START_SERVICE_DISCOVERY 0x003A
446  uint8_t type;
447  int8_t rssi;
448  uint16_t uuid_count;
449  uint8_t uuids[0][16];
450 } __packed;
451 
452 #define MGMT_OP_READ_LOCAL_OOB_EXT_DATA 0x003B
454  uint8_t type;
455 } __packed;
457  uint8_t type;
458  uint16_t eir_len;
459  uint8_t eir[0];
460 } __packed;
461 
462 #define MGMT_OP_READ_EXT_INDEX_LIST 0x003C
464  uint16_t num_controllers;
465  struct {
466  uint16_t index;
467  uint8_t type;
468  uint8_t bus;
469  } entry[0];
470 } __packed;
471 
472 #define MGMT_OP_READ_ADV_FEATURES 0x003D
474  uint32_t supported_flags;
475  uint8_t max_adv_data_len;
476  uint8_t max_scan_rsp_len;
477  uint8_t max_instances;
478  uint8_t num_instances;
479  uint8_t instance[0];
480 } __packed;
481 
482 #define MGMT_OP_ADD_ADVERTISING 0x003E
484  uint8_t instance;
485  uint32_t flags;
486  uint16_t duration;
487  uint16_t timeout;
488  uint8_t adv_data_len;
489  uint8_t scan_rsp_len;
490  uint8_t data[0];
491 } __packed;
493  uint8_t instance;
494 } __packed;
495 
496 #define MGMT_ADV_FLAG_CONNECTABLE (1 << 0)
497 #define MGMT_ADV_FLAG_DISCOV (1 << 1)
498 #define MGMT_ADV_FLAG_LIMITED_DISCOV (1 << 2)
499 #define MGMT_ADV_FLAG_MANAGED_FLAGS (1 << 3)
500 #define MGMT_ADV_FLAG_TX_POWER (1 << 4)
501 #define MGMT_ADV_FLAG_APPEARANCE (1 << 5)
502 #define MGMT_ADV_FLAG_LOCAL_NAME (1 << 6)
503 #define MGMT_ADV_FLAG_SEC_1M (1 << 7)
504 #define MGMT_ADV_FLAG_SEC_2M (1 << 8)
505 #define MGMT_ADV_FLAG_SEC_CODED (1 << 9)
506 #define MGMT_ADV_FLAG_CAN_SET_TX_POWER (1 << 10)
507 #define MGMT_ADV_FLAG_HW_OFFLOAD (1 << 11)
508 #define MGMT_ADV_PARAM_DURATION (1 << 12)
509 #define MGMT_ADV_PARAM_TIMEOUT (1 << 13)
510 #define MGMT_ADV_PARAM_INTERVALS (1 << 14)
511 #define MGMT_ADV_PARAM_TX_POWER (1 << 15)
512 #define MGMT_ADV_PARAM_SCAN_RSP (1 << 16)
513 
514 #define MGMT_OP_REMOVE_ADVERTISING 0x003F
516  uint8_t instance;
517 } __packed;
518 #define MGMT_REMOVE_ADVERTISING_SIZE 1
520  uint8_t instance;
521 } __packed;
522 
523 #define MGMT_OP_GET_ADV_SIZE_INFO 0x0040
525  uint8_t instance;
526  uint32_t flags;
527 } __packed;
528 #define MGMT_GET_ADV_SIZE_INFO_SIZE 5
530  uint8_t instance;
531  uint32_t flags;
532  uint8_t max_adv_data_len;
533  uint8_t max_scan_rsp_len;
534 } __packed;
535 
536 #define MGMT_OP_START_LIMITED_DISCOVERY 0x0041
537 
538 #define MGMT_OP_READ_EXT_INFO 0x0042
540  bdaddr_t bdaddr;
541  uint8_t version;
542  uint16_t manufacturer;
543  uint32_t supported_settings;
544  uint32_t current_settings;
545  uint16_t eir_len;
546  uint8_t eir[0];
547 } __packed;
548 
549 #define MGMT_OP_SET_APPEARANCE 0x0043
551  uint16_t appearance;
552 } __packed;
553 
554 #define MGMT_OP_GET_PHY_CONFIGURATION 0x0044
556  uint32_t supported_phys;
557  uint32_t configurable_phys;
558  uint32_t selected_phys;
559 } __packed;
560 
561 #define MGMT_PHY_BR_1M_1SLOT 0x00000001
562 #define MGMT_PHY_BR_1M_3SLOT 0x00000002
563 #define MGMT_PHY_BR_1M_5SLOT 0x00000004
564 #define MGMT_PHY_EDR_2M_1SLOT 0x00000008
565 #define MGMT_PHY_EDR_2M_3SLOT 0x00000010
566 #define MGMT_PHY_EDR_2M_5SLOT 0x00000020
567 #define MGMT_PHY_EDR_3M_1SLOT 0x00000040
568 #define MGMT_PHY_EDR_3M_3SLOT 0x00000080
569 #define MGMT_PHY_EDR_3M_5SLOT 0x00000100
570 #define MGMT_PHY_LE_1M_TX 0x00000200
571 #define MGMT_PHY_LE_1M_RX 0x00000400
572 #define MGMT_PHY_LE_2M_TX 0x00000800
573 #define MGMT_PHY_LE_2M_RX 0x00001000
574 #define MGMT_PHY_LE_CODED_TX 0x00002000
575 #define MGMT_PHY_LE_CODED_RX 0x00004000
576 
577 #define MGMT_PHY_LE_TX_MASK (MGMT_PHY_LE_1M_TX | MGMT_PHY_LE_2M_TX | \
578  MGMT_PHY_LE_CODED_TX)
579 #define MGMT_PHY_LE_RX_MASK (MGMT_PHY_LE_1M_RX | MGMT_PHY_LE_2M_RX | \
580  MGMT_PHY_LE_CODED_RX)
581 
582 #define MGMT_OP_SET_PHY_CONFIGURATION 0x0045
584  uint32_t selected_phys;
585 } __packed;
586 
587 #define MGMT_OP_SET_BLOCKED_KEYS 0x0046
588 
589 #define MGMT_OP_SET_WIDEBAND_SPEECH 0x0047
590 
591 #define HCI_BLOCKED_KEY_TYPE_LINKKEY 0x00
592 #define HCI_BLOCKED_KEY_TYPE_LTK 0x01
593 #define HCI_BLOCKED_KEY_TYPE_IRK 0x02
594 
596  uint8_t type;
597  uint8_t val[16];
598 } __packed;
599 
601  uint16_t key_count;
602  struct mgmt_blocked_key_info keys[0];
603 } __packed;
604 
605 #define MGMT_CAP_SEC_FLAGS 0x01
606 #define MGMT_CAP_MAX_ENC_KEY_SIZE 0x02
607 #define MGMT_CAP_SMP_MAX_ENC_KEY_SIZE 0x03
608 #define MGMT_CAP_LE_TX_PWR 0x04
609 
610 #define MGMT_OP_READ_CONTROLLER_CAP 0x0048
611 #define MGMT_READ_CONTROLLER_CAP_SIZE 0
613  uint16_t cap_len;
614  uint8_t cap[0];
615 } __packed;
616 
617 #define MGMT_OP_READ_EXP_FEATURES_INFO 0x0049
619  uint16_t feature_count;
620  struct {
621  uint8_t uuid[16];
622  uint32_t flags;
623  } features[];
624 } __packed;
625 
626 #define MGMT_OP_SET_EXP_FEATURE 0x004a
628  uint8_t uuid[16];
629  uint8_t action;
630 } __packed;
631 #define MGMT_SET_EXP_FEATURE_SIZE 17
633  uint8_t uuid[16];
634  uint32_t flags;
635 } __packed;
636 
637 #define MGMT_OP_READ_DEF_SYSTEM_CONFIG 0x004b
639  uint8_t parameters[0]; /* mgmt_tlv */
640 } __packed;
641 
642 #define MGMT_OP_SET_DEF_SYSTEM_CONFIG 0x004c
644  uint8_t parameters[0]; /* mgmt_tlv */
645 } __packed;
646 
647 #define MGMT_OP_READ_DEF_RUNTIME_CONFIG 0x004d
649  uint8_t parameters[0]; /* mgmt_tlv */
650 } __packed;
651 
652 #define MGMT_OP_SET_DEF_RUNTIME_CONFIG 0x004e
654  uint8_t parameters[0]; /* mgmt_tlv */
655 } __packed;
656 
657 #define MGMT_OP_GET_DEVICE_FLAGS 0x004F
658 #define MGMT_GET_DEVICE_FLAGS_SIZE 7
660  struct mgmt_addr_info addr;
661 } __packed;
663  struct mgmt_addr_info addr;
664  uint32_t supported_flags;
665  uint32_t current_flags;
666 } __packed;
667 
668 #define DEVICE_FLAG_REMOTE_WAKEUP BIT(0)
669 #define DEVICE_FLAG_DEVICE_PRIVACY BIT(1)
670 
671 #define MGMT_OP_SET_DEVICE_FLAGS 0x0050
672 #define MGMT_SET_DEVICE_FLAGS_SIZE 11
674  struct mgmt_addr_info addr;
675  uint32_t current_flags;
676 } __packed;
678  struct mgmt_addr_info addr;
679 } __packed;
680 
681 #define MGMT_ADV_MONITOR_FEATURE_MASK_OR_PATTERNS (1 << 0)
682 
683 #define MGMT_OP_READ_ADV_MONITOR_FEATURES 0x0051
685  uint32_t supported_features;
686  uint32_t enabled_features;
687  uint16_t max_num_handles;
688  uint8_t max_num_patterns;
689  uint16_t num_handles;
690  uint16_t handles[0];
691 } __packed;
692 
694  uint8_t ad_type;
695  uint8_t offset;
696  uint8_t length;
697  uint8_t value[31];
698 } __packed;
699 
700 #define MGMT_OP_ADD_ADV_PATTERNS_MONITOR 0x0052
702  uint8_t pattern_count;
703  struct mgmt_adv_pattern patterns[0];
704 } __packed;
706  uint16_t monitor_handle;
707 } __packed;
708 
709 #define MGMT_OP_REMOVE_ADV_MONITOR 0x0053
711  uint16_t monitor_handle;
712 } __packed;
714  uint16_t monitor_handle;
715 } __packed;
716 
717 #define MGMT_OP_ADD_EXT_ADV_PARAMS 0x0054
719  uint8_t instance;
720  uint32_t flags;
721  uint16_t duration;
722  uint16_t timeout;
723  uint32_t min_interval;
724  uint32_t max_interval;
725  int8_t tx_power;
726 } __packed;
728  uint8_t instance;
729  int8_t tx_power;
730  uint8_t max_adv_data_len;
731  uint8_t max_scan_rsp_len;
732 } __packed;
733 
734 #define MGMT_OP_ADD_EXT_ADV_DATA 0x0055
736  uint8_t instance;
737  uint8_t adv_data_len;
738  uint8_t scan_rsp_len;
739  uint8_t data[0];
740 } __packed;
742  uint8_t instance;
743 } __packed;
744 
746  int8_t high_threshold;
747  uint16_t high_threshold_timeout;
748  int8_t low_threshold;
749  uint16_t low_threshold_timeout;
750  uint8_t sampling_period;
751 } __packed;
752 
753 #define MGMT_OP_ADD_ADV_PATTERNS_MONITOR_RSSI 0x0056
755  struct mgmt_adv_rssi_thresholds rssi;
756  uint8_t pattern_count;
757  struct mgmt_adv_pattern patterns[0];
758 } __packed;
759 
760 #define MGMT_EV_CMD_COMPLETE 0x0001
762  uint16_t opcode;
763  uint8_t status;
764  uint8_t data[0];
765 } __packed;
766 
767 #define MGMT_EV_CMD_STATUS 0x0002
769  uint16_t opcode;
770  uint8_t status;
771 } __packed;
772 
773 #define MGMT_EV_CONTROLLER_ERROR 0x0003
775  uint8_t error_code;
776 } __packed;
777 
778 #define MGMT_EV_INDEX_ADDED 0x0004
779 
780 #define MGMT_EV_INDEX_REMOVED 0x0005
781 
782 #define MGMT_EV_NEW_SETTINGS 0x0006
783 
784 #define MGMT_EV_CLASS_OF_DEV_CHANGED 0x0007
786  uint8_t dev_class[3];
787 } __packed;
788 
789 #define MGMT_EV_LOCAL_NAME_CHANGED 0x0008
791  uint8_t name[MGMT_MAX_NAME_LENGTH];
792  uint8_t short_name[MGMT_MAX_SHORT_NAME_LENGTH];
793 } __packed;
794 
795 #define MGMT_EV_NEW_LINK_KEY 0x0009
797  uint8_t store_hint;
798  struct mgmt_link_key_info key;
799 } __packed;
800 
801 #define MGMT_EV_NEW_LONG_TERM_KEY 0x000A
803  uint8_t store_hint;
804  struct mgmt_ltk_info key;
805 } __packed;
806 
807 #define MGMT_EV_DEVICE_CONNECTED 0x000B
809  struct mgmt_addr_info addr;
810  uint32_t flags;
811  uint16_t eir_len;
812  uint8_t eir[0];
813 } __packed;
814 
815 #define MGMT_DEV_DISCONN_UNKNOWN 0x00
816 #define MGMT_DEV_DISCONN_TIMEOUT 0x01
817 #define MGMT_DEV_DISCONN_LOCAL_HOST 0x02
818 #define MGMT_DEV_DISCONN_REMOTE 0x03
819 #define MGMT_DEV_DISCONN_LOCAL_HOST_SUSPEND 0x05
820 
821 #define MGMT_EV_DEVICE_DISCONNECTED 0x000C
823  struct mgmt_addr_info addr;
824  uint8_t reason;
825 } __packed;
826 
827 #define MGMT_EV_CONNECT_FAILED 0x000D
829  struct mgmt_addr_info addr;
830  uint8_t status;
831 } __packed;
832 
833 #define MGMT_EV_PIN_CODE_REQUEST 0x000E
835  struct mgmt_addr_info addr;
836  uint8_t secure;
837 } __packed;
838 
839 #define MGMT_EV_USER_CONFIRM_REQUEST 0x000F
841  struct mgmt_addr_info addr;
842  uint8_t confirm_hint;
843  uint32_t value;
844 } __packed;
845 
846 #define MGMT_EV_USER_PASSKEY_REQUEST 0x0010
848  struct mgmt_addr_info addr;
849 } __packed;
850 
851 #define MGMT_EV_AUTH_FAILED 0x0011
853  struct mgmt_addr_info addr;
854  uint8_t status;
855 } __packed;
856 
857 #define MGMT_DEV_FOUND_CONFIRM_NAME 0x01
858 #define MGMT_DEV_FOUND_LEGACY_PAIRING 0x02
859 #define MGMT_DEV_FOUND_NOT_CONNECTABLE 0x04
860 
861 #define MGMT_EV_DEVICE_FOUND 0x0012
863  struct mgmt_addr_info addr;
864  int8_t rssi;
865  uint32_t flags;
866  uint16_t eir_len;
867  uint8_t eir[0];
868 } __packed;
869 
870 #define MGMT_EV_DISCOVERING 0x0013
872  uint8_t type;
873  uint8_t discovering;
874 } __packed;
875 
876 #define MGMT_EV_DEVICE_BLOCKED 0x0014
878  struct mgmt_addr_info addr;
879 } __packed;
880 
881 #define MGMT_EV_DEVICE_UNBLOCKED 0x0015
883  struct mgmt_addr_info addr;
884 } __packed;
885 
886 #define MGMT_EV_DEVICE_UNPAIRED 0x0016
888  struct mgmt_addr_info addr;
889 } __packed;
890 
891 #define MGMT_EV_PASSKEY_NOTIFY 0x0017
893  struct mgmt_addr_info addr;
894  uint32_t passkey;
895  uint8_t entered;
896 } __packed;
897 
898 #define MGMT_EV_NEW_IRK 0x0018
900  uint8_t store_hint;
901  bdaddr_t rpa;
902  struct mgmt_irk_info key;
903 } __packed;
904 
906  struct mgmt_addr_info addr;
907  uint8_t type;
908  uint8_t val[16];
909 } __packed;
910 
911 #define MGMT_EV_NEW_CSRK 0x0019
913  uint8_t store_hint;
914  struct mgmt_csrk_info key;
915 } __packed;
916 
917 #define MGMT_EV_DEVICE_ADDED 0x001a
919  struct mgmt_addr_info addr;
920  uint8_t action;
921 } __packed;
922 
923 #define MGMT_EV_DEVICE_REMOVED 0x001b
925  struct mgmt_addr_info addr;
926 } __packed;
927 
928 #define MGMT_EV_NEW_CONN_PARAM 0x001c
930  struct mgmt_addr_info addr;
931  uint8_t store_hint;
932  uint16_t min_interval;
933  uint16_t max_interval;
934  uint16_t latency;
935  uint16_t timeout;
936 } __packed;
937 
938 #define MGMT_EV_UNCONF_INDEX_ADDED 0x001d
939 
940 #define MGMT_EV_UNCONF_INDEX_REMOVED 0x001e
941 
942 #define MGMT_EV_NEW_CONFIG_OPTIONS 0x001f
943 
944 #define MGMT_EV_EXT_INDEX_ADDED 0x0020
946  uint8_t type;
947  uint8_t bus;
948 } __packed;
949 
950 #define MGMT_EV_EXT_INDEX_REMOVED 0x0021
952  uint8_t type;
953  uint8_t bus;
954 } __packed;
955 
956 #define MGMT_EV_LOCAL_OOB_DATA_UPDATED 0x0022
958  uint8_t type;
959  uint16_t eir_len;
960  uint8_t eir[0];
961 } __packed;
962 
963 #define MGMT_EV_ADVERTISING_ADDED 0x0023
965  uint8_t instance;
966 } __packed;
967 
968 #define MGMT_EV_ADVERTISING_REMOVED 0x0024
970  uint8_t instance;
971 } __packed;
972 
973 #define MGMT_EV_EXT_INFO_CHANGED 0x0025
975  uint16_t eir_len;
976  uint8_t eir[0];
977 } __packed;
978 
979 #define MGMT_EV_PHY_CONFIGURATION_CHANGED 0x0026
981  uint16_t selected_phys;
982 } __packed;
983 
984 #define MGMT_EV_EXP_FEATURE_CHANGE 0x0027
986  uint8_t uuid[16];
987  uint32_t flags;
988 } __packed;
989 
990 #define MGMT_EV_DEVICE_FLAGS_CHANGED 0x002a
992  struct mgmt_addr_info addr;
993  uint32_t supported_flags;
994  uint32_t current_flags;
995 } __packed;
996 
997 #define MGMT_EV_ADV_MONITOR_ADDED 0x002b
999  uint16_t monitor_handle;
1000 } __packed;
1001 
1002 #define MGMT_EV_ADV_MONITOR_REMOVED 0x002c
1004  uint16_t monitor_handle;
1005 } __packed;
1006 
1007 #define MGMT_EV_CONTROLLER_SUSPEND 0x002d
1009  uint8_t suspend_state;
1010 } __packed;
1011 
1012 #define MGMT_EV_CONTROLLER_RESUME 0x002e
1014  struct mgmt_addr_info addr;
1015  uint8_t wake_reason;
1016 } __packed;
1017 
1018 static const char *mgmt_op[] = {
1019  "<0x0000>",
1020  "Read Version",
1021  "Read Commands",
1022  "Read Index List",
1023  "Read Controller Info",
1024  "Set Powered",
1025  "Set Discoverable",
1026  "Set Connectable",
1027  "Set Fast Connectable", /* 0x0008 */
1028  "Set Bondable",
1029  "Set Link Security",
1030  "Set Secure Simple Pairing",
1031  "Set High Speed",
1032  "Set Low Energy",
1033  "Set Dev Class",
1034  "Set Local Name",
1035  "Add UUID", /* 0x0010 */
1036  "Remove UUID",
1037  "Load Link Keys",
1038  "Load Long Term Keys",
1039  "Disconnect",
1040  "Get Connections",
1041  "PIN Code Reply",
1042  "PIN Code Neg Reply",
1043  "Set IO Capability", /* 0x0018 */
1044  "Pair Device",
1045  "Cancel Pair Device",
1046  "Unpair Device",
1047  "User Confirm Reply",
1048  "User Confirm Neg Reply",
1049  "User Passkey Reply",
1050  "User Passkey Neg Reply",
1051  "Read Local OOB Data", /* 0x0020 */
1052  "Add Remote OOB Data",
1053  "Remove Remove OOB Data",
1054  "Start Discovery",
1055  "Stop Discovery",
1056  "Confirm Name",
1057  "Block Device",
1058  "Unblock Device",
1059  "Set Device ID", /* 0x0028 */
1060  "Set Advertising",
1061  "Set BR/EDR",
1062  "Set Static Address",
1063  "Set Scan Parameters",
1064  "Set Secure Connections",
1065  "Set Debug Keys",
1066  "Set Privacy",
1067  "Load Identity Resolving Keys", /* 0x0030 */
1068  "Get Connection Information",
1069  "Get Clock Information",
1070  "Add Device",
1071  "Remove Device",
1072  "Load Connection Parameters",
1073  "Read Unconfigured Index List",
1074  "Read Controller Configuration Information",
1075  "Set External Configuration", /* 0x0038 */
1076  "Set Public Address",
1077  "Start Service Discovery",
1078  "Read Local Out Of Band Extended Data",
1079  "Read Extended Controller Index List",
1080  "Read Advertising Features",
1081  "Add Advertising",
1082  "Remove Advertising",
1083  "Get Advertising Size Information", /* 0x0040 */
1084  "Start Limited Discovery",
1085  "Read Extended Controller Information",
1086  "Set Appearance",
1087  "Get PHY Configuration",
1088  "Set PHY Configuration",
1089  "Set Blocked Keys",
1090  "Set Wideband Speech",
1091  "Read Controller Capabilities Information", /* 0x0048 */
1092  "Read Experimental Features Information",
1093  "Set Experimental Feature",
1094  "Read Default System Configuration",
1095  "Set Default System Configuration",
1096  "Read Default Runtime Configuration",
1097  "Set Default Runtime Configuration",
1098  "Get Device Flags",
1099  "Set Device Flags", /* 0x0050 */
1100  "Read Advertisement Monitor Features",
1101  "Add Advertisement Patterns Monitor",
1102  "Remove Advertisement Monitor",
1103  "Add Extended Advertisement Parameters", /* 0x0054 */
1104  "Add Extended Advertisement Data",
1105  "Add Advertisement Patterns Monitor RSSI",
1106 };
1107 
1108 static const char *mgmt_ev[] = {
1109  "<0x0000>",
1110  "Command Complete",
1111  "Command Status",
1112  "Controller Error",
1113  "Index Added",
1114  "Index Removed",
1115  "New Settings",
1116  "Class of Device Changed",
1117  "Local Name Changed", /* 0x0008 */
1118  "New Link Key",
1119  "New Long Term Key",
1120  "Device Connected",
1121  "Device Disconnected",
1122  "Connect Failed",
1123  "PIN Code Request",
1124  "User Confirm Request",
1125  "User Passkey Request", /* 0x0010 */
1126  "Authentication Failed",
1127  "Device Found",
1128  "Discovering",
1129  "Device Blocked",
1130  "Device Unblocked",
1131  "Device Unpaired",
1132  "Passkey Notify",
1133  "New Identity Resolving Key", /* 0x0018 */
1134  "New Signature Resolving Key",
1135  "Device Added",
1136  "Device Removed",
1137  "New Connection Parameter",
1138  "Unconfigured Index Added",
1139  "Unconfigured Index Removed",
1140  "New Configuration Options",
1141  "Extended Index Added", /* 0x0020 */
1142  "Extended Index Removed",
1143  "Local Out Of Band Extended Data Updated",
1144  "Advertising Added",
1145  "Advertising Removed",
1146  "Extended Controller Information Changed",
1147  "PHY Configuration Changed",
1148  "Experimental Feature Changed",
1149  "Default System Configuration Changed", /* 0x0028 */
1150  "Default Runtime Configuration Changed",
1151  "Device Flags Changed",
1152  "Advertisement Monitor Added", /* 0x002b */
1153  "Advertisement Monitor Removed",
1154  "Controller Suspend",
1155  "Controller Resume",
1156 };
1157 
1158 static const char *mgmt_status[] = {
1159  "Success",
1160  "Unknown Command",
1161  "Not Connected",
1162  "Failed",
1163  "Connect Failed",
1164  "Authentication Failed",
1165  "Not Paired",
1166  "No Resources",
1167  "Timeout",
1168  "Already Connected",
1169  "Busy",
1170  "Rejected",
1171  "Not Supported",
1172  "Invalid Parameters",
1173  "Disconnected",
1174  "Not Powered",
1175  "Cancelled",
1176  "Invalid Index",
1177  "Blocked through rfkill",
1178  "Already Paired",
1179  "Permission Denied",
1180  "Connection Not Established",
1181 };
1182 
1183 #ifndef NELEM
1184 #define NELEM(x) (sizeof(x) / sizeof((x)[0]))
1185 #endif
1186 
1187 static inline const char *mgmt_opstr(uint16_t op)
1188 {
1189  if (op >= NELEM(mgmt_op))
1190  return "<unknown opcode>";
1191  return mgmt_op[op];
1192 }
1193 
1194 static inline const char *mgmt_evstr(uint16_t ev)
1195 {
1196  if (ev >= NELEM(mgmt_ev))
1197  return "<unknown event>";
1198  return mgmt_ev[ev];
1199 }
1200 
1201 static inline const char *mgmt_errstr(uint8_t status)
1202 {
1203  if (status >= NELEM(mgmt_status))
1204  return "<unknown status>";
1205  return mgmt_status[status];
1206 }
Definition: mgmt.h:673
Definition: mgmt.h:985
Definition: mgmt.h:419
Definition: mgmt.h:377
Definition: mgmt.h:951
Definition: mgmt.h:204
Definition: mgmt.h:483
Definition: mgmt.h:58
Definition: mgmt.h:887
Definition: mgmt.h:918
Definition: mgmt.h:847
Definition: mgmt.h:710
Definition: mgmt.h:46
Definition: mgmt.h:745
Definition: mgmt.h:701
Definition: mgmt.h:912
Definition: mgmt.h:529
Definition: mgmt.h:929
Definition: mgmt.h:231
Definition: mgmt.h:261
Definition: mgmt.h:123
Definition: mgmt.h:550
Definition: mgmt.h:662
Definition: mgmt.h:397
Definition: mgmt.h:400
Definition: mgmt.h:227
Definition: mgmt.h:217
Definition: mgmt.h:143
Definition: mgmt.h:242
Definition: mgmt.h:435
Definition: mgmt.h:595
Definition: mgmt.h:473
Definition: mgmt.h:882
Definition: mgmt.h:247
Definition: mgmt.h:519
Definition: mgmt.h:52
Definition: mgmt.h:964
Definition: mgmt.h:1013
Definition: mgmt.h:980
Definition: mgmt.h:453
Definition: mgmt.h:456
Definition: mgmt.h:969
Definition: mgmt.h:445
Definition: mgmt.h:199
Definition: mgmt.h:317
Definition: mgmt.h:322
Definition: mgmt.h:677
Definition: mgmt.h:632
Definition: mgmt.h:768
Definition: mgmt.h:834
Definition: mgmt.h:1008
Definition: mgmt.h:862
Definition: mgmt.h:161
Definition: mgmt.h:404
Definition: mgmt.h:627
Definition: mgmt.h:210
Definition: mgmt.h:348
Definition: mgmt.h:463
Definition: mgmt.h:413
Definition: mgmt.h:583
Definition: mgmt.h:808
Definition: mgmt.h:643
Definition: mgmt.h:116
Definition: mgmt.h:892
Definition: mgmt.h:945
Definition: mgmt.h:774
Definition: mgmt.h:905
Definition: mgmt.h:735
Definition: mgmt.h:957
Definition: mgmt.h:155
Definition: mgmt.h:257
Definition: mgmt.h:428
Definition: mgmt.h:790
Definition: mgmt.h:741
Definition: mgmt.h:112
Definition: mgmt.h:1003
Definition: mgmt.h:369
Definition: mgmt.h:492
Definition: mgmt.h:705
Definition: mgmt.h:515
Definition: mgmt.h:303
Definition: mgmt.h:271
Definition: mgmt.h:334
Definition: mgmt.h:39
Definition: mgmt.h:298
Definition: mgmt.h:222
Definition: mgmt.h:266
Definition: mgmt.h:924
Definition: mgmt.h:149
Definition: mgmt.h:307
Definition: mgmt.h:196
Definition: mgmt.h:524
Definition: mgmt.h:761
Definition: mgmt.h:354
Definition: mgmt.h:899
Definition: mgmt.h:877
Definition: mgmt.h:727
Definition: mgmt.h:991
Definition: mgmt.h:828
Definition: mgmt.h:539
Definition: mgmt.h:64
Definition: mgmt.h:785
Definition: mgmt.h:840
Definition: mgmt.h:718
Definition: mgmt.h:618
Definition: mgmt.h:190
Definition: mgmt.h:612
Definition: mgmt.h:802
Definition: mgmt.h:288
Definition: mgmt.h:293
Definition: mgmt.h:555
Definition: mgmt.h:392
Definition: mgmt.h:440
Definition: mgmt.h:659
Definition: mgmt.h:179
Definition: mgmt.h:101
Definition: mgmt.h:250
Definition: mgmt.h:871
Definition: mgmt.h:684
Definition: mgmt.h:974
Definition: mgmt.h:238
Definition: mgmt.h:822
Definition: mgmt.h:388
Definition: mgmt.h:312
Definition: mgmt.h:339
Definition: mgmt.h:600
Definition: mgmt.h:71
Definition: mgmt.h:279
Definition: mgmt.h:366
Definition: mgmt.h:852
Definition: mgmt.h:380
Definition: mgmt.h:360
Definition: mgmt.h:713
Definition: mgmt.h:998
Definition: mgmt.h:693