Bluetooth: Implement a more complete adapter initialization sequence
[deliverable/linux.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 };
85
86 /* HCI ioctl defines */
87 #define HCIDEVUP _IOW('H', 201, int)
88 #define HCIDEVDOWN _IOW('H', 202, int)
89 #define HCIDEVRESET _IOW('H', 203, int)
90 #define HCIDEVRESTAT _IOW('H', 204, int)
91
92 #define HCIGETDEVLIST _IOR('H', 210, int)
93 #define HCIGETDEVINFO _IOR('H', 211, int)
94 #define HCIGETCONNLIST _IOR('H', 212, int)
95 #define HCIGETCONNINFO _IOR('H', 213, int)
96 #define HCIGETAUTHINFO _IOR('H', 215, int)
97
98 #define HCISETRAW _IOW('H', 220, int)
99 #define HCISETSCAN _IOW('H', 221, int)
100 #define HCISETAUTH _IOW('H', 222, int)
101 #define HCISETENCRYPT _IOW('H', 223, int)
102 #define HCISETPTYPE _IOW('H', 224, int)
103 #define HCISETLINKPOL _IOW('H', 225, int)
104 #define HCISETLINKMODE _IOW('H', 226, int)
105 #define HCISETACLMTU _IOW('H', 227, int)
106 #define HCISETSCOMTU _IOW('H', 228, int)
107
108 #define HCIBLOCKADDR _IOW('H', 230, int)
109 #define HCIUNBLOCKADDR _IOW('H', 231, int)
110
111 #define HCIINQUIRY _IOR('H', 240, int)
112
113 /* HCI timeouts */
114 #define HCI_CONNECT_TIMEOUT (40000) /* 40 seconds */
115 #define HCI_DISCONN_TIMEOUT (2000) /* 2 seconds */
116 #define HCI_PAIRING_TIMEOUT (60000) /* 60 seconds */
117 #define HCI_IDLE_TIMEOUT (6000) /* 6 seconds */
118 #define HCI_INIT_TIMEOUT (10000) /* 10 seconds */
119
120 /* HCI data types */
121 #define HCI_COMMAND_PKT 0x01
122 #define HCI_ACLDATA_PKT 0x02
123 #define HCI_SCODATA_PKT 0x03
124 #define HCI_EVENT_PKT 0x04
125 #define HCI_VENDOR_PKT 0xff
126
127 /* HCI packet types */
128 #define HCI_DM1 0x0008
129 #define HCI_DM3 0x0400
130 #define HCI_DM5 0x4000
131 #define HCI_DH1 0x0010
132 #define HCI_DH3 0x0800
133 #define HCI_DH5 0x8000
134
135 #define HCI_HV1 0x0020
136 #define HCI_HV2 0x0040
137 #define HCI_HV3 0x0080
138
139 #define SCO_PTYPE_MASK (HCI_HV1 | HCI_HV2 | HCI_HV3)
140 #define ACL_PTYPE_MASK (~SCO_PTYPE_MASK)
141
142 /* eSCO packet types */
143 #define ESCO_HV1 0x0001
144 #define ESCO_HV2 0x0002
145 #define ESCO_HV3 0x0004
146 #define ESCO_EV3 0x0008
147 #define ESCO_EV4 0x0010
148 #define ESCO_EV5 0x0020
149 #define ESCO_2EV3 0x0040
150 #define ESCO_3EV3 0x0080
151 #define ESCO_2EV5 0x0100
152 #define ESCO_3EV5 0x0200
153
154 #define SCO_ESCO_MASK (ESCO_HV1 | ESCO_HV2 | ESCO_HV3)
155 #define EDR_ESCO_MASK (ESCO_2EV3 | ESCO_3EV3 | ESCO_2EV5 | ESCO_3EV5)
156
157 /* ACL flags */
158 #define ACL_START_NO_FLUSH 0x00
159 #define ACL_CONT 0x01
160 #define ACL_START 0x02
161 #define ACL_ACTIVE_BCAST 0x04
162 #define ACL_PICO_BCAST 0x08
163
164 /* Baseband links */
165 #define SCO_LINK 0x00
166 #define ACL_LINK 0x01
167 #define ESCO_LINK 0x02
168
169 /* LMP features */
170 #define LMP_3SLOT 0x01
171 #define LMP_5SLOT 0x02
172 #define LMP_ENCRYPT 0x04
173 #define LMP_SOFFSET 0x08
174 #define LMP_TACCURACY 0x10
175 #define LMP_RSWITCH 0x20
176 #define LMP_HOLD 0x40
177 #define LMP_SNIFF 0x80
178
179 #define LMP_PARK 0x01
180 #define LMP_RSSI 0x02
181 #define LMP_QUALITY 0x04
182 #define LMP_SCO 0x08
183 #define LMP_HV2 0x10
184 #define LMP_HV3 0x20
185 #define LMP_ULAW 0x40
186 #define LMP_ALAW 0x80
187
188 #define LMP_CVSD 0x01
189 #define LMP_PSCHEME 0x02
190 #define LMP_PCONTROL 0x04
191
192 #define LMP_RSSI_INQ 0x40
193 #define LMP_ESCO 0x80
194
195 #define LMP_EV4 0x01
196 #define LMP_EV5 0x02
197 #define LMP_LE 0x40
198
199 #define LMP_SNIFF_SUBR 0x02
200 #define LMP_PAUSE_ENC 0x04
201 #define LMP_EDR_ESCO_2M 0x20
202 #define LMP_EDR_ESCO_3M 0x40
203 #define LMP_EDR_3S_ESCO 0x80
204
205 #define LMP_EXT_INQ 0x01
206 #define LMP_SIMPLE_PAIR 0x08
207 #define LMP_NO_FLUSH 0x40
208
209 #define LMP_LSTO 0x01
210 #define LMP_INQ_TX_PWR 0x02
211
212 /* Connection modes */
213 #define HCI_CM_ACTIVE 0x0000
214 #define HCI_CM_HOLD 0x0001
215 #define HCI_CM_SNIFF 0x0002
216 #define HCI_CM_PARK 0x0003
217
218 /* Link policies */
219 #define HCI_LP_RSWITCH 0x0001
220 #define HCI_LP_HOLD 0x0002
221 #define HCI_LP_SNIFF 0x0004
222 #define HCI_LP_PARK 0x0008
223
224 /* Link modes */
225 #define HCI_LM_ACCEPT 0x8000
226 #define HCI_LM_MASTER 0x0001
227 #define HCI_LM_AUTH 0x0002
228 #define HCI_LM_ENCRYPT 0x0004
229 #define HCI_LM_TRUSTED 0x0008
230 #define HCI_LM_RELIABLE 0x0010
231 #define HCI_LM_SECURE 0x0020
232
233 /* Authentication types */
234 #define HCI_AT_NO_BONDING 0x00
235 #define HCI_AT_NO_BONDING_MITM 0x01
236 #define HCI_AT_DEDICATED_BONDING 0x02
237 #define HCI_AT_DEDICATED_BONDING_MITM 0x03
238 #define HCI_AT_GENERAL_BONDING 0x04
239 #define HCI_AT_GENERAL_BONDING_MITM 0x05
240
241 /* ----- HCI Commands ---- */
242 #define HCI_OP_INQUIRY 0x0401
243 struct hci_cp_inquiry {
244 __u8 lap[3];
245 __u8 length;
246 __u8 num_rsp;
247 } __packed;
248
249 #define HCI_OP_INQUIRY_CANCEL 0x0402
250
251 #define HCI_OP_EXIT_PERIODIC_INQ 0x0404
252
253 #define HCI_OP_CREATE_CONN 0x0405
254 struct hci_cp_create_conn {
255 bdaddr_t bdaddr;
256 __le16 pkt_type;
257 __u8 pscan_rep_mode;
258 __u8 pscan_mode;
259 __le16 clock_offset;
260 __u8 role_switch;
261 } __packed;
262
263 #define HCI_OP_DISCONNECT 0x0406
264 struct hci_cp_disconnect {
265 __le16 handle;
266 __u8 reason;
267 } __packed;
268
269 #define HCI_OP_ADD_SCO 0x0407
270 struct hci_cp_add_sco {
271 __le16 handle;
272 __le16 pkt_type;
273 } __packed;
274
275 #define HCI_OP_CREATE_CONN_CANCEL 0x0408
276 struct hci_cp_create_conn_cancel {
277 bdaddr_t bdaddr;
278 } __packed;
279
280 #define HCI_OP_ACCEPT_CONN_REQ 0x0409
281 struct hci_cp_accept_conn_req {
282 bdaddr_t bdaddr;
283 __u8 role;
284 } __packed;
285
286 #define HCI_OP_REJECT_CONN_REQ 0x040a
287 struct hci_cp_reject_conn_req {
288 bdaddr_t bdaddr;
289 __u8 reason;
290 } __packed;
291
292 #define HCI_OP_LINK_KEY_REPLY 0x040b
293 struct hci_cp_link_key_reply {
294 bdaddr_t bdaddr;
295 __u8 link_key[16];
296 } __packed;
297
298 #define HCI_OP_LINK_KEY_NEG_REPLY 0x040c
299 struct hci_cp_link_key_neg_reply {
300 bdaddr_t bdaddr;
301 } __packed;
302
303 #define HCI_OP_PIN_CODE_REPLY 0x040d
304 struct hci_cp_pin_code_reply {
305 bdaddr_t bdaddr;
306 __u8 pin_len;
307 __u8 pin_code[16];
308 } __packed;
309
310 #define HCI_OP_PIN_CODE_NEG_REPLY 0x040e
311 struct hci_cp_pin_code_neg_reply {
312 bdaddr_t bdaddr;
313 } __packed;
314
315 #define HCI_OP_CHANGE_CONN_PTYPE 0x040f
316 struct hci_cp_change_conn_ptype {
317 __le16 handle;
318 __le16 pkt_type;
319 } __packed;
320
321 #define HCI_OP_AUTH_REQUESTED 0x0411
322 struct hci_cp_auth_requested {
323 __le16 handle;
324 } __packed;
325
326 #define HCI_OP_SET_CONN_ENCRYPT 0x0413
327 struct hci_cp_set_conn_encrypt {
328 __le16 handle;
329 __u8 encrypt;
330 } __packed;
331
332 #define HCI_OP_CHANGE_CONN_LINK_KEY 0x0415
333 struct hci_cp_change_conn_link_key {
334 __le16 handle;
335 } __packed;
336
337 #define HCI_OP_REMOTE_NAME_REQ 0x0419
338 struct hci_cp_remote_name_req {
339 bdaddr_t bdaddr;
340 __u8 pscan_rep_mode;
341 __u8 pscan_mode;
342 __le16 clock_offset;
343 } __packed;
344
345 #define HCI_OP_REMOTE_NAME_REQ_CANCEL 0x041a
346 struct hci_cp_remote_name_req_cancel {
347 bdaddr_t bdaddr;
348 } __packed;
349
350 #define HCI_OP_READ_REMOTE_FEATURES 0x041b
351 struct hci_cp_read_remote_features {
352 __le16 handle;
353 } __packed;
354
355 #define HCI_OP_READ_REMOTE_EXT_FEATURES 0x041c
356 struct hci_cp_read_remote_ext_features {
357 __le16 handle;
358 __u8 page;
359 } __packed;
360
361 #define HCI_OP_READ_REMOTE_VERSION 0x041d
362 struct hci_cp_read_remote_version {
363 __le16 handle;
364 } __packed;
365
366 #define HCI_OP_SETUP_SYNC_CONN 0x0428
367 struct hci_cp_setup_sync_conn {
368 __le16 handle;
369 __le32 tx_bandwidth;
370 __le32 rx_bandwidth;
371 __le16 max_latency;
372 __le16 voice_setting;
373 __u8 retrans_effort;
374 __le16 pkt_type;
375 } __packed;
376
377 #define HCI_OP_ACCEPT_SYNC_CONN_REQ 0x0429
378 struct hci_cp_accept_sync_conn_req {
379 bdaddr_t bdaddr;
380 __le32 tx_bandwidth;
381 __le32 rx_bandwidth;
382 __le16 max_latency;
383 __le16 content_format;
384 __u8 retrans_effort;
385 __le16 pkt_type;
386 } __packed;
387
388 #define HCI_OP_REJECT_SYNC_CONN_REQ 0x042a
389 struct hci_cp_reject_sync_conn_req {
390 bdaddr_t bdaddr;
391 __u8 reason;
392 } __packed;
393
394 #define HCI_OP_IO_CAPABILITY_NEG_REPLY 0x0434
395 struct hci_cp_io_capability_neg_reply {
396 bdaddr_t bdaddr;
397 __u8 reason;
398 } __packed;
399
400 #define HCI_OP_SNIFF_MODE 0x0803
401 struct hci_cp_sniff_mode {
402 __le16 handle;
403 __le16 max_interval;
404 __le16 min_interval;
405 __le16 attempt;
406 __le16 timeout;
407 } __packed;
408
409 #define HCI_OP_EXIT_SNIFF_MODE 0x0804
410 struct hci_cp_exit_sniff_mode {
411 __le16 handle;
412 } __packed;
413
414 #define HCI_OP_ROLE_DISCOVERY 0x0809
415 struct hci_cp_role_discovery {
416 __le16 handle;
417 } __packed;
418 struct hci_rp_role_discovery {
419 __u8 status;
420 __le16 handle;
421 __u8 role;
422 } __packed;
423
424 #define HCI_OP_SWITCH_ROLE 0x080b
425 struct hci_cp_switch_role {
426 bdaddr_t bdaddr;
427 __u8 role;
428 } __packed;
429
430 #define HCI_OP_READ_LINK_POLICY 0x080c
431 struct hci_cp_read_link_policy {
432 __le16 handle;
433 } __packed;
434 struct hci_rp_read_link_policy {
435 __u8 status;
436 __le16 handle;
437 __le16 policy;
438 } __packed;
439
440 #define HCI_OP_WRITE_LINK_POLICY 0x080d
441 struct hci_cp_write_link_policy {
442 __le16 handle;
443 __le16 policy;
444 } __packed;
445 struct hci_rp_write_link_policy {
446 __u8 status;
447 __le16 handle;
448 } __packed;
449
450 #define HCI_OP_READ_DEF_LINK_POLICY 0x080e
451 struct hci_rp_read_def_link_policy {
452 __u8 status;
453 __le16 policy;
454 } __packed;
455
456 #define HCI_OP_WRITE_DEF_LINK_POLICY 0x080f
457 struct hci_cp_write_def_link_policy {
458 __le16 policy;
459 } __packed;
460
461 #define HCI_OP_SNIFF_SUBRATE 0x0811
462 struct hci_cp_sniff_subrate {
463 __le16 handle;
464 __le16 max_latency;
465 __le16 min_remote_timeout;
466 __le16 min_local_timeout;
467 } __packed;
468
469 #define HCI_OP_SET_EVENT_MASK 0x0c01
470 struct hci_cp_set_event_mask {
471 __u8 mask[8];
472 } __packed;
473
474 #define HCI_OP_RESET 0x0c03
475
476 #define HCI_OP_SET_EVENT_FLT 0x0c05
477 struct hci_cp_set_event_flt {
478 __u8 flt_type;
479 __u8 cond_type;
480 __u8 condition[0];
481 } __packed;
482
483 /* Filter types */
484 #define HCI_FLT_CLEAR_ALL 0x00
485 #define HCI_FLT_INQ_RESULT 0x01
486 #define HCI_FLT_CONN_SETUP 0x02
487
488 /* CONN_SETUP Condition types */
489 #define HCI_CONN_SETUP_ALLOW_ALL 0x00
490 #define HCI_CONN_SETUP_ALLOW_CLASS 0x01
491 #define HCI_CONN_SETUP_ALLOW_BDADDR 0x02
492
493 /* CONN_SETUP Conditions */
494 #define HCI_CONN_SETUP_AUTO_OFF 0x01
495 #define HCI_CONN_SETUP_AUTO_ON 0x02
496
497 #define HCI_OP_DELETE_STORED_LINK_KEY 0x0c12
498 struct hci_cp_delete_stored_link_key {
499 bdaddr_t bdaddr;
500 __u8 delete_all;
501 } __packed;
502
503 #define HCI_OP_WRITE_LOCAL_NAME 0x0c13
504 struct hci_cp_write_local_name {
505 __u8 name[248];
506 } __packed;
507
508 #define HCI_OP_READ_LOCAL_NAME 0x0c14
509 struct hci_rp_read_local_name {
510 __u8 status;
511 __u8 name[248];
512 } __packed;
513
514 #define HCI_OP_WRITE_CA_TIMEOUT 0x0c16
515
516 #define HCI_OP_WRITE_PG_TIMEOUT 0x0c18
517
518 #define HCI_OP_WRITE_SCAN_ENABLE 0x0c1a
519 #define SCAN_DISABLED 0x00
520 #define SCAN_INQUIRY 0x01
521 #define SCAN_PAGE 0x02
522
523 #define HCI_OP_READ_AUTH_ENABLE 0x0c1f
524
525 #define HCI_OP_WRITE_AUTH_ENABLE 0x0c20
526 #define AUTH_DISABLED 0x00
527 #define AUTH_ENABLED 0x01
528
529 #define HCI_OP_READ_ENCRYPT_MODE 0x0c21
530
531 #define HCI_OP_WRITE_ENCRYPT_MODE 0x0c22
532 #define ENCRYPT_DISABLED 0x00
533 #define ENCRYPT_P2P 0x01
534 #define ENCRYPT_BOTH 0x02
535
536 #define HCI_OP_READ_CLASS_OF_DEV 0x0c23
537 struct hci_rp_read_class_of_dev {
538 __u8 status;
539 __u8 dev_class[3];
540 } __packed;
541
542 #define HCI_OP_WRITE_CLASS_OF_DEV 0x0c24
543 struct hci_cp_write_class_of_dev {
544 __u8 dev_class[3];
545 } __packed;
546
547 #define HCI_OP_READ_VOICE_SETTING 0x0c25
548 struct hci_rp_read_voice_setting {
549 __u8 status;
550 __le16 voice_setting;
551 } __packed;
552
553 #define HCI_OP_WRITE_VOICE_SETTING 0x0c26
554 struct hci_cp_write_voice_setting {
555 __le16 voice_setting;
556 } __packed;
557
558 #define HCI_OP_HOST_BUFFER_SIZE 0x0c33
559 struct hci_cp_host_buffer_size {
560 __le16 acl_mtu;
561 __u8 sco_mtu;
562 __le16 acl_max_pkt;
563 __le16 sco_max_pkt;
564 } __packed;
565
566 #define HCI_OP_WRITE_INQUIRY_MODE 0x0c45
567
568 #define HCI_OP_READ_SSP_MODE 0x0c55
569 struct hci_rp_read_ssp_mode {
570 __u8 status;
571 __u8 mode;
572 } __packed;
573
574 #define HCI_OP_WRITE_SSP_MODE 0x0c56
575 struct hci_cp_write_ssp_mode {
576 __u8 mode;
577 } __packed;
578
579 #define HCI_OP_READ_INQ_RSP_TX_POWER 0x0c58
580
581 #define HCI_OP_READ_LOCAL_VERSION 0x1001
582 struct hci_rp_read_local_version {
583 __u8 status;
584 __u8 hci_ver;
585 __le16 hci_rev;
586 __u8 lmp_ver;
587 __le16 manufacturer;
588 __le16 lmp_subver;
589 } __packed;
590
591 #define HCI_OP_READ_LOCAL_COMMANDS 0x1002
592 struct hci_rp_read_local_commands {
593 __u8 status;
594 __u8 commands[64];
595 } __packed;
596
597 #define HCI_OP_READ_LOCAL_FEATURES 0x1003
598 struct hci_rp_read_local_features {
599 __u8 status;
600 __u8 features[8];
601 } __packed;
602
603 #define HCI_OP_READ_LOCAL_EXT_FEATURES 0x1004
604 struct hci_rp_read_local_ext_features {
605 __u8 status;
606 __u8 page;
607 __u8 max_page;
608 __u8 features[8];
609 } __packed;
610
611 #define HCI_OP_READ_BUFFER_SIZE 0x1005
612 struct hci_rp_read_buffer_size {
613 __u8 status;
614 __le16 acl_mtu;
615 __u8 sco_mtu;
616 __le16 acl_max_pkt;
617 __le16 sco_max_pkt;
618 } __packed;
619
620 #define HCI_OP_READ_BD_ADDR 0x1009
621 struct hci_rp_read_bd_addr {
622 __u8 status;
623 bdaddr_t bdaddr;
624 } __packed;
625
626 /* ---- HCI Events ---- */
627 #define HCI_EV_INQUIRY_COMPLETE 0x01
628
629 #define HCI_EV_INQUIRY_RESULT 0x02
630 struct inquiry_info {
631 bdaddr_t bdaddr;
632 __u8 pscan_rep_mode;
633 __u8 pscan_period_mode;
634 __u8 pscan_mode;
635 __u8 dev_class[3];
636 __le16 clock_offset;
637 } __packed;
638
639 #define HCI_EV_CONN_COMPLETE 0x03
640 struct hci_ev_conn_complete {
641 __u8 status;
642 __le16 handle;
643 bdaddr_t bdaddr;
644 __u8 link_type;
645 __u8 encr_mode;
646 } __packed;
647
648 #define HCI_EV_CONN_REQUEST 0x04
649 struct hci_ev_conn_request {
650 bdaddr_t bdaddr;
651 __u8 dev_class[3];
652 __u8 link_type;
653 } __packed;
654
655 #define HCI_EV_DISCONN_COMPLETE 0x05
656 struct hci_ev_disconn_complete {
657 __u8 status;
658 __le16 handle;
659 __u8 reason;
660 } __packed;
661
662 #define HCI_EV_AUTH_COMPLETE 0x06
663 struct hci_ev_auth_complete {
664 __u8 status;
665 __le16 handle;
666 } __packed;
667
668 #define HCI_EV_REMOTE_NAME 0x07
669 struct hci_ev_remote_name {
670 __u8 status;
671 bdaddr_t bdaddr;
672 __u8 name[248];
673 } __packed;
674
675 #define HCI_EV_ENCRYPT_CHANGE 0x08
676 struct hci_ev_encrypt_change {
677 __u8 status;
678 __le16 handle;
679 __u8 encrypt;
680 } __packed;
681
682 #define HCI_EV_CHANGE_LINK_KEY_COMPLETE 0x09
683 struct hci_ev_change_link_key_complete {
684 __u8 status;
685 __le16 handle;
686 } __packed;
687
688 #define HCI_EV_REMOTE_FEATURES 0x0b
689 struct hci_ev_remote_features {
690 __u8 status;
691 __le16 handle;
692 __u8 features[8];
693 } __packed;
694
695 #define HCI_EV_REMOTE_VERSION 0x0c
696 struct hci_ev_remote_version {
697 __u8 status;
698 __le16 handle;
699 __u8 lmp_ver;
700 __le16 manufacturer;
701 __le16 lmp_subver;
702 } __packed;
703
704 #define HCI_EV_QOS_SETUP_COMPLETE 0x0d
705 struct hci_qos {
706 __u8 service_type;
707 __u32 token_rate;
708 __u32 peak_bandwidth;
709 __u32 latency;
710 __u32 delay_variation;
711 } __packed;
712 struct hci_ev_qos_setup_complete {
713 __u8 status;
714 __le16 handle;
715 struct hci_qos qos;
716 } __packed;
717
718 #define HCI_EV_CMD_COMPLETE 0x0e
719 struct hci_ev_cmd_complete {
720 __u8 ncmd;
721 __le16 opcode;
722 } __packed;
723
724 #define HCI_EV_CMD_STATUS 0x0f
725 struct hci_ev_cmd_status {
726 __u8 status;
727 __u8 ncmd;
728 __le16 opcode;
729 } __packed;
730
731 #define HCI_EV_ROLE_CHANGE 0x12
732 struct hci_ev_role_change {
733 __u8 status;
734 bdaddr_t bdaddr;
735 __u8 role;
736 } __packed;
737
738 #define HCI_EV_NUM_COMP_PKTS 0x13
739 struct hci_ev_num_comp_pkts {
740 __u8 num_hndl;
741 /* variable length part */
742 } __packed;
743
744 #define HCI_EV_MODE_CHANGE 0x14
745 struct hci_ev_mode_change {
746 __u8 status;
747 __le16 handle;
748 __u8 mode;
749 __le16 interval;
750 } __packed;
751
752 #define HCI_EV_PIN_CODE_REQ 0x16
753 struct hci_ev_pin_code_req {
754 bdaddr_t bdaddr;
755 } __packed;
756
757 #define HCI_EV_LINK_KEY_REQ 0x17
758 struct hci_ev_link_key_req {
759 bdaddr_t bdaddr;
760 } __packed;
761
762 #define HCI_EV_LINK_KEY_NOTIFY 0x18
763 struct hci_ev_link_key_notify {
764 bdaddr_t bdaddr;
765 __u8 link_key[16];
766 __u8 key_type;
767 } __packed;
768
769 #define HCI_EV_CLOCK_OFFSET 0x1c
770 struct hci_ev_clock_offset {
771 __u8 status;
772 __le16 handle;
773 __le16 clock_offset;
774 } __packed;
775
776 #define HCI_EV_PKT_TYPE_CHANGE 0x1d
777 struct hci_ev_pkt_type_change {
778 __u8 status;
779 __le16 handle;
780 __le16 pkt_type;
781 } __packed;
782
783 #define HCI_EV_PSCAN_REP_MODE 0x20
784 struct hci_ev_pscan_rep_mode {
785 bdaddr_t bdaddr;
786 __u8 pscan_rep_mode;
787 } __packed;
788
789 #define HCI_EV_INQUIRY_RESULT_WITH_RSSI 0x22
790 struct inquiry_info_with_rssi {
791 bdaddr_t bdaddr;
792 __u8 pscan_rep_mode;
793 __u8 pscan_period_mode;
794 __u8 dev_class[3];
795 __le16 clock_offset;
796 __s8 rssi;
797 } __packed;
798 struct inquiry_info_with_rssi_and_pscan_mode {
799 bdaddr_t bdaddr;
800 __u8 pscan_rep_mode;
801 __u8 pscan_period_mode;
802 __u8 pscan_mode;
803 __u8 dev_class[3];
804 __le16 clock_offset;
805 __s8 rssi;
806 } __packed;
807
808 #define HCI_EV_REMOTE_EXT_FEATURES 0x23
809 struct hci_ev_remote_ext_features {
810 __u8 status;
811 __le16 handle;
812 __u8 page;
813 __u8 max_page;
814 __u8 features[8];
815 } __packed;
816
817 #define HCI_EV_SYNC_CONN_COMPLETE 0x2c
818 struct hci_ev_sync_conn_complete {
819 __u8 status;
820 __le16 handle;
821 bdaddr_t bdaddr;
822 __u8 link_type;
823 __u8 tx_interval;
824 __u8 retrans_window;
825 __le16 rx_pkt_len;
826 __le16 tx_pkt_len;
827 __u8 air_mode;
828 } __packed;
829
830 #define HCI_EV_SYNC_CONN_CHANGED 0x2d
831 struct hci_ev_sync_conn_changed {
832 __u8 status;
833 __le16 handle;
834 __u8 tx_interval;
835 __u8 retrans_window;
836 __le16 rx_pkt_len;
837 __le16 tx_pkt_len;
838 } __packed;
839
840 #define HCI_EV_SNIFF_SUBRATE 0x2e
841 struct hci_ev_sniff_subrate {
842 __u8 status;
843 __le16 handle;
844 __le16 max_tx_latency;
845 __le16 max_rx_latency;
846 __le16 max_remote_timeout;
847 __le16 max_local_timeout;
848 } __packed;
849
850 #define HCI_EV_EXTENDED_INQUIRY_RESULT 0x2f
851 struct extended_inquiry_info {
852 bdaddr_t bdaddr;
853 __u8 pscan_rep_mode;
854 __u8 pscan_period_mode;
855 __u8 dev_class[3];
856 __le16 clock_offset;
857 __s8 rssi;
858 __u8 data[240];
859 } __packed;
860
861 #define HCI_EV_IO_CAPA_REQUEST 0x31
862 struct hci_ev_io_capa_request {
863 bdaddr_t bdaddr;
864 } __packed;
865
866 #define HCI_EV_IO_CAPA_REPLY 0x32
867 struct hci_ev_io_capa_reply {
868 bdaddr_t bdaddr;
869 __u8 capability;
870 __u8 oob_data;
871 __u8 authentication;
872 } __packed;
873
874 #define HCI_EV_SIMPLE_PAIR_COMPLETE 0x36
875 struct hci_ev_simple_pair_complete {
876 __u8 status;
877 bdaddr_t bdaddr;
878 } __packed;
879
880 #define HCI_EV_REMOTE_HOST_FEATURES 0x3d
881 struct hci_ev_remote_host_features {
882 bdaddr_t bdaddr;
883 __u8 features[8];
884 } __packed;
885
886 /* Internal events generated by Bluetooth stack */
887 #define HCI_EV_STACK_INTERNAL 0xfd
888 struct hci_ev_stack_internal {
889 __u16 type;
890 __u8 data[0];
891 } __packed;
892
893 #define HCI_EV_SI_DEVICE 0x01
894 struct hci_ev_si_device {
895 __u16 event;
896 __u16 dev_id;
897 } __packed;
898
899 #define HCI_EV_SI_SECURITY 0x02
900 struct hci_ev_si_security {
901 __u16 event;
902 __u16 proto;
903 __u16 subproto;
904 __u8 incoming;
905 } __packed;
906
907 /* ---- HCI Packet structures ---- */
908 #define HCI_COMMAND_HDR_SIZE 3
909 #define HCI_EVENT_HDR_SIZE 2
910 #define HCI_ACL_HDR_SIZE 4
911 #define HCI_SCO_HDR_SIZE 3
912
913 struct hci_command_hdr {
914 __le16 opcode; /* OCF & OGF */
915 __u8 plen;
916 } __packed;
917
918 struct hci_event_hdr {
919 __u8 evt;
920 __u8 plen;
921 } __packed;
922
923 struct hci_acl_hdr {
924 __le16 handle; /* Handle & Flags(PB, BC) */
925 __le16 dlen;
926 } __packed;
927
928 struct hci_sco_hdr {
929 __le16 handle;
930 __u8 dlen;
931 } __packed;
932
933 #ifdef __KERNEL__
934 #include <linux/skbuff.h>
935 static inline struct hci_event_hdr *hci_event_hdr(const struct sk_buff *skb)
936 {
937 return (struct hci_event_hdr *) skb->data;
938 }
939
940 static inline struct hci_acl_hdr *hci_acl_hdr(const struct sk_buff *skb)
941 {
942 return (struct hci_acl_hdr *) skb->data;
943 }
944
945 static inline struct hci_sco_hdr *hci_sco_hdr(const struct sk_buff *skb)
946 {
947 return (struct hci_sco_hdr *) skb->data;
948 }
949 #endif
950
951 /* Command opcode pack/unpack */
952 #define hci_opcode_pack(ogf, ocf) (__u16) ((ocf & 0x03ff)|(ogf << 10))
953 #define hci_opcode_ogf(op) (op >> 10)
954 #define hci_opcode_ocf(op) (op & 0x03ff)
955
956 /* ACL handle and flags pack/unpack */
957 #define hci_handle_pack(h, f) (__u16) ((h & 0x0fff)|(f << 12))
958 #define hci_handle(h) (h & 0x0fff)
959 #define hci_flags(h) (h >> 12)
960
961 /* ---- HCI Sockets ---- */
962
963 /* Socket options */
964 #define HCI_DATA_DIR 1
965 #define HCI_FILTER 2
966 #define HCI_TIME_STAMP 3
967
968 /* CMSG flags */
969 #define HCI_CMSG_DIR 0x0001
970 #define HCI_CMSG_TSTAMP 0x0002
971
972 struct sockaddr_hci {
973 sa_family_t hci_family;
974 unsigned short hci_dev;
975 unsigned short hci_channel;
976 };
977 #define HCI_DEV_NONE 0xffff
978
979 #define HCI_CHANNEL_RAW 0
980 #define HCI_CHANNEL_CONTROL 1
981
982 struct hci_filter {
983 unsigned long type_mask;
984 unsigned long event_mask[2];
985 __le16 opcode;
986 };
987
988 struct hci_ufilter {
989 __u32 type_mask;
990 __u32 event_mask[2];
991 __le16 opcode;
992 };
993
994 #define HCI_FLT_TYPE_BITS 31
995 #define HCI_FLT_EVENT_BITS 63
996 #define HCI_FLT_OGF_BITS 63
997 #define HCI_FLT_OCF_BITS 127
998
999 /* ---- HCI Ioctl requests structures ---- */
1000 struct hci_dev_stats {
1001 __u32 err_rx;
1002 __u32 err_tx;
1003 __u32 cmd_tx;
1004 __u32 evt_rx;
1005 __u32 acl_tx;
1006 __u32 acl_rx;
1007 __u32 sco_tx;
1008 __u32 sco_rx;
1009 __u32 byte_rx;
1010 __u32 byte_tx;
1011 };
1012
1013 struct hci_dev_info {
1014 __u16 dev_id;
1015 char name[8];
1016
1017 bdaddr_t bdaddr;
1018
1019 __u32 flags;
1020 __u8 type;
1021
1022 __u8 features[8];
1023
1024 __u32 pkt_type;
1025 __u32 link_policy;
1026 __u32 link_mode;
1027
1028 __u16 acl_mtu;
1029 __u16 acl_pkts;
1030 __u16 sco_mtu;
1031 __u16 sco_pkts;
1032
1033 struct hci_dev_stats stat;
1034 };
1035
1036 struct hci_conn_info {
1037 __u16 handle;
1038 bdaddr_t bdaddr;
1039 __u8 type;
1040 __u8 out;
1041 __u16 state;
1042 __u32 link_mode;
1043 };
1044
1045 struct hci_dev_req {
1046 __u16 dev_id;
1047 __u32 dev_opt;
1048 };
1049
1050 struct hci_dev_list_req {
1051 __u16 dev_num;
1052 struct hci_dev_req dev_req[0]; /* hci_dev_req structures */
1053 };
1054
1055 struct hci_conn_list_req {
1056 __u16 dev_id;
1057 __u16 conn_num;
1058 struct hci_conn_info conn_info[0];
1059 };
1060
1061 struct hci_conn_info_req {
1062 bdaddr_t bdaddr;
1063 __u8 type;
1064 struct hci_conn_info conn_info[0];
1065 };
1066
1067 struct hci_auth_info_req {
1068 bdaddr_t bdaddr;
1069 __u8 type;
1070 };
1071
1072 struct hci_inquiry_req {
1073 __u16 dev_id;
1074 __u16 flags;
1075 __u8 lap[3];
1076 __u8 length;
1077 __u8 num_rsp;
1078 };
1079 #define IREQ_CACHE_FLUSH 0x0001
1080
1081 #endif /* __HCI_H */
This page took 0.058354 seconds and 5 git commands to generate.