Tahr.RPC.Message (tahr v0.1.0)

Copy Markdown View Source

ONC RPC v2 call and reply envelopes — RFC 5531 §9.

An RPC message is one of:

msg_type CALL = 0
msg_type REPLY = 1

Calls carry the program/version/procedure to invoke and the caller's credentials; replies carry an outcome (accepted vs. denied) and either the procedure's result body or a status code.

This module decodes incoming wire bytes into the structs below and encodes outgoing replies back to wire bytes. The procedure-specific argument and result bodies are NOT decoded here — they're left as binaries for the program-specific handler to parse.

Summary

Types

Decoded reply, of either accepted or denied flavour.

Functions

Decode an RPC call message. Returns {:ok, call} on success.

Encode a reply (accepted or denied) to wire bytes.

Numeric RPC version this server implements (always 2).

Quick predicate — is the message version this server speaks?

Types

reply()

Decoded reply, of either accepted or denied flavour.

Functions

decode_call(binary)

@spec decode_call(binary()) :: {:ok, Tahr.RPC.Message.Call.t()} | {:error, term()}

Decode an RPC call message. Returns {:ok, call} on success.

This is the only message type a server expects to receive; replies are produced via encode_reply/1.

encode_reply(reply)

@spec encode_reply(reply()) :: iodata()

Encode a reply (accepted or denied) to wire bytes.

Returns iodata so a streaming procedure body (e.g. NFSv3 READ chunks) can flow through to :gen_tcp.send/2 without flattening. Pass through RPC.RecordMarking.encode/1 before writing to the socket.

rpc_version()

@spec rpc_version() :: 2

Numeric RPC version this server implements (always 2).

rpc_version_ok?(call)

@spec rpc_version_ok?(Tahr.RPC.Message.Call.t()) :: boolean()

Quick predicate — is the message version this server speaks?