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