1little_endian_packets 2 3custom_field SixBytes : 48 "packet/parser/test/" 4custom_field Variable "packet/parser/test/" 5 6packet Parent { 7 _fixed_ = 0x12 : 8, 8 _size_(_payload_) : 8, 9 _payload_, 10 footer : 8, 11} 12 13packet Child : Parent { 14 field_name : 16, 15} 16 17enum FourBits : 4 { 18 ONE = 1, 19 TWO = 2, 20 THREE = 3, 21 FIVE = 5, 22 TEN = 10, 23 LAZY_ME = 15, 24} 25 26packet ParentTwo { 27 _reserved_ : 4, 28 four_bits : FourBits, 29 _payload_, 30} 31 32packet ChildTwoThree : ParentTwo (four_bits = THREE) { 33 more_bits : FourBits, 34 _reserved_ : 4, 35 sixteen_bits : 16 36} 37 38packet ChildTwoTwo : ParentTwo (four_bits = TWO) { 39 more_bits : FourBits, 40 _reserved_ : 4, 41} 42 43packet ChildTwoTwoThree :ChildTwoTwo (more_bits = THREE) { 44} 45 46enum TwoBits : 2 { 47 ZERO = 0, 48 ONE = 1, 49 TWO = 2, 50 THREE = 3, 51} 52 53packet MiddleFourBits { 54 low_two : TwoBits, 55 next_four : FourBits, 56 straddle : FourBits, 57 four_more : FourBits, 58 high_two : TwoBits, 59} 60 61packet ParentWithSixBytes { 62 two_bytes : 16, 63 six_bytes : SixBytes, 64 _payload_, 65} 66 67packet ChildWithSixBytes : ParentWithSixBytes (two_bytes = 0x1234) { 68 child_six_bytes : SixBytes, 69} 70 71checksum SimpleSum : 16 "packet/parser/test/" 72 73packet ParentWithSum { 74 two_bytes : 16, 75 _checksum_start_(example_checksum), 76 sum_bytes : 16, 77 _payload_, 78 example_checksum : SimpleSum, 79} 80 81packet ChildWithSum : ParentWithSum { 82 more_bytes : 32, 83 another_byte : 8, 84} 85 86packet ChildWithNestedSum : ParentWithSum { 87 _checksum_start_(nested_checksum), 88 more_bytes : 32, 89 nested_checksum : SimpleSum, 90} 91 92packet ParentSizeModifier { 93 _size_(_payload_) : 8, 94 _payload_ : [+2*8], // Include two_bytes in the size 95 two_bytes : 16, 96} 97 98packet ChildSizeModifier : ParentSizeModifier (two_bytes = 0x1211) { 99 more_bytes : 32, 100} 101 102packet FieldsEndWithNumbers { 103 field_1 : 16, 104 field_2 : 16, 105 field_10 : 16, 106 field_11 : 16, 107} 108 109enum ForArrays : 16 { 110 ONE = 0x0001, 111 TWO = 0x0002, 112 ONE_TWO = 0x0201, 113 TWO_THREE = 0x0302, 114 FFFF = 0xffff, 115} 116 117packet FixedArrayEnum { 118 enum_array : ForArrays[5], 119} 120 121packet SizedArrayEnum { 122 _size_(enum_array) : 16, 123 enum_array : ForArrays[], 124} 125 126packet CountArrayEnum { 127 _count_(enum_array) : 8, 128 enum_array : ForArrays[], 129} 130 131packet SizedArrayCustom { 132 _size_(six_bytes_array) : 8, 133 an_extra_byte : 8, 134 six_bytes_array : SixBytes[+1*8], 135} 136 137packet FixedArrayCustom { 138 six_bytes_array : SixBytes[5], 139} 140 141packet CountArrayCustom { 142 _count_(six_bytes_array) : 8, 143 six_bytes_array : SixBytes[], 144} 145 146packet PacketWithFixedArraysOfBytes { 147 fixed_256bit_in_bytes : 8[32], 148 fixed_256bit_in_words : 32[8], 149} 150 151packet OneVariable { 152 one : Variable, 153} 154 155packet SizedArrayVariable { 156 _size_(variable_array) : 8, 157 variable_array : Variable[], 158} 159 160packet FixedArrayVariable { 161 variable_array : Variable[5], 162} 163 164packet CountArrayVariable { 165 _count_(variable_array) : 8, 166 variable_array : Variable[], 167} 168 169struct TwoRelatedNumbers { 170 id : 8, 171 count : 16, 172} 173 174packet OneStruct { 175 one : TwoRelatedNumbers, 176} 177 178packet TwoStructs { 179 one : TwoRelatedNumbers, 180 two : TwoRelatedNumbers, 181} 182 183packet VectorOfStruct { 184 _count_(array) : 8, 185 array : TwoRelatedNumbers[], 186} 187 188packet ArrayOfStruct { 189 the_count : 8, 190 array : TwoRelatedNumbers[4], 191} 192 193struct StructWithFixedTypes { 194 four_bits : FourBits, 195 _reserved_ : 4, 196 _checksum_start_(example_checksum), 197 _fixed_ = 0xf3 : 8, 198 id : 8, 199 array : 8[3], 200 example_checksum : SimpleSum, 201 six_bytes : SixBytes, 202} 203 204packet OneFixedTypesStruct { 205 one : StructWithFixedTypes, 206} 207 208packet ArrayOfStructAndAnother { 209 _count_(array) : 8, 210 array : TwoRelatedNumbers[], 211 another : TwoRelatedNumbers, 212} 213 214packet SizedArrayOfStructAndAnother { 215 _size_(array) : 8, 216 array : TwoRelatedNumbers[], 217 another : TwoRelatedNumbers, 218} 219 220struct ArrayOfStructAndAnotherStruct { 221 _count_(array) : 8, 222 array : TwoRelatedNumbers[], 223 another : TwoRelatedNumbers, 224} 225 226struct SizedArrayOfStructAndAnotherStruct { 227 _size_(array) : 8, 228 array : TwoRelatedNumbers[], 229 another : TwoRelatedNumbers, 230} 231 232packet OneArrayOfStructAndAnotherStruct { 233 one : ArrayOfStructAndAnotherStruct, 234} 235 236packet OneSizedArrayOfStructAndAnotherStruct { 237 one : SizedArrayOfStructAndAnotherStruct, 238} 239 240group BitFieldGroup { 241 seven_bits : 7, 242 straddle : 4, 243 five_bits : 5, 244} 245 246packet BitFieldGroupPacket { 247 BitFieldGroup, 248} 249 250packet BitFieldGroupAfterPayloadPacket { 251 _payload_, 252 BitFieldGroup, 253} 254 255packet BitFieldGroupAfterUnsizedArrayPacket : BitFieldGroupAfterPayloadPacket { 256 array : 8[], 257} 258 259struct BitField { 260 seven_bits : 7, 261 straddle : 4, 262 five_bits : 5, 263} 264 265packet BitFieldPacket { 266 bit_field : BitField, 267} 268 269packet BitFieldAfterPayloadPacket { 270 _payload_, 271 bit_field : BitField, 272} 273 274packet BitFieldAfterUnsizedArrayPacket : BitFieldAfterPayloadPacket { 275 array : 8[], 276} 277 278packet BitFieldArrayPacket { 279 _size_(array): 8, 280 array : BitField[], 281} 282 283struct VersionlessStruct { 284 one_number : 8, 285} 286 287packet OneVersionlessStructPacket { 288 versionless : VersionlessStruct, 289 _payload_, 290} 291 292packet OneVersionedStructPacket : OneVersionlessStructPacket { 293 version : 8, 294 _payload_, 295} 296 297packet OneVersionOneStructPacket : OneVersionedStructPacket(version = 0x01) { 298 just_one_number : 8, 299} 300 301packet OneVersionTwoStructPacket : OneVersionedStructPacket(version = 0x02) { 302 one_number : 8, 303 another_number : 8, 304} 305 306enum StructType : 8 { 307 ZERO_BYTE = 0x00, 308 TWO_BYTE = 0x02, 309 FOUR_BYTE = 0x04, 310 AT_LEAST_FOUR_BYTE = 0x05, 311 VARIABLE = 0x06, 312} 313 314struct UnusedParentStruct { 315 struct_type : StructType, 316 _body_, 317} 318 319struct TwoByteStruct : UnusedParentStruct (struct_type = TWO_BYTE) { 320 two_bytes : 16, 321} 322 323struct FourByteStruct : UnusedParentStruct (struct_type = FOUR_BYTE) { 324 four_bytes : 32, 325} 326 327struct AtLeastFourByteStruct : UnusedParentStruct (struct_type = AT_LEAST_FOUR_BYTE) { 328 four_bytes : 32, 329 struct_type : StructType, 330 _body_, 331} 332 333struct OnlyFourByteStruct : AtLeastFourByteStruct (struct_type = ZERO_BYTE) { 334} 335 336struct SixByteStruct : AtLeastFourByteStruct (struct_type = TWO_BYTE) { 337 two_bytes : 16, 338} 339 340struct EightByteStruct : AtLeastFourByteStruct (struct_type = FOUR_BYTE) { 341 four_bytes : 32, 342} 343 344packet OneFourByteStruct { 345 one_struct : FourByteStruct, 346} 347 348packet OneGenericStruct { 349 base_struct : UnusedParentStruct, 350} 351 352packet OneGenericStructArray { 353 an_array : UnusedParentStruct[], 354} 355 356packet OneGenericStructFourArray { 357 an_array : UnusedParentStruct[4], 358} 359 360packet ParentWithOnlyFixed { 361 two_bytes : 16, 362 _body_, 363} 364 365packet OneGenericStructArrayAfterFixed : ParentWithOnlyFixed { 366 an_array : UnusedParentStruct[], 367} 368 369enum DataType : 8 { 370 ONE = 0x01, 371 TWO = 0x02, 372 THREE = 0x03, 373 FOUR = 0x04, 374 FIVE = 0x05, 375 UNUSED = 0x06, 376} 377 378struct LengthTypeValueStruct { 379 _size_(value) : 16, 380 type : DataType, 381 value : 8[+1*8], 382} 383 384packet OneLengthTypeValueStruct { 385 one_array : LengthTypeValueStruct[], 386} 387 388packet SizedParent { 389 _size_(payload) : 8, 390 _payload_, 391} 392 393packet OneLengthTypeValueStructPadded : SizedParent { 394 valid_bytes : 8, 395 one_array : LengthTypeValueStruct[], 396 _padding_[30], 397 after_padding : 8, 398} 399 400packet ByteSizedFields { 401 one : 8, 402 two : 16, 403 three : 24, 404 four : 32, 405 five : 40, 406 six : 48, 407 seven : 56, 408 eight : 64, 409} 410 411enum StructTypeNoZero : 4 { 412 TWO_BYTE = 0x02, 413 FOUR_BYTE = 0x04, 414 AT_LEAST_FOUR_BYTE = 0x05, 415} 416 417struct UnusedParentStructNoZero { 418 struct_type : StructTypeNoZero, 419 _reserved_ : 4, 420 length : 8, 421 _body_, 422} 423 424struct TwoByteStructNoZero : UnusedParentStructNoZero (struct_type = TWO_BYTE, length = 2) { 425 two_bytes : 16, 426} 427 428struct FourByteStructNoZero : UnusedParentStructNoZero (struct_type = FOUR_BYTE, length = 4) { 429 four_bytes : 32, 430} 431 432struct AtLeastFourByteStructNoZero : UnusedParentStructNoZero (struct_type = AT_LEAST_FOUR_BYTE) { 433 four_bytes : 32, 434 struct_type : StructTypeNoZero, 435 _body_, 436} 437 438struct EightByteStructNoZero : AtLeastFourByteStructNoZero (struct_type = FOUR_BYTE, length = 9) { 439 four_bytes : 32, 440} 441 442packet OneGenericStructArrayNoZero { 443 an_array : UnusedParentStructNoZero[], 444} 445