mgmt.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. /*
  2. BlueZ - Bluetooth protocol stack for Linux
  3. Copyright (C) 2010 Nokia Corporation
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License version 2 as
  6. published by the Free Software Foundation;
  7. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  8. OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  9. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
  10. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
  11. CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
  12. WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
  16. COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
  17. SOFTWARE IS DISCLAIMED.
  18. */
  19. struct mgmt_hdr {
  20. __le16 opcode;
  21. __le16 len;
  22. } __packed;
  23. #define MGMT_HDR_SIZE 4
  24. #define MGMT_OP_READ_VERSION 0x0001
  25. struct mgmt_rp_read_version {
  26. __u8 version;
  27. __le16 revision;
  28. } __packed;
  29. #define MGMT_OP_READ_INDEX_LIST 0x0003
  30. struct mgmt_rp_read_index_list {
  31. __le16 num_controllers;
  32. __le16 index[0];
  33. } __packed;
  34. #define MGMT_OP_READ_INFO 0x0004
  35. struct mgmt_cp_read_info {
  36. __le16 index;
  37. } __packed;
  38. struct mgmt_rp_read_info {
  39. __le16 index;
  40. __u8 type;
  41. __u8 powered;
  42. __u8 connectable;
  43. __u8 discoverable;
  44. __u8 pairable;
  45. __u8 sec_mode;
  46. bdaddr_t bdaddr;
  47. __u8 dev_class[3];
  48. __u8 features[8];
  49. __u16 manufacturer;
  50. __u8 hci_ver;
  51. __u16 hci_rev;
  52. } __packed;
  53. struct mgmt_mode {
  54. __le16 index;
  55. __u8 val;
  56. } __packed;
  57. #define MGMT_OP_SET_POWERED 0x0005
  58. #define MGMT_OP_SET_DISCOVERABLE 0x0006
  59. #define MGMT_OP_SET_CONNECTABLE 0x0007
  60. #define MGMT_OP_SET_PAIRABLE 0x0008
  61. #define MGMT_OP_ADD_UUID 0x0009
  62. struct mgmt_cp_add_uuid {
  63. __le16 index;
  64. __u8 uuid[16];
  65. __u8 svc_hint;
  66. } __packed;
  67. #define MGMT_OP_REMOVE_UUID 0x000A
  68. struct mgmt_cp_remove_uuid {
  69. __le16 index;
  70. __u8 uuid[16];
  71. } __packed;
  72. #define MGMT_OP_SET_DEV_CLASS 0x000B
  73. struct mgmt_cp_set_dev_class {
  74. __le16 index;
  75. __u8 major;
  76. __u8 minor;
  77. } __packed;
  78. #define MGMT_OP_SET_SERVICE_CACHE 0x000C
  79. struct mgmt_cp_set_service_cache {
  80. __le16 index;
  81. __u8 enable;
  82. } __packed;
  83. struct mgmt_key_info {
  84. bdaddr_t bdaddr;
  85. u8 type;
  86. u8 val[16];
  87. u8 pin_len;
  88. } __packed;
  89. #define MGMT_OP_LOAD_KEYS 0x000D
  90. struct mgmt_cp_load_keys {
  91. __le16 index;
  92. __u8 debug_keys;
  93. __le16 key_count;
  94. struct mgmt_key_info keys[0];
  95. } __packed;
  96. #define MGMT_OP_REMOVE_KEY 0x000E
  97. struct mgmt_cp_remove_key {
  98. __le16 index;
  99. bdaddr_t bdaddr;
  100. __u8 disconnect;
  101. } __packed;
  102. #define MGMT_OP_DISCONNECT 0x000F
  103. struct mgmt_cp_disconnect {
  104. __le16 index;
  105. bdaddr_t bdaddr;
  106. } __packed;
  107. struct mgmt_rp_disconnect {
  108. __le16 index;
  109. bdaddr_t bdaddr;
  110. } __packed;
  111. #define MGMT_OP_GET_CONNECTIONS 0x0010
  112. struct mgmt_cp_get_connections {
  113. __le16 index;
  114. } __packed;
  115. struct mgmt_rp_get_connections {
  116. __le16 index;
  117. __le16 conn_count;
  118. bdaddr_t conn[0];
  119. } __packed;
  120. #define MGMT_OP_PIN_CODE_REPLY 0x0011
  121. struct mgmt_cp_pin_code_reply {
  122. __le16 index;
  123. bdaddr_t bdaddr;
  124. __u8 pin_len;
  125. __u8 pin_code[16];
  126. } __packed;
  127. #define MGMT_OP_PIN_CODE_NEG_REPLY 0x0012
  128. struct mgmt_cp_pin_code_neg_reply {
  129. __le16 index;
  130. bdaddr_t bdaddr;
  131. } __packed;
  132. #define MGMT_OP_SET_IO_CAPABILITY 0x0013
  133. struct mgmt_cp_set_io_capability {
  134. __le16 index;
  135. __u8 io_capability;
  136. } __packed;
  137. #define MGMT_EV_CMD_COMPLETE 0x0001
  138. struct mgmt_ev_cmd_complete {
  139. __le16 opcode;
  140. __u8 data[0];
  141. } __packed;
  142. #define MGMT_EV_CMD_STATUS 0x0002
  143. struct mgmt_ev_cmd_status {
  144. __u8 status;
  145. __le16 opcode;
  146. } __packed;
  147. #define MGMT_EV_CONTROLLER_ERROR 0x0003
  148. struct mgmt_ev_controller_error {
  149. __le16 index;
  150. __u8 error_code;
  151. } __packed;
  152. #define MGMT_EV_INDEX_ADDED 0x0004
  153. struct mgmt_ev_index_added {
  154. __le16 index;
  155. } __packed;
  156. #define MGMT_EV_INDEX_REMOVED 0x0005
  157. struct mgmt_ev_index_removed {
  158. __le16 index;
  159. } __packed;
  160. #define MGMT_EV_POWERED 0x0006
  161. #define MGMT_EV_DISCOVERABLE 0x0007
  162. #define MGMT_EV_CONNECTABLE 0x0008
  163. #define MGMT_EV_PAIRABLE 0x0009
  164. #define MGMT_EV_NEW_KEY 0x000A
  165. struct mgmt_ev_new_key {
  166. __le16 index;
  167. struct mgmt_key_info key;
  168. __u8 old_key_type;
  169. } __packed;
  170. #define MGMT_EV_CONNECTED 0x000B
  171. struct mgmt_ev_connected {
  172. __le16 index;
  173. bdaddr_t bdaddr;
  174. } __packed;
  175. #define MGMT_EV_DISCONNECTED 0x000C
  176. struct mgmt_ev_disconnected {
  177. __le16 index;
  178. bdaddr_t bdaddr;
  179. } __packed;
  180. #define MGMT_EV_CONNECT_FAILED 0x000D
  181. struct mgmt_ev_connect_failed {
  182. __le16 index;
  183. bdaddr_t bdaddr;
  184. __u8 status;
  185. } __packed;
  186. #define MGMT_EV_PIN_CODE_REQUEST 0x000E
  187. struct mgmt_ev_pin_code_request {
  188. __le16 index;
  189. bdaddr_t bdaddr;
  190. } __packed;