• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1This file just contains some notes about the design and usage of the PDL language.
2
3-------
4 TERMS
5-------
6.pdl
7  The file type that defines packet definitions. You may think of each pdl file
8  as its own translation unit.
9
10Packet Views and Builders
11  Generated from a packet definition. Views are used to validate packets and
12  extract the fields that are defined in the pdl file.  Builders check the input
13  arguments and can be serialized.
14
15Checksum types
16  checksum MyChecksumClass : 16 "path/to/the/class/"
17  Checksum fields need to implement the following three methods:
18    void Initialize(MyChecksumClass&);
19    void AddByte(MyChecksumClass&, uint8_t);
20    // Assuming a 16-bit (uint16_t) checksum:
21    uint16_t GetChecksum(MyChecksumClass&);
22-------------
23 LIMITATIONS
24-------------
25  - Size fields for a variable length field MUST come before the definition
26    of said field.
27
28  - Payload fields must be byte-aligned unless they have an unknown size.
29    Body fields are allowed to not be byte aligned.
30
31  - No conditionals
32
33  - Can not have to fields with the same name anywhere in the in an inheritence chain
34
35  - Can't handle size for Body type fields yet since they might not be byte aligned.
36
37  - Currently no arrays of custom types (might change later)
38
39-------
40 NOTES
41-------
42All field names should be in snake_case.  Types should be in CamelCase.
43
44The _payload_ keyword generates a getter but _body_ doesn't. Therefore, a
45_payload_ must be byte aligned.
46
47Supports constraints on grandparents
48Supports multiple constraints
49Every field handles its own generation.
50One pdl file will result in one header file with all the packets
51
52Things to cover -
53  Constraints
54  Inheritance vs Contains
55
56Custom fields with fixed size must extend and implement:
57  packet::CustomFieldFixedSizeInterface
58
59Custom fields with variable size need the following functions:
60  static void Serialize(const Type&, MutableView&);
61  static std::optional<size_t> Size(Iterator);
62  static Type Parse(Iterator);
63  std::string ToString();