Milis Linux 2.0 Git Deposu
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

773 lines
17KB

  1. /*
  2. * BlueZ - Bluetooth protocol stack for Linux
  3. *
  4. * Copyright (C) 2010 Nokia Corporation
  5. * Copyright (C) 2010 Marcel Holtmann <marcel@holtmann.org>
  6. *
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  21. *
  22. */
  23. #ifndef __packed
  24. #define __packed __attribute__((packed))
  25. #endif
  26. #define MGMT_INDEX_NONE 0xFFFF
  27. #define MGMT_STATUS_SUCCESS 0x00
  28. #define MGMT_STATUS_UNKNOWN_COMMAND 0x01
  29. #define MGMT_STATUS_NOT_CONNECTED 0x02
  30. #define MGMT_STATUS_FAILED 0x03
  31. #define MGMT_STATUS_CONNECT_FAILED 0x04
  32. #define MGMT_STATUS_AUTH_FAILED 0x05
  33. #define MGMT_STATUS_NOT_PAIRED 0x06
  34. #define MGMT_STATUS_NO_RESOURCES 0x07
  35. #define MGMT_STATUS_TIMEOUT 0x08
  36. #define MGMT_STATUS_ALREADY_CONNECTED 0x09
  37. #define MGMT_STATUS_BUSY 0x0a
  38. #define MGMT_STATUS_REJECTED 0x0b
  39. #define MGMT_STATUS_NOT_SUPPORTED 0x0c
  40. #define MGMT_STATUS_INVALID_PARAMS 0x0d
  41. #define MGMT_STATUS_DISCONNECTED 0x0e
  42. #define MGMT_STATUS_NOT_POWERED 0x0f
  43. #define MGMT_STATUS_CANCELLED 0x10
  44. #define MGMT_STATUS_INVALID_INDEX 0x11
  45. #define MGMT_STATUS_RFKILLED 0x12
  46. struct mgmt_hdr {
  47. uint16_t opcode;
  48. uint16_t index;
  49. uint16_t len;
  50. } __packed;
  51. #define MGMT_HDR_SIZE 6
  52. struct mgmt_addr_info {
  53. bdaddr_t bdaddr;
  54. uint8_t type;
  55. } __packed;
  56. #define MGMT_OP_READ_VERSION 0x0001
  57. struct mgmt_rp_read_version {
  58. uint8_t version;
  59. uint16_t revision;
  60. } __packed;
  61. #define MGMT_OP_READ_COMMANDS 0x0002
  62. struct mgmt_rp_read_commands {
  63. uint16_t num_commands;
  64. uint16_t num_events;
  65. uint16_t opcodes[0];
  66. } __packed;
  67. #define MGMT_OP_READ_INDEX_LIST 0x0003
  68. struct mgmt_rp_read_index_list {
  69. uint16_t num_controllers;
  70. uint16_t index[0];
  71. } __packed;
  72. /* Reserve one extra byte for names in management messages so that they
  73. * are always guaranteed to be nul-terminated */
  74. #define MGMT_MAX_NAME_LENGTH (248 + 1)
  75. #define MGMT_MAX_SHORT_NAME_LENGTH (10 + 1)
  76. #define MGMT_SETTING_POWERED 0x00000001
  77. #define MGMT_SETTING_CONNECTABLE 0x00000002
  78. #define MGMT_SETTING_FAST_CONNECTABLE 0x00000004
  79. #define MGMT_SETTING_DISCOVERABLE 0x00000008
  80. #define MGMT_SETTING_BONDABLE 0x00000010
  81. #define MGMT_SETTING_LINK_SECURITY 0x00000020
  82. #define MGMT_SETTING_SSP 0x00000040
  83. #define MGMT_SETTING_BREDR 0x00000080
  84. #define MGMT_SETTING_HS 0x00000100
  85. #define MGMT_SETTING_LE 0x00000200
  86. #define MGMT_SETTING_ADVERTISING 0x00000400
  87. #define MGMT_SETTING_SECURE_CONN 0x00000800
  88. #define MGMT_SETTING_DEBUG_KEYS 0x00001000
  89. #define MGMT_SETTING_PRIVACY 0x00002000
  90. #define MGMT_SETTING_CONFIGURATION 0x00004000
  91. #define MGMT_OP_READ_INFO 0x0004
  92. struct mgmt_rp_read_info {
  93. bdaddr_t bdaddr;
  94. uint8_t version;
  95. uint16_t manufacturer;
  96. uint32_t supported_settings;
  97. uint32_t current_settings;
  98. uint8_t dev_class[3];
  99. uint8_t name[MGMT_MAX_NAME_LENGTH];
  100. uint8_t short_name[MGMT_MAX_SHORT_NAME_LENGTH];
  101. } __packed;
  102. struct mgmt_mode {
  103. uint8_t val;
  104. } __packed;
  105. struct mgmt_cod {
  106. uint8_t val[3];
  107. } __packed;
  108. #define MGMT_OP_SET_POWERED 0x0005
  109. #define MGMT_OP_SET_DISCOVERABLE 0x0006
  110. struct mgmt_cp_set_discoverable {
  111. uint8_t val;
  112. uint16_t timeout;
  113. } __packed;
  114. #define MGMT_OP_SET_CONNECTABLE 0x0007
  115. #define MGMT_OP_SET_FAST_CONNECTABLE 0x0008
  116. #define MGMT_OP_SET_BONDABLE 0x0009
  117. #define MGMT_OP_SET_LINK_SECURITY 0x000A
  118. #define MGMT_OP_SET_SSP 0x000B
  119. #define MGMT_OP_SET_HS 0x000C
  120. #define MGMT_OP_SET_LE 0x000D
  121. #define MGMT_OP_SET_DEV_CLASS 0x000E
  122. struct mgmt_cp_set_dev_class {
  123. uint8_t major;
  124. uint8_t minor;
  125. } __packed;
  126. #define MGMT_OP_SET_LOCAL_NAME 0x000F
  127. struct mgmt_cp_set_local_name {
  128. uint8_t name[MGMT_MAX_NAME_LENGTH];
  129. uint8_t short_name[MGMT_MAX_SHORT_NAME_LENGTH];
  130. } __packed;
  131. #define MGMT_OP_ADD_UUID 0x0010
  132. struct mgmt_cp_add_uuid {
  133. uint8_t uuid[16];
  134. uint8_t svc_hint;
  135. } __packed;
  136. #define MGMT_OP_REMOVE_UUID 0x0011
  137. struct mgmt_cp_remove_uuid {
  138. uint8_t uuid[16];
  139. } __packed;
  140. struct mgmt_link_key_info {
  141. struct mgmt_addr_info addr;
  142. uint8_t type;
  143. uint8_t val[16];
  144. uint8_t pin_len;
  145. } __packed;
  146. #define MGMT_OP_LOAD_LINK_KEYS 0x0012
  147. struct mgmt_cp_load_link_keys {
  148. uint8_t debug_keys;
  149. uint16_t key_count;
  150. struct mgmt_link_key_info keys[0];
  151. } __packed;
  152. struct mgmt_ltk_info {
  153. struct mgmt_addr_info addr;
  154. uint8_t type;
  155. uint8_t master;
  156. uint8_t enc_size;
  157. uint16_t ediv;
  158. uint64_t rand;
  159. uint8_t val[16];
  160. } __packed;
  161. #define MGMT_OP_LOAD_LONG_TERM_KEYS 0x0013
  162. struct mgmt_cp_load_long_term_keys {
  163. uint16_t key_count;
  164. struct mgmt_ltk_info keys[0];
  165. } __packed;
  166. #define MGMT_OP_DISCONNECT 0x0014
  167. struct mgmt_cp_disconnect {
  168. struct mgmt_addr_info addr;
  169. } __packed;
  170. struct mgmt_rp_disconnect {
  171. struct mgmt_addr_info addr;
  172. } __packed;
  173. #define MGMT_OP_GET_CONNECTIONS 0x0015
  174. struct mgmt_rp_get_connections {
  175. uint16_t conn_count;
  176. struct mgmt_addr_info addr[0];
  177. } __packed;
  178. #define MGMT_OP_PIN_CODE_REPLY 0x0016
  179. struct mgmt_cp_pin_code_reply {
  180. struct mgmt_addr_info addr;
  181. uint8_t pin_len;
  182. uint8_t pin_code[16];
  183. } __packed;
  184. #define MGMT_OP_PIN_CODE_NEG_REPLY 0x0017
  185. struct mgmt_cp_pin_code_neg_reply {
  186. struct mgmt_addr_info addr;
  187. } __packed;
  188. #define MGMT_OP_SET_IO_CAPABILITY 0x0018
  189. struct mgmt_cp_set_io_capability {
  190. uint8_t io_capability;
  191. } __packed;
  192. #define MGMT_OP_PAIR_DEVICE 0x0019
  193. struct mgmt_cp_pair_device {
  194. struct mgmt_addr_info addr;
  195. uint8_t io_cap;
  196. } __packed;
  197. struct mgmt_rp_pair_device {
  198. struct mgmt_addr_info addr;
  199. } __packed;
  200. #define MGMT_OP_CANCEL_PAIR_DEVICE 0x001A
  201. #define MGMT_OP_UNPAIR_DEVICE 0x001B
  202. struct mgmt_cp_unpair_device {
  203. struct mgmt_addr_info addr;
  204. uint8_t disconnect;
  205. } __packed;
  206. struct mgmt_rp_unpair_device {
  207. struct mgmt_addr_info addr;
  208. } __packed;
  209. #define MGMT_OP_USER_CONFIRM_REPLY 0x001C
  210. struct mgmt_cp_user_confirm_reply {
  211. struct mgmt_addr_info addr;
  212. } __packed;
  213. struct mgmt_rp_user_confirm_reply {
  214. struct mgmt_addr_info addr;
  215. } __packed;
  216. #define MGMT_OP_USER_CONFIRM_NEG_REPLY 0x001D
  217. #define MGMT_OP_USER_PASSKEY_REPLY 0x001E
  218. struct mgmt_cp_user_passkey_reply {
  219. struct mgmt_addr_info addr;
  220. uint32_t passkey;
  221. } __packed;
  222. struct mgmt_rp_user_passkey_reply {
  223. struct mgmt_addr_info addr;
  224. } __packed;
  225. #define MGMT_OP_USER_PASSKEY_NEG_REPLY 0x001F
  226. struct mgmt_cp_user_passkey_neg_reply {
  227. struct mgmt_addr_info addr;
  228. } __packed;
  229. #define MGMT_OP_READ_LOCAL_OOB_DATA 0x0020
  230. struct mgmt_rp_read_local_oob_data {
  231. uint8_t hash[16];
  232. uint8_t randomizer[16];
  233. } __packed;
  234. struct mgmt_rp_read_local_oob_ext_data {
  235. uint8_t hash192[16];
  236. uint8_t randomizer192[16];
  237. uint8_t hash256[16];
  238. uint8_t randomizer256[16];
  239. } __packed;
  240. #define MGMT_OP_ADD_REMOTE_OOB_DATA 0x0021
  241. struct mgmt_cp_add_remote_oob_data {
  242. struct mgmt_addr_info addr;
  243. uint8_t hash[16];
  244. uint8_t randomizer[16];
  245. } __packed;
  246. #define MGMT_OP_REMOVE_REMOTE_OOB_DATA 0x0022
  247. struct mgmt_cp_remove_remote_oob_data {
  248. struct mgmt_addr_info addr;
  249. } __packed;
  250. #define MGMT_OP_START_DISCOVERY 0x0023
  251. struct mgmt_cp_start_discovery {
  252. uint8_t type;
  253. } __packed;
  254. #define MGMT_OP_STOP_DISCOVERY 0x0024
  255. struct mgmt_cp_stop_discovery {
  256. uint8_t type;
  257. } __packed;
  258. #define MGMT_OP_CONFIRM_NAME 0x0025
  259. struct mgmt_cp_confirm_name {
  260. struct mgmt_addr_info addr;
  261. uint8_t name_known;
  262. } __packed;
  263. struct mgmt_rp_confirm_name {
  264. struct mgmt_addr_info addr;
  265. } __packed;
  266. #define MGMT_OP_BLOCK_DEVICE 0x0026
  267. struct mgmt_cp_block_device {
  268. struct mgmt_addr_info addr;
  269. } __packed;
  270. #define MGMT_OP_UNBLOCK_DEVICE 0x0027
  271. struct mgmt_cp_unblock_device {
  272. struct mgmt_addr_info addr;
  273. } __packed;
  274. #define MGMT_OP_SET_DEVICE_ID 0x0028
  275. struct mgmt_cp_set_device_id {
  276. uint16_t source;
  277. uint16_t vendor;
  278. uint16_t product;
  279. uint16_t version;
  280. } __packed;
  281. #define MGMT_OP_SET_ADVERTISING 0x0029
  282. #define MGMT_OP_SET_BREDR 0x002A
  283. #define MGMT_OP_SET_STATIC_ADDRESS 0x002B
  284. struct mgmt_cp_set_static_address {
  285. bdaddr_t bdaddr;
  286. } __packed;
  287. #define MGMT_OP_SET_SCAN_PARAMS 0x002C
  288. struct mgmt_cp_set_scan_params {
  289. uint16_t interval;
  290. uint16_t window;
  291. } __packed;
  292. #define MGMT_OP_SET_SECURE_CONN 0x002D
  293. #define MGMT_OP_SET_DEBUG_KEYS 0x002E
  294. struct mgmt_irk_info {
  295. struct mgmt_addr_info addr;
  296. uint8_t val[16];
  297. } __packed;
  298. #define MGMT_OP_SET_PRIVACY 0x002F
  299. struct mgmt_cp_set_privacy {
  300. uint8_t privacy;
  301. uint8_t irk[16];
  302. } __packed;
  303. #define MGMT_OP_LOAD_IRKS 0x0030
  304. struct mgmt_cp_load_irks {
  305. uint16_t irk_count;
  306. struct mgmt_irk_info irks[0];
  307. } __packed;
  308. #define MGMT_OP_GET_CONN_INFO 0x0031
  309. struct mgmt_cp_get_conn_info {
  310. struct mgmt_addr_info addr;
  311. } __packed;
  312. struct mgmt_rp_get_conn_info {
  313. struct mgmt_addr_info addr;
  314. int8_t rssi;
  315. int8_t tx_power;
  316. int8_t max_tx_power;
  317. } __packed;
  318. #define MGMT_OP_GET_CLOCK_INFO 0x0032
  319. struct mgmt_cp_get_clock_info {
  320. struct mgmt_addr_info addr;
  321. } __packed;
  322. struct mgmt_rp_get_clock_info {
  323. struct mgmt_addr_info addr;
  324. uint32_t local_clock;
  325. uint32_t piconet_clock;
  326. uint16_t accuracy;
  327. } __packed;
  328. #define MGMT_OP_ADD_DEVICE 0x0033
  329. struct mgmt_cp_add_device {
  330. struct mgmt_addr_info addr;
  331. uint8_t action;
  332. } __packed;
  333. struct mgmt_rp_add_device {
  334. struct mgmt_addr_info addr;
  335. } __packed;
  336. #define MGMT_OP_REMOVE_DEVICE 0x0034
  337. struct mgmt_cp_remove_device {
  338. struct mgmt_addr_info addr;
  339. } __packed;
  340. struct mgmt_rp_remove_device {
  341. struct mgmt_addr_info addr;
  342. } __packed;
  343. struct mgmt_conn_param {
  344. struct mgmt_addr_info addr;
  345. uint16_t min_interval;
  346. uint16_t max_interval;
  347. uint16_t latency;
  348. uint16_t timeout;
  349. } __packed;
  350. #define MGMT_OP_LOAD_CONN_PARAM 0x0035
  351. struct mgmt_cp_load_conn_param {
  352. uint16_t param_count;
  353. struct mgmt_conn_param params[0];
  354. } __packed;
  355. #define MGMT_OP_READ_UNCONF_INDEX_LIST 0x0036
  356. struct mgmt_rp_read_unconf_index_list {
  357. uint16_t num_controllers;
  358. uint16_t index[0];
  359. } __packed;
  360. #define MGMT_OPTION_EXTERNAL_CONFIG 0x00000001
  361. #define MGMT_OPTION_PUBLIC_ADDRESS 0x00000002
  362. #define MGMT_OP_READ_CONFIG_INFO 0x0037
  363. struct mgmt_rp_read_config_info {
  364. uint16_t manufacturer;
  365. uint32_t supported_options;
  366. uint32_t missing_options;
  367. } __packed;
  368. #define MGMT_OP_SET_EXTERNAL_CONFIG 0x0038
  369. struct mgmt_cp_set_external_config {
  370. uint8_t config;
  371. } __packed;
  372. #define MGMT_OP_SET_PUBLIC_ADDRESS 0x0039
  373. struct mgmt_cp_set_public_address {
  374. bdaddr_t bdaddr;
  375. } __packed;
  376. #define MGMT_EV_CMD_COMPLETE 0x0001
  377. struct mgmt_ev_cmd_complete {
  378. uint16_t opcode;
  379. uint8_t status;
  380. uint8_t data[0];
  381. } __packed;
  382. #define MGMT_EV_CMD_STATUS 0x0002
  383. struct mgmt_ev_cmd_status {
  384. uint16_t opcode;
  385. uint8_t status;
  386. } __packed;
  387. #define MGMT_EV_CONTROLLER_ERROR 0x0003
  388. struct mgmt_ev_controller_error {
  389. uint8_t error_code;
  390. } __packed;
  391. #define MGMT_EV_INDEX_ADDED 0x0004
  392. #define MGMT_EV_INDEX_REMOVED 0x0005
  393. #define MGMT_EV_NEW_SETTINGS 0x0006
  394. #define MGMT_EV_CLASS_OF_DEV_CHANGED 0x0007
  395. struct mgmt_ev_class_of_dev_changed {
  396. uint8_t class_of_dev[3];
  397. } __packed;
  398. #define MGMT_EV_LOCAL_NAME_CHANGED 0x0008
  399. struct mgmt_ev_local_name_changed {
  400. uint8_t name[MGMT_MAX_NAME_LENGTH];
  401. uint8_t short_name[MGMT_MAX_SHORT_NAME_LENGTH];
  402. } __packed;
  403. #define MGMT_EV_NEW_LINK_KEY 0x0009
  404. struct mgmt_ev_new_link_key {
  405. uint8_t store_hint;
  406. struct mgmt_link_key_info key;
  407. } __packed;
  408. #define MGMT_EV_NEW_LONG_TERM_KEY 0x000A
  409. struct mgmt_ev_new_long_term_key {
  410. uint8_t store_hint;
  411. struct mgmt_ltk_info key;
  412. } __packed;
  413. #define MGMT_EV_DEVICE_CONNECTED 0x000B
  414. struct mgmt_ev_device_connected {
  415. struct mgmt_addr_info addr;
  416. uint32_t flags;
  417. uint16_t eir_len;
  418. uint8_t eir[0];
  419. } __packed;
  420. #define MGMT_DEV_DISCONN_UNKNOWN 0x00
  421. #define MGMT_DEV_DISCONN_TIMEOUT 0x01
  422. #define MGMT_DEV_DISCONN_LOCAL_HOST 0x02
  423. #define MGMT_DEV_DISCONN_REMOTE 0x03
  424. #define MGMT_EV_DEVICE_DISCONNECTED 0x000C
  425. struct mgmt_ev_device_disconnected {
  426. struct mgmt_addr_info addr;
  427. uint8_t reason;
  428. } __packed;
  429. #define MGMT_EV_CONNECT_FAILED 0x000D
  430. struct mgmt_ev_connect_failed {
  431. struct mgmt_addr_info addr;
  432. uint8_t status;
  433. } __packed;
  434. #define MGMT_EV_PIN_CODE_REQUEST 0x000E
  435. struct mgmt_ev_pin_code_request {
  436. struct mgmt_addr_info addr;
  437. uint8_t secure;
  438. } __packed;
  439. #define MGMT_EV_USER_CONFIRM_REQUEST 0x000F
  440. struct mgmt_ev_user_confirm_request {
  441. struct mgmt_addr_info addr;
  442. uint8_t confirm_hint;
  443. uint32_t value;
  444. } __packed;
  445. #define MGMT_EV_USER_PASSKEY_REQUEST 0x0010
  446. struct mgmt_ev_user_passkey_request {
  447. struct mgmt_addr_info addr;
  448. } __packed;
  449. #define MGMT_EV_AUTH_FAILED 0x0011
  450. struct mgmt_ev_auth_failed {
  451. struct mgmt_addr_info addr;
  452. uint8_t status;
  453. } __packed;
  454. #define MGMT_DEV_FOUND_CONFIRM_NAME 0x01
  455. #define MGMT_DEV_FOUND_LEGACY_PAIRING 0x02
  456. #define MGMT_DEV_FOUND_NOT_CONNECTABLE 0x04
  457. #define MGMT_EV_DEVICE_FOUND 0x0012
  458. struct mgmt_ev_device_found {
  459. struct mgmt_addr_info addr;
  460. int8_t rssi;
  461. uint32_t flags;
  462. uint16_t eir_len;
  463. uint8_t eir[0];
  464. } __packed;
  465. #define MGMT_EV_DISCOVERING 0x0013
  466. struct mgmt_ev_discovering {
  467. uint8_t type;
  468. uint8_t discovering;
  469. } __packed;
  470. #define MGMT_EV_DEVICE_BLOCKED 0x0014
  471. struct mgmt_ev_device_blocked {
  472. struct mgmt_addr_info addr;
  473. } __packed;
  474. #define MGMT_EV_DEVICE_UNBLOCKED 0x0015
  475. struct mgmt_ev_device_unblocked {
  476. struct mgmt_addr_info addr;
  477. } __packed;
  478. #define MGMT_EV_DEVICE_UNPAIRED 0x0016
  479. struct mgmt_ev_device_unpaired {
  480. struct mgmt_addr_info addr;
  481. } __packed;
  482. #define MGMT_EV_PASSKEY_NOTIFY 0x0017
  483. struct mgmt_ev_passkey_notify {
  484. struct mgmt_addr_info addr;
  485. uint32_t passkey;
  486. uint8_t entered;
  487. } __packed;
  488. #define MGMT_EV_NEW_IRK 0x0018
  489. struct mgmt_ev_new_irk {
  490. uint8_t store_hint;
  491. bdaddr_t rpa;
  492. struct mgmt_irk_info key;
  493. } __packed;
  494. struct mgmt_csrk_info {
  495. struct mgmt_addr_info addr;
  496. uint8_t master;
  497. uint8_t val[16];
  498. } __packed;
  499. #define MGMT_EV_NEW_CSRK 0x0019
  500. struct mgmt_ev_new_csrk {
  501. uint8_t store_hint;
  502. struct mgmt_csrk_info key;
  503. } __packed;
  504. #define MGMT_EV_DEVICE_ADDED 0x001a
  505. struct mgmt_ev_device_added {
  506. struct mgmt_addr_info addr;
  507. uint8_t action;
  508. } __packed;
  509. #define MGMT_EV_DEVICE_REMOVED 0x001b
  510. struct mgmt_ev_device_removed {
  511. struct mgmt_addr_info addr;
  512. } __packed;
  513. #define MGMT_EV_NEW_CONN_PARAM 0x001c
  514. struct mgmt_ev_new_conn_param {
  515. struct mgmt_addr_info addr;
  516. uint8_t store_hint;
  517. uint16_t min_interval;
  518. uint16_t max_interval;
  519. uint16_t latency;
  520. uint16_t timeout;
  521. } __packed;
  522. #define MGMT_EV_UNCONF_INDEX_ADDED 0x001d
  523. #define MGMT_EV_UNCONF_INDEX_REMOVED 0x001e
  524. #define MGMT_EV_NEW_CONFIG_OPTIONS 0x001f
  525. static const char *mgmt_op[] = {
  526. "<0x0000>",
  527. "Read Version",
  528. "Read Commands",
  529. "Read Index List",
  530. "Read Controller Info",
  531. "Set Powered",
  532. "Set Discoverable",
  533. "Set Connectable",
  534. "Set Fast Connectable", /* 0x0008 */
  535. "Set Bondable",
  536. "Set Link Security",
  537. "Set Secure Simple Pairing",
  538. "Set High Speed",
  539. "Set Low Energy",
  540. "Set Dev Class",
  541. "Set Local Name",
  542. "Add UUID", /* 0x0010 */
  543. "Remove UUID",
  544. "Load Link Keys",
  545. "Load Long Term Keys",
  546. "Disconnect",
  547. "Get Connections",
  548. "PIN Code Reply",
  549. "PIN Code Neg Reply",
  550. "Set IO Capability", /* 0x0018 */
  551. "Pair Device",
  552. "Cancel Pair Device",
  553. "Unpair Device",
  554. "User Confirm Reply",
  555. "User Confirm Neg Reply",
  556. "User Passkey Reply",
  557. "User Passkey Neg Reply",
  558. "Read Local OOB Data", /* 0x0020 */
  559. "Add Remote OOB Data",
  560. "Remove Remove OOB Data",
  561. "Start Discovery",
  562. "Stop Discovery",
  563. "Confirm Name",
  564. "Block Device",
  565. "Unblock Device",
  566. "Set Device ID",
  567. "Set Advertising",
  568. "Set BR/EDR",
  569. "Set Static Address",
  570. "Set Scan Parameters",
  571. "Set Secure Connections",
  572. "Set Debug Keys",
  573. "Set Privacy",
  574. "Load Identity Resolving Keys",
  575. "Get Connection Information",
  576. "Get Clock Information",
  577. "Add Device",
  578. "Remove Device",
  579. "Load Connection Parameters",
  580. "Read Unconfigured Index List",
  581. "Read Controller Configuration Information",
  582. "Set External Configuration",
  583. "Set Public Address",
  584. };
  585. static const char *mgmt_ev[] = {
  586. "<0x0000>",
  587. "Command Complete",
  588. "Command Status",
  589. "Controller Error",
  590. "Index Added",
  591. "Index Removed",
  592. "New Settings",
  593. "Class of Device Changed",
  594. "Local Name Changed", /* 0x0008 */
  595. "New Link Key",
  596. "New Long Term Key",
  597. "Device Connected",
  598. "Device Disconnected",
  599. "Connect Failed",
  600. "PIN Code Request",
  601. "User Confirm Request",
  602. "User Passkey Request", /* 0x0010 */
  603. "Authentication Failed",
  604. "Device Found",
  605. "Discovering",
  606. "Device Blocked",
  607. "Device Unblocked",
  608. "Device Unpaired",
  609. "Passkey Notify",
  610. "New Identity Resolving Key",
  611. "New Signature Resolving Key",
  612. "Device Added",
  613. "Device Removed",
  614. "New Connection Parameter",
  615. "Unconfigured Index Added",
  616. "Unconfigured Index Removed",
  617. "New Configuration Options",
  618. };
  619. static const char *mgmt_status[] = {
  620. "Success",
  621. "Unknown Command",
  622. "Not Connected",
  623. "Failed",
  624. "Connect Failed",
  625. "Authentication Failed",
  626. "Not Paired",
  627. "No Resources",
  628. "Timeout",
  629. "Already Connected",
  630. "Busy",
  631. "Rejected",
  632. "Not Supported",
  633. "Invalid Parameters",
  634. "Disconnected",
  635. "Not Powered",
  636. "Cancelled",
  637. "Invalid Index",
  638. "Blocked through rfkill",
  639. };
  640. #ifndef NELEM
  641. #define NELEM(x) (sizeof(x) / sizeof((x)[0]))
  642. #endif
  643. static inline const char *mgmt_opstr(uint16_t op)
  644. {
  645. if (op >= NELEM(mgmt_op))
  646. return "<unknown opcode>";
  647. return mgmt_op[op];
  648. }
  649. static inline const char *mgmt_evstr(uint16_t ev)
  650. {
  651. if (ev >= NELEM(mgmt_ev))
  652. return "<unknown event>";
  653. return mgmt_ev[ev];
  654. }
  655. static inline const char *mgmt_errstr(uint8_t status)
  656. {
  657. if (status >= NELEM(mgmt_status))
  658. return "<unknown status>";
  659. return mgmt_status[status];
  660. }