1little_endian_packets
2
3
4enum Enum7 : 7 {
5    A = 1,
6    B = 2,
7}
8
9enum Enum16 : 16 {
10    A = 0xaabb,
11    B = 0xccdd,
12}
13
14struct SizedStruct {
15    a: 8,
16}
17
18struct UnsizedStruct {
19    _size_(array): 2,
20    _reserved_: 6,
21    array: 8[],
22}
23
24packet ScalarParent {
25    a: 8,
26    _size_(_payload_): 8,
27    _payload_
28}
29
30packet EnumParent {
31    a: Enum16,
32    _size_(_payload_): 8,
33    _payload_
34}
35
36packet EmptyParent : ScalarParent {
37    _payload_
38}
39
40packet PartialParent5 {
41    a: 5,
42    _payload_
43}
44
45packet PartialParent12 {
46    a: 12,
47    _payload_
48}
49
50// Packet bit fields
51
52// The parser must be able to handle bit fields with scalar values
53// up to 64 bits wide.  The parser should generate a static size guard.
54packet Packet_Scalar_Field {
55    a: 7,
56    c: 57,
57}
58
59// The parser must be able to handle bit fields with enum values
60// up to 64 bits wide.  The parser should generate a static size guard.
61packet Packet_Enum_Field {
62    a: Enum7,
63    c: 57,
64}
65
66// The parser must be able to handle bit fields with reserved fields
67// up to 64 bits wide.  The parser should generate a static size guard.
68packet Packet_Reserved_Field {
69    a: 7,
70    _reserved_: 2,
71    c: 55,
72}
73
74// The parser must be able to handle bit fields with size fields
75// up to 64 bits wide.  The parser should generate a static size guard.
76packet Packet_Size_Field {
77    _size_(b): 3,
78    a: 61,
79    b: 8[],
80}
81
82// The parser must be able to handle bit fields with count fields
83// up to 64 bits wide.  The parser should generate a static size guard.
84packet Packet_Count_Field {
85    _count_(b): 3,
86    a: 61,
87    b: 8[],
88}
89
90// The parser must be able to handle bit fields with fixed scalar values
91// up to 64 bits wide.  The parser should generate a static size guard.
92packet Packet_FixedScalar_Field {
93    _fixed_ = 7 : 7,
94    b: 57,
95}
96
97// The parser must be able to handle bit fields with fixed enum values
98// up to 64 bits wide. The parser should generate a static size guard.
99packet Packet_FixedEnum_Field {
100    _fixed_ = A : Enum7,
101    b: 57,
102}
103
104// Packet payload fields
105
106// The parser must be able to handle sized payload fields without
107// size modifier.
108packet Packet_Payload_Field_VariableSize {
109    _size_(_payload_): 3,
110    _reserved_: 5,
111    _payload_
112}
113
114// The parser must be able to handle payload fields of unkonwn size followed
115// by fields of statically known size. The remaining span is integrated
116// in the packet.
117packet Packet_Payload_Field_UnknownSize {
118    _payload_,
119    a: 16,
120}
121
122// The parser must be able to handle payload fields of unkonwn size.
123// The remaining span is integrated in the packet.
124packet Packet_Payload_Field_UnknownSize_Terminal {
125    a: 16,
126    _payload_,
127}
128
129// Packet body fields
130
131// The parser must be able to handle sized body fields without
132// size modifier when the packet has no children.
133packet Packet_Body_Field_VariableSize {
134    _size_(_body_): 3,
135    _reserved_: 5,
136    _body_
137}
138
139// The parser must be able to handle body fields of unkonwn size followed
140// by fields of statically known size. The remaining span is integrated
141// in the packet.
142packet Packet_Body_Field_UnknownSize {
143    _body_,
144    a: 16,
145}
146
147// The parser must be able to handle body fields of unkonwn size.
148// The remaining span is integrated in the packet.
149packet Packet_Body_Field_UnknownSize_Terminal {
150    a: 16,
151    _payload_,
152}
153
154// Packet typedef fields
155
156// The parser must be able to handle struct fields.
157// The size guard is generated by the Struct parser.
158packet Packet_Struct_Field {
159    a: SizedStruct,
160    b: UnsizedStruct,
161}
162
163// Array field configurations.
164// Add constructs for all configurations of type, size, and padding:
165//
166// - type: u8, u16, enum, struct with static size, struct with dynamic size
167// - size: constant, with size field, with count field, unspecified
168//
169// The type u8 is tested separately since it is likely to be handled
170// idiomatically by the specific language generators.
171
172packet Packet_Array_Field_ByteElement_ConstantSize {
173    array: 8[4],
174}
175
176packet Packet_Array_Field_ByteElement_VariableSize {
177    _size_(array) : 4,
178    _reserved_: 4,
179    array: 8[],
180}
181
182packet Packet_Array_Field_ByteElement_VariableCount {
183    _count_(array) : 4,
184    _reserved_: 4,
185    array: 8[],
186}
187
188packet Packet_Array_Field_ByteElement_UnknownSize {
189    array: 8[],
190}
191
192packet Packet_Array_Field_ScalarElement_ConstantSize {
193    array: 16[4],
194}
195
196packet Packet_Array_Field_ScalarElement_VariableSize {
197    _size_(array) : 4,
198    _reserved_: 4,
199    array: 16[],
200}
201
202packet Packet_Array_Field_ScalarElement_VariableCount {
203    _count_(array) : 4,
204    _reserved_: 4,
205    array: 16[],
206}
207
208packet Packet_Array_Field_ScalarElement_UnknownSize {
209    array: 16[],
210}
211
212packet Packet_Array_Field_EnumElement_ConstantSize {
213    array: Enum16[4],
214}
215
216packet Packet_Array_Field_EnumElement_VariableSize {
217    _size_(array) : 4,
218    _reserved_: 4,
219    array: Enum16[],
220}
221
222packet Packet_Array_Field_EnumElement_VariableCount {
223    _count_(array) : 4,
224    _reserved_: 4,
225    array: Enum16[],
226}
227
228packet Packet_Array_Field_EnumElement_UnknownSize {
229    array: Enum16[],
230}
231
232packet Packet_Array_Field_SizedElement_ConstantSize {
233    array: SizedStruct[4],
234}
235
236packet Packet_Array_Field_SizedElement_VariableSize {
237    _size_(array) : 4,
238    _reserved_: 4,
239    array: SizedStruct[],
240}
241
242packet Packet_Array_Field_SizedElement_VariableCount {
243    _count_(array) : 4,
244    _reserved_: 4,
245    array: SizedStruct[],
246}
247
248packet Packet_Array_Field_SizedElement_UnknownSize {
249    array: SizedStruct[],
250}
251
252packet Packet_Array_Field_UnsizedElement_ConstantSize {
253    array: UnsizedStruct[4],
254}
255
256packet Packet_Array_Field_UnsizedElement_VariableSize {
257    _size_(array) : 4,
258    _reserved_: 4,
259    array: UnsizedStruct[],
260}
261
262packet Packet_Array_Field_UnsizedElement_VariableCount {
263    _count_(array) : 4,
264    _reserved_: 4,
265    array: UnsizedStruct[],
266}
267
268packet Packet_Array_Field_UnsizedElement_UnknownSize {
269    array: UnsizedStruct[],
270}
271
272// The parser must be able to handle arrays with padded size.
273packet Packet_Array_Field_SizedElement_VariableSize_Padded {
274    _size_(array) : 4,
275    _reserved_: 4,
276    array: 16[],
277    _padding_ [16],
278}
279
280// The parser must be able to handle arrays with padded size.
281packet Packet_Array_Field_UnsizedElement_VariableCount_Padded {
282    _count_(array) : 8,
283    array: UnsizedStruct[],
284    _padding_ [16],
285}
286
287// Packet inheritance
288
289// The parser must handle specialization into
290// any child packet of a parent packet with scalar constraints.
291packet ScalarChild_A : ScalarParent (a = 0) {
292    b: 8,
293}
294
295// The parser must handle specialization into
296// any child packet of a parent packet with scalar constraints.
297packet ScalarChild_B : ScalarParent (a = 1) {
298    c: 16,
299}
300
301// The parser must handle specialization into
302// any child packet of a parent packet with enum constraints.
303packet EnumChild_A : EnumParent (a = A) {
304    b: 8,
305}
306
307// The parser must handle specialization into
308// any child packet of a parent packet with enum constraints.
309packet EnumChild_B : EnumParent (a = B) {
310    c: 16,
311}
312
313// The parser must handle inheritance of packets with payloads starting
314// on a shifted byte boundary, as long as the first fields of the child
315// complete the bit fields.
316packet PartialChild5_A : PartialParent5 (a = 0) {
317    b: 11,
318}
319
320// The parser must handle inheritance of packets with payloads starting
321// on a shifted byte boundary, as long as the first fields of the child
322// complete the bit fields.
323packet PartialChild5_B : PartialParent5 (a = 1) {
324    c: 27,
325}
326
327// The parser must handle inheritance of packets with payloads starting
328// on a shifted byte boundary, as long as the first fields of the child
329// complete the bit fields.
330packet PartialChild12_A : PartialParent12 (a = 2) {
331    d: 4,
332}
333
334// The parser must handle inheritance of packets with payloads starting
335// on a shifted byte boundary, as long as the first fields of the child
336// complete the bit fields.
337packet PartialChild12_B : PartialParent12 (a = 3) {
338    e: 20,
339}
340
341// Struct bit fields
342
343// The parser must be able to handle bit fields with scalar values
344// up to 64 bits wide.  The parser should generate a static size guard.
345struct Struct_Scalar_Field {
346    a: 7,
347    c: 57,
348}
349
350// The parser must be able to handle bit fields with enum values
351// up to 64 bits wide.  The parser should generate a static size guard.
352struct Struct_Enum_Field_ {
353    a: Enum7,
354    c: 57,
355}
356packet Struct_Enum_Field {
357    s: Struct_Enum_Field_,
358}
359
360// The parser must be able to handle bit fields with reserved fields
361// up to 64 bits wide.  The parser should generate a static size guard.
362struct Struct_Reserved_Field_ {
363    a: 7,
364    _reserved_: 2,
365    c: 55,
366}
367packet Struct_Reserved_Field {
368    s: Struct_Reserved_Field_,
369}
370
371// The parser must be able to handle bit fields with size fields
372// up to 64 bits wide.  The parser should generate a static size guard.
373struct Struct_Size_Field_ {
374    _size_(b): 3,
375    a: 61,
376    b: 8[],
377}
378packet Struct_Size_Field {
379    s: Struct_Size_Field_,
380}
381
382// The parser must be able to handle bit fields with count fields
383// up to 64 bits wide.  The parser should generate a static size guard.
384struct Struct_Count_Field_ {
385    _count_(b): 3,
386    a: 61,
387    b: 8[],
388}
389packet Struct_Count_Field {
390    s: Struct_Count_Field_,
391}
392
393// The parser must be able to handle bit fields with fixed scalar values
394// up to 64 bits wide.  The parser should generate a static size guard.
395struct Struct_FixedScalar_Field_ {
396    _fixed_ = 7 : 7,
397    b: 57,
398}
399packet Struct_FixedScalar_Field {
400    s: Struct_FixedScalar_Field_,
401}
402
403// The parser must be able to handle bit fields with fixed enum values
404// up to 64 bits wide. The parser should generate a static size guard.
405struct Struct_FixedEnum_Field_ {
406    _fixed_ = A : Enum7,
407    b: 57,
408}
409packet Struct_FixedEnum_Field {
410    s: Struct_FixedEnum_Field_,
411}
412
413// Struct typedef fields
414
415// The parser must be able to handle struct fields.
416// The size guard is generated by the Struct parser.
417packet Struct_Struct_Field {
418    a: SizedStruct,
419    b: UnsizedStruct,
420}
421
422// Array field configurations.
423// Add constructs for all configurations of type, size, and padding:
424//
425// - type: u8, u16, enum, struct with static size, struct with dynamic size
426// - size: constant, with size field, with count field, unspecified
427//
428// The type u8 is tested separately since it is likely to be handled
429// idiomatically by the specific language generators.
430
431struct Struct_Array_Field_ByteElement_ConstantSize_ {
432    array: 8[4],
433}
434packet Struct_Array_Field_ByteElement_ConstantSize {
435    s: Struct_Array_Field_ByteElement_ConstantSize_,
436}
437
438struct Struct_Array_Field_ByteElement_VariableSize_ {
439    _size_(array) : 4,
440    _reserved_: 4,
441    array: 8[],
442}
443packet Struct_Array_Field_ByteElement_VariableSize {
444    s: Struct_Array_Field_ByteElement_VariableSize_,
445}
446
447struct Struct_Array_Field_ByteElement_VariableCount_ {
448    _count_(array) : 4,
449    _reserved_: 4,
450    array: 8[],
451}
452packet Struct_Array_Field_ByteElement_VariableCount {
453    s: Struct_Array_Field_ByteElement_VariableCount_,
454}
455
456struct Struct_Array_Field_ByteElement_UnknownSize_ {
457    array: 8[],
458}
459packet Struct_Array_Field_ByteElement_UnknownSize {
460    s: Struct_Array_Field_ByteElement_UnknownSize_,
461}
462
463struct Struct_Array_Field_ScalarElement_ConstantSize_ {
464    array: 16[4],
465}
466packet Struct_Array_Field_ScalarElement_ConstantSize {
467    s: Struct_Array_Field_ScalarElement_ConstantSize_,
468}
469
470struct Struct_Array_Field_ScalarElement_VariableSize_ {
471    _size_(array) : 4,
472    _reserved_: 4,
473    array: 16[],
474}
475packet Struct_Array_Field_ScalarElement_VariableSize {
476    s: Struct_Array_Field_ScalarElement_VariableSize_,
477}
478
479struct Struct_Array_Field_ScalarElement_VariableCount_ {
480    _count_(array) : 4,
481    _reserved_: 4,
482    array: 16[],
483}
484packet Struct_Array_Field_ScalarElement_VariableCount {
485    s: Struct_Array_Field_ScalarElement_VariableCount_,
486}
487
488struct Struct_Array_Field_ScalarElement_UnknownSize_ {
489    array: 16[],
490}
491packet Struct_Array_Field_ScalarElement_UnknownSize {
492    s: Struct_Array_Field_ScalarElement_UnknownSize_,
493}
494
495struct Struct_Array_Field_EnumElement_ConstantSize_ {
496    array: Enum16[4],
497}
498packet Struct_Array_Field_EnumElement_ConstantSize {
499    s: Struct_Array_Field_EnumElement_ConstantSize_,
500}
501
502struct Struct_Array_Field_EnumElement_VariableSize_ {
503    _size_(array) : 4,
504    _reserved_: 4,
505    array: Enum16[],
506}
507packet Struct_Array_Field_EnumElement_VariableSize {
508    s: Struct_Array_Field_EnumElement_VariableSize_,
509}
510
511struct Struct_Array_Field_EnumElement_VariableCount_ {
512    _count_(array) : 4,
513    _reserved_: 4,
514    array: Enum16[],
515}
516packet Struct_Array_Field_EnumElement_VariableCount {
517    s: Struct_Array_Field_EnumElement_VariableCount_,
518}
519
520struct Struct_Array_Field_EnumElement_UnknownSize_ {
521    array: Enum16[],
522}
523packet Struct_Array_Field_EnumElement_UnknownSize {
524    s: Struct_Array_Field_EnumElement_UnknownSize_,
525}
526
527struct Struct_Array_Field_SizedElement_ConstantSize_ {
528    array: SizedStruct[4],
529}
530packet Struct_Array_Field_SizedElement_ConstantSize {
531    s: Struct_Array_Field_SizedElement_ConstantSize_,
532}
533
534struct Struct_Array_Field_SizedElement_VariableSize_ {
535    _size_(array) : 4,
536    _reserved_: 4,
537    array: SizedStruct[],
538}
539packet Struct_Array_Field_SizedElement_VariableSize {
540    s: Struct_Array_Field_SizedElement_VariableSize_,
541}
542
543struct Struct_Array_Field_SizedElement_VariableCount_ {
544    _count_(array) : 4,
545    _reserved_: 4,
546    array: SizedStruct[],
547}
548packet Struct_Array_Field_SizedElement_VariableCount {
549    s: Struct_Array_Field_SizedElement_VariableCount_,
550}
551
552struct Struct_Array_Field_SizedElement_UnknownSize_ {
553    array: SizedStruct[],
554}
555packet Struct_Array_Field_SizedElement_UnknownSize {
556    s: Struct_Array_Field_SizedElement_UnknownSize_,
557}
558
559struct Struct_Array_Field_UnsizedElement_ConstantSize_ {
560    array: UnsizedStruct[4],
561}
562packet Struct_Array_Field_UnsizedElement_ConstantSize {
563    s: Struct_Array_Field_UnsizedElement_ConstantSize_,
564}
565
566struct Struct_Array_Field_UnsizedElement_VariableSize_ {
567    _size_(array) : 4,
568    _reserved_: 4,
569    array: UnsizedStruct[],
570}
571packet Struct_Array_Field_UnsizedElement_VariableSize {
572    s: Struct_Array_Field_UnsizedElement_VariableSize_,
573}
574
575struct Struct_Array_Field_UnsizedElement_VariableCount_ {
576    _count_(array) : 4,
577    _reserved_: 4,
578    array: UnsizedStruct[],
579}
580packet Struct_Array_Field_UnsizedElement_VariableCount {
581    s: Struct_Array_Field_UnsizedElement_VariableCount_,
582}
583
584struct Struct_Array_Field_UnsizedElement_UnknownSize_ {
585    array: UnsizedStruct[],
586}
587packet Struct_Array_Field_UnsizedElement_UnknownSize {
588    s: Struct_Array_Field_UnsizedElement_UnknownSize_,
589}
590
591// The parser must be able to handle arrays with padded size.
592struct Struct_Array_Field_SizedElement_VariableSize_Padded_ {
593    _size_(array) : 4,
594    _reserved_: 4,
595    array: 16[],
596    _padding_ [16],
597}
598packet Struct_Array_Field_SizedElement_VariableSize_Padded {
599    s: Struct_Array_Field_SizedElement_VariableSize_Padded_,
600}
601
602// The parser must be able to handle arrays with padded size.
603struct Struct_Array_Field_UnsizedElement_VariableCount_Padded_ {
604    _count_(array) : 8,
605    array: UnsizedStruct[],
606    _padding_ [16],
607}
608packet Struct_Array_Field_UnsizedElement_VariableCount_Padded {
609    s: Struct_Array_Field_UnsizedElement_VariableCount_Padded_,
610}
611