pdu

package
v0.0.0-...-579017f Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2019 License: LGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HeaderSize defines the total size of a header packet.
	HeaderSize = 20
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AllocateIndex

type AllocateIndex struct {
	Variables Variables
}

AllocateIndex defiens the pdu allocate index packet.

func (*AllocateIndex) MarshalBinary

func (ai *AllocateIndex) MarshalBinary() ([]byte, error)

MarshalBinary returns the pdu packet as a slice of bytes.

func (*AllocateIndex) Type

func (ai *AllocateIndex) Type() Type

Type returns the pdu packet type.

func (*AllocateIndex) UnmarshalBinary

func (ai *AllocateIndex) UnmarshalBinary(data []byte) error

UnmarshalBinary sets the packet structure from the provided slice of bytes.

type Close

type Close struct {
	Reason Reason
}

Close defines the pdu close packet.

func (*Close) MarshalBinary

func (c *Close) MarshalBinary() ([]byte, error)

MarshalBinary returns the pdu packet as a slice of bytes.

func (*Close) Type

func (c *Close) Type() Type

Type returns the pdu packet type.

func (*Close) UnmarshalBinary

func (c *Close) UnmarshalBinary(data []byte) error

UnmarshalBinary sets the packet structure from the provided slice of bytes.

type DeallocateIndex

type DeallocateIndex struct {
	Variables Variables
}

DeallocateIndex defiens the pdu deallocate index packet.

func (*DeallocateIndex) MarshalBinary

func (di *DeallocateIndex) MarshalBinary() ([]byte, error)

MarshalBinary returns the pdu packet as a slice of bytes.

func (*DeallocateIndex) Type

func (di *DeallocateIndex) Type() Type

Type returns the pdu packet type.

func (*DeallocateIndex) UnmarshalBinary

func (di *DeallocateIndex) UnmarshalBinary(data []byte) error

UnmarshalBinary sets the packet structure from the provided slice of bytes.

type Error

type Error uint16

Error defines a pdu packet error.

const (
	ErrorNone                  Error = 0
	ErrorOpenFailed            Error = 256
	ErrorNotOpen               Error = 257
	ErrorIndexWrongType        Error = 258
	ErrorIndexAlreadyAllocated Error = 259
	ErrorIndexNoneAvailable    Error = 260
	ErrorIndexNotAllocated     Error = 261
	ErrorUnsupportedContext    Error = 262
	ErrorDuplicateRegistration Error = 263
	ErrorUnknownRegistration   Error = 264
	ErrorUnknownAgentCaps      Error = 265
	ErrorParse                 Error = 266
	ErrorRequestDenied         Error = 267
	ErrorProcessing            Error = 268
)

The various pdu packet errors.

func (Error) String

func (e Error) String() string

type Flags

type Flags byte

Flags defines pdu packet flags.

const (
	FlagInstanceRegistration Flags = 1 << 0
	FlagNewIndex             Flags = 1 << 1
	FlagAnyIndex             Flags = 1 << 2
	FlagNonDefaultContext    Flags = 1 << 3
	FlagNetworkByteOrder     Flags = 1 << 4
)

The various pdu packet flags.

func (Flags) String

func (f Flags) String() string

type Get

type Get struct {
	SearchRange Range
}

Get defines the pdu get packet.

func (*Get) GetOID

func (g *Get) GetOID() value.OID

GetOID returns the oid.

func (*Get) MarshalBinary

func (g *Get) MarshalBinary() ([]byte, error)

MarshalBinary returns the pdu packet as a slice of bytes.

func (*Get) SetOID

func (g *Get) SetOID(oid value.OID)

SetOID sets the provided oid.

func (*Get) Type

func (g *Get) Type() Type

Type returns the pdu packet type.

func (*Get) UnmarshalBinary

func (g *Get) UnmarshalBinary(data []byte) error

UnmarshalBinary sets the packet structure from the provided slice of bytes.

type GetNext

type GetNext struct {
	SearchRanges Ranges
}

GetNext defines the pdu get next packet.

func (*GetNext) MarshalBinary

func (g *GetNext) MarshalBinary() ([]byte, error)

MarshalBinary returns the pdu packet as a slice of bytes.

func (*GetNext) Type

func (g *GetNext) Type() Type

Type returns the pdu packet type.

func (*GetNext) UnmarshalBinary

func (g *GetNext) UnmarshalBinary(data []byte) error

UnmarshalBinary sets the packet structure from the provided slice of bytes.

type Header struct {
	Version       byte
	Type          Type
	Flags         Flags
	SessionID     uint32
	TransactionID uint32
	PacketID      uint32
	PayloadLength uint32
}

Header defines a pdu packet header

func (*Header) MarshalBinary

func (h *Header) MarshalBinary() ([]byte, error)

MarshalBinary returns the pdu header as a slice of bytes.

func (*Header) UnmarshalBinary

func (h *Header) UnmarshalBinary(data []byte) error

UnmarshalBinary sets the header structure from the provided slice of bytes.

type HeaderPacket

type HeaderPacket struct {
	Header *Header
	Packet Packet
}

HeaderPacket defines a container structure for a header and a packet.

func (*HeaderPacket) MarshalBinary

func (hp *HeaderPacket) MarshalBinary() ([]byte, error)

MarshalBinary returns the pdu packet as a slice of bytes.

func (*HeaderPacket) String

func (hp *HeaderPacket) String() string

type ObjectIdentifier

type ObjectIdentifier struct {
	Prefix         uint8
	Include        byte
	Subidentifiers []uint32
}

ObjectIdentifier defines the pdu object identifier packet.

func (*ObjectIdentifier) ByteSize

func (o *ObjectIdentifier) ByteSize() int

ByteSize returns the number of bytes, the binding would need in the encoded version.

func (*ObjectIdentifier) GetIdentifier

func (o *ObjectIdentifier) GetIdentifier() value.OID

GetIdentifier returns the identifier as an oid string.

func (*ObjectIdentifier) GetInclude

func (o *ObjectIdentifier) GetInclude() bool

GetInclude returns true if the include field ist set, false otherwise.

func (*ObjectIdentifier) MarshalBinary

func (o *ObjectIdentifier) MarshalBinary() ([]byte, error)

MarshalBinary returns the pdu packet as a slice of bytes.

func (*ObjectIdentifier) SetIdentifier

func (o *ObjectIdentifier) SetIdentifier(oid value.OID)

SetIdentifier set the subidentifiers by the provided oid string.

func (*ObjectIdentifier) SetInclude

func (o *ObjectIdentifier) SetInclude(value bool)

SetInclude sets the include field.

func (ObjectIdentifier) String

func (o ObjectIdentifier) String() string

func (*ObjectIdentifier) UnmarshalBinary

func (o *ObjectIdentifier) UnmarshalBinary(data []byte) error

UnmarshalBinary sets the packet structure from the provided slice of bytes.

type OctetString

type OctetString struct {
	Text string
}

OctetString defines the pdu description packet.

func (*OctetString) MarshalBinary

func (o *OctetString) MarshalBinary() ([]byte, error)

MarshalBinary returns the pdu packet as a slice of bytes.

func (*OctetString) UnmarshalBinary

func (o *OctetString) UnmarshalBinary(data []byte) error

UnmarshalBinary sets the packet structure from the provided slice of bytes.

type Open

type Open struct {
	Timeout     Timeout
	ID          ObjectIdentifier
	Description OctetString
}

Open defines a pdu open packet.

func (*Open) MarshalBinary

func (o *Open) MarshalBinary() ([]byte, error)

MarshalBinary returns the pdu packet as a slice of bytes.

func (*Open) Type

func (o *Open) Type() Type

Type returns the pdu packet type.

func (*Open) UnmarshalBinary

func (o *Open) UnmarshalBinary(data []byte) error

UnmarshalBinary sets the packet structure from the provided slice of bytes.

type Packet

Packet defines a general interface for a pdu packet.

type Range

type Range struct {
	From ObjectIdentifier
	To   ObjectIdentifier
}

Range defines the pdu search range packet.

func (*Range) ByteSize

func (r *Range) ByteSize() int

ByteSize returns the number of bytes, the binding would need in the encoded version.

func (*Range) MarshalBinary

func (r *Range) MarshalBinary() ([]byte, error)

MarshalBinary returns the pdu packet as a slice of bytes.

func (Range) String

func (r Range) String() string

func (*Range) UnmarshalBinary

func (r *Range) UnmarshalBinary(data []byte) error

UnmarshalBinary sets the packet structure from the provided slice of bytes.

type Ranges

type Ranges []Range

Ranges defines the pdu search range list packet.

func (*Ranges) MarshalBinary

func (r *Ranges) MarshalBinary() ([]byte, error)

MarshalBinary returns the pdu packet as a slice of bytes.

func (*Ranges) UnmarshalBinary

func (r *Ranges) UnmarshalBinary(data []byte) error

UnmarshalBinary sets the packet structure from the provided slice of bytes.

type Reason

type Reason byte

Reason defines a reason.

const (
	ReasonOther         Reason = 1
	ReasonParseError    Reason = 2
	ReasonProtocolError Reason = 3
	ReasonTimeouts      Reason = 4
	ReasonShutdown      Reason = 5
	ReasonByManager     Reason = 6
)

The various pdu packet reasons.

func (Reason) String

func (r Reason) String() string

type Register

type Register struct {
	Timeout Timeout
	Subtree ObjectIdentifier
}

Register defines the pdu register packet.

func (*Register) MarshalBinary

func (r *Register) MarshalBinary() ([]byte, error)

MarshalBinary returns the pdu packet as a slice of bytes.

func (*Register) Type

func (r *Register) Type() Type

Type returns the pdu packet type.

func (*Register) UnmarshalBinary

func (r *Register) UnmarshalBinary(data []byte) error

UnmarshalBinary sets the packet structure from the provided slice of bytes.

type Response

type Response struct {
	UpTime    time.Duration
	Error     Error
	Index     uint16
	Variables Variables
}

Response defines the pdu response packet.

func (*Response) MarshalBinary

func (r *Response) MarshalBinary() ([]byte, error)

MarshalBinary returns the pdu packet as a slice of bytes.

func (*Response) Type

func (r *Response) Type() Type

Type returns the pdu packet type.

func (*Response) UnmarshalBinary

func (r *Response) UnmarshalBinary(data []byte) error

UnmarshalBinary sets the packet structure from the provided slice of bytes.

type Timeout

type Timeout struct {
	Duration time.Duration
	Priority byte
}

Timeout defines the pdu timeout packet.

func (*Timeout) MarshalBinary

func (t *Timeout) MarshalBinary() ([]byte, error)

MarshalBinary returns the pdu packet as a slice of bytes.

func (Timeout) String

func (t Timeout) String() string

func (*Timeout) UnmarshalBinary

func (t *Timeout) UnmarshalBinary(data []byte) error

UnmarshalBinary sets the packet structure from the provided slice of bytes.

type Type

type Type byte

Type defines the pdu packet type.

const (
	TypeOpen            Type = 1
	TypeClose           Type = 2
	TypeRegister        Type = 3
	TypeUnregister      Type = 4
	TypeGet             Type = 5
	TypeGetNext         Type = 6
	TypeGetBulk         Type = 7
	TypeTestSet         Type = 8
	TypeCommitSet       Type = 9
	TypeUndoSet         Type = 10
	TypeCleanupSet      Type = 11
	TypeNotify          Type = 12
	TypePing            Type = 13
	TypeIndexAllocate   Type = 14
	TypeIndexDeallocate Type = 15
	TypeAddAgentCaps    Type = 16
	TypeRemoveAgentCaps Type = 17
	TypeResponse        Type = 18
)

The various pdu packet types.

func (Type) String

func (t Type) String() string

type TypeOwner

type TypeOwner interface {
	Type() Type
}

TypeOwner defines the interface for an object that provides a type.

type Unregister

type Unregister struct {
	Timeout Timeout
	Subtree ObjectIdentifier
}

Unregister defines the pdu unregister packet.

func (*Unregister) MarshalBinary

func (u *Unregister) MarshalBinary() ([]byte, error)

MarshalBinary returns the pdu packet as a slice of bytes.

func (*Unregister) Type

func (u *Unregister) Type() Type

Type returns the pdu packet type.

func (*Unregister) UnmarshalBinary

func (u *Unregister) UnmarshalBinary(data []byte) error

UnmarshalBinary sets the packet structure from the provided slice of bytes.

type Variable

type Variable struct {
	Type  VariableType
	Name  ObjectIdentifier
	Value interface{}
}

Variable defines the pdu varbind packet.

func (*Variable) ByteSize

func (v *Variable) ByteSize() int

ByteSize returns the number of bytes, the binding would need in the encoded version.

func (*Variable) MarshalBinary

func (v *Variable) MarshalBinary() ([]byte, error)

MarshalBinary returns the pdu packet as a slice of bytes.

func (*Variable) Set

func (v *Variable) Set(oid value.OID, t VariableType, value interface{})

Set sets the variable.

func (*Variable) UnmarshalBinary

func (v *Variable) UnmarshalBinary(data []byte) error

UnmarshalBinary sets the packet structure from the provided slice of bytes.

type VariableType

type VariableType uint16

VariableType defines the type of a variable.

const (
	VariableTypeInteger          VariableType = 2
	VariableTypeOctetString      VariableType = 4
	VariableTypeNull             VariableType = 5
	VariableTypeObjectIdentifier VariableType = 6
	VariableTypeIPAddress        VariableType = 64
	VariableTypeCounter32        VariableType = 65
	VariableTypeGauge32          VariableType = 66
	VariableTypeTimeTicks        VariableType = 67
	VariableTypeOpaque           VariableType = 68
	VariableTypeCounter64        VariableType = 70
	VariableTypeNoSuchObject     VariableType = 128
	VariableTypeNoSuchInstance   VariableType = 129
	VariableTypeEndOfMIBView     VariableType = 130
)

The various variable types.

func (VariableType) String

func (v VariableType) String() string

type Variables

type Variables []Variable

Variables defines a list of variable bindings.

func (*Variables) Add

func (v *Variables) Add(oid value.OID, t VariableType, value interface{})

Add adds the provided variable.

func (*Variables) MarshalBinary

func (v *Variables) MarshalBinary() ([]byte, error)

MarshalBinary returns the pdu packet as a slice of bytes.

func (*Variables) UnmarshalBinary

func (v *Variables) UnmarshalBinary(data []byte) error

UnmarshalBinary sets the packet structure from the provided slice of bytes.

Jump to

Keyboard shortcuts

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