entities

package
v0.2.1-0...-39643c2 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TemplateRefreshTimeOut is the template refresh time out for exporting process
	TemplateRefreshTimeOut uint32 = 1800
	// TemplateTTL is the template time to live for collecting process
	TemplateTTL uint32 = TemplateRefreshTimeOut * 3
	// TemplateSetID is the setID for template record
	TemplateSetID uint16 = 2
)
View Source
const (
	MaxTcpSocketMsgSize uint16 = 65535
)
View Source
const VariableLength uint16 = 65535

Variables

View Source
var InfoElementLength = [...]uint16{
	VariableLength,
	1,
	2,
	4,
	8,
	1,
	2,
	4,
	8,
	4,
	8,
	1,
	6,
	VariableLength,
	8,
	8,
	8,
	8,
	4,
	16,
	VariableLength,
	VariableLength,
	VariableLength,
	0,
}

Functions

func IsValidDataType

func IsValidDataType(tp IEDataType) bool

func NewDataRecord

func NewDataRecord(id uint16) *dataRecord

func NewTemplateRecord

func NewTemplateRecord(count uint16, id uint16) *templateRecord

Types

type ContentType

type ContentType uint8
const (
	Template ContentType = iota
	Data
	// Add OptionsTemplate too when it is supported
	Undefined = 255
)

type DataSet

type DataSet map[uint32]map[uint16]interface{}

enterpriseID -> elementID -> val

func NewDataSet

func NewDataSet() DataSet

func (DataSet) AddInfoElement

func (d DataSet) AddInfoElement(element *InfoElement, val *bytes.Buffer) error

type IEDataType

type IEDataType uint8
const (
	OctetArray IEDataType = iota
	Unsigned8
	Unsigned16
	Unsigned32
	Unsigned64
	Signed8
	Signed16
	Signed32
	Signed64
	Float32
	Float64
	Boolean
	MacAddress
	String
	DateTimeSeconds
	DateTimeMilliseconds
	DateTimeMicroseconds
	DateTimeNanoseconds
	Ipv4Address
	Ipv6Address
	BasicList
	SubTemplateList
	SubTemplateMultiList
	InvalidDataType = 255
)

func IENameToType

func IENameToType(name string) IEDataType

type InfoElement

type InfoElement struct {
	// Name of the IE
	Name string
	// Identifier for IE; follows Section 4.3 of RFC7013
	ElementId uint16
	// dataType follows the specification in RFC7012(section 3.1)/RFC5610(section 3.1)
	DataType IEDataType
	// Enterprise number or 0 (0 for IANA registry)
	EnterpriseId uint32
	// Length of IE
	Len uint16
}

InfoElement (IE) follows the specification in Section 2.1 of RFC7012

func NewInfoElement

func NewInfoElement(name string, ieID uint16, ieType IEDataType, entID uint32, len uint16) *InfoElement

type Message

type Message struct {
	Version      uint16
	BufferLength uint16
	SeqNumber    uint32
	ObsDomainID  uint32
	ExportTime   uint32
	Set          interface{}
}

data struct of processed message

type MsgBuffer

type MsgBuffer struct {
	// contains filtered or unexported fields
}

func NewMsgBuffer

func NewMsgBuffer() *MsgBuffer

func (*MsgBuffer) GetDataRecFlag

func (m *MsgBuffer) GetDataRecFlag() bool

func (*MsgBuffer) GetMsgBuffer

func (m *MsgBuffer) GetMsgBuffer() *bytes.Buffer

func (*MsgBuffer) SetDataRecFlag

func (m *MsgBuffer) SetDataRecFlag(flag bool)

type Record

type Record interface {
	PrepareRecord() (uint16, error)
	AddInfoElement(element *InfoElement, val interface{}) (uint16, error)
	// TODO: Functions for multiple elements as well.
	GetBuffer() *bytes.Buffer
	GetTemplateID() uint16
	GetFieldCount() uint16
	GetTemplateElements() []*InfoElement
	GetMinDataRecordLen() uint16
}

type Set

type Set struct {
	// contains filtered or unexported fields
}

func NewSet

func NewSet(buffer *bytes.Buffer) *Set

func (*Set) CreateNewSet

func (s *Set) CreateNewSet(setType ContentType, templateID uint16) error

func (*Set) FinishSet

func (s *Set) FinishSet()

func (*Set) GetBuffLen

func (s *Set) GetBuffLen() uint16

func (*Set) GetSetType

func (s *Set) GetSetType() ContentType

func (*Set) WriteRecordToSet

func (s *Set) WriteRecordToSet(recBuffer *[]byte) error

type TemplateSet

type TemplateSet map[uint32][]uint16

enterpriseID -> elementID

func NewTemplateSet

func NewTemplateSet() TemplateSet

func (TemplateSet) AddInfoElement

func (t TemplateSet) AddInfoElement(enterpriseID uint32, elementID uint16)

Directories

Path Synopsis
Package testing is a generated GoMock package.
Package testing is a generated GoMock package.

Jump to

Keyboard shortcuts

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