1little_endian_packets
2
3custom_field Address : 48 "hci/"
4custom_field ClassOfDevice : 24 "hci/"
5
6enum PacketType : 8 {
7    UNKNOWN = 0x00,
8    ACL = 0x01,
9    DISCONNECT = 0x02,
10    ENCRYPT_CONNECTION = 0x03,
11    ENCRYPT_CONNECTION_RESPONSE = 0x04,
12    EVENT = 0x05,
13    INQUIRY = 0x06,
14    INQUIRY_RESPONSE = 0x07,
15    IO_CAPABILITY_REQUEST = 0x08,
16    IO_CAPABILITY_RESPONSE = 0x09,
17    IO_CAPABILITY_NEGATIVE_RESPONSE = 0x0A,
18    LE_ADVERTISEMENT = 0x0B,
19    LE_CONNECT = 0x0C,
20    LE_CONNECT_COMPLETE = 0x0D,
21    LE_SCAN = 0x0E,
22    LE_SCAN_RESPONSE = 0x0F,
23    PAGE = 0x10,
24    PAGE_RESPONSE = 0x11,
25    PAGE_REJECT = 0x12,
26    READ_CLOCK_OFFSET = 0x13,
27    READ_CLOCK_OFFSET_RESPONSE = 0x14,
28    READ_REMOTE_SUPPORTED_FEATURES = 0x15,
29    READ_REMOTE_SUPPORTED_FEATURES_RESPONSE = 0x16,
30    READ_REMOTE_LMP_FEATURES = 0x17,
31    READ_REMOTE_LMP_FEATURES_RESPONSE = 0x18,
32    READ_REMOTE_EXTENDED_FEATURES = 0x19,
33    READ_REMOTE_EXTENDED_FEATURES_RESPONSE = 0x1A,
34    READ_REMOTE_VERSION_INFORMATION = 0x1B,
35    READ_REMOTE_VERSION_INFORMATION_RESPONSE = 0x1C,
36    REMOTE_NAME_REQUEST = 0x1D,
37    REMOTE_NAME_REQUEST_RESPONSE = 0x1E,
38    SCO = 0x1F,
39    LE_ENCRYPT_CONNECTION = 0x20,
40    LE_ENCRYPT_CONNECTION_RESPONSE = 0x21,
41    ISO = 0x22,
42    ISO_CONNECTION_REQUEST = 0x23,
43    ISO_CONNECTION_RESPONSE = 0x24,
44    OOB_DATA = 0x25,
45    OOB_DATA_RESPONSE = 0x26,
46    PASSKEY = 0x27,
47    PASSKEY_FAILED = 0x28,
48    KEYPRESS_NOTIFICATION = 0x29,
49    PIN_REQUEST = 0x2A,
50    PIN_RESPONSE = 0x2B,
51    LE_READ_REMOTE_FEATURES = 0x2C,
52    LE_READ_REMOTE_FEATURES_RESPONSE = 0x2D,
53}
54
55packet LinkLayerPacket {
56  type : PacketType,
57  source_address : Address,
58  destination_address : Address,
59  _body_,
60}
61
62packet Acl : LinkLayerPacket (type = ACL) {
63  _payload_,
64}
65
66packet Disconnect : LinkLayerPacket (type = DISCONNECT) {
67  reason : 8,
68}
69
70packet EncryptConnection : LinkLayerPacket (type = ENCRYPT_CONNECTION) {
71  key : 8[],
72}
73
74packet EncryptConnectionResponse : LinkLayerPacket (type = ENCRYPT_CONNECTION_RESPONSE) {
75  key : 8[],
76}
77
78enum InquiryState : 8 {
79  STANDBY = 0x00,
80  INQUIRY = 0x01,
81}
82
83enum InquiryType : 8 {
84  STANDARD = 0x00,
85  RSSI = 0x01,
86  EXTENDED = 0x02,
87}
88
89packet Inquiry : LinkLayerPacket (type = INQUIRY) {
90  inquiry_type : InquiryType,
91}
92
93packet BasicInquiryResponse : LinkLayerPacket(type = INQUIRY_RESPONSE) {
94  inquiry_type : InquiryType,
95  page_scan_repetition_mode : 8,
96  class_of_device : ClassOfDevice,
97  clock_offset : 15,
98  _reserved_ : 1,
99  _body_,
100}
101
102packet InquiryResponse : BasicInquiryResponse (inquiry_type = STANDARD) {
103}
104
105packet InquiryResponseWithRssi : BasicInquiryResponse (inquiry_type = RSSI)  {
106  rssi: 8,
107}
108
109packet ExtendedInquiryResponse : BasicInquiryResponse (inquiry_type = EXTENDED)  {
110  rssi: 8,
111  extended_data : 8[],
112}
113
114packet IoCapabilityRequest : LinkLayerPacket (type = IO_CAPABILITY_REQUEST) {
115  io_capability : 8,
116  oob_data_present : 8,
117  authentication_requirements : 8,
118}
119
120packet IoCapabilityResponse : LinkLayerPacket (type = IO_CAPABILITY_RESPONSE) {
121  io_capability : 8,
122  oob_data_present : 8,
123  authentication_requirements : 8,
124}
125
126packet IoCapabilityNegativeResponse : LinkLayerPacket (type = IO_CAPABILITY_NEGATIVE_RESPONSE) {
127  reason : 8,
128}
129
130enum AddressType : 8 {
131  PUBLIC = 0,
132  RANDOM = 1,
133  PUBLIC_IDENTITY = 2,
134  RANDOM_IDENTITY = 3,
135}
136
137enum AdvertisementType : 8 {
138    ADV_IND = 0,          // Connectable and scannable
139    ADV_DIRECT_IND = 1,   // Connectable directed
140    ADV_SCAN_IND = 2,     // Scannable undirected
141    ADV_NONCONN_IND = 3,  // Non connectable undirected
142    SCAN_RESPONSE = 4,
143}
144
145packet LeAdvertisement : LinkLayerPacket (type = LE_ADVERTISEMENT) {
146  address_type : AddressType,
147  advertisement_type : AdvertisementType,
148  data : 8[],
149}
150
151packet LeConnect : LinkLayerPacket (type = LE_CONNECT) {
152  le_connection_interval_min : 16,
153  le_connection_interval_max : 16,
154  le_connection_latency : 16,
155  le_connection_supervision_timeout : 16,
156  address_type : 8,
157}
158
159packet LeConnectComplete : LinkLayerPacket (type = LE_CONNECT_COMPLETE) {
160  le_connection_interval : 16,
161  le_connection_latency : 16,
162  le_connection_supervision_timeout : 16,
163  address_type : 8,
164}
165
166packet LeScan : LinkLayerPacket (type = LE_SCAN) {
167}
168
169packet LeScanResponse : LinkLayerPacket (type = LE_SCAN_RESPONSE) {
170  address_type : AddressType,
171  advertisement_type : AdvertisementType,
172  data : 8[],
173}
174
175packet Page : LinkLayerPacket (type = PAGE) {
176  class_of_device : ClassOfDevice,
177  allow_role_switch : 8,
178}
179
180packet PageResponse : LinkLayerPacket (type = PAGE_RESPONSE) {
181  try_role_switch : 8,
182}
183
184packet PageReject : LinkLayerPacket (type = PAGE_REJECT) {
185  reason : 8,
186}
187
188packet ReadClockOffset : LinkLayerPacket (type = READ_CLOCK_OFFSET) {
189}
190
191packet ReadClockOffsetResponse : LinkLayerPacket (type = READ_CLOCK_OFFSET_RESPONSE) {
192  offset : 16,
193}
194
195packet ReadRemoteSupportedFeatures : LinkLayerPacket (type = READ_REMOTE_SUPPORTED_FEATURES) {
196}
197
198packet ReadRemoteSupportedFeaturesResponse : LinkLayerPacket (type = READ_REMOTE_SUPPORTED_FEATURES_RESPONSE) {
199  features : 64,
200}
201
202packet ReadRemoteLmpFeatures : LinkLayerPacket (type = READ_REMOTE_LMP_FEATURES) {
203}
204
205packet ReadRemoteLmpFeaturesResponse : LinkLayerPacket (type = READ_REMOTE_LMP_FEATURES_RESPONSE) {
206  features : 64,
207}
208
209packet ReadRemoteExtendedFeatures : LinkLayerPacket (type = READ_REMOTE_EXTENDED_FEATURES) {
210  page_number : 8,
211}
212
213packet ReadRemoteExtendedFeaturesResponse : LinkLayerPacket (type = READ_REMOTE_EXTENDED_FEATURES_RESPONSE) {
214  status : 8,
215  page_number : 8,
216  max_page_number : 8,
217  features : 64,
218}
219
220packet ReadRemoteVersionInformation : LinkLayerPacket (type = READ_REMOTE_VERSION_INFORMATION) {
221}
222
223packet ReadRemoteVersionInformationResponse : LinkLayerPacket (type = READ_REMOTE_VERSION_INFORMATION_RESPONSE) {
224  lmp_version : 8,
225  lmp_subversion : 8,
226  manufacturer_name : 16,
227}
228
229packet RemoteNameRequest : LinkLayerPacket (type = REMOTE_NAME_REQUEST) {
230}
231
232packet RemoteNameRequestResponse : LinkLayerPacket (type = REMOTE_NAME_REQUEST_RESPONSE) {
233  name : 8[248],
234}
235
236packet ScoPacket : LinkLayerPacket (type = SCO) {
237  _payload_,
238}
239
240packet LeEncryptConnection : LinkLayerPacket (type = LE_ENCRYPT_CONNECTION) {
241  rand : 8[8],
242  ediv : 16,
243  ltk : 8[16],
244}
245
246packet LeEncryptConnectionResponse : LinkLayerPacket (type = LE_ENCRYPT_CONNECTION_RESPONSE) {
247  rand : 8[8],
248  ediv : 16,
249  ltk : 8[16],
250}
251
252enum StartContinuation : 1 {
253  START = 0,
254  CONTINUATION = 1,
255}
256
257enum Complete : 1 {
258  INCOMPLETE = 0,
259  COMPLETE = 1,
260}
261
262packet IsoDataPacket : LinkLayerPacket (type = ISO) {
263  handle : 12,
264  _reserved_ : 4,
265  sc : StartContinuation,
266  cmplt : Complete,
267  _reserved_ : 6,
268  _size_(_payload_) : 16,
269  _payload_,
270}
271
272packet IsoStart : IsoDataPacket (sc = START) {
273  time_offset : 24,
274  _payload_,
275}
276
277packet IsoContinuation : IsoDataPacket (sc = CONTINUATION) {
278  _payload_,
279}
280
281packet IsoConnectionRequest : LinkLayerPacket (type = ISO_CONNECTION_REQUEST) {
282  // Group
283  cig_id : 8,
284  sdu_interval_m_to_s : 32,
285  sdu_interval_s_to_m : 32,
286  interleaved : 1,
287  framed : 1,
288  _reserved_ : 6,
289  latency_m_to_s : 16,
290  latency_s_to_m : 16,
291  // Stream parameters
292  id : 8,
293  max_sdu_m_to_s_ : 16,
294  max_sdu_s_to_m_ : 16,
295  // For the response
296  requester_cis_handle : 12,
297  _reserved_ : 4,
298  requester_acl_handle : 12,
299  _reserved_ : 4,
300}
301
302packet IsoConnectionResponse  : LinkLayerPacket (type = ISO_CONNECTION_RESPONSE){
303  status : 8, // ErrorCode (SUCCESS == connected)
304  requester_cis_handle : 12,
305  _reserved_ : 4,
306  requester_acl_handle : 12,
307  _reserved_ : 4,
308  // For the link layer
309  responder_cis_handle : 12,
310  _reserved_ : 4,
311}
312
313packet OobData : LinkLayerPacket (type = OOB_DATA){
314  c_p_194 : 8[16],
315  r_p_194 : 8[16],
316  c_p_256 : 8[16],
317  r_p_256 : 8[16],
318}
319
320packet OobDataResponse : LinkLayerPacket (type = OOB_DATA_RESPONSE){
321  matched : 1,
322  _reserved_ : 7,
323}
324
325enum PasskeyNotificationType : 8 {
326  ENTRY_STARTED = 0x00,
327  DIGIT_ENTERED = 0x01,
328  DIGIT_ERASED = 0x02,
329  CLEARED = 0x03,
330  ENTRY_COMPLETED = 0x04,
331}
332
333packet Passkey : LinkLayerPacket (type = PASSKEY){
334  passkey : 20,
335  _reserved_ : 4,
336}
337
338packet PasskeyFailed : LinkLayerPacket (type = PASSKEY_FAILED){
339}
340
341packet KeypressNotification : LinkLayerPacket (type = KEYPRESS_NOTIFICATION){
342  notification_type : PasskeyNotificationType,
343}
344
345packet PinRequest : LinkLayerPacket (type = PIN_REQUEST) {
346  _size_(pin_code) : 5, // 0x01 - 0x10
347  _reserved_ : 3,
348  pin_code : 8[], // string parameter, first octet first
349}
350
351packet PinResponse : LinkLayerPacket (type = PIN_RESPONSE) {
352  _size_(pin_code) : 5, // 0x01 - 0x10
353  _reserved_ : 3,
354  pin_code : 8[], // string parameter, first octet first
355}
356
357packet LeReadRemoteFeatures : LinkLayerPacket (type = LE_READ_REMOTE_FEATURES) {
358}
359
360packet LeReadRemoteFeaturesResponse : LinkLayerPacket (type = LE_READ_REMOTE_FEATURES_RESPONSE) {
361  features : 64,
362  status : 8,
363}
364