Bluetooth: Add lmp_host_le_capable() macro
[linux-flexiantxendom0.git] / include / net / bluetooth / hci.h
1 /*
2    BlueZ - Bluetooth protocol stack for Linux
3    Copyright (C) 2000-2001 Qualcomm Incorporated
4
5    Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
6
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License version 2 as
9    published by the Free Software Foundation;
10
11    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
12    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
14    IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
15    CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
16    WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17    ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
20    ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
21    COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
22    SOFTWARE IS DISCLAIMED.
23 */
24
25 #ifndef __HCI_H
26 #define __HCI_H
27
28 #define HCI_MAX_ACL_SIZE        1024
29 #define HCI_MAX_SCO_SIZE        255
30 #define HCI_MAX_EVENT_SIZE      260
31 #define HCI_MAX_FRAME_SIZE      (HCI_MAX_ACL_SIZE + 4)
32
33 /* HCI dev events */
34 #define HCI_DEV_REG                     1
35 #define HCI_DEV_UNREG                   2
36 #define HCI_DEV_UP                      3
37 #define HCI_DEV_DOWN                    4
38 #define HCI_DEV_SUSPEND                 5
39 #define HCI_DEV_RESUME                  6
40
41 /* HCI notify events */
42 #define HCI_NOTIFY_CONN_ADD             1
43 #define HCI_NOTIFY_CONN_DEL             2
44 #define HCI_NOTIFY_VOICE_SETTING        3
45
46 /* HCI bus types */
47 #define HCI_VIRTUAL     0
48 #define HCI_USB         1
49 #define HCI_PCCARD      2
50 #define HCI_UART        3
51 #define HCI_RS232       4
52 #define HCI_PCI         5
53 #define HCI_SDIO        6
54
55 /* HCI controller types */
56 #define HCI_BREDR       0x00
57 #define HCI_AMP         0x01
58
59 /* HCI device quirks */
60 enum {
61         HCI_QUIRK_NO_RESET,
62         HCI_QUIRK_RAW_DEVICE,
63         HCI_QUIRK_FIXUP_BUFFER_SIZE
64 };
65
66 /* HCI device flags */
67 enum {
68         HCI_UP,
69         HCI_INIT,
70         HCI_RUNNING,
71
72         HCI_PSCAN,
73         HCI_ISCAN,
74         HCI_AUTH,
75         HCI_ENCRYPT,
76         HCI_INQUIRY,
77
78         HCI_RAW,
79
80         HCI_SETUP,
81         HCI_AUTO_OFF,
82         HCI_MGMT,
83         HCI_PAIRABLE,
84         HCI_SERVICE_CACHE,
85         HCI_LINK_KEYS,
86         HCI_DEBUG_KEYS,
87
88         HCI_RESET,
89 };
90
91 /* HCI ioctl defines */
92 #define HCIDEVUP        _IOW('H', 201, int)
93 #define HCIDEVDOWN      _IOW('H', 202, int)
94 #define HCIDEVRESET     _IOW('H', 203, int)
95 #define HCIDEVRESTAT    _IOW('H', 204, int)
96
97 #define HCIGETDEVLIST   _IOR('H', 210, int)
98 #define HCIGETDEVINFO   _IOR('H', 211, int)
99 #define HCIGETCONNLIST  _IOR('H', 212, int)
100 #define HCIGETCONNINFO  _IOR('H', 213, int)
101 #define HCIGETAUTHINFO  _IOR('H', 215, int)
102
103 #define HCISETRAW       _IOW('H', 220, int)
104 #define HCISETSCAN      _IOW('H', 221, int)
105 #define HCISETAUTH      _IOW('H', 222, int)
106 #define HCISETENCRYPT   _IOW('H', 223, int)
107 #define HCISETPTYPE     _IOW('H', 224, int)
108 #define HCISETLINKPOL   _IOW('H', 225, int)
109 #define HCISETLINKMODE  _IOW('H', 226, int)
110 #define HCISETACLMTU    _IOW('H', 227, int)
111 #define HCISETSCOMTU    _IOW('H', 228, int)
112
113 #define HCIBLOCKADDR    _IOW('H', 230, int)
114 #define HCIUNBLOCKADDR  _IOW('H', 231, int)
115
116 #define HCIINQUIRY      _IOR('H', 240, int)
117
118 /* HCI timeouts */
119 #define HCI_CONNECT_TIMEOUT     (40000) /* 40 seconds */
120 #define HCI_DISCONN_TIMEOUT     (2000)  /* 2 seconds */
121 #define HCI_PAIRING_TIMEOUT     (60000) /* 60 seconds */
122 #define HCI_IDLE_TIMEOUT        (6000)  /* 6 seconds */
123 #define HCI_INIT_TIMEOUT        (10000) /* 10 seconds */
124 #define HCI_CMD_TIMEOUT         (1000)  /* 1 seconds */
125
126 /* HCI data types */
127 #define HCI_COMMAND_PKT         0x01
128 #define HCI_ACLDATA_PKT         0x02
129 #define HCI_SCODATA_PKT         0x03
130 #define HCI_EVENT_PKT           0x04
131 #define HCI_VENDOR_PKT          0xff
132
133 /* HCI packet types */
134 #define HCI_DM1         0x0008
135 #define HCI_DM3         0x0400
136 #define HCI_DM5         0x4000
137 #define HCI_DH1         0x0010
138 #define HCI_DH3         0x0800
139 #define HCI_DH5         0x8000
140
141 #define HCI_HV1         0x0020
142 #define HCI_HV2         0x0040
143 #define HCI_HV3         0x0080
144
145 #define SCO_PTYPE_MASK  (HCI_HV1 | HCI_HV2 | HCI_HV3)
146 #define ACL_PTYPE_MASK  (~SCO_PTYPE_MASK)
147
148 /* eSCO packet types */
149 #define ESCO_HV1        0x0001
150 #define ESCO_HV2        0x0002
151 #define ESCO_HV3        0x0004
152 #define ESCO_EV3        0x0008
153 #define ESCO_EV4        0x0010
154 #define ESCO_EV5        0x0020
155 #define ESCO_2EV3       0x0040
156 #define ESCO_3EV3       0x0080
157 #define ESCO_2EV5       0x0100
158 #define ESCO_3EV5       0x0200
159
160 #define SCO_ESCO_MASK  (ESCO_HV1 | ESCO_HV2 | ESCO_HV3)
161 #define EDR_ESCO_MASK  (ESCO_2EV3 | ESCO_3EV3 | ESCO_2EV5 | ESCO_3EV5)
162
163 /* ACL flags */
164 #define ACL_START_NO_FLUSH      0x00
165 #define ACL_CONT                0x01
166 #define ACL_START               0x02
167 #define ACL_ACTIVE_BCAST        0x04
168 #define ACL_PICO_BCAST          0x08
169
170 /* Baseband links */
171 #define SCO_LINK        0x00
172 #define ACL_LINK        0x01
173 #define ESCO_LINK       0x02
174 /* Low Energy links do not have defined link type. Use invented one */
175 #define LE_LINK         0x80
176
177 /* LMP features */
178 #define LMP_3SLOT       0x01
179 #define LMP_5SLOT       0x02
180 #define LMP_ENCRYPT     0x04
181 #define LMP_SOFFSET     0x08
182 #define LMP_TACCURACY   0x10
183 #define LMP_RSWITCH     0x20
184 #define LMP_HOLD        0x40
185 #define LMP_SNIFF       0x80
186
187 #define LMP_PARK        0x01
188 #define LMP_RSSI        0x02
189 #define LMP_QUALITY     0x04
190 #define LMP_SCO         0x08
191 #define LMP_HV2         0x10
192 #define LMP_HV3         0x20
193 #define LMP_ULAW        0x40
194 #define LMP_ALAW        0x80
195
196 #define LMP_CVSD        0x01
197 #define LMP_PSCHEME     0x02
198 #define LMP_PCONTROL    0x04
199
200 #define LMP_RSSI_INQ    0x40
201 #define LMP_ESCO        0x80
202
203 #define LMP_EV4         0x01
204 #define LMP_EV5         0x02
205 #define LMP_LE          0x40
206
207 #define LMP_SNIFF_SUBR  0x02
208 #define LMP_PAUSE_ENC   0x04
209 #define LMP_EDR_ESCO_2M 0x20
210 #define LMP_EDR_ESCO_3M 0x40
211 #define LMP_EDR_3S_ESCO 0x80
212
213 #define LMP_EXT_INQ     0x01
214 #define LMP_SIMUL_LE_BR 0x02
215 #define LMP_SIMPLE_PAIR 0x08
216 #define LMP_NO_FLUSH    0x40
217
218 #define LMP_LSTO        0x01
219 #define LMP_INQ_TX_PWR  0x02
220 #define LMP_EXTFEATURES 0x80
221
222 /* Extended LMP features */
223 #define LMP_HOST_LE     0x02
224
225 /* Connection modes */
226 #define HCI_CM_ACTIVE   0x0000
227 #define HCI_CM_HOLD     0x0001
228 #define HCI_CM_SNIFF    0x0002
229 #define HCI_CM_PARK     0x0003
230
231 /* Link policies */
232 #define HCI_LP_RSWITCH  0x0001
233 #define HCI_LP_HOLD     0x0002
234 #define HCI_LP_SNIFF    0x0004
235 #define HCI_LP_PARK     0x0008
236
237 /* Link modes */
238 #define HCI_LM_ACCEPT   0x8000
239 #define HCI_LM_MASTER   0x0001
240 #define HCI_LM_AUTH     0x0002
241 #define HCI_LM_ENCRYPT  0x0004
242 #define HCI_LM_TRUSTED  0x0008
243 #define HCI_LM_RELIABLE 0x0010
244 #define HCI_LM_SECURE   0x0020
245
246 /* Authentication types */
247 #define HCI_AT_NO_BONDING               0x00
248 #define HCI_AT_NO_BONDING_MITM          0x01
249 #define HCI_AT_DEDICATED_BONDING        0x02
250 #define HCI_AT_DEDICATED_BONDING_MITM   0x03
251 #define HCI_AT_GENERAL_BONDING          0x04
252 #define HCI_AT_GENERAL_BONDING_MITM     0x05
253
254 /* Link Key types */
255 #define HCI_LK_COMBINATION              0x00
256 #define HCI_LK_LOCAL_UNIT               0x01
257 #define HCI_LK_REMOTE_UNIT              0x02
258 #define HCI_LK_DEBUG_COMBINATION        0x03
259 #define HCI_LK_UNAUTH_COMBINATION       0x04
260 #define HCI_LK_AUTH_COMBINATION         0x05
261 #define HCI_LK_CHANGED_COMBINATION      0x06
262
263 /* -----  HCI Commands ---- */
264 #define HCI_OP_NOP                      0x0000
265
266 #define HCI_OP_INQUIRY                  0x0401
267 struct hci_cp_inquiry {
268         __u8     lap[3];
269         __u8     length;
270         __u8     num_rsp;
271 } __packed;
272
273 #define HCI_OP_INQUIRY_CANCEL           0x0402
274
275 #define HCI_OP_EXIT_PERIODIC_INQ        0x0404
276
277 #define HCI_OP_CREATE_CONN              0x0405
278 struct hci_cp_create_conn {
279         bdaddr_t bdaddr;
280         __le16   pkt_type;
281         __u8     pscan_rep_mode;
282         __u8     pscan_mode;
283         __le16   clock_offset;
284         __u8     role_switch;
285 } __packed;
286
287 #define HCI_OP_DISCONNECT               0x0406
288 struct hci_cp_disconnect {
289         __le16   handle;
290         __u8     reason;
291 } __packed;
292
293 #define HCI_OP_ADD_SCO                  0x0407
294 struct hci_cp_add_sco {
295         __le16   handle;
296         __le16   pkt_type;
297 } __packed;
298
299 #define HCI_OP_CREATE_CONN_CANCEL       0x0408
300 struct hci_cp_create_conn_cancel {
301         bdaddr_t bdaddr;
302 } __packed;
303
304 #define HCI_OP_ACCEPT_CONN_REQ          0x0409
305 struct hci_cp_accept_conn_req {
306         bdaddr_t bdaddr;
307         __u8     role;
308 } __packed;
309
310 #define HCI_OP_REJECT_CONN_REQ          0x040a
311 struct hci_cp_reject_conn_req {
312         bdaddr_t bdaddr;
313         __u8     reason;
314 } __packed;
315
316 #define HCI_OP_LINK_KEY_REPLY           0x040b
317 struct hci_cp_link_key_reply {
318         bdaddr_t bdaddr;
319         __u8     link_key[16];
320 } __packed;
321
322 #define HCI_OP_LINK_KEY_NEG_REPLY       0x040c
323 struct hci_cp_link_key_neg_reply {
324         bdaddr_t bdaddr;
325 } __packed;
326
327 #define HCI_OP_PIN_CODE_REPLY           0x040d
328 struct hci_cp_pin_code_reply {
329         bdaddr_t bdaddr;
330         __u8     pin_len;
331         __u8     pin_code[16];
332 } __packed;
333 struct hci_rp_pin_code_reply {
334         __u8     status;
335         bdaddr_t bdaddr;
336 } __packed;
337
338 #define HCI_OP_PIN_CODE_NEG_REPLY       0x040e
339 struct hci_cp_pin_code_neg_reply {
340         bdaddr_t bdaddr;
341 } __packed;
342 struct hci_rp_pin_code_neg_reply {
343         __u8     status;
344         bdaddr_t bdaddr;
345 } __packed;
346
347 #define HCI_OP_CHANGE_CONN_PTYPE        0x040f
348 struct hci_cp_change_conn_ptype {
349         __le16   handle;
350         __le16   pkt_type;
351 } __packed;
352
353 #define HCI_OP_AUTH_REQUESTED           0x0411
354 struct hci_cp_auth_requested {
355         __le16   handle;
356 } __packed;
357
358 #define HCI_OP_SET_CONN_ENCRYPT         0x0413
359 struct hci_cp_set_conn_encrypt {
360         __le16   handle;
361         __u8     encrypt;
362 } __packed;
363
364 #define HCI_OP_CHANGE_CONN_LINK_KEY     0x0415
365 struct hci_cp_change_conn_link_key {
366         __le16   handle;
367 } __packed;
368
369 #define HCI_OP_REMOTE_NAME_REQ          0x0419
370 struct hci_cp_remote_name_req {
371         bdaddr_t bdaddr;
372         __u8     pscan_rep_mode;
373         __u8     pscan_mode;
374         __le16   clock_offset;
375 } __packed;
376
377 #define HCI_OP_REMOTE_NAME_REQ_CANCEL   0x041a
378 struct hci_cp_remote_name_req_cancel {
379         bdaddr_t bdaddr;
380 } __packed;
381
382 #define HCI_OP_READ_REMOTE_FEATURES     0x041b
383 struct hci_cp_read_remote_features {
384         __le16   handle;
385 } __packed;
386
387 #define HCI_OP_READ_REMOTE_EXT_FEATURES 0x041c
388 struct hci_cp_read_remote_ext_features {
389         __le16   handle;
390         __u8     page;
391 } __packed;
392
393 #define HCI_OP_READ_REMOTE_VERSION      0x041d
394 struct hci_cp_read_remote_version {
395         __le16   handle;
396 } __packed;
397
398 #define HCI_OP_SETUP_SYNC_CONN          0x0428
399 struct hci_cp_setup_sync_conn {
400         __le16   handle;
401         __le32   tx_bandwidth;
402         __le32   rx_bandwidth;
403         __le16   max_latency;
404         __le16   voice_setting;
405         __u8     retrans_effort;
406         __le16   pkt_type;
407 } __packed;
408
409 #define HCI_OP_ACCEPT_SYNC_CONN_REQ     0x0429
410 struct hci_cp_accept_sync_conn_req {
411         bdaddr_t bdaddr;
412         __le32   tx_bandwidth;
413         __le32   rx_bandwidth;
414         __le16   max_latency;
415         __le16   content_format;
416         __u8     retrans_effort;
417         __le16   pkt_type;
418 } __packed;
419
420 #define HCI_OP_REJECT_SYNC_CONN_REQ     0x042a
421 struct hci_cp_reject_sync_conn_req {
422         bdaddr_t bdaddr;
423         __u8     reason;
424 } __packed;
425
426 #define HCI_OP_IO_CAPABILITY_REPLY      0x042b
427 struct hci_cp_io_capability_reply {
428         bdaddr_t bdaddr;
429         __u8     capability;
430         __u8     oob_data;
431         __u8     authentication;
432 } __packed;
433
434 #define HCI_OP_USER_CONFIRM_REPLY               0x042c
435 struct hci_cp_user_confirm_reply {
436         bdaddr_t bdaddr;
437 } __packed;
438 struct hci_rp_user_confirm_reply {
439         __u8     status;
440         bdaddr_t bdaddr;
441 } __packed;
442
443 #define HCI_OP_USER_CONFIRM_NEG_REPLY   0x042d
444
445 #define HCI_OP_REMOTE_OOB_DATA_REPLY    0x0430
446 struct hci_cp_remote_oob_data_reply {
447         bdaddr_t bdaddr;
448         __u8     hash[16];
449         __u8     randomizer[16];
450 } __packed;
451
452 #define HCI_OP_REMOTE_OOB_DATA_NEG_REPLY        0x0433
453 struct hci_cp_remote_oob_data_neg_reply {
454         bdaddr_t bdaddr;
455 } __packed;
456
457 #define HCI_OP_IO_CAPABILITY_NEG_REPLY  0x0434
458 struct hci_cp_io_capability_neg_reply {
459         bdaddr_t bdaddr;
460         __u8     reason;
461 } __packed;
462
463 #define HCI_OP_SNIFF_MODE               0x0803
464 struct hci_cp_sniff_mode {
465         __le16   handle;
466         __le16   max_interval;
467         __le16   min_interval;
468         __le16   attempt;
469         __le16   timeout;
470 } __packed;
471
472 #define HCI_OP_EXIT_SNIFF_MODE          0x0804
473 struct hci_cp_exit_sniff_mode {
474         __le16   handle;
475 } __packed;
476
477 #define HCI_OP_ROLE_DISCOVERY           0x0809
478 struct hci_cp_role_discovery {
479         __le16   handle;
480 } __packed;
481 struct hci_rp_role_discovery {
482         __u8     status;
483         __le16   handle;
484         __u8     role;
485 } __packed;
486
487 #define HCI_OP_SWITCH_ROLE              0x080b
488 struct hci_cp_switch_role {
489         bdaddr_t bdaddr;
490         __u8     role;
491 } __packed;
492
493 #define HCI_OP_READ_LINK_POLICY         0x080c
494 struct hci_cp_read_link_policy {
495         __le16   handle;
496 } __packed;
497 struct hci_rp_read_link_policy {
498         __u8     status;
499         __le16   handle;
500         __le16   policy;
501 } __packed;
502
503 #define HCI_OP_WRITE_LINK_POLICY        0x080d
504 struct hci_cp_write_link_policy {
505         __le16   handle;
506         __le16   policy;
507 } __packed;
508 struct hci_rp_write_link_policy {
509         __u8     status;
510         __le16   handle;
511 } __packed;
512
513 #define HCI_OP_READ_DEF_LINK_POLICY     0x080e
514 struct hci_rp_read_def_link_policy {
515         __u8     status;
516         __le16   policy;
517 } __packed;
518
519 #define HCI_OP_WRITE_DEF_LINK_POLICY    0x080f
520 struct hci_cp_write_def_link_policy {
521         __le16   policy;
522 } __packed;
523
524 #define HCI_OP_SNIFF_SUBRATE            0x0811
525 struct hci_cp_sniff_subrate {
526         __le16   handle;
527         __le16   max_latency;
528         __le16   min_remote_timeout;
529         __le16   min_local_timeout;
530 } __packed;
531
532 #define HCI_OP_SET_EVENT_MASK           0x0c01
533 struct hci_cp_set_event_mask {
534         __u8     mask[8];
535 } __packed;
536
537 #define HCI_OP_RESET                    0x0c03
538
539 #define HCI_OP_SET_EVENT_FLT            0x0c05
540 struct hci_cp_set_event_flt {
541         __u8     flt_type;
542         __u8     cond_type;
543         __u8     condition[0];
544 } __packed;
545
546 /* Filter types */
547 #define HCI_FLT_CLEAR_ALL       0x00
548 #define HCI_FLT_INQ_RESULT      0x01
549 #define HCI_FLT_CONN_SETUP      0x02
550
551 /* CONN_SETUP Condition types */
552 #define HCI_CONN_SETUP_ALLOW_ALL        0x00
553 #define HCI_CONN_SETUP_ALLOW_CLASS      0x01
554 #define HCI_CONN_SETUP_ALLOW_BDADDR     0x02
555
556 /* CONN_SETUP Conditions */
557 #define HCI_CONN_SETUP_AUTO_OFF 0x01
558 #define HCI_CONN_SETUP_AUTO_ON  0x02
559
560 #define HCI_OP_DELETE_STORED_LINK_KEY   0x0c12
561 struct hci_cp_delete_stored_link_key {
562         bdaddr_t bdaddr;
563         __u8     delete_all;
564 } __packed;
565
566 #define HCI_MAX_NAME_LENGTH             248
567
568 #define HCI_OP_WRITE_LOCAL_NAME         0x0c13
569 struct hci_cp_write_local_name {
570         __u8     name[HCI_MAX_NAME_LENGTH];
571 } __packed;
572
573 #define HCI_OP_READ_LOCAL_NAME          0x0c14
574 struct hci_rp_read_local_name {
575         __u8     status;
576         __u8     name[HCI_MAX_NAME_LENGTH];
577 } __packed;
578
579 #define HCI_OP_WRITE_CA_TIMEOUT         0x0c16
580
581 #define HCI_OP_WRITE_PG_TIMEOUT         0x0c18
582
583 #define HCI_OP_WRITE_SCAN_ENABLE        0x0c1a
584         #define SCAN_DISABLED           0x00
585         #define SCAN_INQUIRY            0x01
586         #define SCAN_PAGE               0x02
587
588 #define HCI_OP_READ_AUTH_ENABLE         0x0c1f
589
590 #define HCI_OP_WRITE_AUTH_ENABLE        0x0c20
591         #define AUTH_DISABLED           0x00
592         #define AUTH_ENABLED            0x01
593
594 #define HCI_OP_READ_ENCRYPT_MODE        0x0c21
595
596 #define HCI_OP_WRITE_ENCRYPT_MODE       0x0c22
597         #define ENCRYPT_DISABLED        0x00
598         #define ENCRYPT_P2P             0x01
599         #define ENCRYPT_BOTH            0x02
600
601 #define HCI_OP_READ_CLASS_OF_DEV        0x0c23
602 struct hci_rp_read_class_of_dev {
603         __u8     status;
604         __u8     dev_class[3];
605 } __packed;
606
607 #define HCI_OP_WRITE_CLASS_OF_DEV       0x0c24
608 struct hci_cp_write_class_of_dev {
609         __u8     dev_class[3];
610 } __packed;
611
612 #define HCI_OP_READ_VOICE_SETTING       0x0c25
613 struct hci_rp_read_voice_setting {
614         __u8     status;
615         __le16   voice_setting;
616 } __packed;
617
618 #define HCI_OP_WRITE_VOICE_SETTING      0x0c26
619 struct hci_cp_write_voice_setting {
620         __le16   voice_setting;
621 } __packed;
622
623 #define HCI_OP_HOST_BUFFER_SIZE         0x0c33
624 struct hci_cp_host_buffer_size {
625         __le16   acl_mtu;
626         __u8     sco_mtu;
627         __le16   acl_max_pkt;
628         __le16   sco_max_pkt;
629 } __packed;
630
631 #define HCI_OP_WRITE_INQUIRY_MODE       0x0c45
632
633 #define HCI_MAX_EIR_LENGTH              240
634
635 #define HCI_OP_WRITE_EIR                0x0c52
636 struct hci_cp_write_eir {
637         uint8_t         fec;
638         uint8_t         data[HCI_MAX_EIR_LENGTH];
639 } __packed;
640
641 #define HCI_OP_READ_SSP_MODE            0x0c55
642 struct hci_rp_read_ssp_mode {
643         __u8     status;
644         __u8     mode;
645 } __packed;
646
647 #define HCI_OP_WRITE_SSP_MODE           0x0c56
648 struct hci_cp_write_ssp_mode {
649         __u8     mode;
650 } __packed;
651
652 #define HCI_OP_READ_LOCAL_OOB_DATA              0x0c57
653 struct hci_rp_read_local_oob_data {
654         __u8     status;
655         __u8     hash[16];
656         __u8     randomizer[16];
657 } __packed;
658
659 #define HCI_OP_READ_INQ_RSP_TX_POWER    0x0c58
660
661 #define HCI_OP_WRITE_LE_HOST_SUPPORTED  0x0c6d
662 struct hci_cp_write_le_host_supported {
663         __u8 le;
664         __u8 simul;
665 } __packed;
666
667 #define HCI_OP_READ_LOCAL_VERSION       0x1001
668 struct hci_rp_read_local_version {
669         __u8     status;
670         __u8     hci_ver;
671         __le16   hci_rev;
672         __u8     lmp_ver;
673         __le16   manufacturer;
674         __le16   lmp_subver;
675 } __packed;
676
677 #define HCI_OP_READ_LOCAL_COMMANDS      0x1002
678 struct hci_rp_read_local_commands {
679         __u8     status;
680         __u8     commands[64];
681 } __packed;
682
683 #define HCI_OP_READ_LOCAL_FEATURES      0x1003
684 struct hci_rp_read_local_features {
685         __u8     status;
686         __u8     features[8];
687 } __packed;
688
689 #define HCI_OP_READ_LOCAL_EXT_FEATURES  0x1004
690 struct hci_cp_read_local_ext_features {
691         __u8     page;
692 } __packed;
693 struct hci_rp_read_local_ext_features {
694         __u8     status;
695         __u8     page;
696         __u8     max_page;
697         __u8     features[8];
698 } __packed;
699
700 #define HCI_OP_READ_BUFFER_SIZE         0x1005
701 struct hci_rp_read_buffer_size {
702         __u8     status;
703         __le16   acl_mtu;
704         __u8     sco_mtu;
705         __le16   acl_max_pkt;
706         __le16   sco_max_pkt;
707 } __packed;
708
709 #define HCI_OP_READ_BD_ADDR             0x1009
710 struct hci_rp_read_bd_addr {
711         __u8     status;
712         bdaddr_t bdaddr;
713 } __packed;
714
715 #define HCI_OP_LE_SET_EVENT_MASK        0x2001
716 struct hci_cp_le_set_event_mask {
717         __u8     mask[8];
718 } __packed;
719
720 #define HCI_OP_LE_READ_BUFFER_SIZE      0x2002
721 struct hci_rp_le_read_buffer_size {
722         __u8     status;
723         __le16   le_mtu;
724         __u8     le_max_pkt;
725 } __packed;
726
727 #define HCI_OP_LE_SET_SCAN_ENABLE       0x200c
728 struct hci_cp_le_set_scan_enable {
729         __u8     enable;
730         __u8     filter_dup;
731 } __packed;
732
733 #define HCI_OP_LE_CREATE_CONN           0x200d
734 struct hci_cp_le_create_conn {
735         __le16   scan_interval;
736         __le16   scan_window;
737         __u8     filter_policy;
738         __u8     peer_addr_type;
739         bdaddr_t peer_addr;
740         __u8     own_address_type;
741         __le16   conn_interval_min;
742         __le16   conn_interval_max;
743         __le16   conn_latency;
744         __le16   supervision_timeout;
745         __le16   min_ce_len;
746         __le16   max_ce_len;
747 } __packed;
748
749 #define HCI_OP_LE_CREATE_CONN_CANCEL    0x200e
750
751 #define HCI_OP_LE_CONN_UPDATE           0x2013
752 struct hci_cp_le_conn_update {
753         __le16   handle;
754         __le16   conn_interval_min;
755         __le16   conn_interval_max;
756         __le16   conn_latency;
757         __le16   supervision_timeout;
758         __le16   min_ce_len;
759         __le16   max_ce_len;
760 } __packed;
761
762 #define HCI_OP_LE_START_ENC             0x2019
763 struct hci_cp_le_start_enc {
764         __le16  handle;
765         __u8    rand[8];
766         __le16  ediv;
767         __u8    ltk[16];
768 } __packed;
769
770 #define HCI_OP_LE_LTK_REPLY             0x201a
771 struct hci_cp_le_ltk_reply {
772         __le16  handle;
773         __u8    ltk[16];
774 } __packed;
775 struct hci_rp_le_ltk_reply {
776         __u8    status;
777         __le16  handle;
778 } __packed;
779
780 #define HCI_OP_LE_LTK_NEG_REPLY         0x201b
781 struct hci_cp_le_ltk_neg_reply {
782         __le16  handle;
783 } __packed;
784 struct hci_rp_le_ltk_neg_reply {
785         __u8    status;
786         __le16  handle;
787 } __packed;
788
789 /* ---- HCI Events ---- */
790 #define HCI_EV_INQUIRY_COMPLETE         0x01
791
792 #define HCI_EV_INQUIRY_RESULT           0x02
793 struct inquiry_info {
794         bdaddr_t bdaddr;
795         __u8     pscan_rep_mode;
796         __u8     pscan_period_mode;
797         __u8     pscan_mode;
798         __u8     dev_class[3];
799         __le16   clock_offset;
800 } __packed;
801
802 #define HCI_EV_CONN_COMPLETE            0x03
803 struct hci_ev_conn_complete {
804         __u8     status;
805         __le16   handle;
806         bdaddr_t bdaddr;
807         __u8     link_type;
808         __u8     encr_mode;
809 } __packed;
810
811 #define HCI_EV_CONN_REQUEST             0x04
812 struct hci_ev_conn_request {
813         bdaddr_t bdaddr;
814         __u8     dev_class[3];
815         __u8     link_type;
816 } __packed;
817
818 #define HCI_EV_DISCONN_COMPLETE         0x05
819 struct hci_ev_disconn_complete {
820         __u8     status;
821         __le16   handle;
822         __u8     reason;
823 } __packed;
824
825 #define HCI_EV_AUTH_COMPLETE            0x06
826 struct hci_ev_auth_complete {
827         __u8     status;
828         __le16   handle;
829 } __packed;
830
831 #define HCI_EV_REMOTE_NAME              0x07
832 struct hci_ev_remote_name {
833         __u8     status;
834         bdaddr_t bdaddr;
835         __u8     name[HCI_MAX_NAME_LENGTH];
836 } __packed;
837
838 #define HCI_EV_ENCRYPT_CHANGE           0x08
839 struct hci_ev_encrypt_change {
840         __u8     status;
841         __le16   handle;
842         __u8     encrypt;
843 } __packed;
844
845 #define HCI_EV_CHANGE_LINK_KEY_COMPLETE 0x09
846 struct hci_ev_change_link_key_complete {
847         __u8     status;
848         __le16   handle;
849 } __packed;
850
851 #define HCI_EV_REMOTE_FEATURES          0x0b
852 struct hci_ev_remote_features {
853         __u8     status;
854         __le16   handle;
855         __u8     features[8];
856 } __packed;
857
858 #define HCI_EV_REMOTE_VERSION           0x0c
859 struct hci_ev_remote_version {
860         __u8     status;
861         __le16   handle;
862         __u8     lmp_ver;
863         __le16   manufacturer;
864         __le16   lmp_subver;
865 } __packed;
866
867 #define HCI_EV_QOS_SETUP_COMPLETE       0x0d
868 struct hci_qos {
869         __u8     service_type;
870         __u32    token_rate;
871         __u32    peak_bandwidth;
872         __u32    latency;
873         __u32    delay_variation;
874 } __packed;
875 struct hci_ev_qos_setup_complete {
876         __u8     status;
877         __le16   handle;
878         struct   hci_qos qos;
879 } __packed;
880
881 #define HCI_EV_CMD_COMPLETE             0x0e
882 struct hci_ev_cmd_complete {
883         __u8     ncmd;
884         __le16   opcode;
885 } __packed;
886
887 #define HCI_EV_CMD_STATUS               0x0f
888 struct hci_ev_cmd_status {
889         __u8     status;
890         __u8     ncmd;
891         __le16   opcode;
892 } __packed;
893
894 #define HCI_EV_ROLE_CHANGE              0x12
895 struct hci_ev_role_change {
896         __u8     status;
897         bdaddr_t bdaddr;
898         __u8     role;
899 } __packed;
900
901 #define HCI_EV_NUM_COMP_PKTS            0x13
902 struct hci_ev_num_comp_pkts {
903         __u8     num_hndl;
904         /* variable length part */
905 } __packed;
906
907 #define HCI_EV_MODE_CHANGE              0x14
908 struct hci_ev_mode_change {
909         __u8     status;
910         __le16   handle;
911         __u8     mode;
912         __le16   interval;
913 } __packed;
914
915 #define HCI_EV_PIN_CODE_REQ             0x16
916 struct hci_ev_pin_code_req {
917         bdaddr_t bdaddr;
918 } __packed;
919
920 #define HCI_EV_LINK_KEY_REQ             0x17
921 struct hci_ev_link_key_req {
922         bdaddr_t bdaddr;
923 } __packed;
924
925 #define HCI_EV_LINK_KEY_NOTIFY          0x18
926 struct hci_ev_link_key_notify {
927         bdaddr_t bdaddr;
928         __u8     link_key[16];
929         __u8     key_type;
930 } __packed;
931
932 #define HCI_EV_CLOCK_OFFSET             0x1c
933 struct hci_ev_clock_offset {
934         __u8     status;
935         __le16   handle;
936         __le16   clock_offset;
937 } __packed;
938
939 #define HCI_EV_PKT_TYPE_CHANGE          0x1d
940 struct hci_ev_pkt_type_change {
941         __u8     status;
942         __le16   handle;
943         __le16   pkt_type;
944 } __packed;
945
946 #define HCI_EV_PSCAN_REP_MODE           0x20
947 struct hci_ev_pscan_rep_mode {
948         bdaddr_t bdaddr;
949         __u8     pscan_rep_mode;
950 } __packed;
951
952 #define HCI_EV_INQUIRY_RESULT_WITH_RSSI 0x22
953 struct inquiry_info_with_rssi {
954         bdaddr_t bdaddr;
955         __u8     pscan_rep_mode;
956         __u8     pscan_period_mode;
957         __u8     dev_class[3];
958         __le16   clock_offset;
959         __s8     rssi;
960 } __packed;
961 struct inquiry_info_with_rssi_and_pscan_mode {
962         bdaddr_t bdaddr;
963         __u8     pscan_rep_mode;
964         __u8     pscan_period_mode;
965         __u8     pscan_mode;
966         __u8     dev_class[3];
967         __le16   clock_offset;
968         __s8     rssi;
969 } __packed;
970
971 #define HCI_EV_REMOTE_EXT_FEATURES      0x23
972 struct hci_ev_remote_ext_features {
973         __u8     status;
974         __le16   handle;
975         __u8     page;
976         __u8     max_page;
977         __u8     features[8];
978 } __packed;
979
980 #define HCI_EV_SYNC_CONN_COMPLETE       0x2c
981 struct hci_ev_sync_conn_complete {
982         __u8     status;
983         __le16   handle;
984         bdaddr_t bdaddr;
985         __u8     link_type;
986         __u8     tx_interval;
987         __u8     retrans_window;
988         __le16   rx_pkt_len;
989         __le16   tx_pkt_len;
990         __u8     air_mode;
991 } __packed;
992
993 #define HCI_EV_SYNC_CONN_CHANGED        0x2d
994 struct hci_ev_sync_conn_changed {
995         __u8     status;
996         __le16   handle;
997         __u8     tx_interval;
998         __u8     retrans_window;
999         __le16   rx_pkt_len;
1000         __le16   tx_pkt_len;
1001 } __packed;
1002
1003 #define HCI_EV_SNIFF_SUBRATE            0x2e
1004 struct hci_ev_sniff_subrate {
1005         __u8     status;
1006         __le16   handle;
1007         __le16   max_tx_latency;
1008         __le16   max_rx_latency;
1009         __le16   max_remote_timeout;
1010         __le16   max_local_timeout;
1011 } __packed;
1012
1013 #define HCI_EV_EXTENDED_INQUIRY_RESULT  0x2f
1014 struct extended_inquiry_info {
1015         bdaddr_t bdaddr;
1016         __u8     pscan_rep_mode;
1017         __u8     pscan_period_mode;
1018         __u8     dev_class[3];
1019         __le16   clock_offset;
1020         __s8     rssi;
1021         __u8     data[240];
1022 } __packed;
1023
1024 #define HCI_EV_IO_CAPA_REQUEST          0x31
1025 struct hci_ev_io_capa_request {
1026         bdaddr_t bdaddr;
1027 } __packed;
1028
1029 #define HCI_EV_IO_CAPA_REPLY            0x32
1030 struct hci_ev_io_capa_reply {
1031         bdaddr_t bdaddr;
1032         __u8     capability;
1033         __u8     oob_data;
1034         __u8     authentication;
1035 } __packed;
1036
1037 #define HCI_EV_USER_CONFIRM_REQUEST     0x33
1038 struct hci_ev_user_confirm_req {
1039         bdaddr_t        bdaddr;
1040         __le32          passkey;
1041 } __packed;
1042
1043 #define HCI_EV_REMOTE_OOB_DATA_REQUEST  0x35
1044 struct hci_ev_remote_oob_data_request {
1045         bdaddr_t bdaddr;
1046 } __packed;
1047
1048 #define HCI_EV_SIMPLE_PAIR_COMPLETE     0x36
1049 struct hci_ev_simple_pair_complete {
1050         __u8     status;
1051         bdaddr_t bdaddr;
1052 } __packed;
1053
1054 #define HCI_EV_REMOTE_HOST_FEATURES     0x3d
1055 struct hci_ev_remote_host_features {
1056         bdaddr_t bdaddr;
1057         __u8     features[8];
1058 } __packed;
1059
1060 #define HCI_EV_LE_META                  0x3e
1061 struct hci_ev_le_meta {
1062         __u8     subevent;
1063 } __packed;
1064
1065 /* Low energy meta events */
1066 #define HCI_EV_LE_CONN_COMPLETE         0x01
1067 struct hci_ev_le_conn_complete {
1068         __u8     status;
1069         __le16   handle;
1070         __u8     role;
1071         __u8     bdaddr_type;
1072         bdaddr_t bdaddr;
1073         __le16   interval;
1074         __le16   latency;
1075         __le16   supervision_timeout;
1076         __u8     clk_accurancy;
1077 } __packed;
1078
1079 #define HCI_EV_LE_LTK_REQ               0x05
1080 struct hci_ev_le_ltk_req {
1081         __le16  handle;
1082         __u8    random[8];
1083         __le16  ediv;
1084 } __packed;
1085
1086 /* Advertising report event types */
1087 #define ADV_IND         0x00
1088 #define ADV_DIRECT_IND  0x01
1089 #define ADV_SCAN_IND    0x02
1090 #define ADV_NONCONN_IND 0x03
1091 #define ADV_SCAN_RSP    0x04
1092
1093 #define ADDR_LE_DEV_PUBLIC      0x00
1094 #define ADDR_LE_DEV_RANDOM      0x01
1095
1096 #define HCI_EV_LE_ADVERTISING_REPORT    0x02
1097 struct hci_ev_le_advertising_info {
1098         __u8     evt_type;
1099         __u8     bdaddr_type;
1100         bdaddr_t bdaddr;
1101         __u8     length;
1102         __u8     data[0];
1103 } __packed;
1104
1105 /* Internal events generated by Bluetooth stack */
1106 #define HCI_EV_STACK_INTERNAL   0xfd
1107 struct hci_ev_stack_internal {
1108         __u16    type;
1109         __u8     data[0];
1110 } __packed;
1111
1112 #define HCI_EV_SI_DEVICE        0x01
1113 struct hci_ev_si_device {
1114         __u16    event;
1115         __u16    dev_id;
1116 } __packed;
1117
1118 #define HCI_EV_SI_SECURITY      0x02
1119 struct hci_ev_si_security {
1120         __u16    event;
1121         __u16    proto;
1122         __u16    subproto;
1123         __u8     incoming;
1124 } __packed;
1125
1126 /* ---- HCI Packet structures ---- */
1127 #define HCI_COMMAND_HDR_SIZE 3
1128 #define HCI_EVENT_HDR_SIZE   2
1129 #define HCI_ACL_HDR_SIZE     4
1130 #define HCI_SCO_HDR_SIZE     3
1131
1132 struct hci_command_hdr {
1133         __le16  opcode;         /* OCF & OGF */
1134         __u8    plen;
1135 } __packed;
1136
1137 struct hci_event_hdr {
1138         __u8    evt;
1139         __u8    plen;
1140 } __packed;
1141
1142 struct hci_acl_hdr {
1143         __le16  handle;         /* Handle & Flags(PB, BC) */
1144         __le16  dlen;
1145 } __packed;
1146
1147 struct hci_sco_hdr {
1148         __le16  handle;
1149         __u8    dlen;
1150 } __packed;
1151
1152 #include <linux/skbuff.h>
1153 static inline struct hci_event_hdr *hci_event_hdr(const struct sk_buff *skb)
1154 {
1155         return (struct hci_event_hdr *) skb->data;
1156 }
1157
1158 static inline struct hci_acl_hdr *hci_acl_hdr(const struct sk_buff *skb)
1159 {
1160         return (struct hci_acl_hdr *) skb->data;
1161 }
1162
1163 static inline struct hci_sco_hdr *hci_sco_hdr(const struct sk_buff *skb)
1164 {
1165         return (struct hci_sco_hdr *) skb->data;
1166 }
1167
1168 /* Command opcode pack/unpack */
1169 #define hci_opcode_pack(ogf, ocf)       (__u16) ((ocf & 0x03ff)|(ogf << 10))
1170 #define hci_opcode_ogf(op)              (op >> 10)
1171 #define hci_opcode_ocf(op)              (op & 0x03ff)
1172
1173 /* ACL handle and flags pack/unpack */
1174 #define hci_handle_pack(h, f)   (__u16) ((h & 0x0fff)|(f << 12))
1175 #define hci_handle(h)           (h & 0x0fff)
1176 #define hci_flags(h)            (h >> 12)
1177
1178 /* ---- HCI Sockets ---- */
1179
1180 /* Socket options */
1181 #define HCI_DATA_DIR    1
1182 #define HCI_FILTER      2
1183 #define HCI_TIME_STAMP  3
1184
1185 /* CMSG flags */
1186 #define HCI_CMSG_DIR    0x0001
1187 #define HCI_CMSG_TSTAMP 0x0002
1188
1189 struct sockaddr_hci {
1190         sa_family_t    hci_family;
1191         unsigned short hci_dev;
1192         unsigned short hci_channel;
1193 };
1194 #define HCI_DEV_NONE    0xffff
1195
1196 #define HCI_CHANNEL_RAW         0
1197 #define HCI_CHANNEL_CONTROL     1
1198
1199 struct hci_filter {
1200         unsigned long type_mask;
1201         unsigned long event_mask[2];
1202         __le16 opcode;
1203 };
1204
1205 struct hci_ufilter {
1206         __u32  type_mask;
1207         __u32  event_mask[2];
1208         __le16 opcode;
1209 };
1210
1211 #define HCI_FLT_TYPE_BITS       31
1212 #define HCI_FLT_EVENT_BITS      63
1213 #define HCI_FLT_OGF_BITS        63
1214 #define HCI_FLT_OCF_BITS        127
1215
1216 /* ---- HCI Ioctl requests structures ---- */
1217 struct hci_dev_stats {
1218         __u32 err_rx;
1219         __u32 err_tx;
1220         __u32 cmd_tx;
1221         __u32 evt_rx;
1222         __u32 acl_tx;
1223         __u32 acl_rx;
1224         __u32 sco_tx;
1225         __u32 sco_rx;
1226         __u32 byte_rx;
1227         __u32 byte_tx;
1228 };
1229
1230 struct hci_dev_info {
1231         __u16 dev_id;
1232         char  name[8];
1233
1234         bdaddr_t bdaddr;
1235
1236         __u32 flags;
1237         __u8  type;
1238
1239         __u8  features[8];
1240
1241         __u32 pkt_type;
1242         __u32 link_policy;
1243         __u32 link_mode;
1244
1245         __u16 acl_mtu;
1246         __u16 acl_pkts;
1247         __u16 sco_mtu;
1248         __u16 sco_pkts;
1249
1250         struct hci_dev_stats stat;
1251 };
1252
1253 struct hci_conn_info {
1254         __u16    handle;
1255         bdaddr_t bdaddr;
1256         __u8     type;
1257         __u8     out;
1258         __u16    state;
1259         __u32    link_mode;
1260 };
1261
1262 struct hci_dev_req {
1263         __u16  dev_id;
1264         __u32  dev_opt;
1265 };
1266
1267 struct hci_dev_list_req {
1268         __u16  dev_num;
1269         struct hci_dev_req dev_req[0];  /* hci_dev_req structures */
1270 };
1271
1272 struct hci_conn_list_req {
1273         __u16  dev_id;
1274         __u16  conn_num;
1275         struct hci_conn_info conn_info[0];
1276 };
1277
1278 struct hci_conn_info_req {
1279         bdaddr_t bdaddr;
1280         __u8     type;
1281         struct   hci_conn_info conn_info[0];
1282 };
1283
1284 struct hci_auth_info_req {
1285         bdaddr_t bdaddr;
1286         __u8     type;
1287 };
1288
1289 struct hci_inquiry_req {
1290         __u16 dev_id;
1291         __u16 flags;
1292         __u8  lap[3];
1293         __u8  length;
1294         __u8  num_rsp;
1295 };
1296 #define IREQ_CACHE_FLUSH 0x0001
1297
1298 #endif /* __HCI_H */