Bug: 306901204

Clone this repo:
  1. 9d0d0d3 Migrate 25 crates to monorepo. am: 324eb7dd96 by James Farrell · 6 weeks ago main master
  2. 324eb7d Migrate 25 crates to monorepo. by James Farrell · 6 weeks ago
  3. 681a3a2 Update Android.bp by running cargo_embargo am: 4b6ed01c67 by James Farrell · 9 weeks ago
  4. 4b6ed01 Update Android.bp by running cargo_embargo by James Farrell · 9 weeks ago
  5. 791671b Upgrade pdl-runtime to 0.3.1 am: 2f616e0485 by Henri Chataing · 3 months ago android15-tests-dev

Packet Description Language (PDL)

Crate Build workflow GitHub contributors GitHub stars

PDL is a domain specific language for writing the definition of binary protocol packets. Parsing and validating packets from raw bytes is tedious and error prone in any language. PDL generates memory safe and tailored backends for multiple target languages:

- Rust
- C++
- Python

Historically PDL was developed as part of the Android Bluetooth stack (bluetooth_packetgen) as a way to generate the parser and serializer for Bluetooth packets, and reduce the number of memory safety issues that come with manipulating and validating raw data.

How to use PDL

  1. Write the protocol definition
  2. cargo run my-protocol.pdl --output-format rust > my-protocol.rs

Language specific instructions are provided for all supported backends:

  1. Rust generated code guide
  2. Python generated code guide
  3. C++ generated code guide

Supported Features

Full reference documentation

  • Scalar values
  • Enumerators
  • Arrays
  • Optional fields
  • Nested packets
  • Conditional packet derivation
  • Custom field definitions

Similar projects