• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *
3  *  BlueZ - Bluetooth protocol stack for Linux
4  *
5  *  Copyright (C) 2000-2001  Qualcomm Incorporated
6  *  Copyright (C) 2002-2003  Maxim Krasnyansky <maxk@qualcomm.com>
7  *  Copyright (C) 2002-2008  Marcel Holtmann <marcel@holtmann.org>
8  *
9  *
10  *  This program is free software; you can redistribute it and/or modify
11  *  it under the terms of the GNU General Public License as published by
12  *  the Free Software Foundation; either version 2 of the License, or
13  *  (at your option) any later version.
14  *
15  *  This program is distributed in the hope that it will be useful,
16  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  *  GNU General Public License for more details.
19  *
20  *  You should have received a copy of the GNU General Public License
21  *  along with this program; if not, write to the Free Software
22  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
23  *
24  */
25 
26 #ifndef __HCI_H
27 #define __HCI_H
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 #include <sys/socket.h>
34 
35 #define HCI_MAX_DEV	16
36 
37 #define HCI_MAX_ACL_SIZE	1024
38 #define HCI_MAX_SCO_SIZE	255
39 #define HCI_MAX_EVENT_SIZE	260
40 #define HCI_MAX_FRAME_SIZE	(HCI_MAX_ACL_SIZE + 4)
41 
42 /* HCI dev events */
43 #define HCI_DEV_REG	1
44 #define HCI_DEV_UNREG	2
45 #define HCI_DEV_UP	3
46 #define HCI_DEV_DOWN	4
47 #define HCI_DEV_SUSPEND	5
48 #define HCI_DEV_RESUME	6
49 
50 /* HCI device types */
51 #define HCI_VIRTUAL	0
52 #define HCI_USB		1
53 #define HCI_PCCARD	2
54 #define HCI_UART	3
55 #define HCI_RS232	4
56 #define HCI_PCI		5
57 #define HCI_SDIO	6
58 
59 /* HCI device flags */
60 enum {
61 	HCI_UP,
62 	HCI_INIT,
63 	HCI_RUNNING,
64 
65 	HCI_PSCAN,
66 	HCI_ISCAN,
67 	HCI_AUTH,
68 	HCI_ENCRYPT,
69 	HCI_INQUIRY,
70 
71 	HCI_RAW,
72 
73 	HCI_SECMGR
74 };
75 
76 /* HCI ioctl defines */
77 #define HCIDEVUP	_IOW('H', 201, int)
78 #define HCIDEVDOWN	_IOW('H', 202, int)
79 #define HCIDEVRESET	_IOW('H', 203, int)
80 #define HCIDEVRESTAT	_IOW('H', 204, int)
81 
82 #define HCIGETDEVLIST	_IOR('H', 210, int)
83 #define HCIGETDEVINFO	_IOR('H', 211, int)
84 #define HCIGETCONNLIST	_IOR('H', 212, int)
85 #define HCIGETCONNINFO	_IOR('H', 213, int)
86 #define HCIGETAUTHINFO	_IOR('H', 215, int)
87 
88 #define HCISETRAW	_IOW('H', 220, int)
89 #define HCISETSCAN	_IOW('H', 221, int)
90 #define HCISETAUTH	_IOW('H', 222, int)
91 #define HCISETENCRYPT	_IOW('H', 223, int)
92 #define HCISETPTYPE	_IOW('H', 224, int)
93 #define HCISETLINKPOL	_IOW('H', 225, int)
94 #define HCISETLINKMODE	_IOW('H', 226, int)
95 #define HCISETACLMTU	_IOW('H', 227, int)
96 #define HCISETSCOMTU	_IOW('H', 228, int)
97 
98 #define HCISETSECMGR	_IOW('H', 230, int)
99 
100 #define HCIINQUIRY	_IOR('H', 240, int)
101 
102 #ifndef __NO_HCI_DEFS
103 
104 /* HCI Packet types */
105 #define HCI_COMMAND_PKT		0x01
106 #define HCI_ACLDATA_PKT		0x02
107 #define HCI_SCODATA_PKT		0x03
108 #define HCI_EVENT_PKT		0x04
109 #define HCI_VENDOR_PKT		0xff
110 
111 /* HCI Packet types */
112 #define HCI_2DH1	0x0002
113 #define HCI_3DH1	0x0004
114 #define HCI_DM1		0x0008
115 #define HCI_DH1		0x0010
116 #define HCI_2DH3	0x0100
117 #define HCI_3DH3	0x0200
118 #define HCI_DM3		0x0400
119 #define HCI_DH3		0x0800
120 #define HCI_2DH5	0x1000
121 #define HCI_3DH5	0x2000
122 #define HCI_DM5		0x4000
123 #define HCI_DH5		0x8000
124 
125 #define HCI_HV1		0x0020
126 #define HCI_HV2		0x0040
127 #define HCI_HV3		0x0080
128 
129 #define HCI_EV3		0x0008
130 #define HCI_EV4		0x0010
131 #define HCI_EV5		0x0020
132 #define HCI_2EV3	0x0040
133 #define HCI_3EV3	0x0080
134 #define HCI_2EV5	0x0100
135 #define HCI_3EV5	0x0200
136 
137 #define SCO_PTYPE_MASK	(HCI_HV1 | HCI_HV2 | HCI_HV3)
138 #define ACL_PTYPE_MASK	(HCI_DM1 | HCI_DH1 | HCI_DM3 | HCI_DH3 | HCI_DM5 | HCI_DH5)
139 
140 /* HCI Error codes */
141 #define HCI_UNKNOWN_COMMAND			0x01
142 #define HCI_NO_CONNECTION			0x02
143 #define HCI_HARDWARE_FAILURE			0x03
144 #define HCI_PAGE_TIMEOUT			0x04
145 #define HCI_AUTHENTICATION_FAILURE		0x05
146 #define HCI_PIN_OR_KEY_MISSING			0x06
147 #define HCI_MEMORY_FULL				0x07
148 #define HCI_CONNECTION_TIMEOUT			0x08
149 #define HCI_MAX_NUMBER_OF_CONNECTIONS		0x09
150 #define HCI_MAX_NUMBER_OF_SCO_CONNECTIONS	0x0a
151 #define HCI_ACL_CONNECTION_EXISTS		0x0b
152 #define HCI_COMMAND_DISALLOWED			0x0c
153 #define HCI_REJECTED_LIMITED_RESOURCES		0x0d
154 #define HCI_REJECTED_SECURITY			0x0e
155 #define HCI_REJECTED_PERSONAL			0x0f
156 #define HCI_HOST_TIMEOUT			0x10
157 #define HCI_UNSUPPORTED_FEATURE			0x11
158 #define HCI_INVALID_PARAMETERS			0x12
159 #define HCI_OE_USER_ENDED_CONNECTION		0x13
160 #define HCI_OE_LOW_RESOURCES			0x14
161 #define HCI_OE_POWER_OFF			0x15
162 #define HCI_CONNECTION_TERMINATED		0x16
163 #define HCI_REPEATED_ATTEMPTS			0x17
164 #define HCI_PAIRING_NOT_ALLOWED			0x18
165 #define HCI_UNKNOWN_LMP_PDU			0x19
166 #define HCI_UNSUPPORTED_REMOTE_FEATURE		0x1a
167 #define HCI_SCO_OFFSET_REJECTED			0x1b
168 #define HCI_SCO_INTERVAL_REJECTED		0x1c
169 #define HCI_AIR_MODE_REJECTED			0x1d
170 #define HCI_INVALID_LMP_PARAMETERS		0x1e
171 #define HCI_UNSPECIFIED_ERROR			0x1f
172 #define HCI_UNSUPPORTED_LMP_PARAMETER_VALUE	0x20
173 #define HCI_ROLE_CHANGE_NOT_ALLOWED		0x21
174 #define HCI_LMP_RESPONSE_TIMEOUT		0x22
175 #define HCI_LMP_ERROR_TRANSACTION_COLLISION	0x23
176 #define HCI_LMP_PDU_NOT_ALLOWED			0x24
177 #define HCI_ENCRYPTION_MODE_NOT_ACCEPTED	0x25
178 #define HCI_UNIT_LINK_KEY_USED			0x26
179 #define HCI_QOS_NOT_SUPPORTED			0x27
180 #define HCI_INSTANT_PASSED			0x28
181 #define HCI_PAIRING_NOT_SUPPORTED		0x29
182 #define HCI_TRANSACTION_COLLISION		0x2a
183 #define HCI_QOS_UNACCEPTABLE_PARAMETER		0x2c
184 #define HCI_QOS_REJECTED			0x2d
185 #define HCI_CLASSIFICATION_NOT_SUPPORTED	0x2e
186 #define HCI_INSUFFICIENT_SECURITY		0x2f
187 #define HCI_PARAMETER_OUT_OF_RANGE		0x30
188 #define HCI_ROLE_SWITCH_PENDING			0x32
189 #define HCI_SLOT_VIOLATION			0x34
190 #define HCI_ROLE_SWITCH_FAILED			0x35
191 #define HCI_EIR_TOO_LARGE			0x36
192 #define HCI_SIMPLE_PAIRING_NOT_SUPPORTED	0x37
193 #define HCI_HOST_BUSY_PAIRING			0x38
194 
195 /* ACL flags */
196 #define ACL_CONT		0x01
197 #define ACL_START		0x02
198 #define ACL_ACTIVE_BCAST	0x04
199 #define ACL_PICO_BCAST		0x08
200 
201 /* Baseband links */
202 #define SCO_LINK	0x00
203 #define ACL_LINK	0x01
204 #define ESCO_LINK	0x02
205 
206 /* LMP features */
207 #define LMP_3SLOT	0x01
208 #define LMP_5SLOT	0x02
209 #define LMP_ENCRYPT	0x04
210 #define LMP_SOFFSET	0x08
211 #define LMP_TACCURACY	0x10
212 #define LMP_RSWITCH	0x20
213 #define LMP_HOLD	0x40
214 #define LMP_SNIFF	0x80
215 
216 #define LMP_PARK	0x01
217 #define LMP_RSSI	0x02
218 #define LMP_QUALITY	0x04
219 #define LMP_SCO		0x08
220 #define LMP_HV2		0x10
221 #define LMP_HV3		0x20
222 #define LMP_ULAW	0x40
223 #define LMP_ALAW	0x80
224 
225 #define LMP_CVSD	0x01
226 #define LMP_PSCHEME	0x02
227 #define LMP_PCONTROL	0x04
228 #define LMP_TRSP_SCO	0x08
229 #define LMP_BCAST_ENC	0x80
230 
231 #define LMP_EDR_ACL_2M	0x02
232 #define LMP_EDR_ACL_3M	0x04
233 #define LMP_ENH_ISCAN	0x08
234 #define LMP_ILACE_ISCAN	0x10
235 #define LMP_ILACE_PSCAN	0x20
236 #define LMP_RSSI_INQ	0x40
237 #define LMP_ESCO	0x80
238 
239 #define LMP_EV4		0x01
240 #define LMP_EV5		0x02
241 #define LMP_AFH_CAP_SLV	0x08
242 #define LMP_AFH_CLS_SLV	0x10
243 #define LMP_EDR_3SLOT	0x80
244 
245 #define LMP_EDR_5SLOT	0x01
246 #define LMP_SNIFF_SUBR	0x02
247 #define LMP_PAUSE_ENC	0x04
248 #define LMP_AFH_CAP_MST	0x08
249 #define LMP_AFH_CLS_MST	0x10
250 #define LMP_EDR_ESCO_2M	0x20
251 #define LMP_EDR_ESCO_3M	0x40
252 #define LMP_EDR_3S_ESCO	0x80
253 
254 #define LMP_EXT_INQ	0x01
255 #define LMP_SIMPLE_PAIR	0x08
256 #define LMP_ENCAPS_PDU	0x10
257 #define LMP_ERR_DAT_REP	0x20
258 #define LMP_NFLUSH_PKTS	0x40
259 
260 #define LMP_LSTO	0x01
261 #define LMP_INQ_TX_PWR	0x02
262 #define LMP_EXT_FEAT	0x80
263 
264 /* Link policies */
265 #define HCI_LP_RSWITCH	0x0001
266 #define HCI_LP_HOLD	0x0002
267 #define HCI_LP_SNIFF	0x0004
268 #define HCI_LP_PARK	0x0008
269 
270 /* Link mode */
271 #define HCI_LM_ACCEPT	0x8000
272 #define HCI_LM_MASTER	0x0001
273 #define HCI_LM_AUTH	0x0002
274 #define HCI_LM_ENCRYPT	0x0004
275 #define HCI_LM_TRUSTED	0x0008
276 #define HCI_LM_RELIABLE	0x0010
277 #define HCI_LM_SECURE	0x0020
278 
279 /* -----  HCI Commands ----- */
280 
281 /* Link Control */
282 #define OGF_LINK_CTL		0x01
283 
284 #define OCF_INQUIRY			0x0001
285 typedef struct {
286 	uint8_t		lap[3];
287 	uint8_t		length;		/* 1.28s units */
288 	uint8_t		num_rsp;
289 } __attribute__ ((packed)) inquiry_cp;
290 #define INQUIRY_CP_SIZE 5
291 
292 typedef struct {
293 	uint8_t		status;
294 	bdaddr_t	bdaddr;
295 } __attribute__ ((packed)) status_bdaddr_rp;
296 #define STATUS_BDADDR_RP_SIZE 7
297 
298 #define OCF_INQUIRY_CANCEL		0x0002
299 
300 #define OCF_PERIODIC_INQUIRY		0x0003
301 typedef struct {
302 	uint16_t	max_period;	/* 1.28s units */
303 	uint16_t	min_period;	/* 1.28s units */
304 	uint8_t		lap[3];
305 	uint8_t		length;		/* 1.28s units */
306 	uint8_t		num_rsp;
307 } __attribute__ ((packed)) periodic_inquiry_cp;
308 #define PERIODIC_INQUIRY_CP_SIZE 9
309 
310 #define OCF_EXIT_PERIODIC_INQUIRY	0x0004
311 
312 #define OCF_CREATE_CONN			0x0005
313 typedef struct {
314 	bdaddr_t	bdaddr;
315 	uint16_t	pkt_type;
316 	uint8_t		pscan_rep_mode;
317 	uint8_t		pscan_mode;
318 	uint16_t	clock_offset;
319 	uint8_t		role_switch;
320 } __attribute__ ((packed)) create_conn_cp;
321 #define CREATE_CONN_CP_SIZE 13
322 
323 #define OCF_DISCONNECT			0x0006
324 typedef struct {
325 	uint16_t	handle;
326 	uint8_t		reason;
327 } __attribute__ ((packed)) disconnect_cp;
328 #define DISCONNECT_CP_SIZE 3
329 
330 #define OCF_ADD_SCO			0x0007
331 typedef struct {
332 	uint16_t	handle;
333 	uint16_t	pkt_type;
334 } __attribute__ ((packed)) add_sco_cp;
335 #define ADD_SCO_CP_SIZE 4
336 
337 #define OCF_CREATE_CONN_CANCEL		0x0008
338 typedef struct {
339 	bdaddr_t	bdaddr;
340 } __attribute__ ((packed)) create_conn_cancel_cp;
341 #define CREATE_CONN_CANCEL_CP_SIZE 6
342 
343 #define OCF_ACCEPT_CONN_REQ		0x0009
344 typedef struct {
345 	bdaddr_t	bdaddr;
346 	uint8_t		role;
347 } __attribute__ ((packed)) accept_conn_req_cp;
348 #define ACCEPT_CONN_REQ_CP_SIZE	7
349 
350 #define OCF_REJECT_CONN_REQ		0x000A
351 typedef struct {
352 	bdaddr_t	bdaddr;
353 	uint8_t		reason;
354 } __attribute__ ((packed)) reject_conn_req_cp;
355 #define REJECT_CONN_REQ_CP_SIZE	7
356 
357 #define OCF_LINK_KEY_REPLY		0x000B
358 typedef struct {
359 	bdaddr_t	bdaddr;
360 	uint8_t		link_key[16];
361 } __attribute__ ((packed)) link_key_reply_cp;
362 #define LINK_KEY_REPLY_CP_SIZE 22
363 
364 #define OCF_LINK_KEY_NEG_REPLY		0x000C
365 
366 #define OCF_PIN_CODE_REPLY		0x000D
367 typedef struct {
368 	bdaddr_t	bdaddr;
369 	uint8_t		pin_len;
370 	uint8_t		pin_code[16];
371 } __attribute__ ((packed)) pin_code_reply_cp;
372 #define PIN_CODE_REPLY_CP_SIZE 23
373 
374 #define OCF_PIN_CODE_NEG_REPLY		0x000E
375 
376 #define OCF_SET_CONN_PTYPE		0x000F
377 typedef struct {
378 	uint16_t	 handle;
379 	uint16_t	 pkt_type;
380 } __attribute__ ((packed)) set_conn_ptype_cp;
381 #define SET_CONN_PTYPE_CP_SIZE 4
382 
383 #define OCF_AUTH_REQUESTED		0x0011
384 typedef struct {
385 	uint16_t	 handle;
386 } __attribute__ ((packed)) auth_requested_cp;
387 #define AUTH_REQUESTED_CP_SIZE 2
388 
389 #define OCF_SET_CONN_ENCRYPT		0x0013
390 typedef struct {
391 	uint16_t	handle;
392 	uint8_t		encrypt;
393 } __attribute__ ((packed)) set_conn_encrypt_cp;
394 #define SET_CONN_ENCRYPT_CP_SIZE 3
395 
396 #define OCF_CHANGE_CONN_LINK_KEY	0x0015
397 typedef struct {
398 	uint16_t	handle;
399 } __attribute__ ((packed)) change_conn_link_key_cp;
400 #define CHANGE_CONN_LINK_KEY_CP_SIZE 2
401 
402 #define OCF_MASTER_LINK_KEY		0x0017
403 typedef struct {
404 	uint8_t		key_flag;
405 } __attribute__ ((packed)) master_link_key_cp;
406 #define MASTER_LINK_KEY_CP_SIZE 1
407 
408 #define OCF_REMOTE_NAME_REQ		0x0019
409 typedef struct {
410 	bdaddr_t	bdaddr;
411 	uint8_t		pscan_rep_mode;
412 	uint8_t		pscan_mode;
413 	uint16_t	clock_offset;
414 } __attribute__ ((packed)) remote_name_req_cp;
415 #define REMOTE_NAME_REQ_CP_SIZE 10
416 
417 #define OCF_REMOTE_NAME_REQ_CANCEL	0x001A
418 typedef struct {
419 	bdaddr_t	bdaddr;
420 } __attribute__ ((packed)) remote_name_req_cancel_cp;
421 #define REMOTE_NAME_REQ_CANCEL_CP_SIZE 6
422 
423 #define OCF_READ_REMOTE_FEATURES	0x001B
424 typedef struct {
425 	uint16_t	handle;
426 } __attribute__ ((packed)) read_remote_features_cp;
427 #define READ_REMOTE_FEATURES_CP_SIZE 2
428 
429 #define OCF_READ_REMOTE_EXT_FEATURES	0x001C
430 typedef struct {
431 	uint16_t	handle;
432 	uint8_t		page_num;
433 } __attribute__ ((packed)) read_remote_ext_features_cp;
434 #define READ_REMOTE_EXT_FEATURES_CP_SIZE 3
435 
436 #define OCF_READ_REMOTE_VERSION		0x001D
437 typedef struct {
438 	uint16_t	handle;
439 } __attribute__ ((packed)) read_remote_version_cp;
440 #define READ_REMOTE_VERSION_CP_SIZE 2
441 
442 #define OCF_READ_CLOCK_OFFSET		0x001F
443 typedef struct {
444 	uint16_t	handle;
445 } __attribute__ ((packed)) read_clock_offset_cp;
446 #define READ_CLOCK_OFFSET_CP_SIZE 2
447 
448 #define OCF_READ_LMP_HANDLE		0x0020
449 
450 #define OCF_SETUP_SYNC_CONN		0x0028
451 typedef struct {
452 	uint16_t	handle;
453 	uint32_t	tx_bandwith;
454 	uint32_t	rx_bandwith;
455 	uint16_t	max_latency;
456 	uint16_t	voice_setting;
457 	uint8_t		retrans_effort;
458 	uint16_t	pkt_type;
459 } __attribute__ ((packed)) setup_sync_conn_cp;
460 #define SETUP_SYNC_CONN_CP_SIZE 17
461 
462 #define OCF_ACCEPT_SYNC_CONN_REQ	0x0029
463 typedef struct {
464 	bdaddr_t	bdaddr;
465 	uint32_t	tx_bandwith;
466 	uint32_t	rx_bandwith;
467 	uint16_t	max_latency;
468 	uint16_t	voice_setting;
469 	uint8_t		retrans_effort;
470 	uint16_t	pkt_type;
471 } __attribute__ ((packed)) accept_sync_conn_req_cp;
472 #define ACCEPT_SYNC_CONN_REQ_CP_SIZE 21
473 
474 #define OCF_REJECT_SYNC_CONN_REQ	0x002A
475 typedef struct {
476 	bdaddr_t	bdaddr;
477 	uint8_t		reason;
478 } __attribute__ ((packed)) reject_sync_conn_req_cp;
479 #define REJECT_SYNC_CONN_REQ_CP_SIZE 7
480 
481 #define OCF_IO_CAPABILITY_REPLY		0x002B
482 typedef struct {
483 	bdaddr_t	bdaddr;
484 	uint8_t		capability;
485 	uint8_t		oob_data;
486 	uint8_t		authentication;
487 } __attribute__ ((packed)) io_capability_reply_cp;
488 #define IO_CAPABILITY_REPLY_CP_SIZE 9
489 
490 #define OCF_USER_CONFIRM_REPLY		0x002C
491 typedef struct {
492 	bdaddr_t	bdaddr;
493 } __attribute__ ((packed)) user_confirm_reply_cp;
494 #define USER_CONFIRM_REPLY_CP_SIZE 6
495 
496 #define OCF_USER_CONFIRM_NEG_REPLY	0x002D
497 
498 #define OCF_USER_PASSKEY_REPLY		0x002E
499 typedef struct {
500 	bdaddr_t	bdaddr;
501 	uint32_t	passkey;
502 } __attribute__ ((packed)) user_passkey_reply_cp;
503 #define USER_PASSKEY_REPLY_CP_SIZE 10
504 
505 #define OCF_USER_PASSKEY_NEG_REPLY	0x002F
506 
507 #define OCF_REMOTE_OOB_DATA_REPLY	0x0030
508 typedef struct {
509 	bdaddr_t	bdaddr;
510 	uint8_t		hash[16];
511 	uint8_t		randomizer[16];
512 } __attribute__ ((packed)) remote_oob_data_reply_cp;
513 #define REMOTE_OOB_DATA_REPLY_CP_SIZE 38
514 
515 #define OCF_REMOTE_OOB_DATA_NEG_REPLY	0x0033
516 
517 #define OCF_IO_CAPABILITY_NEG_REPLY	0x0034
518 typedef struct {
519 	bdaddr_t	bdaddr;
520 	uint8_t		reason;
521 } __attribute__ ((packed)) io_capability_neg_reply_cp;
522 #define IO_CAPABILITY_NEG_REPLY_CP_SIZE 7
523 
524 /* Link Policy */
525 #define OGF_LINK_POLICY		0x02
526 
527 #define OCF_HOLD_MODE			0x0001
528 typedef struct {
529 	uint16_t	handle;
530 	uint16_t	max_interval;
531 	uint16_t	min_interval;
532 } __attribute__ ((packed)) hold_mode_cp;
533 #define HOLD_MODE_CP_SIZE 6
534 
535 #define OCF_SNIFF_MODE			0x0003
536 typedef struct {
537 	uint16_t	handle;
538 	uint16_t	max_interval;
539 	uint16_t	min_interval;
540 	uint16_t	attempt;
541 	uint16_t	timeout;
542 } __attribute__ ((packed)) sniff_mode_cp;
543 #define SNIFF_MODE_CP_SIZE 10
544 
545 #define OCF_EXIT_SNIFF_MODE		0x0004
546 typedef struct {
547 	uint16_t	handle;
548 } __attribute__ ((packed)) exit_sniff_mode_cp;
549 #define EXIT_SNIFF_MODE_CP_SIZE 2
550 
551 #define OCF_PARK_MODE			0x0005
552 typedef struct {
553 	uint16_t	handle;
554 	uint16_t	max_interval;
555 	uint16_t	min_interval;
556 } __attribute__ ((packed)) park_mode_cp;
557 #define PARK_MODE_CP_SIZE 6
558 
559 #define OCF_EXIT_PARK_MODE		0x0006
560 typedef struct {
561 	uint16_t	handle;
562 } __attribute__ ((packed)) exit_park_mode_cp;
563 #define EXIT_PARK_MODE_CP_SIZE 2
564 
565 #define OCF_QOS_SETUP			0x0007
566 typedef struct {
567 	uint8_t		service_type;		/* 1 = best effort */
568 	uint32_t	token_rate;		/* Byte per seconds */
569 	uint32_t	peak_bandwidth;		/* Byte per seconds */
570 	uint32_t	latency;		/* Microseconds */
571 	uint32_t	delay_variation;	/* Microseconds */
572 } __attribute__ ((packed)) hci_qos;
573 #define HCI_QOS_CP_SIZE 17
574 typedef struct {
575 	uint16_t 	handle;
576 	uint8_t 	flags;			/* Reserved */
577 	hci_qos 	qos;
578 } __attribute__ ((packed)) qos_setup_cp;
579 #define QOS_SETUP_CP_SIZE (3 + HCI_QOS_CP_SIZE)
580 
581 #define OCF_ROLE_DISCOVERY		0x0009
582 typedef struct {
583 	uint16_t	handle;
584 } __attribute__ ((packed)) role_discovery_cp;
585 #define ROLE_DISCOVERY_CP_SIZE 2
586 typedef struct {
587 	uint8_t		status;
588 	uint16_t	handle;
589 	uint8_t		role;
590 } __attribute__ ((packed)) role_discovery_rp;
591 #define ROLE_DISCOVERY_RP_SIZE 4
592 
593 #define OCF_SWITCH_ROLE			0x000B
594 typedef struct {
595 	bdaddr_t	bdaddr;
596 	uint8_t		role;
597 } __attribute__ ((packed)) switch_role_cp;
598 #define SWITCH_ROLE_CP_SIZE 7
599 
600 #define OCF_READ_LINK_POLICY		0x000C
601 typedef struct {
602 	uint16_t	handle;
603 } __attribute__ ((packed)) read_link_policy_cp;
604 #define READ_LINK_POLICY_CP_SIZE 2
605 typedef struct {
606 	uint8_t 	status;
607 	uint16_t	handle;
608 	uint16_t	policy;
609 } __attribute__ ((packed)) read_link_policy_rp;
610 #define READ_LINK_POLICY_RP_SIZE 5
611 
612 #define OCF_WRITE_LINK_POLICY		0x000D
613 typedef struct {
614 	uint16_t	handle;
615 	uint16_t	policy;
616 } __attribute__ ((packed)) write_link_policy_cp;
617 #define WRITE_LINK_POLICY_CP_SIZE 4
618 typedef struct {
619 	uint8_t 	status;
620 	uint16_t	handle;
621 } __attribute__ ((packed)) write_link_policy_rp;
622 #define WRITE_LINK_POLICY_RP_SIZE 3
623 
624 #define OCF_READ_DEFAULT_LINK_POLICY	0x000E
625 
626 #define OCF_WRITE_DEFAULT_LINK_POLICY	0x000F
627 
628 #define OCF_FLOW_SPECIFICATION		0x0010
629 
630 #define OCF_SNIFF_SUBRATING		0x0011
631 typedef struct {
632 	uint16_t	handle;
633 	uint16_t	max_latency;
634 	uint16_t	min_remote_timeout;
635 	uint16_t	min_local_timeout;
636 } __attribute__ ((packed)) sniff_subrating_cp;
637 #define SNIFF_SUBRATING_CP_SIZE 8
638 
639 /* Host Controller and Baseband */
640 #define OGF_HOST_CTL		0x03
641 
642 #define OCF_SET_EVENT_MASK		0x0001
643 typedef struct {
644 	uint8_t		mask[8];
645 } __attribute__ ((packed)) set_event_mask_cp;
646 #define SET_EVENT_MASK_CP_SIZE 8
647 
648 #define OCF_RESET			0x0003
649 
650 #define OCF_SET_EVENT_FLT		0x0005
651 typedef struct {
652 	uint8_t		flt_type;
653 	uint8_t		cond_type;
654 	uint8_t		condition[0];
655 } __attribute__ ((packed)) set_event_flt_cp;
656 #define SET_EVENT_FLT_CP_SIZE 2
657 
658 /* Filter types */
659 #define FLT_CLEAR_ALL			0x00
660 #define FLT_INQ_RESULT			0x01
661 #define FLT_CONN_SETUP			0x02
662 /* INQ_RESULT Condition types */
663 #define INQ_RESULT_RETURN_ALL		0x00
664 #define INQ_RESULT_RETURN_CLASS		0x01
665 #define INQ_RESULT_RETURN_BDADDR	0x02
666 /* CONN_SETUP Condition types */
667 #define CONN_SETUP_ALLOW_ALL		0x00
668 #define CONN_SETUP_ALLOW_CLASS		0x01
669 #define CONN_SETUP_ALLOW_BDADDR		0x02
670 /* CONN_SETUP Conditions */
671 #define CONN_SETUP_AUTO_OFF		0x01
672 #define CONN_SETUP_AUTO_ON		0x02
673 
674 #define OCF_FLUSH			0x0008
675 
676 #define OCF_READ_PIN_TYPE		0x0009
677 typedef struct {
678 	uint8_t		status;
679 	uint8_t		pin_type;
680 } __attribute__ ((packed)) read_pin_type_rp;
681 #define READ_PIN_TYPE_RP_SIZE 2
682 
683 #define OCF_WRITE_PIN_TYPE		0x000A
684 typedef struct {
685 	uint8_t		pin_type;
686 } __attribute__ ((packed)) write_pin_type_cp;
687 #define WRITE_PIN_TYPE_CP_SIZE 1
688 
689 #define OCF_CREATE_NEW_UNIT_KEY		0x000B
690 
691 #define OCF_READ_STORED_LINK_KEY	0x000D
692 typedef struct {
693 	bdaddr_t	bdaddr;
694 	uint8_t		read_all;
695 } __attribute__ ((packed)) read_stored_link_key_cp;
696 #define READ_STORED_LINK_KEY_CP_SIZE 7
697 typedef struct {
698 	uint8_t		status;
699 	uint16_t	max_keys;
700 	uint16_t	num_keys;
701 } __attribute__ ((packed)) read_stored_link_key_rp;
702 #define READ_STORED_LINK_KEY_RP_SIZE 5
703 
704 #define OCF_WRITE_STORED_LINK_KEY	0x0011
705 typedef struct {
706 	uint8_t		num_keys;
707 	/* variable length part */
708 } __attribute__ ((packed)) write_stored_link_key_cp;
709 #define WRITE_STORED_LINK_KEY_CP_SIZE 1
710 typedef struct {
711 	uint8_t		status;
712 	uint8_t		num_keys;
713 } __attribute__ ((packed)) write_stored_link_key_rp;
714 #define READ_WRITE_LINK_KEY_RP_SIZE 2
715 
716 #define OCF_DELETE_STORED_LINK_KEY	0x0012
717 typedef struct {
718 	bdaddr_t	bdaddr;
719 	uint8_t		delete_all;
720 } __attribute__ ((packed)) delete_stored_link_key_cp;
721 #define DELETE_STORED_LINK_KEY_CP_SIZE 7
722 typedef struct {
723 	uint8_t		status;
724 	uint16_t	num_keys;
725 } __attribute__ ((packed)) delete_stored_link_key_rp;
726 #define DELETE_STORED_LINK_KEY_RP_SIZE 3
727 
728 #define OCF_CHANGE_LOCAL_NAME		0x0013
729 typedef struct {
730 	uint8_t		name[248];
731 } __attribute__ ((packed)) change_local_name_cp;
732 #define CHANGE_LOCAL_NAME_CP_SIZE 248
733 
734 #define OCF_READ_LOCAL_NAME		0x0014
735 typedef struct {
736 	uint8_t		status;
737 	uint8_t		name[248];
738 } __attribute__ ((packed)) read_local_name_rp;
739 #define READ_LOCAL_NAME_RP_SIZE 249
740 
741 #define OCF_READ_CONN_ACCEPT_TIMEOUT	0x0015
742 typedef struct {
743 	uint8_t		status;
744 	uint16_t	timeout;
745 } __attribute__ ((packed)) read_conn_accept_timeout_rp;
746 #define READ_CONN_ACCEPT_TIMEOUT_RP_SIZE 3
747 
748 #define OCF_WRITE_CONN_ACCEPT_TIMEOUT	0x0016
749 typedef struct {
750 	uint16_t	timeout;
751 } __attribute__ ((packed)) write_conn_accept_timeout_cp;
752 #define WRITE_CONN_ACCEPT_TIMEOUT_CP_SIZE 2
753 
754 #define OCF_READ_PAGE_TIMEOUT		0x0017
755 typedef struct {
756 	uint8_t		status;
757 	uint16_t	timeout;
758 } __attribute__ ((packed)) read_page_timeout_rp;
759 #define READ_PAGE_TIMEOUT_RP_SIZE 3
760 
761 #define OCF_WRITE_PAGE_TIMEOUT		0x0018
762 typedef struct {
763 	uint16_t	timeout;
764 } __attribute__ ((packed)) write_page_timeout_cp;
765 #define WRITE_PAGE_TIMEOUT_CP_SIZE 2
766 
767 #define OCF_READ_SCAN_ENABLE		0x0019
768 typedef struct {
769 	uint8_t		status;
770 	uint8_t		enable;
771 } __attribute__ ((packed)) read_scan_enable_rp;
772 #define READ_SCAN_ENABLE_RP_SIZE 2
773 
774 #define OCF_WRITE_SCAN_ENABLE		0x001A
775 	#define SCAN_DISABLED		0x00
776 	#define SCAN_INQUIRY		0x01
777 	#define SCAN_PAGE		0x02
778 
779 #define OCF_READ_PAGE_ACTIVITY		0x001B
780 typedef struct {
781 	uint8_t		status;
782 	uint16_t	interval;
783 	uint16_t	window;
784 } __attribute__ ((packed)) read_page_activity_rp;
785 #define READ_PAGE_ACTIVITY_RP_SIZE 5
786 
787 #define OCF_WRITE_PAGE_ACTIVITY		0x001C
788 typedef struct {
789 	uint16_t	interval;
790 	uint16_t	window;
791 } __attribute__ ((packed)) write_page_activity_cp;
792 #define WRITE_PAGE_ACTIVITY_CP_SIZE 4
793 
794 #define OCF_READ_INQ_ACTIVITY		0x001D
795 typedef struct {
796 	uint8_t		status;
797 	uint16_t	interval;
798 	uint16_t	window;
799 } __attribute__ ((packed)) read_inq_activity_rp;
800 #define READ_INQ_ACTIVITY_RP_SIZE 5
801 
802 #define OCF_WRITE_INQ_ACTIVITY		0x001E
803 typedef struct {
804 	uint16_t	interval;
805 	uint16_t	window;
806 } __attribute__ ((packed)) write_inq_activity_cp;
807 #define WRITE_INQ_ACTIVITY_CP_SIZE 4
808 
809 #define OCF_READ_AUTH_ENABLE		0x001F
810 
811 #define OCF_WRITE_AUTH_ENABLE		0x0020
812 	#define AUTH_DISABLED		0x00
813 	#define AUTH_ENABLED		0x01
814 
815 #define OCF_READ_ENCRYPT_MODE		0x0021
816 
817 #define OCF_WRITE_ENCRYPT_MODE		0x0022
818 	#define ENCRYPT_DISABLED	0x00
819 	#define ENCRYPT_P2P		0x01
820 	#define ENCRYPT_BOTH		0x02
821 
822 #define OCF_READ_CLASS_OF_DEV		0x0023
823 typedef struct {
824 	uint8_t		status;
825 	uint8_t		dev_class[3];
826 } __attribute__ ((packed)) read_class_of_dev_rp;
827 #define READ_CLASS_OF_DEV_RP_SIZE 4
828 
829 #define OCF_WRITE_CLASS_OF_DEV		0x0024
830 typedef struct {
831 	uint8_t		dev_class[3];
832 } __attribute__ ((packed)) write_class_of_dev_cp;
833 #define WRITE_CLASS_OF_DEV_CP_SIZE 3
834 
835 #define OCF_READ_VOICE_SETTING		0x0025
836 typedef struct {
837 	uint8_t		status;
838 	uint16_t	voice_setting;
839 } __attribute__ ((packed)) read_voice_setting_rp;
840 #define READ_VOICE_SETTING_RP_SIZE 3
841 
842 #define OCF_WRITE_VOICE_SETTING		0x0026
843 typedef struct {
844 	uint16_t	voice_setting;
845 } __attribute__ ((packed)) write_voice_setting_cp;
846 #define WRITE_VOICE_SETTING_CP_SIZE 2
847 
848 #define OCF_READ_AUTOMATIC_FLUSH_TIMEOUT	0x0027
849 
850 #define OCF_WRITE_AUTOMATIC_FLUSH_TIMEOUT	0x0028
851 
852 #define OCF_READ_NUM_BROADCAST_RETRANS	0x0029
853 
854 #define OCF_WRITE_NUM_BROADCAST_RETRANS	0x002A
855 
856 #define OCF_READ_HOLD_MODE_ACTIVITY	0x002B
857 
858 #define OCF_WRITE_HOLD_MODE_ACTIVITY	0x002C
859 
860 #define OCF_READ_TRANSMIT_POWER_LEVEL	0x002D
861 typedef struct {
862 	uint16_t	handle;
863 	uint8_t		type;
864 } __attribute__ ((packed)) read_transmit_power_level_cp;
865 #define READ_TRANSMIT_POWER_LEVEL_CP_SIZE 3
866 typedef struct {
867 	uint8_t		status;
868 	uint16_t	handle;
869 	int8_t		level;
870 } __attribute__ ((packed)) read_transmit_power_level_rp;
871 #define READ_TRANSMIT_POWER_LEVEL_RP_SIZE 4
872 
873 #define OCF_READ_SYNC_FLOW_ENABLE	0x002E
874 
875 #define OCF_WRITE_SYNC_FLOW_ENABLE	0x002F
876 
877 #define OCF_SET_CONTROLLER_TO_HOST_FC	0x0031
878 
879 #define OCF_HOST_BUFFER_SIZE		0x0033
880 typedef struct {
881 	uint16_t	acl_mtu;
882 	uint8_t		sco_mtu;
883 	uint16_t	acl_max_pkt;
884 	uint16_t	sco_max_pkt;
885 } __attribute__ ((packed)) host_buffer_size_cp;
886 #define HOST_BUFFER_SIZE_CP_SIZE 7
887 
888 #define OCF_HOST_NUM_COMP_PKTS		0x0035
889 typedef struct {
890 	uint8_t		num_hndl;
891 	/* variable length part */
892 } __attribute__ ((packed)) host_num_comp_pkts_cp;
893 #define HOST_NUM_COMP_PKTS_CP_SIZE 1
894 
895 #define OCF_READ_LINK_SUPERVISION_TIMEOUT	0x0036
896 typedef struct {
897 	uint8_t		status;
898 	uint16_t	handle;
899 	uint16_t	timeout;
900 } __attribute__ ((packed)) read_link_supervision_timeout_rp;
901 #define READ_LINK_SUPERVISION_TIMEOUT_RP_SIZE 5
902 
903 #define OCF_WRITE_LINK_SUPERVISION_TIMEOUT	0x0037
904 typedef struct {
905 	uint16_t	handle;
906 	uint16_t	timeout;
907 } __attribute__ ((packed)) write_link_supervision_timeout_cp;
908 #define WRITE_LINK_SUPERVISION_TIMEOUT_CP_SIZE 4
909 typedef struct {
910 	uint8_t		status;
911 	uint16_t	handle;
912 } __attribute__ ((packed)) write_link_supervision_timeout_rp;
913 #define WRITE_LINK_SUPERVISION_TIMEOUT_RP_SIZE 3
914 
915 #define OCF_READ_NUM_SUPPORTED_IAC	0x0038
916 
917 #define MAX_IAC_LAP 0x40
918 #define OCF_READ_CURRENT_IAC_LAP	0x0039
919 typedef struct {
920 	uint8_t		status;
921 	uint8_t		num_current_iac;
922 	uint8_t		lap[MAX_IAC_LAP][3];
923 } __attribute__ ((packed)) read_current_iac_lap_rp;
924 #define READ_CURRENT_IAC_LAP_RP_SIZE 2+3*MAX_IAC_LAP
925 
926 #define OCF_WRITE_CURRENT_IAC_LAP	0x003A
927 typedef struct {
928 	uint8_t		num_current_iac;
929 	uint8_t		lap[MAX_IAC_LAP][3];
930 } __attribute__ ((packed)) write_current_iac_lap_cp;
931 #define WRITE_CURRENT_IAC_LAP_CP_SIZE 1+3*MAX_IAC_LAP
932 
933 #define OCF_READ_PAGE_SCAN_PERIOD_MODE	0x003B
934 
935 #define OCF_WRITE_PAGE_SCAN_PERIOD_MODE	0x003C
936 
937 #define OCF_READ_PAGE_SCAN_MODE		0x003D
938 
939 #define OCF_WRITE_PAGE_SCAN_MODE	0x003E
940 
941 #define OCF_SET_AFH_CLASSIFICATION	0x003F
942 typedef struct {
943 	uint8_t		map[10];
944 } __attribute__ ((packed)) set_afh_classification_cp;
945 #define SET_AFH_CLASSIFICATION_CP_SIZE 10
946 typedef struct {
947 	uint8_t		status;
948 } __attribute__ ((packed)) set_afh_classification_rp;
949 #define SET_AFH_CLASSIFICATION_RP_SIZE 1
950 
951 #define OCF_READ_INQUIRY_SCAN_TYPE	0x0042
952 typedef struct {
953 	uint8_t		status;
954 	uint8_t		type;
955 } __attribute__ ((packed)) read_inquiry_scan_type_rp;
956 #define READ_INQUIRY_SCAN_TYPE_RP_SIZE 2
957 
958 #define OCF_WRITE_INQUIRY_SCAN_TYPE	0x0043
959 typedef struct {
960 	uint8_t		type;
961 } __attribute__ ((packed)) write_inquiry_scan_type_cp;
962 #define WRITE_INQUIRY_SCAN_TYPE_CP_SIZE 1
963 typedef struct {
964 	uint8_t		status;
965 } __attribute__ ((packed)) write_inquiry_scan_type_rp;
966 #define WRITE_INQUIRY_SCAN_TYPE_RP_SIZE 1
967 
968 #define OCF_READ_INQUIRY_MODE		0x0044
969 typedef struct {
970 	uint8_t		status;
971 	uint8_t		mode;
972 } __attribute__ ((packed)) read_inquiry_mode_rp;
973 #define READ_INQUIRY_MODE_RP_SIZE 2
974 
975 #define OCF_WRITE_INQUIRY_MODE		0x0045
976 typedef struct {
977 	uint8_t		mode;
978 } __attribute__ ((packed)) write_inquiry_mode_cp;
979 #define WRITE_INQUIRY_MODE_CP_SIZE 1
980 typedef struct {
981 	uint8_t		status;
982 } __attribute__ ((packed)) write_inquiry_mode_rp;
983 #define WRITE_INQUIRY_MODE_RP_SIZE 1
984 
985 #define OCF_READ_PAGE_SCAN_TYPE		0x0046
986 
987 #define OCF_WRITE_PAGE_SCAN_TYPE	0x0047
988 
989 #define OCF_READ_AFH_MODE		0x0048
990 typedef struct {
991 	uint8_t		status;
992 	uint8_t		mode;
993 } __attribute__ ((packed)) read_afh_mode_rp;
994 #define READ_AFH_MODE_RP_SIZE 2
995 
996 #define OCF_WRITE_AFH_MODE		0x0049
997 typedef struct {
998 	uint8_t		mode;
999 } __attribute__ ((packed)) write_afh_mode_cp;
1000 #define WRITE_AFH_MODE_CP_SIZE 1
1001 typedef struct {
1002 	uint8_t		status;
1003 } __attribute__ ((packed)) write_afh_mode_rp;
1004 #define WRITE_AFH_MODE_RP_SIZE 1
1005 
1006 #define OCF_READ_EXT_INQUIRY_RESPONSE	0x0051
1007 typedef struct {
1008 	uint8_t		status;
1009 	uint8_t		fec;
1010 	uint8_t		data[240];
1011 } __attribute__ ((packed)) read_ext_inquiry_response_rp;
1012 #define READ_EXT_INQUIRY_RESPONSE_RP_SIZE 242
1013 
1014 #define OCF_WRITE_EXT_INQUIRY_RESPONSE	0x0052
1015 typedef struct {
1016 	uint8_t		fec;
1017 	uint8_t		data[240];
1018 } __attribute__ ((packed)) write_ext_inquiry_response_cp;
1019 #define WRITE_EXT_INQUIRY_RESPONSE_CP_SIZE 241
1020 typedef struct {
1021 	uint8_t		status;
1022 } __attribute__ ((packed)) write_ext_inquiry_response_rp;
1023 #define WRITE_EXT_INQUIRY_RESPONSE_RP_SIZE 1
1024 
1025 #define OCF_REFRESH_ENCRYPTION_KEY	0x0053
1026 typedef struct {
1027 	uint16_t	handle;
1028 } __attribute__ ((packed)) refresh_encryption_key_cp;
1029 #define REFRESH_ENCRYPTION_KEY_CP_SIZE 2
1030 typedef struct {
1031 	uint8_t		status;
1032 } __attribute__ ((packed)) refresh_encryption_key_rp;
1033 #define REFRESH_ENCRYPTION_KEY_RP_SIZE 1
1034 
1035 #define OCF_READ_SIMPLE_PAIRING_MODE	0x0055
1036 typedef struct {
1037 	uint8_t		status;
1038 	uint8_t		mode;
1039 } __attribute__ ((packed)) read_simple_pairing_mode_rp;
1040 #define READ_SIMPLE_PAIRING_MODE_RP_SIZE 2
1041 
1042 #define OCF_WRITE_SIMPLE_PAIRING_MODE	0x0056
1043 typedef struct {
1044 	uint8_t		mode;
1045 } __attribute__ ((packed)) write_simple_pairing_mode_cp;
1046 #define WRITE_SIMPLE_PAIRING_MODE_CP_SIZE 1
1047 typedef struct {
1048 	uint8_t		status;
1049 } __attribute__ ((packed)) write_simple_pairing_mode_rp;
1050 #define WRITE_SIMPLE_PAIRING_MODE_RP_SIZE 1
1051 
1052 #define OCF_READ_LOCAL_OOB_DATA		0x0057
1053 typedef struct {
1054 	uint8_t		status;
1055 	uint8_t		hash[16];
1056 	uint8_t		randomizer[16];
1057 } __attribute__ ((packed)) read_local_oob_data_rp;
1058 #define READ_LOCAL_OOB_DATA_RP_SIZE 33
1059 
1060 #define OCF_READ_INQUIRY_TRANSMIT_POWER_LEVEL	0x0058
1061 typedef struct {
1062 	uint8_t		status;
1063 	int8_t		level;
1064 } __attribute__ ((packed)) read_inquiry_transmit_power_level_rp;
1065 #define READ_INQUIRY_TRANSMIT_POWER_LEVEL_RP_SIZE 2
1066 
1067 #define OCF_WRITE_INQUIRY_TRANSMIT_POWER_LEVEL	0x0059
1068 typedef struct {
1069 	int8_t		level;
1070 } __attribute__ ((packed)) write_inquiry_transmit_power_level_cp;
1071 #define WRITE_INQUIRY_TRANSMIT_POWER_LEVEL_CP_SIZE 1
1072 typedef struct {
1073 	uint8_t		status;
1074 } __attribute__ ((packed)) write_inquiry_transmit_power_level_rp;
1075 #define WRITE_INQUIRY_TRANSMIT_POWER_LEVEL_RP_SIZE 1
1076 
1077 #define OCF_READ_DEFAULT_ERROR_DATA_REPORTING	0x005A
1078 typedef struct {
1079 	uint8_t		status;
1080 	uint8_t		reporting;
1081 } __attribute__ ((packed)) read_default_error_data_reporting_rp;
1082 #define READ_DEFAULT_ERROR_DATA_REPORTING_RP_SIZE 2
1083 
1084 #define OCF_WRITE_DEFAULT_ERROR_DATA_REPORTING	0x005B
1085 typedef struct {
1086 	uint8_t		reporting;
1087 } __attribute__ ((packed)) write_default_error_data_reporting_cp;
1088 #define WRITE_DEFAULT_ERROR_DATA_REPORTING_CP_SIZE 1
1089 typedef struct {
1090 	uint8_t		status;
1091 } __attribute__ ((packed)) write_default_error_data_reporting_rp;
1092 #define WRITE_DEFAULT_ERROR_DATA_REPORTING_RP_SIZE 1
1093 
1094 #define OCF_ENHANCED_FLUSH		0x005F
1095 typedef struct {
1096 	uint16_t	handle;
1097 	uint8_t		type;
1098 } __attribute__ ((packed)) enhanced_flush_cp;
1099 #define ENHANCED_FLUSH_CP_SIZE 3
1100 
1101 #define OCF_SEND_KEYPRESS_NOTIFY	0x0060
1102 typedef struct {
1103 	bdaddr_t	bdaddr;
1104 	uint8_t		type;
1105 } __attribute__ ((packed)) send_keypress_notify_cp;
1106 #define SEND_KEYPRESS_NOTIFY_CP_SIZE 7
1107 typedef struct {
1108 	uint8_t		status;
1109 } __attribute__ ((packed)) send_keypress_notify_rp;
1110 #define SEND_KEYPRESS_NOTIFY_RP_SIZE 1
1111 
1112 /* Informational Parameters */
1113 #define OGF_INFO_PARAM		0x04
1114 
1115 #define OCF_READ_LOCAL_VERSION		0x0001
1116 typedef struct {
1117 	uint8_t		status;
1118 	uint8_t		hci_ver;
1119 	uint16_t	hci_rev;
1120 	uint8_t		lmp_ver;
1121 	uint16_t	manufacturer;
1122 	uint16_t	lmp_subver;
1123 } __attribute__ ((packed)) read_local_version_rp;
1124 #define READ_LOCAL_VERSION_RP_SIZE 9
1125 
1126 #define OCF_READ_LOCAL_COMMANDS		0x0002
1127 typedef struct {
1128 	uint8_t		status;
1129 	uint8_t		commands[64];
1130 } __attribute__ ((packed)) read_local_commands_rp;
1131 #define READ_LOCAL_COMMANDS_RP_SIZE 65
1132 
1133 #define OCF_READ_LOCAL_FEATURES		0x0003
1134 typedef struct {
1135 	uint8_t		status;
1136 	uint8_t		features[8];
1137 } __attribute__ ((packed)) read_local_features_rp;
1138 #define READ_LOCAL_FEATURES_RP_SIZE 9
1139 
1140 #define OCF_READ_LOCAL_EXT_FEATURES	0x0004
1141 typedef struct {
1142 	uint8_t		page_num;
1143 } __attribute__ ((packed)) read_local_ext_features_cp;
1144 #define READ_LOCAL_EXT_FEATURES_CP_SIZE 1
1145 typedef struct {
1146 	uint8_t		status;
1147 	uint8_t		page_num;
1148 	uint8_t		max_page_num;
1149 	uint8_t		features[8];
1150 } __attribute__ ((packed)) read_local_ext_features_rp;
1151 #define READ_LOCAL_EXT_FEATURES_RP_SIZE 11
1152 
1153 #define OCF_READ_BUFFER_SIZE		0x0005
1154 typedef struct {
1155 	uint8_t		status;
1156 	uint16_t	acl_mtu;
1157 	uint8_t		sco_mtu;
1158 	uint16_t	acl_max_pkt;
1159 	uint16_t	sco_max_pkt;
1160 } __attribute__ ((packed)) read_buffer_size_rp;
1161 #define READ_BUFFER_SIZE_RP_SIZE 8
1162 
1163 #define OCF_READ_COUNTRY_CODE		0x0007
1164 
1165 #define OCF_READ_BD_ADDR		0x0009
1166 typedef struct {
1167 	uint8_t		status;
1168 	bdaddr_t	bdaddr;
1169 } __attribute__ ((packed)) read_bd_addr_rp;
1170 #define READ_BD_ADDR_RP_SIZE 7
1171 
1172 /* Status params */
1173 #define OGF_STATUS_PARAM	0x05
1174 
1175 #define OCF_READ_FAILED_CONTACT_COUNTER		0x0001
1176 typedef struct {
1177 	uint8_t		status;
1178 	uint16_t	handle;
1179 	uint8_t		counter;
1180 } __attribute__ ((packed)) read_failed_contact_counter_rp;
1181 #define READ_FAILED_CONTACT_COUNTER_RP_SIZE 4
1182 
1183 #define OCF_RESET_FAILED_CONTACT_COUNTER	0x0002
1184 typedef struct {
1185 	uint8_t		status;
1186 	uint16_t	handle;
1187 } __attribute__ ((packed)) reset_failed_contact_counter_rp;
1188 #define RESET_FAILED_CONTACT_COUNTER_RP_SIZE 4
1189 
1190 #define OCF_READ_LINK_QUALITY		0x0003
1191 typedef struct {
1192 	uint8_t		status;
1193 	uint16_t	handle;
1194 	uint8_t		link_quality;
1195 } __attribute__ ((packed)) read_link_quality_rp;
1196 #define READ_LINK_QUALITY_RP_SIZE 4
1197 
1198 #define OCF_READ_RSSI			0x0005
1199 typedef struct {
1200 	uint8_t		status;
1201 	uint16_t	handle;
1202 	int8_t		rssi;
1203 } __attribute__ ((packed)) read_rssi_rp;
1204 #define READ_RSSI_RP_SIZE 4
1205 
1206 #define OCF_READ_AFH_MAP		0x0006
1207 typedef struct {
1208 	uint8_t		status;
1209 	uint16_t	handle;
1210 	uint8_t		mode;
1211 	uint8_t		map[10];
1212 } __attribute__ ((packed)) read_afh_map_rp;
1213 #define READ_AFH_MAP_RP_SIZE 14
1214 
1215 #define OCF_READ_CLOCK			0x0007
1216 typedef struct {
1217 	uint16_t	handle;
1218 	uint8_t		which_clock;
1219 } __attribute__ ((packed)) read_clock_cp;
1220 #define READ_CLOCK_CP_SIZE 3
1221 typedef struct {
1222 	uint8_t		status;
1223 	uint16_t	handle;
1224 	uint32_t	clock;
1225 	uint16_t	accuracy;
1226 } __attribute__ ((packed)) read_clock_rp;
1227 #define READ_CLOCK_RP_SIZE 9
1228 
1229 /* Testing commands */
1230 #define OGF_TESTING_CMD		0x3e
1231 
1232 #define OCF_READ_LOOPBACK_MODE			0x0001
1233 
1234 #define OCF_WRITE_LOOPBACK_MODE			0x0002
1235 
1236 #define OCF_ENABLE_DEVICE_UNDER_TEST_MODE	0x0003
1237 
1238 #define OCF_WRITE_SIMPLE_PAIRING_DEBUG_MODE	0x0004
1239 typedef struct {
1240 	uint8_t		mode;
1241 } __attribute__ ((packed)) write_simple_pairing_debug_mode_cp;
1242 #define WRITE_SIMPLE_PAIRING_DEBUG_MODE_CP_SIZE 1
1243 typedef struct {
1244 	uint8_t		status;
1245 } __attribute__ ((packed)) write_simple_pairing_debug_mode_rp;
1246 #define WRITE_SIMPLE_PAIRING_DEBUG_MODE_RP_SIZE 1
1247 
1248 /* Vendor specific commands */
1249 #define OGF_VENDOR_CMD		0x3f
1250 
1251 /* ---- HCI Events ---- */
1252 
1253 #define EVT_INQUIRY_COMPLETE		0x01
1254 
1255 #define EVT_INQUIRY_RESULT		0x02
1256 typedef struct {
1257 	bdaddr_t	bdaddr;
1258 	uint8_t		pscan_rep_mode;
1259 	uint8_t		pscan_period_mode;
1260 	uint8_t		pscan_mode;
1261 	uint8_t		dev_class[3];
1262 	uint16_t	clock_offset;
1263 } __attribute__ ((packed)) inquiry_info;
1264 #define INQUIRY_INFO_SIZE 14
1265 
1266 #define EVT_CONN_COMPLETE		0x03
1267 typedef struct {
1268 	uint8_t		status;
1269 	uint16_t	handle;
1270 	bdaddr_t	bdaddr;
1271 	uint8_t		link_type;
1272 	uint8_t		encr_mode;
1273 } __attribute__ ((packed)) evt_conn_complete;
1274 #define EVT_CONN_COMPLETE_SIZE 13
1275 
1276 #define EVT_CONN_REQUEST		0x04
1277 typedef struct {
1278 	bdaddr_t	bdaddr;
1279 	uint8_t		dev_class[3];
1280 	uint8_t		link_type;
1281 } __attribute__ ((packed)) evt_conn_request;
1282 #define EVT_CONN_REQUEST_SIZE 10
1283 
1284 #define EVT_DISCONN_COMPLETE		0x05
1285 typedef struct {
1286 	uint8_t		status;
1287 	uint16_t	handle;
1288 	uint8_t		reason;
1289 } __attribute__ ((packed)) evt_disconn_complete;
1290 #define EVT_DISCONN_COMPLETE_SIZE 4
1291 
1292 #define EVT_AUTH_COMPLETE		0x06
1293 typedef struct {
1294 	uint8_t		status;
1295 	uint16_t	handle;
1296 } __attribute__ ((packed)) evt_auth_complete;
1297 #define EVT_AUTH_COMPLETE_SIZE 3
1298 
1299 #define EVT_REMOTE_NAME_REQ_COMPLETE	0x07
1300 typedef struct {
1301 	uint8_t		status;
1302 	bdaddr_t	bdaddr;
1303 	uint8_t		name[248];
1304 } __attribute__ ((packed)) evt_remote_name_req_complete;
1305 #define EVT_REMOTE_NAME_REQ_COMPLETE_SIZE 255
1306 
1307 #define EVT_ENCRYPT_CHANGE		0x08
1308 typedef struct {
1309 	uint8_t		status;
1310 	uint16_t	handle;
1311 	uint8_t		encrypt;
1312 } __attribute__ ((packed)) evt_encrypt_change;
1313 #define EVT_ENCRYPT_CHANGE_SIZE 5
1314 
1315 #define EVT_CHANGE_CONN_LINK_KEY_COMPLETE	0x09
1316 typedef struct {
1317 	uint8_t		status;
1318 	uint16_t	handle;
1319 }  __attribute__ ((packed)) evt_change_conn_link_key_complete;
1320 #define EVT_CHANGE_CONN_LINK_KEY_COMPLETE_SIZE 3
1321 
1322 #define EVT_MASTER_LINK_KEY_COMPLETE		0x0A
1323 typedef struct {
1324 	uint8_t		status;
1325 	uint16_t	handle;
1326 	uint8_t		key_flag;
1327 } __attribute__ ((packed)) evt_master_link_key_complete;
1328 #define EVT_MASTER_LINK_KEY_COMPLETE_SIZE 4
1329 
1330 #define EVT_READ_REMOTE_FEATURES_COMPLETE	0x0B
1331 typedef struct {
1332 	uint8_t		status;
1333 	uint16_t	handle;
1334 	uint8_t		features[8];
1335 } __attribute__ ((packed)) evt_read_remote_features_complete;
1336 #define EVT_READ_REMOTE_FEATURES_COMPLETE_SIZE 11
1337 
1338 #define EVT_READ_REMOTE_VERSION_COMPLETE	0x0C
1339 typedef struct {
1340 	uint8_t		status;
1341 	uint16_t	handle;
1342 	uint8_t		lmp_ver;
1343 	uint16_t	manufacturer;
1344 	uint16_t	lmp_subver;
1345 } __attribute__ ((packed)) evt_read_remote_version_complete;
1346 #define EVT_READ_REMOTE_VERSION_COMPLETE_SIZE 8
1347 
1348 #define EVT_QOS_SETUP_COMPLETE		0x0D
1349 typedef struct {
1350 	uint8_t		status;
1351 	uint16_t	handle;
1352 	uint8_t		flags;			/* Reserved */
1353 	hci_qos		qos;
1354 } __attribute__ ((packed)) evt_qos_setup_complete;
1355 #define EVT_QOS_SETUP_COMPLETE_SIZE (4 + HCI_QOS_CP_SIZE)
1356 
1357 #define EVT_CMD_COMPLETE 		0x0E
1358 typedef struct {
1359 	uint8_t		ncmd;
1360 	uint16_t	opcode;
1361 } __attribute__ ((packed)) evt_cmd_complete;
1362 #define EVT_CMD_COMPLETE_SIZE 3
1363 
1364 #define EVT_CMD_STATUS 			0x0F
1365 typedef struct {
1366 	uint8_t		status;
1367 	uint8_t		ncmd;
1368 	uint16_t	opcode;
1369 } __attribute__ ((packed)) evt_cmd_status;
1370 #define EVT_CMD_STATUS_SIZE 4
1371 
1372 #define EVT_HARDWARE_ERROR		0x10
1373 typedef struct {
1374 	uint8_t		code;
1375 } __attribute__ ((packed)) evt_hardware_error;
1376 #define EVT_HARDWARE_ERROR_SIZE 1
1377 
1378 #define EVT_FLUSH_OCCURRED		0x11
1379 typedef struct {
1380 	uint16_t	handle;
1381 } __attribute__ ((packed)) evt_flush_occured;
1382 #define EVT_FLUSH_OCCURRED_SIZE 2
1383 
1384 #define EVT_ROLE_CHANGE			0x12
1385 typedef struct {
1386 	uint8_t		status;
1387 	bdaddr_t	bdaddr;
1388 	uint8_t		role;
1389 } __attribute__ ((packed)) evt_role_change;
1390 #define EVT_ROLE_CHANGE_SIZE 8
1391 
1392 #define EVT_NUM_COMP_PKTS		0x13
1393 typedef struct {
1394 	uint8_t		num_hndl;
1395 	/* variable length part */
1396 } __attribute__ ((packed)) evt_num_comp_pkts;
1397 #define EVT_NUM_COMP_PKTS_SIZE 1
1398 
1399 #define EVT_MODE_CHANGE			0x14
1400 typedef struct {
1401 	uint8_t		status;
1402 	uint16_t	handle;
1403 	uint8_t		mode;
1404 	uint16_t	interval;
1405 } __attribute__ ((packed)) evt_mode_change;
1406 #define EVT_MODE_CHANGE_SIZE 6
1407 
1408 #define EVT_RETURN_LINK_KEYS		0x15
1409 typedef struct {
1410 	uint8_t		num_keys;
1411 	/* variable length part */
1412 } __attribute__ ((packed)) evt_return_link_keys;
1413 #define EVT_RETURN_LINK_KEYS_SIZE 1
1414 
1415 #define EVT_PIN_CODE_REQ		0x16
1416 typedef struct {
1417 	bdaddr_t	bdaddr;
1418 } __attribute__ ((packed)) evt_pin_code_req;
1419 #define EVT_PIN_CODE_REQ_SIZE 6
1420 
1421 #define EVT_LINK_KEY_REQ		0x17
1422 typedef struct {
1423 	bdaddr_t	bdaddr;
1424 } __attribute__ ((packed)) evt_link_key_req;
1425 #define EVT_LINK_KEY_REQ_SIZE 6
1426 
1427 #define EVT_LINK_KEY_NOTIFY		0x18
1428 typedef struct {
1429 	bdaddr_t	bdaddr;
1430 	uint8_t		link_key[16];
1431 	uint8_t		key_type;
1432 } __attribute__ ((packed)) evt_link_key_notify;
1433 #define EVT_LINK_KEY_NOTIFY_SIZE 23
1434 
1435 #define EVT_LOOPBACK_COMMAND		0x19
1436 
1437 #define EVT_DATA_BUFFER_OVERFLOW	0x1A
1438 typedef struct {
1439 	uint8_t		link_type;
1440 } __attribute__ ((packed)) evt_data_buffer_overflow;
1441 #define EVT_DATA_BUFFER_OVERFLOW_SIZE 1
1442 
1443 #define EVT_MAX_SLOTS_CHANGE		0x1B
1444 typedef struct {
1445 	uint16_t	handle;
1446 	uint8_t		max_slots;
1447 } __attribute__ ((packed)) evt_max_slots_change;
1448 #define EVT_MAX_SLOTS_CHANGE_SIZE 3
1449 
1450 #define EVT_READ_CLOCK_OFFSET_COMPLETE	0x1C
1451 typedef struct {
1452 	uint8_t		status;
1453 	uint16_t	handle;
1454 	uint16_t	clock_offset;
1455 } __attribute__ ((packed)) evt_read_clock_offset_complete;
1456 #define EVT_READ_CLOCK_OFFSET_COMPLETE_SIZE 5
1457 
1458 #define EVT_CONN_PTYPE_CHANGED		0x1D
1459 typedef struct {
1460 	uint8_t		status;
1461 	uint16_t	handle;
1462 	uint16_t	ptype;
1463 } __attribute__ ((packed)) evt_conn_ptype_changed;
1464 #define EVT_CONN_PTYPE_CHANGED_SIZE 5
1465 
1466 #define EVT_QOS_VIOLATION		0x1E
1467 typedef struct {
1468 	uint16_t	handle;
1469 } __attribute__ ((packed)) evt_qos_violation;
1470 #define EVT_QOS_VIOLATION_SIZE 2
1471 
1472 #define EVT_PSCAN_REP_MODE_CHANGE	0x20
1473 typedef struct {
1474 	bdaddr_t	bdaddr;
1475 	uint8_t		pscan_rep_mode;
1476 } __attribute__ ((packed)) evt_pscan_rep_mode_change;
1477 #define EVT_PSCAN_REP_MODE_CHANGE_SIZE 7
1478 
1479 #define EVT_FLOW_SPEC_COMPLETE		0x21
1480 typedef struct {
1481 	uint8_t		status;
1482 	uint16_t	handle;
1483 	uint8_t		flags;
1484 	uint8_t		direction;
1485 	hci_qos		qos;
1486 } __attribute__ ((packed)) evt_flow_spec_complete;
1487 #define EVT_FLOW_SPEC_COMPLETE_SIZE (5 + HCI_QOS_CP_SIZE)
1488 
1489 #define EVT_INQUIRY_RESULT_WITH_RSSI	0x22
1490 typedef struct {
1491 	bdaddr_t	bdaddr;
1492 	uint8_t		pscan_rep_mode;
1493 	uint8_t		pscan_period_mode;
1494 	uint8_t		dev_class[3];
1495 	uint16_t	clock_offset;
1496 	int8_t		rssi;
1497 } __attribute__ ((packed)) inquiry_info_with_rssi;
1498 #define INQUIRY_INFO_WITH_RSSI_SIZE 14
1499 typedef struct {
1500 	bdaddr_t	bdaddr;
1501 	uint8_t		pscan_rep_mode;
1502 	uint8_t		pscan_period_mode;
1503 	uint8_t		pscan_mode;
1504 	uint8_t		dev_class[3];
1505 	uint16_t	clock_offset;
1506 	int8_t		rssi;
1507 } __attribute__ ((packed)) inquiry_info_with_rssi_and_pscan_mode;
1508 #define INQUIRY_INFO_WITH_RSSI_AND_PSCAN_MODE_SIZE 15
1509 
1510 #define EVT_READ_REMOTE_EXT_FEATURES_COMPLETE	0x23
1511 typedef struct {
1512 	uint8_t		status;
1513 	uint16_t	handle;
1514 	uint8_t		page_num;
1515 	uint8_t		max_page_num;
1516 	uint8_t		features[8];
1517 } __attribute__ ((packed)) evt_read_remote_ext_features_complete;
1518 #define EVT_READ_REMOTE_EXT_FEATURES_COMPLETE_SIZE 13
1519 
1520 #define EVT_SYNC_CONN_COMPLETE		0x2C
1521 typedef struct {
1522 	uint8_t		status;
1523 	uint16_t	handle;
1524 	bdaddr_t	bdaddr;
1525 	uint8_t		link_type;
1526 	uint8_t		trans_interval;
1527 	uint8_t		retrans_window;
1528 	uint16_t	rx_pkt_len;
1529 	uint16_t	tx_pkt_len;
1530 	uint8_t		air_mode;
1531 } __attribute__ ((packed)) evt_sync_conn_complete;
1532 #define EVT_SYNC_CONN_COMPLETE_SIZE 17
1533 
1534 #define EVT_SYNC_CONN_CHANGED		0x2D
1535 typedef struct {
1536 	uint8_t		status;
1537 	uint16_t	handle;
1538 	uint8_t		trans_interval;
1539 	uint8_t		retrans_window;
1540 	uint16_t	rx_pkt_len;
1541 	uint16_t	tx_pkt_len;
1542 } __attribute__ ((packed)) evt_sync_conn_changed;
1543 #define EVT_SYNC_CONN_CHANGED_SIZE 9
1544 
1545 #define EVT_SNIFF_SUBRATING		0x2E
1546 typedef struct {
1547 	uint8_t		status;
1548 	uint16_t	handle;
1549 	uint16_t	max_tx_latency;
1550 	uint16_t	max_rx_latency;
1551 	uint16_t	min_remote_timeout;
1552 	uint16_t	min_local_timeout;
1553 } __attribute__ ((packed)) evt_sniff_subrating;
1554 #define EVT_SNIFF_SUBRATING_SIZE 11
1555 
1556 #define EVT_EXTENDED_INQUIRY_RESULT	0x2F
1557 typedef struct {
1558 	bdaddr_t	bdaddr;
1559 	uint8_t		pscan_rep_mode;
1560 	uint8_t		pscan_period_mode;
1561 	uint8_t		dev_class[3];
1562 	uint16_t	clock_offset;
1563 	int8_t		rssi;
1564 	uint8_t		data[240];
1565 } __attribute__ ((packed)) extended_inquiry_info;
1566 #define EXTENDED_INQUIRY_INFO_SIZE 254
1567 
1568 #define EVT_ENCRYPTION_KEY_REFRESH_COMPLETE	0x30
1569 typedef struct {
1570 	uint8_t		status;
1571 	uint16_t	handle;
1572 } __attribute__ ((packed)) evt_encryption_key_refresh_complete;
1573 #define EVT_ENCRYPTION_KEY_REFRESH_COMPLETE_SIZE 3
1574 
1575 #define EVT_IO_CAPABILITY_REQUEST	0x31
1576 typedef struct {
1577 	bdaddr_t	bdaddr;
1578 } __attribute__ ((packed)) evt_io_capability_request;
1579 #define EVT_IO_CAPABILITY_REQUEST_SIZE 6
1580 
1581 #define EVT_IO_CAPABILITY_RESPONSE	0x32
1582 typedef struct {
1583 	bdaddr_t	bdaddr;
1584 	uint8_t		capability;
1585 	uint8_t		oob_data;
1586 	uint8_t		authentication;
1587 } __attribute__ ((packed)) evt_io_capability_response;
1588 #define EVT_IO_CAPABILITY_RESPONSE_SIZE 9
1589 
1590 #define EVT_USER_CONFIRM_REQUEST	0x33
1591 typedef struct {
1592 	bdaddr_t	bdaddr;
1593 	uint32_t	passkey;
1594 } __attribute__ ((packed)) evt_user_confirm_request;
1595 #define EVT_USER_CONFIRM_REQUEST_SIZE 10
1596 
1597 #define EVT_USER_PASSKEY_REQUEST	0x34
1598 typedef struct {
1599 	bdaddr_t	bdaddr;
1600 } __attribute__ ((packed)) evt_user_passkey_request;
1601 #define EVT_USER_PASSKEY_REQUEST_SIZE 6
1602 
1603 #define EVT_REMOTE_OOB_DATA_REQUEST	0x35
1604 typedef struct {
1605 	bdaddr_t	bdaddr;
1606 } __attribute__ ((packed)) evt_remote_oob_data_request;
1607 #define EVT_REMOTE_OOB_DATA_REQUEST_SIZE 6
1608 
1609 #define EVT_SIMPLE_PAIRING_COMPLETE	0x36
1610 typedef struct {
1611 	uint8_t		status;
1612 	bdaddr_t	bdaddr;
1613 } __attribute__ ((packed)) evt_simple_pairing_complete;
1614 #define EVT_SIMPLE_PAIRING_COMPLETE_SIZE 7
1615 
1616 #define EVT_LINK_SUPERVISION_TIMEOUT_CHANGED	0x38
1617 typedef struct {
1618 	uint16_t	handle;
1619 	uint16_t	timeout;
1620 } __attribute__ ((packed)) evt_link_supervision_timeout_changed;
1621 #define EVT_LINK_SUPERVISION_TIMEOUT_CHANGED_SIZE 4
1622 
1623 #define EVT_ENHANCED_FLUSH_COMPLETE	0x39
1624 typedef struct {
1625 	uint16_t	handle;
1626 } __attribute__ ((packed)) evt_enhanced_flush_complete;
1627 #define EVT_ENHANCED_FLUSH_COMPLETE_SIZE 2
1628 
1629 #define EVT_USER_PASSKEY_NOTIFY		0x3B
1630 typedef struct {
1631 	bdaddr_t	bdaddr;
1632 	uint32_t	passkey;
1633 } __attribute__ ((packed)) evt_user_passkey_notify;
1634 #define EVT_USER_PASSKEY_NOTIFY_SIZE 10
1635 
1636 #define EVT_KEYPRESS_NOTIFY		0x3C
1637 typedef struct {
1638 	bdaddr_t	bdaddr;
1639 	uint8_t		type;
1640 } __attribute__ ((packed)) evt_keypress_notify;
1641 #define EVT_KEYPRESS_NOTIFY_SIZE 7
1642 
1643 #define EVT_REMOTE_HOST_FEATURES_NOTIFY	0x3D
1644 typedef struct {
1645 	bdaddr_t	bdaddr;
1646 	uint8_t		features[8];
1647 } __attribute__ ((packed)) evt_remote_host_features_notify;
1648 #define EVT_REMOTE_HOST_FEATURES_NOTIFY_SIZE 14
1649 
1650 #define EVT_TESTING			0xFE
1651 
1652 #define EVT_VENDOR			0xFF
1653 
1654 /* Internal events generated by BlueZ stack */
1655 #define EVT_STACK_INTERNAL		0xFD
1656 typedef struct {
1657 	uint16_t	type;
1658 	uint8_t		data[0];
1659 } __attribute__ ((packed)) evt_stack_internal;
1660 #define EVT_STACK_INTERNAL_SIZE 2
1661 
1662 #define EVT_SI_DEVICE	0x01
1663 typedef struct {
1664 	uint16_t	event;
1665 	uint16_t	dev_id;
1666 } __attribute__ ((packed)) evt_si_device;
1667 #define EVT_SI_DEVICE_SIZE 4
1668 
1669 #define EVT_SI_SECURITY	0x02
1670 typedef struct {
1671 	uint16_t	event;
1672 	uint16_t	proto;
1673 	uint16_t	subproto;
1674 	uint8_t		incoming;
1675 } __attribute__ ((packed)) evt_si_security;
1676 
1677 /* --------  HCI Packet structures  -------- */
1678 #define HCI_TYPE_LEN	1
1679 
1680 typedef struct {
1681 	uint16_t	opcode;		/* OCF & OGF */
1682 	uint8_t		plen;
1683 } __attribute__ ((packed))	hci_command_hdr;
1684 #define HCI_COMMAND_HDR_SIZE 	3
1685 
1686 typedef struct {
1687 	uint8_t		evt;
1688 	uint8_t		plen;
1689 } __attribute__ ((packed))	hci_event_hdr;
1690 #define HCI_EVENT_HDR_SIZE 	2
1691 
1692 typedef struct {
1693 	uint16_t	handle;		/* Handle & Flags(PB, BC) */
1694 	uint16_t	dlen;
1695 } __attribute__ ((packed))	hci_acl_hdr;
1696 #define HCI_ACL_HDR_SIZE 	4
1697 
1698 typedef struct {
1699 	uint16_t	handle;
1700 	uint8_t		dlen;
1701 } __attribute__ ((packed))	hci_sco_hdr;
1702 #define HCI_SCO_HDR_SIZE 	3
1703 
1704 typedef struct {
1705 	uint16_t	device;
1706 	uint16_t	type;
1707 	uint16_t	plen;
1708 } __attribute__ ((packed))	hci_msg_hdr;
1709 #define HCI_MSG_HDR_SIZE	6
1710 
1711 /* Command opcode pack/unpack */
1712 #define cmd_opcode_pack(ogf, ocf)	(uint16_t)((ocf & 0x03ff)|(ogf << 10))
1713 #define cmd_opcode_ogf(op)		(op >> 10)
1714 #define cmd_opcode_ocf(op)		(op & 0x03ff)
1715 
1716 /* ACL handle and flags pack/unpack */
1717 #define acl_handle_pack(h, f)	(uint16_t)((h & 0x0fff)|(f << 12))
1718 #define acl_handle(h)		(h & 0x0fff)
1719 #define acl_flags(h)		(h >> 12)
1720 
1721 #endif /* _NO_HCI_DEFS */
1722 
1723 /* HCI Socket options */
1724 #define HCI_DATA_DIR	1
1725 #define HCI_FILTER	2
1726 #define HCI_TIME_STAMP	3
1727 
1728 /* HCI CMSG flags */
1729 #define HCI_CMSG_DIR	0x0001
1730 #define HCI_CMSG_TSTAMP	0x0002
1731 
1732 struct sockaddr_hci {
1733 	sa_family_t	hci_family;
1734 	unsigned short	hci_dev;
1735 };
1736 #define HCI_DEV_NONE	0xffff
1737 
1738 struct hci_filter {
1739 	uint32_t type_mask;
1740 	uint32_t event_mask[2];
1741 	uint16_t opcode;
1742 };
1743 
1744 #define HCI_FLT_TYPE_BITS	31
1745 #define HCI_FLT_EVENT_BITS	63
1746 #define HCI_FLT_OGF_BITS	63
1747 #define HCI_FLT_OCF_BITS	127
1748 
1749 /* Ioctl requests structures */
1750 struct hci_dev_stats {
1751 	uint32_t err_rx;
1752 	uint32_t err_tx;
1753 	uint32_t cmd_tx;
1754 	uint32_t evt_rx;
1755 	uint32_t acl_tx;
1756 	uint32_t acl_rx;
1757 	uint32_t sco_tx;
1758 	uint32_t sco_rx;
1759 	uint32_t byte_rx;
1760 	uint32_t byte_tx;
1761 };
1762 
1763 struct hci_dev_info {
1764 	uint16_t dev_id;
1765 	char     name[8];
1766 
1767 	bdaddr_t bdaddr;
1768 
1769 	uint32_t flags;
1770 	uint8_t  type;
1771 
1772 	uint8_t  features[8];
1773 
1774 	uint32_t pkt_type;
1775 	uint32_t link_policy;
1776 	uint32_t link_mode;
1777 
1778 	uint16_t acl_mtu;
1779 	uint16_t acl_pkts;
1780 	uint16_t sco_mtu;
1781 	uint16_t sco_pkts;
1782 
1783 	struct   hci_dev_stats stat;
1784 };
1785 
1786 struct hci_conn_info {
1787 	uint16_t handle;
1788 	bdaddr_t bdaddr;
1789 	uint8_t  type;
1790 	uint8_t	 out;
1791 	uint16_t state;
1792 	uint32_t link_mode;
1793 };
1794 
1795 struct hci_dev_req {
1796 	uint16_t dev_id;
1797 	uint32_t dev_opt;
1798 };
1799 
1800 struct hci_dev_list_req {
1801 	uint16_t dev_num;
1802 	struct hci_dev_req dev_req[0];	/* hci_dev_req structures */
1803 };
1804 
1805 struct hci_conn_list_req {
1806 	uint16_t dev_id;
1807 	uint16_t conn_num;
1808 	struct hci_conn_info conn_info[0];
1809 };
1810 
1811 struct hci_conn_info_req {
1812 	bdaddr_t bdaddr;
1813 	uint8_t  type;
1814 	struct hci_conn_info conn_info[0];
1815 };
1816 
1817 struct hci_auth_info_req {
1818 	bdaddr_t bdaddr;
1819 	uint8_t  type;
1820 };
1821 
1822 struct hci_inquiry_req {
1823 	uint16_t dev_id;
1824 	uint16_t flags;
1825 	uint8_t  lap[3];
1826 	uint8_t  length;
1827 	uint8_t  num_rsp;
1828 };
1829 #define IREQ_CACHE_FLUSH 0x0001
1830 
1831 struct hci_remotename_req {
1832 	uint16_t dev_id;
1833 	uint16_t flags;
1834 	bdaddr_t bdaddr;
1835 	uint8_t  name[248];
1836 };
1837 
1838 #ifdef __cplusplus
1839 }
1840 #endif
1841 
1842 #endif /* __HCI_H */
1843