tizen 2.3.1 release
[framework/connectivity/bluez.git] / lib / hci.h
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-2010  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        (1492 + 4)
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 bus 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 #ifdef __TIZEN_PATCH__
60 #define HCI_SMD         7
61 #endif
62
63 /* HCI controller types */
64 #define HCI_BREDR       0x00
65 #define HCI_AMP         0x01
66
67 /* HCI device flags */
68 enum {
69         HCI_UP,
70         HCI_INIT,
71         HCI_RUNNING,
72
73         HCI_PSCAN,
74         HCI_ISCAN,
75         HCI_AUTH,
76         HCI_ENCRYPT,
77         HCI_INQUIRY,
78
79         HCI_RAW,
80 };
81
82 /* LE address type */
83 enum {
84         LE_PUBLIC_ADDRESS = 0x00,
85         LE_RANDOM_ADDRESS = 0x01
86 };
87
88 /* HCI ioctl defines */
89 #define HCIDEVUP        _IOW('H', 201, int)
90 #define HCIDEVDOWN      _IOW('H', 202, int)
91 #define HCIDEVRESET     _IOW('H', 203, int)
92 #define HCIDEVRESTAT    _IOW('H', 204, int)
93
94 #define HCIGETDEVLIST   _IOR('H', 210, int)
95 #define HCIGETDEVINFO   _IOR('H', 211, int)
96 #define HCIGETCONNLIST  _IOR('H', 212, int)
97 #define HCIGETCONNINFO  _IOR('H', 213, int)
98 #define HCIGETAUTHINFO  _IOR('H', 215, int)
99
100 #define HCISETRAW       _IOW('H', 220, int)
101 #define HCISETSCAN      _IOW('H', 221, int)
102 #define HCISETAUTH      _IOW('H', 222, int)
103 #define HCISETENCRYPT   _IOW('H', 223, int)
104 #define HCISETPTYPE     _IOW('H', 224, int)
105 #define HCISETLINKPOL   _IOW('H', 225, int)
106 #define HCISETLINKMODE  _IOW('H', 226, int)
107 #define HCISETACLMTU    _IOW('H', 227, int)
108 #define HCISETSCOMTU    _IOW('H', 228, int)
109
110 #define HCIBLOCKADDR    _IOW('H', 230, int)
111 #define HCIUNBLOCKADDR  _IOW('H', 231, int)
112
113 #define HCIINQUIRY      _IOR('H', 240, int)
114
115 #ifndef __NO_HCI_DEFS
116
117 /* HCI Packet types */
118 #define HCI_COMMAND_PKT         0x01
119 #define HCI_ACLDATA_PKT         0x02
120 #define HCI_SCODATA_PKT         0x03
121 #define HCI_EVENT_PKT           0x04
122 #define HCI_VENDOR_PKT          0xff
123
124 /* HCI Packet types */
125 #define HCI_2DH1        0x0002
126 #define HCI_3DH1        0x0004
127 #define HCI_DM1         0x0008
128 #define HCI_DH1         0x0010
129 #define HCI_2DH3        0x0100
130 #define HCI_3DH3        0x0200
131 #define HCI_DM3         0x0400
132 #define HCI_DH3         0x0800
133 #define HCI_2DH5        0x1000
134 #define HCI_3DH5        0x2000
135 #define HCI_DM5         0x4000
136 #define HCI_DH5         0x8000
137
138 #define HCI_HV1         0x0020
139 #define HCI_HV2         0x0040
140 #define HCI_HV3         0x0080
141
142 #define HCI_EV3         0x0008
143 #define HCI_EV4         0x0010
144 #define HCI_EV5         0x0020
145 #define HCI_2EV3        0x0040
146 #define HCI_3EV3        0x0080
147 #define HCI_2EV5        0x0100
148 #define HCI_3EV5        0x0200
149
150 #define SCO_PTYPE_MASK  (HCI_HV1 | HCI_HV2 | HCI_HV3)
151 #define ACL_PTYPE_MASK  (HCI_DM1 | HCI_DH1 | HCI_DM3 | HCI_DH3 | HCI_DM5 | HCI_DH5)
152
153 /* HCI Error codes */
154 #define HCI_UNKNOWN_COMMAND                     0x01
155 #define HCI_NO_CONNECTION                       0x02
156 #define HCI_HARDWARE_FAILURE                    0x03
157 #define HCI_PAGE_TIMEOUT                        0x04
158 #define HCI_AUTHENTICATION_FAILURE              0x05
159 #define HCI_PIN_OR_KEY_MISSING                  0x06
160 #define HCI_MEMORY_FULL                         0x07
161 #define HCI_CONNECTION_TIMEOUT                  0x08
162 #define HCI_MAX_NUMBER_OF_CONNECTIONS           0x09
163 #define HCI_MAX_NUMBER_OF_SCO_CONNECTIONS       0x0a
164 #define HCI_ACL_CONNECTION_EXISTS               0x0b
165 #define HCI_COMMAND_DISALLOWED                  0x0c
166 #define HCI_REJECTED_LIMITED_RESOURCES          0x0d
167 #define HCI_REJECTED_SECURITY                   0x0e
168 #define HCI_REJECTED_PERSONAL                   0x0f
169 #define HCI_HOST_TIMEOUT                        0x10
170 #define HCI_UNSUPPORTED_FEATURE                 0x11
171 #define HCI_INVALID_PARAMETERS                  0x12
172 #define HCI_OE_USER_ENDED_CONNECTION            0x13
173 #define HCI_OE_LOW_RESOURCES                    0x14
174 #define HCI_OE_POWER_OFF                        0x15
175 #define HCI_CONNECTION_TERMINATED               0x16
176 #define HCI_REPEATED_ATTEMPTS                   0x17
177 #define HCI_PAIRING_NOT_ALLOWED                 0x18
178 #define HCI_UNKNOWN_LMP_PDU                     0x19
179 #define HCI_UNSUPPORTED_REMOTE_FEATURE          0x1a
180 #define HCI_SCO_OFFSET_REJECTED                 0x1b
181 #define HCI_SCO_INTERVAL_REJECTED               0x1c
182 #define HCI_AIR_MODE_REJECTED                   0x1d
183 #define HCI_INVALID_LMP_PARAMETERS              0x1e
184 #define HCI_UNSPECIFIED_ERROR                   0x1f
185 #define HCI_UNSUPPORTED_LMP_PARAMETER_VALUE     0x20
186 #define HCI_ROLE_CHANGE_NOT_ALLOWED             0x21
187 #define HCI_LMP_RESPONSE_TIMEOUT                0x22
188 #define HCI_LMP_ERROR_TRANSACTION_COLLISION     0x23
189 #define HCI_LMP_PDU_NOT_ALLOWED                 0x24
190 #define HCI_ENCRYPTION_MODE_NOT_ACCEPTED        0x25
191 #define HCI_UNIT_LINK_KEY_USED                  0x26
192 #define HCI_QOS_NOT_SUPPORTED                   0x27
193 #define HCI_INSTANT_PASSED                      0x28
194 #define HCI_PAIRING_NOT_SUPPORTED               0x29
195 #define HCI_TRANSACTION_COLLISION               0x2a
196 #define HCI_QOS_UNACCEPTABLE_PARAMETER          0x2c
197 #define HCI_QOS_REJECTED                        0x2d
198 #define HCI_CLASSIFICATION_NOT_SUPPORTED        0x2e
199 #define HCI_INSUFFICIENT_SECURITY               0x2f
200 #define HCI_PARAMETER_OUT_OF_RANGE              0x30
201 #define HCI_ROLE_SWITCH_PENDING                 0x32
202 #define HCI_SLOT_VIOLATION                      0x34
203 #define HCI_ROLE_SWITCH_FAILED                  0x35
204 #define HCI_EIR_TOO_LARGE                       0x36
205 #define HCI_SIMPLE_PAIRING_NOT_SUPPORTED        0x37
206 #define HCI_HOST_BUSY_PAIRING                   0x38
207
208 /* ACL flags */
209 #define ACL_START_NO_FLUSH      0x00
210 #define ACL_CONT                0x01
211 #define ACL_START               0x02
212 #define ACL_ACTIVE_BCAST        0x04
213 #define ACL_PICO_BCAST          0x08
214
215 /* Baseband links */
216 #define SCO_LINK        0x00
217 #define ACL_LINK        0x01
218 #define ESCO_LINK       0x02
219
220 /* LMP features */
221 #define LMP_3SLOT       0x01
222 #define LMP_5SLOT       0x02
223 #define LMP_ENCRYPT     0x04
224 #define LMP_SOFFSET     0x08
225 #define LMP_TACCURACY   0x10
226 #define LMP_RSWITCH     0x20
227 #define LMP_HOLD        0x40
228 #define LMP_SNIFF       0x80
229
230 #define LMP_PARK        0x01
231 #define LMP_RSSI        0x02
232 #define LMP_QUALITY     0x04
233 #define LMP_SCO         0x08
234 #define LMP_HV2         0x10
235 #define LMP_HV3         0x20
236 #define LMP_ULAW        0x40
237 #define LMP_ALAW        0x80
238
239 #define LMP_CVSD        0x01
240 #define LMP_PSCHEME     0x02
241 #define LMP_PCONTROL    0x04
242 #define LMP_TRSP_SCO    0x08
243 #define LMP_BCAST_ENC   0x80
244
245 #define LMP_EDR_ACL_2M  0x02
246 #define LMP_EDR_ACL_3M  0x04
247 #define LMP_ENH_ISCAN   0x08
248 #define LMP_ILACE_ISCAN 0x10
249 #define LMP_ILACE_PSCAN 0x20
250 #define LMP_RSSI_INQ    0x40
251 #define LMP_ESCO        0x80
252
253 #define LMP_EV4         0x01
254 #define LMP_EV5         0x02
255 #define LMP_AFH_CAP_SLV 0x08
256 #define LMP_AFH_CLS_SLV 0x10
257 #define LMP_NO_BREDR    0x20
258 #define LMP_LE          0x40
259 #define LMP_EDR_3SLOT   0x80
260
261 #define LMP_EDR_5SLOT   0x01
262 #define LMP_SNIFF_SUBR  0x02
263 #define LMP_PAUSE_ENC   0x04
264 #define LMP_AFH_CAP_MST 0x08
265 #define LMP_AFH_CLS_MST 0x10
266 #define LMP_EDR_ESCO_2M 0x20
267 #define LMP_EDR_ESCO_3M 0x40
268 #define LMP_EDR_3S_ESCO 0x80
269
270 #define LMP_EXT_INQ     0x01
271 #define LMP_LE_BREDR    0x02
272 #define LMP_SIMPLE_PAIR 0x08
273 #define LMP_ENCAPS_PDU  0x10
274 #define LMP_ERR_DAT_REP 0x20
275 #define LMP_NFLUSH_PKTS 0x40
276
277 #define LMP_LSTO        0x01
278 #define LMP_INQ_TX_PWR  0x02
279 #define LMP_EPC         0x04
280 #define LMP_EXT_FEAT    0x80
281
282 /* Extended LMP features */
283 #define LMP_HOST_SSP            0x01
284 #define LMP_HOST_LE             0x02
285 #define LMP_HOST_LE_BREDR       0x04
286
287 /* Link policies */
288 #define HCI_LP_RSWITCH  0x0001
289 #define HCI_LP_HOLD     0x0002
290 #define HCI_LP_SNIFF    0x0004
291 #define HCI_LP_PARK     0x0008
292
293 /* Link mode */
294 #define HCI_LM_ACCEPT   0x8000
295 #define HCI_LM_MASTER   0x0001
296 #define HCI_LM_AUTH     0x0002
297 #define HCI_LM_ENCRYPT  0x0004
298 #define HCI_LM_TRUSTED  0x0008
299 #define HCI_LM_RELIABLE 0x0010
300 #define HCI_LM_SECURE   0x0020
301
302 /* Link Key types */
303 #define HCI_LK_COMBINATION              0x00
304 #define HCI_LK_LOCAL_UNIT               0x01
305 #define HCI_LK_REMOTE_UNIT              0x02
306 #define HCI_LK_DEBUG_COMBINATION        0x03
307 #define HCI_LK_UNAUTH_COMBINATION       0x04
308 #define HCI_LK_AUTH_COMBINATION         0x05
309 #define HCI_LK_CHANGED_COMBINATION      0x06
310 #define HCI_LK_INVALID                  0xFF
311
312 /* -----  HCI Commands ----- */
313
314 /* Link Control */
315 #define OGF_LINK_CTL            0x01
316
317 #define OCF_INQUIRY                     0x0001
318 typedef struct {
319         uint8_t         lap[3];
320         uint8_t         length;         /* 1.28s units */
321         uint8_t         num_rsp;
322 } __attribute__ ((packed)) inquiry_cp;
323 #define INQUIRY_CP_SIZE 5
324
325 typedef struct {
326         uint8_t         status;
327         bdaddr_t        bdaddr;
328 } __attribute__ ((packed)) status_bdaddr_rp;
329 #define STATUS_BDADDR_RP_SIZE 7
330
331 #define OCF_INQUIRY_CANCEL              0x0002
332
333 #define OCF_PERIODIC_INQUIRY            0x0003
334 typedef struct {
335         uint16_t        max_period;     /* 1.28s units */
336         uint16_t        min_period;     /* 1.28s units */
337         uint8_t         lap[3];
338         uint8_t         length;         /* 1.28s units */
339         uint8_t         num_rsp;
340 } __attribute__ ((packed)) periodic_inquiry_cp;
341 #define PERIODIC_INQUIRY_CP_SIZE 9
342
343 #define OCF_EXIT_PERIODIC_INQUIRY       0x0004
344
345 #define OCF_CREATE_CONN                 0x0005
346 typedef struct {
347         bdaddr_t        bdaddr;
348         uint16_t        pkt_type;
349         uint8_t         pscan_rep_mode;
350         uint8_t         pscan_mode;
351         uint16_t        clock_offset;
352         uint8_t         role_switch;
353 } __attribute__ ((packed)) create_conn_cp;
354 #define CREATE_CONN_CP_SIZE 13
355
356 #define OCF_DISCONNECT                  0x0006
357 typedef struct {
358         uint16_t        handle;
359         uint8_t         reason;
360 } __attribute__ ((packed)) disconnect_cp;
361 #define DISCONNECT_CP_SIZE 3
362
363 #define OCF_ADD_SCO                     0x0007
364 typedef struct {
365         uint16_t        handle;
366         uint16_t        pkt_type;
367 } __attribute__ ((packed)) add_sco_cp;
368 #define ADD_SCO_CP_SIZE 4
369
370 #define OCF_CREATE_CONN_CANCEL          0x0008
371 typedef struct {
372         bdaddr_t        bdaddr;
373 } __attribute__ ((packed)) create_conn_cancel_cp;
374 #define CREATE_CONN_CANCEL_CP_SIZE 6
375
376 #define OCF_ACCEPT_CONN_REQ             0x0009
377 typedef struct {
378         bdaddr_t        bdaddr;
379         uint8_t         role;
380 } __attribute__ ((packed)) accept_conn_req_cp;
381 #define ACCEPT_CONN_REQ_CP_SIZE 7
382
383 #define OCF_REJECT_CONN_REQ             0x000A
384 typedef struct {
385         bdaddr_t        bdaddr;
386         uint8_t         reason;
387 } __attribute__ ((packed)) reject_conn_req_cp;
388 #define REJECT_CONN_REQ_CP_SIZE 7
389
390 #define OCF_LINK_KEY_REPLY              0x000B
391 typedef struct {
392         bdaddr_t        bdaddr;
393         uint8_t         link_key[16];
394 } __attribute__ ((packed)) link_key_reply_cp;
395 #define LINK_KEY_REPLY_CP_SIZE 22
396
397 #define OCF_LINK_KEY_NEG_REPLY          0x000C
398
399 #define OCF_PIN_CODE_REPLY              0x000D
400 typedef struct {
401         bdaddr_t        bdaddr;
402         uint8_t         pin_len;
403         uint8_t         pin_code[16];
404 } __attribute__ ((packed)) pin_code_reply_cp;
405 #define PIN_CODE_REPLY_CP_SIZE 23
406
407 #define OCF_PIN_CODE_NEG_REPLY          0x000E
408
409 #define OCF_SET_CONN_PTYPE              0x000F
410 typedef struct {
411         uint16_t         handle;
412         uint16_t         pkt_type;
413 } __attribute__ ((packed)) set_conn_ptype_cp;
414 #define SET_CONN_PTYPE_CP_SIZE 4
415
416 #define OCF_AUTH_REQUESTED              0x0011
417 typedef struct {
418         uint16_t         handle;
419 } __attribute__ ((packed)) auth_requested_cp;
420 #define AUTH_REQUESTED_CP_SIZE 2
421
422 #define OCF_SET_CONN_ENCRYPT            0x0013
423 typedef struct {
424         uint16_t        handle;
425         uint8_t         encrypt;
426 } __attribute__ ((packed)) set_conn_encrypt_cp;
427 #define SET_CONN_ENCRYPT_CP_SIZE 3
428
429 #define OCF_CHANGE_CONN_LINK_KEY        0x0015
430 typedef struct {
431         uint16_t        handle;
432 } __attribute__ ((packed)) change_conn_link_key_cp;
433 #define CHANGE_CONN_LINK_KEY_CP_SIZE 2
434
435 #define OCF_MASTER_LINK_KEY             0x0017
436 typedef struct {
437         uint8_t         key_flag;
438 } __attribute__ ((packed)) master_link_key_cp;
439 #define MASTER_LINK_KEY_CP_SIZE 1
440
441 #define OCF_REMOTE_NAME_REQ             0x0019
442 typedef struct {
443         bdaddr_t        bdaddr;
444         uint8_t         pscan_rep_mode;
445         uint8_t         pscan_mode;
446         uint16_t        clock_offset;
447 } __attribute__ ((packed)) remote_name_req_cp;
448 #define REMOTE_NAME_REQ_CP_SIZE 10
449
450 #define OCF_REMOTE_NAME_REQ_CANCEL      0x001A
451 typedef struct {
452         bdaddr_t        bdaddr;
453 } __attribute__ ((packed)) remote_name_req_cancel_cp;
454 #define REMOTE_NAME_REQ_CANCEL_CP_SIZE 6
455
456 #define OCF_READ_REMOTE_FEATURES        0x001B
457 typedef struct {
458         uint16_t        handle;
459 } __attribute__ ((packed)) read_remote_features_cp;
460 #define READ_REMOTE_FEATURES_CP_SIZE 2
461
462 #define OCF_READ_REMOTE_EXT_FEATURES    0x001C
463 typedef struct {
464         uint16_t        handle;
465         uint8_t         page_num;
466 } __attribute__ ((packed)) read_remote_ext_features_cp;
467 #define READ_REMOTE_EXT_FEATURES_CP_SIZE 3
468
469 #define OCF_READ_REMOTE_VERSION         0x001D
470 typedef struct {
471         uint16_t        handle;
472 } __attribute__ ((packed)) read_remote_version_cp;
473 #define READ_REMOTE_VERSION_CP_SIZE 2
474
475 #define OCF_READ_CLOCK_OFFSET           0x001F
476 typedef struct {
477         uint16_t        handle;
478 } __attribute__ ((packed)) read_clock_offset_cp;
479 #define READ_CLOCK_OFFSET_CP_SIZE 2
480
481 #define OCF_READ_LMP_HANDLE             0x0020
482
483 #define OCF_SETUP_SYNC_CONN             0x0028
484 typedef struct {
485         uint16_t        handle;
486         uint32_t        tx_bandwith;
487         uint32_t        rx_bandwith;
488         uint16_t        max_latency;
489         uint16_t        voice_setting;
490         uint8_t         retrans_effort;
491         uint16_t        pkt_type;
492 } __attribute__ ((packed)) setup_sync_conn_cp;
493 #define SETUP_SYNC_CONN_CP_SIZE 17
494
495 #define OCF_ACCEPT_SYNC_CONN_REQ        0x0029
496 typedef struct {
497         bdaddr_t        bdaddr;
498         uint32_t        tx_bandwith;
499         uint32_t        rx_bandwith;
500         uint16_t        max_latency;
501         uint16_t        voice_setting;
502         uint8_t         retrans_effort;
503         uint16_t        pkt_type;
504 } __attribute__ ((packed)) accept_sync_conn_req_cp;
505 #define ACCEPT_SYNC_CONN_REQ_CP_SIZE 21
506
507 #define OCF_REJECT_SYNC_CONN_REQ        0x002A
508 typedef struct {
509         bdaddr_t        bdaddr;
510         uint8_t         reason;
511 } __attribute__ ((packed)) reject_sync_conn_req_cp;
512 #define REJECT_SYNC_CONN_REQ_CP_SIZE 7
513
514 #define OCF_IO_CAPABILITY_REPLY         0x002B
515 typedef struct {
516         bdaddr_t        bdaddr;
517         uint8_t         capability;
518         uint8_t         oob_data;
519         uint8_t         authentication;
520 } __attribute__ ((packed)) io_capability_reply_cp;
521 #define IO_CAPABILITY_REPLY_CP_SIZE 9
522
523 #define OCF_USER_CONFIRM_REPLY          0x002C
524 typedef struct {
525         bdaddr_t        bdaddr;
526 } __attribute__ ((packed)) user_confirm_reply_cp;
527 #define USER_CONFIRM_REPLY_CP_SIZE 6
528
529 #define OCF_USER_CONFIRM_NEG_REPLY      0x002D
530
531 #define OCF_USER_PASSKEY_REPLY          0x002E
532 typedef struct {
533         bdaddr_t        bdaddr;
534         uint32_t        passkey;
535 } __attribute__ ((packed)) user_passkey_reply_cp;
536 #define USER_PASSKEY_REPLY_CP_SIZE 10
537
538 #define OCF_USER_PASSKEY_NEG_REPLY      0x002F
539
540 #define OCF_REMOTE_OOB_DATA_REPLY       0x0030
541 typedef struct {
542         bdaddr_t        bdaddr;
543         uint8_t         hash[16];
544         uint8_t         randomizer[16];
545 } __attribute__ ((packed)) remote_oob_data_reply_cp;
546 #define REMOTE_OOB_DATA_REPLY_CP_SIZE 38
547
548 #define OCF_REMOTE_OOB_DATA_NEG_REPLY   0x0033
549
550 #define OCF_IO_CAPABILITY_NEG_REPLY     0x0034
551 typedef struct {
552         bdaddr_t        bdaddr;
553         uint8_t         reason;
554 } __attribute__ ((packed)) io_capability_neg_reply_cp;
555 #define IO_CAPABILITY_NEG_REPLY_CP_SIZE 7
556
557 #define OCF_CREATE_PHYSICAL_LINK                0x0035
558 typedef struct {
559         uint8_t         handle;
560         uint8_t         key_length;
561         uint8_t         key_type;
562         uint8_t         key[32];
563 } __attribute__ ((packed)) create_physical_link_cp;
564 #define CREATE_PHYSICAL_LINK_CP_SIZE 35
565
566 #define OCF_ACCEPT_PHYSICAL_LINK                0x0036
567 typedef struct {
568         uint8_t         handle;
569         uint8_t         key_length;
570         uint8_t         key_type;
571         uint8_t         key[32];
572 } __attribute__ ((packed)) accept_physical_link_cp;
573 #define ACCEPT_PHYSICAL_LINK_CP_SIZE 35
574
575 #define OCF_DISCONNECT_PHYSICAL_LINK            0x0037
576 typedef struct {
577         uint8_t         handle;
578         uint8_t         reason;
579 } __attribute__ ((packed)) disconnect_physical_link_cp;
580 #define DISCONNECT_PHYSICAL_LINK_CP_SIZE 2
581
582 #define OCF_CREATE_LOGICAL_LINK         0x0038
583 typedef struct {
584         uint8_t         handle;
585         uint8_t         tx_flow[16];
586         uint8_t         rx_flow[16];
587 } __attribute__ ((packed)) create_logical_link_cp;
588 #define CREATE_LOGICAL_LINK_CP_SIZE 33
589
590 #define OCF_ACCEPT_LOGICAL_LINK         0x0039
591
592 #define OCF_DISCONNECT_LOGICAL_LINK             0x003A
593 typedef struct {
594         uint16_t        handle;
595 } __attribute__ ((packed)) disconnect_logical_link_cp;
596 #define DISCONNECT_LOGICAL_LINK_CP_SIZE 2
597
598 #define OCF_LOGICAL_LINK_CANCEL         0x003B
599 typedef struct {
600         uint8_t         handle;
601         uint8_t         tx_flow_id;
602 } __attribute__ ((packed)) cancel_logical_link_cp;
603 #define LOGICAL_LINK_CANCEL_CP_SIZE 2
604 typedef struct {
605         uint8_t         status;
606         uint8_t         handle;
607         uint8_t         tx_flow_id;
608 } __attribute__ ((packed)) cancel_logical_link_rp;
609 #define LOGICAL_LINK_CANCEL_RP_SIZE 3
610
611 #define OCF_FLOW_SPEC_MODIFY            0x003C
612
613 /* Link Policy */
614 #define OGF_LINK_POLICY         0x02
615
616 #define OCF_HOLD_MODE                   0x0001
617 typedef struct {
618         uint16_t        handle;
619         uint16_t        max_interval;
620         uint16_t        min_interval;
621 } __attribute__ ((packed)) hold_mode_cp;
622 #define HOLD_MODE_CP_SIZE 6
623
624 #define OCF_SNIFF_MODE                  0x0003
625 typedef struct {
626         uint16_t        handle;
627         uint16_t        max_interval;
628         uint16_t        min_interval;
629         uint16_t        attempt;
630         uint16_t        timeout;
631 } __attribute__ ((packed)) sniff_mode_cp;
632 #define SNIFF_MODE_CP_SIZE 10
633
634 #define OCF_EXIT_SNIFF_MODE             0x0004
635 typedef struct {
636         uint16_t        handle;
637 } __attribute__ ((packed)) exit_sniff_mode_cp;
638 #define EXIT_SNIFF_MODE_CP_SIZE 2
639
640 #define OCF_PARK_MODE                   0x0005
641 typedef struct {
642         uint16_t        handle;
643         uint16_t        max_interval;
644         uint16_t        min_interval;
645 } __attribute__ ((packed)) park_mode_cp;
646 #define PARK_MODE_CP_SIZE 6
647
648 #define OCF_EXIT_PARK_MODE              0x0006
649 typedef struct {
650         uint16_t        handle;
651 } __attribute__ ((packed)) exit_park_mode_cp;
652 #define EXIT_PARK_MODE_CP_SIZE 2
653
654 #define OCF_QOS_SETUP                   0x0007
655 typedef struct {
656         uint8_t         service_type;           /* 1 = best effort */
657         uint32_t        token_rate;             /* Byte per seconds */
658         uint32_t        peak_bandwidth;         /* Byte per seconds */
659         uint32_t        latency;                /* Microseconds */
660         uint32_t        delay_variation;        /* Microseconds */
661 } __attribute__ ((packed)) hci_qos;
662 #define HCI_QOS_CP_SIZE 17
663 typedef struct {
664         uint16_t        handle;
665         uint8_t         flags;                  /* Reserved */
666         hci_qos         qos;
667 } __attribute__ ((packed)) qos_setup_cp;
668 #define QOS_SETUP_CP_SIZE (3 + HCI_QOS_CP_SIZE)
669
670 #define OCF_ROLE_DISCOVERY              0x0009
671 typedef struct {
672         uint16_t        handle;
673 } __attribute__ ((packed)) role_discovery_cp;
674 #define ROLE_DISCOVERY_CP_SIZE 2
675 typedef struct {
676         uint8_t         status;
677         uint16_t        handle;
678         uint8_t         role;
679 } __attribute__ ((packed)) role_discovery_rp;
680 #define ROLE_DISCOVERY_RP_SIZE 4
681
682 #define OCF_SWITCH_ROLE                 0x000B
683 typedef struct {
684         bdaddr_t        bdaddr;
685         uint8_t         role;
686 } __attribute__ ((packed)) switch_role_cp;
687 #define SWITCH_ROLE_CP_SIZE 7
688
689 #define OCF_READ_LINK_POLICY            0x000C
690 typedef struct {
691         uint16_t        handle;
692 } __attribute__ ((packed)) read_link_policy_cp;
693 #define READ_LINK_POLICY_CP_SIZE 2
694 typedef struct {
695         uint8_t         status;
696         uint16_t        handle;
697         uint16_t        policy;
698 } __attribute__ ((packed)) read_link_policy_rp;
699 #define READ_LINK_POLICY_RP_SIZE 5
700
701 #define OCF_WRITE_LINK_POLICY           0x000D
702 typedef struct {
703         uint16_t        handle;
704         uint16_t        policy;
705 } __attribute__ ((packed)) write_link_policy_cp;
706 #define WRITE_LINK_POLICY_CP_SIZE 4
707 typedef struct {
708         uint8_t         status;
709         uint16_t        handle;
710 } __attribute__ ((packed)) write_link_policy_rp;
711 #define WRITE_LINK_POLICY_RP_SIZE 3
712
713 #define OCF_READ_DEFAULT_LINK_POLICY    0x000E
714
715 #define OCF_WRITE_DEFAULT_LINK_POLICY   0x000F
716
717 #define OCF_FLOW_SPECIFICATION          0x0010
718
719 #define OCF_SNIFF_SUBRATING             0x0011
720 typedef struct {
721         uint16_t        handle;
722         uint16_t        max_latency;
723         uint16_t        min_remote_timeout;
724         uint16_t        min_local_timeout;
725 } __attribute__ ((packed)) sniff_subrating_cp;
726 #define SNIFF_SUBRATING_CP_SIZE 8
727
728 /* Host Controller and Baseband */
729 #define OGF_HOST_CTL            0x03
730
731 #define OCF_SET_EVENT_MASK              0x0001
732 typedef struct {
733         uint8_t         mask[8];
734 } __attribute__ ((packed)) set_event_mask_cp;
735 #define SET_EVENT_MASK_CP_SIZE 8
736
737 #define OCF_RESET                       0x0003
738
739 #define OCF_SET_EVENT_FLT               0x0005
740 typedef struct {
741         uint8_t         flt_type;
742         uint8_t         cond_type;
743         uint8_t         condition[0];
744 } __attribute__ ((packed)) set_event_flt_cp;
745 #define SET_EVENT_FLT_CP_SIZE 2
746
747 /* Filter types */
748 #define FLT_CLEAR_ALL                   0x00
749 #define FLT_INQ_RESULT                  0x01
750 #define FLT_CONN_SETUP                  0x02
751 /* INQ_RESULT Condition types */
752 #define INQ_RESULT_RETURN_ALL           0x00
753 #define INQ_RESULT_RETURN_CLASS         0x01
754 #define INQ_RESULT_RETURN_BDADDR        0x02
755 /* CONN_SETUP Condition types */
756 #define CONN_SETUP_ALLOW_ALL            0x00
757 #define CONN_SETUP_ALLOW_CLASS          0x01
758 #define CONN_SETUP_ALLOW_BDADDR         0x02
759 /* CONN_SETUP Conditions */
760 #define CONN_SETUP_AUTO_OFF             0x01
761 #define CONN_SETUP_AUTO_ON              0x02
762
763 #define OCF_FLUSH                       0x0008
764
765 #define OCF_READ_PIN_TYPE               0x0009
766 typedef struct {
767         uint8_t         status;
768         uint8_t         pin_type;
769 } __attribute__ ((packed)) read_pin_type_rp;
770 #define READ_PIN_TYPE_RP_SIZE 2
771
772 #define OCF_WRITE_PIN_TYPE              0x000A
773 typedef struct {
774         uint8_t         pin_type;
775 } __attribute__ ((packed)) write_pin_type_cp;
776 #define WRITE_PIN_TYPE_CP_SIZE 1
777
778 #define OCF_CREATE_NEW_UNIT_KEY         0x000B
779
780 #define OCF_READ_STORED_LINK_KEY        0x000D
781 typedef struct {
782         bdaddr_t        bdaddr;
783         uint8_t         read_all;
784 } __attribute__ ((packed)) read_stored_link_key_cp;
785 #define READ_STORED_LINK_KEY_CP_SIZE 7
786 typedef struct {
787         uint8_t         status;
788         uint16_t        max_keys;
789         uint16_t        num_keys;
790 } __attribute__ ((packed)) read_stored_link_key_rp;
791 #define READ_STORED_LINK_KEY_RP_SIZE 5
792
793 #define OCF_WRITE_STORED_LINK_KEY       0x0011
794 typedef struct {
795         uint8_t         num_keys;
796         /* variable length part */
797 } __attribute__ ((packed)) write_stored_link_key_cp;
798 #define WRITE_STORED_LINK_KEY_CP_SIZE 1
799 typedef struct {
800         uint8_t         status;
801         uint8_t         num_keys;
802 } __attribute__ ((packed)) write_stored_link_key_rp;
803 #define READ_WRITE_LINK_KEY_RP_SIZE 2
804
805 #define OCF_DELETE_STORED_LINK_KEY      0x0012
806 typedef struct {
807         bdaddr_t        bdaddr;
808         uint8_t         delete_all;
809 } __attribute__ ((packed)) delete_stored_link_key_cp;
810 #define DELETE_STORED_LINK_KEY_CP_SIZE 7
811 typedef struct {
812         uint8_t         status;
813         uint16_t        num_keys;
814 } __attribute__ ((packed)) delete_stored_link_key_rp;
815 #define DELETE_STORED_LINK_KEY_RP_SIZE 3
816
817 #define HCI_MAX_NAME_LENGTH             248
818
819 #define OCF_CHANGE_LOCAL_NAME           0x0013
820 typedef struct {
821         uint8_t         name[HCI_MAX_NAME_LENGTH];
822 } __attribute__ ((packed)) change_local_name_cp;
823 #define CHANGE_LOCAL_NAME_CP_SIZE 248
824
825 #define OCF_READ_LOCAL_NAME             0x0014
826 typedef struct {
827         uint8_t         status;
828         uint8_t         name[HCI_MAX_NAME_LENGTH];
829 } __attribute__ ((packed)) read_local_name_rp;
830 #define READ_LOCAL_NAME_RP_SIZE 249
831
832 #define OCF_READ_CONN_ACCEPT_TIMEOUT    0x0015
833 typedef struct {
834         uint8_t         status;
835         uint16_t        timeout;
836 } __attribute__ ((packed)) read_conn_accept_timeout_rp;
837 #define READ_CONN_ACCEPT_TIMEOUT_RP_SIZE 3
838
839 #define OCF_WRITE_CONN_ACCEPT_TIMEOUT   0x0016
840 typedef struct {
841         uint16_t        timeout;
842 } __attribute__ ((packed)) write_conn_accept_timeout_cp;
843 #define WRITE_CONN_ACCEPT_TIMEOUT_CP_SIZE 2
844
845 #define OCF_READ_PAGE_TIMEOUT           0x0017
846 typedef struct {
847         uint8_t         status;
848         uint16_t        timeout;
849 } __attribute__ ((packed)) read_page_timeout_rp;
850 #define READ_PAGE_TIMEOUT_RP_SIZE 3
851
852 #define OCF_WRITE_PAGE_TIMEOUT          0x0018
853 typedef struct {
854         uint16_t        timeout;
855 } __attribute__ ((packed)) write_page_timeout_cp;
856 #define WRITE_PAGE_TIMEOUT_CP_SIZE 2
857
858 #define OCF_READ_SCAN_ENABLE            0x0019
859 typedef struct {
860         uint8_t         status;
861         uint8_t         enable;
862 } __attribute__ ((packed)) read_scan_enable_rp;
863 #define READ_SCAN_ENABLE_RP_SIZE 2
864
865 #define OCF_WRITE_SCAN_ENABLE           0x001A
866         #define SCAN_DISABLED           0x00
867         #define SCAN_INQUIRY            0x01
868         #define SCAN_PAGE               0x02
869
870 #define OCF_READ_PAGE_ACTIVITY          0x001B
871 typedef struct {
872         uint8_t         status;
873         uint16_t        interval;
874         uint16_t        window;
875 } __attribute__ ((packed)) read_page_activity_rp;
876 #define READ_PAGE_ACTIVITY_RP_SIZE 5
877
878 #define OCF_WRITE_PAGE_ACTIVITY         0x001C
879 typedef struct {
880         uint16_t        interval;
881         uint16_t        window;
882 } __attribute__ ((packed)) write_page_activity_cp;
883 #define WRITE_PAGE_ACTIVITY_CP_SIZE 4
884
885 #define OCF_READ_INQ_ACTIVITY           0x001D
886 typedef struct {
887         uint8_t         status;
888         uint16_t        interval;
889         uint16_t        window;
890 } __attribute__ ((packed)) read_inq_activity_rp;
891 #define READ_INQ_ACTIVITY_RP_SIZE 5
892
893 #define OCF_WRITE_INQ_ACTIVITY          0x001E
894 typedef struct {
895         uint16_t        interval;
896         uint16_t        window;
897 } __attribute__ ((packed)) write_inq_activity_cp;
898 #define WRITE_INQ_ACTIVITY_CP_SIZE 4
899
900 #define OCF_READ_AUTH_ENABLE            0x001F
901
902 #define OCF_WRITE_AUTH_ENABLE           0x0020
903         #define AUTH_DISABLED           0x00
904         #define AUTH_ENABLED            0x01
905
906 #define OCF_READ_ENCRYPT_MODE           0x0021
907
908 #define OCF_WRITE_ENCRYPT_MODE          0x0022
909         #define ENCRYPT_DISABLED        0x00
910         #define ENCRYPT_P2P             0x01
911         #define ENCRYPT_BOTH            0x02
912
913 #define OCF_READ_CLASS_OF_DEV           0x0023
914 typedef struct {
915         uint8_t         status;
916         uint8_t         dev_class[3];
917 } __attribute__ ((packed)) read_class_of_dev_rp;
918 #define READ_CLASS_OF_DEV_RP_SIZE 4
919
920 #define OCF_WRITE_CLASS_OF_DEV          0x0024
921 typedef struct {
922         uint8_t         dev_class[3];
923 } __attribute__ ((packed)) write_class_of_dev_cp;
924 #define WRITE_CLASS_OF_DEV_CP_SIZE 3
925
926 #define OCF_READ_VOICE_SETTING          0x0025
927 typedef struct {
928         uint8_t         status;
929         uint16_t        voice_setting;
930 } __attribute__ ((packed)) read_voice_setting_rp;
931 #define READ_VOICE_SETTING_RP_SIZE 3
932
933 #define OCF_WRITE_VOICE_SETTING         0x0026
934 typedef struct {
935         uint16_t        voice_setting;
936 } __attribute__ ((packed)) write_voice_setting_cp;
937 #define WRITE_VOICE_SETTING_CP_SIZE 2
938
939 #define OCF_READ_AUTOMATIC_FLUSH_TIMEOUT        0x0027
940
941 #define OCF_WRITE_AUTOMATIC_FLUSH_TIMEOUT       0x0028
942
943 #define OCF_READ_NUM_BROADCAST_RETRANS  0x0029
944
945 #define OCF_WRITE_NUM_BROADCAST_RETRANS 0x002A
946
947 #define OCF_READ_HOLD_MODE_ACTIVITY     0x002B
948
949 #define OCF_WRITE_HOLD_MODE_ACTIVITY    0x002C
950
951 #define OCF_READ_TRANSMIT_POWER_LEVEL   0x002D
952 typedef struct {
953         uint16_t        handle;
954         uint8_t         type;
955 } __attribute__ ((packed)) read_transmit_power_level_cp;
956 #define READ_TRANSMIT_POWER_LEVEL_CP_SIZE 3
957 typedef struct {
958         uint8_t         status;
959         uint16_t        handle;
960         int8_t          level;
961 } __attribute__ ((packed)) read_transmit_power_level_rp;
962 #define READ_TRANSMIT_POWER_LEVEL_RP_SIZE 4
963
964 #define OCF_READ_SYNC_FLOW_ENABLE       0x002E
965
966 #define OCF_WRITE_SYNC_FLOW_ENABLE      0x002F
967
968 #define OCF_SET_CONTROLLER_TO_HOST_FC   0x0031
969
970 #define OCF_HOST_BUFFER_SIZE            0x0033
971 typedef struct {
972         uint16_t        acl_mtu;
973         uint8_t         sco_mtu;
974         uint16_t        acl_max_pkt;
975         uint16_t        sco_max_pkt;
976 } __attribute__ ((packed)) host_buffer_size_cp;
977 #define HOST_BUFFER_SIZE_CP_SIZE 7
978
979 #define OCF_HOST_NUM_COMP_PKTS          0x0035
980 typedef struct {
981         uint8_t         num_hndl;
982         /* variable length part */
983 } __attribute__ ((packed)) host_num_comp_pkts_cp;
984 #define HOST_NUM_COMP_PKTS_CP_SIZE 1
985
986 #define OCF_READ_LINK_SUPERVISION_TIMEOUT       0x0036
987 typedef struct {
988         uint8_t         status;
989         uint16_t        handle;
990         uint16_t        timeout;
991 } __attribute__ ((packed)) read_link_supervision_timeout_rp;
992 #define READ_LINK_SUPERVISION_TIMEOUT_RP_SIZE 5
993
994 #define OCF_WRITE_LINK_SUPERVISION_TIMEOUT      0x0037
995 typedef struct {
996         uint16_t        handle;
997         uint16_t        timeout;
998 } __attribute__ ((packed)) write_link_supervision_timeout_cp;
999 #define WRITE_LINK_SUPERVISION_TIMEOUT_CP_SIZE 4
1000 typedef struct {
1001         uint8_t         status;
1002         uint16_t        handle;
1003 } __attribute__ ((packed)) write_link_supervision_timeout_rp;
1004 #define WRITE_LINK_SUPERVISION_TIMEOUT_RP_SIZE 3
1005
1006 #define OCF_READ_NUM_SUPPORTED_IAC      0x0038
1007
1008 #define MAX_IAC_LAP 0x40
1009 #define OCF_READ_CURRENT_IAC_LAP        0x0039
1010 typedef struct {
1011         uint8_t         status;
1012         uint8_t         num_current_iac;
1013         uint8_t         lap[MAX_IAC_LAP][3];
1014 } __attribute__ ((packed)) read_current_iac_lap_rp;
1015 #define READ_CURRENT_IAC_LAP_RP_SIZE 2+3*MAX_IAC_LAP
1016
1017 #define OCF_WRITE_CURRENT_IAC_LAP       0x003A
1018 typedef struct {
1019         uint8_t         num_current_iac;
1020         uint8_t         lap[MAX_IAC_LAP][3];
1021 } __attribute__ ((packed)) write_current_iac_lap_cp;
1022 #define WRITE_CURRENT_IAC_LAP_CP_SIZE 1+3*MAX_IAC_LAP
1023
1024 #define OCF_READ_PAGE_SCAN_PERIOD_MODE  0x003B
1025
1026 #define OCF_WRITE_PAGE_SCAN_PERIOD_MODE 0x003C
1027
1028 #define OCF_READ_PAGE_SCAN_MODE         0x003D
1029
1030 #define OCF_WRITE_PAGE_SCAN_MODE        0x003E
1031
1032 #define OCF_SET_AFH_CLASSIFICATION      0x003F
1033 typedef struct {
1034         uint8_t         map[10];
1035 } __attribute__ ((packed)) set_afh_classification_cp;
1036 #define SET_AFH_CLASSIFICATION_CP_SIZE 10
1037 typedef struct {
1038         uint8_t         status;
1039 } __attribute__ ((packed)) set_afh_classification_rp;
1040 #define SET_AFH_CLASSIFICATION_RP_SIZE 1
1041
1042 #define OCF_READ_INQUIRY_SCAN_TYPE      0x0042
1043 typedef struct {
1044         uint8_t         status;
1045         uint8_t         type;
1046 } __attribute__ ((packed)) read_inquiry_scan_type_rp;
1047 #define READ_INQUIRY_SCAN_TYPE_RP_SIZE 2
1048
1049 #define OCF_WRITE_INQUIRY_SCAN_TYPE     0x0043
1050 typedef struct {
1051         uint8_t         type;
1052 } __attribute__ ((packed)) write_inquiry_scan_type_cp;
1053 #define WRITE_INQUIRY_SCAN_TYPE_CP_SIZE 1
1054 typedef struct {
1055         uint8_t         status;
1056 } __attribute__ ((packed)) write_inquiry_scan_type_rp;
1057 #define WRITE_INQUIRY_SCAN_TYPE_RP_SIZE 1
1058
1059 #define OCF_READ_INQUIRY_MODE           0x0044
1060 typedef struct {
1061         uint8_t         status;
1062         uint8_t         mode;
1063 } __attribute__ ((packed)) read_inquiry_mode_rp;
1064 #define READ_INQUIRY_MODE_RP_SIZE 2
1065
1066 #define OCF_WRITE_INQUIRY_MODE          0x0045
1067 typedef struct {
1068         uint8_t         mode;
1069 } __attribute__ ((packed)) write_inquiry_mode_cp;
1070 #define WRITE_INQUIRY_MODE_CP_SIZE 1
1071 typedef struct {
1072         uint8_t         status;
1073 } __attribute__ ((packed)) write_inquiry_mode_rp;
1074 #define WRITE_INQUIRY_MODE_RP_SIZE 1
1075
1076 #define OCF_READ_PAGE_SCAN_TYPE         0x0046
1077
1078 #define OCF_WRITE_PAGE_SCAN_TYPE        0x0047
1079         #define PAGE_SCAN_TYPE_STANDARD         0x00
1080         #define PAGE_SCAN_TYPE_INTERLACED       0x01
1081
1082 #define OCF_READ_AFH_MODE               0x0048
1083 typedef struct {
1084         uint8_t         status;
1085         uint8_t         mode;
1086 } __attribute__ ((packed)) read_afh_mode_rp;
1087 #define READ_AFH_MODE_RP_SIZE 2
1088
1089 #define OCF_WRITE_AFH_MODE              0x0049
1090 typedef struct {
1091         uint8_t         mode;
1092 } __attribute__ ((packed)) write_afh_mode_cp;
1093 #define WRITE_AFH_MODE_CP_SIZE 1
1094 typedef struct {
1095         uint8_t         status;
1096 } __attribute__ ((packed)) write_afh_mode_rp;
1097 #define WRITE_AFH_MODE_RP_SIZE 1
1098
1099 #define HCI_MAX_EIR_LENGTH              240
1100
1101 #define OCF_READ_EXT_INQUIRY_RESPONSE   0x0051
1102 typedef struct {
1103         uint8_t         status;
1104         uint8_t         fec;
1105         uint8_t         data[HCI_MAX_EIR_LENGTH];
1106 } __attribute__ ((packed)) read_ext_inquiry_response_rp;
1107 #define READ_EXT_INQUIRY_RESPONSE_RP_SIZE 242
1108
1109 #define OCF_WRITE_EXT_INQUIRY_RESPONSE  0x0052
1110 typedef struct {
1111         uint8_t         fec;
1112         uint8_t         data[HCI_MAX_EIR_LENGTH];
1113 } __attribute__ ((packed)) write_ext_inquiry_response_cp;
1114 #define WRITE_EXT_INQUIRY_RESPONSE_CP_SIZE 241
1115 typedef struct {
1116         uint8_t         status;
1117 } __attribute__ ((packed)) write_ext_inquiry_response_rp;
1118 #define WRITE_EXT_INQUIRY_RESPONSE_RP_SIZE 1
1119
1120 #define OCF_REFRESH_ENCRYPTION_KEY      0x0053
1121 typedef struct {
1122         uint16_t        handle;
1123 } __attribute__ ((packed)) refresh_encryption_key_cp;
1124 #define REFRESH_ENCRYPTION_KEY_CP_SIZE 2
1125 typedef struct {
1126         uint8_t         status;
1127 } __attribute__ ((packed)) refresh_encryption_key_rp;
1128 #define REFRESH_ENCRYPTION_KEY_RP_SIZE 1
1129
1130 #define OCF_READ_SIMPLE_PAIRING_MODE    0x0055
1131 typedef struct {
1132         uint8_t         status;
1133         uint8_t         mode;
1134 } __attribute__ ((packed)) read_simple_pairing_mode_rp;
1135 #define READ_SIMPLE_PAIRING_MODE_RP_SIZE 2
1136
1137 #define OCF_WRITE_SIMPLE_PAIRING_MODE   0x0056
1138 typedef struct {
1139         uint8_t         mode;
1140 } __attribute__ ((packed)) write_simple_pairing_mode_cp;
1141 #define WRITE_SIMPLE_PAIRING_MODE_CP_SIZE 1
1142 typedef struct {
1143         uint8_t         status;
1144 } __attribute__ ((packed)) write_simple_pairing_mode_rp;
1145 #define WRITE_SIMPLE_PAIRING_MODE_RP_SIZE 1
1146
1147 #define OCF_READ_LOCAL_OOB_DATA         0x0057
1148 typedef struct {
1149         uint8_t         status;
1150         uint8_t         hash[16];
1151         uint8_t         randomizer[16];
1152 } __attribute__ ((packed)) read_local_oob_data_rp;
1153 #define READ_LOCAL_OOB_DATA_RP_SIZE 33
1154
1155 #define OCF_READ_INQ_RESPONSE_TX_POWER_LEVEL    0x0058
1156 typedef struct {
1157         uint8_t         status;
1158         int8_t          level;
1159 } __attribute__ ((packed)) read_inq_response_tx_power_level_rp;
1160 #define READ_INQ_RESPONSE_TX_POWER_LEVEL_RP_SIZE 2
1161
1162 #define OCF_READ_INQUIRY_TRANSMIT_POWER_LEVEL   0x0058
1163 typedef struct {
1164         uint8_t         status;
1165         int8_t          level;
1166 } __attribute__ ((packed)) read_inquiry_transmit_power_level_rp;
1167 #define READ_INQUIRY_TRANSMIT_POWER_LEVEL_RP_SIZE 2
1168
1169 #define OCF_WRITE_INQUIRY_TRANSMIT_POWER_LEVEL  0x0059
1170 typedef struct {
1171         int8_t          level;
1172 } __attribute__ ((packed)) write_inquiry_transmit_power_level_cp;
1173 #define WRITE_INQUIRY_TRANSMIT_POWER_LEVEL_CP_SIZE 1
1174 typedef struct {
1175         uint8_t         status;
1176 } __attribute__ ((packed)) write_inquiry_transmit_power_level_rp;
1177 #define WRITE_INQUIRY_TRANSMIT_POWER_LEVEL_RP_SIZE 1
1178
1179 #define OCF_READ_DEFAULT_ERROR_DATA_REPORTING   0x005A
1180 typedef struct {
1181         uint8_t         status;
1182         uint8_t         reporting;
1183 } __attribute__ ((packed)) read_default_error_data_reporting_rp;
1184 #define READ_DEFAULT_ERROR_DATA_REPORTING_RP_SIZE 2
1185
1186 #define OCF_WRITE_DEFAULT_ERROR_DATA_REPORTING  0x005B
1187 typedef struct {
1188         uint8_t         reporting;
1189 } __attribute__ ((packed)) write_default_error_data_reporting_cp;
1190 #define WRITE_DEFAULT_ERROR_DATA_REPORTING_CP_SIZE 1
1191 typedef struct {
1192         uint8_t         status;
1193 } __attribute__ ((packed)) write_default_error_data_reporting_rp;
1194 #define WRITE_DEFAULT_ERROR_DATA_REPORTING_RP_SIZE 1
1195
1196 #define OCF_ENHANCED_FLUSH              0x005F
1197 typedef struct {
1198         uint16_t        handle;
1199         uint8_t         type;
1200 } __attribute__ ((packed)) enhanced_flush_cp;
1201 #define ENHANCED_FLUSH_CP_SIZE 3
1202
1203 #define OCF_SEND_KEYPRESS_NOTIFY        0x0060
1204 typedef struct {
1205         bdaddr_t        bdaddr;
1206         uint8_t         type;
1207 } __attribute__ ((packed)) send_keypress_notify_cp;
1208 #define SEND_KEYPRESS_NOTIFY_CP_SIZE 7
1209 typedef struct {
1210         uint8_t         status;
1211 } __attribute__ ((packed)) send_keypress_notify_rp;
1212 #define SEND_KEYPRESS_NOTIFY_RP_SIZE 1
1213
1214 #define OCF_READ_LOGICAL_LINK_ACCEPT_TIMEOUT     0x0061
1215 typedef struct {
1216         uint8_t         status;
1217         uint16_t        timeout;
1218 } __attribute__ ((packed)) read_log_link_accept_timeout_rp;
1219 #define READ_LOGICAL_LINK_ACCEPT_TIMEOUT_RP_SIZE 3
1220
1221 #define OCF_WRITE_LOGICAL_LINK_ACCEPT_TIMEOUT   0x0062
1222 typedef struct {
1223         uint16_t        timeout;
1224 } __attribute__ ((packed)) write_log_link_accept_timeout_cp;
1225 #define WRITE_LOGICAL_LINK_ACCEPT_TIMEOUT_CP_SIZE 2
1226
1227 #define OCF_SET_EVENT_MASK_PAGE_2       0x0063
1228
1229 #define OCF_READ_LOCATION_DATA          0x0064
1230
1231 #define OCF_WRITE_LOCATION_DATA 0x0065
1232
1233 #define OCF_READ_FLOW_CONTROL_MODE      0x0066
1234
1235 #define OCF_WRITE_FLOW_CONTROL_MODE     0x0067
1236
1237 #define OCF_READ_ENHANCED_TRANSMIT_POWER_LEVEL  0x0068
1238 typedef struct {
1239         uint8_t         status;
1240         uint16_t        handle;
1241         int8_t          level_gfsk;
1242         int8_t          level_dqpsk;
1243         int8_t          level_8dpsk;
1244 } __attribute__ ((packed)) read_enhanced_transmit_power_level_rp;
1245 #define READ_ENHANCED_TRANSMIT_POWER_LEVEL_RP_SIZE 6
1246
1247 #define OCF_READ_BEST_EFFORT_FLUSH_TIMEOUT      0x0069
1248 typedef struct {
1249         uint8_t         status;
1250         uint32_t        timeout;
1251 } __attribute__ ((packed)) read_best_effort_flush_timeout_rp;
1252 #define READ_BEST_EFFORT_FLUSH_TIMEOUT_RP_SIZE 5
1253
1254 #define OCF_WRITE_BEST_EFFORT_FLUSH_TIMEOUT     0x006A
1255 typedef struct {
1256         uint16_t        handle;
1257         uint32_t        timeout;
1258 } __attribute__ ((packed)) write_best_effort_flush_timeout_cp;
1259 #define WRITE_BEST_EFFORT_FLUSH_TIMEOUT_CP_SIZE 6
1260 typedef struct {
1261         uint8_t         status;
1262 } __attribute__ ((packed)) write_best_effort_flush_timeout_rp;
1263 #define WRITE_BEST_EFFORT_FLUSH_TIMEOUT_RP_SIZE 1
1264
1265 #define OCF_READ_LE_HOST_SUPPORTED      0x006C
1266 typedef struct {
1267         uint8_t         status;
1268         uint8_t         le;
1269         uint8_t         simul;
1270 } __attribute__ ((packed)) read_le_host_supported_rp;
1271 #define READ_LE_HOST_SUPPORTED_RP_SIZE 3
1272
1273 #define OCF_WRITE_LE_HOST_SUPPORTED     0x006D
1274 typedef struct {
1275         uint8_t         le;
1276         uint8_t         simul;
1277 } __attribute__ ((packed)) write_le_host_supported_cp;
1278 #define WRITE_LE_HOST_SUPPORTED_CP_SIZE 2
1279
1280 /* Informational Parameters */
1281 #define OGF_INFO_PARAM          0x04
1282
1283 #define OCF_READ_LOCAL_VERSION          0x0001
1284 typedef struct {
1285         uint8_t         status;
1286         uint8_t         hci_ver;
1287         uint16_t        hci_rev;
1288         uint8_t         lmp_ver;
1289         uint16_t        manufacturer;
1290         uint16_t        lmp_subver;
1291 } __attribute__ ((packed)) read_local_version_rp;
1292 #define READ_LOCAL_VERSION_RP_SIZE 9
1293
1294 #define OCF_READ_LOCAL_COMMANDS         0x0002
1295 typedef struct {
1296         uint8_t         status;
1297         uint8_t         commands[64];
1298 } __attribute__ ((packed)) read_local_commands_rp;
1299 #define READ_LOCAL_COMMANDS_RP_SIZE 65
1300
1301 #define OCF_READ_LOCAL_FEATURES         0x0003
1302 typedef struct {
1303         uint8_t         status;
1304         uint8_t         features[8];
1305 } __attribute__ ((packed)) read_local_features_rp;
1306 #define READ_LOCAL_FEATURES_RP_SIZE 9
1307
1308 #define OCF_READ_LOCAL_EXT_FEATURES     0x0004
1309 typedef struct {
1310         uint8_t         page_num;
1311 } __attribute__ ((packed)) read_local_ext_features_cp;
1312 #define READ_LOCAL_EXT_FEATURES_CP_SIZE 1
1313 typedef struct {
1314         uint8_t         status;
1315         uint8_t         page_num;
1316         uint8_t         max_page_num;
1317         uint8_t         features[8];
1318 } __attribute__ ((packed)) read_local_ext_features_rp;
1319 #define READ_LOCAL_EXT_FEATURES_RP_SIZE 11
1320
1321 #define OCF_READ_BUFFER_SIZE            0x0005
1322 typedef struct {
1323         uint8_t         status;
1324         uint16_t        acl_mtu;
1325         uint8_t         sco_mtu;
1326         uint16_t        acl_max_pkt;
1327         uint16_t        sco_max_pkt;
1328 } __attribute__ ((packed)) read_buffer_size_rp;
1329 #define READ_BUFFER_SIZE_RP_SIZE 8
1330
1331 #define OCF_READ_COUNTRY_CODE           0x0007
1332
1333 #define OCF_READ_BD_ADDR                0x0009
1334 typedef struct {
1335         uint8_t         status;
1336         bdaddr_t        bdaddr;
1337 } __attribute__ ((packed)) read_bd_addr_rp;
1338 #define READ_BD_ADDR_RP_SIZE 7
1339
1340 #define OCF_READ_DATA_BLOCK_SIZE        0x000A
1341 typedef struct {
1342         uint8_t         status;
1343         uint16_t        max_acl_len;
1344         uint16_t        data_block_len;
1345         uint16_t        num_blocks;
1346 } __attribute__ ((packed)) read_data_block_size_rp;
1347
1348 /* Status params */
1349 #define OGF_STATUS_PARAM        0x05
1350
1351 #define OCF_READ_FAILED_CONTACT_COUNTER         0x0001
1352 typedef struct {
1353         uint8_t         status;
1354         uint16_t        handle;
1355         uint8_t         counter;
1356 } __attribute__ ((packed)) read_failed_contact_counter_rp;
1357 #define READ_FAILED_CONTACT_COUNTER_RP_SIZE 4
1358
1359 #define OCF_RESET_FAILED_CONTACT_COUNTER        0x0002
1360 typedef struct {
1361         uint8_t         status;
1362         uint16_t        handle;
1363 } __attribute__ ((packed)) reset_failed_contact_counter_rp;
1364 #define RESET_FAILED_CONTACT_COUNTER_RP_SIZE 3
1365
1366 #define OCF_READ_LINK_QUALITY           0x0003
1367 typedef struct {
1368         uint8_t         status;
1369         uint16_t        handle;
1370         uint8_t         link_quality;
1371 } __attribute__ ((packed)) read_link_quality_rp;
1372 #define READ_LINK_QUALITY_RP_SIZE 4
1373
1374 #define OCF_READ_RSSI                   0x0005
1375 typedef struct {
1376         uint8_t         status;
1377         uint16_t        handle;
1378         int8_t          rssi;
1379 } __attribute__ ((packed)) read_rssi_rp;
1380 #define READ_RSSI_RP_SIZE 4
1381
1382 #define OCF_READ_AFH_MAP                0x0006
1383 typedef struct {
1384         uint8_t         status;
1385         uint16_t        handle;
1386         uint8_t         mode;
1387         uint8_t         map[10];
1388 } __attribute__ ((packed)) read_afh_map_rp;
1389 #define READ_AFH_MAP_RP_SIZE 14
1390
1391 #define OCF_READ_CLOCK                  0x0007
1392 typedef struct {
1393         uint16_t        handle;
1394         uint8_t         which_clock;
1395 } __attribute__ ((packed)) read_clock_cp;
1396 #define READ_CLOCK_CP_SIZE 3
1397 typedef struct {
1398         uint8_t         status;
1399         uint16_t        handle;
1400         uint32_t        clock;
1401         uint16_t        accuracy;
1402 } __attribute__ ((packed)) read_clock_rp;
1403 #define READ_CLOCK_RP_SIZE 9
1404
1405 #define OCF_READ_LOCAL_AMP_INFO 0x0009
1406 typedef struct {
1407         uint8_t         status;
1408         uint8_t         amp_status;
1409         uint32_t        total_bandwidth;
1410         uint32_t        max_guaranteed_bandwidth;
1411         uint32_t        min_latency;
1412         uint32_t        max_pdu_size;
1413         uint8_t         controller_type;
1414         uint16_t        pal_caps;
1415         uint16_t        max_amp_assoc_length;
1416         uint32_t        max_flush_timeout;
1417         uint32_t        best_effort_flush_timeout;
1418 } __attribute__ ((packed)) read_local_amp_info_rp;
1419 #define READ_LOCAL_AMP_INFO_RP_SIZE 31
1420
1421 #define OCF_READ_LOCAL_AMP_ASSOC        0x000A
1422 typedef struct {
1423         uint8_t         handle;
1424         uint16_t        length_so_far;
1425         uint16_t        assoc_length;
1426 } __attribute__ ((packed)) read_local_amp_assoc_cp;
1427 #define READ_LOCAL_AMP_ASSOC_CP_SIZE 5
1428 typedef struct {
1429         uint8_t         status;
1430         uint8_t         handle;
1431         uint16_t        length;
1432         uint8_t         fragment[HCI_MAX_NAME_LENGTH];
1433 } __attribute__ ((packed)) read_local_amp_assoc_rp;
1434 #define READ_LOCAL_AMP_ASSOC_RP_SIZE 252
1435
1436 #define OCF_WRITE_REMOTE_AMP_ASSOC      0x000B
1437 typedef struct {
1438         uint8_t         handle;
1439         uint16_t        length_so_far;
1440         uint16_t        remaining_length;
1441         uint8_t         fragment[HCI_MAX_NAME_LENGTH];
1442 } __attribute__ ((packed)) write_remote_amp_assoc_cp;
1443 #define WRITE_REMOTE_AMP_ASSOC_CP_SIZE 253
1444 typedef struct {
1445         uint8_t         status;
1446         uint8_t         handle;
1447 } __attribute__ ((packed)) write_remote_amp_assoc_rp;
1448 #define WRITE_REMOTE_AMP_ASSOC_RP_SIZE 2
1449
1450 /* Testing commands */
1451 #define OGF_TESTING_CMD         0x3e
1452
1453 #define OCF_READ_LOOPBACK_MODE                  0x0001
1454
1455 #define OCF_WRITE_LOOPBACK_MODE                 0x0002
1456
1457 #define OCF_ENABLE_DEVICE_UNDER_TEST_MODE       0x0003
1458
1459 #define OCF_WRITE_SIMPLE_PAIRING_DEBUG_MODE     0x0004
1460 typedef struct {
1461         uint8_t         mode;
1462 } __attribute__ ((packed)) write_simple_pairing_debug_mode_cp;
1463 #define WRITE_SIMPLE_PAIRING_DEBUG_MODE_CP_SIZE 1
1464 typedef struct {
1465         uint8_t         status;
1466 } __attribute__ ((packed)) write_simple_pairing_debug_mode_rp;
1467 #define WRITE_SIMPLE_PAIRING_DEBUG_MODE_RP_SIZE 1
1468
1469 /* LE commands */
1470 #define OGF_LE_CTL              0x08
1471
1472 #define OCF_LE_SET_EVENT_MASK                   0x0001
1473 typedef struct {
1474         uint8_t         mask[8];
1475 } __attribute__ ((packed)) le_set_event_mask_cp;
1476 #define LE_SET_EVENT_MASK_CP_SIZE 8
1477
1478 #define OCF_LE_READ_BUFFER_SIZE                 0x0002
1479 typedef struct {
1480         uint8_t         status;
1481         uint16_t        pkt_len;
1482         uint8_t         max_pkt;
1483 } __attribute__ ((packed)) le_read_buffer_size_rp;
1484 #define LE_READ_BUFFER_SIZE_RP_SIZE 4
1485
1486 #define OCF_LE_READ_LOCAL_SUPPORTED_FEATURES    0x0003
1487 typedef struct {
1488         uint8_t         status;
1489         uint8_t         features[8];
1490 } __attribute__ ((packed)) le_read_local_supported_features_rp;
1491 #define LE_READ_LOCAL_SUPPORTED_FEATURES_RP_SIZE 9
1492
1493 #define OCF_LE_SET_RANDOM_ADDRESS               0x0005
1494 typedef struct {
1495         bdaddr_t        bdaddr;
1496 } __attribute__ ((packed)) le_set_random_address_cp;
1497 #define LE_SET_RANDOM_ADDRESS_CP_SIZE 6
1498
1499 #define OCF_LE_SET_ADVERTISING_PARAMETERS       0x0006
1500 typedef struct {
1501         uint16_t        min_interval;
1502         uint16_t        max_interval;
1503         uint8_t         advtype;
1504         uint8_t         own_bdaddr_type;
1505         uint8_t         direct_bdaddr_type;
1506         bdaddr_t        direct_bdaddr;
1507         uint8_t         chan_map;
1508         uint8_t         filter;
1509 } __attribute__ ((packed)) le_set_advertising_parameters_cp;
1510 #define LE_SET_ADVERTISING_PARAMETERS_CP_SIZE 15
1511
1512 #define OCF_LE_READ_ADVERTISING_CHANNEL_TX_POWER        0x0007
1513 typedef struct {
1514         uint8_t         status;
1515         int8_t          level;
1516 } __attribute__ ((packed)) le_read_advertising_channel_tx_power_rp;
1517 #define LE_READ_ADVERTISING_CHANNEL_TX_POWER_RP_SIZE 2
1518
1519 #define OCF_LE_SET_ADVERTISING_DATA             0x0008
1520 typedef struct {
1521         uint8_t         length;
1522         uint8_t         data[31];
1523 } __attribute__ ((packed)) le_set_advertising_data_cp;
1524 #define LE_SET_ADVERTISING_DATA_CP_SIZE 32
1525
1526 #define OCF_LE_SET_SCAN_RESPONSE_DATA           0x0009
1527 typedef struct {
1528         uint8_t         length;
1529         uint8_t         data[31];
1530 } __attribute__ ((packed)) le_set_scan_response_data_cp;
1531 #define LE_SET_SCAN_RESPONSE_DATA_CP_SIZE 32
1532
1533 #define OCF_LE_SET_ADVERTISE_ENABLE             0x000A
1534 typedef struct {
1535         uint8_t         enable;
1536 } __attribute__ ((packed)) le_set_advertise_enable_cp;
1537 #define LE_SET_ADVERTISE_ENABLE_CP_SIZE 1
1538
1539 #define OCF_LE_SET_SCAN_PARAMETERS              0x000B
1540 typedef struct {
1541         uint8_t         type;
1542         uint16_t        interval;
1543         uint16_t        window;
1544         uint8_t         own_bdaddr_type;
1545         uint8_t         filter;
1546 } __attribute__ ((packed)) le_set_scan_parameters_cp;
1547 #define LE_SET_SCAN_PARAMETERS_CP_SIZE 7
1548
1549 #define OCF_LE_SET_SCAN_ENABLE                  0x000C
1550 typedef struct {
1551         uint8_t         enable;
1552         uint8_t         filter_dup;
1553 } __attribute__ ((packed)) le_set_scan_enable_cp;
1554 #define LE_SET_SCAN_ENABLE_CP_SIZE 2
1555
1556 #define OCF_LE_CREATE_CONN                      0x000D
1557 typedef struct {
1558         uint16_t        interval;
1559         uint16_t        window;
1560         uint8_t         initiator_filter;
1561         uint8_t         peer_bdaddr_type;
1562         bdaddr_t        peer_bdaddr;
1563         uint8_t         own_bdaddr_type;
1564         uint16_t        min_interval;
1565         uint16_t        max_interval;
1566         uint16_t        latency;
1567         uint16_t        supervision_timeout;
1568         uint16_t        min_ce_length;
1569         uint16_t        max_ce_length;
1570 } __attribute__ ((packed)) le_create_connection_cp;
1571 #define LE_CREATE_CONN_CP_SIZE 25
1572
1573 #define OCF_LE_CREATE_CONN_CANCEL               0x000E
1574
1575 #define OCF_LE_READ_WHITE_LIST_SIZE             0x000F
1576 typedef struct {
1577         uint8_t         status;
1578         uint8_t         size;
1579 } __attribute__ ((packed)) le_read_white_list_size_rp;
1580 #define LE_READ_WHITE_LIST_SIZE_RP_SIZE 2
1581
1582 #define OCF_LE_CLEAR_WHITE_LIST                 0x0010
1583
1584 #define OCF_LE_ADD_DEVICE_TO_WHITE_LIST         0x0011
1585 typedef struct {
1586         uint8_t         bdaddr_type;
1587         bdaddr_t        bdaddr;
1588 } __attribute__ ((packed)) le_add_device_to_white_list_cp;
1589 #define LE_ADD_DEVICE_TO_WHITE_LIST_CP_SIZE 7
1590
1591 #define OCF_LE_REMOVE_DEVICE_FROM_WHITE_LIST    0x0012
1592 typedef struct {
1593         uint8_t         bdaddr_type;
1594         bdaddr_t        bdaddr;
1595 } __attribute__ ((packed)) le_remove_device_from_white_list_cp;
1596 #define LE_REMOVE_DEVICE_FROM_WHITE_LIST_CP_SIZE 7
1597
1598 #define OCF_LE_CONN_UPDATE                      0x0013
1599 typedef struct {
1600         uint16_t        handle;
1601         uint16_t        min_interval;
1602         uint16_t        max_interval;
1603         uint16_t        latency;
1604         uint16_t        supervision_timeout;
1605         uint16_t        min_ce_length;
1606         uint16_t        max_ce_length;
1607 } __attribute__ ((packed)) le_connection_update_cp;
1608 #define LE_CONN_UPDATE_CP_SIZE 14
1609
1610 #define OCF_LE_SET_HOST_CHANNEL_CLASSIFICATION  0x0014
1611 typedef struct {
1612         uint8_t         map[5];
1613 } __attribute__ ((packed)) le_set_host_channel_classification_cp;
1614 #define LE_SET_HOST_CHANNEL_CLASSIFICATION_CP_SIZE 5
1615
1616 #define OCF_LE_READ_CHANNEL_MAP                 0x0015
1617 typedef struct {
1618         uint16_t        handle;
1619 } __attribute__ ((packed)) le_read_channel_map_cp;
1620 #define LE_READ_CHANNEL_MAP_CP_SIZE 2
1621 typedef struct {
1622         uint8_t         status;
1623         uint16_t        handle;
1624         uint8_t         map[5];
1625 } __attribute__ ((packed)) le_read_channel_map_rp;
1626 #define LE_READ_CHANNEL_MAP_RP_SIZE 8
1627
1628 #define OCF_LE_READ_REMOTE_USED_FEATURES        0x0016
1629 typedef struct {
1630         uint16_t        handle;
1631 } __attribute__ ((packed)) le_read_remote_used_features_cp;
1632 #define LE_READ_REMOTE_USED_FEATURES_CP_SIZE 2
1633
1634 #define OCF_LE_ENCRYPT                          0x0017
1635 typedef struct {
1636         uint8_t         key[16];
1637         uint8_t         plaintext[16];
1638 } __attribute__ ((packed)) le_encrypt_cp;
1639 #define LE_ENCRYPT_CP_SIZE 32
1640 typedef struct {
1641         uint8_t         status;
1642         uint8_t         data[16];
1643 } __attribute__ ((packed)) le_encrypt_rp;
1644 #define LE_ENCRYPT_RP_SIZE 17
1645
1646 #define OCF_LE_RAND                             0x0018
1647 typedef struct {
1648         uint8_t         status;
1649         uint64_t        random;
1650 } __attribute__ ((packed)) le_rand_rp;
1651 #define LE_RAND_RP_SIZE 9
1652
1653 #define OCF_LE_START_ENCRYPTION                 0x0019
1654 typedef struct {
1655         uint16_t        handle;
1656         uint64_t        random;
1657         uint16_t        diversifier;
1658         uint8_t         key[16];
1659 } __attribute__ ((packed)) le_start_encryption_cp;
1660 #define LE_START_ENCRYPTION_CP_SIZE 28
1661
1662 #define OCF_LE_LTK_REPLY                        0x001A
1663 typedef struct {
1664         uint16_t        handle;
1665         uint8_t         key[16];
1666 } __attribute__ ((packed)) le_ltk_reply_cp;
1667 #define LE_LTK_REPLY_CP_SIZE 18
1668 typedef struct {
1669         uint8_t         status;
1670         uint16_t        handle;
1671 } __attribute__ ((packed)) le_ltk_reply_rp;
1672 #define LE_LTK_REPLY_RP_SIZE 3
1673
1674 #define OCF_LE_LTK_NEG_REPLY                    0x001B
1675 typedef struct {
1676         uint16_t        handle;
1677 } __attribute__ ((packed)) le_ltk_neg_reply_cp;
1678 #define LE_LTK_NEG_REPLY_CP_SIZE 2
1679 typedef struct {
1680         uint8_t         status;
1681         uint16_t        handle;
1682 } __attribute__ ((packed)) le_ltk_neg_reply_rp;
1683 #define LE_LTK_NEG_REPLY_RP_SIZE 3
1684
1685 #define OCF_LE_READ_SUPPORTED_STATES            0x001C
1686 typedef struct {
1687         uint8_t         status;
1688         uint64_t        states;
1689 } __attribute__ ((packed)) le_read_supported_states_rp;
1690 #define LE_READ_SUPPORTED_STATES_RP_SIZE 9
1691
1692 #define OCF_LE_RECEIVER_TEST                    0x001D
1693 typedef struct {
1694         uint8_t         frequency;
1695 } __attribute__ ((packed)) le_receiver_test_cp;
1696 #define LE_RECEIVER_TEST_CP_SIZE 1
1697
1698 #define OCF_LE_TRANSMITTER_TEST                 0x001E
1699 typedef struct {
1700         uint8_t         frequency;
1701         uint8_t         length;
1702         uint8_t         payload;
1703 } __attribute__ ((packed)) le_transmitter_test_cp;
1704 #define LE_TRANSMITTER_TEST_CP_SIZE 3
1705
1706 #define OCF_LE_TEST_END                         0x001F
1707 typedef struct {
1708         uint8_t         status;
1709         uint16_t        num_pkts;
1710 } __attribute__ ((packed)) le_test_end_rp;
1711 #define LE_TEST_END_RP_SIZE 3
1712
1713 #define OCF_LE_ADD_DEVICE_TO_RESOLV_LIST        0x0027
1714 typedef struct {
1715         uint8_t         bdaddr_type;
1716         bdaddr_t        bdaddr;
1717         uint8_t         peer_irk[16];
1718         uint8_t         local_irk[16];
1719 } __attribute__ ((packed)) le_add_device_to_resolv_list_cp;
1720 #define LE_ADD_DEVICE_TO_RESOLV_LIST_CP_SIZE 39
1721
1722 #define OCF_LE_REMOVE_DEVICE_FROM_RESOLV_LIST   0x0028
1723 typedef struct {
1724         uint8_t         bdaddr_type;
1725         bdaddr_t        bdaddr;
1726 } __attribute__ ((packed)) le_remove_device_from_resolv_list_cp;
1727 #define LE_REMOVE_DEVICE_FROM_RESOLV_LIST_CP_SIZE 7
1728
1729 #define OCF_LE_CLEAR_RESOLV_LIST                0x0029
1730
1731 #define OCF_LE_READ_RESOLV_LIST_SIZE            0x002A
1732 typedef struct {
1733         uint8_t         status;
1734         uint8_t         size;
1735 } __attribute__ ((packed)) le_read_resolv_list_size_rp;
1736 #define LE_READ_RESOLV_LIST_SIZE_RP_SIZE 2
1737
1738 #define OCF_LE_SET_ADDRESS_RESOLUTION_ENABLE    0x002D
1739 typedef struct {
1740         uint8_t         enable;
1741 } __attribute__ ((packed)) le_set_address_resolution_enable_cp;
1742 #define LE_SET_ADDRESS_RESOLUTION_ENABLE_CP_SIZE 1
1743
1744 /* Vendor specific commands */
1745 #define OGF_VENDOR_CMD          0x3f
1746
1747 #ifdef __TIZEN_PATCH__
1748 #ifdef __BROADCOM_QOS_PATCH__
1749 #define BRCM_QOS_PRIORITY_NORMAL        0x00
1750 #define BRCM_QOS_PRIORITY_HIGH          0xFF
1751 #define BROADCOM_QOS_CMD        0xFC57  /* Only for bcm4329/bcm4330/bcm4334 chipsets */
1752 typedef struct {
1753         uint16_t handle;
1754         uint8_t priority;
1755 } __attribute__ ((__packed__)) broadcom_qos_cp;
1756 #define BROADCOM_QOS_CP_SIZE 3
1757 #endif  /* __BROADCOM_QOS_PATCH__ */
1758 #endif  /* __TIZEN_PATCH__ */
1759
1760 /* ---- HCI Events ---- */
1761
1762 #define EVT_INQUIRY_COMPLETE            0x01
1763
1764 #define EVT_INQUIRY_RESULT              0x02
1765 typedef struct {
1766         bdaddr_t        bdaddr;
1767         uint8_t         pscan_rep_mode;
1768         uint8_t         pscan_period_mode;
1769         uint8_t         pscan_mode;
1770         uint8_t         dev_class[3];
1771         uint16_t        clock_offset;
1772 } __attribute__ ((packed)) inquiry_info;
1773 #define INQUIRY_INFO_SIZE 14
1774
1775 #define EVT_CONN_COMPLETE               0x03
1776 typedef struct {
1777         uint8_t         status;
1778         uint16_t        handle;
1779         bdaddr_t        bdaddr;
1780         uint8_t         link_type;
1781         uint8_t         encr_mode;
1782 } __attribute__ ((packed)) evt_conn_complete;
1783 #define EVT_CONN_COMPLETE_SIZE 11
1784
1785 #define EVT_CONN_REQUEST                0x04
1786 typedef struct {
1787         bdaddr_t        bdaddr;
1788         uint8_t         dev_class[3];
1789         uint8_t         link_type;
1790 } __attribute__ ((packed)) evt_conn_request;
1791 #define EVT_CONN_REQUEST_SIZE 10
1792
1793 #define EVT_DISCONN_COMPLETE            0x05
1794 typedef struct {
1795         uint8_t         status;
1796         uint16_t        handle;
1797         uint8_t         reason;
1798 } __attribute__ ((packed)) evt_disconn_complete;
1799 #define EVT_DISCONN_COMPLETE_SIZE 4
1800
1801 #define EVT_AUTH_COMPLETE               0x06
1802 typedef struct {
1803         uint8_t         status;
1804         uint16_t        handle;
1805 } __attribute__ ((packed)) evt_auth_complete;
1806 #define EVT_AUTH_COMPLETE_SIZE 3
1807
1808 #define EVT_REMOTE_NAME_REQ_COMPLETE    0x07
1809 typedef struct {
1810         uint8_t         status;
1811         bdaddr_t        bdaddr;
1812         uint8_t         name[HCI_MAX_NAME_LENGTH];
1813 } __attribute__ ((packed)) evt_remote_name_req_complete;
1814 #define EVT_REMOTE_NAME_REQ_COMPLETE_SIZE 255
1815
1816 #define EVT_ENCRYPT_CHANGE              0x08
1817 typedef struct {
1818         uint8_t         status;
1819         uint16_t        handle;
1820         uint8_t         encrypt;
1821 } __attribute__ ((packed)) evt_encrypt_change;
1822 #define EVT_ENCRYPT_CHANGE_SIZE 4
1823
1824 #define EVT_CHANGE_CONN_LINK_KEY_COMPLETE       0x09
1825 typedef struct {
1826         uint8_t         status;
1827         uint16_t        handle;
1828 }  __attribute__ ((packed)) evt_change_conn_link_key_complete;
1829 #define EVT_CHANGE_CONN_LINK_KEY_COMPLETE_SIZE 3
1830
1831 #define EVT_MASTER_LINK_KEY_COMPLETE            0x0A
1832 typedef struct {
1833         uint8_t         status;
1834         uint16_t        handle;
1835         uint8_t         key_flag;
1836 } __attribute__ ((packed)) evt_master_link_key_complete;
1837 #define EVT_MASTER_LINK_KEY_COMPLETE_SIZE 4
1838
1839 #define EVT_READ_REMOTE_FEATURES_COMPLETE       0x0B
1840 typedef struct {
1841         uint8_t         status;
1842         uint16_t        handle;
1843         uint8_t         features[8];
1844 } __attribute__ ((packed)) evt_read_remote_features_complete;
1845 #define EVT_READ_REMOTE_FEATURES_COMPLETE_SIZE 11
1846
1847 #define EVT_READ_REMOTE_VERSION_COMPLETE        0x0C
1848 typedef struct {
1849         uint8_t         status;
1850         uint16_t        handle;
1851         uint8_t         lmp_ver;
1852         uint16_t        manufacturer;
1853         uint16_t        lmp_subver;
1854 } __attribute__ ((packed)) evt_read_remote_version_complete;
1855 #define EVT_READ_REMOTE_VERSION_COMPLETE_SIZE 8
1856
1857 #define EVT_QOS_SETUP_COMPLETE          0x0D
1858 typedef struct {
1859         uint8_t         status;
1860         uint16_t        handle;
1861         uint8_t         flags;                  /* Reserved */
1862         hci_qos         qos;
1863 } __attribute__ ((packed)) evt_qos_setup_complete;
1864 #define EVT_QOS_SETUP_COMPLETE_SIZE (4 + HCI_QOS_CP_SIZE)
1865
1866 #define EVT_CMD_COMPLETE                0x0E
1867 typedef struct {
1868         uint8_t         ncmd;
1869         uint16_t        opcode;
1870 } __attribute__ ((packed)) evt_cmd_complete;
1871 #define EVT_CMD_COMPLETE_SIZE 3
1872
1873 #define EVT_CMD_STATUS                  0x0F
1874 typedef struct {
1875         uint8_t         status;
1876         uint8_t         ncmd;
1877         uint16_t        opcode;
1878 } __attribute__ ((packed)) evt_cmd_status;
1879 #define EVT_CMD_STATUS_SIZE 4
1880
1881 #define EVT_HARDWARE_ERROR              0x10
1882 typedef struct {
1883         uint8_t         code;
1884 } __attribute__ ((packed)) evt_hardware_error;
1885 #define EVT_HARDWARE_ERROR_SIZE 1
1886
1887 #define EVT_FLUSH_OCCURRED              0x11
1888 typedef struct {
1889         uint16_t        handle;
1890 } __attribute__ ((packed)) evt_flush_occured;
1891 #define EVT_FLUSH_OCCURRED_SIZE 2
1892
1893 #define EVT_ROLE_CHANGE                 0x12
1894 typedef struct {
1895         uint8_t         status;
1896         bdaddr_t        bdaddr;
1897         uint8_t         role;
1898 } __attribute__ ((packed)) evt_role_change;
1899 #define EVT_ROLE_CHANGE_SIZE 8
1900
1901 #define EVT_NUM_COMP_PKTS               0x13
1902 typedef struct {
1903         uint8_t         num_hndl;
1904         /* variable length part */
1905 } __attribute__ ((packed)) evt_num_comp_pkts;
1906 #define EVT_NUM_COMP_PKTS_SIZE 1
1907
1908 #define EVT_MODE_CHANGE                 0x14
1909 typedef struct {
1910         uint8_t         status;
1911         uint16_t        handle;
1912         uint8_t         mode;
1913         uint16_t        interval;
1914 } __attribute__ ((packed)) evt_mode_change;
1915 #define EVT_MODE_CHANGE_SIZE 6
1916
1917 #define EVT_RETURN_LINK_KEYS            0x15
1918 typedef struct {
1919         uint8_t         num_keys;
1920         /* variable length part */
1921 } __attribute__ ((packed)) evt_return_link_keys;
1922 #define EVT_RETURN_LINK_KEYS_SIZE 1
1923
1924 #define EVT_PIN_CODE_REQ                0x16
1925 typedef struct {
1926         bdaddr_t        bdaddr;
1927 } __attribute__ ((packed)) evt_pin_code_req;
1928 #define EVT_PIN_CODE_REQ_SIZE 6
1929
1930 #define EVT_LINK_KEY_REQ                0x17
1931 typedef struct {
1932         bdaddr_t        bdaddr;
1933 } __attribute__ ((packed)) evt_link_key_req;
1934 #define EVT_LINK_KEY_REQ_SIZE 6
1935
1936 #define EVT_LINK_KEY_NOTIFY             0x18
1937 typedef struct {
1938         bdaddr_t        bdaddr;
1939         uint8_t         link_key[16];
1940         uint8_t         key_type;
1941 } __attribute__ ((packed)) evt_link_key_notify;
1942 #define EVT_LINK_KEY_NOTIFY_SIZE 23
1943
1944 #define EVT_LOOPBACK_COMMAND            0x19
1945
1946 #define EVT_DATA_BUFFER_OVERFLOW        0x1A
1947 typedef struct {
1948         uint8_t         link_type;
1949 } __attribute__ ((packed)) evt_data_buffer_overflow;
1950 #define EVT_DATA_BUFFER_OVERFLOW_SIZE 1
1951
1952 #define EVT_MAX_SLOTS_CHANGE            0x1B
1953 typedef struct {
1954         uint16_t        handle;
1955         uint8_t         max_slots;
1956 } __attribute__ ((packed)) evt_max_slots_change;
1957 #define EVT_MAX_SLOTS_CHANGE_SIZE 3
1958
1959 #define EVT_READ_CLOCK_OFFSET_COMPLETE  0x1C
1960 typedef struct {
1961         uint8_t         status;
1962         uint16_t        handle;
1963         uint16_t        clock_offset;
1964 } __attribute__ ((packed)) evt_read_clock_offset_complete;
1965 #define EVT_READ_CLOCK_OFFSET_COMPLETE_SIZE 5
1966
1967 #define EVT_CONN_PTYPE_CHANGED          0x1D
1968 typedef struct {
1969         uint8_t         status;
1970         uint16_t        handle;
1971         uint16_t        ptype;
1972 } __attribute__ ((packed)) evt_conn_ptype_changed;
1973 #define EVT_CONN_PTYPE_CHANGED_SIZE 5
1974
1975 #define EVT_QOS_VIOLATION               0x1E
1976 typedef struct {
1977         uint16_t        handle;
1978 } __attribute__ ((packed)) evt_qos_violation;
1979 #define EVT_QOS_VIOLATION_SIZE 2
1980
1981 #define EVT_PSCAN_REP_MODE_CHANGE       0x20
1982 typedef struct {
1983         bdaddr_t        bdaddr;
1984         uint8_t         pscan_rep_mode;
1985 } __attribute__ ((packed)) evt_pscan_rep_mode_change;
1986 #define EVT_PSCAN_REP_MODE_CHANGE_SIZE 7
1987
1988 #define EVT_FLOW_SPEC_COMPLETE          0x21
1989 typedef struct {
1990         uint8_t         status;
1991         uint16_t        handle;
1992         uint8_t         flags;
1993         uint8_t         direction;
1994         hci_qos         qos;
1995 } __attribute__ ((packed)) evt_flow_spec_complete;
1996 #define EVT_FLOW_SPEC_COMPLETE_SIZE (5 + HCI_QOS_CP_SIZE)
1997
1998 #define EVT_INQUIRY_RESULT_WITH_RSSI    0x22
1999 typedef struct {
2000         bdaddr_t        bdaddr;
2001         uint8_t         pscan_rep_mode;
2002         uint8_t         pscan_period_mode;
2003         uint8_t         dev_class[3];
2004         uint16_t        clock_offset;
2005         int8_t          rssi;
2006 } __attribute__ ((packed)) inquiry_info_with_rssi;
2007 #define INQUIRY_INFO_WITH_RSSI_SIZE 14
2008 typedef struct {
2009         bdaddr_t        bdaddr;
2010         uint8_t         pscan_rep_mode;
2011         uint8_t         pscan_period_mode;
2012         uint8_t         pscan_mode;
2013         uint8_t         dev_class[3];
2014         uint16_t        clock_offset;
2015         int8_t          rssi;
2016 } __attribute__ ((packed)) inquiry_info_with_rssi_and_pscan_mode;
2017 #define INQUIRY_INFO_WITH_RSSI_AND_PSCAN_MODE_SIZE 15
2018
2019 #define EVT_READ_REMOTE_EXT_FEATURES_COMPLETE   0x23
2020 typedef struct {
2021         uint8_t         status;
2022         uint16_t        handle;
2023         uint8_t         page_num;
2024         uint8_t         max_page_num;
2025         uint8_t         features[8];
2026 } __attribute__ ((packed)) evt_read_remote_ext_features_complete;
2027 #define EVT_READ_REMOTE_EXT_FEATURES_COMPLETE_SIZE 13
2028
2029 #define EVT_SYNC_CONN_COMPLETE          0x2C
2030 typedef struct {
2031         uint8_t         status;
2032         uint16_t        handle;
2033         bdaddr_t        bdaddr;
2034         uint8_t         link_type;
2035         uint8_t         trans_interval;
2036         uint8_t         retrans_window;
2037         uint16_t        rx_pkt_len;
2038         uint16_t        tx_pkt_len;
2039         uint8_t         air_mode;
2040 } __attribute__ ((packed)) evt_sync_conn_complete;
2041 #define EVT_SYNC_CONN_COMPLETE_SIZE 17
2042
2043 #define EVT_SYNC_CONN_CHANGED           0x2D
2044 typedef struct {
2045         uint8_t         status;
2046         uint16_t        handle;
2047         uint8_t         trans_interval;
2048         uint8_t         retrans_window;
2049         uint16_t        rx_pkt_len;
2050         uint16_t        tx_pkt_len;
2051 } __attribute__ ((packed)) evt_sync_conn_changed;
2052 #define EVT_SYNC_CONN_CHANGED_SIZE 9
2053
2054 #define EVT_SNIFF_SUBRATING             0x2E
2055 typedef struct {
2056         uint8_t         status;
2057         uint16_t        handle;
2058         uint16_t        max_tx_latency;
2059         uint16_t        max_rx_latency;
2060         uint16_t        min_remote_timeout;
2061         uint16_t        min_local_timeout;
2062 } __attribute__ ((packed)) evt_sniff_subrating;
2063 #define EVT_SNIFF_SUBRATING_SIZE 11
2064
2065 #define EVT_EXTENDED_INQUIRY_RESULT     0x2F
2066 typedef struct {
2067         bdaddr_t        bdaddr;
2068         uint8_t         pscan_rep_mode;
2069         uint8_t         pscan_period_mode;
2070         uint8_t         dev_class[3];
2071         uint16_t        clock_offset;
2072         int8_t          rssi;
2073         uint8_t         data[HCI_MAX_EIR_LENGTH];
2074 } __attribute__ ((packed)) extended_inquiry_info;
2075 #define EXTENDED_INQUIRY_INFO_SIZE 254
2076
2077 #define EVT_ENCRYPTION_KEY_REFRESH_COMPLETE     0x30
2078 typedef struct {
2079         uint8_t         status;
2080         uint16_t        handle;
2081 } __attribute__ ((packed)) evt_encryption_key_refresh_complete;
2082 #define EVT_ENCRYPTION_KEY_REFRESH_COMPLETE_SIZE 3
2083
2084 #define EVT_IO_CAPABILITY_REQUEST       0x31
2085 typedef struct {
2086         bdaddr_t        bdaddr;
2087 } __attribute__ ((packed)) evt_io_capability_request;
2088 #define EVT_IO_CAPABILITY_REQUEST_SIZE 6
2089
2090 #define EVT_IO_CAPABILITY_RESPONSE      0x32
2091 typedef struct {
2092         bdaddr_t        bdaddr;
2093         uint8_t         capability;
2094         uint8_t         oob_data;
2095         uint8_t         authentication;
2096 } __attribute__ ((packed)) evt_io_capability_response;
2097 #define EVT_IO_CAPABILITY_RESPONSE_SIZE 9
2098
2099 #define EVT_USER_CONFIRM_REQUEST        0x33
2100 typedef struct {
2101         bdaddr_t        bdaddr;
2102         uint32_t        passkey;
2103 } __attribute__ ((packed)) evt_user_confirm_request;
2104 #define EVT_USER_CONFIRM_REQUEST_SIZE 10
2105
2106 #define EVT_USER_PASSKEY_REQUEST        0x34
2107 typedef struct {
2108         bdaddr_t        bdaddr;
2109 } __attribute__ ((packed)) evt_user_passkey_request;
2110 #define EVT_USER_PASSKEY_REQUEST_SIZE 6
2111
2112 #define EVT_REMOTE_OOB_DATA_REQUEST     0x35
2113 typedef struct {
2114         bdaddr_t        bdaddr;
2115 } __attribute__ ((packed)) evt_remote_oob_data_request;
2116 #define EVT_REMOTE_OOB_DATA_REQUEST_SIZE 6
2117
2118 #define EVT_SIMPLE_PAIRING_COMPLETE     0x36
2119 typedef struct {
2120         uint8_t         status;
2121         bdaddr_t        bdaddr;
2122 } __attribute__ ((packed)) evt_simple_pairing_complete;
2123 #define EVT_SIMPLE_PAIRING_COMPLETE_SIZE 7
2124
2125 #define EVT_LINK_SUPERVISION_TIMEOUT_CHANGED    0x38
2126 typedef struct {
2127         uint16_t        handle;
2128         uint16_t        timeout;
2129 } __attribute__ ((packed)) evt_link_supervision_timeout_changed;
2130 #define EVT_LINK_SUPERVISION_TIMEOUT_CHANGED_SIZE 4
2131
2132 #define EVT_ENHANCED_FLUSH_COMPLETE     0x39
2133 typedef struct {
2134         uint16_t        handle;
2135 } __attribute__ ((packed)) evt_enhanced_flush_complete;
2136 #define EVT_ENHANCED_FLUSH_COMPLETE_SIZE 2
2137
2138 #define EVT_USER_PASSKEY_NOTIFY         0x3B
2139 typedef struct {
2140         bdaddr_t        bdaddr;
2141         uint32_t        passkey;
2142 } __attribute__ ((packed)) evt_user_passkey_notify;
2143 #define EVT_USER_PASSKEY_NOTIFY_SIZE 10
2144
2145 #define EVT_KEYPRESS_NOTIFY             0x3C
2146 typedef struct {
2147         bdaddr_t        bdaddr;
2148         uint8_t         type;
2149 } __attribute__ ((packed)) evt_keypress_notify;
2150 #define EVT_KEYPRESS_NOTIFY_SIZE 7
2151
2152 #define EVT_REMOTE_HOST_FEATURES_NOTIFY 0x3D
2153 typedef struct {
2154         bdaddr_t        bdaddr;
2155         uint8_t         features[8];
2156 } __attribute__ ((packed)) evt_remote_host_features_notify;
2157 #define EVT_REMOTE_HOST_FEATURES_NOTIFY_SIZE 14
2158
2159 #define EVT_LE_META_EVENT       0x3E
2160 typedef struct {
2161         uint8_t         subevent;
2162         uint8_t         data[0];
2163 } __attribute__ ((packed)) evt_le_meta_event;
2164 #define EVT_LE_META_EVENT_SIZE 1
2165
2166 #define EVT_LE_CONN_COMPLETE    0x01
2167 typedef struct {
2168         uint8_t         status;
2169         uint16_t        handle;
2170         uint8_t         role;
2171         uint8_t         peer_bdaddr_type;
2172         bdaddr_t        peer_bdaddr;
2173         uint16_t        interval;
2174         uint16_t        latency;
2175         uint16_t        supervision_timeout;
2176         uint8_t         master_clock_accuracy;
2177 } __attribute__ ((packed)) evt_le_connection_complete;
2178 #define EVT_LE_CONN_COMPLETE_SIZE 18
2179
2180 #define EVT_LE_ADVERTISING_REPORT       0x02
2181 typedef struct {
2182         uint8_t         evt_type;
2183         uint8_t         bdaddr_type;
2184         bdaddr_t        bdaddr;
2185         uint8_t         length;
2186         uint8_t         data[0];
2187 } __attribute__ ((packed)) le_advertising_info;
2188 #define LE_ADVERTISING_INFO_SIZE 9
2189
2190 #define EVT_LE_CONN_UPDATE_COMPLETE     0x03
2191 typedef struct {
2192         uint8_t         status;
2193         uint16_t        handle;
2194         uint16_t        interval;
2195         uint16_t        latency;
2196         uint16_t        supervision_timeout;
2197 } __attribute__ ((packed)) evt_le_connection_update_complete;
2198 #define EVT_LE_CONN_UPDATE_COMPLETE_SIZE 9
2199
2200 #define EVT_LE_READ_REMOTE_USED_FEATURES_COMPLETE       0x04
2201 typedef struct {
2202         uint8_t         status;
2203         uint16_t        handle;
2204         uint8_t         features[8];
2205 } __attribute__ ((packed)) evt_le_read_remote_used_features_complete;
2206 #define EVT_LE_READ_REMOTE_USED_FEATURES_COMPLETE_SIZE 11
2207
2208 #define EVT_LE_LTK_REQUEST      0x05
2209 typedef struct {
2210         uint16_t        handle;
2211         uint64_t        random;
2212         uint16_t        diversifier;
2213 } __attribute__ ((packed)) evt_le_long_term_key_request;
2214 #define EVT_LE_LTK_REQUEST_SIZE 12
2215
2216 #define EVT_PHYSICAL_LINK_COMPLETE              0x40
2217 typedef struct {
2218         uint8_t         status;
2219         uint8_t         handle;
2220 } __attribute__ ((packed)) evt_physical_link_complete;
2221 #define EVT_PHYSICAL_LINK_COMPLETE_SIZE 2
2222
2223 #define EVT_CHANNEL_SELECTED            0x41
2224
2225 #define EVT_DISCONNECT_PHYSICAL_LINK_COMPLETE   0x42
2226 typedef struct {
2227         uint8_t         status;
2228         uint8_t         handle;
2229         uint8_t         reason;
2230 } __attribute__ ((packed)) evt_disconn_physical_link_complete;
2231 #define EVT_DISCONNECT_PHYSICAL_LINK_COMPLETE_SIZE 3
2232
2233 #define EVT_PHYSICAL_LINK_LOSS_EARLY_WARNING    0x43
2234 typedef struct {
2235         uint8_t         handle;
2236         uint8_t         reason;
2237 } __attribute__ ((packed)) evt_physical_link_loss_warning;
2238 #define EVT_PHYSICAL_LINK_LOSS_WARNING_SIZE 2
2239
2240 #define EVT_PHYSICAL_LINK_RECOVERY              0x44
2241 typedef struct {
2242         uint8_t         handle;
2243 } __attribute__ ((packed)) evt_physical_link_recovery;
2244 #define EVT_PHYSICAL_LINK_RECOVERY_SIZE 1
2245
2246 #define EVT_LOGICAL_LINK_COMPLETE               0x45
2247 typedef struct {
2248         uint8_t         status;
2249         uint16_t        log_handle;
2250         uint8_t         handle;
2251         uint8_t         tx_flow_id;
2252 } __attribute__ ((packed)) evt_logical_link_complete;
2253 #define EVT_LOGICAL_LINK_COMPLETE_SIZE 5
2254
2255 #define EVT_DISCONNECT_LOGICAL_LINK_COMPLETE    0x46
2256
2257 #define EVT_FLOW_SPEC_MODIFY_COMPLETE           0x47
2258 typedef struct {
2259         uint8_t         status;
2260         uint16_t        handle;
2261 } __attribute__ ((packed)) evt_flow_spec_modify_complete;
2262 #define EVT_FLOW_SPEC_MODIFY_COMPLETE_SIZE 3
2263
2264 #define EVT_NUMBER_COMPLETED_BLOCKS             0x48
2265 typedef struct {
2266         uint16_t                handle;
2267         uint16_t                num_cmplt_pkts;
2268         uint16_t                num_cmplt_blks;
2269 } __attribute__ ((packed)) cmplt_handle;
2270 typedef struct {
2271         uint16_t                total_num_blocks;
2272         uint8_t                 num_handles;
2273         cmplt_handle            handles[0];
2274 }  __attribute__ ((packed)) evt_num_completed_blocks;
2275
2276 #define EVT_AMP_STATUS_CHANGE                   0x4D
2277 typedef struct {
2278         uint8_t         status;
2279         uint8_t         amp_status;
2280 } __attribute__ ((packed)) evt_amp_status_change;
2281 #define EVT_AMP_STATUS_CHANGE_SIZE 2
2282
2283 #define EVT_TESTING                     0xFE
2284
2285 #define EVT_VENDOR                      0xFF
2286
2287 /* Internal events generated by BlueZ stack */
2288 #define EVT_STACK_INTERNAL              0xFD
2289 typedef struct {
2290         uint16_t        type;
2291         uint8_t         data[0];
2292 } __attribute__ ((packed)) evt_stack_internal;
2293 #define EVT_STACK_INTERNAL_SIZE 2
2294
2295 #define EVT_SI_DEVICE   0x01
2296 typedef struct {
2297         uint16_t        event;
2298         uint16_t        dev_id;
2299 } __attribute__ ((packed)) evt_si_device;
2300 #define EVT_SI_DEVICE_SIZE 4
2301
2302 /* --------  HCI Packet structures  -------- */
2303 #define HCI_TYPE_LEN    1
2304
2305 typedef struct {
2306         uint16_t        opcode;         /* OCF & OGF */
2307         uint8_t         plen;
2308 } __attribute__ ((packed))      hci_command_hdr;
2309 #define HCI_COMMAND_HDR_SIZE    3
2310
2311 typedef struct {
2312         uint8_t         evt;
2313         uint8_t         plen;
2314 } __attribute__ ((packed))      hci_event_hdr;
2315 #define HCI_EVENT_HDR_SIZE      2
2316
2317 typedef struct {
2318         uint16_t        handle;         /* Handle & Flags(PB, BC) */
2319         uint16_t        dlen;
2320 } __attribute__ ((packed))      hci_acl_hdr;
2321 #define HCI_ACL_HDR_SIZE        4
2322
2323 typedef struct {
2324         uint16_t        handle;
2325         uint8_t         dlen;
2326 } __attribute__ ((packed))      hci_sco_hdr;
2327 #define HCI_SCO_HDR_SIZE        3
2328
2329 typedef struct {
2330         uint16_t        device;
2331         uint16_t        type;
2332         uint16_t        plen;
2333 } __attribute__ ((packed))      hci_msg_hdr;
2334 #define HCI_MSG_HDR_SIZE        6
2335
2336 /* Command opcode pack/unpack */
2337 #define cmd_opcode_pack(ogf, ocf)       (uint16_t)((ocf & 0x03ff)|(ogf << 10))
2338 #define cmd_opcode_ogf(op)              (op >> 10)
2339 #define cmd_opcode_ocf(op)              (op & 0x03ff)
2340
2341 /* ACL handle and flags pack/unpack */
2342 #define acl_handle_pack(h, f)   (uint16_t)((h & 0x0fff)|(f << 12))
2343 #define acl_handle(h)           (h & 0x0fff)
2344 #define acl_flags(h)            (h >> 12)
2345
2346 #endif /* _NO_HCI_DEFS */
2347
2348 /* HCI Socket options */
2349 #define HCI_DATA_DIR    1
2350 #define HCI_FILTER      2
2351 #define HCI_TIME_STAMP  3
2352
2353 /* HCI CMSG flags */
2354 #define HCI_CMSG_DIR    0x0001
2355 #define HCI_CMSG_TSTAMP 0x0002
2356
2357 struct sockaddr_hci {
2358         sa_family_t     hci_family;
2359         unsigned short  hci_dev;
2360         unsigned short  hci_channel;
2361 };
2362 #define HCI_DEV_NONE    0xffff
2363
2364 #define HCI_CHANNEL_RAW         0
2365 #define HCI_CHANNEL_USER        1
2366 #define HCI_CHANNEL_MONITOR     2
2367 #define HCI_CHANNEL_CONTROL     3
2368
2369 struct hci_filter {
2370         uint32_t type_mask;
2371         uint32_t event_mask[2];
2372         uint16_t opcode;
2373 };
2374
2375 #define HCI_FLT_TYPE_BITS       31
2376 #define HCI_FLT_EVENT_BITS      63
2377 #define HCI_FLT_OGF_BITS        63
2378 #define HCI_FLT_OCF_BITS        127
2379
2380 /* Ioctl requests structures */
2381 struct hci_dev_stats {
2382         uint32_t err_rx;
2383         uint32_t err_tx;
2384         uint32_t cmd_tx;
2385         uint32_t evt_rx;
2386         uint32_t acl_tx;
2387         uint32_t acl_rx;
2388         uint32_t sco_tx;
2389         uint32_t sco_rx;
2390         uint32_t byte_rx;
2391         uint32_t byte_tx;
2392 };
2393
2394 struct hci_dev_info {
2395         uint16_t dev_id;
2396         char     name[8];
2397
2398         bdaddr_t bdaddr;
2399
2400         uint32_t flags;
2401         uint8_t  type;
2402
2403         uint8_t  features[8];
2404
2405         uint32_t pkt_type;
2406         uint32_t link_policy;
2407         uint32_t link_mode;
2408
2409         uint16_t acl_mtu;
2410         uint16_t acl_pkts;
2411         uint16_t sco_mtu;
2412         uint16_t sco_pkts;
2413
2414         struct   hci_dev_stats stat;
2415 };
2416
2417 struct hci_conn_info {
2418         uint16_t handle;
2419         bdaddr_t bdaddr;
2420         uint8_t  type;
2421         uint8_t  out;
2422         uint16_t state;
2423         uint32_t link_mode;
2424 };
2425
2426 struct hci_dev_req {
2427         uint16_t dev_id;
2428         uint32_t dev_opt;
2429 };
2430
2431 struct hci_dev_list_req {
2432         uint16_t dev_num;
2433         struct hci_dev_req dev_req[0];  /* hci_dev_req structures */
2434 };
2435
2436 struct hci_conn_list_req {
2437         uint16_t dev_id;
2438         uint16_t conn_num;
2439         struct hci_conn_info conn_info[0];
2440 };
2441
2442 struct hci_conn_info_req {
2443         bdaddr_t bdaddr;
2444         uint8_t  type;
2445         struct hci_conn_info conn_info[0];
2446 };
2447
2448 struct hci_auth_info_req {
2449         bdaddr_t bdaddr;
2450         uint8_t  type;
2451 };
2452
2453 struct hci_inquiry_req {
2454         uint16_t dev_id;
2455         uint16_t flags;
2456         uint8_t  lap[3];
2457         uint8_t  length;
2458         uint8_t  num_rsp;
2459 };
2460 #define IREQ_CACHE_FLUSH 0x0001
2461
2462 #ifdef __cplusplus
2463 }
2464 #endif
2465
2466 #endif /* __HCI_H */