You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jianglk.darker 7ee447c011
v811_spc009_project
7 months ago
..
fields v811_spc009_project 7 months ago
test v811_spc009_project 7 months ago
Android.bp v811_spc009_project 7 months ago
BUILD.gn v811_spc009_project 7 months ago
README v811_spc009_project 7 months ago
bison.gni v811_spc009_project 7 months ago
checksum_def.cc v811_spc009_project 7 months ago
checksum_def.h v811_spc009_project 7 months ago
checksum_type_checker.h v811_spc009_project 7 months ago
custom_field_def.cc v811_spc009_project 7 months ago
custom_field_def.h v811_spc009_project 7 months ago
custom_type_checker.h v811_spc009_project 7 months ago
declarations.h v811_spc009_project 7 months ago
enum_def.cc v811_spc009_project 7 months ago
enum_def.h v811_spc009_project 7 months ago
enum_gen.cc v811_spc009_project 7 months ago
enum_gen.h v811_spc009_project 7 months ago
field_list.h v811_spc009_project 7 months ago
flex.gni v811_spc009_project 7 months ago
gen_cpp.cc v811_spc009_project 7 months ago
gen_rust.cc v811_spc009_project 7 months ago
language_l.ll v811_spc009_project 7 months ago
language_y.yy v811_spc009_project 7 months ago
logging.h v811_spc009_project 7 months ago
main.cc v811_spc009_project 7 months ago
packet_def.cc v811_spc009_project 7 months ago
packet_def.h v811_spc009_project 7 months ago
packetgen.gni v811_spc009_project 7 months ago
parent_def.cc v811_spc009_project 7 months ago
parent_def.h v811_spc009_project 7 months ago
parse_location.h v811_spc009_project 7 months ago
size.h v811_spc009_project 7 months ago
struct_def.cc v811_spc009_project 7 months ago
struct_def.h v811_spc009_project 7 months ago
struct_parser_generator.cc v811_spc009_project 7 months ago
struct_parser_generator.h v811_spc009_project 7 months ago
type_def.h v811_spc009_project 7 months ago
util.h v811_spc009_project 7 months ago

README

This file just contains some notes about the design and usage of the PDL language.

-------
 TERMS
-------
.pdl
  The file type that defines packet definitions. You may think of each pdl file
  as its own translation unit.

Packet Views and Builders
  Generated from a packet definition. Views are used to validate packets and
  extract the fields that are defined in the pdl file.  Builders check the input
  arguments and can be serialized.

Checksum types
  checksum MyChecksumClass : 16 "path/to/the/class/"
  Checksum fields need to implement the following three methods:
    void Initialize(MyChecksumClass&);
    void AddByte(MyChecksumClass&, uint8_t);
    // Assuming a 16-bit (uint16_t) checksum:
    uint16_t GetChecksum(MyChecksumClass&);
-------------
 LIMITATIONS
-------------
  - Size fields for a variable length field MUST come before the definition
    of said field.

  - Payload fields must be byte-aligned unless they have an unknown size.
    Body fields are allowed to not be byte aligned.

  - No conditionals

  - Can not have to fields with the same name anywhere in the in an inheritence chain

  - Can't handle size for Body type fields yet since they might not be byte aligned.

  - Currently no arrays of custom types (might change later)

-------
 NOTES
-------
All field names should be in snake_case.  Types should be in CamelCase.

The _payload_ keyword generates a getter but _body_ doesn't. Therefore, a
_payload_ must be byte aligned.

Supports constraints on grandparents
Supports multiple constraints
Every field handles its own generation.
One pdl file will result in one header file with all the packets

Things to cover -
  Constraints
  Inheritance vs Contains

Custom fields with fixed size must extend and implement:
  packet::CustomFieldFixedSizeInterface

Custom fields with variable size need the following functions:
  static void Serialize(const Type&, MutableView&);
  static std::optional<size_t> Size(Iterator);
  static Type Parse(Iterator);
  std::string ToString();