• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
24 #ifndef __packed
25 #define __packed __attribute__((packed))
26 #endif
27 
28 #define MGMT_INDEX_NONE			0xFFFF
29 
30 struct mgmt_hdr {
31 	uint16_t opcode;
32 	uint16_t index;
33 	uint16_t len;
34 } __packed;
35 #define MGMT_HDR_SIZE	6
36 
37 #define MGMT_OP_READ_VERSION		0x0001
38 struct mgmt_rp_read_version {
39 	uint8_t version;
40 	uint16_t revision;
41 } __packed;
42 
43 #define MGMT_OP_READ_FEATURES		0x0002
44 struct mgmt_rp_read_features {
45 	uint8_t features[8];
46 } __packed;
47 
48 #define MGMT_OP_READ_INDEX_LIST		0x0003
49 struct mgmt_rp_read_index_list {
50 	uint16_t num_controllers;
51 	uint16_t index[0];
52 } __packed;
53 
54 /* Reserve one extra byte for names in management messages so that they
55  * are always guaranteed to be nul-terminated */
56 #define MGMT_MAX_NAME_LENGTH		(HCI_MAX_NAME_LENGTH + 1)
57 
58 #define MGMT_OP_READ_INFO		0x0004
59 struct mgmt_rp_read_info {
60 	uint8_t type;
61 	uint8_t powered;
62 	uint8_t connectable;
63 	uint8_t discoverable;
64 	uint8_t pairable;
65 	uint8_t sec_mode;
66 	bdaddr_t bdaddr;
67 	uint8_t dev_class[3];
68 	uint8_t features[8];
69 	uint16_t manufacturer;
70 	uint8_t hci_ver;
71 	uint16_t hci_rev;
72 	uint8_t name[MGMT_MAX_NAME_LENGTH];
73 } __packed;
74 
75 struct mgmt_mode {
76 	uint8_t val;
77 } __packed;
78 
79 #define MGMT_OP_SET_POWERED		0x0005
80 
81 #define MGMT_OP_SET_DISCOVERABLE	0x0006
82 
83 #define MGMT_OP_SET_CONNECTABLE		0x0007
84 
85 #define MGMT_OP_SET_PAIRABLE		0x0008
86 
87 #define MGMT_OP_ADD_UUID		0x0009
88 struct mgmt_cp_add_uuid {
89 	uint8_t uuid[16];
90 	uint8_t svc_hint;
91 } __packed;
92 
93 #define MGMT_OP_REMOVE_UUID		0x000A
94 struct mgmt_cp_remove_uuid {
95 	uint8_t uuid[16];
96 } __packed;
97 
98 #define MGMT_OP_SET_DEV_CLASS		0x000B
99 struct mgmt_cp_set_dev_class {
100 	uint8_t major;
101 	uint8_t minor;
102 } __packed;
103 
104 #define MGMT_OP_SET_SERVICE_CACHE	0x000C
105 struct mgmt_cp_set_service_cache {
106 	uint8_t enable;
107 } __packed;
108 
109 struct mgmt_key_info {
110 	bdaddr_t bdaddr;
111 	uint8_t type;
112 	uint8_t val[16];
113 	uint8_t pin_len;
114 } __packed;
115 
116 #define MGMT_OP_LOAD_KEYS		0x000D
117 struct mgmt_cp_load_keys {
118 	uint8_t debug_keys;
119 	uint16_t key_count;
120 	struct mgmt_key_info keys[0];
121 } __packed;
122 
123 #define MGMT_OP_REMOVE_KEY		0x000E
124 struct mgmt_cp_remove_key {
125 	bdaddr_t bdaddr;
126 	uint8_t disconnect;
127 } __packed;
128 
129 #define MGMT_OP_DISCONNECT		0x000F
130 struct mgmt_cp_disconnect {
131 	bdaddr_t bdaddr;
132 } __packed;
133 struct mgmt_rp_disconnect {
134 	bdaddr_t bdaddr;
135 } __packed;
136 
137 #define MGMT_OP_GET_CONNECTIONS		0x0010
138 struct mgmt_rp_get_connections {
139 	uint16_t conn_count;
140 	bdaddr_t conn[0];
141 } __packed;
142 
143 #define MGMT_OP_PIN_CODE_REPLY		0x0011
144 struct mgmt_cp_pin_code_reply {
145 	bdaddr_t bdaddr;
146 	uint8_t pin_len;
147 	uint8_t pin_code[16];
148 } __packed;
149 
150 #define MGMT_OP_PIN_CODE_NEG_REPLY	0x0012
151 struct mgmt_cp_pin_code_neg_reply {
152 	bdaddr_t bdaddr;
153 } __packed;
154 
155 #define MGMT_OP_SET_IO_CAPABILITY	0x0013
156 struct mgmt_cp_set_io_capability {
157 	uint8_t io_capability;
158 } __packed;
159 
160 #define MGMT_OP_PAIR_DEVICE		0x0014
161 struct mgmt_cp_pair_device {
162 	bdaddr_t bdaddr;
163 	uint8_t io_cap;
164 } __packed;
165 struct mgmt_rp_pair_device {
166 	bdaddr_t bdaddr;
167 	uint8_t status;
168 } __packed;
169 
170 #define MGMT_OP_USER_CONFIRM_REPLY	0x0015
171 struct mgmt_cp_user_confirm_reply {
172 	bdaddr_t bdaddr;
173 } __packed;
174 struct mgmt_rp_user_confirm_reply {
175 	bdaddr_t bdaddr;
176 	uint8_t status;
177 } __packed;
178 
179 #define MGMT_OP_USER_CONFIRM_NEG_REPLY	0x0016
180 
181 #define MGMT_OP_SET_LOCAL_NAME		0x0017
182 struct mgmt_cp_set_local_name {
183 	uint8_t name[MGMT_MAX_NAME_LENGTH];
184 } __packed;
185 
186 #define MGMT_OP_READ_LOCAL_OOB_DATA	0x0018
187 struct mgmt_rp_read_local_oob_data {
188 	uint8_t hash[16];
189 	uint8_t randomizer[16];
190 } __packed;
191 
192 #define MGMT_OP_ADD_REMOTE_OOB_DATA	0x0019
193 struct mgmt_cp_add_remote_oob_data {
194 	bdaddr_t bdaddr;
195 	uint8_t hash[16];
196 	uint8_t randomizer[16];
197 } __packed;
198 
199 #define MGMT_OP_REMOVE_REMOTE_OOB_DATA	0x001A
200 struct mgmt_cp_remove_remote_oob_data {
201 	bdaddr_t bdaddr;
202 } __packed;
203 
204 #define MGMT_OP_START_DISCOVERY		0x001B
205 
206 #define MGMT_OP_STOP_DISCOVERY		0x001C
207 
208 #define MGMT_EV_CMD_COMPLETE		0x0001
209 struct mgmt_ev_cmd_complete {
210 	uint16_t opcode;
211 	uint8_t data[0];
212 } __packed;
213 
214 #define MGMT_EV_CMD_STATUS		0x0002
215 struct mgmt_ev_cmd_status {
216 	uint8_t status;
217 	uint16_t opcode;
218 } __packed;
219 
220 #define MGMT_EV_CONTROLLER_ERROR	0x0003
221 struct mgmt_ev_controller_error {
222 	uint8_t error_code;
223 } __packed;
224 
225 #define MGMT_EV_INDEX_ADDED		0x0004
226 
227 #define MGMT_EV_INDEX_REMOVED		0x0005
228 
229 #define MGMT_EV_POWERED			0x0006
230 
231 #define MGMT_EV_DISCOVERABLE		0x0007
232 
233 #define MGMT_EV_CONNECTABLE		0x0008
234 
235 #define MGMT_EV_PAIRABLE		0x0009
236 
237 #define MGMT_EV_NEW_KEY			0x000A
238 struct mgmt_ev_new_key {
239 	uint8_t store_hint;
240 	struct mgmt_key_info key;
241 } __packed;
242 
243 #define MGMT_EV_DEVICE_CONNECTED	0x000B
244 struct mgmt_ev_device_connected {
245 	bdaddr_t bdaddr;
246 } __packed;
247 
248 #define MGMT_EV_DEVICE_DISCONNECTED	0x000C
249 struct mgmt_ev_device_disconnected {
250 	bdaddr_t bdaddr;
251 } __packed;
252 
253 #define MGMT_EV_CONNECT_FAILED		0x000D
254 struct mgmt_ev_connect_failed {
255 	bdaddr_t bdaddr;
256 	uint8_t status;
257 } __packed;
258 
259 #define MGMT_EV_PIN_CODE_REQUEST	0x000E
260 struct mgmt_ev_pin_code_request {
261 	bdaddr_t bdaddr;
262 	uint8_t secure;
263 } __packed;
264 
265 #define MGMT_EV_USER_CONFIRM_REQUEST	0x000F
266 struct mgmt_ev_user_confirm_request {
267 	bdaddr_t bdaddr;
268 	uint8_t confirm_hint;
269 	uint32_t value;
270 } __packed;
271 
272 #define MGMT_EV_AUTH_FAILED		0x0010
273 struct mgmt_ev_auth_failed {
274 	bdaddr_t bdaddr;
275 	uint8_t status;
276 } __packed;
277 
278 #define MGMT_EV_LOCAL_NAME_CHANGED	0x0011
279 struct mgmt_ev_local_name_changed {
280 	uint8_t name[MGMT_MAX_NAME_LENGTH];
281 } __packed;
282 
283 #define MGMT_EV_DEVICE_FOUND		0x0012
284 struct mgmt_ev_device_found {
285 	bdaddr_t bdaddr;
286 	uint8_t dev_class[3];
287 	int8_t rssi;
288 	uint8_t eir[HCI_MAX_EIR_LENGTH];
289 } __packed;
290 
291 #define MGMT_EV_REMOTE_NAME		0x0013
292 struct mgmt_ev_remote_name {
293 	bdaddr_t bdaddr;
294 	uint8_t name[MGMT_MAX_NAME_LENGTH];
295 } __packed;
296 
297 #define MGMT_EV_DISCOVERING		0x0014
298