Johan Hedberg | c02178d | 2010-12-08 00:21:05 +0200 | [diff] [blame] | 1 | /* |
| 2 | BlueZ - Bluetooth protocol stack for Linux |
| 3 | |
| 4 | Copyright (C) 2010 Nokia Corporation |
| 5 | |
| 6 | This program is free software; you can redistribute it and/or modify |
| 7 | it under the terms of the GNU General Public License version 2 as |
| 8 | published by the Free Software Foundation; |
| 9 | |
| 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 11 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 12 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. |
| 13 | IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY |
| 14 | CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES |
| 15 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 16 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 17 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 18 | |
| 19 | ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, |
| 20 | COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS |
| 21 | SOFTWARE IS DISCLAIMED. |
| 22 | */ |
| 23 | |
| 24 | struct mgmt_hdr { |
| 25 | __le16 opcode; |
| 26 | __le16 len; |
| 27 | } __packed; |
| 28 | #define MGMT_HDR_SIZE 4 |
| 29 | |
Johan Hedberg | 02d9812 | 2010-12-13 21:07:04 +0200 | [diff] [blame] | 30 | #define MGMT_OP_READ_VERSION 0x0001 |
| 31 | struct mgmt_rp_read_version { |
| 32 | __u8 version; |
| 33 | __le16 revision; |
| 34 | } __packed; |
| 35 | |
Johan Hedberg | faba42e | 2010-12-13 21:07:05 +0200 | [diff] [blame] | 36 | #define MGMT_OP_READ_INDEX_LIST 0x0003 |
| 37 | struct mgmt_rp_read_index_list { |
| 38 | __le16 num_controllers; |
| 39 | __le16 index[0]; |
| 40 | } __packed; |
| 41 | |
Johan Hedberg | f7b64e69 | 2010-12-13 21:07:06 +0200 | [diff] [blame] | 42 | #define MGMT_OP_READ_INFO 0x0004 |
| 43 | struct mgmt_cp_read_info { |
| 44 | __le16 index; |
| 45 | } __packed; |
| 46 | struct mgmt_rp_read_info { |
| 47 | __le16 index; |
| 48 | __u8 type; |
| 49 | __u8 powered; |
Johan Hedberg | 9fbcbb4 | 2010-12-30 00:18:33 +0200 | [diff] [blame] | 50 | __u8 connectable; |
Johan Hedberg | f7b64e69 | 2010-12-13 21:07:06 +0200 | [diff] [blame] | 51 | __u8 discoverable; |
| 52 | __u8 pairable; |
| 53 | __u8 sec_mode; |
| 54 | bdaddr_t bdaddr; |
| 55 | __u8 dev_class[3]; |
| 56 | __u8 features[8]; |
| 57 | __u16 manufacturer; |
| 58 | __u8 hci_ver; |
| 59 | __u16 hci_rev; |
| 60 | } __packed; |
| 61 | |
Johan Hedberg | 72a734e | 2010-12-30 00:38:22 +0200 | [diff] [blame] | 62 | struct mgmt_mode { |
| 63 | __le16 index; |
| 64 | __u8 val; |
| 65 | } __packed; |
| 66 | |
Johan Hedberg | eec8d2b | 2010-12-16 10:17:38 +0200 | [diff] [blame] | 67 | #define MGMT_OP_SET_POWERED 0x0005 |
Johan Hedberg | eec8d2b | 2010-12-16 10:17:38 +0200 | [diff] [blame] | 68 | |
Johan Hedberg | 73f22f6 | 2010-12-29 16:00:25 +0200 | [diff] [blame] | 69 | #define MGMT_OP_SET_DISCOVERABLE 0x0006 |
Johan Hedberg | 73f22f6 | 2010-12-29 16:00:25 +0200 | [diff] [blame] | 70 | |
Johan Hedberg | 9fbcbb4 | 2010-12-30 00:18:33 +0200 | [diff] [blame] | 71 | #define MGMT_OP_SET_CONNECTABLE 0x0007 |
Johan Hedberg | 9fbcbb4 | 2010-12-30 00:18:33 +0200 | [diff] [blame] | 72 | |
Johan Hedberg | c542a06 | 2011-01-26 13:11:03 +0200 | [diff] [blame] | 73 | #define MGMT_OP_SET_PAIRABLE 0x0008 |
| 74 | |
Johan Hedberg | 2aeb9a1 | 2011-01-04 12:08:51 +0200 | [diff] [blame] | 75 | #define MGMT_OP_ADD_UUID 0x0009 |
| 76 | struct mgmt_cp_add_uuid { |
| 77 | __le16 index; |
| 78 | __u8 uuid[16]; |
Johan Hedberg | 1aff6f0 | 2011-01-13 21:56:52 +0200 | [diff] [blame] | 79 | __u8 svc_hint; |
Johan Hedberg | 2aeb9a1 | 2011-01-04 12:08:51 +0200 | [diff] [blame] | 80 | } __packed; |
| 81 | |
| 82 | #define MGMT_OP_REMOVE_UUID 0x000A |
| 83 | struct mgmt_cp_remove_uuid { |
| 84 | __le16 index; |
| 85 | __u8 uuid[16]; |
| 86 | } __packed; |
| 87 | |
Johan Hedberg | 1aff6f0 | 2011-01-13 21:56:52 +0200 | [diff] [blame] | 88 | #define MGMT_OP_SET_DEV_CLASS 0x000B |
| 89 | struct mgmt_cp_set_dev_class { |
| 90 | __le16 index; |
| 91 | __u8 major; |
| 92 | __u8 minor; |
| 93 | } __packed; |
| 94 | |
| 95 | #define MGMT_OP_SET_SERVICE_CACHE 0x000C |
| 96 | struct mgmt_cp_set_service_cache { |
| 97 | __le16 index; |
| 98 | __u8 enable; |
| 99 | } __packed; |
| 100 | |
Johan Hedberg | 55ed8ca1 | 2011-01-17 14:41:05 +0200 | [diff] [blame] | 101 | struct mgmt_key_info { |
| 102 | bdaddr_t bdaddr; |
| 103 | u8 type; |
| 104 | u8 val[16]; |
| 105 | u8 pin_len; |
| 106 | } __packed; |
| 107 | |
| 108 | #define MGMT_OP_LOAD_KEYS 0x000D |
| 109 | struct mgmt_cp_load_keys { |
| 110 | __le16 index; |
| 111 | __u8 debug_keys; |
| 112 | __le16 key_count; |
| 113 | struct mgmt_key_info keys[0]; |
| 114 | } __packed; |
| 115 | |
| 116 | #define MGMT_OP_REMOVE_KEY 0x000E |
| 117 | struct mgmt_cp_remove_key { |
| 118 | __le16 index; |
| 119 | bdaddr_t bdaddr; |
| 120 | __u8 disconnect; |
| 121 | } __packed; |
| 122 | |
Johan Hedberg | 8962ee7 | 2011-01-20 12:40:27 +0200 | [diff] [blame] | 123 | #define MGMT_OP_DISCONNECT 0x000F |
| 124 | struct mgmt_cp_disconnect { |
| 125 | __le16 index; |
| 126 | bdaddr_t bdaddr; |
| 127 | } __packed; |
| 128 | struct mgmt_rp_disconnect { |
| 129 | __le16 index; |
| 130 | bdaddr_t bdaddr; |
| 131 | } __packed; |
| 132 | |
Johan Hedberg | 2784eb4 | 2011-01-21 13:56:35 +0200 | [diff] [blame] | 133 | #define MGMT_OP_GET_CONNECTIONS 0x0010 |
| 134 | struct mgmt_cp_get_connections { |
| 135 | __le16 index; |
| 136 | } __packed; |
| 137 | struct mgmt_rp_get_connections { |
| 138 | __le16 index; |
| 139 | __le16 conn_count; |
| 140 | bdaddr_t conn[0]; |
| 141 | } __packed; |
| 142 | |
Johan Hedberg | 980e1a5 | 2011-01-22 06:10:07 +0200 | [diff] [blame] | 143 | #define MGMT_OP_PIN_CODE_REPLY 0x0011 |
| 144 | struct mgmt_cp_pin_code_reply { |
| 145 | __le16 index; |
| 146 | bdaddr_t bdaddr; |
| 147 | __u8 pin_len; |
| 148 | __u8 pin_code[16]; |
| 149 | } __packed; |
Johan Hedberg | ac56fb1 | 2011-02-19 12:05:59 -0300 | [diff] [blame] | 150 | struct mgmt_rp_pin_code_reply { |
| 151 | __le16 index; |
| 152 | bdaddr_t bdaddr; |
| 153 | uint8_t status; |
| 154 | } __packed; |
Johan Hedberg | 980e1a5 | 2011-01-22 06:10:07 +0200 | [diff] [blame] | 155 | |
| 156 | #define MGMT_OP_PIN_CODE_NEG_REPLY 0x0012 |
| 157 | struct mgmt_cp_pin_code_neg_reply { |
| 158 | __le16 index; |
| 159 | bdaddr_t bdaddr; |
| 160 | } __packed; |
| 161 | |
Johan Hedberg | 17fa4b9 | 2011-01-25 13:28:33 +0200 | [diff] [blame] | 162 | #define MGMT_OP_SET_IO_CAPABILITY 0x0013 |
| 163 | struct mgmt_cp_set_io_capability { |
| 164 | __le16 index; |
| 165 | __u8 io_capability; |
| 166 | } __packed; |
| 167 | |
Johan Hedberg | e9a416b | 2011-02-19 12:05:56 -0300 | [diff] [blame] | 168 | #define MGMT_OP_PAIR_DEVICE 0x0014 |
| 169 | struct mgmt_cp_pair_device { |
| 170 | __le16 index; |
| 171 | bdaddr_t bdaddr; |
| 172 | __u8 io_cap; |
| 173 | } __packed; |
| 174 | struct mgmt_rp_pair_device { |
| 175 | __le16 index; |
| 176 | bdaddr_t bdaddr; |
| 177 | __u8 status; |
| 178 | } __packed; |
| 179 | |
Johan Hedberg | a5c2968 | 2011-02-19 12:05:57 -0300 | [diff] [blame] | 180 | #define MGMT_OP_USER_CONFIRM_REPLY 0x0015 |
| 181 | struct mgmt_cp_user_confirm_reply { |
| 182 | __le16 index; |
| 183 | bdaddr_t bdaddr; |
| 184 | } __packed; |
| 185 | struct mgmt_rp_user_confirm_reply { |
| 186 | __le16 index; |
| 187 | bdaddr_t bdaddr; |
| 188 | __u8 status; |
| 189 | } __packed; |
| 190 | |
| 191 | #define MGMT_OP_USER_CONFIRM_NEG_REPLY 0x0016 |
| 192 | |
Johan Hedberg | c02178d | 2010-12-08 00:21:05 +0200 | [diff] [blame] | 193 | #define MGMT_EV_CMD_COMPLETE 0x0001 |
| 194 | struct mgmt_ev_cmd_complete { |
| 195 | __le16 opcode; |
| 196 | __u8 data[0]; |
| 197 | } __packed; |
| 198 | |
| 199 | #define MGMT_EV_CMD_STATUS 0x0002 |
| 200 | struct mgmt_ev_cmd_status { |
| 201 | __u8 status; |
| 202 | __le16 opcode; |
| 203 | } __packed; |
| 204 | |
| 205 | #define MGMT_EV_CONTROLLER_ERROR 0x0003 |
| 206 | struct mgmt_ev_controller_error { |
| 207 | __le16 index; |
| 208 | __u8 error_code; |
| 209 | } __packed; |
Johan Hedberg | c71e97b | 2010-12-13 21:07:07 +0200 | [diff] [blame] | 210 | |
| 211 | #define MGMT_EV_INDEX_ADDED 0x0004 |
| 212 | struct mgmt_ev_index_added { |
| 213 | __le16 index; |
| 214 | } __packed; |
| 215 | |
| 216 | #define MGMT_EV_INDEX_REMOVED 0x0005 |
| 217 | struct mgmt_ev_index_removed { |
| 218 | __le16 index; |
| 219 | } __packed; |
Johan Hedberg | 5add6af | 2010-12-16 10:00:37 +0200 | [diff] [blame] | 220 | |
| 221 | #define MGMT_EV_POWERED 0x0006 |
Johan Hedberg | 73f22f6 | 2010-12-29 16:00:25 +0200 | [diff] [blame] | 222 | |
| 223 | #define MGMT_EV_DISCOVERABLE 0x0007 |
Johan Hedberg | 9fbcbb4 | 2010-12-30 00:18:33 +0200 | [diff] [blame] | 224 | |
| 225 | #define MGMT_EV_CONNECTABLE 0x0008 |
Johan Hedberg | c542a06 | 2011-01-26 13:11:03 +0200 | [diff] [blame] | 226 | |
| 227 | #define MGMT_EV_PAIRABLE 0x0009 |
Johan Hedberg | 55ed8ca1 | 2011-01-17 14:41:05 +0200 | [diff] [blame] | 228 | |
| 229 | #define MGMT_EV_NEW_KEY 0x000A |
| 230 | struct mgmt_ev_new_key { |
| 231 | __le16 index; |
| 232 | struct mgmt_key_info key; |
| 233 | __u8 old_key_type; |
| 234 | } __packed; |
Johan Hedberg | f752054 | 2011-01-20 12:34:39 +0200 | [diff] [blame] | 235 | |
| 236 | #define MGMT_EV_CONNECTED 0x000B |
| 237 | struct mgmt_ev_connected { |
| 238 | __le16 index; |
| 239 | bdaddr_t bdaddr; |
| 240 | } __packed; |
| 241 | |
| 242 | #define MGMT_EV_DISCONNECTED 0x000C |
| 243 | struct mgmt_ev_disconnected { |
| 244 | __le16 index; |
| 245 | bdaddr_t bdaddr; |
| 246 | } __packed; |
Johan Hedberg | 17d5c04 | 2011-01-22 06:09:08 +0200 | [diff] [blame] | 247 | |
| 248 | #define MGMT_EV_CONNECT_FAILED 0x000D |
| 249 | struct mgmt_ev_connect_failed { |
| 250 | __le16 index; |
| 251 | bdaddr_t bdaddr; |
| 252 | __u8 status; |
| 253 | } __packed; |
Johan Hedberg | 980e1a5 | 2011-01-22 06:10:07 +0200 | [diff] [blame] | 254 | |
| 255 | #define MGMT_EV_PIN_CODE_REQUEST 0x000E |
| 256 | struct mgmt_ev_pin_code_request { |
| 257 | __le16 index; |
| 258 | bdaddr_t bdaddr; |
| 259 | } __packed; |
Johan Hedberg | a5c2968 | 2011-02-19 12:05:57 -0300 | [diff] [blame] | 260 | |
| 261 | #define MGMT_EV_USER_CONFIRM_REQUEST 0x000F |
| 262 | struct mgmt_ev_user_confirm_request { |
| 263 | __le16 index; |
| 264 | bdaddr_t bdaddr; |
| 265 | __le32 value; |
| 266 | } __packed; |
Johan Hedberg | 2a61169 | 2011-02-19 12:06:00 -0300 | [diff] [blame^] | 267 | |
| 268 | #define MGMT_EV_AUTH_FAILED 0x0010 |
| 269 | struct mgmt_ev_auth_failed { |
| 270 | __le16 index; |
| 271 | bdaddr_t bdaddr; |
| 272 | __u8 status; |
| 273 | } __packed; |