ipfix

package
v0.0.0-...-7ed803a Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2017 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package ipfix decodes IPFIX packets : ---------------------------------------------------------------------------- : Copyright (C) 2017 Verizon. All Rights Reserved. : All Rights Reserved : : file: decoder.go : details: TODO : author: Mehrdad Arshad Rad : date: 02/01/2017 : : Licensed under the Apache License, Version 2.0 (the "License"); : you may not use this file except in compliance with the License. : You may obtain a copy of the License at : : http://www.apache.org/licenses/LICENSE-2.0 : : Unless required by applicable law or agreed to in writing, software : distributed under the License is distributed on an "AS IS" BASIS, : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. : See the License for the specific language governing permissions and : limitations under the License. : ----------------------------------------------------------------------------

Package packet decodes layer two, three and four OSI model layers : ---------------------------------------------------------------------------- : Copyright (C) 2017 Verizon. All Rights Reserved. : All Rights Reserved : : file: ipfix.go : details: TODO : author: Mehrdad Arshad Rad : date: 02/01/2017 : : Licensed under the Apache License, Version 2.0 (the "License"); : you may not use this file except in compliance with the License. : You may obtain a copy of the License at : : http://www.apache.org/licenses/LICENSE-2.0 : : Unless required by applicable law or agreed to in writing, software : distributed under the License is distributed on an "AS IS" BASIS, : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. : See the License for the specific language governing permissions and : limitations under the License. : ----------------------------------------------------------------------------

Package ipfix decodes IPFIX packets : ---------------------------------------------------------------------------- : Copyright (C) 2017 Verizon. All Rights Reserved. : All Rights Reserved : : file: marshal.go : details: TODO : author: Mehrdad Arshad Rad : date: 02/01/2017 : : Licensed under the Apache License, Version 2.0 (the "License"); : you may not use this file except in compliance with the License. : You may obtain a copy of the License at : : http://www.apache.org/licenses/LICENSE-2.0 : : Unless required by applicable law or agreed to in writing, software : distributed under the License is distributed on an "AS IS" BASIS, : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. : See the License for the specific language governing permissions and : limitations under the License. : ----------------------------------------------------------------------------

Package ipfix decodes IPFIX packets : ---------------------------------------------------------------------------- : Copyright (C) 2017 Verizon. All Rights Reserved. : All Rights Reserved : : file: memcache.go : details: TODO : author: Mehrdad Arshad Rad : date: 02/01/2017 : : Licensed under the Apache License, Version 2.0 (the "License"); : you may not use this file except in compliance with the License. : You may obtain a copy of the License at : : http://www.apache.org/licenses/LICENSE-2.0 : : Unless required by applicable law or agreed to in writing, software : distributed under the License is distributed on an "AS IS" BASIS, : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. : See the License for the specific language governing permissions and : limitations under the License. : ----------------------------------------------------------------------------

Package ipfix decodes IPFIX packets : ---------------------------------------------------------------------------- : Copyright (C) 2017 Verizon. All Rights Reserved. : All Rights Reserved : : file: decoder.go : details: TODO : author: Mehrdad Arshad Rad : date: 02/01/2017 : : Licensed under the Apache License, Version 2.0 (the "License"); : you may not use this file except in compliance with the License. : You may obtain a copy of the License at : : http://www.apache.org/licenses/LICENSE-2.0 : : Unless required by applicable law or agreed to in writing, software : distributed under the License is distributed on an "AS IS" BASIS, : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. : See the License for the specific language governing permissions and : limitations under the License. : ----------------------------------------------------------------------------

Package ipfix decodes IPFIX packets : ---------------------------------------------------------------------------- : Copyright (C) 2017 Verizon. All Rights Reserved. : All Rights Reserved : : file: reader.go : details: TODO : author: Mehrdad Arshad Rad : date: 02/01/2017 : : Licensed under the Apache License, Version 2.0 (the "License"); : you may not use this file except in compliance with the License. : You may obtain a copy of the License at : : http://www.apache.org/licenses/LICENSE-2.0 : : Unless required by applicable law or agreed to in writing, software : distributed under the License is distributed on an "AS IS" BASIS, : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. : See the License for the specific language governing permissions and : limitations under the License. : ----------------------------------------------------------------------------

Package ipfix decodes IPFIX packets : ---------------------------------------------------------------------------- : Copyright (C) 2017 Verizon. All Rights Reserved. : All Rights Reserved : : file: ipfix.go : details: TODO : author: Mehrdad Arshad Rad : date: 02/01/2017 : : Licensed under the Apache License, Version 2.0 (the "License"); : you may not use this file except in compliance with the License. : You may obtain a copy of the License at : : http://www.apache.org/licenses/LICENSE-2.0 : : Unless required by applicable law or agreed to in writing, software : distributed under the License is distributed on an "AS IS" BASIS, : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. : See the License for the specific language governing permissions and : limitations under the License. : ----------------------------------------------------------------------------

Index

Constants

This section is empty.

Variables

View Source
var FieldTypes = map[string]FieldType{
	"unsigned8":            Uint8,
	"unsigned16":           Uint16,
	"unsigned32":           Uint32,
	"unsigned64":           Uint64,
	"signed8":              Int8,
	"signed16":             Int16,
	"signed32":             Int32,
	"signed64":             Int64,
	"float32":              Float32,
	"float64":              Float64,
	"boolean":              Boolean,
	"macAddress":           MacAddress,
	"octetArray":           OctetArray,
	"string":               String,
	"dateTimeSeconds":      DateTimeSeconds,
	"dateTimeMilliseconds": DateTimeMilliseconds,
	"dateTimeMicroseconds": DateTimeMicroseconds,
	"dateTimeNanoseconds":  DateTimeNanoseconds,
	"ipv4Address":          Ipv4Address,
	"ipv6Address":          Ipv6Address,
}

FieldTypes represents data types

Functions

func RPCServer

func RPCServer(mCache MemCache) error

Types

type Data

type Data struct {
	Template  TemplateRecords
	Timestamp int64
}

Data represents template records and updated timestamp

type DecodedField

type DecodedField struct {
	ID    uint16
	Value interface{}
}

DecodedField represents a decoded field

type Decoder

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

Decoder represents IPFIX payload and remote address

func NewDecoder

func NewDecoder(raddr net.IP, b []byte) *Decoder

NewDecoder constructs a decoder

func (*Decoder) Decode

func (d *Decoder) Decode(mem MemCache) (*Message, error)

Decode decodes the IPFIX raw data

type FieldType

type FieldType int

FieldType is IPFIX Abstract Data Types RFC5102#section-3.1

const (
	// Unknown data type
	Unknown FieldType = iota

	// Uint8 represents a non-negative integer value in the
	// range of 0 to 255.
	Uint8

	// Uint16 represents a non-negative integer value in the
	// range of 0 to 65535.
	Uint16

	// Uint32 represents a non-negative integer value in the
	// range of 0 to 4294967295.
	Uint32

	// Uint64 represents a non-negative integer value in the
	// range of 0 to 18446744073709551615.
	Uint64

	// Int8 represents an integer value in the range of -128
	// to 127.
	Int8

	// Int16 represents an integer value in the range of
	// -32768 to 32767.
	Int16

	// Int32 represents an integer value in the range of
	// -2147483648 to 2147483647.
	Int32

	// Int64 represents an integer value in the range of
	// -9223372036854775808 to 9223372036854775807.
	Int64

	// Float32 corresponds to an IEEE single-precision 32-bit
	// floating point type as defined in [IEEE.754.1985].
	Float32

	// Float64 corresponds to an IEEE double-precision 64-bit
	// floating point type as defined in [IEEE.754.1985].
	Float64

	// Boolean represents a binary value.  The only allowed
	// values are "true" and "false".
	Boolean

	// MacAddress represents a string of 6 octets.
	MacAddress

	// OctetArray represents a finite-length string of octets.
	OctetArray

	// String represents a finite-length string of valid
	String

	// DateTimeSeconds represents a time value in units of
	// seconds based on coordinated universal time (UTC).
	DateTimeSeconds

	// DateTimeMilliseconds represents a time value in units of
	// milliseconds based on coordinated universal time (UTC).
	DateTimeMilliseconds

	// DateTimeMicroseconds represents a time value in units of
	// microseconds based on coordinated universal time (UTC).
	DateTimeMicroseconds

	// DateTimeNanoseconds represents a time value in units of
	// nanoseconds based on coordinated universal time (UTC).
	DateTimeNanoseconds

	// Ipv4Address represents a value of an IPv4 address.
	Ipv4Address

	// Ipv6Address represents a value of an IPv6 address.
	Ipv6Address
)

type InfoElementEntry

type InfoElementEntry struct {
	FieldID uint16
	Name    string
	Type    FieldType
}

InfoElementEntry represents standard name and type for a field - RFC5102

type InfoModel

type InfoModel map[elementKey]InfoElementEntry

InfoModel represents IPFIX field's name, identification and type

type MemCache

type MemCache []*TemplatesShard

MemCache represents templates shards

func GetCache

func GetCache(cacheFile string) MemCache

GetCache tries to load saved templates otherwise it constructs new empty shards

func (MemCache) Dump

func (m MemCache) Dump(cacheFile string) error

Dump saves the current templates to hard disk

type Message

type Message struct {
	AgentID  string
	Header   MessageHeader
	DataSets [][]DecodedField
}

Message represents IPFIX decoded data

func (*Message) JSONMarshal

func (m *Message) JSONMarshal(b *bytes.Buffer) ([]byte, error)

JSONMarshal encodes IPFIX message

type MessageHeader

type MessageHeader struct {
	Version    uint16 // Version of IPFIX to which this Message conforms
	Length     uint16 // Total length of the IPFIX Message, measured in octets
	ExportTime uint32 // Time at which the IPFIX Message Header leaves the Exporter
	SequenceNo uint32 // Incremental sequence counter modulo 2^32
	DomainID   uint32 // A 32-bit id that is locally unique to the Exporting Process
}

MessageHeader represents IPFIX message header

type RPC

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

func NewRPC

func NewRPC(mCache MemCache) *RPC

func (*RPC) Get

func (r *RPC) Get(req Request, resp *TemplateRecords) error

type RPCClient

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

func NewRPCClient

func NewRPCClient(rAddr string) *RPCClient

func (*RPCClient) Get

func (c *RPCClient) Get(req Request) (*TemplateRecords, error)

type Reader

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

Reader represents the data bytes for reading

func NewReader

func NewReader(b []byte) *Reader

NewReader constructs a reader

func (*Reader) Len

func (r *Reader) Len() int

Len returns the current length of the reader's data

func (*Reader) Read

func (r *Reader) Read(n int) ([]byte, error)

Read reads n bytes and returns it

func (*Reader) Uint16

func (r *Reader) Uint16() (uint16, error)

Uint16 reads two bytes as big-endian

func (*Reader) Uint32

func (r *Reader) Uint32() (uint32, error)

Uint32 reads four bytes as big-endian

func (*Reader) Uint64

func (r *Reader) Uint64() (uint64, error)

Uint64 reads eight bytes as big-endian

func (*Reader) Uint8

func (r *Reader) Uint8() (uint8, error)

Uint8 reads a byte

type Request

type Request struct {
	ID uint16
	IP net.IP
}

type SetHeader

type SetHeader struct {
	SetID  uint16
	Length uint16
}

SetHeader represents set header fields

type TemplateFieldSpecifier

type TemplateFieldSpecifier struct {
	ElementID    uint16
	Length       uint16
	EnterpriseNo uint32
}

TemplateFieldSpecifier represents field properties

type TemplateHeader

type TemplateHeader struct {
	TemplateID      uint16
	FieldCount      uint16
	ScopeFieldCount uint16
}

TemplateHeader represents template fields

type TemplateRecords

type TemplateRecords struct {
	TemplateID           uint16
	FieldCount           uint16
	FieldSpecifiers      []TemplateFieldSpecifier
	ScopeFieldCount      uint16
	ScopeFieldSpecifiers []TemplateFieldSpecifier
}

TemplateRecords represents template records

type TemplatesShard

type TemplatesShard struct {
	Templates map[uint32]Data
	sync.RWMutex
}

TemplatesShard represents a shard

Jump to

Keyboard shortcuts

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