]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/net/bluetooth/hci.h
[Bluetooth] Correct SCO buffer size on request
[mirror_ubuntu-bionic-kernel.git] / include / net / bluetooth / hci.h
CommitLineData
1da177e4
LT
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 device types */
47#define HCI_VHCI 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
54/* HCI device quirks */
55enum {
56 HCI_QUIRK_RESET_ON_INIT,
da1f5198
MH
57 HCI_QUIRK_RAW_DEVICE,
58 HCI_QUIRK_FIXUP_BUFFER_SIZE
1da177e4
LT
59};
60
61/* HCI device flags */
62enum {
63 HCI_UP,
64 HCI_INIT,
65 HCI_RUNNING,
66
67 HCI_PSCAN,
68 HCI_ISCAN,
69 HCI_AUTH,
70 HCI_ENCRYPT,
71 HCI_INQUIRY,
72
73 HCI_RAW,
74
75 HCI_SECMGR
76};
77
78/* HCI ioctl defines */
79#define HCIDEVUP _IOW('H', 201, int)
80#define HCIDEVDOWN _IOW('H', 202, int)
81#define HCIDEVRESET _IOW('H', 203, int)
82#define HCIDEVRESTAT _IOW('H', 204, int)
83
84#define HCIGETDEVLIST _IOR('H', 210, int)
85#define HCIGETDEVINFO _IOR('H', 211, int)
86#define HCIGETCONNLIST _IOR('H', 212, int)
87#define HCIGETCONNINFO _IOR('H', 213, int)
88
89#define HCISETRAW _IOW('H', 220, int)
90#define HCISETSCAN _IOW('H', 221, int)
91#define HCISETAUTH _IOW('H', 222, int)
92#define HCISETENCRYPT _IOW('H', 223, int)
93#define HCISETPTYPE _IOW('H', 224, int)
94#define HCISETLINKPOL _IOW('H', 225, int)
95#define HCISETLINKMODE _IOW('H', 226, int)
96#define HCISETACLMTU _IOW('H', 227, int)
97#define HCISETSCOMTU _IOW('H', 228, int)
98
99#define HCISETSECMGR _IOW('H', 230, int)
100
101#define HCIINQUIRY _IOR('H', 240, int)
102
103/* HCI timeouts */
104#define HCI_CONN_TIMEOUT (HZ * 40)
105#define HCI_DISCONN_TIMEOUT (HZ * 2)
106#define HCI_CONN_IDLE_TIMEOUT (HZ * 60)
107
108/* HCI Packet types */
109#define HCI_COMMAND_PKT 0x01
110#define HCI_ACLDATA_PKT 0x02
111#define HCI_SCODATA_PKT 0x03
112#define HCI_EVENT_PKT 0x04
113#define HCI_VENDOR_PKT 0xff
114
115/* HCI Packet types */
116#define HCI_DM1 0x0008
117#define HCI_DM3 0x0400
118#define HCI_DM5 0x4000
119#define HCI_DH1 0x0010
120#define HCI_DH3 0x0800
121#define HCI_DH5 0x8000
122
123#define HCI_HV1 0x0020
124#define HCI_HV2 0x0040
125#define HCI_HV3 0x0080
126
127#define SCO_PTYPE_MASK (HCI_HV1 | HCI_HV2 | HCI_HV3)
128#define ACL_PTYPE_MASK (~SCO_PTYPE_MASK)
129
130/* ACL flags */
131#define ACL_CONT 0x01
132#define ACL_START 0x02
133#define ACL_ACTIVE_BCAST 0x04
134#define ACL_PICO_BCAST 0x08
135
136/* Baseband links */
137#define SCO_LINK 0x00
138#define ACL_LINK 0x01
139
140/* LMP features */
141#define LMP_3SLOT 0x01
142#define LMP_5SLOT 0x02
143#define LMP_ENCRYPT 0x04
144#define LMP_SOFFSET 0x08
145#define LMP_TACCURACY 0x10
146#define LMP_RSWITCH 0x20
147#define LMP_HOLD 0x40
148#define LMP_SNIF 0x80
149
150#define LMP_PARK 0x01
151#define LMP_RSSI 0x02
152#define LMP_QUALITY 0x04
153#define LMP_SCO 0x08
154#define LMP_HV2 0x10
155#define LMP_HV3 0x20
156#define LMP_ULAW 0x40
157#define LMP_ALAW 0x80
158
159#define LMP_CVSD 0x01
160#define LMP_PSCHEME 0x02
161#define LMP_PCONTROL 0x04
162
163/* Link policies */
164#define HCI_LP_RSWITCH 0x0001
165#define HCI_LP_HOLD 0x0002
166#define HCI_LP_SNIFF 0x0004
167#define HCI_LP_PARK 0x0008
168
169/* Link mode */
170#define HCI_LM_ACCEPT 0x8000
171#define HCI_LM_MASTER 0x0001
172#define HCI_LM_AUTH 0x0002
173#define HCI_LM_ENCRYPT 0x0004
174#define HCI_LM_TRUSTED 0x0008
175#define HCI_LM_RELIABLE 0x0010
176#define HCI_LM_SECURE 0x0020
177
178/* ----- HCI Commands ---- */
179/* OGF & OCF values */
180
181/* Informational Parameters */
182#define OGF_INFO_PARAM 0x04
183
184#define OCF_READ_LOCAL_VERSION 0x0001
185struct hci_rp_read_loc_version {
186 __u8 status;
187 __u8 hci_ver;
1ebb9252 188 __le16 hci_rev;
1da177e4 189 __u8 lmp_ver;
1ebb9252
MH
190 __le16 manufacturer;
191 __le16 lmp_subver;
1da177e4
LT
192} __attribute__ ((packed));
193
194#define OCF_READ_LOCAL_FEATURES 0x0003
195struct hci_rp_read_loc_features {
196 __u8 status;
197 __u8 features[8];
198} __attribute__ ((packed));
199
200#define OCF_READ_BUFFER_SIZE 0x0005
201struct hci_rp_read_buffer_size {
202 __u8 status;
1ebb9252 203 __le16 acl_mtu;
1da177e4 204 __u8 sco_mtu;
1ebb9252
MH
205 __le16 acl_max_pkt;
206 __le16 sco_max_pkt;
1da177e4
LT
207} __attribute__ ((packed));
208
209#define OCF_READ_BD_ADDR 0x0009
210struct hci_rp_read_bd_addr {
211 __u8 status;
212 bdaddr_t bdaddr;
213} __attribute__ ((packed));
214
215/* Host Controller and Baseband */
216#define OGF_HOST_CTL 0x03
217#define OCF_RESET 0x0003
218#define OCF_READ_AUTH_ENABLE 0x001F
219#define OCF_WRITE_AUTH_ENABLE 0x0020
220 #define AUTH_DISABLED 0x00
221 #define AUTH_ENABLED 0x01
222
223#define OCF_READ_ENCRYPT_MODE 0x0021
224#define OCF_WRITE_ENCRYPT_MODE 0x0022
225 #define ENCRYPT_DISABLED 0x00
226 #define ENCRYPT_P2P 0x01
227 #define ENCRYPT_BOTH 0x02
228
229#define OCF_WRITE_CA_TIMEOUT 0x0016
230#define OCF_WRITE_PG_TIMEOUT 0x0018
231
232#define OCF_WRITE_SCAN_ENABLE 0x001A
233 #define SCAN_DISABLED 0x00
234 #define SCAN_INQUIRY 0x01
235 #define SCAN_PAGE 0x02
236
237#define OCF_SET_EVENT_FLT 0x0005
238struct hci_cp_set_event_flt {
239 __u8 flt_type;
240 __u8 cond_type;
241 __u8 condition[0];
242} __attribute__ ((packed));
243
244/* Filter types */
245#define HCI_FLT_CLEAR_ALL 0x00
246#define HCI_FLT_INQ_RESULT 0x01
247#define HCI_FLT_CONN_SETUP 0x02
248
249/* CONN_SETUP Condition types */
250#define HCI_CONN_SETUP_ALLOW_ALL 0x00
251#define HCI_CONN_SETUP_ALLOW_CLASS 0x01
252#define HCI_CONN_SETUP_ALLOW_BDADDR 0x02
253
254/* CONN_SETUP Conditions */
255#define HCI_CONN_SETUP_AUTO_OFF 0x01
256#define HCI_CONN_SETUP_AUTO_ON 0x02
257
258#define OCF_READ_CLASS_OF_DEV 0x0023
259struct hci_rp_read_dev_class {
260 __u8 status;
261 __u8 dev_class[3];
262} __attribute__ ((packed));
263
264#define OCF_WRITE_CLASS_OF_DEV 0x0024
265struct hci_cp_write_dev_class {
266 __u8 dev_class[3];
267} __attribute__ ((packed));
268
269#define OCF_READ_VOICE_SETTING 0x0025
270struct hci_rp_read_voice_setting {
1ebb9252
MH
271 __u8 status;
272 __le16 voice_setting;
1da177e4
LT
273} __attribute__ ((packed));
274
275#define OCF_WRITE_VOICE_SETTING 0x0026
276struct hci_cp_write_voice_setting {
1ebb9252 277 __le16 voice_setting;
1da177e4
LT
278} __attribute__ ((packed));
279
280#define OCF_HOST_BUFFER_SIZE 0x0033
281struct hci_cp_host_buffer_size {
1ebb9252 282 __le16 acl_mtu;
1da177e4 283 __u8 sco_mtu;
1ebb9252
MH
284 __le16 acl_max_pkt;
285 __le16 sco_max_pkt;
1da177e4
LT
286} __attribute__ ((packed));
287
288/* Link Control */
289#define OGF_LINK_CTL 0x01
290#define OCF_CREATE_CONN 0x0005
291struct hci_cp_create_conn {
292 bdaddr_t bdaddr;
1ebb9252 293 __le16 pkt_type;
1da177e4
LT
294 __u8 pscan_rep_mode;
295 __u8 pscan_mode;
1ebb9252 296 __le16 clock_offset;
1da177e4
LT
297 __u8 role_switch;
298} __attribute__ ((packed));
299
300#define OCF_ACCEPT_CONN_REQ 0x0009
301struct hci_cp_accept_conn_req {
302 bdaddr_t bdaddr;
303 __u8 role;
304} __attribute__ ((packed));
305
306#define OCF_REJECT_CONN_REQ 0x000a
307struct hci_cp_reject_conn_req {
308 bdaddr_t bdaddr;
309 __u8 reason;
310} __attribute__ ((packed));
311
312#define OCF_DISCONNECT 0x0006
313struct hci_cp_disconnect {
1ebb9252 314 __le16 handle;
1da177e4
LT
315 __u8 reason;
316} __attribute__ ((packed));
317
318#define OCF_ADD_SCO 0x0007
319struct hci_cp_add_sco {
1ebb9252
MH
320 __le16 handle;
321 __le16 pkt_type;
1da177e4
LT
322} __attribute__ ((packed));
323
324#define OCF_INQUIRY 0x0001
325struct hci_cp_inquiry {
326 __u8 lap[3];
327 __u8 length;
328 __u8 num_rsp;
329} __attribute__ ((packed));
330
331#define OCF_INQUIRY_CANCEL 0x0002
332
333#define OCF_LINK_KEY_REPLY 0x000B
334struct hci_cp_link_key_reply {
335 bdaddr_t bdaddr;
336 __u8 link_key[16];
337} __attribute__ ((packed));
338
339#define OCF_LINK_KEY_NEG_REPLY 0x000C
340struct hci_cp_link_key_neg_reply {
341 bdaddr_t bdaddr;
342} __attribute__ ((packed));
343
344#define OCF_PIN_CODE_REPLY 0x000D
345struct hci_cp_pin_code_reply {
346 bdaddr_t bdaddr;
347 __u8 pin_len;
348 __u8 pin_code[16];
349} __attribute__ ((packed));
350
351#define OCF_PIN_CODE_NEG_REPLY 0x000E
352struct hci_cp_pin_code_neg_reply {
353 bdaddr_t bdaddr;
354} __attribute__ ((packed));
355
356#define OCF_CHANGE_CONN_PTYPE 0x000F
357struct hci_cp_change_conn_ptype {
1ebb9252
MH
358 __le16 handle;
359 __le16 pkt_type;
1da177e4
LT
360} __attribute__ ((packed));
361
362#define OCF_AUTH_REQUESTED 0x0011
363struct hci_cp_auth_requested {
1ebb9252 364 __le16 handle;
1da177e4
LT
365} __attribute__ ((packed));
366
367#define OCF_SET_CONN_ENCRYPT 0x0013
368struct hci_cp_set_conn_encrypt {
1ebb9252 369 __le16 handle;
1da177e4
LT
370 __u8 encrypt;
371} __attribute__ ((packed));
372
373#define OCF_CHANGE_CONN_LINK_KEY 0x0015
374struct hci_cp_change_conn_link_key {
1ebb9252 375 __le16 handle;
1da177e4
LT
376} __attribute__ ((packed));
377
378#define OCF_READ_REMOTE_FEATURES 0x001B
379struct hci_cp_read_rmt_features {
1ebb9252 380 __le16 handle;
1da177e4
LT
381} __attribute__ ((packed));
382
383#define OCF_READ_REMOTE_VERSION 0x001D
384struct hci_cp_read_rmt_version {
1ebb9252 385 __le16 handle;
1da177e4
LT
386} __attribute__ ((packed));
387
388/* Link Policy */
389#define OGF_LINK_POLICY 0x02
390#define OCF_ROLE_DISCOVERY 0x0009
391struct hci_cp_role_discovery {
1ebb9252 392 __le16 handle;
1da177e4
LT
393} __attribute__ ((packed));
394struct hci_rp_role_discovery {
395 __u8 status;
1ebb9252 396 __le16 handle;
1da177e4
LT
397 __u8 role;
398} __attribute__ ((packed));
399
400#define OCF_READ_LINK_POLICY 0x000C
401struct hci_cp_read_link_policy {
1ebb9252 402 __le16 handle;
1da177e4
LT
403} __attribute__ ((packed));
404struct hci_rp_read_link_policy {
405 __u8 status;
1ebb9252
MH
406 __le16 handle;
407 __le16 policy;
1da177e4
LT
408} __attribute__ ((packed));
409
410#define OCF_SWITCH_ROLE 0x000B
411struct hci_cp_switch_role {
412 bdaddr_t bdaddr;
413 __u8 role;
414} __attribute__ ((packed));
415
416#define OCF_WRITE_LINK_POLICY 0x000D
417struct hci_cp_write_link_policy {
1ebb9252
MH
418 __le16 handle;
419 __le16 policy;
1da177e4
LT
420} __attribute__ ((packed));
421struct hci_rp_write_link_policy {
422 __u8 status;
1ebb9252 423 __le16 handle;
1da177e4
LT
424} __attribute__ ((packed));
425
426/* Status params */
427#define OGF_STATUS_PARAM 0x05
428
429/* Testing commands */
430#define OGF_TESTING_CMD 0x3E
431
432/* Vendor specific commands */
433#define OGF_VENDOR_CMD 0x3F
434
435/* ---- HCI Events ---- */
436#define HCI_EV_INQUIRY_COMPLETE 0x01
437
438#define HCI_EV_INQUIRY_RESULT 0x02
439struct inquiry_info {
440 bdaddr_t bdaddr;
441 __u8 pscan_rep_mode;
442 __u8 pscan_period_mode;
443 __u8 pscan_mode;
444 __u8 dev_class[3];
1ebb9252 445 __le16 clock_offset;
1da177e4
LT
446} __attribute__ ((packed));
447
448#define HCI_EV_INQUIRY_RESULT_WITH_RSSI 0x22
449struct inquiry_info_with_rssi {
450 bdaddr_t bdaddr;
451 __u8 pscan_rep_mode;
452 __u8 pscan_period_mode;
453 __u8 dev_class[3];
1ebb9252 454 __le16 clock_offset;
1da177e4
LT
455 __s8 rssi;
456} __attribute__ ((packed));
45bb4bf0
MH
457struct inquiry_info_with_rssi_and_pscan_mode {
458 bdaddr_t bdaddr;
459 __u8 pscan_rep_mode;
460 __u8 pscan_period_mode;
461 __u8 pscan_mode;
462 __u8 dev_class[3];
1ebb9252 463 __le16 clock_offset;
45bb4bf0
MH
464 __s8 rssi;
465} __attribute__ ((packed));
1da177e4 466
21d9e30e
MH
467#define HCI_EV_EXTENDED_INQUIRY_RESULT 0x2F
468struct extended_inquiry_info {
469 bdaddr_t bdaddr;
470 __u8 pscan_rep_mode;
471 __u8 pscan_period_mode;
472 __u8 dev_class[3];
1ebb9252 473 __le16 clock_offset;
21d9e30e
MH
474 __s8 rssi;
475 __u8 data[240];
476} __attribute__ ((packed));
477
1da177e4
LT
478#define HCI_EV_CONN_COMPLETE 0x03
479struct hci_ev_conn_complete {
480 __u8 status;
1ebb9252 481 __le16 handle;
1da177e4
LT
482 bdaddr_t bdaddr;
483 __u8 link_type;
484 __u8 encr_mode;
485} __attribute__ ((packed));
486
487#define HCI_EV_CONN_REQUEST 0x04
488struct hci_ev_conn_request {
489 bdaddr_t bdaddr;
490 __u8 dev_class[3];
491 __u8 link_type;
492} __attribute__ ((packed));
493
494#define HCI_EV_DISCONN_COMPLETE 0x05
495struct hci_ev_disconn_complete {
496 __u8 status;
1ebb9252 497 __le16 handle;
1da177e4
LT
498 __u8 reason;
499} __attribute__ ((packed));
500
501#define HCI_EV_AUTH_COMPLETE 0x06
502struct hci_ev_auth_complete {
503 __u8 status;
1ebb9252 504 __le16 handle;
1da177e4
LT
505} __attribute__ ((packed));
506
507#define HCI_EV_ENCRYPT_CHANGE 0x08
508struct hci_ev_encrypt_change {
509 __u8 status;
1ebb9252 510 __le16 handle;
1da177e4
LT
511 __u8 encrypt;
512} __attribute__ ((packed));
513
514#define HCI_EV_CHANGE_CONN_LINK_KEY_COMPLETE 0x09
515struct hci_ev_change_conn_link_key_complete {
516 __u8 status;
1ebb9252 517 __le16 handle;
1da177e4
LT
518} __attribute__ ((packed));
519
520#define HCI_EV_QOS_SETUP_COMPLETE 0x0D
521struct hci_qos {
522 __u8 service_type;
523 __u32 token_rate;
524 __u32 peak_bandwidth;
525 __u32 latency;
526 __u32 delay_variation;
527} __attribute__ ((packed));
528struct hci_ev_qos_setup_complete {
529 __u8 status;
1ebb9252 530 __le16 handle;
1da177e4
LT
531 struct hci_qos qos;
532} __attribute__ ((packed));
533
534#define HCI_EV_CMD_COMPLETE 0x0E
535struct hci_ev_cmd_complete {
536 __u8 ncmd;
1ebb9252 537 __le16 opcode;
1da177e4
LT
538} __attribute__ ((packed));
539
540#define HCI_EV_CMD_STATUS 0x0F
541struct hci_ev_cmd_status {
542 __u8 status;
543 __u8 ncmd;
1ebb9252 544 __le16 opcode;
1da177e4
LT
545} __attribute__ ((packed));
546
547#define HCI_EV_NUM_COMP_PKTS 0x13
548struct hci_ev_num_comp_pkts {
549 __u8 num_hndl;
550 /* variable length part */
551} __attribute__ ((packed));
552
553#define HCI_EV_ROLE_CHANGE 0x12
554struct hci_ev_role_change {
555 __u8 status;
556 bdaddr_t bdaddr;
557 __u8 role;
558} __attribute__ ((packed));
559
560#define HCI_EV_MODE_CHANGE 0x14
561struct hci_ev_mode_change {
562 __u8 status;
1ebb9252 563 __le16 handle;
1da177e4 564 __u8 mode;
1ebb9252 565 __le16 interval;
1da177e4
LT
566} __attribute__ ((packed));
567
568#define HCI_EV_PIN_CODE_REQ 0x16
569struct hci_ev_pin_code_req {
570 bdaddr_t bdaddr;
571} __attribute__ ((packed));
572
573#define HCI_EV_LINK_KEY_REQ 0x17
574struct hci_ev_link_key_req {
575 bdaddr_t bdaddr;
576} __attribute__ ((packed));
577
578#define HCI_EV_LINK_KEY_NOTIFY 0x18
579struct hci_ev_link_key_notify {
580 bdaddr_t bdaddr;
581 __u8 link_key[16];
582 __u8 key_type;
583} __attribute__ ((packed));
584
585#define HCI_EV_RMT_FEATURES 0x0B
586struct hci_ev_rmt_features {
587 __u8 status;
1ebb9252 588 __le16 handle;
1da177e4
LT
589 __u8 features[8];
590} __attribute__ ((packed));
591
592#define HCI_EV_RMT_VERSION 0x0C
593struct hci_ev_rmt_version {
594 __u8 status;
1ebb9252 595 __le16 handle;
1da177e4 596 __u8 lmp_ver;
1ebb9252
MH
597 __le16 manufacturer;
598 __le16 lmp_subver;
1da177e4
LT
599} __attribute__ ((packed));
600
601#define HCI_EV_CLOCK_OFFSET 0x01C
602struct hci_ev_clock_offset {
603 __u8 status;
1ebb9252
MH
604 __le16 handle;
605 __le16 clock_offset;
1da177e4
LT
606} __attribute__ ((packed));
607
85a1e930
MH
608#define HCI_EV_PSCAN_REP_MODE 0x20
609struct hci_ev_pscan_rep_mode {
610 bdaddr_t bdaddr;
611 __u8 pscan_rep_mode;
612} __attribute__ ((packed));
613
1da177e4
LT
614/* Internal events generated by Bluetooth stack */
615#define HCI_EV_STACK_INTERNAL 0xFD
616struct hci_ev_stack_internal {
617 __u16 type;
618 __u8 data[0];
619} __attribute__ ((packed));
620
621#define HCI_EV_SI_DEVICE 0x01
622struct hci_ev_si_device {
623 __u16 event;
624 __u16 dev_id;
625} __attribute__ ((packed));
626
627#define HCI_EV_SI_SECURITY 0x02
628struct hci_ev_si_security {
629 __u16 event;
630 __u16 proto;
631 __u16 subproto;
632 __u8 incoming;
633} __attribute__ ((packed));
634
635/* ---- HCI Packet structures ---- */
636#define HCI_COMMAND_HDR_SIZE 3
637#define HCI_EVENT_HDR_SIZE 2
638#define HCI_ACL_HDR_SIZE 4
639#define HCI_SCO_HDR_SIZE 3
640
641struct hci_command_hdr {
1ebb9252 642 __le16 opcode; /* OCF & OGF */
1da177e4
LT
643 __u8 plen;
644} __attribute__ ((packed));
645
646struct hci_event_hdr {
647 __u8 evt;
648 __u8 plen;
649} __attribute__ ((packed));
650
651struct hci_acl_hdr {
1ebb9252
MH
652 __le16 handle; /* Handle & Flags(PB, BC) */
653 __le16 dlen;
1da177e4
LT
654} __attribute__ ((packed));
655
656struct hci_sco_hdr {
1ebb9252 657 __le16 handle;
1da177e4
LT
658 __u8 dlen;
659} __attribute__ ((packed));
660
661/* Command opcode pack/unpack */
1ebb9252 662#define hci_opcode_pack(ogf, ocf) (__u16) ((ocf & 0x03ff)|(ogf << 10))
1da177e4
LT
663#define hci_opcode_ogf(op) (op >> 10)
664#define hci_opcode_ocf(op) (op & 0x03ff)
665
666/* ACL handle and flags pack/unpack */
1ebb9252 667#define hci_handle_pack(h, f) (__u16) ((h & 0x0fff)|(f << 12))
1da177e4
LT
668#define hci_handle(h) (h & 0x0fff)
669#define hci_flags(h) (h >> 12)
670
671/* ---- HCI Sockets ---- */
672
673/* Socket options */
674#define HCI_DATA_DIR 1
675#define HCI_FILTER 2
676#define HCI_TIME_STAMP 3
677
678/* CMSG flags */
679#define HCI_CMSG_DIR 0x0001
680#define HCI_CMSG_TSTAMP 0x0002
681
682struct sockaddr_hci {
683 sa_family_t hci_family;
684 unsigned short hci_dev;
685};
686#define HCI_DEV_NONE 0xffff
687
688struct hci_filter {
689 unsigned long type_mask;
690 unsigned long event_mask[2];
691 __u16 opcode;
692};
693
694struct hci_ufilter {
695 __u32 type_mask;
696 __u32 event_mask[2];
697 __u16 opcode;
698};
699
700#define HCI_FLT_TYPE_BITS 31
701#define HCI_FLT_EVENT_BITS 63
702#define HCI_FLT_OGF_BITS 63
703#define HCI_FLT_OCF_BITS 127
704
705/* ---- HCI Ioctl requests structures ---- */
706struct hci_dev_stats {
707 __u32 err_rx;
708 __u32 err_tx;
709 __u32 cmd_tx;
710 __u32 evt_rx;
711 __u32 acl_tx;
712 __u32 acl_rx;
713 __u32 sco_tx;
714 __u32 sco_rx;
715 __u32 byte_rx;
716 __u32 byte_tx;
717};
718
719struct hci_dev_info {
720 __u16 dev_id;
721 char name[8];
722
723 bdaddr_t bdaddr;
724
725 __u32 flags;
726 __u8 type;
727
728 __u8 features[8];
729
730 __u32 pkt_type;
731 __u32 link_policy;
732 __u32 link_mode;
733
734 __u16 acl_mtu;
735 __u16 acl_pkts;
736 __u16 sco_mtu;
737 __u16 sco_pkts;
738
739 struct hci_dev_stats stat;
740};
741
742struct hci_conn_info {
743 __u16 handle;
744 bdaddr_t bdaddr;
745 __u8 type;
746 __u8 out;
747 __u16 state;
748 __u32 link_mode;
749};
750
751struct hci_dev_req {
752 __u16 dev_id;
753 __u32 dev_opt;
754};
755
756struct hci_dev_list_req {
757 __u16 dev_num;
758 struct hci_dev_req dev_req[0]; /* hci_dev_req structures */
759};
760
761struct hci_conn_list_req {
762 __u16 dev_id;
763 __u16 conn_num;
764 struct hci_conn_info conn_info[0];
765};
766
767struct hci_conn_info_req {
768 bdaddr_t bdaddr;
769 __u8 type;
770 struct hci_conn_info conn_info[0];
771};
772
773struct hci_inquiry_req {
774 __u16 dev_id;
775 __u16 flags;
776 __u8 lap[3];
777 __u8 length;
778 __u8 num_rsp;
779};
780#define IREQ_CACHE_FLUSH 0x0001
781
782#endif /* __HCI_H */