snmp

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2018 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UnpackPDU

func UnpackPDU(raw asn1.RawValue) (PDUMeta, PDU, error)

Types

type ApplicationValueType

type ApplicationValueType int // application-specific values in VarBind.Value
const (
	IPAddressType   ApplicationValueType = 0
	Counter32Type   ApplicationValueType = 1
	Gauge32Type     ApplicationValueType = 2
	TimeTicks32Type ApplicationValueType = 3
	OpaqueType      ApplicationValueType = 4
	Counter64Type   ApplicationValueType = 6
)

type BulkPDU

type BulkPDU struct {
	RequestID      int
	NonRepeaters   int
	MaxRepetitions int
	VarBinds       []VarBind
}

Very similar to the PDU type, but the error fields are replaced by parameters

func (BulkPDU) GetError

func (pdu BulkPDU) GetError() PDUError

func (BulkPDU) GetRequestID

func (pdu BulkPDU) GetRequestID() int

func (BulkPDU) Pack

func (pdu BulkPDU) Pack(meta PDUMeta) (asn1.RawValue, error)

func (BulkPDU) String

func (pdu BulkPDU) String() string

type Counter32

type Counter32 uint32

type Counter64

type Counter64 uint64

type ErrorStatus

type ErrorStatus int
const (
	Success         ErrorStatus = 0
	TooBigError     ErrorStatus = 1
	NoSuchNameError ErrorStatus = 2
	BadValueError   ErrorStatus = 3
	ReadOnlyError   ErrorStatus = 4
	GenericError    ErrorStatus = 5
)

func (ErrorStatus) Error

func (err ErrorStatus) Error() string

func (ErrorStatus) String

func (err ErrorStatus) String() string

type ErrorValue

type ErrorValue int // context-specific NULLs in VarBind.Value
const (
	NoSuchObjectValue   ErrorValue = 0
	NoSuchInstanceValue ErrorValue = 1
	EndOfMibViewValue   ErrorValue = 2
)

func (ErrorValue) Error

func (err ErrorValue) Error() string

func (ErrorValue) String

func (err ErrorValue) String() string

type Gauge32

type Gauge32 uint32

type GenericPDU

type GenericPDU struct {
	RequestID   int
	ErrorStatus ErrorStatus
	ErrorIndex  int
	VarBinds    []VarBind
}

func (GenericPDU) GetError

func (pdu GenericPDU) GetError() PDUError

func (GenericPDU) GetRequestID

func (pdu GenericPDU) GetRequestID() int

func (GenericPDU) GetVarBind

func (pdu GenericPDU) GetVarBind(index int) VarBind

func (GenericPDU) Pack

func (pdu GenericPDU) Pack(meta PDUMeta) (asn1.RawValue, error)

func (GenericPDU) String

func (pdu GenericPDU) String() string

type GenericTrap

type GenericTrap int
const (
	TrapColdStart             GenericTrap = 0
	TrapWarmStart             GenericTrap = 1
	TrapLinkDown              GenericTrap = 2
	TrapLinkUp                GenericTrap = 3
	TrapAuthenticationFailure GenericTrap = 4
	TrapEgpNeighborLoss       GenericTrap = 5
	TrapEnterpriseSpecific    GenericTrap = 6
)

type IPAddress

type IPAddress [4]uint8

type OID

type OID []int

func MustParseOID

func MustParseOID(str string) OID

panic on ParseOID errors

func ParseOID

func ParseOID(str string) (OID, error)

func (OID) Copy

func (oid OID) Copy() OID

func (OID) Equals

func (oid OID) Equals(other OID) bool

Compare two OIDs for equality

func (OID) Extend

func (oid OID) Extend(ids ...int) OID

Extend this OID with the given ids, returning the new, more-specific, OID.

func (OID) Index

func (oid OID) Index(other OID) []int

Test if the given OID is a more-specific of this OID, returning the extended part if so. Returns {} if the OIDs are an exact match Returns nil if the OIDs do not match

func (OID) String

func (oid OID) String() (str string)

type Opaque

type Opaque []byte

type PDU

type PDU interface {
	GetRequestID() int

	GetError() PDUError

	Pack(PDUMeta) (asn1.RawValue, error)
}

type PDUError

type PDUError struct {
	ErrorStatus ErrorStatus
	VarBind     VarBind
}

type PDUMeta

type PDUMeta struct {
	PDUType   PDUType
	RequestID int
}

type PDUType

type PDUType int // context-specific
const (
	GetRequestType     PDUType = 0
	GetNextRequestType PDUType = 1
	GetResponseType    PDUType = 2
	SetRequestType     PDUType = 3
	TrapV1Type         PDUType = 4
	GetBulkRequestType PDUType = 5
	InformRequestType  PDUType = 6
	TrapV2Type         PDUType = 7
	ReportType         PDUType = 8
)

func (PDUType) String

func (pduType PDUType) String() string

type Packet

type Packet struct {
	Version   Version
	Community []byte
	RawPDU    asn1.RawValue
}

func (*Packet) Marshal

func (packet *Packet) Marshal() ([]byte, error)

func (*Packet) PDUType

func (packet *Packet) PDUType() PDUType

func (*Packet) PackPDU

func (packet *Packet) PackPDU(meta PDUMeta, pdu PDU) error

func (*Packet) Unmarshal

func (packet *Packet) Unmarshal(buf []byte) error

func (*Packet) UnpackPDU

func (packet *Packet) UnpackPDU() (PDUMeta, PDU, error)

type TimeTicks32

type TimeTicks32 uint32 // duration of 1/100 s

type TrapPDU

type TrapPDU struct {
	Enterprise   asn1.ObjectIdentifier
	AgentAddr    net.IP // []byte
	GenericTrap  GenericTrap
	SpecificTrap int
	TimeStamp    time.Duration // int64
	VarBinds     []VarBind
}

SNMPv1 Trap-PDU

type VarBind

type VarBind struct {
	Name     asn1.ObjectIdentifier
	RawValue asn1.RawValue
}

func MakeVarBind

func MakeVarBind(oid OID, value interface{}) VarBind

panics if unable to pack value

func (VarBind) ErrorValue

func (varBind VarBind) ErrorValue() error

Return ErrorValue if exists, otherwise nil

func (VarBind) OID

func (varBind VarBind) OID() OID

func (*VarBind) Set

func (varBind *VarBind) Set(genericValue interface{}) error

func (*VarBind) SetError

func (varBind *VarBind) SetError(errorValue ErrorValue) error

func (*VarBind) SetNull

func (varBind *VarBind) SetNull()

func (VarBind) String

func (varBind VarBind) String() string

func (VarBind) Value

func (varBind VarBind) Value() (interface{}, error)

type Version

type Version int
const (
	SNMPv1  Version = 0
	SNMPv2c Version = 1
)

Jump to

Keyboard shortcuts

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