Documentation
¶
Overview ¶
Package imsg provides tools for working with OpenBSD's imsg library.
Index ¶
Constants ¶
const ( // HeaderSizeInBytes is the size in bytes of the fixed-length header that // prepends each imsg. HeaderSizeInBytes = 16 // MaxSizeInBytes is the maximum allowed size in bytes of a single imsg. MaxSizeInBytes = 16384 )
Variables ¶
This section is empty.
Functions ¶
func SystemEndianness ¶ added in v1.0.0
SystemEndianness returns the determined system byte order.
Types ¶
type ErrDataTooLarge ¶ added in v1.1.0
ErrDataTooLarge is returned when the provided ancillary data is larger than is allowed.
func (*ErrDataTooLarge) Error ¶ added in v1.1.0
func (e *ErrDataTooLarge) Error() string
Error implements the error interface.
type ErrInsufficientData ¶ added in v1.1.0
ErrInsufficientData is returned when reading an imsg produces less data than is expected.
func (*ErrInsufficientData) Error ¶ added in v1.1.0
func (e *ErrInsufficientData) Error() string
Error implements the error interface.
type ErrLengthOutOfBounds ¶ added in v1.1.0
type ErrLengthOutOfBounds struct { LengthInBytes uint16 MinLengthInBytes uint16 MaxLengthInBytes uint16 }
ErrLengthOutOfBounds is returned when the length parameter is either smaller than the imsg header size or larger than the allowed maximum size.
func (*ErrLengthOutOfBounds) Error ¶ added in v1.1.0
func (e *ErrLengthOutOfBounds) Error() string
Error implements the error interface.
type IMsg ¶
type IMsg struct { Type uint32 // Describes the meaning of the message PeerID uint32 // Free for use by caller; intended to identify message sender PID uint32 // Free for use by caller; intended to identify message sender Data []byte // Ancillary data included with the imsg // contains filtered or unexported fields }
An IMsg is a message used to aid inter-process communication over sockets, often when processes with different privileges are required to cooperate.
func ComposeIMsg ¶
ComposeIMsg constructs an IMsg of the provided type. If the included ancillary data is too large, an error is returned. When composing an IMsg using this function, the PID field is filled in automatically by a call to os.Getpid(). This can be overwritten as desired.
func ReadIMsg ¶
ReadIMsg constructs an IMsg by reading from an io.Reader. If the incoming data is malformed, this function can block by attempting to read more data than is present.
func (IMsg) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (*IMsg) UnmarshalBinary ¶ added in v1.2.0
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.