Skip to main content

Module dnode

Module dnode 

Source
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:

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.
DnodeParser
Streaming DNODE header parser.
Handshake
Peer-handshake control payload exchanged on top of a DmsgType::GossipSyn frame.

Enums§

DmsgDispatch
Outcome of dmsg_process.
DmsgType
DNODE message type identifier.
DnodeError
Errors that can be raised when encoding or parsing a DNODE header without going through the streaming state machine.
DynParseState
Parser state transitions.
ParseStep
Result of a single DnodeParser::step invocation.

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_mbuf when 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_write when no AES key payload accompanies the header.
MAGIC
Magic literal that opens every DNODE header.
VERSION_10
Default protocol version emitted by dmsg_write. Mirrors VERSION_10 in the reference engine.

Functions§

dmsg_process
Stage 7 dispatcher: classify a parsed Dmsg as 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 chain into a contiguous Vec<u8> recycling each chunk back to pool. 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_req for response messages.