3
* BlueZ - Bluetooth protocol stack for Linux
5
* Copyright (C) 2000-2001 Qualcomm Incorporated
6
* Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com>
7
* Copyright (C) 2002-2008 Marcel Holtmann <marcel@holtmann.org>
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.
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.
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
33
#include <sys/socket.h>
35
#define HCI_MAX_DEV 16
37
#define HCI_MAX_ACL_SIZE 1024
38
#define HCI_MAX_SCO_SIZE 255
39
#define HCI_MAX_EVENT_SIZE 260
40
#define HCI_MAX_FRAME_SIZE (HCI_MAX_ACL_SIZE + 4)
44
#define HCI_DEV_UNREG 2
46
#define HCI_DEV_DOWN 4
47
#define HCI_DEV_SUSPEND 5
48
#define HCI_DEV_RESUME 6
50
/* HCI device types */
59
/* HCI device flags */
74
/* HCI ioctl defines */
75
#define HCIDEVUP _IOW('H', 201, int)
76
#define HCIDEVDOWN _IOW('H', 202, int)
77
#define HCIDEVRESET _IOW('H', 203, int)
78
#define HCIDEVRESTAT _IOW('H', 204, int)
80
#define HCIGETDEVLIST _IOR('H', 210, int)
81
#define HCIGETDEVINFO _IOR('H', 211, int)
82
#define HCIGETCONNLIST _IOR('H', 212, int)
83
#define HCIGETCONNINFO _IOR('H', 213, int)
84
#define HCIGETAUTHINFO _IOR('H', 215, int)
86
#define HCISETRAW _IOW('H', 220, int)
87
#define HCISETSCAN _IOW('H', 221, int)
88
#define HCISETAUTH _IOW('H', 222, int)
89
#define HCISETENCRYPT _IOW('H', 223, int)
90
#define HCISETPTYPE _IOW('H', 224, int)
91
#define HCISETLINKPOL _IOW('H', 225, int)
92
#define HCISETLINKMODE _IOW('H', 226, int)
93
#define HCISETACLMTU _IOW('H', 227, int)
94
#define HCISETSCOMTU _IOW('H', 228, int)
96
#define HCIINQUIRY _IOR('H', 240, int)
100
/* HCI Packet types */
101
#define HCI_COMMAND_PKT 0x01
102
#define HCI_ACLDATA_PKT 0x02
103
#define HCI_SCODATA_PKT 0x03
104
#define HCI_EVENT_PKT 0x04
105
#define HCI_VENDOR_PKT 0xff
107
/* HCI Packet types */
108
#define HCI_2DH1 0x0002
109
#define HCI_3DH1 0x0004
110
#define HCI_DM1 0x0008
111
#define HCI_DH1 0x0010
112
#define HCI_2DH3 0x0100
113
#define HCI_3DH3 0x0200
114
#define HCI_DM3 0x0400
115
#define HCI_DH3 0x0800
116
#define HCI_2DH5 0x1000
117
#define HCI_3DH5 0x2000
118
#define HCI_DM5 0x4000
119
#define HCI_DH5 0x8000
121
#define HCI_HV1 0x0020
122
#define HCI_HV2 0x0040
123
#define HCI_HV3 0x0080
125
#define HCI_EV3 0x0008
126
#define HCI_EV4 0x0010
127
#define HCI_EV5 0x0020
128
#define HCI_2EV3 0x0040
129
#define HCI_3EV3 0x0080
130
#define HCI_2EV5 0x0100
131
#define HCI_3EV5 0x0200
133
#define SCO_PTYPE_MASK (HCI_HV1 | HCI_HV2 | HCI_HV3)
134
#define ACL_PTYPE_MASK (HCI_DM1 | HCI_DH1 | HCI_DM3 | HCI_DH3 | HCI_DM5 | HCI_DH5)
136
/* HCI Error codes */
137
#define HCI_UNKNOWN_COMMAND 0x01
138
#define HCI_NO_CONNECTION 0x02
139
#define HCI_HARDWARE_FAILURE 0x03
140
#define HCI_PAGE_TIMEOUT 0x04
141
#define HCI_AUTHENTICATION_FAILURE 0x05
142
#define HCI_PIN_OR_KEY_MISSING 0x06
143
#define HCI_MEMORY_FULL 0x07
144
#define HCI_CONNECTION_TIMEOUT 0x08
145
#define HCI_MAX_NUMBER_OF_CONNECTIONS 0x09
146
#define HCI_MAX_NUMBER_OF_SCO_CONNECTIONS 0x0a
147
#define HCI_ACL_CONNECTION_EXISTS 0x0b
148
#define HCI_COMMAND_DISALLOWED 0x0c
149
#define HCI_REJECTED_LIMITED_RESOURCES 0x0d
150
#define HCI_REJECTED_SECURITY 0x0e
151
#define HCI_REJECTED_PERSONAL 0x0f
152
#define HCI_HOST_TIMEOUT 0x10
153
#define HCI_UNSUPPORTED_FEATURE 0x11
154
#define HCI_INVALID_PARAMETERS 0x12
155
#define HCI_OE_USER_ENDED_CONNECTION 0x13
156
#define HCI_OE_LOW_RESOURCES 0x14
157
#define HCI_OE_POWER_OFF 0x15
158
#define HCI_CONNECTION_TERMINATED 0x16
159
#define HCI_REPEATED_ATTEMPTS 0x17
160
#define HCI_PAIRING_NOT_ALLOWED 0x18
161
#define HCI_UNKNOWN_LMP_PDU 0x19
162
#define HCI_UNSUPPORTED_REMOTE_FEATURE 0x1a
163
#define HCI_SCO_OFFSET_REJECTED 0x1b
164
#define HCI_SCO_INTERVAL_REJECTED 0x1c
165
#define HCI_AIR_MODE_REJECTED 0x1d
166
#define HCI_INVALID_LMP_PARAMETERS 0x1e
167
#define HCI_UNSPECIFIED_ERROR 0x1f
168
#define HCI_UNSUPPORTED_LMP_PARAMETER_VALUE 0x20
169
#define HCI_ROLE_CHANGE_NOT_ALLOWED 0x21
170
#define HCI_LMP_RESPONSE_TIMEOUT 0x22
171
#define HCI_LMP_ERROR_TRANSACTION_COLLISION 0x23
172
#define HCI_LMP_PDU_NOT_ALLOWED 0x24
173
#define HCI_ENCRYPTION_MODE_NOT_ACCEPTED 0x25
174
#define HCI_UNIT_LINK_KEY_USED 0x26
175
#define HCI_QOS_NOT_SUPPORTED 0x27
176
#define HCI_INSTANT_PASSED 0x28
177
#define HCI_PAIRING_NOT_SUPPORTED 0x29
178
#define HCI_TRANSACTION_COLLISION 0x2a
179
#define HCI_QOS_UNACCEPTABLE_PARAMETER 0x2c
180
#define HCI_QOS_REJECTED 0x2d
181
#define HCI_CLASSIFICATION_NOT_SUPPORTED 0x2e
182
#define HCI_INSUFFICIENT_SECURITY 0x2f
183
#define HCI_PARAMETER_OUT_OF_RANGE 0x30
184
#define HCI_ROLE_SWITCH_PENDING 0x32
185
#define HCI_SLOT_VIOLATION 0x34
186
#define HCI_ROLE_SWITCH_FAILED 0x35
187
#define HCI_EIR_TOO_LARGE 0x36
188
#define HCI_SIMPLE_PAIRING_NOT_SUPPORTED 0x37
189
#define HCI_HOST_BUSY_PAIRING 0x38
192
#define ACL_CONT 0x01
193
#define ACL_START 0x02
194
#define ACL_ACTIVE_BCAST 0x04
195
#define ACL_PICO_BCAST 0x08
198
#define SCO_LINK 0x00
199
#define ACL_LINK 0x01
200
#define ESCO_LINK 0x02
203
#define LMP_3SLOT 0x01
204
#define LMP_5SLOT 0x02
205
#define LMP_ENCRYPT 0x04
206
#define LMP_SOFFSET 0x08
207
#define LMP_TACCURACY 0x10
208
#define LMP_RSWITCH 0x20
209
#define LMP_HOLD 0x40
210
#define LMP_SNIFF 0x80
212
#define LMP_PARK 0x01
213
#define LMP_RSSI 0x02
214
#define LMP_QUALITY 0x04
218
#define LMP_ULAW 0x40
219
#define LMP_ALAW 0x80
221
#define LMP_CVSD 0x01
222
#define LMP_PSCHEME 0x02
223
#define LMP_PCONTROL 0x04
224
#define LMP_TRSP_SCO 0x08
225
#define LMP_BCAST_ENC 0x80
227
#define LMP_EDR_ACL_2M 0x02
228
#define LMP_EDR_ACL_3M 0x04
229
#define LMP_ENH_ISCAN 0x08
230
#define LMP_ILACE_ISCAN 0x10
231
#define LMP_ILACE_PSCAN 0x20
232
#define LMP_RSSI_INQ 0x40
233
#define LMP_ESCO 0x80
237
#define LMP_AFH_CAP_SLV 0x08
238
#define LMP_AFH_CLS_SLV 0x10
239
#define LMP_EDR_3SLOT 0x80
241
#define LMP_EDR_5SLOT 0x01
242
#define LMP_SNIFF_SUBR 0x02
243
#define LMP_PAUSE_ENC 0x04
244
#define LMP_AFH_CAP_MST 0x08
245
#define LMP_AFH_CLS_MST 0x10
246
#define LMP_EDR_ESCO_2M 0x20
247
#define LMP_EDR_ESCO_3M 0x40
248
#define LMP_EDR_3S_ESCO 0x80
250
#define LMP_EXT_INQ 0x01
251
#define LMP_SIMPLE_PAIR 0x08
252
#define LMP_ENCAPS_PDU 0x10
253
#define LMP_ERR_DAT_REP 0x20
254
#define LMP_NFLUSH_PKTS 0x40
256
#define LMP_LSTO 0x01
257
#define LMP_INQ_TX_PWR 0x02
258
#define LMP_EXT_FEAT 0x80
261
#define HCI_LP_RSWITCH 0x0001
262
#define HCI_LP_HOLD 0x0002
263
#define HCI_LP_SNIFF 0x0004
264
#define HCI_LP_PARK 0x0008
267
#define HCI_LM_ACCEPT 0x8000
268
#define HCI_LM_MASTER 0x0001
269
#define HCI_LM_AUTH 0x0002
270
#define HCI_LM_ENCRYPT 0x0004
271
#define HCI_LM_TRUSTED 0x0008
272
#define HCI_LM_RELIABLE 0x0010
273
#define HCI_LM_SECURE 0x0020
275
/* ----- HCI Commands ----- */
278
#define OGF_LINK_CTL 0x01
280
#define OCF_INQUIRY 0x0001
283
uint8_t length; /* 1.28s units */
285
} __attribute__ ((packed)) inquiry_cp;
286
#define INQUIRY_CP_SIZE 5
291
} __attribute__ ((packed)) status_bdaddr_rp;
292
#define STATUS_BDADDR_RP_SIZE 7
294
#define OCF_INQUIRY_CANCEL 0x0002
296
#define OCF_PERIODIC_INQUIRY 0x0003
298
uint16_t max_period; /* 1.28s units */
299
uint16_t min_period; /* 1.28s units */
301
uint8_t length; /* 1.28s units */
303
} __attribute__ ((packed)) periodic_inquiry_cp;
304
#define PERIODIC_INQUIRY_CP_SIZE 9
306
#define OCF_EXIT_PERIODIC_INQUIRY 0x0004
308
#define OCF_CREATE_CONN 0x0005
312
uint8_t pscan_rep_mode;
314
uint16_t clock_offset;
316
} __attribute__ ((packed)) create_conn_cp;
317
#define CREATE_CONN_CP_SIZE 13
319
#define OCF_DISCONNECT 0x0006
323
} __attribute__ ((packed)) disconnect_cp;
324
#define DISCONNECT_CP_SIZE 3
326
#define OCF_ADD_SCO 0x0007
330
} __attribute__ ((packed)) add_sco_cp;
331
#define ADD_SCO_CP_SIZE 4
333
#define OCF_CREATE_CONN_CANCEL 0x0008
336
} __attribute__ ((packed)) create_conn_cancel_cp;
337
#define CREATE_CONN_CANCEL_CP_SIZE 6
339
#define OCF_ACCEPT_CONN_REQ 0x0009
343
} __attribute__ ((packed)) accept_conn_req_cp;
344
#define ACCEPT_CONN_REQ_CP_SIZE 7
346
#define OCF_REJECT_CONN_REQ 0x000A
350
} __attribute__ ((packed)) reject_conn_req_cp;
351
#define REJECT_CONN_REQ_CP_SIZE 7
353
#define OCF_LINK_KEY_REPLY 0x000B
356
uint8_t link_key[16];
357
} __attribute__ ((packed)) link_key_reply_cp;
358
#define LINK_KEY_REPLY_CP_SIZE 22
360
#define OCF_LINK_KEY_NEG_REPLY 0x000C
362
#define OCF_PIN_CODE_REPLY 0x000D
366
uint8_t pin_code[16];
367
} __attribute__ ((packed)) pin_code_reply_cp;
368
#define PIN_CODE_REPLY_CP_SIZE 23
370
#define OCF_PIN_CODE_NEG_REPLY 0x000E
372
#define OCF_SET_CONN_PTYPE 0x000F
376
} __attribute__ ((packed)) set_conn_ptype_cp;
377
#define SET_CONN_PTYPE_CP_SIZE 4
379
#define OCF_AUTH_REQUESTED 0x0011
382
} __attribute__ ((packed)) auth_requested_cp;
383
#define AUTH_REQUESTED_CP_SIZE 2
385
#define OCF_SET_CONN_ENCRYPT 0x0013
389
} __attribute__ ((packed)) set_conn_encrypt_cp;
390
#define SET_CONN_ENCRYPT_CP_SIZE 3
392
#define OCF_CHANGE_CONN_LINK_KEY 0x0015
395
} __attribute__ ((packed)) change_conn_link_key_cp;
396
#define CHANGE_CONN_LINK_KEY_CP_SIZE 2
398
#define OCF_MASTER_LINK_KEY 0x0017
401
} __attribute__ ((packed)) master_link_key_cp;
402
#define MASTER_LINK_KEY_CP_SIZE 1
404
#define OCF_REMOTE_NAME_REQ 0x0019
407
uint8_t pscan_rep_mode;
409
uint16_t clock_offset;
410
} __attribute__ ((packed)) remote_name_req_cp;
411
#define REMOTE_NAME_REQ_CP_SIZE 10
413
#define OCF_REMOTE_NAME_REQ_CANCEL 0x001A
416
} __attribute__ ((packed)) remote_name_req_cancel_cp;
417
#define REMOTE_NAME_REQ_CANCEL_CP_SIZE 6
419
#define OCF_READ_REMOTE_FEATURES 0x001B
422
} __attribute__ ((packed)) read_remote_features_cp;
423
#define READ_REMOTE_FEATURES_CP_SIZE 2
425
#define OCF_READ_REMOTE_EXT_FEATURES 0x001C
429
} __attribute__ ((packed)) read_remote_ext_features_cp;
430
#define READ_REMOTE_EXT_FEATURES_CP_SIZE 3
432
#define OCF_READ_REMOTE_VERSION 0x001D
435
} __attribute__ ((packed)) read_remote_version_cp;
436
#define READ_REMOTE_VERSION_CP_SIZE 2
438
#define OCF_READ_CLOCK_OFFSET 0x001F
441
} __attribute__ ((packed)) read_clock_offset_cp;
442
#define READ_CLOCK_OFFSET_CP_SIZE 2
444
#define OCF_READ_LMP_HANDLE 0x0020
446
#define OCF_SETUP_SYNC_CONN 0x0028
449
uint32_t tx_bandwith;
450
uint32_t rx_bandwith;
451
uint16_t max_latency;
452
uint16_t voice_setting;
453
uint8_t retrans_effort;
455
} __attribute__ ((packed)) setup_sync_conn_cp;
456
#define SETUP_SYNC_CONN_CP_SIZE 17
458
#define OCF_ACCEPT_SYNC_CONN_REQ 0x0029
461
uint32_t tx_bandwith;
462
uint32_t rx_bandwith;
463
uint16_t max_latency;
464
uint16_t voice_setting;
465
uint8_t retrans_effort;
467
} __attribute__ ((packed)) accept_sync_conn_req_cp;
468
#define ACCEPT_SYNC_CONN_REQ_CP_SIZE 21
470
#define OCF_REJECT_SYNC_CONN_REQ 0x002A
474
} __attribute__ ((packed)) reject_sync_conn_req_cp;
475
#define REJECT_SYNC_CONN_REQ_CP_SIZE 7
477
#define OCF_IO_CAPABILITY_REPLY 0x002B
482
uint8_t authentication;
483
} __attribute__ ((packed)) io_capability_reply_cp;
484
#define IO_CAPABILITY_REPLY_CP_SIZE 9
486
#define OCF_USER_CONFIRM_REPLY 0x002C
489
} __attribute__ ((packed)) user_confirm_reply_cp;
490
#define USER_CONFIRM_REPLY_CP_SIZE 6
492
#define OCF_USER_CONFIRM_NEG_REPLY 0x002D
494
#define OCF_USER_PASSKEY_REPLY 0x002E
498
} __attribute__ ((packed)) user_passkey_reply_cp;
499
#define USER_PASSKEY_REPLY_CP_SIZE 10
501
#define OCF_USER_PASSKEY_NEG_REPLY 0x002F
503
#define OCF_REMOTE_OOB_DATA_REPLY 0x0030
507
uint8_t randomizer[16];
508
} __attribute__ ((packed)) remote_oob_data_reply_cp;
509
#define REMOTE_OOB_DATA_REPLY_CP_SIZE 38
511
#define OCF_REMOTE_OOB_DATA_NEG_REPLY 0x0033
513
#define OCF_IO_CAPABILITY_NEG_REPLY 0x0034
517
} __attribute__ ((packed)) io_capability_neg_reply_cp;
518
#define IO_CAPABILITY_NEG_REPLY_CP_SIZE 7
521
#define OGF_LINK_POLICY 0x02
523
#define OCF_HOLD_MODE 0x0001
526
uint16_t max_interval;
527
uint16_t min_interval;
528
} __attribute__ ((packed)) hold_mode_cp;
529
#define HOLD_MODE_CP_SIZE 6
531
#define OCF_SNIFF_MODE 0x0003
534
uint16_t max_interval;
535
uint16_t min_interval;
538
} __attribute__ ((packed)) sniff_mode_cp;
539
#define SNIFF_MODE_CP_SIZE 10
541
#define OCF_EXIT_SNIFF_MODE 0x0004
544
} __attribute__ ((packed)) exit_sniff_mode_cp;
545
#define EXIT_SNIFF_MODE_CP_SIZE 2
547
#define OCF_PARK_MODE 0x0005
550
uint16_t max_interval;
551
uint16_t min_interval;
552
} __attribute__ ((packed)) park_mode_cp;
553
#define PARK_MODE_CP_SIZE 6
555
#define OCF_EXIT_PARK_MODE 0x0006
558
} __attribute__ ((packed)) exit_park_mode_cp;
559
#define EXIT_PARK_MODE_CP_SIZE 2
561
#define OCF_QOS_SETUP 0x0007
563
uint8_t service_type; /* 1 = best effort */
564
uint32_t token_rate; /* Byte per seconds */
565
uint32_t peak_bandwidth; /* Byte per seconds */
566
uint32_t latency; /* Microseconds */
567
uint32_t delay_variation; /* Microseconds */
568
} __attribute__ ((packed)) hci_qos;
569
#define HCI_QOS_CP_SIZE 17
572
uint8_t flags; /* Reserved */
574
} __attribute__ ((packed)) qos_setup_cp;
575
#define QOS_SETUP_CP_SIZE (3 + HCI_QOS_CP_SIZE)
577
#define OCF_ROLE_DISCOVERY 0x0009
580
} __attribute__ ((packed)) role_discovery_cp;
581
#define ROLE_DISCOVERY_CP_SIZE 2
586
} __attribute__ ((packed)) role_discovery_rp;
587
#define ROLE_DISCOVERY_RP_SIZE 4
589
#define OCF_SWITCH_ROLE 0x000B
593
} __attribute__ ((packed)) switch_role_cp;
594
#define SWITCH_ROLE_CP_SIZE 7
596
#define OCF_READ_LINK_POLICY 0x000C
599
} __attribute__ ((packed)) read_link_policy_cp;
600
#define READ_LINK_POLICY_CP_SIZE 2
605
} __attribute__ ((packed)) read_link_policy_rp;
606
#define READ_LINK_POLICY_RP_SIZE 5
608
#define OCF_WRITE_LINK_POLICY 0x000D
612
} __attribute__ ((packed)) write_link_policy_cp;
613
#define WRITE_LINK_POLICY_CP_SIZE 4
617
} __attribute__ ((packed)) write_link_policy_rp;
618
#define WRITE_LINK_POLICY_RP_SIZE 3
620
#define OCF_READ_DEFAULT_LINK_POLICY 0x000E
622
#define OCF_WRITE_DEFAULT_LINK_POLICY 0x000F
624
#define OCF_FLOW_SPECIFICATION 0x0010
626
#define OCF_SNIFF_SUBRATING 0x0011
629
uint16_t max_latency;
630
uint16_t min_remote_timeout;
631
uint16_t min_local_timeout;
632
} __attribute__ ((packed)) sniff_subrating_cp;
633
#define SNIFF_SUBRATING_CP_SIZE 8
635
/* Host Controller and Baseband */
636
#define OGF_HOST_CTL 0x03
638
#define OCF_SET_EVENT_MASK 0x0001
641
} __attribute__ ((packed)) set_event_mask_cp;
642
#define SET_EVENT_MASK_CP_SIZE 8
644
#define OCF_RESET 0x0003
646
#define OCF_SET_EVENT_FLT 0x0005
650
uint8_t condition[0];
651
} __attribute__ ((packed)) set_event_flt_cp;
652
#define SET_EVENT_FLT_CP_SIZE 2
655
#define FLT_CLEAR_ALL 0x00
656
#define FLT_INQ_RESULT 0x01
657
#define FLT_CONN_SETUP 0x02
658
/* INQ_RESULT Condition types */
659
#define INQ_RESULT_RETURN_ALL 0x00
660
#define INQ_RESULT_RETURN_CLASS 0x01
661
#define INQ_RESULT_RETURN_BDADDR 0x02
662
/* CONN_SETUP Condition types */
663
#define CONN_SETUP_ALLOW_ALL 0x00
664
#define CONN_SETUP_ALLOW_CLASS 0x01
665
#define CONN_SETUP_ALLOW_BDADDR 0x02
666
/* CONN_SETUP Conditions */
667
#define CONN_SETUP_AUTO_OFF 0x01
668
#define CONN_SETUP_AUTO_ON 0x02
670
#define OCF_FLUSH 0x0008
672
#define OCF_READ_PIN_TYPE 0x0009
676
} __attribute__ ((packed)) read_pin_type_rp;
677
#define READ_PIN_TYPE_RP_SIZE 2
679
#define OCF_WRITE_PIN_TYPE 0x000A
682
} __attribute__ ((packed)) write_pin_type_cp;
683
#define WRITE_PIN_TYPE_CP_SIZE 1
685
#define OCF_CREATE_NEW_UNIT_KEY 0x000B
687
#define OCF_READ_STORED_LINK_KEY 0x000D
691
} __attribute__ ((packed)) read_stored_link_key_cp;
692
#define READ_STORED_LINK_KEY_CP_SIZE 7
697
} __attribute__ ((packed)) read_stored_link_key_rp;
698
#define READ_STORED_LINK_KEY_RP_SIZE 5
700
#define OCF_WRITE_STORED_LINK_KEY 0x0011
703
/* variable length part */
704
} __attribute__ ((packed)) write_stored_link_key_cp;
705
#define WRITE_STORED_LINK_KEY_CP_SIZE 1
709
} __attribute__ ((packed)) write_stored_link_key_rp;
710
#define READ_WRITE_LINK_KEY_RP_SIZE 2
712
#define OCF_DELETE_STORED_LINK_KEY 0x0012
716
} __attribute__ ((packed)) delete_stored_link_key_cp;
717
#define DELETE_STORED_LINK_KEY_CP_SIZE 7
721
} __attribute__ ((packed)) delete_stored_link_key_rp;
722
#define DELETE_STORED_LINK_KEY_RP_SIZE 3
724
#define OCF_CHANGE_LOCAL_NAME 0x0013
727
} __attribute__ ((packed)) change_local_name_cp;
728
#define CHANGE_LOCAL_NAME_CP_SIZE 248
730
#define OCF_READ_LOCAL_NAME 0x0014
734
} __attribute__ ((packed)) read_local_name_rp;
735
#define READ_LOCAL_NAME_RP_SIZE 249
737
#define OCF_READ_CONN_ACCEPT_TIMEOUT 0x0015
741
} __attribute__ ((packed)) read_conn_accept_timeout_rp;
742
#define READ_CONN_ACCEPT_TIMEOUT_RP_SIZE 3
744
#define OCF_WRITE_CONN_ACCEPT_TIMEOUT 0x0016
747
} __attribute__ ((packed)) write_conn_accept_timeout_cp;
748
#define WRITE_CONN_ACCEPT_TIMEOUT_CP_SIZE 2
750
#define OCF_READ_PAGE_TIMEOUT 0x0017
754
} __attribute__ ((packed)) read_page_timeout_rp;
755
#define READ_PAGE_TIMEOUT_RP_SIZE 3
757
#define OCF_WRITE_PAGE_TIMEOUT 0x0018
760
} __attribute__ ((packed)) write_page_timeout_cp;
761
#define WRITE_PAGE_TIMEOUT_CP_SIZE 2
763
#define OCF_READ_SCAN_ENABLE 0x0019
767
} __attribute__ ((packed)) read_scan_enable_rp;
768
#define READ_SCAN_ENABLE_RP_SIZE 2
770
#define OCF_WRITE_SCAN_ENABLE 0x001A
771
#define SCAN_DISABLED 0x00
772
#define SCAN_INQUIRY 0x01
773
#define SCAN_PAGE 0x02
775
#define OCF_READ_PAGE_ACTIVITY 0x001B
780
} __attribute__ ((packed)) read_page_activity_rp;
781
#define READ_PAGE_ACTIVITY_RP_SIZE 5
783
#define OCF_WRITE_PAGE_ACTIVITY 0x001C
787
} __attribute__ ((packed)) write_page_activity_cp;
788
#define WRITE_PAGE_ACTIVITY_CP_SIZE 4
790
#define OCF_READ_INQ_ACTIVITY 0x001D
795
} __attribute__ ((packed)) read_inq_activity_rp;
796
#define READ_INQ_ACTIVITY_RP_SIZE 5
798
#define OCF_WRITE_INQ_ACTIVITY 0x001E
802
} __attribute__ ((packed)) write_inq_activity_cp;
803
#define WRITE_INQ_ACTIVITY_CP_SIZE 4
805
#define OCF_READ_AUTH_ENABLE 0x001F
807
#define OCF_WRITE_AUTH_ENABLE 0x0020
808
#define AUTH_DISABLED 0x00
809
#define AUTH_ENABLED 0x01
811
#define OCF_READ_ENCRYPT_MODE 0x0021
813
#define OCF_WRITE_ENCRYPT_MODE 0x0022
814
#define ENCRYPT_DISABLED 0x00
815
#define ENCRYPT_P2P 0x01
816
#define ENCRYPT_BOTH 0x02
818
#define OCF_READ_CLASS_OF_DEV 0x0023
821
uint8_t dev_class[3];
822
} __attribute__ ((packed)) read_class_of_dev_rp;
823
#define READ_CLASS_OF_DEV_RP_SIZE 4
825
#define OCF_WRITE_CLASS_OF_DEV 0x0024
827
uint8_t dev_class[3];
828
} __attribute__ ((packed)) write_class_of_dev_cp;
829
#define WRITE_CLASS_OF_DEV_CP_SIZE 3
831
#define OCF_READ_VOICE_SETTING 0x0025
834
uint16_t voice_setting;
835
} __attribute__ ((packed)) read_voice_setting_rp;
836
#define READ_VOICE_SETTING_RP_SIZE 3
838
#define OCF_WRITE_VOICE_SETTING 0x0026
840
uint16_t voice_setting;
841
} __attribute__ ((packed)) write_voice_setting_cp;
842
#define WRITE_VOICE_SETTING_CP_SIZE 2
844
#define OCF_READ_AUTOMATIC_FLUSH_TIMEOUT 0x0027
846
#define OCF_WRITE_AUTOMATIC_FLUSH_TIMEOUT 0x0028
848
#define OCF_READ_NUM_BROADCAST_RETRANS 0x0029
850
#define OCF_WRITE_NUM_BROADCAST_RETRANS 0x002A
852
#define OCF_READ_HOLD_MODE_ACTIVITY 0x002B
854
#define OCF_WRITE_HOLD_MODE_ACTIVITY 0x002C
856
#define OCF_READ_TRANSMIT_POWER_LEVEL 0x002D
860
} __attribute__ ((packed)) read_transmit_power_level_cp;
861
#define READ_TRANSMIT_POWER_LEVEL_CP_SIZE 3
866
} __attribute__ ((packed)) read_transmit_power_level_rp;
867
#define READ_TRANSMIT_POWER_LEVEL_RP_SIZE 4
869
#define OCF_READ_SYNC_FLOW_ENABLE 0x002E
871
#define OCF_WRITE_SYNC_FLOW_ENABLE 0x002F
873
#define OCF_SET_CONTROLLER_TO_HOST_FC 0x0031
875
#define OCF_HOST_BUFFER_SIZE 0x0033
879
uint16_t acl_max_pkt;
880
uint16_t sco_max_pkt;
881
} __attribute__ ((packed)) host_buffer_size_cp;
882
#define HOST_BUFFER_SIZE_CP_SIZE 7
884
#define OCF_HOST_NUM_COMP_PKTS 0x0035
887
/* variable length part */
888
} __attribute__ ((packed)) host_num_comp_pkts_cp;
889
#define HOST_NUM_COMP_PKTS_CP_SIZE 1
891
#define OCF_READ_LINK_SUPERVISION_TIMEOUT 0x0036
896
} __attribute__ ((packed)) read_link_supervision_timeout_rp;
897
#define READ_LINK_SUPERVISION_TIMEOUT_RP_SIZE 5
899
#define OCF_WRITE_LINK_SUPERVISION_TIMEOUT 0x0037
903
} __attribute__ ((packed)) write_link_supervision_timeout_cp;
904
#define WRITE_LINK_SUPERVISION_TIMEOUT_CP_SIZE 4
908
} __attribute__ ((packed)) write_link_supervision_timeout_rp;
909
#define WRITE_LINK_SUPERVISION_TIMEOUT_RP_SIZE 3
911
#define OCF_READ_NUM_SUPPORTED_IAC 0x0038
913
#define MAX_IAC_LAP 0x40
914
#define OCF_READ_CURRENT_IAC_LAP 0x0039
917
uint8_t num_current_iac;
918
uint8_t lap[MAX_IAC_LAP][3];
919
} __attribute__ ((packed)) read_current_iac_lap_rp;
920
#define READ_CURRENT_IAC_LAP_RP_SIZE 2+3*MAX_IAC_LAP
922
#define OCF_WRITE_CURRENT_IAC_LAP 0x003A
924
uint8_t num_current_iac;
925
uint8_t lap[MAX_IAC_LAP][3];
926
} __attribute__ ((packed)) write_current_iac_lap_cp;
927
#define WRITE_CURRENT_IAC_LAP_CP_SIZE 1+3*MAX_IAC_LAP
929
#define OCF_READ_PAGE_SCAN_PERIOD_MODE 0x003B
931
#define OCF_WRITE_PAGE_SCAN_PERIOD_MODE 0x003C
933
#define OCF_READ_PAGE_SCAN_MODE 0x003D
935
#define OCF_WRITE_PAGE_SCAN_MODE 0x003E
937
#define OCF_SET_AFH_CLASSIFICATION 0x003F
940
} __attribute__ ((packed)) set_afh_classification_cp;
941
#define SET_AFH_CLASSIFICATION_CP_SIZE 10
944
} __attribute__ ((packed)) set_afh_classification_rp;
945
#define SET_AFH_CLASSIFICATION_RP_SIZE 1
947
#define OCF_READ_INQUIRY_SCAN_TYPE 0x0042
951
} __attribute__ ((packed)) read_inquiry_scan_type_rp;
952
#define READ_INQUIRY_SCAN_TYPE_RP_SIZE 2
954
#define OCF_WRITE_INQUIRY_SCAN_TYPE 0x0043
957
} __attribute__ ((packed)) write_inquiry_scan_type_cp;
958
#define WRITE_INQUIRY_SCAN_TYPE_CP_SIZE 1
961
} __attribute__ ((packed)) write_inquiry_scan_type_rp;
962
#define WRITE_INQUIRY_SCAN_TYPE_RP_SIZE 1
964
#define OCF_READ_INQUIRY_MODE 0x0044
968
} __attribute__ ((packed)) read_inquiry_mode_rp;
969
#define READ_INQUIRY_MODE_RP_SIZE 2
971
#define OCF_WRITE_INQUIRY_MODE 0x0045
974
} __attribute__ ((packed)) write_inquiry_mode_cp;
975
#define WRITE_INQUIRY_MODE_CP_SIZE 1
978
} __attribute__ ((packed)) write_inquiry_mode_rp;
979
#define WRITE_INQUIRY_MODE_RP_SIZE 1
981
#define OCF_READ_PAGE_SCAN_TYPE 0x0046
983
#define OCF_WRITE_PAGE_SCAN_TYPE 0x0047
985
#define OCF_READ_AFH_MODE 0x0048
989
} __attribute__ ((packed)) read_afh_mode_rp;
990
#define READ_AFH_MODE_RP_SIZE 2
992
#define OCF_WRITE_AFH_MODE 0x0049
995
} __attribute__ ((packed)) write_afh_mode_cp;
996
#define WRITE_AFH_MODE_CP_SIZE 1
999
} __attribute__ ((packed)) write_afh_mode_rp;
1000
#define WRITE_AFH_MODE_RP_SIZE 1
1002
#define OCF_READ_EXT_INQUIRY_RESPONSE 0x0051
1007
} __attribute__ ((packed)) read_ext_inquiry_response_rp;
1008
#define READ_EXT_INQUIRY_RESPONSE_RP_SIZE 242
1010
#define OCF_WRITE_EXT_INQUIRY_RESPONSE 0x0052
1014
} __attribute__ ((packed)) write_ext_inquiry_response_cp;
1015
#define WRITE_EXT_INQUIRY_RESPONSE_CP_SIZE 241
1018
} __attribute__ ((packed)) write_ext_inquiry_response_rp;
1019
#define WRITE_EXT_INQUIRY_RESPONSE_RP_SIZE 1
1021
#define OCF_REFRESH_ENCRYPTION_KEY 0x0053
1024
} __attribute__ ((packed)) refresh_encryption_key_cp;
1025
#define REFRESH_ENCRYPTION_KEY_CP_SIZE 2
1028
} __attribute__ ((packed)) refresh_encryption_key_rp;
1029
#define REFRESH_ENCRYPTION_KEY_RP_SIZE 1
1031
#define OCF_READ_SIMPLE_PAIRING_MODE 0x0055
1035
} __attribute__ ((packed)) read_simple_pairing_mode_rp;
1036
#define READ_SIMPLE_PAIRING_MODE_RP_SIZE 2
1038
#define OCF_WRITE_SIMPLE_PAIRING_MODE 0x0056
1041
} __attribute__ ((packed)) write_simple_pairing_mode_cp;
1042
#define WRITE_SIMPLE_PAIRING_MODE_CP_SIZE 1
1045
} __attribute__ ((packed)) write_simple_pairing_mode_rp;
1046
#define WRITE_SIMPLE_PAIRING_MODE_RP_SIZE 1
1048
#define OCF_READ_LOCAL_OOB_DATA 0x0057
1052
uint8_t randomizer[16];
1053
} __attribute__ ((packed)) read_local_oob_data_rp;
1054
#define READ_LOCAL_OOB_DATA_RP_SIZE 33
1056
#define OCF_READ_INQUIRY_TRANSMIT_POWER_LEVEL 0x0058
1060
} __attribute__ ((packed)) read_inquiry_transmit_power_level_rp;
1061
#define READ_INQUIRY_TRANSMIT_POWER_LEVEL_RP_SIZE 2
1063
#define OCF_WRITE_INQUIRY_TRANSMIT_POWER_LEVEL 0x0059
1066
} __attribute__ ((packed)) write_inquiry_transmit_power_level_cp;
1067
#define WRITE_INQUIRY_TRANSMIT_POWER_LEVEL_CP_SIZE 1
1070
} __attribute__ ((packed)) write_inquiry_transmit_power_level_rp;
1071
#define WRITE_INQUIRY_TRANSMIT_POWER_LEVEL_RP_SIZE 1
1073
#define OCF_READ_DEFAULT_ERROR_DATA_REPORTING 0x005A
1077
} __attribute__ ((packed)) read_default_error_data_reporting_rp;
1078
#define READ_DEFAULT_ERROR_DATA_REPORTING_RP_SIZE 2
1080
#define OCF_WRITE_DEFAULT_ERROR_DATA_REPORTING 0x005B
1083
} __attribute__ ((packed)) write_default_error_data_reporting_cp;
1084
#define WRITE_DEFAULT_ERROR_DATA_REPORTING_CP_SIZE 1
1087
} __attribute__ ((packed)) write_default_error_data_reporting_rp;
1088
#define WRITE_DEFAULT_ERROR_DATA_REPORTING_RP_SIZE 1
1090
#define OCF_ENHANCED_FLUSH 0x005F
1094
} __attribute__ ((packed)) enhanced_flush_cp;
1095
#define ENHANCED_FLUSH_CP_SIZE 3
1097
#define OCF_SEND_KEYPRESS_NOTIFY 0x0060
1101
} __attribute__ ((packed)) send_keypress_notify_cp;
1102
#define SEND_KEYPRESS_NOTIFY_CP_SIZE 7
1105
} __attribute__ ((packed)) send_keypress_notify_rp;
1106
#define SEND_KEYPRESS_NOTIFY_RP_SIZE 1
1108
/* Informational Parameters */
1109
#define OGF_INFO_PARAM 0x04
1111
#define OCF_READ_LOCAL_VERSION 0x0001
1117
uint16_t manufacturer;
1118
uint16_t lmp_subver;
1119
} __attribute__ ((packed)) read_local_version_rp;
1120
#define READ_LOCAL_VERSION_RP_SIZE 9
1122
#define OCF_READ_LOCAL_COMMANDS 0x0002
1125
uint8_t commands[64];
1126
} __attribute__ ((packed)) read_local_commands_rp;
1127
#define READ_LOCAL_COMMANDS_RP_SIZE 65
1129
#define OCF_READ_LOCAL_FEATURES 0x0003
1132
uint8_t features[8];
1133
} __attribute__ ((packed)) read_local_features_rp;
1134
#define READ_LOCAL_FEATURES_RP_SIZE 9
1136
#define OCF_READ_LOCAL_EXT_FEATURES 0x0004
1139
} __attribute__ ((packed)) read_local_ext_features_cp;
1140
#define READ_LOCAL_EXT_FEATURES_CP_SIZE 1
1144
uint8_t max_page_num;
1145
uint8_t features[8];
1146
} __attribute__ ((packed)) read_local_ext_features_rp;
1147
#define READ_LOCAL_EXT_FEATURES_RP_SIZE 11
1149
#define OCF_READ_BUFFER_SIZE 0x0005
1154
uint16_t acl_max_pkt;
1155
uint16_t sco_max_pkt;
1156
} __attribute__ ((packed)) read_buffer_size_rp;
1157
#define READ_BUFFER_SIZE_RP_SIZE 8
1159
#define OCF_READ_COUNTRY_CODE 0x0007
1161
#define OCF_READ_BD_ADDR 0x0009
1165
} __attribute__ ((packed)) read_bd_addr_rp;
1166
#define READ_BD_ADDR_RP_SIZE 7
1169
#define OGF_STATUS_PARAM 0x05
1171
#define OCF_READ_FAILED_CONTACT_COUNTER 0x0001
1176
} __attribute__ ((packed)) read_failed_contact_counter_rp;
1177
#define READ_FAILED_CONTACT_COUNTER_RP_SIZE 4
1179
#define OCF_RESET_FAILED_CONTACT_COUNTER 0x0002
1183
} __attribute__ ((packed)) reset_failed_contact_counter_rp;
1184
#define RESET_FAILED_CONTACT_COUNTER_RP_SIZE 4
1186
#define OCF_READ_LINK_QUALITY 0x0003
1190
uint8_t link_quality;
1191
} __attribute__ ((packed)) read_link_quality_rp;
1192
#define READ_LINK_QUALITY_RP_SIZE 4
1194
#define OCF_READ_RSSI 0x0005
1199
} __attribute__ ((packed)) read_rssi_rp;
1200
#define READ_RSSI_RP_SIZE 4
1202
#define OCF_READ_AFH_MAP 0x0006
1208
} __attribute__ ((packed)) read_afh_map_rp;
1209
#define READ_AFH_MAP_RP_SIZE 14
1211
#define OCF_READ_CLOCK 0x0007
1214
uint8_t which_clock;
1215
} __attribute__ ((packed)) read_clock_cp;
1216
#define READ_CLOCK_CP_SIZE 3
1222
} __attribute__ ((packed)) read_clock_rp;
1223
#define READ_CLOCK_RP_SIZE 9
1225
/* Testing commands */
1226
#define OGF_TESTING_CMD 0x3e
1228
#define OCF_READ_LOOPBACK_MODE 0x0001
1230
#define OCF_WRITE_LOOPBACK_MODE 0x0002
1232
#define OCF_ENABLE_DEVICE_UNDER_TEST_MODE 0x0003
1234
#define OCF_WRITE_SIMPLE_PAIRING_DEBUG_MODE 0x0004
1237
} __attribute__ ((packed)) write_simple_pairing_debug_mode_cp;
1238
#define WRITE_SIMPLE_PAIRING_DEBUG_MODE_CP_SIZE 1
1241
} __attribute__ ((packed)) write_simple_pairing_debug_mode_rp;
1242
#define WRITE_SIMPLE_PAIRING_DEBUG_MODE_RP_SIZE 1
1244
/* Vendor specific commands */
1245
#define OGF_VENDOR_CMD 0x3f
1247
/* ---- HCI Events ---- */
1249
#define EVT_INQUIRY_COMPLETE 0x01
1251
#define EVT_INQUIRY_RESULT 0x02
1254
uint8_t pscan_rep_mode;
1255
uint8_t pscan_period_mode;
1257
uint8_t dev_class[3];
1258
uint16_t clock_offset;
1259
} __attribute__ ((packed)) inquiry_info;
1260
#define INQUIRY_INFO_SIZE 14
1262
#define EVT_CONN_COMPLETE 0x03
1269
} __attribute__ ((packed)) evt_conn_complete;
1270
#define EVT_CONN_COMPLETE_SIZE 13
1272
#define EVT_CONN_REQUEST 0x04
1275
uint8_t dev_class[3];
1277
} __attribute__ ((packed)) evt_conn_request;
1278
#define EVT_CONN_REQUEST_SIZE 10
1280
#define EVT_DISCONN_COMPLETE 0x05
1285
} __attribute__ ((packed)) evt_disconn_complete;
1286
#define EVT_DISCONN_COMPLETE_SIZE 4
1288
#define EVT_AUTH_COMPLETE 0x06
1292
} __attribute__ ((packed)) evt_auth_complete;
1293
#define EVT_AUTH_COMPLETE_SIZE 3
1295
#define EVT_REMOTE_NAME_REQ_COMPLETE 0x07
1300
} __attribute__ ((packed)) evt_remote_name_req_complete;
1301
#define EVT_REMOTE_NAME_REQ_COMPLETE_SIZE 255
1303
#define EVT_ENCRYPT_CHANGE 0x08
1308
} __attribute__ ((packed)) evt_encrypt_change;
1309
#define EVT_ENCRYPT_CHANGE_SIZE 5
1311
#define EVT_CHANGE_CONN_LINK_KEY_COMPLETE 0x09
1315
} __attribute__ ((packed)) evt_change_conn_link_key_complete;
1316
#define EVT_CHANGE_CONN_LINK_KEY_COMPLETE_SIZE 3
1318
#define EVT_MASTER_LINK_KEY_COMPLETE 0x0A
1323
} __attribute__ ((packed)) evt_master_link_key_complete;
1324
#define EVT_MASTER_LINK_KEY_COMPLETE_SIZE 4
1326
#define EVT_READ_REMOTE_FEATURES_COMPLETE 0x0B
1330
uint8_t features[8];
1331
} __attribute__ ((packed)) evt_read_remote_features_complete;
1332
#define EVT_READ_REMOTE_FEATURES_COMPLETE_SIZE 11
1334
#define EVT_READ_REMOTE_VERSION_COMPLETE 0x0C
1339
uint16_t manufacturer;
1340
uint16_t lmp_subver;
1341
} __attribute__ ((packed)) evt_read_remote_version_complete;
1342
#define EVT_READ_REMOTE_VERSION_COMPLETE_SIZE 8
1344
#define EVT_QOS_SETUP_COMPLETE 0x0D
1348
uint8_t flags; /* Reserved */
1350
} __attribute__ ((packed)) evt_qos_setup_complete;
1351
#define EVT_QOS_SETUP_COMPLETE_SIZE (4 + HCI_QOS_CP_SIZE)
1353
#define EVT_CMD_COMPLETE 0x0E
1357
} __attribute__ ((packed)) evt_cmd_complete;
1358
#define EVT_CMD_COMPLETE_SIZE 3
1360
#define EVT_CMD_STATUS 0x0F
1365
} __attribute__ ((packed)) evt_cmd_status;
1366
#define EVT_CMD_STATUS_SIZE 4
1368
#define EVT_HARDWARE_ERROR 0x10
1371
} __attribute__ ((packed)) evt_hardware_error;
1372
#define EVT_HARDWARE_ERROR_SIZE 1
1374
#define EVT_FLUSH_OCCURRED 0x11
1377
} __attribute__ ((packed)) evt_flush_occured;
1378
#define EVT_FLUSH_OCCURRED_SIZE 2
1380
#define EVT_ROLE_CHANGE 0x12
1385
} __attribute__ ((packed)) evt_role_change;
1386
#define EVT_ROLE_CHANGE_SIZE 8
1388
#define EVT_NUM_COMP_PKTS 0x13
1391
/* variable length part */
1392
} __attribute__ ((packed)) evt_num_comp_pkts;
1393
#define EVT_NUM_COMP_PKTS_SIZE 1
1395
#define EVT_MODE_CHANGE 0x14
1401
} __attribute__ ((packed)) evt_mode_change;
1402
#define EVT_MODE_CHANGE_SIZE 6
1404
#define EVT_RETURN_LINK_KEYS 0x15
1407
/* variable length part */
1408
} __attribute__ ((packed)) evt_return_link_keys;
1409
#define EVT_RETURN_LINK_KEYS_SIZE 1
1411
#define EVT_PIN_CODE_REQ 0x16
1414
} __attribute__ ((packed)) evt_pin_code_req;
1415
#define EVT_PIN_CODE_REQ_SIZE 6
1417
#define EVT_LINK_KEY_REQ 0x17
1420
} __attribute__ ((packed)) evt_link_key_req;
1421
#define EVT_LINK_KEY_REQ_SIZE 6
1423
#define EVT_LINK_KEY_NOTIFY 0x18
1426
uint8_t link_key[16];
1428
} __attribute__ ((packed)) evt_link_key_notify;
1429
#define EVT_LINK_KEY_NOTIFY_SIZE 23
1431
#define EVT_LOOPBACK_COMMAND 0x19
1433
#define EVT_DATA_BUFFER_OVERFLOW 0x1A
1436
} __attribute__ ((packed)) evt_data_buffer_overflow;
1437
#define EVT_DATA_BUFFER_OVERFLOW_SIZE 1
1439
#define EVT_MAX_SLOTS_CHANGE 0x1B
1443
} __attribute__ ((packed)) evt_max_slots_change;
1444
#define EVT_MAX_SLOTS_CHANGE_SIZE 3
1446
#define EVT_READ_CLOCK_OFFSET_COMPLETE 0x1C
1450
uint16_t clock_offset;
1451
} __attribute__ ((packed)) evt_read_clock_offset_complete;
1452
#define EVT_READ_CLOCK_OFFSET_COMPLETE_SIZE 5
1454
#define EVT_CONN_PTYPE_CHANGED 0x1D
1459
} __attribute__ ((packed)) evt_conn_ptype_changed;
1460
#define EVT_CONN_PTYPE_CHANGED_SIZE 5
1462
#define EVT_QOS_VIOLATION 0x1E
1465
} __attribute__ ((packed)) evt_qos_violation;
1466
#define EVT_QOS_VIOLATION_SIZE 2
1468
#define EVT_PSCAN_REP_MODE_CHANGE 0x20
1471
uint8_t pscan_rep_mode;
1472
} __attribute__ ((packed)) evt_pscan_rep_mode_change;
1473
#define EVT_PSCAN_REP_MODE_CHANGE_SIZE 7
1475
#define EVT_FLOW_SPEC_COMPLETE 0x21
1482
} __attribute__ ((packed)) evt_flow_spec_complete;
1483
#define EVT_FLOW_SPEC_COMPLETE_SIZE (5 + HCI_QOS_CP_SIZE)
1485
#define EVT_INQUIRY_RESULT_WITH_RSSI 0x22
1488
uint8_t pscan_rep_mode;
1489
uint8_t pscan_period_mode;
1490
uint8_t dev_class[3];
1491
uint16_t clock_offset;
1493
} __attribute__ ((packed)) inquiry_info_with_rssi;
1494
#define INQUIRY_INFO_WITH_RSSI_SIZE 14
1497
uint8_t pscan_rep_mode;
1498
uint8_t pscan_period_mode;
1500
uint8_t dev_class[3];
1501
uint16_t clock_offset;
1503
} __attribute__ ((packed)) inquiry_info_with_rssi_and_pscan_mode;
1504
#define INQUIRY_INFO_WITH_RSSI_AND_PSCAN_MODE_SIZE 15
1506
#define EVT_READ_REMOTE_EXT_FEATURES_COMPLETE 0x23
1511
uint8_t max_page_num;
1512
uint8_t features[8];
1513
} __attribute__ ((packed)) evt_read_remote_ext_features_complete;
1514
#define EVT_READ_REMOTE_EXT_FEATURES_COMPLETE_SIZE 13
1516
#define EVT_SYNC_CONN_COMPLETE 0x2C
1522
uint8_t trans_interval;
1523
uint8_t retrans_window;
1524
uint16_t rx_pkt_len;
1525
uint16_t tx_pkt_len;
1527
} __attribute__ ((packed)) evt_sync_conn_complete;
1528
#define EVT_SYNC_CONN_COMPLETE_SIZE 17
1530
#define EVT_SYNC_CONN_CHANGED 0x2D
1534
uint8_t trans_interval;
1535
uint8_t retrans_window;
1536
uint16_t rx_pkt_len;
1537
uint16_t tx_pkt_len;
1538
} __attribute__ ((packed)) evt_sync_conn_changed;
1539
#define EVT_SYNC_CONN_CHANGED_SIZE 9
1541
#define EVT_SNIFF_SUBRATING 0x2E
1545
uint16_t max_tx_latency;
1546
uint16_t max_rx_latency;
1547
uint16_t min_remote_timeout;
1548
uint16_t min_local_timeout;
1549
} __attribute__ ((packed)) evt_sniff_subrating;
1550
#define EVT_SNIFF_SUBRATING_SIZE 11
1552
#define EVT_EXTENDED_INQUIRY_RESULT 0x2F
1555
uint8_t pscan_rep_mode;
1556
uint8_t pscan_period_mode;
1557
uint8_t dev_class[3];
1558
uint16_t clock_offset;
1561
} __attribute__ ((packed)) extended_inquiry_info;
1562
#define EXTENDED_INQUIRY_INFO_SIZE 254
1564
#define EVT_ENCRYPTION_KEY_REFRESH_COMPLETE 0x30
1568
} __attribute__ ((packed)) evt_encryption_key_refresh_complete;
1569
#define EVT_ENCRYPTION_KEY_REFRESH_COMPLETE_SIZE 3
1571
#define EVT_IO_CAPABILITY_REQUEST 0x31
1574
} __attribute__ ((packed)) evt_io_capability_request;
1575
#define EVT_IO_CAPABILITY_REQUEST_SIZE 6
1577
#define EVT_IO_CAPABILITY_RESPONSE 0x32
1582
uint8_t authentication;
1583
} __attribute__ ((packed)) evt_io_capability_response;
1584
#define EVT_IO_CAPABILITY_RESPONSE_SIZE 9
1586
#define EVT_USER_CONFIRM_REQUEST 0x33
1590
} __attribute__ ((packed)) evt_user_confirm_request;
1591
#define EVT_USER_CONFIRM_REQUEST_SIZE 10
1593
#define EVT_USER_PASSKEY_REQUEST 0x34
1596
} __attribute__ ((packed)) evt_user_passkey_request;
1597
#define EVT_USER_PASSKEY_REQUEST_SIZE 6
1599
#define EVT_REMOTE_OOB_DATA_REQUEST 0x35
1602
} __attribute__ ((packed)) evt_remote_oob_data_request;
1603
#define EVT_REMOTE_OOB_DATA_REQUEST_SIZE 6
1605
#define EVT_SIMPLE_PAIRING_COMPLETE 0x36
1609
} __attribute__ ((packed)) evt_simple_pairing_complete;
1610
#define EVT_SIMPLE_PAIRING_COMPLETE_SIZE 7
1612
#define EVT_LINK_SUPERVISION_TIMEOUT_CHANGED 0x38
1616
} __attribute__ ((packed)) evt_link_supervision_timeout_changed;
1617
#define EVT_LINK_SUPERVISION_TIMEOUT_CHANGED_SIZE 4
1619
#define EVT_ENHANCED_FLUSH_COMPLETE 0x39
1622
} __attribute__ ((packed)) evt_enhanced_flush_complete;
1623
#define EVT_ENHANCED_FLUSH_COMPLETE_SIZE 2
1625
#define EVT_USER_PASSKEY_NOTIFY 0x3B
1629
} __attribute__ ((packed)) evt_user_passkey_notify;
1630
#define EVT_USER_PASSKEY_NOTIFY_SIZE 10
1632
#define EVT_KEYPRESS_NOTIFY 0x3C
1636
} __attribute__ ((packed)) evt_keypress_notify;
1637
#define EVT_KEYPRESS_NOTIFY_SIZE 7
1639
#define EVT_REMOTE_HOST_FEATURES_NOTIFY 0x3D
1642
uint8_t features[8];
1643
} __attribute__ ((packed)) evt_remote_host_features_notify;
1644
#define EVT_REMOTE_HOST_FEATURES_NOTIFY_SIZE 14
1646
#define EVT_TESTING 0xFE
1648
#define EVT_VENDOR 0xFF
1650
/* Internal events generated by BlueZ stack */
1651
#define EVT_STACK_INTERNAL 0xFD
1655
} __attribute__ ((packed)) evt_stack_internal;
1656
#define EVT_STACK_INTERNAL_SIZE 2
1658
#define EVT_SI_DEVICE 0x01
1662
} __attribute__ ((packed)) evt_si_device;
1663
#define EVT_SI_DEVICE_SIZE 4
1665
/* -------- HCI Packet structures -------- */
1666
#define HCI_TYPE_LEN 1
1669
uint16_t opcode; /* OCF & OGF */
1671
} __attribute__ ((packed)) hci_command_hdr;
1672
#define HCI_COMMAND_HDR_SIZE 3
1677
} __attribute__ ((packed)) hci_event_hdr;
1678
#define HCI_EVENT_HDR_SIZE 2
1681
uint16_t handle; /* Handle & Flags(PB, BC) */
1683
} __attribute__ ((packed)) hci_acl_hdr;
1684
#define HCI_ACL_HDR_SIZE 4
1689
} __attribute__ ((packed)) hci_sco_hdr;
1690
#define HCI_SCO_HDR_SIZE 3
1696
} __attribute__ ((packed)) hci_msg_hdr;
1697
#define HCI_MSG_HDR_SIZE 6
1699
/* Command opcode pack/unpack */
1700
#define cmd_opcode_pack(ogf, ocf) (uint16_t)((ocf & 0x03ff)|(ogf << 10))
1701
#define cmd_opcode_ogf(op) (op >> 10)
1702
#define cmd_opcode_ocf(op) (op & 0x03ff)
1704
/* ACL handle and flags pack/unpack */
1705
#define acl_handle_pack(h, f) (uint16_t)((h & 0x0fff)|(f << 12))
1706
#define acl_handle(h) (h & 0x0fff)
1707
#define acl_flags(h) (h >> 12)
1709
#endif /* _NO_HCI_DEFS */
1711
/* HCI Socket options */
1712
#define HCI_DATA_DIR 1
1713
#define HCI_FILTER 2
1714
#define HCI_TIME_STAMP 3
1716
/* HCI CMSG flags */
1717
#define HCI_CMSG_DIR 0x0001
1718
#define HCI_CMSG_TSTAMP 0x0002
1720
struct sockaddr_hci {
1721
sa_family_t hci_family;
1722
unsigned short hci_dev;
1724
#define HCI_DEV_NONE 0xffff
1728
uint32_t event_mask[2];
1732
#define HCI_FLT_TYPE_BITS 31
1733
#define HCI_FLT_EVENT_BITS 63
1734
#define HCI_FLT_OGF_BITS 63
1735
#define HCI_FLT_OCF_BITS 127
1737
/* Ioctl requests structures */
1738
struct hci_dev_stats {
1751
struct hci_dev_info {
1760
uint8_t features[8];
1763
uint32_t link_policy;
1771
struct hci_dev_stats stat;
1774
struct hci_conn_info {
1783
struct hci_dev_req {
1788
struct hci_dev_list_req {
1790
struct hci_dev_req dev_req[0]; /* hci_dev_req structures */
1793
struct hci_conn_list_req {
1796
struct hci_conn_info conn_info[0];
1799
struct hci_conn_info_req {
1802
struct hci_conn_info conn_info[0];
1805
struct hci_auth_info_req {
1810
struct hci_inquiry_req {
1817
#define IREQ_CACHE_FLUSH 0x0001
1823
#endif /* __HCI_H */