Expand description
DNODE wire codec.
The DNODE protocol frames every Dynomite peer-to-peer message
with a small ASCII header followed by an opaque payload. The
header carries the message id, type tag, encryption/compression
flags, protocol version, same-datacenter bit, an inline data
field (either a one-byte placeholder or an RSA-wrapped AES key),
and the byte length of the payload that follows after \r\n.
The reference engine implements the parser as a single state machine driven byte-by-byte. This module ports the same machine into safe Rust and exposes:
DynParseState- the parser’s state alphabet.DmsgType- the full set of message-type discriminators.Dmsg- the in-memory header.DnodeParser- the state machine, advanced by feeding bytes throughDnodeParser::step.dmsg_write/dmsg_write_mbuf- the canonical encoders.parse_req/parse_rsp- thin sync wrappers around the parser that operate on acrate::msg::Msg’s mbuf chain.dmsg_process- dispatcher that classifies a parsedDmsgby type for the cluster layer to act on.
The encoder accepts an optional aes_key_payload: when present,
the caller provides the bytes the inline data field should hold
(the RSA-wrapped AES key produced by crate::crypto::Crypto).
When absent, the encoder writes the single-byte 'd' placeholder
the reference engine emits after the first handshake message.
Structs§
- Dmsg
- Parsed DNODE header.
- Dnode
Parser - Streaming DNODE header parser.
- Handshake
- Peer-handshake control payload exchanged on top of a
DmsgType::GossipSynframe.
Enums§
- Dmsg
Dispatch - Outcome of
dmsg_process. - Dmsg
Type - DNODE message type identifier.
- Dnode
Error - Errors that can be raised when encoding or parsing a DNODE header without going through the streaming state machine.
- DynParse
State - Parser state transitions.
- Parse
Step - Result of a single
DnodeParser::stepinvocation.
Constants§
- CRLF
- CRLF delimiter that separates the DNODE header from its payload.
- DMSG_
FLAG_ COMPRESSED - Compression bit in
Dmsg::flags. - DMSG_
FLAG_ ENCRYPTED - Encryption bit in
Dmsg::flags. - GOSSIP_
PLACEHOLDER_ DATA - Single-byte placeholder used by
dmsg_write_mbufwhen no AES key payload accompanies the header. The gossip path emits'a'instead of'd'to disambiguate the two encoder flavours. - HANDSHAKE_
PLACEHOLDER_ DATA - Single-byte placeholder used by
dmsg_writewhen no AES key payload accompanies the header. - MAGIC
- Magic literal that opens every DNODE header.
- VERSION_
10 - Default protocol version emitted by
dmsg_write. MirrorsVERSION_10in the reference engine.
Functions§
- dmsg_
process - Stage 7 dispatcher: classify a parsed
Dmsgas control-plane traffic the cluster layer should consume directly, or data-plane traffic that should continue through the protocol stack. - dmsg_
write - Encode a DNODE header into the writable region of
mbuf. - dmsg_
write_ mbuf - Encode a gossip-flavored DNODE header.
- flatten_
chain - Drain
chaininto a contiguousVec<u8>recycling each chunk back topool. Useful for tests and for the Stage 9 path that needs a flat buffer of decrypted payload bytes. - parse_
req - Sync byte parser that drives a request message’s DNODE header state machine.
- parse_
rsp - Sync byte parser counterpart to
parse_reqfor response messages.