Skip to main content

Module wire

Module wire 

Source
Expand description

The D-Bus wire protocol (D-Bus Specification 0.43), shared by NetGet’s server and client: the SASL handshake that precedes messages, and messages themselves — the fixed header, the header fields, and a body marshalled by its type signature. Bodies are converted to and from JSON so the model never sees bytes: a signature says how a JSON value is encoded.

NetGet writes little-endian (l) and reads both byte orders. Two bounds are enforced before anything is allocated or recursed into: a message is at most MAX_MESSAGE_BYTES, and containers — arrays, structs, dict entries and variants — nest at most MAX_DEPTH deep (half the specification’s 64; see the constant). Variants matter: a signature is at most 255 bytes, but a variant carries its own signature inside the data, so without a counter seven bytes per level nest without limit.

Structs§

Message

Enums§

Ty
One complete type.

Constants§

BUS_NAME
BUS_PATH
ERROR
MAX_AUTH_LINE
One SASL line, and how many lines the handshake may take.
MAX_AUTH_LINES
MAX_DEPTH
Container nesting, variants included. The specification allows 64 (32 arrays + 32 structs); NetGet allows 32, because a decoded value becomes JSON inside an event, and the event and handler pipeline bounds JSON at 64 levels: a 64-deep value plus its event’s own wrapping does not fit, and was refused there instead of here.
MAX_MESSAGE_BYTES
The most a message may be, header and body. The specification allows 128 MiB.
METHOD_CALL
METHOD_RETURN
NO_REPLY_EXPECTED
SIGNAL

Functions§

decode
hex_ascii
SASL’s hex encoding of a string (EXTERNAL’s identity, ANONYMOUS’s trace).
infer_signature
marshal
Marshal values by signature; the signature and the bytes.
parse_signature
Parse a signature into its complete types. At most 255 bytes, 32 nested arrays and 32 nested structs, as the specification requires.
random_guid
read_auth_line
One CRLF-terminated SASL line, at most MAX_AUTH_LINE bytes.
read_message
Read one message. Its announced size is checked against MAX_MESSAGE_BYTES from the fixed header, before the rest is read. Ok(None) at a clean end of stream.
type_name
valid_bus_name
valid_interface
valid_member
valid_object_path
variant_parts
A variant as the model writes it: {"signature": "s", "value": ...}, or a plain JSON value whose signature is inferred (string s, bool b, integer i or x or t, number d, array of strings as, other array av, object a{sv}).