Skip to main content

Module framing

Module framing 

Source

Structs§

FragmentHeader
Parsed representation of the 10-byte fragment metadata header.
Frame

Constants§

COMPRESS_THRESHOLD
Payloads at or above this size are candidates for zstd compression.
FLAG_COMPRESSED
Payload is zstd-compressed. Decompressed by framing layer before delivery. CRC32 is computed over the compressed bytes (what is on the wire).
FLAG_FRAGMENTED
Frame is one fragment of a larger message. The first FRAG_HEADER_SIZE bytes of the payload contain fragment metadata; the remainder is the chunk.
FLAG_MAC_PRESENT
flags bit indicating a 32-byte HMAC tag is appended after the payload.
FLAG_RAW_BINARY
Payload is raw binary (PCM/Opus audio). Router skips Protobuf decode.
FRAG_HEADER_SIZE
Byte length of the fragment metadata header embedded at the start of a fragmented frame’s payload when FLAG_FRAGMENTED is set.
MAX_PAYLOAD_SIZE

Functions§

parse_frag_header
Parses the FragmentHeader from the start of a frame payload. Returns None if the payload is shorter than FRAG_HEADER_SIZE.
read_frame
read_frame_with_timeout
serialize_header
Serialize the 44-byte frame header exactly as it goes on the wire. Used by both write_frame_raw and MAC computation so the tag covers the real bytes.
target_as_str
Returns None if the target bytes are not valid UTF-8. Callers must log the raw hex and return an error frame in that case (VULN-022).
write_frame
write_frame_raw