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§
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_LINEbytes. - read_
message - Read one message. Its announced size is checked against
MAX_MESSAGE_BYTESfrom 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}).