aboutsummaryrefslogtreecommitdiffstats
path: root/sys/linux/dev_vhci.txt
blob: b74691521a02ae9db1065058e797dbf43477efd2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
# Copyright 2020 syzkaller project authors. All rights reserved.
# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.

include <net/bluetooth/bluetooth.h>
include <net/bluetooth/hci_sock.h>
include <net/bluetooth/sco.h>
include <net/bluetooth/hci.h>

syz_emit_vhci(data ptr[in, vhci_pkt], size bytesize[data])

# Matches HCI_HANDLE_1/HCI_HANDLE_2 in executor/common_linux.h.
hci_handles = 200, 201
type hci_conn_handle flags[hci_handles, int16]
type hci_phy_handle flags[hci_handles, int8]

vhci_pkt [
	HCI_EVENT_PKT	vhci_event_pkt
	HCI_ACLDATA_PKT	vhci_acldata_pkt
	HCI_SCODATA_PKT	vhci_scodata_pkt
	HCI_VENDOR_PKT	vhci_vendor_pkt
] [varlen]

vhci_command_pkt {
	cmd	const[HCI_COMMAND_PKT, int8]
	hdr	hci_command_hdr_un
}

vhci_event_pkt {
	cmd	const[HCI_EVENT_PKT, int8]
	hdr	hci_event_hdr_un
}

vhci_acldata_pkt {
	cmd		const[HCI_ACLDATA_PKT, int8]
	acl_hdr		hci_acl_hdr[vhci_acldata_pkt:l2cap_hdr]
	l2cap_hdr	l2cap_hdr_un
}

vhci_scodata_pkt {
	cmd	const[HCI_SCODATA_PKT, int8]
	sco_hdr	hci_sco_hdr[vhci_scodata_pkt:data]
	data	array[int8]
}

vhci_vendor_pkt {
	cmd	const[HCI_VENDOR_PKT, int8]
	opcode	flags[vhci_vendor_pkt_opcode, int8]
}

vhci_vendor_pkt_opcode = HCI_PRIMARY, HCI_AMP, HCI_EXTERNAL_CONFIG, HCI_RAW_DEVICE

type hci_acl_hdr[DATA] {
	handle	flags[hci_handles, int16:12]
	pb	int16:2
	bc	int16:2
	dlen	bytesize[DATA, int16]
} [packed]

type hci_sco_hdr[DATA] {
	handle	hci_conn_handle
	dlen	bytesize[DATA, int8]
} [packed]

ext_flow_spec {
	id		int8
	stype		int8
	msdu		int16
	sdu_itime	int32
	acc_lat		int32
	flush_to	int32
} [packed]

hci_cis {
	cis_handle	int16
	acl_handle	int16
} [packed]

hci_cis_params {
	cis_id	int8
	m_sdu	int16
	s_sdu	int16
	m_phy	int8
	s_phy	int8
	m_rtn	int8
	s_rtn	int8
} [packed]

hci_command_hdr_un [
	accept_conn_req			hci_command_packet_t[HCI_OP_ACCEPT_CONN_REQ, hci_cp_accept_conn_req]
	accept_phy_link			hci_command_packet_t[HCI_OP_ACCEPT_PHY_LINK, hci_cp_accept_phy_link]
	accept_sync_conn_req		hci_command_packet_t[HCI_OP_ACCEPT_SYNC_CONN_REQ, hci_cp_accept_sync_conn_req]
	add_sco				hci_command_packet_t[HCI_OP_ADD_SCO, hci_cp_add_sco]
	auth_requested			hci_command_packet_t[HCI_OP_AUTH_REQUESTED, hci_cp_auth_requested]
	change_conn_link_key		hci_command_packet_t[HCI_OP_CHANGE_CONN_LINK_KEY, hci_cp_change_conn_link_key]
	change_conn_ptype		hci_command_packet_t[HCI_OP_CHANGE_CONN_PTYPE, hci_cp_change_conn_ptype]
	create_logical_link		hci_command_packet_t[HCI_OP_CREATE_LOGICAL_LINK, hci_cp_create_accept_logical_link]
	accept_logical_link		hci_command_packet_t[HCI_OP_ACCEPT_LOGICAL_LINK, hci_cp_create_accept_logical_link]
	create_conn			hci_command_packet_t[HCI_OP_CREATE_CONN, hci_cp_create_conn]
	create_conn_cancel		hci_command_packet_t[HCI_OP_CREATE_CONN_CANCEL, hci_cp_create_conn_cancel]
	create_phy_link			hci_command_packet_t[HCI_OP_CREATE_PHY_LINK, hci_cp_create_phy_link]
	delete_reserved_lt_addr		hci_command_packet_t[HCI_OP_DELETE_RESERVED_LT_ADDR, hci_cp_delete_reserved_lt_addr]
	delete_stored_link_key		hci_command_packet_t[HCI_OP_DELETE_STORED_LINK_KEY, hci_cp_delete_stored_link_key]
	disconn_logical_link		hci_command_packet_t[HCI_OP_DISCONN_LOGICAL_LINK, hci_cp_disconn_logical_link]
	disconn_phy_link		hci_command_packet_t[HCI_OP_DISCONN_PHY_LINK, hci_cp_disconn_phy_link]
	disconnect			hci_command_packet_t[HCI_OP_DISCONNECT, hci_cp_disconnect]
	exit_sniff_mode			hci_command_packet_t[HCI_OP_EXIT_SNIFF_MODE, hci_cp_exit_sniff_mode]
	host_buffer_size		hci_command_packet_t[HCI_OP_HOST_BUFFER_SIZE, hci_cp_host_buffer_size]
	inquiry				hci_command_packet_t[HCI_OP_INQUIRY, hci_cp_inquiry]
	io_capability_neg_reply		hci_command_packet_t[HCI_OP_IO_CAPABILITY_NEG_REPLY, hci_cp_io_capability_neg_reply]
	io_capability_reply		hci_command_packet_t[HCI_OP_IO_CAPABILITY_REPLY, hci_cp_io_capability_reply]
	le_accept_cis			hci_command_packet_t[HCI_OP_LE_ACCEPT_CIS, hci_cp_le_accept_cis]
	le_add_to_resolv_list		hci_command_packet_t[HCI_OP_LE_ADD_TO_RESOLV_LIST, hci_cp_le_add_to_resolv_list]
	le_add_to_accept_list		hci_command_packet_t[HCI_OP_LE_ADD_TO_ACCEPT_LIST, hci_cp_le_add_to_accept_list]
	le_conn_param_req_neg_reply	hci_command_packet_t[HCI_OP_LE_CONN_PARAM_REQ_NEG_REPLY, hci_cp_le_conn_param_req_neg_reply]
	le_conn_param_req_reply		hci_command_packet_t[HCI_OP_LE_CONN_PARAM_REQ_REPLY, hci_cp_le_conn_param_req_reply]
	le_conn_update			hci_command_packet_t[HCI_OP_LE_CONN_UPDATE, hci_cp_le_conn_update]
	le_create_cis			hci_command_packet_t[HCI_OP_LE_CREATE_CIS, hci_cp_le_create_cis]
	le_create_conn			hci_command_packet_t[HCI_OP_LE_CREATE_CONN, hci_cp_le_create_conn]
	le_del_from_resolv_list		hci_command_packet_t[HCI_OP_LE_DEL_FROM_RESOLV_LIST, hci_cp_le_del_from_resolv_list]
	le_del_from_accept_list		hci_command_packet_t[HCI_OP_LE_DEL_FROM_ACCEPT_LIST, hci_cp_le_del_from_accept_list]
	le_ext_create_conn		hci_command_packet_t[HCI_OP_LE_EXT_CREATE_CONN, hci_cp_le_ext_create_conn]
	le_ltk_neg_reply		hci_command_packet_t[HCI_OP_LE_LTK_NEG_REPLY, hci_cp_le_ltk_neg_reply]
	le_ltk_reply			hci_command_packet_t[HCI_OP_LE_LTK_REPLY, hci_cp_le_ltk_reply]
	le_read_iso_tx_sync		hci_command_packet_t[HCI_OP_LE_READ_ISO_TX_SYNC, hci_cp_le_read_iso_tx_sync]
	le_read_remote_features		hci_command_packet_t[HCI_OP_LE_READ_REMOTE_FEATURES, hci_cp_le_read_remote_features]
	le_reject_cis			hci_command_packet_t[HCI_OP_LE_REJECT_CIS, hci_cp_le_reject_cis]
	le_remove_cig			hci_command_packet_t[HCI_OP_LE_REMOVE_CIG, hci_cp_le_remove_cig]
	le_set_adv_data			hci_command_packet_t[HCI_OP_LE_SET_ADV_DATA, hci_cp_le_set_adv_data]
	le_set_adv_param		hci_command_packet_t[HCI_OP_LE_SET_ADV_PARAM, hci_cp_le_set_adv_param]
	le_set_adv_set_rand_addr	hci_command_packet_t[HCI_OP_LE_SET_ADV_SET_RAND_ADDR, hci_cp_le_set_adv_set_rand_addr]
	le_set_cig_params		hci_command_packet_t[HCI_OP_LE_SET_CIG_PARAMS, hci_cp_le_set_cig_params]
	le_set_data_len			hci_command_packet_t[HCI_OP_LE_SET_DATA_LEN, hci_cp_le_set_data_len]
	le_set_default_phy		hci_command_packet_t[HCI_OP_LE_SET_DEFAULT_PHY, hci_cp_le_set_default_phy]
	le_set_event_mask		hci_command_packet_t[HCI_OP_LE_SET_EVENT_MASK, hci_cp_le_set_event_mask]
	le_set_ext_adv_data		hci_command_packet_t[HCI_OP_LE_SET_EXT_ADV_DATA, hci_cp_le_set_ext_adv_data]
	le_set_ext_adv_enable		hci_command_packet_t[HCI_OP_LE_SET_EXT_ADV_ENABLE, hci_cp_le_set_ext_adv_enable]
	le_set_ext_adv_params		hci_command_packet_t[HCI_OP_LE_SET_EXT_ADV_PARAMS, hci_cp_le_set_ext_adv_params]
	le_set_ext_scan_enable		hci_command_packet_t[HCI_OP_LE_SET_EXT_SCAN_ENABLE, hci_cp_le_set_ext_scan_enable]
	le_set_ext_scan_params		hci_command_packet_t[HCI_OP_LE_SET_EXT_SCAN_PARAMS, hci_cp_le_set_ext_scan_params]
	le_set_ext_scan_rsp_data	hci_command_packet_t[HCI_OP_LE_SET_EXT_SCAN_RSP_DATA, hci_cp_le_set_ext_scan_rsp_data]
	le_set_scan_enable		hci_command_packet_t[HCI_OP_LE_SET_SCAN_ENABLE, hci_cp_le_set_scan_enable]
	le_set_scan_param		hci_command_packet_t[HCI_OP_LE_SET_SCAN_PARAM, hci_cp_le_set_scan_param]
	le_set_scan_rsp_data		hci_command_packet_t[HCI_OP_LE_SET_SCAN_RSP_DATA, hci_cp_le_set_scan_rsp_data]
	le_start_enc			hci_command_packet_t[HCI_OP_LE_START_ENC, hci_cp_le_start_enc]
	le_write_def_data_len		hci_command_packet_t[HCI_OP_LE_WRITE_DEF_DATA_LEN, hci_cp_le_write_def_data_len]
	link_key_neg_reply		hci_command_packet_t[HCI_OP_LINK_KEY_NEG_REPLY, hci_cp_link_key_neg_reply]
	link_key_reply			hci_command_packet_t[HCI_OP_LINK_KEY_REPLY, hci_cp_link_key_reply]
	logical_link_cancel		hci_command_packet_t[HCI_OP_LOGICAL_LINK_CANCEL, hci_cp_logical_link_cancel]
	pin_code_neg_reply		hci_command_packet_t[HCI_OP_PIN_CODE_NEG_REPLY, hci_cp_pin_code_neg_reply]
	pin_code_reply			hci_command_packet_t[HCI_OP_PIN_CODE_REPLY, hci_cp_pin_code_reply]
	read_auth_payload_to		hci_command_packet_t[HCI_OP_READ_AUTH_PAYLOAD_TO, hci_cp_read_auth_payload_to]
	read_clock			hci_command_packet_t[HCI_OP_READ_CLOCK, hci_cp_read_clock]
	read_clock_offset		hci_command_packet_t[HCI_OP_READ_CLOCK_OFFSET, hci_cp_read_clock_offset]
	read_enc_key_size		hci_command_packet_t[HCI_OP_READ_ENC_KEY_SIZE, hci_cp_read_enc_key_size]
	read_link_policy		hci_command_packet_t[HCI_OP_READ_LINK_POLICY, hci_cp_read_link_policy]
	read_local_amp_assoc		hci_command_packet_t[HCI_OP_READ_LOCAL_AMP_ASSOC, hci_cp_read_local_amp_assoc]
	read_local_ext_features		hci_command_packet_t[HCI_OP_READ_LOCAL_EXT_FEATURES, hci_cp_read_local_ext_features]
	read_remote_ext_features	hci_command_packet_t[HCI_OP_READ_REMOTE_EXT_FEATURES, hci_cp_read_remote_ext_features]
	read_remote_features		hci_command_packet_t[HCI_OP_READ_REMOTE_FEATURES, hci_cp_read_remote_features]
	read_remote_version		hci_command_packet_t[HCI_OP_READ_REMOTE_VERSION, hci_cp_read_remote_version]
	read_rssi			hci_command_packet_t[HCI_OP_READ_RSSI, hci_cp_read_rssi]
	read_stored_link_key		hci_command_packet_t[HCI_OP_READ_STORED_LINK_KEY, hci_cp_read_stored_link_key]
	read_tx_power			hci_command_packet_t[HCI_OP_READ_TX_POWER, hci_cp_read_tx_power]
	reject_conn_req			hci_command_packet_t[HCI_OP_REJECT_CONN_REQ, hci_cp_reject_conn_req]
	reject_sync_conn_req		hci_command_packet_t[HCI_OP_REJECT_SYNC_CONN_REQ, hci_cp_reject_sync_conn_req]
	remote_name_req			hci_command_packet_t[HCI_OP_REMOTE_NAME_REQ, hci_cp_remote_name_req]
	remote_name_req_cancel		hci_command_packet_t[HCI_OP_REMOTE_NAME_REQ_CANCEL, hci_cp_remote_name_req_cancel]
	remote_oob_data_neg_reply	hci_command_packet_t[HCI_OP_REMOTE_OOB_DATA_NEG_REPLY, hci_cp_remote_oob_data_neg_reply]
	remote_oob_data_reply		hci_command_packet_t[HCI_OP_REMOTE_OOB_DATA_REPLY, hci_cp_remote_oob_data_reply]
	remote_oob_ext_data_reply	hci_command_packet_t[HCI_OP_REMOTE_OOB_EXT_DATA_REPLY, hci_cp_remote_oob_ext_data_reply]
	role_discovery			hci_command_packet_t[HCI_OP_ROLE_DISCOVERY, hci_cp_role_discovery]
	set_conn_encrypt		hci_command_packet_t[HCI_OP_SET_CONN_ENCRYPT, hci_cp_set_conn_encrypt]
	set_cpb				hci_command_packet_t[HCI_OP_SET_CPB, hci_cp_set_cpb]
	set_cpb_data			hci_command_packet_t[HCI_OP_SET_CPB_DATA, hci_cp_set_cpb_data]
	set_reserved_lt_addr		hci_command_packet_t[HCI_OP_SET_RESERVED_LT_ADDR, hci_cp_set_reserved_lt_addr]
	setup_sync_conn			hci_command_packet_t[HCI_OP_SETUP_SYNC_CONN, hci_cp_setup_sync_conn]
	sniff_mode			hci_command_packet_t[HCI_OP_SNIFF_MODE, hci_cp_sniff_mode]
	sniff_subrate			hci_command_packet_t[HCI_OP_SNIFF_SUBRATE, hci_cp_sniff_subrate]
	switch_role			hci_command_packet_t[HCI_OP_SWITCH_ROLE, hci_cp_switch_role]
	user_confirm_reply		hci_command_packet_t[HCI_OP_USER_CONFIRM_REPLY, hci_cp_user_confirm_reply]
	user_passkey_reply		hci_command_packet_t[HCI_OP_USER_PASSKEY_REPLY, hci_cp_user_passkey_reply]
	write_auth_payload_to		hci_command_packet_t[HCI_OP_WRITE_AUTH_PAYLOAD_TO, hci_cp_write_auth_payload_to]
	write_class_of_dev		hci_command_packet_t[HCI_OP_WRITE_CLASS_OF_DEV, hci_cp_write_class_of_dev]
	write_current_iac_lap		hci_command_packet_t[HCI_OP_WRITE_CURRENT_IAC_LAP, hci_cp_write_current_iac_lap]
	write_def_err_data_reporting	hci_command_packet_t[HCI_OP_WRITE_DEF_ERR_DATA_REPORTING, hci_cp_write_def_err_data_reporting]
	write_def_link_policy		hci_command_packet_t[HCI_OP_WRITE_DEF_LINK_POLICY, hci_cp_write_def_link_policy]
	write_eir			hci_command_packet_t[HCI_OP_WRITE_EIR, hci_cp_write_eir]
	write_le_host_supported		hci_command_packet_t[HCI_OP_WRITE_LE_HOST_SUPPORTED, hci_cp_write_le_host_supported]
	write_link_policy		hci_command_packet_t[HCI_OP_WRITE_LINK_POLICY, hci_cp_write_link_policy]
	write_local_name		hci_command_packet_t[HCI_OP_WRITE_LOCAL_NAME, hci_cp_write_local_name]
	write_page_scan_activity	hci_command_packet_t[HCI_OP_WRITE_PAGE_SCAN_ACTIVITY, hci_cp_write_page_scan_activity]
	write_remote_amp_assoc		hci_command_packet_t[HCI_OP_WRITE_REMOTE_AMP_ASSOC, hci_cp_write_remote_amp_assoc]
	write_sc_support		hci_command_packet_t[HCI_OP_WRITE_SC_SUPPORT, hci_cp_write_sc_support]
	write_ssp_mode			hci_command_packet_t[HCI_OP_WRITE_SSP_MODE, hci_cp_write_ssp_mode]
	write_sync_train_params		hci_command_packet_t[HCI_OP_WRITE_SYNC_TRAIN_PARAMS, hci_cp_write_sync_train_params]
	write_voice_setting		hci_command_packet_t[HCI_OP_WRITE_VOICE_SETTING, hci_cp_write_voice_setting]
] [varlen]

type hci_command_packet_t[OPCODE, PAYLOAD] {
	hdr	hci_command_packet[OPCODE]
	payload	PAYLOAD
} [packed]

type hci_command_packet[OPCODE] {
	opcode	const[OPCODE, int16]
	plen	bytesize[hci_command_packet_t:payload, int8]
} [packed]

hci_cp_accept_conn_req {
	bdaddr	bdaddr_t
	role	int8
} [packed]

hci_cp_accept_phy_link {
	phy_handle	hci_phy_handle
	key_len		int8
	key_type	int8
	key		array[int8]
} [packed]

hci_cp_accept_sync_conn_req {
	bdaddr		bdaddr_t
	tx_bandwidth	int32
	rx_bandwidth	int32
	max_latency	int16
	content_format	int16
	retrans_effort	int8
	pkt_type	int16
} [packed]

hci_cp_add_sco {
	handle		hci_conn_handle
	pkt_type	int16
} [packed]

hci_cp_auth_requested {
	handle	hci_conn_handle
} [packed]

hci_cp_change_conn_link_key {
	handle	hci_conn_handle
} [packed]

hci_cp_change_conn_ptype {
	handle		hci_conn_handle
	pkt_type	int16
} [packed]

hci_cp_create_accept_logical_link {
	phy_handle	hci_phy_handle
	tx_flow_spec	ext_flow_spec
	rx_flow_spec	ext_flow_spec
} [packed]

hci_cp_create_conn {
	bdaddr		bdaddr_t
	pkt_type	int16
	pscan_rep_mode	int8
	pscan_mode	int8
	clock_offset	int16
	role_switch	int8
} [packed]

hci_cp_create_conn_cancel {
	bdaddr	bdaddr_t
} [packed]

hci_cp_create_phy_link {
	phy_handle	hci_phy_handle
	key_len		int8
	key_type	int8
	key		array[int8]
} [packed]

hci_cp_delete_reserved_lt_addr {
	lt_addr	int8
} [packed]

hci_cp_delete_stored_link_key {
	bdaddr		bdaddr_t
	delete_all	int8
} [packed]

hci_cp_disconn_logical_link {
	log_handle	int16
} [packed]

hci_cp_disconn_phy_link {
	phy_handle	hci_phy_handle
	reason		int8
} [packed]

hci_cp_disconnect {
	handle	hci_conn_handle
	reason	int8
} [packed]

hci_cp_exit_sniff_mode {
	handle	hci_conn_handle
} [packed]

hci_cp_host_buffer_size {
	acl_mtu		int16
	sco_mtu		int8
	acl_max_pkt	int16
	sco_max_pkt	int16
} [packed]

hci_cp_inquiry {
	lap	array[int8, 3]
	length	int8
	num_rsp	int8
} [packed]

hci_cp_io_capability_neg_reply {
	bdaddr	bdaddr_t
	reason	int8
} [packed]

hci_cp_io_capability_reply {
	bdaddr		bdaddr_t
	capability	int8
	oob_data	int8
	authentication	int8
} [packed]

hci_cp_le_accept_cis {
	handle	hci_conn_handle
} [packed]

hci_cp_le_add_to_resolv_list {
	bdaddr_type	int8
	bdaddr		bdaddr_t
	peer_irk	array[int8, 16]
	local_irk	array[int8, 16]
} [packed]

hci_cp_le_add_to_accept_list {
	bdaddr_type	int8
	bdaddr		bdaddr_t
} [packed]

hci_cp_le_conn_param_req_neg_reply {
	handle	hci_conn_handle
	reason	int8
} [packed]

hci_cp_le_conn_param_req_reply {
	handle		hci_conn_handle
	interval_min	int16
	interval_max	int16
	latency		int16
	timeout		int16
	min_ce_len	int16
	max_ce_len	int16
} [packed]

hci_cp_le_conn_update {
	handle			hci_conn_handle
	conn_interval_min	int16
	conn_interval_max	int16
	conn_latency		int16
	supervision_timeout	int16
	min_ce_len		int16
	max_ce_len		int16
} [packed]

hci_cp_le_create_cis {
	num_cis	len[cis, int8]
	cis	array[hci_cis]
} [packed]

hci_cp_le_create_conn {
	scan_interval		int16
	scan_window		int16
	filter_policy		int8
	peer_addr_type		int8
	peer_addr		bdaddr_t
	own_address_type	int8
	conn_interval_min	int16
	conn_interval_max	int16
	conn_latency		int16
	supervision_timeout	int16
	min_ce_len		int16
	max_ce_len		int16
} [packed]

hci_cp_le_del_from_resolv_list {
	bdaddr_type	int8
	bdaddr		bdaddr_t
} [packed]

hci_cp_le_del_from_accept_list {
	bdaddr_type	int8
	bdaddr		bdaddr_t
} [packed]

hci_cp_le_ext_create_conn {
	filter_policy	int8
	own_addr_type	int8
	peer_addr_type	int8
	peer_addr	bdaddr_t
	phys		int8
	data		array[int8]
} [packed]

hci_cp_le_ltk_neg_reply {
	handle	hci_conn_handle
} [packed]

hci_cp_le_ltk_reply {
	handle	hci_conn_handle
	ltk	array[int8, 16]
} [packed]

hci_cp_le_read_iso_tx_sync {
	handle	hci_conn_handle
} [packed]

hci_cp_le_read_remote_features {
	handle	hci_conn_handle
} [packed]

hci_cp_le_reject_cis {
	handle	hci_conn_handle
	reason	int8
} [packed]

hci_cp_le_remove_cig {
	cig_id	int8
} [packed]

hci_cp_le_set_adv_data {
	length	int8
	data	array[int8, 31]
} [packed]

hci_cp_le_set_adv_param {
	min_interval		int16
	max_interval		int16
	type			int8
	own_address_type	int8
	direct_addr_type	int8
	direct_addr		bdaddr_t
	channel_map		int8
	filter_policy		int8
} [packed]

hci_cp_le_set_adv_set_rand_addr {
	handle	int8
	bdaddr	bdaddr_t
} [packed]

hci_cp_le_set_cig_params {
	cig_id		int8
	m_interval	array[int8, 3]
	s_interval	array[int8, 3]
	sca		int8
	packing		int8
	framing		int8
	m_latency	int16
	s_latency	int16
	num_cis		len[cis, int8]
	cis		array[hci_cis_params]
} [packed]

hci_cp_le_set_data_len {
	handle	hci_conn_handle
	tx_len	int16
	tx_time	int16
} [packed]

hci_cp_le_set_default_phy {
	all_phys	int8
	tx_phys		int8
	rx_phys		int8
} [packed]

hci_cp_le_set_event_mask {
	mask	array[int8, 8]
} [packed]

hci_cp_le_set_ext_adv_data {
	handle		int8
	operation	int8
	frag_pref	int8
	length		int8
	data		array[int8, 31]
} [packed]

hci_cp_le_set_ext_adv_enable {
	enable		int8
	num_of_sets	int8
	data		array[int8]
} [packed]

hci_cp_le_set_ext_adv_params {
	handle			int8
	evt_properties		int16
	min_interval		array[int8, 3]
	max_interval		array[int8, 3]
	channel_map		int8
	own_addr_type		int8
	peer_addr_type		int8
	peer_addr		bdaddr_t
	filter_policy		int8
	tx_power		int8
	primary_phy		int8
	secondary_max_skip	int8
	secondary_phy		int8
	sid			int8
	notif_enable		int8
} [packed]

hci_cp_le_set_ext_scan_enable {
	enable		int8
	filter_dup	int8
	duration	int16
	period		int16
} [packed]

hci_cp_le_set_ext_scan_params {
	own_addr_type	int8
	filter_policy	int8
	scanning_phys	int8
	data		array[int8]
} [packed]

hci_cp_le_set_ext_scan_rsp_data {
	handle		int8
	operation	int8
	frag_pref	int8
	length		int8
	data		array[int8, 31]
} [packed]

hci_cp_le_set_scan_enable {
	enable		int8
	filter_dup	int8
} [packed]

hci_cp_le_set_scan_param {
	type			int8
	interval		int16
	window			int16
	own_address_type	int8
	filter_policy		int8
} [packed]

hci_cp_le_set_scan_rsp_data {
	length	int8
	data	array[int8, 31]
} [packed]

hci_cp_le_start_enc {
	handle	hci_conn_handle
	rand	int64
	ediv	int16
	ltk	array[int8, 16]
} [packed]

hci_cp_le_write_def_data_len {
	tx_len	int16
	tx_time	int16
} [packed]

hci_cp_link_key_neg_reply {
	bdaddr	bdaddr_t
} [packed]

hci_cp_link_key_reply {
	bdaddr		bdaddr_t
	link_key	array[int8, 16]
} [packed]

hci_cp_logical_link_cancel {
	phy_handle	hci_phy_handle
	flow_spec_id	int8
} [packed]

hci_cp_pin_code_neg_reply {
	bdaddr	bdaddr_t
} [packed]

hci_cp_pin_code_reply {
	bdaddr		bdaddr_t
	pin_len		int8
	pin_code	array[int8, 16]
} [packed]

hci_cp_read_auth_payload_to {
	handle	hci_conn_handle
} [packed]

hci_cp_read_clock {
	handle	hci_conn_handle
	which	int8
} [packed]

hci_cp_read_clock_offset {
	handle	hci_conn_handle
} [packed]

hci_cp_read_enc_key_size {
	handle	hci_conn_handle
} [packed]

hci_cp_read_link_policy {
	handle	hci_conn_handle
} [packed]

hci_cp_read_local_amp_assoc {
	phy_handle	hci_phy_handle
	len_so_far	int16
	max_len		int16
} [packed]

hci_cp_read_local_ext_features {
	page	int8
} [packed]

hci_cp_read_remote_ext_features {
	handle	hci_conn_handle
	page	int8
} [packed]

hci_cp_read_remote_features {
	handle	hci_conn_handle
} [packed]

hci_cp_read_remote_version {
	handle	hci_conn_handle
} [packed]

hci_cp_read_rssi {
	handle	hci_conn_handle
} [packed]

hci_cp_read_stored_link_key {
	bdaddr		bdaddr_t
	read_all	int8
} [packed]

hci_cp_read_tx_power {
	handle	hci_conn_handle
	type	int8
} [packed]

hci_cp_reject_conn_req {
	bdaddr	bdaddr_t
	reason	int8
} [packed]

hci_cp_reject_sync_conn_req {
	bdaddr	bdaddr_t
	reason	int8
} [packed]

hci_cp_remote_name_req {
	bdaddr		bdaddr_t
	pscan_rep_mode	int8
	pscan_mode	int8
	clock_offset	int16
} [packed]

hci_cp_remote_name_req_cancel {
	bdaddr	bdaddr_t
} [packed]

hci_cp_remote_oob_data_neg_reply {
	bdaddr	bdaddr_t
} [packed]

hci_cp_remote_oob_data_reply {
	bdaddr	bdaddr_t
	hash	array[int8, 16]
	rand	array[int8, 16]
} [packed]

hci_cp_remote_oob_ext_data_reply {
	bdaddr	bdaddr_t
	hash192	array[int8, 16]
	rand192	array[int8, 16]
	hash256	array[int8, 16]
	rand256	array[int8, 16]
} [packed]

hci_cp_role_discovery {
	handle	hci_conn_handle
} [packed]

hci_cp_set_conn_encrypt {
	handle	hci_conn_handle
	encrypt	int8
} [packed]

hci_cp_set_cpb {
	enable		int8
	lt_addr		int8
	lpo_allowed	int8
	packet_type	int16
	interval_min	int16
	interval_max	int16
	cpb_sv_tout	int16
} [packed]

hci_cp_set_cpb_data {
	lt_addr		int8
	fragment	int8
	data_length	int8
	data		array[int8, 252]
} [packed]

hci_cp_set_reserved_lt_addr {
	lt_addr	int8
} [packed]

hci_cp_setup_sync_conn {
	handle		hci_conn_handle
	tx_bandwidth	int32
	rx_bandwidth	int32
	max_latency	int16
	voice_setting	int16
	retrans_effort	int8
	pkt_type	int16
} [packed]

hci_cp_sniff_mode {
	handle		hci_conn_handle
	max_interval	int16
	min_interval	int16
	attempt		int16
	timeout		int16
} [packed]

hci_cp_sniff_subrate {
	handle			hci_conn_handle
	max_latency		int16
	min_remote_timeout	int16
	min_local_timeout	int16
} [packed]

hci_cp_switch_role {
	bdaddr	bdaddr_t
	role	int8
} [packed]

hci_cp_user_confirm_reply {
	bdaddr	bdaddr_t
} [packed]

hci_cp_user_passkey_reply {
	bdaddr	bdaddr_t
	passkey	int32
} [packed]

hci_cp_write_auth_payload_to {
	handle	hci_conn_handle
	timeout	int16
} [packed]

hci_cp_write_class_of_dev {
	dev_class	array[int8, 3]
} [packed]

hci_cp_write_current_iac_lap {
	num_iac	len[iac_lap, int8]
	iac_lap	array[int8, 6]
} [packed]

hci_cp_write_def_err_data_reporting {
	err_data_reporting	int8
} [packed]

hci_cp_write_def_link_policy {
	policy	int16
} [packed]

hci_cp_write_eir {
	fec	int8
	data	array[int8, 240]
} [packed]

hci_cp_write_le_host_supported {
	le	int8
	simul	int8
} [packed]

hci_cp_write_link_policy {
	handle	hci_conn_handle
	policy	int16
} [packed]

hci_cp_write_local_name {
	name	array[int8, 248]
} [packed]

hci_cp_write_page_scan_activity {
	interval	int16
	window		int16
} [packed]

hci_cp_write_remote_amp_assoc {
	phy_handle	hci_phy_handle
	len_so_far	int16
	rem_len		int16
	frag		array[int8]
} [packed]

hci_cp_write_sc_support {
	support	int8
} [packed]

hci_cp_write_ssp_mode {
	mode	int8
} [packed]

hci_cp_write_sync_train_params {
	interval_min	int16
	interval_max	int16
	sync_train_tout	int32
	service_data	int8
} [packed]

hci_cp_write_voice_setting {
	voice_setting	int16
} [packed]

hci_event_hdr_un [
	HCI_EV_INQUIRY_COMPLETE			hci_event_hdr_t[HCI_EV_INQUIRY_COMPLETE, int8]
	extended_inquiry_info			hci_event_hdr_t[HCI_EV_EXTENDED_INQUIRY_RESULT, extended_inquiry_info_t]
	hci_ev_auth_complete			hci_event_hdr_t[HCI_EV_AUTH_COMPLETE, hci_ev_auth_complete]
	hci_ev_change_link_key_complete		hci_event_hdr_t[HCI_EV_CHANGE_LINK_KEY_COMPLETE, hci_ev_change_link_key_complete]
	hci_ev_channel_selected			hci_event_hdr_t[HCI_EV_CHANNEL_SELECTED, hci_ev_channel_selected]
	hci_ev_clock_offset			hci_event_hdr_t[HCI_EV_CLOCK_OFFSET, hci_ev_clock_offset]
	hci_ev_cmd_complete			hci_event_hdr_t[HCI_EV_CMD_COMPLETE, hci_ev_cmd_complete_un]
	hci_ev_cmd_status			hci_event_hdr_t[HCI_EV_CMD_STATUS, hci_ev_cmd_status]
	hci_ev_conn_complete			hci_event_hdr_t[HCI_EV_CONN_COMPLETE, hci_ev_conn_complete]
	hci_ev_conn_request			hci_event_hdr_t[HCI_EV_CONN_REQUEST, hci_ev_conn_request]
	hci_ev_disconn_complete			hci_event_hdr_t[HCI_EV_DISCONN_COMPLETE, hci_ev_disconn_complete]
	hci_ev_disconn_logical_link_complete	hci_event_hdr_t[HCI_EV_DISCONN_LOGICAL_LINK_COMPLETE, hci_ev_disconn_logical_link_complete]
	hci_ev_disconn_phy_link_complete	hci_event_hdr_t[HCI_EV_DISCONN_PHY_LINK_COMPLETE, hci_ev_disconn_phy_link_complete]
	hci_ev_encrypt_change			hci_event_hdr_t[HCI_EV_ENCRYPT_CHANGE, hci_ev_encrypt_change]
	hci_ev_hardware_error			hci_event_hdr_t[HCI_EV_HARDWARE_ERROR, hci_ev_hardware_error]
	hci_ev_io_capa_reply			hci_event_hdr_t[HCI_EV_IO_CAPA_REPLY, hci_ev_io_capa_reply]
	hci_ev_io_capa_request			hci_event_hdr_t[HCI_EV_IO_CAPA_REQUEST, hci_ev_io_capa_request]
	hci_ev_key_refresh_complete		hci_event_hdr_t[HCI_EV_KEY_REFRESH_COMPLETE, hci_ev_key_refresh_complete]
	hci_ev_keypress_notify			hci_event_hdr_t[HCI_EV_KEYPRESS_NOTIFY, hci_ev_keypress_notify]
	hci_ev_le_meta				hci_event_hdr_t[HCI_EV_LE_META, hci_ev_le_meta_un]
	hci_ev_link_key_notify			hci_event_hdr_t[HCI_EV_LINK_KEY_NOTIFY, hci_ev_link_key_notify]
	hci_ev_link_key_req			hci_event_hdr_t[HCI_EV_LINK_KEY_REQ, hci_ev_link_key_req]
	hci_ev_logical_link_complete		hci_event_hdr_t[HCI_EV_LOGICAL_LINK_COMPLETE, hci_ev_logical_link_complete]
	hci_ev_mode_change			hci_event_hdr_t[HCI_EV_MODE_CHANGE, hci_ev_mode_change]
	hci_ev_num_comp_blocks			hci_event_hdr_t[HCI_EV_NUM_COMP_BLOCKS, hci_ev_num_comp_blocks]
	hci_ev_num_comp_pkts			hci_event_hdr_t[HCI_EV_NUM_COMP_PKTS, hci_ev_num_comp_pkts]
	hci_ev_phy_link_complete		hci_event_hdr_t[HCI_EV_PHY_LINK_COMPLETE, hci_ev_phy_link_complete]
	hci_ev_pin_code_req			hci_event_hdr_t[HCI_EV_PIN_CODE_REQ, hci_ev_pin_code_req]
	hci_ev_pkt_type_change			hci_event_hdr_t[HCI_EV_PKT_TYPE_CHANGE, hci_ev_pkt_type_change]
	hci_ev_pscan_rep_mode			hci_event_hdr_t[HCI_EV_PSCAN_REP_MODE, hci_ev_pscan_rep_mode]
	hci_ev_qos_setup_complete		hci_event_hdr_t[HCI_EV_QOS_SETUP_COMPLETE, hci_ev_qos_setup_complete]
	hci_ev_remote_ext_features		hci_event_hdr_t[HCI_EV_REMOTE_EXT_FEATURES, hci_ev_remote_ext_features]
	hci_ev_remote_features			hci_event_hdr_t[HCI_EV_REMOTE_FEATURES, hci_ev_remote_features]
	hci_ev_remote_host_features		hci_event_hdr_t[HCI_EV_REMOTE_HOST_FEATURES, hci_ev_remote_host_features]
	hci_ev_remote_name			hci_event_hdr_t[HCI_EV_REMOTE_NAME, hci_ev_remote_name]
	hci_ev_remote_oob_data_request		hci_event_hdr_t[HCI_EV_REMOTE_OOB_DATA_REQUEST, hci_ev_remote_oob_data_request]
	hci_ev_remote_version			hci_event_hdr_t[HCI_EV_REMOTE_VERSION, hci_ev_remote_version]
	hci_ev_role_change			hci_event_hdr_t[HCI_EV_ROLE_CHANGE, hci_ev_role_change]
	hci_ev_si_device			hci_event_hdr_t[HCI_EV_SI_DEVICE, hci_ev_si_device]
	hci_ev_si_security			hci_event_hdr_t[HCI_EV_SI_SECURITY, hci_ev_si_security]
	hci_ev_simple_pair_complete		hci_event_hdr_t[HCI_EV_SIMPLE_PAIR_COMPLETE, hci_ev_simple_pair_complete]
	hci_ev_sniff_subrate			hci_event_hdr_t[HCI_EV_SNIFF_SUBRATE, hci_ev_sniff_subrate]
	hci_ev_stack_internal			hci_event_hdr_t[HCI_EV_STACK_INTERNAL, hci_ev_stack_internal]
	hci_ev_sync_conn_changed		hci_event_hdr_t[HCI_EV_SYNC_CONN_CHANGED, hci_ev_sync_conn_changed]
	hci_ev_sync_conn_complete		hci_event_hdr_t[HCI_EV_SYNC_CONN_COMPLETE, hci_ev_sync_conn_complete]
	hci_ev_sync_train_complete		hci_event_hdr_t[HCI_EV_SYNC_TRAIN_COMPLETE, hci_ev_sync_train_complete]
	hci_ev_user_confirm_req			hci_event_hdr_t[HCI_EV_USER_CONFIRM_REQUEST, hci_ev_user_confirm_req]
	hci_ev_user_passkey_notify		hci_event_hdr_t[HCI_EV_USER_PASSKEY_NOTIFY, hci_ev_user_passkey_notify]
	hci_ev_user_passkey_req			hci_event_hdr_t[HCI_EV_USER_PASSKEY_REQUEST, hci_ev_user_passkey_req]
	inquiry_info				hci_event_hdr_t[HCI_EV_INQUIRY_RESULT, inquiry_info_t]
	inquiry_info_with_rssi			hci_event_hdr_t[HCI_EV_INQUIRY_RESULT_WITH_RSSI, inquiry_info_with_rssi_t]
	inquiry_info_with_rssi_and_pscan_mode	hci_event_hdr_t[HCI_EV_INQUIRY_RESULT_WITH_RSSI, inquiry_info_with_rssi_and_pscan_mode_t]
	HCI_EV_VENDOR				hci_event_hdr_t[HCI_EV_VENDOR, array[int8]]
] [varlen]

type hci_event_hdr_t[EVENT, PAYLOAD] {
	hdr	hci_event_hdr[EVENT]
	payload	PAYLOAD
} [packed]

type hci_event_hdr[EVENT] {
	evt	const[EVENT, int8]
	plen	bytesize[hci_event_hdr_t:payload, int8]
} [packed]

hci_ev_le_meta_un [
	hci_ev_le_advertising_info	hci_ev_le_meta_t[HCI_EV_LE_ADVERTISING_REPORT, hci_ev_le_advertising_info_t]
	hci_ev_le_conn_complete		hci_ev_le_meta_t[HCI_EV_LE_CONN_COMPLETE, hci_ev_le_conn_complete]
	hci_ev_le_conn_update_complete	hci_ev_le_meta_t[HCI_EV_LE_CONN_UPDATE_COMPLETE, hci_ev_le_conn_update_complete]
	hci_ev_le_data_len_change	hci_ev_le_meta_t[HCI_EV_LE_DATA_LEN_CHANGE, hci_ev_le_data_len_change]
	hci_ev_le_direct_adv_info	hci_ev_le_meta_t[HCI_EV_LE_DIRECT_ADV_REPORT, hci_ev_le_direct_adv_info]
	hci_ev_le_enh_conn_complete	hci_ev_le_meta_t[HCI_EV_LE_ENHANCED_CONN_COMPLETE, hci_ev_le_enh_conn_complete]
	hci_ev_le_ext_adv_report	hci_ev_le_meta_t[HCI_EV_LE_EXT_ADV_REPORT, hci_ev_le_ext_adv_report]
	hci_ev_le_ltk_req		hci_ev_le_meta_t[HCI_EV_LE_LTK_REQ, hci_ev_le_ltk_req]
	hci_ev_le_phy_update_complete	hci_ev_le_meta_t[HCI_EV_LE_PHY_UPDATE_COMPLETE, hci_ev_le_phy_update_complete]
	hci_ev_le_remote_conn_param_req	hci_ev_le_meta_t[HCI_EV_LE_REMOTE_CONN_PARAM_REQ, hci_ev_le_remote_conn_param_req]
	hci_ev_le_remote_feat_complete	hci_ev_le_meta_t[HCI_EV_LE_REMOTE_FEAT_COMPLETE, hci_ev_le_remote_feat_complete]
	hci_evt_le_cis_established	hci_ev_le_meta_t[HCI_EVT_LE_CIS_ESTABLISHED, hci_evt_le_cis_established]
	hci_evt_le_ext_adv_set_term	hci_ev_le_meta_t[HCI_EV_LE_EXT_ADV_SET_TERM, hci_evt_le_ext_adv_set_term]
] [varlen]

type hci_ev_le_meta_t[SUBEVENT, PAYLOAD] {
	hdr	hci_ev_le_meta[SUBEVENT]
	payload	PAYLOAD
} [packed]

type hci_ev_le_meta[SUBEVENT] {
	subevent	const[SUBEVENT, int8]
} [packed]

hci_ev_cmd_complete_un [
	hci_rp_delete_reserved_lt_addr		hci_ev_cmd_complete_t[HCI_OP_DELETE_RESERVED_LT_ADDR, hci_rp_delete_reserved_lt_addr]
	hci_rp_delete_stored_link_key		hci_ev_cmd_complete_t[HCI_OP_DELETE_STORED_LINK_KEY, hci_rp_delete_stored_link_key]
	hci_rp_le_ltk_neg_reply			hci_ev_cmd_complete_t[HCI_OP_LE_LTK_NEG_REPLY, hci_rp_le_ltk_neg_reply]
	hci_rp_le_ltk_reply			hci_ev_cmd_complete_t[HCI_OP_LE_LTK_REPLY, hci_rp_le_ltk_reply]
	hci_rp_le_read_adv_tx_power		hci_ev_cmd_complete_t[HCI_OP_LE_READ_ADV_TX_POWER, hci_rp_le_read_adv_tx_power]
	hci_rp_le_read_buffer_size		hci_ev_cmd_complete_t[HCI_OP_LE_READ_BUFFER_SIZE, hci_rp_le_read_buffer_size]
	hci_rp_le_read_buffer_size_v2		hci_ev_cmd_complete_t[HCI_OP_LE_READ_BUFFER_SIZE_V2, hci_rp_le_read_buffer_size_v2]
	hci_rp_le_read_def_data_len		hci_ev_cmd_complete_t[HCI_OP_LE_READ_DEF_DATA_LEN, hci_rp_le_read_def_data_len]
	hci_rp_le_read_iso_tx_sync		hci_ev_cmd_complete_t[HCI_OP_LE_READ_ISO_TX_SYNC, hci_rp_le_read_iso_tx_sync]
	hci_rp_le_read_local_features		hci_ev_cmd_complete_t[HCI_OP_LE_READ_LOCAL_FEATURES, hci_rp_le_read_local_features]
	hci_rp_le_read_max_data_len		hci_ev_cmd_complete_t[HCI_OP_LE_READ_MAX_DATA_LEN, hci_rp_le_read_max_data_len]
	hci_rp_le_read_num_supported_adv_sets	hci_ev_cmd_complete_t[HCI_OP_LE_READ_NUM_SUPPORTED_ADV_SETS, hci_rp_le_read_num_supported_adv_sets]
	hci_rp_le_read_resolv_list_size		hci_ev_cmd_complete_t[HCI_OP_LE_READ_RESOLV_LIST_SIZE, hci_rp_le_read_resolv_list_size]
	hci_rp_le_read_supported_states		hci_ev_cmd_complete_t[HCI_OP_LE_READ_SUPPORTED_STATES, hci_rp_le_read_supported_states]
	hci_rp_le_read_accept_list_size		hci_ev_cmd_complete_t[HCI_OP_LE_READ_ACCEPT_LIST_SIZE, hci_rp_le_read_accept_list_size]
	hci_rp_le_set_cig_params		hci_ev_cmd_complete_t[HCI_OP_LE_SET_CIG_PARAMS, hci_rp_le_set_cig_params]
	hci_rp_le_set_data_len			hci_ev_cmd_complete_t[HCI_OP_LE_SET_DATA_LEN, hci_rp_le_set_data_len]
	hci_rp_le_set_ext_adv_params		hci_ev_cmd_complete_t[HCI_OP_LE_SET_EXT_ADV_PARAMS, hci_rp_le_set_ext_adv_params]
	hci_rp_logical_link_cancel		hci_ev_cmd_complete_t[HCI_OP_LOGICAL_LINK_CANCEL, hci_rp_logical_link_cancel]
	hci_rp_pin_code_neg_reply		hci_ev_cmd_complete_t[HCI_OP_PIN_CODE_NEG_REPLY, hci_rp_pin_code_neg_reply]
	hci_rp_pin_code_reply			hci_ev_cmd_complete_t[HCI_OP_PIN_CODE_REPLY, hci_rp_pin_code_reply]
	hci_rp_read_auth_payload_to		hci_ev_cmd_complete_t[HCI_OP_READ_AUTH_PAYLOAD_TO, hci_rp_read_auth_payload_to]
	hci_rp_read_bd_addr			hci_ev_cmd_complete_t[HCI_OP_READ_BD_ADDR, hci_rp_read_bd_addr]
	hci_rp_read_buffer_size			hci_ev_cmd_complete_t[HCI_OP_READ_BUFFER_SIZE, hci_rp_read_buffer_size]
	hci_rp_read_class_of_dev		hci_ev_cmd_complete_t[HCI_OP_READ_CLASS_OF_DEV, hci_rp_read_class_of_dev]
	hci_rp_read_clock			hci_ev_cmd_complete_t[HCI_OP_READ_CLOCK, hci_rp_read_clock]
	hci_rp_read_data_block_size		hci_ev_cmd_complete_t[HCI_OP_READ_DATA_BLOCK_SIZE, hci_rp_read_data_block_size]
	hci_rp_read_def_err_data_reporting	hci_ev_cmd_complete_t[HCI_OP_READ_DEF_ERR_DATA_REPORTING, hci_rp_read_def_err_data_reporting]
	hci_rp_read_def_link_policy		hci_ev_cmd_complete_t[HCI_OP_READ_DEF_LINK_POLICY, hci_rp_read_def_link_policy]
	hci_rp_read_enc_key_size		hci_ev_cmd_complete_t[HCI_OP_READ_ENC_KEY_SIZE, hci_rp_read_enc_key_size]
	hci_rp_read_flow_control_mode		hci_ev_cmd_complete_t[HCI_OP_READ_FLOW_CONTROL_MODE, hci_rp_read_flow_control_mode]
	hci_rp_read_inq_rsp_tx_power		hci_ev_cmd_complete_t[HCI_OP_READ_INQ_RSP_TX_POWER, hci_rp_read_inq_rsp_tx_power]
	hci_rp_read_link_policy			hci_ev_cmd_complete_t[HCI_OP_READ_LINK_POLICY, hci_rp_read_link_policy]
	hci_rp_read_local_amp_assoc		hci_ev_cmd_complete_t[HCI_OP_READ_LOCAL_AMP_ASSOC, hci_rp_read_local_amp_assoc]
	hci_rp_read_local_amp_info		hci_ev_cmd_complete_t[HCI_OP_READ_LOCAL_AMP_INFO, hci_rp_read_local_amp_info]
	hci_rp_read_local_commands		hci_ev_cmd_complete_t[HCI_OP_READ_LOCAL_COMMANDS, hci_rp_read_local_commands]
	hci_rp_read_local_ext_features		hci_ev_cmd_complete_t[HCI_OP_READ_LOCAL_EXT_FEATURES, hci_rp_read_local_ext_features]
	hci_rp_read_local_features		hci_ev_cmd_complete_t[HCI_OP_READ_LOCAL_FEATURES, hci_rp_read_local_features]
	hci_rp_read_local_name			hci_ev_cmd_complete_t[HCI_OP_READ_LOCAL_NAME, hci_rp_read_local_name]
	hci_rp_read_local_oob_data		hci_ev_cmd_complete_t[HCI_OP_READ_LOCAL_OOB_DATA, hci_rp_read_local_oob_data]
	hci_rp_read_local_oob_ext_data		hci_ev_cmd_complete_t[HCI_OP_READ_LOCAL_OOB_EXT_DATA, hci_rp_read_local_oob_ext_data]
	hci_rp_read_local_pairing_opts		hci_ev_cmd_complete_t[HCI_OP_READ_LOCAL_PAIRING_OPTS, hci_rp_read_local_pairing_opts]
	hci_rp_read_local_version		hci_ev_cmd_complete_t[HCI_OP_READ_LOCAL_VERSION, hci_rp_read_local_version]
	hci_rp_read_num_supported_iac		hci_ev_cmd_complete_t[HCI_OP_READ_NUM_SUPPORTED_IAC, hci_rp_read_num_supported_iac]
	hci_rp_read_page_scan_activity		hci_ev_cmd_complete_t[HCI_OP_READ_PAGE_SCAN_ACTIVITY, hci_rp_read_page_scan_activity]
	hci_rp_read_page_scan_type		hci_ev_cmd_complete_t[HCI_OP_READ_PAGE_SCAN_TYPE, hci_rp_read_page_scan_type]
	hci_rp_read_rssi			hci_ev_cmd_complete_t[HCI_OP_READ_RSSI, hci_rp_read_rssi]
	hci_rp_read_sc_support			hci_ev_cmd_complete_t[HCI_OP_READ_SC_SUPPORT, hci_rp_read_sc_support]
	hci_rp_read_ssp_mode			hci_ev_cmd_complete_t[HCI_OP_READ_SSP_MODE, hci_rp_read_ssp_mode]
	hci_rp_read_stored_link_key		hci_ev_cmd_complete_t[HCI_OP_READ_STORED_LINK_KEY, hci_rp_read_stored_link_key]
	hci_rp_read_tx_power			hci_ev_cmd_complete_t[HCI_OP_READ_TX_POWER, hci_rp_read_tx_power]
	hci_rp_read_voice_setting		hci_ev_cmd_complete_t[HCI_OP_READ_VOICE_SETTING, hci_rp_read_voice_setting]
	hci_rp_role_discovery			hci_ev_cmd_complete_t[HCI_OP_ROLE_DISCOVERY, hci_rp_role_discovery]
	hci_rp_set_cpb				hci_ev_cmd_complete_t[HCI_OP_SET_CPB, hci_rp_set_cpb]
	hci_rp_set_cpb_data			hci_ev_cmd_complete_t[HCI_OP_SET_CPB_DATA, hci_rp_set_cpb_data]
	hci_rp_set_reserved_lt_addr		hci_ev_cmd_complete_t[HCI_OP_SET_RESERVED_LT_ADDR, hci_rp_set_reserved_lt_addr]
	hci_rp_user_confirm_reply		hci_ev_cmd_complete_t[HCI_OP_USER_CONFIRM_REPLY, hci_rp_user_confirm_reply]
	hci_rp_write_auth_payload_to		hci_ev_cmd_complete_t[HCI_OP_WRITE_AUTH_PAYLOAD_TO, hci_rp_write_auth_payload_to]
	hci_rp_write_link_policy		hci_ev_cmd_complete_t[HCI_OP_WRITE_LINK_POLICY, hci_rp_write_link_policy]
	hci_rp_write_remote_amp_assoc		hci_ev_cmd_complete_t[HCI_OP_WRITE_REMOTE_AMP_ASSOC, hci_rp_write_remote_amp_assoc]
	hci_rp_write_sync_train_params		hci_ev_cmd_complete_t[HCI_OP_WRITE_SYNC_TRAIN_PARAMS, hci_rp_write_sync_train_params]
	HCI_OP_INQUIRY_CANCEL			hci_ev_cmd_complete_t[HCI_OP_INQUIRY_CANCEL, int8]
	HCI_OP_PERIODIC_INQ			hci_ev_cmd_complete_t[HCI_OP_PERIODIC_INQ, int8]
	HCI_OP_EXIT_PERIODIC_INQ		hci_ev_cmd_complete_t[HCI_OP_EXIT_PERIODIC_INQ, int8]
# Unused:
# HCI_OP_REMOTE_NAME_REQ_CANCEL		hci_ev_cmd_complete_t[HCI_OP_REMOTE_NAME_REQ_CANCEL, int8]
	HCI_OP_WRITE_DEF_LINK_POLICY		hci_ev_cmd_complete_t[HCI_OP_WRITE_DEF_LINK_POLICY, int8]
	HCI_OP_RESET				hci_ev_cmd_complete_t[HCI_OP_RESET, int8]
	HCI_OP_WRITE_LOCAL_NAME			hci_ev_cmd_complete_t[HCI_OP_WRITE_LOCAL_NAME, int8]
	HCI_OP_WRITE_AUTH_ENABLE		hci_ev_cmd_complete_t[HCI_OP_WRITE_AUTH_ENABLE, int8]
	HCI_OP_WRITE_ENCRYPT_MODE		hci_ev_cmd_complete_t[HCI_OP_WRITE_ENCRYPT_MODE, int8]
	HCI_OP_WRITE_SCAN_ENABLE		hci_ev_cmd_complete_t[HCI_OP_WRITE_SCAN_ENABLE, int8]
	HCI_OP_WRITE_CLASS_OF_DEV		hci_ev_cmd_complete_t[HCI_OP_WRITE_CLASS_OF_DEV, int8]
	HCI_OP_WRITE_VOICE_SETTING		hci_ev_cmd_complete_t[HCI_OP_WRITE_VOICE_SETTING, int8]
	HCI_OP_WRITE_SSP_MODE			hci_ev_cmd_complete_t[HCI_OP_WRITE_SSP_MODE, int8]
	HCI_OP_WRITE_SC_SUPPORT			hci_ev_cmd_complete_t[HCI_OP_WRITE_SC_SUPPORT, int8]
	HCI_OP_WRITE_PAGE_SCAN_ACTIVITY		hci_ev_cmd_complete_t[HCI_OP_WRITE_PAGE_SCAN_ACTIVITY, int8]
	HCI_OP_WRITE_PAGE_SCAN_TYPE		hci_ev_cmd_complete_t[HCI_OP_WRITE_PAGE_SCAN_TYPE, int8]
	HCI_OP_WRITE_DEF_ERR_DATA_REPORTING	hci_ev_cmd_complete_t[HCI_OP_WRITE_DEF_ERR_DATA_REPORTING, int8]
	HCI_OP_USER_CONFIRM_NEG_REPLY		hci_ev_cmd_complete_t[HCI_OP_USER_CONFIRM_NEG_REPLY, int8]
	HCI_OP_USER_PASSKEY_REPLY		hci_ev_cmd_complete_t[HCI_OP_USER_PASSKEY_REPLY, int8]
	HCI_OP_USER_PASSKEY_NEG_REPLY		hci_ev_cmd_complete_t[HCI_OP_USER_PASSKEY_NEG_REPLY, int8]
	HCI_OP_LE_SET_RANDOM_ADDR		hci_ev_cmd_complete_t[HCI_OP_LE_SET_RANDOM_ADDR, int8]
	HCI_OP_LE_SET_ADV_ENABLE		hci_ev_cmd_complete_t[HCI_OP_LE_SET_ADV_ENABLE, int8]
	HCI_OP_LE_SET_SCAN_PARAM		hci_ev_cmd_complete_t[HCI_OP_LE_SET_SCAN_PARAM, int8]
	HCI_OP_LE_SET_SCAN_ENABLE		hci_ev_cmd_complete_t[HCI_OP_LE_SET_SCAN_ENABLE, int8]
	HCI_OP_LE_CLEAR_ACCEPT_LIST		hci_ev_cmd_complete_t[HCI_OP_LE_CLEAR_ACCEPT_LIST, int8]
	HCI_OP_LE_ADD_TO_ACCEPT_LIST		hci_ev_cmd_complete_t[HCI_OP_LE_ADD_TO_ACCEPT_LIST, int8]
	HCI_OP_LE_DEL_FROM_ACCEPT_LIST		hci_ev_cmd_complete_t[HCI_OP_LE_DEL_FROM_ACCEPT_LIST, int8]
	HCI_OP_LE_WRITE_DEF_DATA_LEN		hci_ev_cmd_complete_t[HCI_OP_LE_WRITE_DEF_DATA_LEN, int8]
	HCI_OP_LE_ADD_TO_RESOLV_LIST		hci_ev_cmd_complete_t[HCI_OP_LE_ADD_TO_RESOLV_LIST, int8]
	HCI_OP_LE_DEL_FROM_RESOLV_LIST		hci_ev_cmd_complete_t[HCI_OP_LE_DEL_FROM_RESOLV_LIST, int8]
	HCI_OP_LE_CLEAR_RESOLV_LIST		hci_ev_cmd_complete_t[HCI_OP_LE_CLEAR_RESOLV_LIST, int8]
	HCI_OP_LE_SET_ADDR_RESOLV_ENABLE	hci_ev_cmd_complete_t[HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, int8]
	HCI_OP_WRITE_LE_HOST_SUPPORTED		hci_ev_cmd_complete_t[HCI_OP_WRITE_LE_HOST_SUPPORTED, int8]
	HCI_OP_LE_SET_ADV_PARAM			hci_ev_cmd_complete_t[HCI_OP_LE_SET_ADV_PARAM, int8]
	HCI_OP_WRITE_SSP_DEBUG_MODE		hci_ev_cmd_complete_t[HCI_OP_WRITE_SSP_DEBUG_MODE, int8]
	HCI_OP_LE_SET_EXT_SCAN_PARAMS		hci_ev_cmd_complete_t[HCI_OP_LE_SET_EXT_SCAN_PARAMS, int8]
	HCI_OP_LE_SET_EXT_SCAN_ENABLE		hci_ev_cmd_complete_t[HCI_OP_LE_SET_EXT_SCAN_ENABLE, int8]
	HCI_OP_LE_SET_DEFAULT_PHY		hci_ev_cmd_complete_t[HCI_OP_LE_SET_DEFAULT_PHY, int8]
	HCI_OP_LE_SET_EXT_ADV_ENABLE		hci_ev_cmd_complete_t[HCI_OP_LE_SET_EXT_ADV_ENABLE, int8]
	HCI_OP_LE_SET_ADV_SET_RAND_ADDR		hci_ev_cmd_complete_t[HCI_OP_LE_SET_ADV_SET_RAND_ADDR, int8]
	HCI_OP_NOP				hci_ev_cmd_complete_t[HCI_OP_NOP, int8]
] [varlen]

type hci_ev_cmd_complete_t[OPCODE, PAYLOAD] {
	hdr	hci_ev_cmd_complete[OPCODE]
	payload	PAYLOAD
} [packed]

type hci_ev_cmd_complete[OPCODE] {
	ncmd	int8
	opcode	const[OPCODE, int16]
} [packed]

link_types = SCO_LINK, ACL_LINK, ESCO_LINK
bdaddr_types = ADDR_LE_DEV_PUBLIC, ADDR_LE_DEV_RANDOM

extended_inquiry_info_t {
	num_rsp	len[rsps, int8]
	rsps	array[extended_inquiry_info]
} [packed]

extended_inquiry_info {
	bdaddr			bdaddr_t
	pscan_rep_mode		int8
	pscan_period_mode	int8
	dev_class		array[int8, 3]
	clock_offset		int16
	rssi			int8
	data			array[int8, 240]
} [packed]

hci_comp_blocks_info {
	handle	hci_conn_handle
	pkts	int16
	blocks	int16
} [packed]

hci_comp_pkts_info {
	handle	hci_conn_handle
	count	int16
} [packed]

hci_ev_auth_complete {
	status	int8
	handle	hci_conn_handle
} [packed]

hci_ev_change_link_key_complete {
	status	int8
	handle	hci_conn_handle
} [packed]

hci_ev_channel_selected {
	phy_handle	hci_phy_handle
} [packed]

hci_ev_clock_offset {
	status		int8
	handle		hci_conn_handle
	clock_offset	int16
} [packed]

hci_ev_cmd_status_opcodes = HCI_OP_NOP, HCI_OP_INQUIRY, HCI_OP_CREATE_CONN, HCI_OP_DISCONNECT, HCI_OP_ADD_SCO, HCI_OP_AUTH_REQUESTED, HCI_OP_SET_CONN_ENCRYPT, HCI_OP_REMOTE_NAME_REQ, HCI_OP_READ_REMOTE_FEATURES, HCI_OP_READ_REMOTE_EXT_FEATURES, HCI_OP_SETUP_SYNC_CONN, HCI_OP_SNIFF_MODE, HCI_OP_EXIT_SNIFF_MODE, HCI_OP_SWITCH_ROLE, HCI_OP_LE_CREATE_CONN, HCI_OP_LE_READ_REMOTE_FEATURES, HCI_OP_LE_START_ENC, HCI_OP_LE_EXT_CREATE_CONN

hci_ev_cmd_status {
	status	int8
	ncmd	bool8
	opcode	flags[hci_ev_cmd_status_opcodes, int16]
} [packed]

hci_ev_conn_complete {
	status		int8
	handle		hci_conn_handle
	bdaddr		bdaddr_t
	link_type	flags[link_types, int8]
	encr_mode	int8
} [packed]

hci_ev_conn_request {
	bdaddr		bdaddr_t
	dev_class	array[int8, 3]
	link_type	flags[link_types, int8]
} [packed]

hci_ev_disconn_complete {
	status	int8
	handle	hci_conn_handle
	reason	int8
} [packed]

hci_ev_disconn_logical_link_complete {
	status	int8
	handle	hci_conn_handle
	reason	int8
} [packed]

hci_ev_disconn_phy_link_complete {
	status		int8
	phy_handle	hci_phy_handle
	reason		int8
} [packed]

hci_ev_encrypt_change {
	status	int8
	handle	hci_conn_handle
	encrypt	int8
} [packed]

hci_ev_hardware_error {
	code	int8
} [packed]

hci_ev_io_capa_reply {
	bdaddr		bdaddr_t
	capability	int8
	oob_data	int8
	authentication	int8
} [packed]

hci_ev_io_capa_request {
	bdaddr	bdaddr_t
} [packed]

hci_ev_key_refresh_complete {
	status	int8
	handle	hci_conn_handle
} [packed]

hci_ev_keypress_notify {
	bdaddr	bdaddr_t
	type	int8
} [packed]

hci_ev_le_advertising_info_t {
	num_reports	len[reports, int8]
	reports		array[hci_ev_le_advertising_info]
} [packed]

hci_ev_le_advertising_info {
	evt_type	flags[hci_adv_evt_type, int8]
	bdaddr_type	flags[bdaddr_types, int8]
	bdaddr		bdaddr_t
	length		bytesize[data, int8]
	data		array[int8, 0:HCI_MAX_AD_LENGTH]
	rssi		int8
} [packed]

hci_adv_evt_type = LE_ADV_IND, LE_ADV_DIRECT_IND, LE_ADV_SCAN_IND, LE_ADV_NONCONN_IND, LE_ADV_SCAN_RSP

hci_ev_le_conn_complete {
	status			int8
	handle			hci_conn_handle
	role			int8
	bdaddr_type		flags[bdaddr_types, int8]
	bdaddr			bdaddr_t
	interval		int16
	latency			int16
	supervision_timeout	int16
	clk_accurancy		int8
} [packed]

hci_ev_le_conn_update_complete {
	status			const[0, int8]
	handle			hci_conn_handle
	interval		int16
	latency			int16
	supervision_timeout	int16
} [packed]

hci_ev_le_data_len_change {
	handle	hci_conn_handle
	tx_len	int16
	tx_time	int16
	rx_len	int16
	rx_time	int16
} [packed]

hci_ev_le_direct_adv_info {
	evt_type		int8
	bdaddr_type		flags[bdaddr_types, int8]
	bdaddr			bdaddr_t
	direct_addr_type	int8
	direct_addr		bdaddr_t
	rssi			int8
} [packed]

hci_ev_le_enh_conn_complete {
	status			int8
	handle			hci_conn_handle
	role			int8
	bdaddr_type		flags[bdaddr_types, int8]
	bdaddr			bdaddr_t
	local_rpa		bdaddr_t
	peer_rpa		bdaddr_t
	interval		int16
	latency			int16
	supervision_timeout	int16
	clk_accurancy		int8
} [packed]

hci_ev_le_ext_adv_report {
	num	len[info, int8]
	info	array[hci_ev_le_ext_adv_info]
} [packed]

hci_ev_le_ext_adv_info {
	type			flags[hci_legacy_adv_evt_type, int16]
	bdaddr_type		flags[bdaddr_types, int8]
	bdaddr			bdaddr_t
	primary_phy		int8
	secondary_phy		int8
	sid			int8
	tx_power		int8
	rssi			int8
	interval		int16
	direct_addr_type	int8
	direct_addr		bdaddr_t
	length			bytesize[data, int8]
	data			array[int8]
} [packed]

hci_legacy_adv_evt_type = LE_LEGACY_ADV_IND, LE_LEGACY_ADV_DIRECT_IND, LE_LEGACY_ADV_SCAN_IND, LE_LEGACY_NONCONN_IND, LE_LEGACY_SCAN_RSP_ADV, LE_LEGACY_SCAN_RSP_ADV_SCAN, LE_EXT_ADV_NON_CONN_IND, LE_EXT_ADV_CONN_IND, LE_EXT_ADV_SCAN_IND, LE_EXT_ADV_DIRECT_IND, LE_EXT_ADV_SCAN_RSP, LE_EXT_ADV_LEGACY_PDU

hci_ev_le_ltk_req {
	handle	hci_conn_handle
	rand	int64
	ediv	int16
} [packed]

hci_ev_le_phy_update_complete {
	status	int8
	handle	hci_conn_handle
	tx_phy	int8
	rx_phy	int8
} [packed]

hci_ev_le_remote_conn_param_req {
	handle		hci_conn_handle
	interval_min	int16
	interval_max	int16
	latency		int16
	timeout		int16
} [packed]

hci_ev_le_remote_feat_complete {
	status		int8
	handle		hci_conn_handle
	features	array[int8, 8]
} [packed]

hci_ev_link_key_notify {
	bdaddr		bdaddr_t
	link_key	array[int8, 16]
	key_type	int8
} [packed]

hci_ev_link_key_req {
	bdaddr	bdaddr_t
} [packed]

hci_ev_logical_link_complete {
	status		int8
	handle		hci_conn_handle
	phy_handle	hci_phy_handle
	flow_spec_id	int8
} [packed]

hci_ev_mode_change {
	status		int8
	handle		hci_conn_handle
	mode		int8
	interval	int16
} [packed]

hci_ev_num_comp_blocks {
	num_blocks	int16
	num_hndl	len[handles, int8]
	handles		array[hci_comp_blocks_info]
} [packed]

hci_ev_num_comp_pkts {
	num_hndl	len[handles, int8]
	handles		array[hci_comp_pkts_info]
} [packed]

hci_ev_phy_link_complete {
	status		int8
	phy_handle	hci_phy_handle
} [packed]

hci_ev_pin_code_req {
	bdaddr	bdaddr_t
} [packed]

hci_ev_pkt_type_change {
	status		int8
	handle		hci_conn_handle
	pkt_type	int16
} [packed]

hci_ev_pscan_rep_mode {
	bdaddr		bdaddr_t
	pscan_rep_mode	int8
} [packed]

hci_ev_qos_setup_complete {
	status	int8
	handle	hci_conn_handle
	qos	hci_qos
} [packed]

hci_ev_remote_ext_features {
	status		int8
	handle		hci_conn_handle
	page		int8
	max_page	int8
	features	array[int8, 8]
} [packed]

hci_ev_remote_features {
	status		int8
	handle		hci_conn_handle
	features	array[int8, 8]
} [packed]

hci_ev_remote_host_features {
	bdaddr		bdaddr_t
	features	array[int8, 8]
} [packed]

hci_ev_remote_name {
	status	int8
	bdaddr	bdaddr_t
	name	array[int8, 248]
} [packed]

hci_ev_remote_oob_data_request {
	bdaddr	bdaddr_t
} [packed]

hci_ev_remote_version {
	status		int8
	handle		hci_conn_handle
	lmp_ver		int8
	manufacturer	int16
	lmp_subver	int16
} [packed]

hci_ev_role_change {
	status	int8
	bdaddr	bdaddr_t
	role	int8
} [packed]

hci_ev_si_device {
	event	int16
	dev_id	int16
} [packed]

hci_ev_si_security {
	event		int16
	proto		int16
	subproto	int16
	incoming	int8
} [packed]

hci_ev_simple_pair_complete {
	status	int8
	bdaddr	bdaddr_t
} [packed]

hci_ev_sniff_subrate {
	status			int8
	handle			hci_conn_handle
	max_tx_latency		int16
	max_rx_latency		int16
	max_remote_timeout	int16
	max_local_timeout	int16
} [packed]

hci_ev_stack_internal {
	type	int16
	data	array[int8]
} [packed]

hci_ev_sync_conn_changed {
	status		int8
	handle		hci_conn_handle
	tx_interval	int8
	retrans_window	int8
	rx_pkt_len	int16
	tx_pkt_len	int16
} [packed]

hci_ev_sync_conn_complete {
	status		int8
	handle		hci_conn_handle
	bdaddr		bdaddr_t
	link_type	flags[link_types, int8]
	tx_interval	int8
	retrans_window	int8
	rx_pkt_len	int16
	tx_pkt_len	int16
	air_mode	int8
} [packed]

hci_ev_sync_train_complete {
	status	int8
} [packed]

hci_ev_user_confirm_req {
	bdaddr	bdaddr_t
	passkey	int32
} [packed]

hci_ev_user_passkey_notify {
	bdaddr	bdaddr_t
	passkey	int32
} [packed]

hci_ev_user_passkey_req {
	bdaddr	bdaddr_t
} [packed]

hci_evt_le_cis_established {
	status		int8
	handle		hci_conn_handle
	cig_sync_delay	array[int8, 3]
	cis_sync_delay	array[int8, 3]
	m_latency	array[int8, 3]
	s_latency	array[int8, 3]
	m_phy		int8
	s_phy		int8
	nse		int8
	m_bn		int8
	s_bn		int8
	m_ft		int8
	s_ft		int8
	m_mtu		int16
	s_mtu		int16
	interval	int16
} [packed]

hci_evt_le_ext_adv_set_term {
	status		const[0, int8]
# This does not seem to be used.
	handle		const[0, int8]
	conn_handle	hci_conn_handle
	num_evts	int8
} [packed]

hci_rp_delete_reserved_lt_addr {
	status	int8
	lt_addr	int8
} [packed]

hci_rp_delete_stored_link_key {
	status		int8
	num_keys	int16
} [packed]

hci_rp_le_ltk_neg_reply {
	status	int8
	handle	hci_conn_handle
} [packed]

hci_rp_le_ltk_reply {
	status	int8
	handle	hci_conn_handle
} [packed]

hci_rp_le_read_adv_tx_power {
	status		int8
	tx_power	int8
} [packed]

hci_rp_le_read_buffer_size {
	status		int8
	le_mtu		int16
	le_max_pkt	int8
} [packed]

hci_rp_le_read_buffer_size_v2 {
	status		int8
	acl_mtu		int16
	acl_max_pkt	int8
	iso_mtu		int16
	iso_max_pkt	int8
} [packed]

hci_rp_le_read_def_data_len {
	status	int8
	tx_len	int16
	tx_time	int16
} [packed]

hci_rp_le_read_iso_tx_sync {
	status		int8
	handle		hci_conn_handle
	seq		int16
	imestamp	int32
	offset		array[int8, 3]
} [packed]

hci_rp_le_read_local_features {
	status		int8
	features	array[int8, 8]
} [packed]

hci_rp_le_read_max_data_len {
	status	int8
	tx_len	int16
	tx_time	int16
	rx_len	int16
	rx_time	int16
} [packed]

hci_rp_le_read_num_supported_adv_sets {
	status		int8
	num_of_sets	int8
} [packed]

hci_rp_le_read_resolv_list_size {
	status	int8
	size	int8
} [packed]

hci_rp_le_read_supported_states {
	status		int8
	le_states	array[int8, 8]
} [packed]

hci_rp_le_read_accept_list_size {
	status	int8
	size	int8
} [packed]

hci_rp_le_set_cig_params {
	status		int8
	cig_id		int8
	num_handles	len[handle, int8]
	handle		array[hci_conn_handle]
} [packed]

hci_rp_le_set_data_len {
	status	int8
	handle	hci_conn_handle
} [packed]

hci_rp_le_set_ext_adv_params {
	status		int8
	tx_power	int8
} [packed]

hci_rp_logical_link_cancel {
	status		int8
	phy_handle	hci_phy_handle
	flow_spec_id	int8
} [packed]

hci_rp_pin_code_neg_reply {
	status	int8
	bdaddr	bdaddr_t
} [packed]

hci_rp_pin_code_reply {
	status	int8
	bdaddr	bdaddr_t
} [packed]

hci_rp_read_auth_payload_to {
	status	int8
	handle	hci_conn_handle
	timeout	int16
} [packed]

hci_rp_read_bd_addr {
	status	int8
	bdaddr	bdaddr_t
} [packed]

hci_rp_read_buffer_size {
	status		int8
	acl_mtu		int16
	sco_mtu		int8
	acl_max_pkt	int16
	sco_max_pkt	int16
} [packed]

hci_rp_read_class_of_dev {
	status		int8
	dev_class	array[int8, 3]
} [packed]

hci_rp_read_clock {
	status		int8
	handle		hci_conn_handle
	clock		int32
	accuracy	int16
} [packed]

hci_rp_read_data_block_size {
	status		int8
	max_acl_len	int16
	block_len	int16
	num_blocks	int16
} [packed]

hci_rp_read_def_err_data_reporting {
	status			int8
	err_data_reporting	int8
} [packed]

hci_rp_read_def_link_policy {
	status	int8
	policy	int16
} [packed]

hci_rp_read_enc_key_size {
	status		int8
	handle		hci_conn_handle
	key_size	int8
} [packed]

hci_rp_read_flow_control_mode {
	status	int8
	mode	int8
} [packed]

hci_rp_read_inq_rsp_tx_power {
	status		int8
	tx_power	int8
} [packed]

hci_rp_read_link_policy {
	status	int8
	handle	hci_conn_handle
	policy	int16
} [packed]

hci_rp_read_local_amp_assoc {
	status		int8
	phy_handle	hci_phy_handle
	rem_len		int16
	frag		array[int8]
} [packed]

hci_rp_read_local_amp_info {
	status		int8
	amp_status	int8
	total_bw	int32
	max_bw		int32
	min_latency	int32
	max_pdu		int32
	amp_type	int8
	pal_cap		int16
	max_assoc_size	int16
	max_flush_to	int32
	be_flush_to	int32
} [packed]

hci_rp_read_local_commands {
	status		int8
	commands	array[int8, 64]
} [packed]

hci_rp_read_local_ext_features {
	status		int8
	page		int8
	max_page	int8
	features	array[int8, 8]
} [packed]

hci_rp_read_local_features {
	status		int8
	features	array[int8, 8]
} [packed]

hci_rp_read_local_name {
	status	int8
	name	array[int8, 248]
} [packed]

hci_rp_read_local_oob_data {
	status	int8
	hash	array[int8, 16]
	rand	array[int8, 16]
} [packed]

hci_rp_read_local_oob_ext_data {
	status	int8
	hash192	array[int8, 16]
	rand192	array[int8, 16]
	hash256	array[int8, 16]
	rand256	array[int8, 16]
} [packed]

hci_rp_read_local_pairing_opts {
	status		int8
	pairing_opts	int8
	max_key_size	int8
} [packed]

hci_rp_read_local_version {
	status		int8
	hci_ver		int8
	hci_rev		int16
	lmp_ver		int8
	manufacturer	int16
	lmp_subver	int16
} [packed]

hci_rp_read_num_supported_iac {
	status	int8
	num_iac	int8
} [packed]

hci_rp_read_page_scan_activity {
	status		int8
	interval	int16
	window		int16
} [packed]

hci_rp_read_page_scan_type {
	status	int8
	type	int8
} [packed]

hci_rp_read_rssi {
	status	int8
	handle	hci_conn_handle
	rssi	int8
} [packed]

hci_rp_read_sc_support {
	status	int8
	support	int8
} [packed]

hci_rp_read_ssp_mode {
	status	int8
	mode	int8
} [packed]

hci_rp_read_stored_link_key {
	status		int8
	max_keys	int16
	num_keys	int16
} [packed]

hci_rp_read_tx_power {
	status		int8
	handle		hci_conn_handle
	tx_power	int8
} [packed]

hci_rp_read_voice_setting {
	status		int8
	voice_setting	int16
} [packed]

hci_rp_role_discovery {
	status	int8
	handle	hci_conn_handle
	role	int8
} [packed]

hci_rp_set_cpb {
	status		int8
	lt_addr		int8
	interval	int16
} [packed]

hci_rp_set_cpb_data {
	status	int8
	lt_addr	int8
} [packed]

hci_rp_set_reserved_lt_addr {
	status	int8
	lt_addr	int8
} [packed]

hci_rp_user_confirm_reply {
	status	int8
	bdaddr	bdaddr_t
} [packed]

hci_rp_write_auth_payload_to {
	status	int8
	handle	hci_conn_handle
} [packed]

hci_rp_write_link_policy {
	status	int8
	handle	hci_conn_handle
} [packed]

hci_rp_write_remote_amp_assoc {
	status		int8
	phy_handle	hci_phy_handle
} [packed]

hci_rp_write_sync_train_params {
	status		int8
	sync_train_int	int16
} [packed]

hci_qos {
	service_type	int8
	token_rate	int32
	peak_bandwidth	int32
	latency		int32
	delay_variation	int32
} [packed]

inquiry_info_t {
	num_rsp	len[rsps, int8]
	rsps	array[inquiry_info]
} [packed]

inquiry_info {
	bdaddr			bdaddr_t
	pscan_rep_mode		int8
	pscan_period_mode	int8
	pscan_mode		int8
	dev_class		array[int8, 3]
	clock_offset		int16
} [packed]

inquiry_info_with_rssi_t {
	num_rsp	len[rsps, int8]
	rsps	array[inquiry_info_with_rssi]
} [packed]

inquiry_info_with_rssi {
	bdaddr			bdaddr_t
	pscan_rep_mode		int8
	pscan_period_mode	int8
	dev_class		array[int8, 3]
	clock_offset		int16
	rssi			int8
} [packed]

inquiry_info_with_rssi_and_pscan_mode_t {
	num_rsp	len[rsps, int8]
	rsps	array[inquiry_info_with_rssi_and_pscan_mode]
} [packed]

inquiry_info_with_rssi_and_pscan_mode {
	bdaddr			bdaddr_t
	pscan_rep_mode		int8
	pscan_period_mode	int8
	pscan_mode		int8
	dev_class		array[int8, 3]
	clock_offset		int16
	rssi			int8
} [packed]