Documentation ¶
Overview ¶
Package frame contains utilities to implement various network protocols and describe their relationship within Lucius. Each supported network protocol implements the interface protocol.Handler and registers a parse and (an optional) add handler.
Index ¶
Constants ¶
const ByteBitCount = 8
ByteBitCount is the number of bits in a byte.
const Uint32BitCount = 4 * ByteBitCount
Uint32BitCount is the number of bits in a uint32.
const Uint64BitCount = 8 * ByteBitCount
Uint64BitCount is the number of bits in a uint64.
Variables ¶
This section is empty.
Functions ¶
func Resize ¶
Resize returns a slice of bytes either padded or truncated to the specified number of bytes. The intent of resize is to be used with the frame utilities which operate on bytes that represent data in network order. For padding data, zeroes are added at the MSB and when truncating data, the MSB is stripped.
Types ¶
type Field ¶
type Field []byte
A Field is a slice of bytes within a header. Fields of certain sizes may contain numeric data in BigEndian format.
func (Field) BitField ¶
BitField creates a new field using bitcount bits at position bitpos in a numeric field.
type Frame ¶
type Frame struct {
// contains filtered or unexported fields
}
A Frame is a set of bytes that can be read sequentially (or parsed) as a series of packet headers.
func (*Frame) Peek ¶
Peek creates a field of n bytes at offset off from the read position. If the specified bytes do not exist, an error is returned.
func (*Frame) ReadHeader ¶
ReadHeader reads a header of n bytes from the read position. If the specified bytes do not exist, an error is returned.
func (*Frame) StripTrailing ¶
StripTrailing strips the trailing 'n' bytes from the buffer. Note that there must be at-least 'n' unread bytes in the frame.