blob: e5a866a20eda80a296a3eaf30a681419dedf5d5c [file] [log] [blame]
Johan Hedbergc02178d2010-12-08 00:21:05 +02001/*
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
Szymon Janc4e51eae2011-02-25 19:05:48 +010024#define MGMT_INDEX_NONE 0xFFFF
25
Johan Hedbergc02178d2010-12-08 00:21:05 +020026struct mgmt_hdr {
27 __le16 opcode;
Szymon Janc4e51eae2011-02-25 19:05:48 +010028 __le16 index;
Johan Hedbergc02178d2010-12-08 00:21:05 +020029 __le16 len;
30} __packed;
Johan Hedbergc02178d2010-12-08 00:21:05 +020031
Johan Hedberg02d98122010-12-13 21:07:04 +020032#define MGMT_OP_READ_VERSION 0x0001
33struct mgmt_rp_read_version {
34 __u8 version;
35 __le16 revision;
36} __packed;
37
Johan Hedbergfaba42e2010-12-13 21:07:05 +020038#define MGMT_OP_READ_INDEX_LIST 0x0003
39struct mgmt_rp_read_index_list {
40 __le16 num_controllers;
41 __le16 index[0];
42} __packed;
43
Johan Hedbergdc4fe302011-03-16 14:29:36 +020044/* Reserve one extra byte for names in management messages so that they
45 * are always guaranteed to be nul-terminated */
46#define MGMT_MAX_NAME_LENGTH (HCI_MAX_NAME_LENGTH + 1)
47
Johan Hedbergf7b64e62010-12-13 21:07:06 +020048#define MGMT_OP_READ_INFO 0x0004
Johan Hedbergf7b64e62010-12-13 21:07:06 +020049struct mgmt_rp_read_info {
Johan Hedbergf7b64e62010-12-13 21:07:06 +020050 __u8 type;
51 __u8 powered;
Johan Hedberg9fbcbb42010-12-30 00:18:33 +020052 __u8 connectable;
Johan Hedbergf7b64e62010-12-13 21:07:06 +020053 __u8 discoverable;
54 __u8 pairable;
55 __u8 sec_mode;
56 bdaddr_t bdaddr;
57 __u8 dev_class[3];
58 __u8 features[8];
59 __u16 manufacturer;
60 __u8 hci_ver;
61 __u16 hci_rev;
Johan Hedbergdc4fe302011-03-16 14:29:36 +020062 __u8 name[MGMT_MAX_NAME_LENGTH];
Johan Hedbergf7b64e62010-12-13 21:07:06 +020063} __packed;
64
Johan Hedberg72a734e2010-12-30 00:38:22 +020065struct mgmt_mode {
Johan Hedberg72a734e2010-12-30 00:38:22 +020066 __u8 val;
67} __packed;
68
Johan Hedbergeec8d2b2010-12-16 10:17:38 +020069#define MGMT_OP_SET_POWERED 0x0005
Johan Hedbergeec8d2b2010-12-16 10:17:38 +020070
Johan Hedberg73f22f62010-12-29 16:00:25 +020071#define MGMT_OP_SET_DISCOVERABLE 0x0006
Johan Hedberg16ab91a2011-11-07 22:16:02 +020072struct mgmt_cp_set_discoverable {
73 __u8 val;
74 __u16 timeout;
75} __packed;
Johan Hedberg73f22f62010-12-29 16:00:25 +020076
Johan Hedberg9fbcbb42010-12-30 00:18:33 +020077#define MGMT_OP_SET_CONNECTABLE 0x0007
Johan Hedberg9fbcbb42010-12-30 00:18:33 +020078
Johan Hedbergc542a062011-01-26 13:11:03 +020079#define MGMT_OP_SET_PAIRABLE 0x0008
80
Johan Hedberg2aeb9a12011-01-04 12:08:51 +020081#define MGMT_OP_ADD_UUID 0x0009
82struct mgmt_cp_add_uuid {
Johan Hedberg2aeb9a12011-01-04 12:08:51 +020083 __u8 uuid[16];
Johan Hedberg1aff6f02011-01-13 21:56:52 +020084 __u8 svc_hint;
Johan Hedberg2aeb9a12011-01-04 12:08:51 +020085} __packed;
86
87#define MGMT_OP_REMOVE_UUID 0x000A
88struct mgmt_cp_remove_uuid {
Johan Hedberg2aeb9a12011-01-04 12:08:51 +020089 __u8 uuid[16];
90} __packed;
91
Johan Hedberg1aff6f02011-01-13 21:56:52 +020092#define MGMT_OP_SET_DEV_CLASS 0x000B
93struct mgmt_cp_set_dev_class {
Johan Hedberg1aff6f02011-01-13 21:56:52 +020094 __u8 major;
95 __u8 minor;
96} __packed;
97
98#define MGMT_OP_SET_SERVICE_CACHE 0x000C
99struct mgmt_cp_set_service_cache {
Johan Hedberg1aff6f02011-01-13 21:56:52 +0200100 __u8 enable;
101} __packed;
102
Johan Hedberg86742e12011-11-07 23:13:38 +0200103struct mgmt_link_key_info {
Johan Hedberg55ed8ca2011-01-17 14:41:05 +0200104 bdaddr_t bdaddr;
105 u8 type;
106 u8 val[16];
107 u8 pin_len;
108} __packed;
109
Johan Hedberg86742e12011-11-07 23:13:38 +0200110#define MGMT_OP_LOAD_LINK_KEYS 0x000D
111struct mgmt_cp_load_link_keys {
Johan Hedberg55ed8ca2011-01-17 14:41:05 +0200112 __u8 debug_keys;
113 __le16 key_count;
Johan Hedberg86742e12011-11-07 23:13:38 +0200114 struct mgmt_link_key_info keys[0];
Johan Hedberg55ed8ca2011-01-17 14:41:05 +0200115} __packed;
116
Johan Hedberg86742e12011-11-07 23:13:38 +0200117#define MGMT_OP_REMOVE_KEYS 0x000E
118struct mgmt_cp_remove_keys {
Johan Hedberg55ed8ca2011-01-17 14:41:05 +0200119 bdaddr_t bdaddr;
120 __u8 disconnect;
121} __packed;
Johan Hedberga8a1d192011-11-10 15:54:38 +0200122struct mgmt_rp_remove_keys {
123 bdaddr_t bdaddr;
124 __u8 status;
125};
Johan Hedberg55ed8ca2011-01-17 14:41:05 +0200126
Johan Hedberg8962ee72011-01-20 12:40:27 +0200127#define MGMT_OP_DISCONNECT 0x000F
128struct mgmt_cp_disconnect {
Johan Hedberg8962ee72011-01-20 12:40:27 +0200129 bdaddr_t bdaddr;
130} __packed;
131struct mgmt_rp_disconnect {
Johan Hedberg8962ee72011-01-20 12:40:27 +0200132 bdaddr_t bdaddr;
133} __packed;
134
Johan Hedberg4c659c32011-11-07 23:13:39 +0200135#define MGMT_ADDR_BREDR 0x00
Johan Hedberg48264f02011-11-09 13:58:58 +0200136#define MGMT_ADDR_LE_PUBLIC 0x01
137#define MGMT_ADDR_LE_RANDOM 0x02
Johan Hedberg4c659c32011-11-07 23:13:39 +0200138#define MGMT_ADDR_INVALID 0xff
139
140struct mgmt_addr_info {
141 bdaddr_t bdaddr;
142 __u8 type;
143} __packed;
144
Johan Hedberg2784eb42011-01-21 13:56:35 +0200145#define MGMT_OP_GET_CONNECTIONS 0x0010
Johan Hedberg2784eb42011-01-21 13:56:35 +0200146struct mgmt_rp_get_connections {
Johan Hedberg2784eb42011-01-21 13:56:35 +0200147 __le16 conn_count;
Johan Hedberg4c659c32011-11-07 23:13:39 +0200148 struct mgmt_addr_info addr[0];
Johan Hedberg2784eb42011-01-21 13:56:35 +0200149} __packed;
150
Johan Hedberg980e1a52011-01-22 06:10:07 +0200151#define MGMT_OP_PIN_CODE_REPLY 0x0011
152struct mgmt_cp_pin_code_reply {
Johan Hedberg980e1a52011-01-22 06:10:07 +0200153 bdaddr_t bdaddr;
154 __u8 pin_len;
155 __u8 pin_code[16];
156} __packed;
Johan Hedbergac56fb12011-02-19 12:05:59 -0300157struct mgmt_rp_pin_code_reply {
Johan Hedbergac56fb12011-02-19 12:05:59 -0300158 bdaddr_t bdaddr;
159 uint8_t status;
160} __packed;
Johan Hedberg980e1a52011-01-22 06:10:07 +0200161
162#define MGMT_OP_PIN_CODE_NEG_REPLY 0x0012
163struct mgmt_cp_pin_code_neg_reply {
Johan Hedberg980e1a52011-01-22 06:10:07 +0200164 bdaddr_t bdaddr;
165} __packed;
166
Johan Hedberg17fa4b92011-01-25 13:28:33 +0200167#define MGMT_OP_SET_IO_CAPABILITY 0x0013
168struct mgmt_cp_set_io_capability {
Johan Hedberg17fa4b92011-01-25 13:28:33 +0200169 __u8 io_capability;
170} __packed;
171
Johan Hedberge9a416b2011-02-19 12:05:56 -0300172#define MGMT_OP_PAIR_DEVICE 0x0014
173struct mgmt_cp_pair_device {
Johan Hedberge9a416b2011-02-19 12:05:56 -0300174 bdaddr_t bdaddr;
175 __u8 io_cap;
176} __packed;
177struct mgmt_rp_pair_device {
Johan Hedberge9a416b2011-02-19 12:05:56 -0300178 bdaddr_t bdaddr;
179 __u8 status;
180} __packed;
181
Johan Hedberga5c29682011-02-19 12:05:57 -0300182#define MGMT_OP_USER_CONFIRM_REPLY 0x0015
183struct mgmt_cp_user_confirm_reply {
Johan Hedberga5c29682011-02-19 12:05:57 -0300184 bdaddr_t bdaddr;
185} __packed;
186struct mgmt_rp_user_confirm_reply {
Johan Hedberga5c29682011-02-19 12:05:57 -0300187 bdaddr_t bdaddr;
188 __u8 status;
189} __packed;
190
191#define MGMT_OP_USER_CONFIRM_NEG_REPLY 0x0016
192
Johan Hedbergb312b1612011-03-16 14:29:37 +0200193#define MGMT_OP_SET_LOCAL_NAME 0x0017
194struct mgmt_cp_set_local_name {
195 __u8 name[MGMT_MAX_NAME_LENGTH];
196} __packed;
197
Szymon Jancc35938b2011-03-22 13:12:21 +0100198#define MGMT_OP_READ_LOCAL_OOB_DATA 0x0018
199struct mgmt_rp_read_local_oob_data {
200 __u8 hash[16];
201 __u8 randomizer[16];
202} __packed;
203
Szymon Janc2763eda2011-03-22 13:12:22 +0100204#define MGMT_OP_ADD_REMOTE_OOB_DATA 0x0019
205struct mgmt_cp_add_remote_oob_data {
206 bdaddr_t bdaddr;
207 __u8 hash[16];
208 __u8 randomizer[16];
209} __packed;
210
211#define MGMT_OP_REMOVE_REMOTE_OOB_DATA 0x001A
212struct mgmt_cp_remove_remote_oob_data {
213 bdaddr_t bdaddr;
214} __packed;
215
Johan Hedberg14a53662011-04-27 10:29:56 -0400216#define MGMT_OP_START_DISCOVERY 0x001B
217
218#define MGMT_OP_STOP_DISCOVERY 0x001C
219
Antti Julku7fbec222011-06-15 12:01:15 +0300220#define MGMT_OP_BLOCK_DEVICE 0x001D
221struct mgmt_cp_block_device {
222 bdaddr_t bdaddr;
223} __packed;
224
225#define MGMT_OP_UNBLOCK_DEVICE 0x001E
226struct mgmt_cp_unblock_device {
227 bdaddr_t bdaddr;
228} __packed;
229
Antti Julkuf6422ec2011-06-22 13:11:56 +0300230#define MGMT_OP_SET_FAST_CONNECTABLE 0x001F
231struct mgmt_cp_set_fast_connectable {
232 __u8 enable;
233} __packed;
234
Johan Hedbergc02178d2010-12-08 00:21:05 +0200235#define MGMT_EV_CMD_COMPLETE 0x0001
236struct mgmt_ev_cmd_complete {
237 __le16 opcode;
238 __u8 data[0];
239} __packed;
240
241#define MGMT_EV_CMD_STATUS 0x0002
242struct mgmt_ev_cmd_status {
243 __u8 status;
244 __le16 opcode;
245} __packed;
246
247#define MGMT_EV_CONTROLLER_ERROR 0x0003
248struct mgmt_ev_controller_error {
Johan Hedbergc02178d2010-12-08 00:21:05 +0200249 __u8 error_code;
250} __packed;
Johan Hedbergc71e97b2010-12-13 21:07:07 +0200251
252#define MGMT_EV_INDEX_ADDED 0x0004
Johan Hedbergc71e97b2010-12-13 21:07:07 +0200253
254#define MGMT_EV_INDEX_REMOVED 0x0005
Johan Hedberg5add6af2010-12-16 10:00:37 +0200255
256#define MGMT_EV_POWERED 0x0006
Johan Hedberg73f22f62010-12-29 16:00:25 +0200257
258#define MGMT_EV_DISCOVERABLE 0x0007
Johan Hedberg9fbcbb42010-12-30 00:18:33 +0200259
260#define MGMT_EV_CONNECTABLE 0x0008
Johan Hedbergc542a062011-01-26 13:11:03 +0200261
262#define MGMT_EV_PAIRABLE 0x0009
Johan Hedberg55ed8ca2011-01-17 14:41:05 +0200263
Johan Hedberg86742e12011-11-07 23:13:38 +0200264#define MGMT_EV_NEW_LINK_KEY 0x000A
265struct mgmt_ev_new_link_key {
Johan Hedberg4df378a2011-04-28 11:29:03 -0700266 __u8 store_hint;
Johan Hedberg86742e12011-11-07 23:13:38 +0200267 struct mgmt_link_key_info key;
Johan Hedberg55ed8ca2011-01-17 14:41:05 +0200268} __packed;
Johan Hedbergf7520542011-01-20 12:34:39 +0200269
270#define MGMT_EV_CONNECTED 0x000B
Johan Hedbergf7520542011-01-20 12:34:39 +0200271
272#define MGMT_EV_DISCONNECTED 0x000C
Johan Hedberg17d5c042011-01-22 06:09:08 +0200273
274#define MGMT_EV_CONNECT_FAILED 0x000D
275struct mgmt_ev_connect_failed {
Johan Hedberg4c659c32011-11-07 23:13:39 +0200276 struct mgmt_addr_info addr;
Johan Hedberg17d5c042011-01-22 06:09:08 +0200277 __u8 status;
278} __packed;
Johan Hedberg980e1a52011-01-22 06:10:07 +0200279
280#define MGMT_EV_PIN_CODE_REQUEST 0x000E
281struct mgmt_ev_pin_code_request {
Johan Hedberg980e1a52011-01-22 06:10:07 +0200282 bdaddr_t bdaddr;
Waldemar Rymarkiewicza770bb52011-04-28 12:07:59 +0200283 __u8 secure;
Johan Hedberg980e1a52011-01-22 06:10:07 +0200284} __packed;
Johan Hedberga5c29682011-02-19 12:05:57 -0300285
286#define MGMT_EV_USER_CONFIRM_REQUEST 0x000F
287struct mgmt_ev_user_confirm_request {
Johan Hedberga5c29682011-02-19 12:05:57 -0300288 bdaddr_t bdaddr;
Johan Hedberg55bc1a32011-04-28 11:28:56 -0700289 __u8 confirm_hint;
Johan Hedberga5c29682011-02-19 12:05:57 -0300290 __le32 value;
291} __packed;
Johan Hedberg2a611692011-02-19 12:06:00 -0300292
293#define MGMT_EV_AUTH_FAILED 0x0010
294struct mgmt_ev_auth_failed {
Johan Hedberg2a611692011-02-19 12:06:00 -0300295 bdaddr_t bdaddr;
296 __u8 status;
297} __packed;
Johan Hedbergb312b1612011-03-16 14:29:37 +0200298
299#define MGMT_EV_LOCAL_NAME_CHANGED 0x0011
300struct mgmt_ev_local_name_changed {
301 __u8 name[MGMT_MAX_NAME_LENGTH];
302} __packed;
Johan Hedberge17acd42011-03-30 23:57:16 +0300303
304#define MGMT_EV_DEVICE_FOUND 0x0012
305struct mgmt_ev_device_found {
Johan Hedberg4c659c32011-11-07 23:13:39 +0200306 struct mgmt_addr_info addr;
Johan Hedberge17acd42011-03-30 23:57:16 +0300307 __u8 dev_class[3];
308 __s8 rssi;
309 __u8 eir[HCI_MAX_EIR_LENGTH];
310} __packed;
Johan Hedberga88a9652011-03-30 13:18:12 +0300311
312#define MGMT_EV_REMOTE_NAME 0x0013
313struct mgmt_ev_remote_name {
314 bdaddr_t bdaddr;
315 __u8 name[MGMT_MAX_NAME_LENGTH];
316} __packed;
Johan Hedberg314b2382011-04-27 10:29:57 -0400317
318#define MGMT_EV_DISCOVERING 0x0014
Antti Julku5e762442011-08-25 16:48:02 +0300319
320#define MGMT_EV_DEVICE_BLOCKED 0x0015
321struct mgmt_ev_device_blocked {
322 bdaddr_t bdaddr;
323} __packed;
324
325#define MGMT_EV_DEVICE_UNBLOCKED 0x0016
326struct mgmt_ev_device_unblocked {
327 bdaddr_t bdaddr;
328} __packed;