From c475e8b4fef0014be0aa9ca127fab888f61de455 Mon Sep 17 00:00:00 2001 From: DcruBro Date: Tue, 13 Oct 2026 16:45:02 +0200 Subject: [PATCH] frame.h for the core 'frames' thingy --- src/wire/frame.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/wire/frame.h diff --git a/src/wire/frame.h b/src/wire/frame.h new file mode 100644 index 0000000..2e3f80f --- /dev/null +++ b/src/wire/frame.h @@ -0,0 +1,42 @@ +// frame.h +// Defines "frames", the unit of content inside a packet. +// Frames know nothing about transport - QUIC and raw modes only differ in packet headers, not the contents. +// Note: Pointers in a parsed frame borrow from the packet buffer. + +#ifndef BRAVAIS_FRAME_H +#define BRAVAIS_FRAME_H + +#include +#include + +typedef enum { + BRAVAIS_FRAME_TYPE_PADDING = 0x00, + BRAVAIS_FRAME_TYPE_CRYPTO = 0x06, // QUIC crypto frame + BRAVAIS_FRAME_TYPE_DATAGRAM = 0x31, // QUIC datagram frame +} bravais_frame_type_t; + +// Handshake bytes at a byte offset in the handshake stream. Offset + Length makes the fragmentation across datagrams to happen naturally. +typedef struct { + uint64_t offset; + const uint8_t* data; + size_t dataLen; +} bravais_crypto_frame_t; + +// One tunneled IP packet +typedef struct { + const uint8_t* data; + size_t dataLen; +} bravais_datagram_frame_t; + +typedef struct { + bravais_frame_type_t type; + union { + size_t paddingLen; // For PADDING frames, the length of the padding, a consequtive run of PAdDING bytes (parsed as a single frame) + bravais_crypto_frame_t crypto; + bravais_datagram_frame_t datagram; + }; +} bravais_frame_t; + +// TODO: Functions or something + +#endif // BRAVAIS_FRAME_H