oncrpc

package
v0.587.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2026 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package oncrpc parses the ONC RPC (Sun RPC, RFC 5531) message header shared by the project's RPC-protocol decoders — internal/portmap (rpcbind), internal/mount (NFS MOUNT) and internal/nfs (NFS v3). Each of those decodes the same call/reply framing (transaction id, message type, the call program/version/procedure + auth/verifier, or the reply accept status) before its procedure-specific body; this package owns that framing once so the protocol decoders only implement their own procedure bodies.

Wrap-vs-native judgement

Native. The RPC message header is a short sequence of 32-bit XDR
fields with two variable-length auth/verifier opaque blobs — a
byte-field read with bounds checks. stdlib only, no new go.mod dep.

Scope

The message header only: the transaction id, the call fields
(rpcvers / program / version / procedure / auth flavor, skipping the
auth + verifier opaque bodies) or the reply fields (reply status,
and for an accepted reply the accept status), and the byte offset of
the procedure-specific Body. The body itself is decoded by the
per-program packages. RPCSEC_GSS auth bodies are skipped by their
declared length like any other flavor.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AcceptStatName

func AcceptStatName(s uint32) string

AcceptStatName maps the RFC 5531 accept_stat enumeration.

Types

type Message

type Message struct {
	XID  uint32
	Type uint32 // 0 = CALL, 1 = REPLY

	// CALL fields (valid when Type == 0).
	RPCVersion     uint32
	Program        uint32
	ProgramVersion uint32
	Procedure      uint32
	AuthFlavor     uint32

	// REPLY fields (valid when Type == 1).
	ReplyStat  uint32 // 0 = MSG_ACCEPTED, 1 = MSG_DENIED
	Accepted   bool
	AcceptStat uint32 // valid when Accepted

	// Body is the procedure arguments (CALL), the accepted result (REPLY,
	// after the accept status), or the reject info (a denied REPLY).
	Body []byte
}

Message is a parsed ONC RPC message header with the procedure-specific body isolated in Body.

func Parse

func Parse(b []byte) (*Message, error)

Parse decodes the ONC RPC message header from b (the RPC payload without any TCP record marker) and isolates the procedure-specific body.

func (*Message) IsCall

func (m *Message) IsCall() bool

IsCall reports whether the message is an RPC CALL.

func (*Message) IsReply

func (m *Message) IsReply() bool

IsReply reports whether the message is an RPC REPLY.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL