entities

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2021 License: Apache-2.0 Imports: 5 Imported by: 30

Documentation

Index

Constants

View Source
const (
	MaxTcpSocketMsgSize int = 65535
	DefaultUDPMsgSize   int = 512
	MaxUDPMsgSize       int = 1500
	MsgHeaderLength     int = 16
)
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 = TemplateRefreshTimeOut * 3
	// TemplateSetID is the setID for template record
	TemplateSetID uint16 = 2
	SetHeaderLen  int    = 4
)
View Source
const VariableLength uint16 = 65535

Variables

Functions

func DecodeToIEDataType added in v0.3.0

func DecodeToIEDataType(dataType IEDataType, val interface{}) (interface{}, error)

DecodeToIEDataType is to decode to specific type

func EncodeToIEDataType added in v0.3.0

func EncodeToIEDataType(dataType IEDataType, val interface{}) ([]byte, error)

EncodeToIEDataType is to encode data to specific type to the buff

func IsValidDataType

func IsValidDataType(tp IEDataType) bool

func NewDataRecord

func NewDataRecord(id uint16, numElements, numExtraElements int, isDecoding bool) *dataRecord

func NewTemplateRecord

func NewTemplateRecord(id uint16, numElements int, isDecoding bool) *templateRecord

Types

type ContentType

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

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 InfoElementWithValue added in v0.3.0

type InfoElementWithValue struct {
	Element *InfoElement
	Value   interface{}
	Length  int
}

InfoElementWithValue represents mapping from element to value for data records

func NewInfoElementWithValue added in v0.3.0

func NewInfoElementWithValue(element *InfoElement, value interface{}) InfoElementWithValue

type Message added in v0.2.0

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

Message represents IPFIX message. TODO: Currently, it supports only one set. This will be extended to support multiple sets.

func NewMessage added in v0.4.0

func NewMessage(isDecoding bool) *Message

func (*Message) AddSet added in v0.4.0

func (m *Message) AddSet(set Set)

func (*Message) GetExportAddress added in v0.4.0

func (m *Message) GetExportAddress() string

func (*Message) GetExportTime added in v0.4.0

func (m *Message) GetExportTime() uint32

func (*Message) GetMessageLen added in v0.4.0

func (m *Message) GetMessageLen() uint16

func (*Message) GetMsgHeader added in v0.5.4

func (m *Message) GetMsgHeader() []byte

func (*Message) GetObsDomainID added in v0.4.0

func (m *Message) GetObsDomainID() uint32

func (*Message) GetSequenceNum added in v0.4.0

func (m *Message) GetSequenceNum() uint32

func (*Message) GetSet added in v0.4.0

func (m *Message) GetSet() Set

func (*Message) GetVersion added in v0.4.0

func (m *Message) GetVersion() uint16

func (*Message) ResetMsgHeader added in v0.5.4

func (m *Message) ResetMsgHeader()

func (*Message) SetExportAddress added in v0.4.0

func (m *Message) SetExportAddress(ipAddr string)

func (*Message) SetExportTime added in v0.4.0

func (m *Message) SetExportTime(exportTime uint32)

func (*Message) SetMessageLen added in v0.4.0

func (m *Message) SetMessageLen(len uint16)

func (*Message) SetObsDomainID added in v0.4.0

func (m *Message) SetObsDomainID(obsDomainID uint32)

func (*Message) SetSequenceNum added in v0.4.0

func (m *Message) SetSequenceNum(seqNum uint32)

func (*Message) SetVersion added in v0.4.0

func (m *Message) SetVersion(version uint16)

type Record

type Record interface {
	PrepareRecord() error
	AddInfoElement(element *InfoElementWithValue) error
	// TODO: Functions for multiple elements as well.
	GetBuffer() []byte
	GetTemplateID() uint16
	GetFieldCount() uint16
	GetOrderedElementList() []InfoElementWithValue
	GetInfoElementWithValue(name string) (*InfoElementWithValue, int, bool)
	SetInfoElementWithValue(index int, infoElement InfoElementWithValue) error
	GetRecordLength() int
	GetMinDataRecordLen() uint16
}

type Set

type Set interface {
	PrepareSet(setType ContentType, templateID uint16) error
	ResetSet()
	GetHeaderBuffer() []byte
	GetSetLength() int
	GetSetType() ContentType
	UpdateLenInHeader()
	AddRecord(elements []InfoElementWithValue, templateID uint16) error
	AddRecordWithExtraElements(elements []InfoElementWithValue, numExtraElements int, templateID uint16) error
	GetRecords() []Record
	GetNumberOfRecords() uint32
}

func NewSet

func NewSet(isDecoding bool) Set

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