xref: /openbmc/linux/include/net/bluetooth/mgmt.h (revision e319d2e7)
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 #define MGMT_INDEX_NONE			0xFFFF
25 
26 #define MGMT_STATUS_SUCCESS		0x00
27 #define MGMT_STATUS_UNKNOWN_COMMAND	0x01
28 #define MGMT_STATUS_NOT_CONNECTED	0x02
29 #define MGMT_STATUS_FAILED		0x03
30 #define MGMT_STATUS_CONNECT_FAILED	0x04
31 #define MGMT_STATUS_AUTH_FAILED		0x05
32 #define MGMT_STATUS_NOT_PAIRED		0x06
33 #define MGMT_STATUS_NO_RESOURCES	0x07
34 #define MGMT_STATUS_TIMEOUT		0x08
35 #define MGMT_STATUS_ALREADY_CONNECTED	0x09
36 #define MGMT_STATUS_BUSY		0x0a
37 #define MGMT_STATUS_REJECTED		0x0b
38 #define MGMT_STATUS_NOT_SUPPORTED	0x0c
39 #define MGMT_STATUS_INVALID_PARAMS	0x0d
40 #define MGMT_STATUS_DISCONNECTED	0x0e
41 #define MGMT_STATUS_NOT_POWERED		0x0f
42 
43 struct mgmt_hdr {
44 	__le16 opcode;
45 	__le16 index;
46 	__le16 len;
47 } __packed;
48 
49 #define MGMT_OP_READ_VERSION		0x0001
50 struct mgmt_rp_read_version {
51 	__u8 version;
52 	__le16 revision;
53 } __packed;
54 
55 #define MGMT_OP_READ_INDEX_LIST		0x0003
56 struct mgmt_rp_read_index_list {
57 	__le16 num_controllers;
58 	__le16 index[0];
59 } __packed;
60 
61 /* Reserve one extra byte for names in management messages so that they
62  * are always guaranteed to be nul-terminated */
63 #define MGMT_MAX_NAME_LENGTH		(HCI_MAX_NAME_LENGTH + 1)
64 #define MGMT_MAX_SHORT_NAME_LENGTH	(10 + 1)
65 
66 #define MGMT_SETTING_POWERED		0x00000001
67 #define MGMT_SETTING_CONNECTABLE	0x00000002
68 #define MGMT_SETTING_FAST_CONNECTABLE	0x00000004
69 #define MGMT_SETTING_DISCOVERABLE	0x00000008
70 #define MGMT_SETTING_PAIRABLE		0x00000010
71 #define MGMT_SETTING_LINK_SECURITY	0x00000020
72 #define MGMT_SETTING_SSP		0x00000040
73 #define MGMT_SETTING_BREDR		0x00000080
74 #define MGMT_SETTING_HS			0x00000100
75 #define MGMT_SETTING_LE			0x00000200
76 
77 #define MGMT_OP_READ_INFO		0x0004
78 struct mgmt_rp_read_info {
79 	bdaddr_t bdaddr;
80 	__u8 version;
81 	__le16 manufacturer;
82 	__le32 supported_settings;
83 	__le32 current_settings;
84 	__u8 dev_class[3];
85 	__u8 name[MGMT_MAX_NAME_LENGTH];
86 	__u8 short_name[MGMT_MAX_SHORT_NAME_LENGTH];
87 } __packed;
88 
89 struct mgmt_mode {
90 	__u8 val;
91 } __packed;
92 
93 #define MGMT_OP_SET_POWERED		0x0005
94 
95 #define MGMT_OP_SET_DISCOVERABLE	0x0006
96 struct mgmt_cp_set_discoverable {
97 	__u8 val;
98 	__u16 timeout;
99 } __packed;
100 
101 #define MGMT_OP_SET_CONNECTABLE		0x0007
102 
103 #define MGMT_OP_SET_FAST_CONNECTABLE	0x0008
104 
105 #define MGMT_OP_SET_PAIRABLE		0x0009
106 
107 #define MGMT_OP_SET_LINK_SECURITY	0x000A
108 
109 #define MGMT_OP_SET_SSP			0x000B
110 
111 #define MGMT_OP_SET_HS			0x000C
112 
113 #define MGMT_OP_SET_LE			0x000D
114 
115 #define MGMT_OP_SET_DEV_CLASS		0x000E
116 struct mgmt_cp_set_dev_class {
117 	__u8 major;
118 	__u8 minor;
119 } __packed;
120 
121 #define MGMT_OP_SET_LOCAL_NAME		0x000F
122 struct mgmt_cp_set_local_name {
123 	__u8 name[MGMT_MAX_NAME_LENGTH];
124 } __packed;
125 
126 #define MGMT_OP_ADD_UUID		0x0010
127 struct mgmt_cp_add_uuid {
128 	__u8 uuid[16];
129 	__u8 svc_hint;
130 } __packed;
131 
132 #define MGMT_OP_REMOVE_UUID		0x0011
133 struct mgmt_cp_remove_uuid {
134 	__u8 uuid[16];
135 } __packed;
136 
137 struct mgmt_link_key_info {
138 	bdaddr_t bdaddr;
139 	u8 type;
140 	u8 val[16];
141 	u8 pin_len;
142 } __packed;
143 
144 #define MGMT_OP_LOAD_LINK_KEYS		0x0012
145 struct mgmt_cp_load_link_keys {
146 	__u8 debug_keys;
147 	__le16 key_count;
148 	struct mgmt_link_key_info keys[0];
149 } __packed;
150 
151 #define MGMT_OP_REMOVE_KEYS		0x0013
152 struct mgmt_cp_remove_keys {
153 	bdaddr_t bdaddr;
154 	__u8 disconnect;
155 } __packed;
156 struct mgmt_rp_remove_keys {
157 	bdaddr_t bdaddr;
158 	__u8 status;
159 };
160 
161 #define MGMT_OP_DISCONNECT		0x0014
162 struct mgmt_cp_disconnect {
163 	bdaddr_t bdaddr;
164 } __packed;
165 struct mgmt_rp_disconnect {
166 	bdaddr_t bdaddr;
167 	__u8 status;
168 } __packed;
169 
170 #define MGMT_ADDR_BREDR			0x00
171 #define MGMT_ADDR_LE_PUBLIC		0x01
172 #define MGMT_ADDR_LE_RANDOM		0x02
173 #define MGMT_ADDR_INVALID		0xff
174 
175 struct mgmt_addr_info {
176 	bdaddr_t bdaddr;
177 	__u8 type;
178 } __packed;
179 
180 #define MGMT_OP_GET_CONNECTIONS		0x0015
181 struct mgmt_rp_get_connections {
182 	__le16 conn_count;
183 	struct mgmt_addr_info addr[0];
184 } __packed;
185 
186 #define MGMT_OP_PIN_CODE_REPLY		0x0016
187 struct mgmt_cp_pin_code_reply {
188 	bdaddr_t bdaddr;
189 	__u8 pin_len;
190 	__u8 pin_code[16];
191 } __packed;
192 struct mgmt_rp_pin_code_reply {
193 	bdaddr_t bdaddr;
194 	uint8_t status;
195 } __packed;
196 
197 #define MGMT_OP_PIN_CODE_NEG_REPLY	0x0017
198 struct mgmt_cp_pin_code_neg_reply {
199 	bdaddr_t bdaddr;
200 } __packed;
201 
202 #define MGMT_OP_SET_IO_CAPABILITY	0x0018
203 struct mgmt_cp_set_io_capability {
204 	__u8 io_capability;
205 } __packed;
206 
207 #define MGMT_OP_PAIR_DEVICE		0x0019
208 struct mgmt_cp_pair_device {
209 	struct mgmt_addr_info addr;
210 	__u8 io_cap;
211 } __packed;
212 struct mgmt_rp_pair_device {
213 	struct mgmt_addr_info addr;
214 	__u8 status;
215 } __packed;
216 
217 #define MGMT_OP_USER_CONFIRM_REPLY	0x001A
218 struct mgmt_cp_user_confirm_reply {
219 	bdaddr_t bdaddr;
220 } __packed;
221 struct mgmt_rp_user_confirm_reply {
222 	bdaddr_t bdaddr;
223 	__u8 status;
224 } __packed;
225 
226 #define MGMT_OP_USER_CONFIRM_NEG_REPLY	0x001B
227 struct mgmt_cp_user_confirm_neg_reply {
228 	bdaddr_t bdaddr;
229 } __packed;
230 
231 #define MGMT_OP_USER_PASSKEY_REPLY	0x001C
232 struct mgmt_cp_user_passkey_reply {
233 	bdaddr_t bdaddr;
234 	__le32 passkey;
235 } __packed;
236 struct mgmt_rp_user_passkey_reply {
237 	bdaddr_t bdaddr;
238 	__u8 status;
239 } __packed;
240 
241 #define MGMT_OP_USER_PASSKEY_NEG_REPLY	0x001D
242 struct mgmt_cp_user_passkey_neg_reply {
243 	bdaddr_t bdaddr;
244 } __packed;
245 
246 #define MGMT_OP_READ_LOCAL_OOB_DATA	0x001E
247 struct mgmt_rp_read_local_oob_data {
248 	__u8 hash[16];
249 	__u8 randomizer[16];
250 } __packed;
251 
252 #define MGMT_OP_ADD_REMOTE_OOB_DATA	0x001F
253 struct mgmt_cp_add_remote_oob_data {
254 	bdaddr_t bdaddr;
255 	__u8 hash[16];
256 	__u8 randomizer[16];
257 } __packed;
258 
259 #define MGMT_OP_REMOVE_REMOTE_OOB_DATA	0x0020
260 struct mgmt_cp_remove_remote_oob_data {
261 	bdaddr_t bdaddr;
262 } __packed;
263 
264 #define MGMT_OP_START_DISCOVERY		0x0021
265 struct mgmt_cp_start_discovery {
266 	__u8 type;
267 } __packed;
268 
269 #define MGMT_OP_STOP_DISCOVERY		0x0022
270 
271 #define MGMT_OP_CONFIRM_NAME		0x0023
272 struct mgmt_cp_confirm_name {
273 	bdaddr_t bdaddr;
274 	__u8 name_known;
275 } __packed;
276 struct mgmt_rp_confirm_name {
277 	bdaddr_t bdaddr;
278 	__u8 status;
279 } __packed;
280 
281 #define MGMT_OP_BLOCK_DEVICE		0x0024
282 struct mgmt_cp_block_device {
283 	bdaddr_t bdaddr;
284 } __packed;
285 
286 #define MGMT_OP_UNBLOCK_DEVICE		0x0025
287 struct mgmt_cp_unblock_device {
288 	bdaddr_t bdaddr;
289 } __packed;
290 
291 #define MGMT_EV_CMD_COMPLETE		0x0001
292 struct mgmt_ev_cmd_complete {
293 	__le16 opcode;
294 	__u8 data[0];
295 } __packed;
296 
297 #define MGMT_EV_CMD_STATUS		0x0002
298 struct mgmt_ev_cmd_status {
299 	__u8 status;
300 	__le16 opcode;
301 } __packed;
302 
303 #define MGMT_EV_CONTROLLER_ERROR	0x0003
304 struct mgmt_ev_controller_error {
305 	__u8 error_code;
306 } __packed;
307 
308 #define MGMT_EV_INDEX_ADDED		0x0004
309 
310 #define MGMT_EV_INDEX_REMOVED		0x0005
311 
312 #define MGMT_EV_NEW_SETTINGS		0x0006
313 
314 #define MGMT_EV_CLASS_OF_DEV_CHANGED	0x0007
315 struct mgmt_ev_class_of_dev_changed {
316 	__u8 dev_class[3];
317 };
318 
319 #define MGMT_EV_LOCAL_NAME_CHANGED	0x0008
320 struct mgmt_ev_local_name_changed {
321 	__u8 name[MGMT_MAX_NAME_LENGTH];
322 	__u8 short_name[MGMT_MAX_SHORT_NAME_LENGTH];
323 } __packed;
324 
325 #define MGMT_EV_NEW_LINK_KEY		0x0009
326 struct mgmt_ev_new_link_key {
327 	__u8 store_hint;
328 	struct mgmt_link_key_info key;
329 } __packed;
330 
331 #define MGMT_EV_DEVICE_CONNECTED	0x000A
332 
333 #define MGMT_EV_DEVICE_DISCONNECTED	0x000B
334 
335 #define MGMT_EV_CONNECT_FAILED		0x000C
336 struct mgmt_ev_connect_failed {
337 	struct mgmt_addr_info addr;
338 	__u8 status;
339 } __packed;
340 
341 #define MGMT_EV_PIN_CODE_REQUEST	0x000D
342 struct mgmt_ev_pin_code_request {
343 	bdaddr_t bdaddr;
344 	__u8 secure;
345 } __packed;
346 
347 #define MGMT_EV_USER_CONFIRM_REQUEST	0x000E
348 struct mgmt_ev_user_confirm_request {
349 	bdaddr_t bdaddr;
350 	__u8 confirm_hint;
351 	__le32 value;
352 } __packed;
353 
354 #define MGMT_EV_USER_PASSKEY_REQUEST	0x000F
355 struct mgmt_ev_user_passkey_request {
356 	bdaddr_t bdaddr;
357 } __packed;
358 
359 #define MGMT_EV_AUTH_FAILED		0x0010
360 struct mgmt_ev_auth_failed {
361 	bdaddr_t bdaddr;
362 	__u8 status;
363 } __packed;
364 
365 #define MGMT_EV_DEVICE_FOUND		0x0011
366 struct mgmt_ev_device_found {
367 	struct mgmt_addr_info addr;
368 	__u8 dev_class[3];
369 	__s8 rssi;
370 	__u8 confirm_name;
371 	__le16 eir_len;
372 	__u8 eir[0];
373 } __packed;
374 
375 #define MGMT_EV_REMOTE_NAME		0x0012
376 struct mgmt_ev_remote_name {
377 	bdaddr_t bdaddr;
378 	__u8 name[MGMT_MAX_NAME_LENGTH];
379 } __packed;
380 
381 #define MGMT_EV_DISCOVERING		0x0013
382 
383 #define MGMT_EV_DEVICE_BLOCKED		0x0014
384 struct mgmt_ev_device_blocked {
385 	bdaddr_t bdaddr;
386 } __packed;
387 
388 #define MGMT_EV_DEVICE_UNBLOCKED	0x0015
389 struct mgmt_ev_device_unblocked {
390 	bdaddr_t bdaddr;
391 } __packed;
392