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