hci.h revision 1.2 1 /* $NetBSD: hci.h,v 1.2 2006/07/23 22:06:13 ad Exp $ */
2
3 /*-
4 * Copyright (c) 2005 Iain Hibbert.
5 * Copyright (c) 2006 Itronix Inc.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. The name of Itronix Inc. may not be used to endorse
17 * or promote products derived from this software without specific
18 * prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY ITRONIX INC. ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ITRONIX INC. BE LIABLE FOR ANY
24 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27 * ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32 /*-
33 * Copyright (c) 2001 Maksim Yevmenkin <m_evmenkin (at) yahoo.com>
34 * All rights reserved.
35 *
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
38 * are met:
39 * 1. Redistributions of source code must retain the above copyright
40 * notice, this list of conditions and the following disclaimer.
41 * 2. Redistributions in binary form must reproduce the above copyright
42 * notice, this list of conditions and the following disclaimer in the
43 * documentation and/or other materials provided with the distribution.
44 *
45 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
46 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
47 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
48 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
49 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
51 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
53 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
54 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
55 * SUCH DAMAGE.
56 *
57 * $Id: hci.h,v 1.2 2006/07/23 22:06:13 ad Exp $
58 * $FreeBSD: src/sys/netgraph/bluetooth/include/ng_hci.h,v 1.6 2005/01/07 01:45:43 imp Exp $
59 */
60
61 /*
62 * This file contains everything that applications need to know from
63 * Host Controller Interface (HCI). Information taken from Bluetooth
64 * Core Specifications (v1.1 and v2.0)
65 *
66 * This file can be included by both kernel and userland applications.
67 *
68 * NOTE: Here and after Bluetooth device is called a "unit". Bluetooth
69 * specification refers to both devices and units. They are the
70 * same thing (I think), so to be consistent word "unit" will be
71 * used.
72 */
73
74 #ifndef _NETBT_HCI_H_
75 #define _NETBT_HCI_H_
76
77 #include <netbt/bluetooth.h>
78
79 /**************************************************************************
80 **************************************************************************
81 ** Common defines and types (HCI)
82 **************************************************************************
83 **************************************************************************/
84
85 #define HCI_LAP_SIZE 3 /* unit LAP */
86 #define HCI_KEY_SIZE 16 /* link key */
87 #define HCI_PIN_SIZE 16 /* link PIN */
88 #define HCI_EVENT_MASK_SIZE 8 /* event mask */
89 #define HCI_CLASS_SIZE 3 /* unit class */
90 #define HCI_FEATURES_SIZE 8 /* LMP features */
91 #define HCI_UNIT_NAME_SIZE 248 /* unit name size */
92 #define HCI_DEVNAME_SIZE 16 /* same as dv_xname */
93
94 /* HCI specification */
95 #define HCI_SPEC_V10 0x00 /* v1.0 */
96 #define HCI_SPEC_V11 0x01 /* v1.1 */
97 #define HCI_SPEC_V12 0x02 /* v1.2 */
98 /* 0x02 - 0xFF - reserved for future use */
99
100 /* LMP features (and page 0 of extended features) */
101 /* ------------------- byte 0 --------------------*/
102 #define HCI_LMP_3SLOT 0x01
103 #define HCI_LMP_5SLOT 0x02
104 #define HCI_LMP_ENCRYPTION 0x04
105 #define HCI_LMP_SLOT_OFFSET 0x08
106 #define HCI_LMP_TIMIACCURACY 0x10
107 #define HCI_LMP_ROLE_SWITCH 0x20
108 #define HCI_LMP_HOLD_MODE 0x40
109 #define HCI_LMP_SNIFF_MODE 0x80
110 /* ------------------- byte 1 --------------------*/
111 #define HCI_LMP_PARK_MODE 0x01
112 #define HCI_LMP_RSSI 0x02
113 #define HCI_LMP_CHANNEL_QUALITY 0x04
114 #define HCI_LMP_SCO_LINK 0x08
115 #define HCI_LMP_HV2_PKT 0x10
116 #define HCI_LMP_HV3_PKT 0x20
117 #define HCI_LMP_ULAW_LOG 0x40
118 #define HCI_LMP_ALAW_LOG 0x80
119 /* ------------------- byte 2 --------------------*/
120 #define HCI_LMP_CVSD 0x01
121 #define HCI_LMP_PAGISCHEME 0x02
122 #define HCI_LMP_POWER_CONTROL 0x04
123 #define HCI_LMP_TRANSPARENT_SCO 0x08
124 #define HCI_LMP_FLOW_CONTROL_LAG0 0x10
125 #define HCI_LMP_FLOW_CONTROL_LAG1 0x20
126 #define HCI_LMP_FLOW_CONTROL_LAG2 0x40
127 #define HCI_LMP_BC_ENCRYPTION 0x80
128 /* ------------------- byte 3 --------------------*/
129 /* reserved 0x01 */
130 #define HCI_LMP_EDR_ACL_2MBPS 0x02
131 #define HCI_LMP_EDR_ACL_3MBPS 0x04
132 #define HCI_LMP_ENHANCED_ISCAN 0x08
133 #define HCI_LMP_INTERLACED_ISCAN 0x10
134 #define HCI_LMP_INTERLACED_PSCAN 0x20
135 #define HCI_LMP_RSSI_INQUIRY 0x40
136 #define HCI_LMP_EV3_PKT 0x80
137 /* ------------------- byte 4 --------------------*/
138 #define HCI_LMP_EV4_PKT 0x01
139 #define HCI_LMP_EV5_PKT 0x02
140 /* reserved 0x04 */
141 #define HCI_LMP_AFH_CAPABLE_SLAVE 0x08
142 #define HCI_LMP_AFH_CLASS_SLAVE 0x10
143 /* reserved 0x20 */
144 /* reserved 0x40 */
145 #define HCI_LMP_3SLOT_EDR_ACL 0x80
146 /* ------------------- byte 5 --------------------*/
147 #define HCI_LMP_5SLOT_EDR_ACL 0x01
148 /* reserved 0x02 */
149 /* reserved 0x04 */
150 #define HCI_LMP_AFH_CAPABLE_MASTER 0x08
151 #define HCI_LMP_AFH_CLASS_MASTER 0x10
152 #define HCI_LMP_EDR_eSCO_2MBPS 0x20
153 #define HCI_LMP_EDR_eSCO_3MBPS 0x40
154 #define HCI_LMP_3SLOT_EDR_eSCO 0x80
155 /* ------------------- byte 6 --------------------*/
156 /* reserved */
157 /* ------------------- byte 7 --------------------*/
158 #define HCI_LMP_EXTENDED_FEATURES 0x80
159
160 /* Link types */
161 #define HCI_LINK_SCO 0x00 /* Voice */
162 #define HCI_LINK_ACL 0x01 /* Data */
163 #define HCI_LINK_eSCO 0x02 /* eSCO */
164 /* 0x03 - 0xFF - reserved for future use */
165
166 /*
167 * ACL/SCO packet type bits are set to enable the
168 * packet type, except for 2MBPS and 3MBPS when they
169 * are unset to enable the packet type.
170 */
171 /* ACL Packet types */
172 #define HCI_PKT_2MBPS_DH1 0x0002
173 #define HCI_PKT_3MBPS_DH1 0x0004
174 #define HCI_PKT_DM1 0x0008
175 #define HCI_PKT_DH1 0x0010
176 #define HCI_PKT_2MBPS_DH3 0x0100
177 #define HCI_PKT_3MBPS_DH3 0x0200
178 #define HCI_PKT_DM3 0x0400
179 #define HCI_PKT_DH3 0x0800
180 #define HCI_PKT_2MBPS_DH5 0x1000
181 #define HCI_PKT_3MBPS_DH5 0x2000
182 #define HCI_PKT_DM5 0x4000
183 #define HCI_PKT_DH5 0x8000
184
185 /* SCO Packet types */
186 #define HCI_PKT_HV1 0x0001
187 #define HCI_PKT_HV2 0x0002
188 #define HCI_PKT_HV3 0x0004
189 #define HCI_PKT_EV3 0x0008
190 #define HCI_PKT_EV4 0x0010
191 #define HCI_PKT_EV5 0x0020
192 #define HCI_PKT_2MBPS_EV3 0x0040
193 #define HCI_PKT_3MBPS_EV3 0x0080
194 #define HCI_PKT_2MBPS_EV5 0x0100
195 #define HCI_PKT_3MBPS_EV5 0x0200
196
197 /*
198 * Connection modes/Unit modes
199 *
200 * This is confusing. It means that one of the units change its mode
201 * for the specific connection. For example one connection was put on
202 * hold (but i could be wrong :)
203 */
204
205 /* Page scan modes */
206 #define HCI_MANDATORY_PAGE_SCAN_MODE 0x00
207 #define HCI_OPTIONAL_PAGE_SCAN_MODE1 0x01
208 #define HCI_OPTIONAL_PAGE_SCAN_MODE2 0x02
209 #define HCI_OPTIONAL_PAGE_SCAN_MODE3 0x03
210 /* 0x04 - 0xFF - reserved for future use */
211
212 /* Page scan repetition modes */
213 #define HCI_SCAN_REP_MODE0 0x00
214 #define HCI_SCAN_REP_MODE1 0x01
215 #define HCI_SCAN_REP_MODE2 0x02
216 /* 0x03 - 0xFF - reserved for future use */
217
218 /* Page scan period modes */
219 #define HCI_PAGE_SCAN_PERIOD_MODE0 0x00
220 #define HCI_PAGE_SCAN_PERIOD_MODE1 0x01
221 #define HCI_PAGE_SCAN_PERIOD_MODE2 0x02
222 /* 0x03 - 0xFF - reserved for future use */
223
224 /* Scan enable */
225 #define HCI_NO_SCAN_ENABLE 0x00
226 #define HCI_INQUIRY_SCAN_ENABLE 0x01
227 #define HCI_PAGE_SCAN_ENABLE 0x02
228 /* 0x04 - 0xFF - reserved for future use */
229
230 /* Hold mode activities */
231 #define HCI_HOLD_MODE_NO_CHANGE 0x00
232 #define HCI_HOLD_MODE_SUSPEND_PAGE_SCAN 0x01
233 #define HCI_HOLD_MODE_SUSPEND_INQUIRY_SCAN 0x02
234 #define HCI_HOLD_MODE_SUSPEND_PERIOD_INQUIRY 0x04
235 /* 0x08 - 0x80 - reserved for future use */
236
237 /* Connection roles */
238 #define HCI_ROLE_MASTER 0x00
239 #define HCI_ROLE_SLAVE 0x01
240 /* 0x02 - 0xFF - reserved for future use */
241
242 /* Key flags */
243 #define HCI_USE_SEMI_PERMANENT_LINK_KEYS 0x00
244 #define HCI_USE_TEMPORARY_LINK_KEY 0x01
245 /* 0x02 - 0xFF - reserved for future use */
246
247 /* Pin types */
248 #define HCI_PIN_TYPE_VARIABLE 0x00
249 #define HCI_PIN_TYPE_FIXED 0x01
250
251 /* Link key types */
252 #define HCI_LINK_KEY_TYPE_COMBINATION_KEY 0x00
253 #define HCI_LINK_KEY_TYPE_LOCAL_UNIT_KEY 0x01
254 #define HCI_LINK_KEY_TYPE_REMOTE_UNIT_KEY 0x02
255 /* 0x03 - 0xFF - reserved for future use */
256
257 /* Encryption modes */
258 #define HCI_ENCRYPTION_MODE_NONE 0x00
259 #define HCI_ENCRYPTION_MODE_P2P 0x01
260 #define HCI_ENCRYPTION_MODE_ALL 0x02
261 /* 0x03 - 0xFF - reserved for future use */
262
263 /* Quality of service types */
264 #define HCI_SERVICE_TYPE_NO_TRAFFIC 0x00
265 #define HCI_SERVICE_TYPE_BEST_EFFORT 0x01
266 #define HCI_SERVICE_TYPE_GUARANTEED 0x02
267 /* 0x03 - 0xFF - reserved for future use */
268
269 /* Link policy settings */
270 #define HCI_LINK_POLICY_DISABLE_ALL_LM_MODES 0x0000
271 #define HCI_LINK_POLICY_ENABLE_ROLE_SWITCH 0x0001 /* Master/Slave switch */
272 #define HCI_LINK_POLICY_ENABLE_HOLD_MODE 0x0002
273 #define HCI_LINK_POLICY_ENABLE_SNIFF_MODE 0x0004
274 #define HCI_LINK_POLICY_ENABLE_PARK_MODE 0x0008
275 /* 0x0010 - 0x8000 - reserved for future use */
276
277 /* Event masks */
278 #define HCI_EVMSK_ALL 0x00000000ffffffff
279 #define HCI_EVMSK_NONE 0x0000000000000000
280 #define HCI_EVMSK_INQUIRY_COMPL 0x0000000000000001
281 #define HCI_EVMSK_INQUIRY_RESULT 0x0000000000000002
282 #define HCI_EVMSK_CON_COMPL 0x0000000000000004
283 #define HCI_EVMSK_CON_REQ 0x0000000000000008
284 #define HCI_EVMSK_DISCON_COMPL 0x0000000000000010
285 #define HCI_EVMSK_AUTH_COMPL 0x0000000000000020
286 #define HCI_EVMSK_REMOTE_NAME_REQ_COMPL 0x0000000000000040
287 #define HCI_EVMSK_ENCRYPTION_CHANGE 0x0000000000000080
288 #define HCI_EVMSK_CHANGE_CON_LINK_KEY_COMPL 0x0000000000000100
289 #define HCI_EVMSK_MASTER_LINK_KEY_COMPL 0x0000000000000200
290 #define HCI_EVMSK_READ_REMOTE_FEATURES_COMPL 0x0000000000000400
291 #define HCI_EVMSK_READ_REMOTE_VER_INFO_COMPL 0x0000000000000800
292 #define HCI_EVMSK_QOS_SETUP_COMPL 0x0000000000001000
293 #define HCI_EVMSK_COMMAND_COMPL 0x0000000000002000
294 #define HCI_EVMSK_COMMAND_STATUS 0x0000000000004000
295 #define HCI_EVMSK_HARDWARE_ERROR 0x0000000000008000
296 #define HCI_EVMSK_FLUSH_OCCUR 0x0000000000010000
297 #define HCI_EVMSK_ROLE_CHANGE 0x0000000000020000
298 #define HCI_EVMSK_NUM_COMPL_PKTS 0x0000000000040000
299 #define HCI_EVMSK_MODE_CHANGE 0x0000000000080000
300 #define HCI_EVMSK_RETURN_LINK_KEYS 0x0000000000100000
301 #define HCI_EVMSK_PIN_CODE_REQ 0x0000000000200000
302 #define HCI_EVMSK_LINK_KEY_REQ 0x0000000000400000
303 #define HCI_EVMSK_LINK_KEY_NOTIFICATION 0x0000000000800000
304 #define HCI_EVMSK_LOOPBACK_COMMAND 0x0000000001000000
305 #define HCI_EVMSK_DATA_BUFFER_OVERFLOW 0x0000000002000000
306 #define HCI_EVMSK_MAX_SLOT_CHANGE 0x0000000004000000
307 #define HCI_EVMSK_READ_CLOCK_OFFSET_COMLETE 0x0000000008000000
308 #define HCI_EVMSK_CON_PKT_TYPE_CHANGED 0x0000000010000000
309 #define HCI_EVMSK_QOS_VIOLATION 0x0000000020000000
310 #define HCI_EVMSK_PAGE_SCAN_MODE_CHANGE 0x0000000040000000
311 #define HCI_EVMSK_PAGE_SCAN_REP_MODE_CHANGE 0x0000000080000000
312 /* 0x0000000100000000 - 0x8000000000000000 - reserved for future use */
313
314 /* Filter types */
315 #define HCI_FILTER_TYPE_NONE 0x00
316 #define HCI_FILTER_TYPE_INQUIRY_RESULT 0x01
317 #define HCI_FILTER_TYPE_CON_SETUP 0x02
318 /* 0x03 - 0xFF - reserved for future use */
319
320 /* Filter condition types for HCI_FILTER_TYPE_INQUIRY_RESULT */
321 #define HCI_FILTER_COND_INQUIRY_NEW_UNIT 0x00
322 #define HCI_FILTER_COND_INQUIRY_UNIT_CLASS 0x01
323 #define HCI_FILTER_COND_INQUIRY_BDADDR 0x02
324 /* 0x03 - 0xFF - reserved for future use */
325
326 /* Filter condition types for HCI_FILTER_TYPE_CON_SETUP */
327 #define HCI_FILTER_COND_CON_ANY_UNIT 0x00
328 #define HCI_FILTER_COND_CON_UNIT_CLASS 0x01
329 #define HCI_FILTER_COND_CON_BDADDR 0x02
330 /* 0x03 - 0xFF - reserved for future use */
331
332 /* Xmit level types */
333 #define HCI_XMIT_LEVEL_CURRENT 0x00
334 #define HCI_XMIT_LEVEL_MAXIMUM 0x01
335 /* 0x02 - 0xFF - reserved for future use */
336
337 /* Host Controller to Host flow control */
338 #define HCI_HC2H_FLOW_CONTROL_NONE 0x00
339 #define HCI_HC2H_FLOW_CONTROL_ACL 0x01
340 #define HCI_HC2H_FLOW_CONTROL_SCO 0x02
341 #define HCI_HC2H_FLOW_CONTROL_BOTH 0x03
342 /* 0x04 - 0xFF - reserved future use */
343
344 /* Loopback modes */
345 #define HCI_LOOPBACK_NONE 0x00
346 #define HCI_LOOPBACK_LOCAL 0x01
347 #define HCI_LOOPBACK_REMOTE 0x02
348 /* 0x03 - 0xFF - reserved future use */
349
350 /**************************************************************************
351 **************************************************************************
352 ** Link level defines, headers and types
353 **************************************************************************
354 **************************************************************************/
355
356 /*
357 * Macro(s) to combine OpCode and extract OGF (OpCode Group Field)
358 * and OCF (OpCode Command Field) from OpCode.
359 */
360
361 #define HCI_OPCODE(gf,cf) ((((gf) & 0x3f) << 10) | ((cf) & 0x3ff))
362 #define HCI_OCF(op) ((op) & 0x3ff)
363 #define HCI_OGF(op) (((op) >> 10) & 0x3f)
364
365 /*
366 * Macro(s) to extract/combine connection handle, BC (Broadcast) and
367 * PB (Packet boundary) flags.
368 */
369
370 #define HCI_CON_HANDLE(h) ((h) & 0x0fff)
371 #define HCI_PB_FLAG(h) (((h) & 0x3000) >> 12)
372 #define HCI_BC_FLAG(h) (((h) & 0xc000) >> 14)
373 #define HCI_MK_CON_HANDLE(h, pb, bc) \
374 (((h) & 0x0fff) | (((pb) & 3) << 12) | (((bc) & 3) << 14))
375
376 /* PB flag values */
377 /* 00 - reserved for future use */
378 #define HCI_PACKET_FRAGMENT 0x1
379 #define HCI_PACKET_START 0x2
380 /* 11 - reserved for future use */
381
382 /* BC flag values */
383 #define HCI_POINT2POINT 0x0 /* only Host controller to Host */
384 #define HCI_BROADCAST_ACTIVE 0x1 /* both directions */
385 #define HCI_BROADCAST_PICONET 0x2 /* both directions */
386 /* 11 - reserved for future use */
387
388 /* HCI command packet header */
389 typedef struct {
390 uint8_t type; /* MUST be 0x01 */
391 uint16_t opcode; /* OpCode */
392 uint8_t length; /* parameter(s) length in bytes */
393 } __attribute__ ((__packed__)) hci_cmd_hdr_t;
394
395 #define HCI_CMD_PKT 0x01
396 #define HCI_CMD_PKT_SIZE (sizeof(hci_cmd_hdr_t) + 0xff)
397
398 /* ACL data packet header */
399 typedef struct {
400 uint8_t type; /* MUST be 0x02 */
401 uint16_t con_handle; /* connection handle + PB + BC flags */
402 uint16_t length; /* payload length in bytes */
403 } __attribute__ ((__packed__)) hci_acldata_hdr_t;
404
405 #define HCI_ACL_DATA_PKT 0x02
406 #define HCI_ACL_PKT_SIZE (sizeof(hci_acldata_hdr_t) + 0xffff)
407
408 /* SCO data packet header */
409 typedef struct {
410 uint8_t type; /* MUST be 0x03 */
411 uint16_t con_handle; /* connection handle + reserved bits */
412 uint8_t length; /* payload length in bytes */
413 } __attribute__ ((__packed__)) hci_scodata_hdr_t;
414
415 #define HCI_SCO_DATA_PKT 0x03
416 #define HCI_SCO_PKT_SIZE (sizeof(hci_scodata_hdr_t) + 0xff)
417
418 /* HCI event packet header */
419 typedef struct {
420 uint8_t type; /* MUST be 0x04 */
421 uint8_t event; /* event */
422 uint8_t length; /* parameter(s) length in bytes */
423 } __attribute__ ((__packed__)) hci_event_hdr_t;
424
425 #define HCI_EVENT_PKT 0x04
426 #define HCI_EVENT_PKT_SIZE (sizeof(hci_event_hdr_t) + 0xff)
427
428 /* HCI status return parameter */
429 typedef struct {
430 uint8_t status; /* 0x00 - success */
431 } __attribute__ ((__packed__)) hci_status_rp;
432
433 /**************************************************************************
434 **************************************************************************
435 ** OGF 0x01 Link control commands and return parameters
436 **************************************************************************
437 **************************************************************************/
438
439 #define HCI_OGF_LINK_CONTROL 0x01
440
441 #define HCI_OCF_INQUIRY 0x0001
442 #define HCI_CMD_INQUIRY 0x0401
443 typedef struct {
444 uint8_t lap[HCI_LAP_SIZE]; /* LAP */
445 uint8_t inquiry_length; /* (N x 1.28) sec */
446 uint8_t num_responses; /* Max. # of responses */
447 } __attribute__ ((__packed__)) hci_inquiry_cp;
448 /* No return parameter(s) */
449
450 #define HCI_OCF_INQUIRY_CANCEL 0x0002
451 #define HCI_CMD_INQUIRY_CANCEL 0x0402
452 /* No command parameter(s) */
453 typedef hci_status_rp hci_inquiry_cancel_rp;
454
455 #define HCI_OCF_PERIODIC_INQUIRY 0x0003
456 #define HCI_CMD_PERIODIC_INQUIRY 0x0403
457 typedef struct {
458 uint16_t max_period_length; /* Max. and min. amount of time */
459 uint16_t min_period_length; /* between consecutive inquiries */
460 uint8_t lap[HCI_LAP_SIZE]; /* LAP */
461 uint8_t inquiry_length; /* (inquiry_length * 1.28) sec */
462 uint8_t num_responses; /* Max. # of responses */
463 } __attribute__ ((__packed__)) hci_periodic_inquiry_cp;
464
465 typedef hci_status_rp hci_periodic_inquiry_rp;
466
467 #define HCI_OCF_EXIT_PERIODIC_INQUIRY 0x0004
468 #define HCI_CMD_EXIT_PERIODIC_INQUIRY 0x0404
469 /* No command parameter(s) */
470 typedef hci_status_rp hci_exit_periodic_inquiry_rp;
471
472 #define HCI_OCF_CREATE_CON 0x0005
473 #define HCI_CMD_CREATE_CON 0x0405
474 typedef struct {
475 bdaddr_t bdaddr; /* destination address */
476 uint16_t pkt_type; /* packet type */
477 uint8_t page_scan_rep_mode; /* page scan repetition mode */
478 uint8_t page_scan_mode; /* reserved - set to 0x00 */
479 uint16_t clock_offset; /* clock offset */
480 uint8_t accept_role_switch; /* accept role switch? 0x00 == No */
481 } __attribute__ ((__packed__)) hci_create_con_cp;
482 /* No return parameter(s) */
483
484 #define HCI_OCF_DISCONNECT 0x0006
485 #define HCI_CMD_DISCONNECT 0x0406
486 typedef struct {
487 uint16_t con_handle; /* connection handle */
488 uint8_t reason; /* reason to disconnect */
489 } __attribute__ ((__packed__)) hci_discon_cp;
490 /* No return parameter(s) */
491
492 #define HCI_OCF_ADD_SCO_CON 0x0007
493 #define HCI_CMD_ADD_SCO_CON 0x0407
494 typedef struct {
495 uint16_t con_handle; /* connection handle */
496 uint16_t pkt_type; /* packet type */
497 } __attribute__ ((__packed__)) hci_add_sco_con_cp;
498 /* No return parameter(s) */
499
500 #define HCI_OCF_CREATE_CON_CANCEL 0x0008
501 #define HCI_CMD_CREATE_CON_CANCEL 0x0408
502 typedef struct {
503 bdaddr_t bdaddr; /* destination address */
504 } __attribute__ ((__packed__)) hci_create_con_cancel_cp;
505
506 typedef struct {
507 uint8_t status; /* 0x00 - success */
508 bdaddr_t bdaddr; /* destination address */
509 } __attribute__ ((__packed__)) hci_create_con_cancel_rp;
510
511 #define HCI_OCF_ACCEPT_CON 0x0009
512 #define HCI_CMD_ACCEPT_CON 0x0409
513 typedef struct {
514 bdaddr_t bdaddr; /* address of unit to be connected */
515 uint8_t role; /* connection role */
516 } __attribute__ ((__packed__)) hci_accept_con_cp;
517 /* No return parameter(s) */
518
519 #define HCI_OCF_REJECT_CON 0x000a
520 #define HCI_CMD_REJECT_CON 0x040A
521 typedef struct {
522 bdaddr_t bdaddr; /* remote address */
523 uint8_t reason; /* reason to reject */
524 } __attribute__ ((__packed__)) hci_reject_con_cp;
525 /* No return parameter(s) */
526
527 #define HCI_OCF_LINK_KEY_REP 0x000b
528 #define HCI_CMD_LINK_KEY_REP 0x040B
529 typedef struct {
530 bdaddr_t bdaddr; /* remote address */
531 uint8_t key[HCI_KEY_SIZE]; /* key */
532 } __attribute__ ((__packed__)) hci_link_key_rep_cp;
533
534 typedef struct {
535 uint8_t status; /* 0x00 - success */
536 bdaddr_t bdaddr; /* unit address */
537 } __attribute__ ((__packed__)) hci_link_key_rep_rp;
538
539 #define HCI_OCF_LINK_KEY_NEG_REP 0x000c
540 #define HCI_CMD_LINK_KEY_NEG_REP 0x040C
541 typedef struct {
542 bdaddr_t bdaddr; /* remote address */
543 } __attribute__ ((__packed__)) hci_link_key_neg_rep_cp;
544
545 typedef struct {
546 uint8_t status; /* 0x00 - success */
547 bdaddr_t bdaddr; /* unit address */
548 } __attribute__ ((__packed__)) hci_link_key_neg_rep_rp;
549
550 #define HCI_OCF_PIN_CODE_REP 0x000d
551 #define HCI_CMD_PIN_CODE_REP 0x040D
552 typedef struct {
553 bdaddr_t bdaddr; /* remote address */
554 uint8_t pin_size; /* pin code length (in bytes) */
555 uint8_t pin[HCI_PIN_SIZE]; /* pin code */
556 } __attribute__ ((__packed__)) hci_pin_code_rep_cp;
557
558 typedef struct {
559 uint8_t status; /* 0x00 - success */
560 bdaddr_t bdaddr; /* unit address */
561 } __attribute__ ((__packed__)) hci_pin_code_rep_rp;
562
563 #define HCI_OCF_PIN_CODE_NEG_REP 0x000e
564 #define HCI_CMD_PIN_CODE_NEG_REP 0x040E
565 typedef struct {
566 bdaddr_t bdaddr; /* remote address */
567 } __attribute__ ((__packed__)) hci_pin_code_neg_rep_cp;
568
569 typedef struct {
570 uint8_t status; /* 0x00 - success */
571 bdaddr_t bdaddr; /* unit address */
572 } __attribute__ ((__packed__)) hci_pin_code_neg_rep_rp;
573
574 #define HCI_OCF_CHANGE_CON_PACKET_TYPE 0x000f
575 #define HCI_CMD_CHANGE_CON_PACKET_TYPE 0x040F
576 typedef struct {
577 uint16_t con_handle; /* connection handle */
578 uint16_t pkt_type; /* packet type */
579 } __attribute__ ((__packed__)) hci_change_con_pkt_type_cp;
580 /* No return parameter(s) */
581
582 #define HCI_OCF_AUTH_REQ 0x0011
583 #define HCI_CMD_AUTH_REQ 0x0411
584 typedef struct {
585 uint16_t con_handle; /* connection handle */
586 } __attribute__ ((__packed__)) hci_auth_req_cp;
587 /* No return parameter(s) */
588
589 #define HCI_OCF_SET_CON_ENCRYPTION 0x0013
590 #define HCI_CMD_SET_CON_ENCRYPTION 0x0413
591 typedef struct {
592 uint16_t con_handle; /* connection handle */
593 uint8_t encryption_enable; /* 0x00 - disable, 0x01 - enable */
594 } __attribute__ ((__packed__)) hci_set_con_encryption_cp;
595 /* No return parameter(s) */
596
597 #define HCI_OCF_CHANGE_CON_LINK_KEY 0x0015
598 #define HCI_CMD_CHANGE_CON_LINK_KEY 0x0415
599 typedef struct {
600 uint16_t con_handle; /* connection handle */
601 } __attribute__ ((__packed__)) hci_change_con_link_key_cp;
602 /* No return parameter(s) */
603
604 #define HCI_OCF_MASTER_LINK_KEY 0x0017
605 #define HCI_CMD_MASTER_LINK_KEY 0x0417
606 typedef struct {
607 uint8_t key_flag; /* key flag */
608 } __attribute__ ((__packed__)) hci_master_link_key_cp;
609 /* No return parameter(s) */
610
611 #define HCI_OCF_REMOTE_NAME_REQ 0x0019
612 #define HCI_CMD_REMOTE_NAME_REQ 0x0419
613 typedef struct {
614 bdaddr_t bdaddr; /* remote address */
615 uint8_t page_scan_rep_mode; /* page scan repetition mode */
616 uint8_t page_scan_mode; /* page scan mode */
617 uint16_t clock_offset; /* clock offset */
618 } __attribute__ ((__packed__)) hci_remote_name_req_cp;
619 /* No return parameter(s) */
620
621 #define HCI_OCF_REMOTE_NAME_REQ_CANCEL 0x001a
622 #define HCI_CMD_REMOTE_NAME_REQ_CANCEL 0x041A
623 typedef struct {
624 bdaddr_t bdaddr; /* remote address */
625 } __attribute__ ((__packed__)) hci_remote_name_req_cancel_cp;
626
627 typedef struct {
628 uint8_t status; /* 0x00 - success */
629 bdaddr_t bdaddr; /* remote address */
630 } __attribute__ ((__packed__)) hci_remote_name_req_cancel_rp;
631
632 #define HCI_OCF_READ_REMOTE_FEATURES 0x001b
633 #define HCI_CMD_READ_REMOTE_FEATURES 0x041B
634 typedef struct {
635 uint16_t con_handle; /* connection handle */
636 } __attribute__ ((__packed__)) hci_read_remote_features_cp;
637 /* No return parameter(s) */
638
639 #define HCI_OCF_READ_REMOTE_EXTENDED_FEATURES 0x001c
640 #define HCI_CMD_READ_REMOTE_EXTENDED_FEATURES 0x041C
641 typedef struct {
642 uint16_t con_handle; /* connection handle */
643 uint8_t page; /* page number */
644 } __attribute__ ((__packed__)) hci_read_remote_extended_features_cp;
645 /* No return parameter(s) */
646
647 #define HCI_OCF_READ_REMOTE_VER_INFO 0x001d
648 #define HCI_CMD_READ_REMOTE_VER_INFO 0x041D
649 typedef struct {
650 uint16_t con_handle; /* connection handle */
651 } __attribute__ ((__packed__)) hci_read_remote_ver_info_cp;
652 /* No return parameter(s) */
653
654 #define HCI_OCF_READ_CLOCK_OFFSET 0x001f
655 #define HCI_CMD_READ_CLOCK_OFFSET 0x041F
656 typedef struct {
657 uint16_t con_handle; /* connection handle */
658 } __attribute__ ((__packed__)) hci_read_clock_offset_cp;
659 /* No return parameter(s) */
660
661 #define HCI_OCF_READ_LMP_HANDLE 0x0020
662 #define HCI_CMD_READ_LMP_HANDLE 0x0420
663 typedef struct {
664 uint16_t con_handle; /* connection handle */
665 } __attribute__ ((__packed__)) hci_read_lmp_handle_cp;
666
667 typedef struct {
668 uint8_t status; /* 0x00 - success */
669 uint16_t con_handle; /* connection handle */
670 uint8_t lmp_handle; /* LMP handle */
671 uint32_t reserved; /* reserved */
672 } __attribute__ ((__packed__)) hci_read_lmp_handle_rp;
673
674 #define HCI_OCF_SETUP_SCO_CON 0x0028
675 #define HCI_CMD_SETUP_SCO_CON 0x0428
676 typedef struct {
677 uint16_t con_handle; /* connection handle */
678 uint32_t tx_bandwidth; /* transmit bandwidth */
679 uint32_t rx_bandwidth; /* receive bandwidth */
680 uint16_t latency; /* maximum latency */
681 uint16_t voice; /* voice setting */
682 uint8_t rt_effort; /* retransmission effort */
683 uint16_t pkt_type; /* packet types */
684 } __attribute__ ((__packed__)) hci_setup_sco_con_cp;
685 /* No return parameter(s) */
686
687 #define HCI_OCF_ACCEPT_SCO_CON_REQ 0x0029
688 #define HCI_CMD_ACCEPT_SCO_CON_REQ 0x0429
689 typedef struct {
690 bdaddr_t bdaddr; /* remote address */
691 uint32_t tx_bandwidth; /* transmit bandwidth */
692 uint32_t rx_bandwidth; /* receive bandwidth */
693 uint16_t latency; /* maximum latency */
694 uint16_t content; /* voice setting */
695 uint8_t rt_effort; /* retransmission effort */
696 uint16_t pkt_type; /* packet types */
697 } __attribute__ ((__packed__)) hci_accept_sco_con_req_cp;
698 /* No return parameter(s) */
699
700 #define HCI_OCF_REJECT_SCO_CON_REQ 0x002a
701 #define HCI_CMD_REJECT_SCO_CON_REQ 0x042a
702 typedef struct {
703 bdaddr_t bdaddr; /* remote address */
704 uint8_t reason; /* reject error code */
705 } __attribute__ ((__packed__)) hci_reject_sco_con_req_cp;
706 /* No return parameter(s) */
707
708 /**************************************************************************
709 **************************************************************************
710 ** OGF 0x02 Link policy commands and return parameters
711 **************************************************************************
712 **************************************************************************/
713
714 #define HCI_OGF_LINK_POLICY 0x02
715
716 #define HCI_OCF_HOLD_MODE 0x0001
717 #define HCI_CMD_HOLD_MODE 0x0801
718 typedef struct {
719 uint16_t con_handle; /* connection handle */
720 uint16_t max_interval; /* (max_interval * 0.625) msec */
721 uint16_t min_interval; /* (max_interval * 0.625) msec */
722 } __attribute__ ((__packed__)) hci_hold_mode_cp;
723 /* No return parameter(s) */
724
725 #define HCI_OCF_SNIFF_MODE 0x0003
726 #define HCI_CMD_SNIFF_MODE 0x0803
727 typedef struct {
728 uint16_t con_handle; /* connection handle */
729 uint16_t max_interval; /* (max_interval * 0.625) msec */
730 uint16_t min_interval; /* (max_interval * 0.625) msec */
731 uint16_t attempt; /* (2 * attempt - 1) * 0.625 msec */
732 uint16_t timeout; /* (2 * attempt - 1) * 0.625 msec */
733 } __attribute__ ((__packed__)) hci_sniff_mode_cp;
734 /* No return parameter(s) */
735
736 #define HCI_OCF_EXIT_SNIFF_MODE 0x0004
737 #define HCI_CMD_EXIT_SNIFF_MODE 0x0804
738 typedef struct {
739 uint16_t con_handle; /* connection handle */
740 } __attribute__ ((__packed__)) hci_exit_sniff_mode_cp;
741 /* No return parameter(s) */
742
743 #define HCI_OCF_PARK_MODE 0x0005
744 #define HCI_CMD_PARK_MODE 0x0805
745 typedef struct {
746 uint16_t con_handle; /* connection handle */
747 uint16_t max_interval; /* (max_interval * 0.625) msec */
748 uint16_t min_interval; /* (max_interval * 0.625) msec */
749 } __attribute__ ((__packed__)) hci_park_mode_cp;
750 /* No return parameter(s) */
751
752 #define HCI_OCF_EXIT_PARK_MODE 0x0006
753 #define HCI_CMD_EXIT_PARK_MODE 0x0806
754 typedef struct {
755 uint16_t con_handle; /* connection handle */
756 } __attribute__ ((__packed__)) hci_exit_park_mode_cp;
757 /* No return parameter(s) */
758
759 #define HCI_OCF_QOS_SETUP 0x0007
760 #define HCI_CMD_QOS_SETUP 0x0807
761 typedef struct {
762 uint16_t con_handle; /* connection handle */
763 uint8_t flags; /* reserved for future use */
764 uint8_t service_type; /* service type */
765 uint32_t token_rate; /* bytes per second */
766 uint32_t peak_bandwidth; /* bytes per second */
767 uint32_t latency; /* microseconds */
768 uint32_t delay_variation; /* microseconds */
769 } __attribute__ ((__packed__)) hci_qos_setup_cp;
770 /* No return parameter(s) */
771
772 #define HCI_OCF_ROLE_DISCOVERY 0x0009
773 #define HCI_CMD_ROLE_DISCOVERY 0x0809
774 typedef struct {
775 uint16_t con_handle; /* connection handle */
776 } __attribute__ ((__packed__)) hci_role_discovery_cp;
777
778 typedef struct {
779 uint8_t status; /* 0x00 - success */
780 uint16_t con_handle; /* connection handle */
781 uint8_t role; /* role for the connection handle */
782 } __attribute__ ((__packed__)) hci_role_discovery_rp;
783
784 #define HCI_OCF_SWITCH_ROLE 0x000b
785 #define HCI_CMD_SWITCH_ROLE 0x080B
786 typedef struct {
787 bdaddr_t bdaddr; /* remote address */
788 uint8_t role; /* new local role */
789 } __attribute__ ((__packed__)) hci_switch_role_cp;
790 /* No return parameter(s) */
791
792 #define HCI_OCF_READ_LINK_POLICY_SETTINGS 0x000c
793 #define HCI_CMD_READ_LINK_POLICY_SETTINGS 0x080C
794 typedef struct {
795 uint16_t con_handle; /* connection handle */
796 } __attribute__ ((__packed__)) hci_read_link_policy_settings_cp;
797
798 typedef struct {
799 uint8_t status; /* 0x00 - success */
800 uint16_t con_handle; /* connection handle */
801 uint16_t settings; /* link policy settings */
802 } __attribute__ ((__packed__)) hci_read_link_policy_settings_rp;
803
804 #define HCI_OCF_WRITE_LINK_POLICY_SETTINGS 0x000d
805 #define HCI_CMD_WRITE_LINK_POLICY_SETTINGS 0x080D
806 typedef struct {
807 uint16_t con_handle; /* connection handle */
808 uint16_t settings; /* link policy settings */
809 } __attribute__ ((__packed__)) hci_write_link_policy_settings_cp;
810
811 typedef struct {
812 uint8_t status; /* 0x00 - success */
813 uint16_t con_handle; /* connection handle */
814 } __attribute__ ((__packed__)) hci_write_link_policy_settings_rp;
815
816 #define HCI_OCF_READ_DEFAULT_LINK_POLICY_SETTINGS 0x000e
817 #define HCI_CMD_READ_DEFAULT_LINK_POLICY_SETTINGS 0x080E
818 /* No command parameter(s) */
819 typedef struct {
820 uint8_t status; /* 0x00 - success */
821 uint16_t settings; /* link policy settings */
822 } __attribute__ ((__packed__)) hci_read_default_link_policy_settings_rp;
823
824 #define HCI_OCF_WRITE_DEFAULT_LINK_POLICY_SETTINGS 0x000f
825 #define HCI_CMD_WRITE_DEFAULT_LINK_POLICY_SETTINGS 0x080F
826 typedef struct {
827 uint16_t settings; /* link policy settings */
828 } __attribute__ ((__packed__)) hci_write_default_link_policy_settings_cp;
829
830 typedef hci_status_rp hci_write_default_link_policy_settings_rp;
831
832 #define HCI_OCF_FLOW_SPECIFICATION 0x0010
833 #define HCI_CMD_FLOW_SPECIFICATION 0x0810
834 typedef struct {
835 uint16_t con_handle; /* connection handle */
836 uint8_t flags; /* reserved */
837 uint8_t flow_direction;
838 uint8_t service_type;
839 uint32_t token_rate;
840 uint32_t token_bucket;
841 uint32_t peak_bandwidth;
842 uint32_t latency;
843 } __attribute__ ((__packed__)) hci_flow_specification_cp;
844 /* No return parameter(s) */
845
846 /**************************************************************************
847 **************************************************************************
848 ** OGF 0x03 Host Controller and Baseband commands and return parameters
849 **************************************************************************
850 **************************************************************************/
851
852 #define HCI_OGF_HC_BASEBAND 0x03
853
854 #define HCI_OCF_SET_EVENT_MASK 0x0001
855 #define HCI_CMD_SET_EVENT_MASK 0x0C01
856 typedef struct {
857 uint8_t event_mask[HCI_EVENT_MASK_SIZE]; /* event_mask */
858 } __attribute__ ((__packed__)) hci_set_event_mask_cp;
859
860 typedef hci_status_rp hci_set_event_mask_rp;
861
862 #define HCI_OCF_RESET 0x0003
863 #define HCI_CMD_RESET 0x0C03
864 /* No command parameter(s) */
865 typedef hci_status_rp hci_reset_rp;
866
867 #define HCI_OCF_SET_EVENT_FILTER 0x0005
868 #define HCI_CMD_SET_EVENT_FILTER 0x0C05
869 typedef struct {
870 uint8_t filter_type; /* filter type */
871 uint8_t filter_condition_type; /* filter condition type */
872 /* variable size condition
873 uint8_t condition[]; -- conditions */
874 } __attribute__ ((__packed__)) hci_set_event_filter_cp;
875
876 typedef hci_status_rp hci_set_event_filter_rp;
877
878 #define HCI_OCF_FLUSH 0x0008
879 #define HCI_CMD_FLUSH 0x0C08
880 typedef struct {
881 uint16_t con_handle; /* connection handle */
882 } __attribute__ ((__packed__)) hci_flush_cp;
883
884 typedef struct {
885 uint8_t status; /* 0x00 - success */
886 uint16_t con_handle; /* connection handle */
887 } __attribute__ ((__packed__)) hci_flush_rp;
888
889 #define HCI_OCF_READ_PIN_TYPE 0x0009
890 #define HCI_CMD_READ_PIN_TYPE 0x0C09
891 /* No command parameter(s) */
892 typedef struct {
893 uint8_t status; /* 0x00 - success */
894 uint8_t pin_type; /* PIN type */
895 } __attribute__ ((__packed__)) hci_read_pin_type_rp;
896
897 #define HCI_OCF_WRITE_PIN_TYPE 0x000a
898 #define HCI_CMD_WRITE_PIN_TYPE 0x0C0A
899 typedef struct {
900 uint8_t pin_type; /* PIN type */
901 } __attribute__ ((__packed__)) hci_write_pin_type_cp;
902
903 typedef hci_status_rp hci_write_pin_type_rp;
904
905 #define HCI_OCF_CREATE_NEW_UNIT_KEY 0x000b
906 #define HCI_CMD_CREATE_NEW_UNIT_KEY 0x0C0B
907 /* No command parameter(s) */
908 typedef hci_status_rp hci_create_new_unit_key_rp;
909
910 #define HCI_OCF_READ_STORED_LINK_KEY 0x000d
911 #define HCI_CMD_READ_STORED_LINK_KEY 0x0C0D
912 typedef struct {
913 bdaddr_t bdaddr; /* address */
914 uint8_t read_all; /* read all keys? 0x01 - yes */
915 } __attribute__ ((__packed__)) hci_read_stored_link_key_cp;
916
917 typedef struct {
918 uint8_t status; /* 0x00 - success */
919 uint16_t max_num_keys; /* Max. number of keys */
920 uint16_t num_keys_read; /* Number of stored keys */
921 } __attribute__ ((__packed__)) hci_read_stored_link_key_rp;
922
923 #define HCI_OCF_WRITE_STORED_LINK_KEY 0x0011
924 #define HCI_CMD_WRITE_STORED_LINK_KEY 0x0C11
925 typedef struct {
926 uint8_t num_keys_write; /* # of keys to write */
927 /* these are repeated "num_keys_write" times
928 bdaddr_t bdaddr; --- remote address(es)
929 uint8_t key[HCI_KEY_SIZE]; --- key(s) */
930 } __attribute__ ((__packed__)) hci_write_stored_link_key_cp;
931
932 typedef struct {
933 uint8_t status; /* 0x00 - success */
934 uint8_t num_keys_written; /* # of keys successfully written */
935 } __attribute__ ((__packed__)) hci_write_stored_link_key_rp;
936
937 #define HCI_OCF_DELETE_STORED_LINK_KEY 0x0012
938 #define HCI_CMD_DELETE_STORED_LINK_KEY 0x0C12
939 typedef struct {
940 bdaddr_t bdaddr; /* address */
941 uint8_t delete_all; /* delete all keys? 0x01 - yes */
942 } __attribute__ ((__packed__)) hci_delete_stored_link_key_cp;
943
944 typedef struct {
945 uint8_t status; /* 0x00 - success */
946 uint16_t num_keys_deleted; /* Number of keys deleted */
947 } __attribute__ ((__packed__)) hci_delete_stored_link_key_rp;
948
949 #define HCI_OCF_WRITE_LOCAL_NAME 0x0013
950 #define HCI_CMD_WRITE_LOCAL_NAME 0x0C13
951 typedef struct {
952 char name[HCI_UNIT_NAME_SIZE]; /* new unit name */
953 } __attribute__ ((__packed__)) hci_write_local_name_cp;
954
955 typedef hci_status_rp hci_write_local_name_rp;
956
957 #define HCI_OCF_READ_LOCAL_NAME 0x0014
958 #define HCI_CMD_READ_LOCAL_NAME 0x0C14
959 /* No command parameter(s) */
960 typedef struct {
961 uint8_t status; /* 0x00 - success */
962 char name[HCI_UNIT_NAME_SIZE]; /* unit name */
963 } __attribute__ ((__packed__)) hci_read_local_name_rp;
964
965 #define HCI_OCF_READ_CON_ACCEPT_TIMEOUT 0x0015
966 #define HCI_CMD_READ_CON_ACCEPT_TIMEOUT 0x0C15
967 /* No command parameter(s) */
968 typedef struct {
969 uint8_t status; /* 0x00 - success */
970 uint16_t timeout; /* (timeout * 0.625) msec */
971 } __attribute__ ((__packed__)) hci_read_con_accept_timeout_rp;
972
973 #define HCI_OCF_WRITE_CON_ACCEPT_TIMEOUT 0x0016
974 #define HCI_CMD_WRITE_CON_ACCEPT_TIMEOUT 0x0C16
975 typedef struct {
976 uint16_t timeout; /* (timeout * 0.625) msec */
977 } __attribute__ ((__packed__)) hci_write_con_accept_timeout_cp;
978
979 typedef hci_status_rp hci_write_con_accept_timeout_rp;
980
981 #define HCI_OCF_READ_PAGE_TIMEOUT 0x0017
982 #define HCI_CMD_READ_PAGE_TIMEOUT 0x0C17
983 /* No command parameter(s) */
984 typedef struct {
985 uint8_t status; /* 0x00 - success */
986 uint16_t timeout; /* (timeout * 0.625) msec */
987 } __attribute__ ((__packed__)) hci_read_page_timeout_rp;
988
989 #define HCI_OCF_WRITE_PAGE_TIMEOUT 0x0018
990 #define HCI_CMD_WRITE_PAGE_TIMEOUT 0x0C18
991 typedef struct {
992 uint16_t timeout; /* (timeout * 0.625) msec */
993 } __attribute__ ((__packed__)) hci_write_page_timeout_cp;
994
995 typedef hci_status_rp hci_write_page_timeout_rp;
996
997 #define HCI_OCF_READ_SCAN_ENABLE 0x0019
998 #define HCI_CMD_READ_SCAN_ENABLE 0x0C19
999 /* No command parameter(s) */
1000 typedef struct {
1001 uint8_t status; /* 0x00 - success */
1002 uint8_t scan_enable; /* Scan enable */
1003 } __attribute__ ((__packed__)) hci_read_scan_enable_rp;
1004
1005 #define HCI_OCF_WRITE_SCAN_ENABLE 0x001a
1006 #define HCI_CMD_WRITE_SCAN_ENABLE 0x0C1A
1007 typedef struct {
1008 uint8_t scan_enable; /* Scan enable */
1009 } __attribute__ ((__packed__)) hci_write_scan_enable_cp;
1010
1011 typedef hci_status_rp hci_write_scan_enable_rp;
1012
1013 #define HCI_OCF_READ_PAGE_SCAN_ACTIVITY 0x001b
1014 #define HCI_CMD_READ_PAGE_SCAN_ACTIVITY 0x0C1B
1015 /* No command parameter(s) */
1016 typedef struct {
1017 uint8_t status; /* 0x00 - success */
1018 uint16_t page_scan_interval; /* interval * 0.625 msec */
1019 uint16_t page_scan_window; /* window * 0.625 msec */
1020 } __attribute__ ((__packed__)) hci_read_page_scan_activity_rp;
1021
1022 #define HCI_OCF_WRITE_PAGE_SCAN_ACTIVITY 0x001c
1023 #define HCI_CMD_WRITE_PAGE_SCAN_ACTIVITY 0x0C1C
1024 typedef struct {
1025 uint16_t page_scan_interval; /* interval * 0.625 msec */
1026 uint16_t page_scan_window; /* window * 0.625 msec */
1027 } __attribute__ ((__packed__)) hci_write_page_scan_activity_cp;
1028
1029 typedef hci_status_rp hci_write_page_scan_activity_rp;
1030
1031 #define HCI_OCF_READ_INQUIRY_SCAN_ACTIVITY 0x001d
1032 #define HCI_CMD_READ_INQUIRY_SCAN_ACTIVITY 0x0C1D
1033 /* No command parameter(s) */
1034 typedef struct {
1035 uint8_t status; /* 0x00 - success */
1036 uint16_t inquiry_scan_interval; /* interval * 0.625 msec */
1037 uint16_t inquiry_scan_window; /* window * 0.625 msec */
1038 } __attribute__ ((__packed__)) hci_read_inquiry_scan_activity_rp;
1039
1040 #define HCI_OCF_WRITE_INQUIRY_SCAN_ACTIVITY 0x001e
1041 #define HCI_CMD_WRITE_INQUIRY_SCAN_ACTIVITY 0x0C1E
1042 typedef struct {
1043 uint16_t inquiry_scan_interval; /* interval * 0.625 msec */
1044 uint16_t inquiry_scan_window; /* window * 0.625 msec */
1045 } __attribute__ ((__packed__)) hci_write_inquiry_scan_activity_cp;
1046
1047 typedef hci_status_rp hci_write_inquiry_scan_activity_rp;
1048
1049 #define HCI_OCF_READ_AUTH_ENABLE 0x001f
1050 #define HCI_CMD_READ_AUTH_ENABLE 0x0C1F
1051 /* No command parameter(s) */
1052 typedef struct {
1053 uint8_t status; /* 0x00 - success */
1054 uint8_t auth_enable; /* 0x01 - enabled */
1055 } __attribute__ ((__packed__)) hci_read_auth_enable_rp;
1056
1057 #define HCI_OCF_WRITE_AUTH_ENABLE 0x0020
1058 #define HCI_CMD_WRITE_AUTH_ENABLE 0x0C20
1059 typedef struct {
1060 uint8_t auth_enable; /* 0x01 - enabled */
1061 } __attribute__ ((__packed__)) hci_write_auth_enable_cp;
1062
1063 typedef hci_status_rp hci_write_auth_enable_rp;
1064
1065 #define HCI_OCF_READ_ENCRYPTION_MODE 0x0021
1066 #define HCI_CMD_READ_ENCRYPTION_MODE 0x0C21
1067 /* No command parameter(s) */
1068 typedef struct {
1069 uint8_t status; /* 0x00 - success */
1070 uint8_t encryption_mode; /* encryption mode */
1071 } __attribute__ ((__packed__)) hci_read_encryption_mode_rp;
1072
1073 #define HCI_OCF_WRITE_ENCRYPTION_MODE 0x0022
1074 #define HCI_CMD_WRITE_ENCRYPTION_MODE 0x0C22
1075 typedef struct {
1076 uint8_t encryption_mode; /* encryption mode */
1077 } __attribute__ ((__packed__)) hci_write_encryption_mode_cp;
1078
1079 typedef hci_status_rp hci_write_encryption_mode_rp;
1080
1081 #define HCI_OCF_READ_UNIT_CLASS 0x0023
1082 #define HCI_CMD_READ_UNIT_CLASS 0x0C23
1083 /* No command parameter(s) */
1084 typedef struct {
1085 uint8_t status; /* 0x00 - success */
1086 uint8_t uclass[HCI_CLASS_SIZE]; /* unit class */
1087 } __attribute__ ((__packed__)) hci_read_unit_class_rp;
1088
1089 #define HCI_OCF_WRITE_UNIT_CLASS 0x0024
1090 #define HCI_CMD_WRITE_UNIT_CLASS 0x0C24
1091 typedef struct {
1092 uint8_t uclass[HCI_CLASS_SIZE]; /* unit class */
1093 } __attribute__ ((__packed__)) hci_write_unit_class_cp;
1094
1095 typedef hci_status_rp hci_write_unit_class_rp;
1096
1097 #define HCI_OCF_READ_VOICE_SETTING 0x0025
1098 #define HCI_CMD_READ_VOICE_SETTING 0x0C25
1099 /* No command parameter(s) */
1100 typedef struct {
1101 uint8_t status; /* 0x00 - success */
1102 uint16_t settings; /* voice settings */
1103 } __attribute__ ((__packed__)) hci_read_voice_setting_rp;
1104
1105 #define HCI_OCF_WRITE_VOICE_SETTING 0x0026
1106 #define HCI_CMD_WRITE_VOICE_SETTING 0x0C26
1107 typedef struct {
1108 uint16_t settings; /* voice settings */
1109 } __attribute__ ((__packed__)) hci_write_voice_setting_cp;
1110
1111 typedef hci_status_rp hci_write_voice_setting_rp;
1112
1113 #define HCI_OCF_READ_AUTO_FLUSH_TIMEOUT 0x0027
1114 #define HCI_CMD_READ_AUTO_FLUSH_TIMEOUT 0x0C27
1115 typedef struct {
1116 uint16_t con_handle; /* connection handle */
1117 } __attribute__ ((__packed__)) hci_read_auto_flush_timeout_cp;
1118
1119 typedef struct {
1120 uint8_t status; /* 0x00 - success */
1121 uint16_t con_handle; /* connection handle */
1122 uint16_t timeout; /* 0x00 - no flush, timeout * 0.625 msec */
1123 } __attribute__ ((__packed__)) hci_read_auto_flush_timeout_rp;
1124
1125 #define HCI_OCF_WRITE_AUTO_FLUSH_TIMEOUT 0x0028
1126 #define HCI_CMD_WRITE_AUTO_FLUSH_TIMEOUT 0x0C28
1127 typedef struct {
1128 uint16_t con_handle; /* connection handle */
1129 uint16_t timeout; /* 0x00 - no flush, timeout * 0.625 msec */
1130 } __attribute__ ((__packed__)) hci_write_auto_flush_timeout_cp;
1131
1132 typedef struct {
1133 uint8_t status; /* 0x00 - success */
1134 uint16_t con_handle; /* connection handle */
1135 } __attribute__ ((__packed__)) hci_write_auto_flush_timeout_rp;
1136
1137 #define HCI_OCF_READ_NUM_BROADCAST_RETRANS 0x0029
1138 #define HCI_CMD_READ_NUM_BROADCAST_RETRANS 0x0C29
1139 /* No command parameter(s) */
1140 typedef struct {
1141 uint8_t status; /* 0x00 - success */
1142 uint8_t counter; /* number of broadcast retransmissions */
1143 } __attribute__ ((__packed__)) hci_read_num_broadcast_retrans_rp;
1144
1145 #define HCI_OCF_WRITE_NUM_BROADCAST_RETRANS 0x002a
1146 #define HCI_CMD_WRITE_NUM_BROADCAST_RETRANS 0x0C2A
1147 typedef struct {
1148 uint8_t counter; /* number of broadcast retransmissions */
1149 } __attribute__ ((__packed__)) hci_write_num_broadcast_retrans_cp;
1150
1151 typedef hci_status_rp hci_write_num_broadcast_retrans_rp;
1152
1153 #define HCI_OCF_READ_HOLD_MODE_ACTIVITY 0x002b
1154 #define HCI_CMD_READ_HOLD_MODE_ACTIVITY 0x0C2B
1155 /* No command parameter(s) */
1156 typedef struct {
1157 uint8_t status; /* 0x00 - success */
1158 uint8_t hold_mode_activity; /* Hold mode activities */
1159 } __attribute__ ((__packed__)) hci_read_hold_mode_activity_rp;
1160
1161 #define HCI_OCF_WRITE_HOLD_MODE_ACTIVITY 0x002c
1162 #define HCI_CMD_WRITE_HOLD_MODE_ACTIVITY 0x0C2C
1163 typedef struct {
1164 uint8_t hold_mode_activity; /* Hold mode activities */
1165 } __attribute__ ((__packed__)) hci_write_hold_mode_activity_cp;
1166
1167 typedef hci_status_rp hci_write_hold_mode_activity_rp;
1168
1169 #define HCI_OCF_READ_XMIT_LEVEL 0x002d
1170 #define HCI_CMD_READ_XMIT_LEVEL 0x0C2D
1171 typedef struct {
1172 uint16_t con_handle; /* connection handle */
1173 uint8_t type; /* Xmit level type */
1174 } __attribute__ ((__packed__)) hci_read_xmit_level_cp;
1175
1176 typedef struct {
1177 uint8_t status; /* 0x00 - success */
1178 uint16_t con_handle; /* connection handle */
1179 char level; /* -30 <= level <= 30 dBm */
1180 } __attribute__ ((__packed__)) hci_read_xmit_level_rp;
1181
1182 #define HCI_OCF_READ_SCO_FLOW_CONTROL 0x002e
1183 #define HCI_CMD_READ_SCO_FLOW_CONTROL 0x0C2E
1184 /* No command parameter(s) */
1185 typedef struct {
1186 uint8_t status; /* 0x00 - success */
1187 uint8_t flow_control; /* 0x00 - disabled */
1188 } __attribute__ ((__packed__)) hci_read_sco_flow_control_rp;
1189
1190 #define HCI_OCF_WRITE_SCO_FLOW_CONTROL 0x002f
1191 #define HCI_CMD_WRITE_SCO_FLOW_CONTROL 0x0C2F
1192 typedef struct {
1193 uint8_t flow_control; /* 0x00 - disabled */
1194 } __attribute__ ((__packed__)) hci_write_sco_flow_control_cp;
1195
1196 typedef hci_status_rp hci_write_sco_flow_control_rp;
1197
1198 #define HCI_OCF_HC2H_FLOW_CONTROL 0x0031
1199 #define HCI_CMD_HC2H_FLOW_CONTROL 0x0C31
1200 typedef struct {
1201 uint8_t hc2h_flow; /* Host Controller to Host flow control */
1202 } __attribute__ ((__packed__)) hci_hc2h_flow_control_cp;
1203
1204 typedef hci_status_rp hci_h2hc_flow_control_rp;
1205
1206 #define HCI_OCF_HOST_BUFFER_SIZE 0x0033
1207 #define HCI_CMD_HOST_BUFFER_SIZE 0x0C33
1208 typedef struct {
1209 uint16_t max_acl_size; /* Max. size of ACL packet (bytes) */
1210 uint8_t max_sco_size; /* Max. size of SCO packet (bytes) */
1211 uint16_t num_acl_pkts; /* Max. number of ACL packets */
1212 uint16_t num_sco_pkts; /* Max. number of SCO packets */
1213 } __attribute__ ((__packed__)) hci_host_buffer_size_cp;
1214
1215 typedef hci_status_rp hci_host_buffer_size_rp;
1216
1217 #define HCI_OCF_HOST_NUM_COMPL_PKTS 0x0035
1218 #define HCI_CMD_HOST_NUM_COMPL_PKTS 0x0C35
1219 typedef struct {
1220 uint8_t nu_con_handles; /* # of connection handles */
1221 /* these are repeated "num_con_handles" times
1222 uint16_t con_handle; --- connection handle(s)
1223 uint16_t compl_pkts; --- # of completed packets */
1224 } __attribute__ ((__packed__)) hci_host_num_compl_pkts_cp;
1225 /* No return parameter(s) */
1226
1227 #define HCI_OCF_READ_LINK_SUPERVISION_TIMEOUT 0x0036
1228 #define HCI_CMD_READ_LINK_SUPERVISION_TIMEOUT 0x0C36
1229 typedef struct {
1230 uint16_t con_handle; /* connection handle */
1231 } __attribute__ ((__packed__)) hci_read_link_supervision_timeout_cp;
1232
1233 typedef struct {
1234 uint8_t status; /* 0x00 - success */
1235 uint16_t con_handle; /* connection handle */
1236 uint16_t timeout; /* Link supervision timeout * 0.625 msec */
1237 } __attribute__ ((__packed__)) hci_read_link_supervision_timeout_rp;
1238
1239 #define HCI_OCF_WRITE_LINK_SUPERVISION_TIMEOUT 0x0037
1240 #define HCI_CMD_WRITE_LINK_SUPERVISION_TIMEOUT 0x0C37
1241 typedef struct {
1242 uint16_t con_handle; /* connection handle */
1243 uint16_t timeout; /* Link supervision timeout * 0.625 msec */
1244 } __attribute__ ((__packed__)) hci_write_link_supervision_timeout_cp;
1245
1246 typedef struct {
1247 uint8_t status; /* 0x00 - success */
1248 uint16_t con_handle; /* connection handle */
1249 } __attribute__ ((__packed__)) hci_write_link_supervision_timeout_rp;
1250
1251 #define HCI_OCF_READ_NUM_SUPPORTED_IAC 0x0038
1252 #define HCI_CMD_READ_NUM_SUPPORTED_IAC 0x0C38
1253 /* No command parameter(s) */
1254 typedef struct {
1255 uint8_t status; /* 0x00 - success */
1256 uint8_t num_iac; /* # of supported IAC during scan */
1257 } __attribute__ ((__packed__)) hci_read_num_supported_iac_rp;
1258
1259 #define HCI_OCF_READ_IAC_LAP 0x0039
1260 #define HCI_CMD_READ_IAC_LAP 0x0C39
1261 /* No command parameter(s) */
1262 typedef struct {
1263 uint8_t status; /* 0x00 - success */
1264 uint8_t num_iac; /* # of IAC */
1265 /* these are repeated "num_iac" times
1266 uint8_t laps[HCI_LAP_SIZE]; --- LAPs */
1267 } __attribute__ ((__packed__)) hci_read_iac_lap_rp;
1268
1269 #define HCI_OCF_WRITE_IAC_LAP 0x003a
1270 #define HCI_CMD_WRITE_IAC_LAP 0x0C3A
1271 typedef struct {
1272 uint8_t num_iac; /* # of IAC */
1273 /* these are repeated "num_iac" times
1274 uint8_t laps[HCI_LAP_SIZE]; --- LAPs */
1275 } __attribute__ ((__packed__)) hci_write_iac_lap_cp;
1276
1277 typedef hci_status_rp hci_write_iac_lap_rp;
1278
1279 #define HCI_OCF_READ_PAGE_SCAN_PERIOD 0x003b
1280 #define HCI_CMD_READ_PAGE_SCAN_PERIOD 0x0C3B
1281 /* No command parameter(s) */
1282 typedef struct {
1283 uint8_t status; /* 0x00 - success */
1284 uint8_t page_scan_period_mode; /* Page scan period mode */
1285 } __attribute__ ((__packed__)) hci_read_page_scan_period_rp;
1286
1287 #define HCI_OCF_WRITE_PAGE_SCAN_PERIOD 0x003c
1288 #define HCI_CMD_WRITE_PAGE_SCAN_PERIOD 0x0C3C
1289 typedef struct {
1290 uint8_t page_scan_period_mode; /* Page scan period mode */
1291 } __attribute__ ((__packed__)) hci_write_page_scan_period_cp;
1292
1293 typedef hci_status_rp hci_write_page_scan_period_rp;
1294
1295 #define HCI_OCF_READ_PAGE_SCAN 0x003d
1296 #define HCI_CMD_READ_PAGE_SCAN 0x0C3D
1297 /* No command parameter(s) */
1298 typedef struct {
1299 uint8_t status; /* 0x00 - success */
1300 uint8_t page_scan_mode; /* Page scan mode */
1301 } __attribute__ ((__packed__)) hci_read_page_scan_rp;
1302
1303 #define HCI_OCF_WRITE_PAGE_SCAN 0x003e
1304 #define HCI_CMD_WRITE_PAGE_SCAN 0x0C3E
1305 typedef struct {
1306 uint8_t page_scan_mode; /* Page scan mode */
1307 } __attribute__ ((__packed__)) hci_write_page_scan_cp;
1308
1309 typedef hci_status_rp hci_write_page_scan_rp;
1310
1311 #define HCI_OCF_SET_AFH_CLASSIFICATION 0x003f
1312 #define HCI_CMD_SET_AFH_CLASSIFICATION 0x0C3F
1313 typedef struct {
1314 uint8_t classification[10];
1315 } __attribute__ ((__packed__)) hci_set_afh_classification_cp;
1316
1317 typedef hci_status_rp hci_set_afh_classification_rp;
1318
1319 #define HCI_OCF_READ_INQUIRY_SCAN_TYPE 0x0042
1320 #define HCI_CMD_READ_INQUIRY_SCAN_TYPE 0x0C42
1321 /* No command parameter(s) */
1322
1323 typedef struct {
1324 uint8_t status; /* 0x00 - success */
1325 uint8_t type; /* inquiry scan type */
1326 } __attribute__ ((__packed__)) hci_read_inquiry_scan_type_rp;
1327
1328 #define HCI_OCF_WRITE_INQUIRY_SCAN_TYPE 0x0043
1329 #define HCI_CMD_WRITE_INQUIRY_SCAN_TYPE 0x0C43
1330 typedef struct {
1331 uint8_t type; /* inquiry scan type */
1332 } __attribute__ ((__packed__)) hci_write_inquiry_scan_type_cp;
1333
1334 typedef hci_status_rp hci_write_inquiry_scan_type_rp;
1335
1336 #define HCI_OCF_READ_INQUIRY_MODE 0x0044
1337 #define HCI_CMD_READ_INQUIRY_MODE 0x0C44
1338 /* No command parameter(s) */
1339
1340 typedef struct {
1341 uint8_t status; /* 0x00 - success */
1342 uint8_t mode; /* inquiry mode */
1343 } __attribute__ ((__packed__)) hci_read_inquiry_mode_rp;
1344
1345 #define HCI_OCF_WRITE_INQUIRY_MODE 0x0045
1346 #define HCI_CMD_WRITE_INQUIRY_MODE 0x0C45
1347 typedef struct {
1348 uint8_t mode; /* inquiry mode */
1349 } __attribute__ ((__packed__)) hci_write_inquiry_mode_cp;
1350
1351 typedef hci_status_rp hci_write_inquiry_mode_rp;
1352
1353 #define HCI_OCF_READ_PAGE_SCAN_TYPE 0x0046
1354 #define HCI_CMD_READ_PAGE_SCAN_TYPE 0x0C46
1355 /* No command parameter(s) */
1356
1357 typedef struct {
1358 uint8_t status; /* 0x00 - success */
1359 uint8_t type; /* page scan type */
1360 } __attribute__ ((__packed__)) hci_read_page_scan_type_rp;
1361
1362 #define HCI_OCF_WRITE_PAGE_SCAN_TYPE 0x0047
1363 #define HCI_CMD_WRITE_PAGE_SCAN_TYPE 0x0C47
1364 typedef struct {
1365 uint8_t type; /* page scan type */
1366 } __attribute__ ((__packed__)) hci_write_page_scan_type_cp;
1367
1368 typedef hci_status_rp hci_write_page_scan_type_rp;
1369
1370 #define HCI_OCF_READ_AFH_ASSESSMENT 0x0048
1371 #define HCI_CMD_READ_AFH_ASSESSMENT 0x0C48
1372 /* No command parameter(s) */
1373
1374 typedef struct {
1375 uint8_t status; /* 0x00 - success */
1376 uint8_t mode; /* assessment mode */
1377 } __attribute__ ((__packed__)) hci_read_afh_assessment_rp;
1378
1379 #define HCI_OCF_WRITE_AFH_ASSESSMENT 0x0049
1380 #define HCI_CMD_WRITE_AFH_ASSESSMENT 0x0C49
1381 typedef struct {
1382 uint8_t mode; /* assessment mode */
1383 } __attribute__ ((__packed__)) hci_write_afh_assessment_cp;
1384
1385 typedef hci_status_rp hci_write_afh_assessment_rp;
1386
1387 /**************************************************************************
1388 **************************************************************************
1389 ** OGF 0x04 Informational commands and return parameters
1390 **************************************************************************
1391 **************************************************************************/
1392
1393 #define HCI_OGF_INFO 0x04
1394
1395 #define HCI_OCF_READ_LOCAL_VER 0x0001
1396 #define HCI_CMD_READ_LOCAL_VER 0x1001
1397 /* No command parameter(s) */
1398 typedef struct {
1399 uint8_t status; /* 0x00 - success */
1400 uint8_t hci_version; /* HCI version */
1401 uint16_t hci_revision; /* HCI revision */
1402 uint8_t lmp_version; /* LMP version */
1403 uint16_t manufacturer; /* Hardware manufacturer name */
1404 uint16_t lmp_subversion; /* LMP sub-version */
1405 } __attribute__ ((__packed__)) hci_read_local_ver_rp;
1406
1407 #define HCI_OCF_READ_LOCAL_COMMANDS 0x0002
1408 #define HCI_CMD_READ_LOCAL_COMMANDS 0x1002
1409 /* No command parameter(s) */
1410 typedef struct {
1411 uint8_t status; /* 0x00 - success */
1412 uint8_t commands[64]; /* opcode bitmask */
1413 } __attribute__ ((__packed__)) hci_read_local_commands_rp;
1414
1415 #define HCI_OCF_READ_LOCAL_FEATURES 0x0003
1416 #define HCI_CMD_READ_LOCAL_FEATURES 0x1003
1417 /* No command parameter(s) */
1418 typedef struct {
1419 uint8_t status; /* 0x00 - success */
1420 uint8_t features[HCI_FEATURES_SIZE]; /* LMP features bitmsk*/
1421 } __attribute__ ((__packed__)) hci_read_local_features_rp;
1422
1423 #define HCI_OCF_READ_LOCAL_EXTENDED_FEATURES 0x0004
1424 #define HCI_CMD_READ_LOCAL_EXTENDED_FEATURES 0x1004
1425 typedef struct {
1426 uint8_t page; /* page number */
1427 } __attribute__ ((__packed__)) hci_read_local_extended_features_cp;
1428
1429 typedef struct {
1430 uint8_t status; /* 0x00 - success */
1431 uint8_t page; /* page number */
1432 uint8_t max_page; /* maximum page number */
1433 uint8_t features[HCI_FEATURES_SIZE]; /* LMP features */
1434 } __attribute__ ((__packed__)) hci_read_local_extended_features_rp;
1435
1436 #define HCI_OCF_READ_BUFFER_SIZE 0x0005
1437 #define HCI_CMD_READ_BUFFER_SIZE 0x1005
1438 /* No command parameter(s) */
1439 typedef struct {
1440 uint8_t status; /* 0x00 - success */
1441 uint16_t max_acl_size; /* Max. size of ACL packet (bytes) */
1442 uint8_t max_sco_size; /* Max. size of SCO packet (bytes) */
1443 uint16_t num_acl_pkts; /* Max. number of ACL packets */
1444 uint16_t num_sco_pkts; /* Max. number of SCO packets */
1445 } __attribute__ ((__packed__)) hci_read_buffer_size_rp;
1446
1447 #define HCI_OCF_READ_COUNTRY_CODE 0x0007
1448 #define HCI_CMD_READ_COUNTRY_CODE 0x1007
1449 /* No command parameter(s) */
1450 typedef struct {
1451 uint8_t status; /* 0x00 - success */
1452 uint8_t country_code; /* 0x00 - NAM, EUR, JP; 0x01 - France */
1453 } __attribute__ ((__packed__)) hci_read_country_code_rp;
1454
1455 #define HCI_OCF_READ_BDADDR 0x0009
1456 #define HCI_CMD_READ_BDADDR 0x1009
1457 /* No command parameter(s) */
1458 typedef struct {
1459 uint8_t status; /* 0x00 - success */
1460 bdaddr_t bdaddr; /* unit address */
1461 } __attribute__ ((__packed__)) hci_read_bdaddr_rp;
1462
1463 /**************************************************************************
1464 **************************************************************************
1465 ** OGF 0x05 Status commands and return parameters
1466 **************************************************************************
1467 **************************************************************************/
1468
1469 #define HCI_OGF_STATUS 0x05
1470
1471 #define HCI_OCF_READ_FAILED_CONTACT_CNTR 0x0001
1472 #define HCI_CMD_READ_FAILED_CONTACT_CNTR 0x1401
1473 typedef struct {
1474 uint16_t con_handle; /* connection handle */
1475 } __attribute__ ((__packed__)) hci_read_failed_contact_cntr_cp;
1476
1477 typedef struct {
1478 uint8_t status; /* 0x00 - success */
1479 uint16_t con_handle; /* connection handle */
1480 uint16_t counter; /* number of consecutive failed contacts */
1481 } __attribute__ ((__packed__)) hci_read_failed_contact_cntr_rp;
1482
1483 #define HCI_OCF_RESET_FAILED_CONTACT_CNTR 0x0002
1484 #define HCI_CMD_RESET_FAILED_CONTACT_CNTR 0x1402
1485 typedef struct {
1486 uint16_t con_handle; /* connection handle */
1487 } __attribute__ ((__packed__)) hci_reset_failed_contact_cntr_cp;
1488
1489 typedef struct {
1490 uint8_t status; /* 0x00 - success */
1491 uint16_t con_handle; /* connection handle */
1492 } __attribute__ ((__packed__)) hci_reset_failed_contact_cntr_rp;
1493
1494 #define HCI_OCF_READ_LINK_QUALITY 0x0003
1495 #define HCI_CMD_READ_LINK_QUALITY 0x1403
1496 typedef struct {
1497 uint16_t con_handle; /* connection handle */
1498 } __attribute__ ((__packed__)) hci_read_link_quality_cp;
1499
1500 typedef struct {
1501 uint8_t status; /* 0x00 - success */
1502 uint16_t con_handle; /* connection handle */
1503 uint8_t quality; /* higher value means better quality */
1504 } __attribute__ ((__packed__)) hci_read_link_quality_rp;
1505
1506 #define HCI_OCF_READ_RSSI 0x0005
1507 #define HCI_CMD_READ_RSSI 0x1405
1508 typedef struct {
1509 uint16_t con_handle; /* connection handle */
1510 } __attribute__ ((__packed__)) hci_read_rssi_cp;
1511
1512 typedef struct {
1513 uint8_t status; /* 0x00 - success */
1514 uint16_t con_handle; /* connection handle */
1515 char rssi; /* -127 <= rssi <= 127 dB */
1516 } __attribute__ ((__packed__)) hci_read_rssi_rp;
1517
1518 #define HCI_OCF_READ_AFH_CHANNEL_MAP 0x0006
1519 #define HCI_CMD_READ_AFH_CHANNEL_MAP 0x1406
1520 typedef struct {
1521 uint16_t con_handle; /* connection handle */
1522 } __attribute__ ((__packed__)) hci_read_afh_channel_map_cp;
1523
1524 typedef struct {
1525 uint8_t status; /* 0x00 - success */
1526 uint16_t con_handle; /* connection handle */
1527 uint8_t mode; /* AFH mode */
1528 uint8_t map[10]; /* AFH Channel Map */
1529 } __attribute__ ((__packed__)) hci_read_afh_channel_map_rp;
1530
1531 #define HCI_OCF_READ_CLOCK 0x0007
1532 #define HCI_CMD_READ_CLOCK 0x1407
1533 typedef struct {
1534 uint16_t con_handle; /* connection handle */
1535 uint8_t clock; /* which clock */
1536 } __attribute__ ((__packed__)) hci_read_clock_cp;
1537
1538 typedef struct {
1539 uint8_t status; /* 0x00 - success */
1540 uint16_t con_handle; /* connection handle */
1541 uint32_t clock; /* clock value */
1542 uint16_t accuracy; /* clock accuracy */
1543 } __attribute__ ((__packed__)) hci_read_clock_rp;
1544
1545
1546 /**************************************************************************
1547 **************************************************************************
1548 ** OGF 0x06 Testing commands and return parameters
1549 **************************************************************************
1550 **************************************************************************/
1551
1552 #define HCI_OGF_TESTING 0x06
1553
1554 #define HCI_OCF_READ_LOOPBACK_MODE 0x0001
1555 #define HCI_CMD_READ_LOOPBACK_MODE 0x1801
1556 /* No command parameter(s) */
1557 typedef struct {
1558 uint8_t status; /* 0x00 - success */
1559 uint8_t lbmode; /* loopback mode */
1560 } __attribute__ ((__packed__)) hci_read_loopback_mode_rp;
1561
1562 #define HCI_OCF_WRITE_LOOPBACK_MODE 0x0002
1563 #define HCI_CMD_WRITE_LOOPBACK_MODE 0x1802
1564 typedef struct {
1565 uint8_t lbmode; /* loopback mode */
1566 } __attribute__ ((__packed__)) hci_write_loopback_mode_cp;
1567
1568 typedef hci_status_rp hci_write_loopback_mode_rp;
1569
1570 #define HCI_OCF_ENABLE_UNIT_UNDER_TEST 0x0003
1571 #define HCI_CMD_ENABLE_UNIT_UNDER_TEST 0x1803
1572 /* No command parameter(s) */
1573 typedef hci_status_rp hci_enable_unit_under_test_rp;
1574
1575 /**************************************************************************
1576 **************************************************************************
1577 ** OGF 0x3e Bluetooth Logo Testing
1578 ** OGF 0x3f Vendor Specific
1579 **************************************************************************
1580 **************************************************************************/
1581
1582 #define HCI_OGF_BT_LOGO 0x3e
1583 #define HCI_OGF_VENDOR 0x3f
1584
1585 /* Ericsson specific FC */
1586 #define HCI_CMD_ERICSSON_WRITE_PCM_SETTINGS 0xFC07
1587 #define HCI_CMD_ERICSSON_SET_SCO_DATA_PATH 0xFC1D
1588
1589
1590 /**************************************************************************
1591 **************************************************************************
1592 ** Events and event parameters
1593 **************************************************************************
1594 **************************************************************************/
1595
1596 #define HCI_EVENT_INQUIRY_COMPL 0x01
1597 typedef struct {
1598 uint8_t status; /* 0x00 - success */
1599 } __attribute__ ((__packed__)) hci_inquiry_compl_ep;
1600
1601 #define HCI_EVENT_INQUIRY_RESULT 0x02
1602 typedef struct {
1603 uint8_t num_responses; /* number of responses */
1604 /* hci_inquiry_response[num_responses] -- see below */
1605 } __attribute__ ((__packed__)) hci_inquiry_result_ep;
1606
1607 typedef struct {
1608 bdaddr_t bdaddr; /* unit address */
1609 uint8_t page_scan_rep_mode; /* page scan rep. mode */
1610 uint8_t page_scan_period_mode; /* page scan period mode */
1611 uint8_t page_scan_mode; /* page scan mode */
1612 uint8_t uclass[HCI_CLASS_SIZE]; /* unit class */
1613 uint16_t clock_offset; /* clock offset */
1614 } __attribute__ ((__packed__)) hci_inquiry_response;
1615
1616 #define HCI_EVENT_CON_COMPL 0x03
1617 typedef struct {
1618 uint8_t status; /* 0x00 - success */
1619 uint16_t con_handle; /* Connection handle */
1620 bdaddr_t bdaddr; /* remote unit address */
1621 uint8_t link_type; /* Link type */
1622 uint8_t encryption_mode; /* Encryption mode */
1623 } __attribute__ ((__packed__)) hci_con_compl_ep;
1624
1625 #define HCI_EVENT_CON_REQ 0x04
1626 typedef struct {
1627 bdaddr_t bdaddr; /* remote unit address */
1628 uint8_t uclass[HCI_CLASS_SIZE]; /* remote unit class */
1629 uint8_t link_type; /* link type */
1630 } __attribute__ ((__packed__)) hci_con_req_ep;
1631
1632 #define HCI_EVENT_DISCON_COMPL 0x05
1633 typedef struct {
1634 uint8_t status; /* 0x00 - success */
1635 uint16_t con_handle; /* connection handle */
1636 uint8_t reason; /* reason to disconnect */
1637 } __attribute__ ((__packed__)) hci_discon_compl_ep;
1638
1639 #define HCI_EVENT_AUTH_COMPL 0x06
1640 typedef struct {
1641 uint8_t status; /* 0x00 - success */
1642 uint16_t con_handle; /* connection handle */
1643 } __attribute__ ((__packed__)) hci_auth_compl_ep;
1644
1645 #define HCI_EVENT_REMOTE_NAME_REQ_COMPL 0x07
1646 typedef struct {
1647 uint8_t status; /* 0x00 - success */
1648 bdaddr_t bdaddr; /* remote unit address */
1649 char name[HCI_UNIT_NAME_SIZE]; /* remote unit name */
1650 } __attribute__ ((__packed__)) hci_remote_name_req_compl_ep;
1651
1652 #define HCI_EVENT_ENCRYPTION_CHANGE 0x08
1653 typedef struct {
1654 uint8_t status; /* 0x00 - success */
1655 uint16_t con_handle; /* Connection handle */
1656 uint8_t encryption_enable; /* 0x00 - disable */
1657 } __attribute__ ((__packed__)) hci_encryption_change_ep;
1658
1659 #define HCI_EVENT_CHANGE_CON_LINK_KEY_COMPL 0x09
1660 typedef struct {
1661 uint8_t status; /* 0x00 - success */
1662 uint16_t con_handle; /* Connection handle */
1663 } __attribute__ ((__packed__)) hci_change_con_link_key_compl_ep;
1664
1665 #define HCI_EVENT_MASTER_LINK_KEY_COMPL 0x0a
1666 typedef struct {
1667 uint8_t status; /* 0x00 - success */
1668 uint16_t con_handle; /* Connection handle */
1669 uint8_t key_flag; /* Key flag */
1670 } __attribute__ ((__packed__)) hci_master_link_key_compl_ep;
1671
1672 #define HCI_EVENT_READ_REMOTE_FEATURES_COMPL 0x0b
1673 typedef struct {
1674 uint8_t status; /* 0x00 - success */
1675 uint16_t con_handle; /* Connection handle */
1676 uint8_t features[HCI_FEATURES_SIZE]; /* LMP features bitmsk*/
1677 } __attribute__ ((__packed__)) hci_read_remote_features_compl_ep;
1678
1679 #define HCI_EVENT_READ_REMOTE_VER_INFO_COMPL 0x0c
1680 typedef struct {
1681 uint8_t status; /* 0x00 - success */
1682 uint16_t con_handle; /* Connection handle */
1683 uint8_t lmp_version; /* LMP version */
1684 uint16_t manufacturer; /* Hardware manufacturer name */
1685 uint16_t lmp_subversion; /* LMP sub-version */
1686 } __attribute__ ((__packed__)) hci_read_remote_ver_info_compl_ep;
1687
1688 #define HCI_EVENT_QOS_SETUP_COMPL 0x0d
1689 typedef struct {
1690 uint8_t status; /* 0x00 - success */
1691 uint16_t con_handle; /* connection handle */
1692 uint8_t flags; /* reserved for future use */
1693 uint8_t service_type; /* service type */
1694 uint32_t token_rate; /* bytes per second */
1695 uint32_t peak_bandwidth; /* bytes per second */
1696 uint32_t latency; /* microseconds */
1697 uint32_t delay_variation; /* microseconds */
1698 } __attribute__ ((__packed__)) hci_qos_setup_compl_ep;
1699
1700 #define HCI_EVENT_COMMAND_COMPL 0x0e
1701 typedef struct {
1702 uint8_t num_cmd_pkts; /* # of HCI command packets */
1703 uint16_t opcode; /* command OpCode */
1704 /* command return parameters (if any) */
1705 } __attribute__ ((__packed__)) hci_command_compl_ep;
1706
1707 #define HCI_EVENT_COMMAND_STATUS 0x0f
1708 typedef struct {
1709 uint8_t status; /* 0x00 - pending */
1710 uint8_t num_cmd_pkts; /* # of HCI command packets */
1711 uint16_t opcode; /* command OpCode */
1712 } __attribute__ ((__packed__)) hci_command_status_ep;
1713
1714 #define HCI_EVENT_HARDWARE_ERROR 0x10
1715 typedef struct {
1716 uint8_t hardware_code; /* hardware error code */
1717 } __attribute__ ((__packed__)) hci_hardware_error_ep;
1718
1719 #define HCI_EVENT_FLUSH_OCCUR 0x11
1720 typedef struct {
1721 uint16_t con_handle; /* connection handle */
1722 } __attribute__ ((__packed__)) hci_flush_occur_ep;
1723
1724 #define HCI_EVENT_ROLE_CHANGE 0x12
1725 typedef struct {
1726 uint8_t status; /* 0x00 - success */
1727 bdaddr_t bdaddr; /* address of remote unit */
1728 uint8_t role; /* new connection role */
1729 } __attribute__ ((__packed__)) hci_role_change_ep;
1730
1731 #define HCI_EVENT_NUM_COMPL_PKTS 0x13
1732 typedef struct {
1733 uint8_t num_con_handles; /* # of connection handles */
1734 /* these are repeated "num_con_handles" times
1735 uint16_t con_handle; --- connection handle(s)
1736 uint16_t compl_pkts; --- # of completed packets */
1737 } __attribute__ ((__packed__)) hci_num_compl_pkts_ep;
1738
1739 #define HCI_EVENT_MODE_CHANGE 0x14
1740 typedef struct {
1741 uint8_t status; /* 0x00 - success */
1742 uint16_t con_handle; /* connection handle */
1743 uint8_t unit_mode; /* remote unit mode */
1744 uint16_t interval; /* interval * 0.625 msec */
1745 } __attribute__ ((__packed__)) hci_mode_change_ep;
1746
1747 #define HCI_EVENT_RETURN_LINK_KEYS 0x15
1748 typedef struct {
1749 uint8_t num_keys; /* # of keys */
1750 /* these are repeated "num_keys" times
1751 bdaddr_t bdaddr; --- remote address(es)
1752 uint8_t key[HCI_KEY_SIZE]; --- key(s) */
1753 } __attribute__ ((__packed__)) hci_return_link_keys_ep;
1754
1755 #define HCI_EVENT_PIN_CODE_REQ 0x16
1756 typedef struct {
1757 bdaddr_t bdaddr; /* remote unit address */
1758 } __attribute__ ((__packed__)) hci_pin_code_req_ep;
1759
1760 #define HCI_EVENT_LINK_KEY_REQ 0x17
1761 typedef struct {
1762 bdaddr_t bdaddr; /* remote unit address */
1763 } __attribute__ ((__packed__)) hci_link_key_req_ep;
1764
1765 #define HCI_EVENT_LINK_KEY_NOTIFICATION 0x18
1766 typedef struct {
1767 bdaddr_t bdaddr; /* remote unit address */
1768 uint8_t key[HCI_KEY_SIZE]; /* link key */
1769 uint8_t key_type; /* type of the key */
1770 } __attribute__ ((__packed__)) hci_link_key_notification_ep;
1771
1772 #define HCI_EVENT_LOOPBACK_COMMAND 0x19
1773 typedef hci_cmd_hdr_t hci_loopback_command_ep;
1774
1775 #define HCI_EVENT_DATA_BUFFER_OVERFLOW 0x1a
1776 typedef struct {
1777 uint8_t link_type; /* Link type */
1778 } __attribute__ ((__packed__)) hci_data_buffer_overflow_ep;
1779
1780 #define HCI_EVENT_MAX_SLOT_CHANGE 0x1b
1781 typedef struct {
1782 uint16_t con_handle; /* connection handle */
1783 uint8_t lmp_max_slots; /* Max. # of slots allowed */
1784 } __attribute__ ((__packed__)) hci_max_slot_change_ep;
1785
1786 #define HCI_EVENT_READ_CLOCK_OFFSET_COMPL 0x1c
1787 typedef struct {
1788 uint8_t status; /* 0x00 - success */
1789 uint16_t con_handle; /* Connection handle */
1790 uint16_t clock_offset; /* Clock offset */
1791 } __attribute__ ((__packed__)) hci_read_clock_offset_compl_ep;
1792
1793 #define HCI_EVENT_CON_PKT_TYPE_CHANGED 0x1d
1794 typedef struct {
1795 uint8_t status; /* 0x00 - success */
1796 uint16_t con_handle; /* connection handle */
1797 uint16_t pkt_type; /* packet type */
1798 } __attribute__ ((__packed__)) hci_con_pkt_type_changed_ep;
1799
1800 #define HCI_EVENT_QOS_VIOLATION 0x1e
1801 typedef struct {
1802 uint16_t con_handle; /* connection handle */
1803 } __attribute__ ((__packed__)) hci_qos_violation_ep;
1804
1805 #define HCI_EVENT_PAGE_SCAN_MODE_CHANGE 0x1f
1806 typedef struct {
1807 bdaddr_t bdaddr; /* destination address */
1808 uint8_t page_scan_mode; /* page scan mode */
1809 } __attribute__ ((__packed__)) hci_page_scan_mode_change_ep;
1810
1811 #define HCI_EVENT_PAGE_SCAN_REP_MODE_CHANGE 0x20
1812 typedef struct {
1813 bdaddr_t bdaddr; /* destination address */
1814 uint8_t page_scan_rep_mode; /* page scan repetition mode */
1815 } __attribute__ ((__packed__)) hci_page_scan_rep_mode_change_ep;
1816
1817 #define HCI_EVENT_FLOW_SPECIFICATION_COMPL 0x21
1818 typedef struct {
1819 uint8_t status; /* 0x00 - success */
1820 uint16_t con_handle; /* connection handle */
1821 uint8_t flags; /* reserved */
1822 uint8_t direction; /* flow direction */
1823 uint8_t type; /* service type */
1824 uint32_t token_rate; /* token rate */
1825 uint32_t bucket_size; /* token bucket size */
1826 uint32_t peak_bandwidth; /* peak bandwidth */
1827 uint32_t latency; /* access latency */
1828 } __attribute__ ((__packed__)) hci_flow_specification_compl_ep;
1829
1830 #define HCI_EVENT_RSSI_RESULT 0x22
1831 typedef struct {
1832 uint8_t num_responses; /* number of responses */
1833 /* hci_rssi_response[num_responses] -- see below */
1834 } __attribute__ ((__packed__)) hci_rssi_result_ep;
1835
1836 typedef struct {
1837 bdaddr_t bdaddr; /* unit address */
1838 uint8_t page_scan_rep_mode; /* page scan rep. mode */
1839 uint8_t blank; /* reserved */
1840 uint8_t uclass[HCI_CLASS_SIZE]; /* unit class */
1841 uint16_t clock_offset; /* clock offset */
1842 int8_t rssi; /* rssi */
1843 } __attribute__ ((__packed__)) hci_rssi_response_ep;
1844
1845 #define HCI_EVENT_READ_REMOTE_EXTENDED_FEATURES 0x23
1846 typedef struct {
1847 uint8_t status; /* 0x00 - success */
1848 uint16_t con_handle; /* connection handle */
1849 uint8_t page; /* page number */
1850 uint8_t max; /* max page number */
1851 uint8_t features[HCI_FEATURES_SIZE]; /* LMP features bitmsk*/
1852 } __attribute__ ((__packed__)) hci_read_remote_extended_features_ep;
1853
1854 #define HCI_EVENT_SCO_CON_COMPL 0x2c
1855 typedef struct {
1856 uint8_t status; /* 0x00 - success */
1857 uint16_t con_handle; /* connection handle */
1858 bdaddr_t bdaddr; /* unit address */
1859 uint8_t link_type; /* link type */
1860 uint8_t interval; /* transmission interval */
1861 uint8_t window; /* retransmission window */
1862 uint16_t rxlen; /* rx packet length */
1863 uint16_t txlen; /* tx packet length */
1864 uint8_t mode; /* air mode */
1865 } __attribute__ ((__packed__)) hci_sco_con_compl_ep;
1866
1867 #define HCI_EVENT_SCO_CON_CHANGED 0x2d
1868 typedef struct {
1869 uint8_t status; /* 0x00 - success */
1870 uint16_t con_handle; /* connection handle */
1871 uint8_t interval; /* transmission interval */
1872 uint8_t window; /* retransmission window */
1873 uint16_t rxlen; /* rx packet length */
1874 uint16_t txlen; /* tx packet length */
1875 } __attribute__ ((__packed__)) hci_sco_con_changed_ep;
1876
1877 #define HCI_EVENT_BT_LOGO 0xfe
1878
1879 #define HCI_EVENT_VENDOR 0xff
1880
1881 /**************************************************************************
1882 **************************************************************************
1883 ** HCI Socket Definitions
1884 **************************************************************************
1885 **************************************************************************/
1886
1887 /* HCI socket options */
1888 #define SO_HCI_EVT_FILTER 1 /* get/set event filter */
1889 #define SO_HCI_PKT_FILTER 2 /* get/set packet filter */
1890 #define SO_HCI_DIRECTION 3 /* packet direction indicator */
1891
1892 /* Control Messages */
1893 #define SCM_HCI_DIRECTION SO_HCI_DIRECTION
1894
1895 /*
1896 * HCI socket filter and get/set routines
1897 *
1898 * for ease of use, we filter 256 possible events/packets
1899 */
1900 struct hci_filter {
1901 uint32_t mask[8]; /* 256 bits */
1902 };
1903
1904 static __inline void __unused
1905 hci_filter_set(uint8_t bit, struct hci_filter *filter)
1906 {
1907 uint8_t off = bit - 1;
1908
1909 off >>= 5;
1910 filter->mask[off] |= (1 << ((bit - 1) & 0x1f));
1911 }
1912
1913 static __inline void __unused
1914 hci_filter_clr(uint8_t bit, struct hci_filter *filter)
1915 {
1916 uint8_t off = bit - 1;
1917
1918 off >>= 5;
1919 filter->mask[off] &= ~(1 << ((bit - 1) & 0x1f));
1920 }
1921
1922 static __inline int __unused
1923 hci_filter_test(uint8_t bit, struct hci_filter *filter)
1924 {
1925 uint8_t off = bit - 1;
1926
1927 off >>= 5;
1928 return (filter->mask[off] & (1 << ((bit - 1) & 0x1f)));
1929 }
1930
1931 /*
1932 * HCI socket ioctl's
1933 *
1934 * Apart from GBTINFOA, these are all indexed on the unit name
1935 */
1936
1937 #define SIOCGBTINFO _IOWR('b', 5, struct btreq) /* get unit info */
1938 #define SIOCGBTINFOA _IOWR('b', 6, struct btreq) /* get info by address */
1939 #define SIOCNBTINFO _IOWR('b', 7, struct btreq) /* next unit info */
1940
1941 #define SIOCSBTFLAGS _IOWR('b', 8, struct btreq) /* set unit flags */
1942 #define SIOCSBTPOLICY _IOWR('b', 9, struct btreq) /* set unit link policy */
1943 #define SIOCSBTPTYPE _IOWR('b', 10, struct btreq) /* set unit packet type */
1944
1945 #define SIOCGBTSTATS _IOWR('b', 11, struct btreq) /* get unit statistics */
1946 #define SIOCZBTSTATS _IOWR('b', 12, struct btreq) /* zero unit statistics */
1947
1948 #define SIOCBTDUMP _IOW('b', 13, struct btreq) /* print debug info */
1949
1950 struct bt_stats {
1951 uint32_t err_tx;
1952 uint32_t err_rx;
1953 uint32_t cmd_tx;
1954 uint32_t evt_rx;
1955 uint32_t acl_tx;
1956 uint32_t acl_rx;
1957 uint32_t sco_tx;
1958 uint32_t sco_rx;
1959 uint32_t byte_tx;
1960 uint32_t byte_rx;
1961 };
1962
1963 struct btreq {
1964 char btr_name[HCI_DEVNAME_SIZE]; /* device name */
1965
1966 union {
1967 struct {
1968 bdaddr_t btri_bdaddr; /* device bdaddr */
1969 uint16_t btri_flags; /* flags */
1970 uint16_t btri_num_cmd; /* # of free cmd buffers */
1971 uint16_t btri_num_acl; /* # of free ACL buffers */
1972 uint16_t btri_num_sco; /* # of free SCO buffers */
1973 uint16_t btri_acl_mtu; /* ACL mtu */
1974 uint16_t btri_sco_mtu; /* SCO mtu */
1975 uint16_t btri_link_policy; /* Link Policy */
1976 uint16_t btri_packet_type; /* Packet Type */
1977 } btri;
1978 struct bt_stats btrs; /* unit stats */
1979 } btru;
1980 };
1981
1982 #define btr_flags btru.btri.btri_flags
1983 #define btr_bdaddr btru.btri.btri_bdaddr
1984 #define btr_num_cmd btru.btri.btri_num_cmd
1985 #define btr_num_acl btru.btri.btri_num_acl
1986 #define btr_num_sco btru.btri.btri_num_sco
1987 #define btr_acl_mtu btru.btri.btri_acl_mtu
1988 #define btr_sco_mtu btru.btri.btri_sco_mtu
1989 #define btr_link_policy btru.btri.btri_link_policy
1990 #define btr_packet_type btru.btri.btri_packet_type
1991 #define btr_uclass btru.btri.btri_uclass
1992 #define btr_stats btru.btrs
1993
1994 /* hci_unit & btr_flags */
1995 #define BTF_UP (1<<0) /* unit is up */
1996 #define BTF_RUNNING (1<<1) /* unit is running */
1997 #define BTF_XMIT_CMD (1<<2) /* unit is transmitting CMD packets */
1998 #define BTF_XMIT_ACL (1<<3) /* unit is transmitting ACL packets */
1999 #define BTF_XMIT_SCO (1<<4) /* unit is transmitting SCO packets */
2000 #define BTF_XMIT (BTF_XMIT_CMD | BTF_XMIT_ACL | BTF_XMIT_SCO)
2001 #define BTF_INIT_BDADDR (1<<5) /* waiting for bdaddr */
2002 #define BTF_INIT_BUFFER_SIZE (1<<6) /* waiting for buffer size */
2003 #define BTF_INIT_FEATURES (1<<7) /* waiting for features */
2004 #define BTF_INIT (BTF_INIT_BDADDR | BTF_INIT_BUFFER_SIZE | BTF_INIT_FEATURES)
2005
2006 /**************************************************************************
2007 **************************************************************************
2008 ** HCI Kernel Definitions
2009 **************************************************************************
2010 **************************************************************************/
2011
2012 #ifdef _KERNEL
2013
2014 struct l2cap_channel;
2015 struct mbuf;
2016 struct sco_pcb;
2017 struct socket;
2018
2019 /* global HCI kernel variables */
2020
2021 /* sysctl variables */
2022 extern int hci_memo_expiry;
2023 extern int hci_acl_expiry;
2024 extern int hci_sendspace, hci_recvspace;
2025 extern int hci_eventq_max, hci_aclrxq_max, hci_scorxq_max;
2026
2027 /*
2028 * HCI Connection Information
2029 */
2030 struct hci_link {
2031 struct hci_unit *hl_unit; /* our unit */
2032 TAILQ_ENTRY(hci_link) hl_next; /* next link on unit */
2033
2034 /* common info */
2035 uint16_t hl_state; /* connection state */
2036 bdaddr_t hl_bdaddr; /* dest address */
2037 uint16_t hl_handle; /* connection handle */
2038 uint8_t hl_type; /* link type */
2039
2040 /* ACL link info */
2041 uint8_t hl_lastid; /* last id used */
2042 uint16_t hl_refcnt; /* reference count */
2043 uint16_t hl_mtu; /* signalling mtu for link */
2044 uint16_t hl_flush; /* flush timeout */
2045
2046 TAILQ_HEAD(,l2cap_pdu) hl_txq; /* queue of outgoing PDUs */
2047 int hl_txqlen; /* number of fragments */
2048 struct mbuf *hl_rxp; /* incoming PDU (accumulating)*/
2049 struct callout hl_expire; /* connection expiry timer */
2050 TAILQ_HEAD(,l2cap_req) hl_reqs; /* pending requests */
2051
2052 /* SCO link info */
2053 struct hci_link *hl_link; /* SCO ACL link */
2054 struct sco_pcb *hl_sco; /* SCO pcb */
2055 MBUFQ_HEAD() hl_data; /* SCO outgoing data */
2056 };
2057
2058 /* hci_link state bits */
2059 #define HCI_LINK_CLOSED 0 /* closed */
2060 #define HCI_LINK_WAIT_CONNECT 1 /* waiting to connect */
2061 #define HCI_LINK_OPEN 2 /* ready and willing */
2062 #define HCI_LINK_BLOCK 3 /* open but blocking (see hci_acl_start) */
2063
2064 /*
2065 * Bluetooth Memo
2066 * cached device information for remote devices that this unit has seen
2067 */
2068 struct hci_memo {
2069 struct timeval time; /* time of last response */
2070 hci_inquiry_response response; /* inquiry response */
2071 LIST_ENTRY(hci_memo) next;
2072 };
2073
2074 /*
2075 * The Bluetooth HCI device unit structure
2076 */
2077 struct hci_unit {
2078 void *hci_softc; /* ptr to device softc */
2079
2080 /* device info */
2081 char *hci_devname; /* device name */
2082 bdaddr_t hci_bdaddr; /* device address */
2083 uint16_t hci_flags; /* see BTF_ above */
2084
2085 uint16_t hci_packet_type; /* packet types */
2086 uint16_t hci_acl_mask; /* ACL packet capabilities */
2087 uint16_t hci_sco_mask; /* SCO packet capabilities */
2088
2089 uint16_t hci_link_policy; /* link policy */
2090 uint16_t hci_lmp_mask; /* link policy capabilities */
2091
2092 /* flow control */
2093 uint16_t hci_max_acl_size; /* ACL payload mtu */
2094 uint16_t hci_num_acl_pkts; /* free ACL packet buffers */
2095 uint8_t hci_num_cmd_pkts; /* free CMD packet buffers */
2096 uint8_t hci_max_sco_size; /* SCO payload mtu */
2097 uint16_t hci_num_sco_pkts; /* free SCO packet buffers */
2098
2099 TAILQ_HEAD(,hci_link) hci_links; /* list of ACL/SCO links */
2100 LIST_HEAD(,hci_memo) hci_memos; /* cached memo list */
2101
2102 /*
2103 * h/w driver callbacks
2104 *
2105 * the device driver must supply these.
2106 */
2107 int (*hci_enable) /* enable device */
2108 (struct hci_unit *);
2109 void (*hci_disable) /* disable device */
2110 (struct hci_unit *);
2111 void (*hci_start_cmd) /* initiate cmd output routine */
2112 (struct hci_unit *);
2113 void (*hci_start_acl) /* initiate acl output routine */
2114 (struct hci_unit *);
2115 void (*hci_start_sco) /* initiate sco output routine */
2116 (struct hci_unit *);
2117 int hci_ipl; /* to block queue operations */
2118
2119 /* input queues */
2120 void *hci_rxint; /* receive interrupt cookie */
2121 MBUFQ_HEAD() hci_eventq; /* Event queue */
2122 MBUFQ_HEAD() hci_aclrxq; /* ACL rx queue */
2123 MBUFQ_HEAD() hci_scorxq; /* SCO rx queue */
2124 uint16_t hci_eventqlen; /* Event queue length */
2125 uint16_t hci_aclrxqlen; /* ACL rx queue length */
2126 uint16_t hci_scorxqlen; /* SCO rx queue length */
2127
2128 /* output queues */
2129 MBUFQ_HEAD() hci_cmdwait; /* pending commands */
2130 MBUFQ_HEAD() hci_cmdq; /* Command queue */
2131 MBUFQ_HEAD() hci_acltxq; /* ACL tx queue */
2132 MBUFQ_HEAD() hci_scotxq; /* SCO tx queue */
2133 MBUFQ_HEAD() hci_scodone; /* SCO done queue */
2134
2135 struct bt_stats hci_stats; /* unit statistics */
2136
2137 SIMPLEQ_ENTRY(hci_unit) hci_next;
2138 };
2139
2140 extern SIMPLEQ_HEAD(hci_unit_list, hci_unit) hci_unit_list;
2141
2142 /*
2143 * HCI layer function prototypes
2144 */
2145
2146 /* hci_event.c */
2147 void hci_event(struct mbuf *, struct hci_unit *);
2148
2149 /* hci_ioctl.c */
2150 int hci_ioctl(unsigned long, void *, struct lwp *);
2151
2152 /* hci_link.c */
2153 struct hci_link *hci_acl_open(struct hci_unit *, bdaddr_t *);
2154 struct hci_link *hci_acl_newconn(struct hci_unit *, bdaddr_t *);
2155 void hci_acl_close(struct hci_link *, int);
2156 void hci_acl_timeout(void *);
2157 void hci_acl_recv(struct mbuf *, struct hci_unit *);
2158 int hci_acl_send(struct mbuf *, struct hci_link *, struct l2cap_channel *);
2159 void hci_acl_start(struct hci_link *);
2160 void hci_acl_complete(struct hci_link *, int);
2161 struct hci_link *hci_sco_newconn(struct hci_unit *, bdaddr_t *);
2162 void hci_sco_recv(struct mbuf *, struct hci_unit *);
2163 void hci_sco_start(struct hci_link *);
2164 void hci_sco_complete(struct hci_link *, int);
2165 struct hci_link *hci_link_alloc(struct hci_unit *);
2166 void hci_link_free(struct hci_link *, int);
2167 struct hci_link *hci_link_lookup_bdaddr(struct hci_unit *, bdaddr_t *, uint16_t);
2168 struct hci_link *hci_link_lookup_handle(struct hci_unit *, uint16_t);
2169
2170 /* hci_misc.c */
2171 int hci_route_lookup(bdaddr_t *, bdaddr_t *);
2172 struct hci_memo *hci_memo_find(struct hci_unit *, bdaddr_t *);
2173 void hci_memo_free(struct hci_memo *);
2174
2175 /* hci_socket.c */
2176 void hci_drop(void *);
2177 int hci_usrreq(struct socket *, int, struct mbuf *, struct mbuf *, struct mbuf *, struct lwp *);
2178 int hci_ctloutput(int, struct socket *, int, int, struct mbuf **);
2179 void hci_drain(void);
2180 void hci_mtap(struct mbuf *, struct hci_unit *);
2181
2182 /* hci_unit.c */
2183 void hci_attach(struct hci_unit *);
2184 void hci_detach(struct hci_unit *);
2185 int hci_enable(struct hci_unit *);
2186 void hci_disable(struct hci_unit *);
2187 struct hci_unit *hci_unit_lookup(bdaddr_t *);
2188 int hci_send_cmd(struct hci_unit *, uint16_t, void *, uint8_t);
2189 void hci_input_event(struct hci_unit *, struct mbuf *);
2190 void hci_input_acl(struct hci_unit *, struct mbuf *);
2191 void hci_input_sco(struct hci_unit *, struct mbuf *);
2192 void hci_complete_sco(struct hci_unit *, struct mbuf *);
2193 void hci_output_cmd(struct hci_unit *, struct mbuf *);
2194 void hci_output_acl(struct hci_unit *, struct mbuf *);
2195 void hci_output_sco(struct hci_unit *, struct mbuf *);
2196
2197 #endif /* _KERNEL */
2198
2199 #endif /* _NETBT_HCI_H_ */
2200