records

package
v0.0.0-...-3c379a5 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2016 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeRawPacketFlowRecord     = 1
	TypeEthernetFrameFlowRecord = 2
	TypeIpv4FlowRecord          = 3
	TypeIpv6FlowRecord          = 4

	TypeExtendedSwitchFlowRecord     = 1001
	TypeExtendedRouterFlowRecord     = 1002
	TypeExtendedGatewayFlowRecord    = 1003
	TypeExtendedUserFlowRecord       = 1004
	TypeExtendedURLFlowRecord        = 1005
	TypeExtendedMlpsFlowRecord       = 1006
	TypeExtendedNatFlowRecord        = 1007
	TypeExtendedMlpsTunnelFlowRecord = 1008
	TypeExtendedMlpsVcFlowRecord     = 1009
	TypeExtendedMlpsFecFlowRecord    = 1010
	TypeExtendedMlpsLvpFecFlowRecord = 1011
	TypeExtendedVlanFlowRecord       = 1012

	TypeExtendedSocketIPv4FlowRecord      = 2100
	TypeExtendedSocketIPv6FlowRecord      = 2101
	TypeExtendedProxySocketIPv4FlowRecord = 2102
	TypeExtendedProxySocketIPv6FlowRecord = 2103
	TypeHTTPRequestFlowRecord             = 2206
	TypeHTTPExtendedProxyFlowRecord       = 2207
)

sflow flow record types

View Source
const (
	TypeHostDescriptionCounterRecord = 2000
	TypeHTTPCounterRecord            = 2201
)

sflow counter record types

View Source
const (
	IPProtocolICMP = 1
	IPProtocolTCP  = 6
	IPProtocolUDP  = 17
	IPProtocolESP  = 50 // IPSEC
	IPProtocolAH   = 51 // IPSEC
)

IP Header Protocol Types (see: https://en.wikipedia.org/wiki/List_of_IP_protocol_numbers)

View Source
const (
	// MaximumRecordLength defines the maximum length acceptable for decoded records.
	// This maximum prevents from excessive memory allocation.
	// The value is derived from MAX_PKT_SIZ 65536 in the reference sFlow implementation
	// https://github.com/sflow/sflowtool/blob/bd3df6e11bdf/src/sflowtool.c#L4313.
	MaximumRecordLength = 65536

	// MaximumHeaderLength defines the maximum length acceptable for decoded flow samples.
	// This maximum prevents from excessive memory allocation.
	// The value is set to maximum transmission unit (MTU), as the header of a network packet
	// may not exceed the MTU.
	MaximumHeaderLength = 1500

	// MinimumEthernetHeaderSize defines the minimum header size to be parsed
	MinimumEthernetHeaderSize = 14
)
View Source
const (
	AsPathSegmentTypeUnOrdered = 1
	AsPathSegmentTypeOrdered   = 2
)

As Path Segment ordering Types

View Source
const (
	HTTPOther   = 0
	HTTPOptions = 1
	HTTPGet     = 2
	HTTPHead    = 3
	HTTPPost    = 4
	HTTPPut     = 5
	HTTPDelete  = 6
	HTTPTrace   = 7
	HTTPConnect = 8
)

HTTP Request Types

View Source
const (
	HeaderProtocolEthernetISO8023   = 1
	HeaderProtocolISO88024Tokenbus  = 2
	HeaderProtocolISO88024Tokenring = 3
	HeaderProtocolFDDI              = 4
	HeaderProtocolFrameRelay        = 5
	HeaderProtocolX24               = 6
	HeaderProtocolPPP               = 7
	HeaderProtocolSMDS              = 8
	HeaderProtocolAAL5              = 9
	HeaderProtocolAAL5IP            = 10
	HeaderProtocolIPv4              = 11
	HeaderProtocolIPv6              = 12
)

Header Protocol Types found in Raw Packet Flow Record

View Source
const (
	HeaderTypeIPv4 = "0800"
	HeaderTypeIPv6 = "86DD"
)

Raw Packet Header Types

Variables

View Source
var (
	ErrEncodingRecord = errors.New("sflow: failed to encode record")
	ErrDecodingRecord = errors.New("sflow: failed to decode record")
)

Functions

func Encode

func Encode(w io.Writer, s interface{}) error

Encode an sflow packet from 's' into 'w' - The structs datatypes define the binary representation

Types

type EthernetFrameFlow

type EthernetFrameFlow struct {
	Dot3StatsAlignmentErrors           uint32
	Dot3StatsFCSErrors                 uint32
	Dot3StatsSingleCollisionFrames     uint32
	Dot3StatsMultipleCollisionFrames   uint32
	Dot3StatsSQETestErrors             uint32
	Dot3StatsDeferredTransmissions     uint32
	Dot3StatsLateCollisions            uint32
	Dot3StatsExcessiveCollisions       uint32
	Dot3StatsInternalMacTransmitErrors uint32
	Dot3StatsCarrierSenseErrors        uint32
	Dot3StatsFrameTooLongs             uint32
	Dot3StatsInternalMacReceiveErrors  uint32
	Dot3StatsSymbolErrors              uint32
}

func DecodeEthernetFrameFlow

func DecodeEthernetFrameFlow(r io.Reader) (EthernetFrameFlow, error)

func (EthernetFrameFlow) Encode

func (f EthernetFrameFlow) Encode(w io.Writer) error

func (EthernetFrameFlow) RecordName

func (f EthernetFrameFlow) RecordName() string

RecordName returns the Name of this flow record

func (EthernetFrameFlow) RecordType

func (f EthernetFrameFlow) RecordType() int

RecordType returns the type of flow record.

func (EthernetFrameFlow) String

func (f EthernetFrameFlow) String() string

type EthernetHeader

type EthernetHeader struct {
	DstMac HardwareAddr
	SrcMac HardwareAddr
}

EthernetHeader as found in RawPacketFlow.Header

type ExtendedGatewayFlow

type ExtendedGatewayFlow struct {
	NextHopType          uint32
	NextHop              net.IP `ipVersionLookUp:"NextHopType"`
	As                   uint32
	SrcAs                uint32
	SrcPeerAs            uint32
	DstAs                uint32 `ignoreOnMarshal:"true"`
	DstPeerAs            uint32 `ignoreOnMarshal:"true"`
	DstAsPathSegmentsLen uint32
	DstAsPathSegments    []ExtendedGatewayFlowASPathSegment `lengthLookUp:"DstAsPathSegmentsLen"`
	CommunitiesLen       uint32
	Communities          []uint32 `lengthLookUp:"CommunitiesLen"`
	LocalPref            uint32
}

func (ExtendedGatewayFlow) Encode

func (f ExtendedGatewayFlow) Encode(w io.Writer) error

func (*ExtendedGatewayFlow) PostDecode

func (f *ExtendedGatewayFlow) PostDecode() error

func (ExtendedGatewayFlow) RecordName

func (f ExtendedGatewayFlow) RecordName() string

RecordName returns the Name of this flow record

func (ExtendedGatewayFlow) RecordType

func (f ExtendedGatewayFlow) RecordType() int

RecordType returns the ID of the sflow flow record

func (ExtendedGatewayFlow) String

func (f ExtendedGatewayFlow) String() string

type ExtendedGatewayFlowASPathSegment

type ExtendedGatewayFlowASPathSegment struct {
	SegType uint32 // 1: Unordered Set || 2: Ordered Set
	SegLen  uint32
	Seg     []uint32 `lengthLookUp:"SegLen"`
}

type ExtendedProxyRequestFlow

type ExtendedProxyRequestFlow struct {
}

ExtendedProxyRequest - TypeHTTPExtendedProxyFlowRecord

type ExtendedProxySocketIPv4Flow

type ExtendedProxySocketIPv4Flow struct {
	Socket ExtendedSocketIPv4Flow
}

ExtendedProxySocketIPv4 - TypeExtendedProxySocketIPv4FlowRecord

func (ExtendedProxySocketIPv4Flow) Encode

func (ExtendedProxySocketIPv4Flow) RecordName

func (f ExtendedProxySocketIPv4Flow) RecordName() string

func (ExtendedProxySocketIPv4Flow) RecordType

func (f ExtendedProxySocketIPv4Flow) RecordType() int

type ExtendedProxySocketIPv6Flow

type ExtendedProxySocketIPv6Flow struct {
	Socket ExtendedSocketIPv6Flow
}

ExtendedProxySocketIPv6 - TypeExtendedProxySocketIPv6FlowRecord

func (ExtendedProxySocketIPv6Flow) Encode

func (ExtendedProxySocketIPv6Flow) RecordName

func (f ExtendedProxySocketIPv6Flow) RecordName() string

func (ExtendedProxySocketIPv6Flow) RecordType

func (f ExtendedProxySocketIPv6Flow) RecordType() int

type ExtendedRouterFlow

type ExtendedRouterFlow struct {
	NextHopType uint32
	NextHop     net.IP `ipVersionLookUp:"NextHopType"`
	SrcMask     uint32
	DstMask     uint32
}

func (ExtendedRouterFlow) Encode

func (f ExtendedRouterFlow) Encode(w io.Writer) error

func (ExtendedRouterFlow) RecordName

func (f ExtendedRouterFlow) RecordName() string

RecordName returns the Name of this flow record

func (ExtendedRouterFlow) RecordType

func (f ExtendedRouterFlow) RecordType() int

RecordType returns the ID of the sflow flow record

func (ExtendedRouterFlow) String

func (f ExtendedRouterFlow) String() string

type ExtendedSocketIPv4Flow

type ExtendedSocketIPv4Flow struct {
	Protocol   uint32
	LocalIP    net.IP `ipVersion:"4"`
	RemoteIP   net.IP `ipVersion:"4"`
	LocalPort  uint32
	RemotePort uint32
}

ExtendedSocketIPv4Flow - TypeExtendedSocketIPv4FlowRecord

func (ExtendedSocketIPv4Flow) Encode

func (f ExtendedSocketIPv4Flow) Encode(w io.Writer) error

func (ExtendedSocketIPv4Flow) RecordName

func (f ExtendedSocketIPv4Flow) RecordName() string

func (ExtendedSocketIPv4Flow) RecordType

func (f ExtendedSocketIPv4Flow) RecordType() int

type ExtendedSocketIPv6Flow

type ExtendedSocketIPv6Flow struct {
	Protocol   uint32
	LocalIP    net.IP `ipVersion:"6"`
	RemoteIP   net.IP `ipVersion:"6"`
	LocalPort  uint32
	RemotePort uint32
}

ExtendedSocketIPv6Flow - TypeExtendedSocketIPv6FlowRecord

func (ExtendedSocketIPv6Flow) Encode

func (f ExtendedSocketIPv6Flow) Encode(w io.Writer) error

func (ExtendedSocketIPv6Flow) RecordName

func (f ExtendedSocketIPv6Flow) RecordName() string

func (ExtendedSocketIPv6Flow) RecordType

func (f ExtendedSocketIPv6Flow) RecordType() int

type ExtendedSwitchFlow

type ExtendedSwitchFlow struct {
	SourceVlan          uint32
	SourcePriority      uint32
	DestinationVlan     uint32
	DestinationPriority uint32
}

ExtendedSwitchFlow is an extended switch flow record.

func (ExtendedSwitchFlow) Encode

func (f ExtendedSwitchFlow) Encode(w io.Writer) error

func (ExtendedSwitchFlow) RecordName

func (f ExtendedSwitchFlow) RecordName() string

RecordName returns the Name of this flow record

func (ExtendedSwitchFlow) RecordType

func (f ExtendedSwitchFlow) RecordType() int

RecordType returns the ID of the sflow flow record

func (ExtendedSwitchFlow) String

func (f ExtendedSwitchFlow) String() string

type HTTPCounter

type HTTPCounter struct {
	MethodOptionCount  uint32
	MethodGetCount     uint32
	MethodHeadCount    uint32
	MethodPostCount    uint32
	MethodPutCount     uint32
	MethodDeleteCount  uint32
	MethodTraceCount   uint32
	MethodConnectCount uint32
	MethodOtherCount   uint32
	Status1XXCount     uint32
	Status2XXCount     uint32
	Status3XXCount     uint32
	Status4XXCount     uint32
	Status5XXCount     uint32
	StatusOtherCount   uint32
}

HTTPCounters - TypeHTTPCounterRecord

func (HTTPCounter) Encode

func (f HTTPCounter) Encode(w io.Writer) error

func (HTTPCounter) RecordName

func (f HTTPCounter) RecordName() string

RecordName returns the Name of this flow record

func (HTTPCounter) RecordType

func (f HTTPCounter) RecordType() int

RecordType returns the ID of the sflow flow record

type HTTPRequestFlow

type HTTPRequestFlow struct {
	Method       uint32
	Protocol     uint32 /* HTTP protocol version: Encoded as major_number * 1000 + minor_number. e.g. HTTP1.1 is encoded as 1001 */
	URILen       uint32
	URI          []byte `lengthLookUp:"URILen"` /* URI exactly as it came from the client */
	HostLen      uint32
	Host         []byte `lengthLookUp:"HostLen"` /* Host value from request header */
	RefererLen   uint32
	Referer      []byte `lengthLookUp:"RefererLen"` /* Referer value from request header */
	UserAgentLen uint32
	UserAgent    []byte `lengthLookUp:"UserAgentLen"` /* User-Agent value from request header */
	XFFLen       uint32
	XFF          []byte `lengthLookUp:"XFFLen"` /* X-Forwarded-For value from request header */
	AuthUserLen  uint32
	AuthUser     []byte `lengthLookUp:"AuthUserLen"` /* RFC 1413 identity of user*/
	MimeTypeLen  uint32
	MimeType     []byte `lengthLookUp:"MimeTypeLen"` /* Mime-Type of response */
	ReqBytes     uint64 /* Content-Length of request */
	RespBytes    uint64 /* Content-Length of response */
	Duration     uint32 /* duration of the operation (in microseconds) */
	Status       uint32 /* HTTP status code */
}

HTTPRequestFlow - TypeHTTPRequestFlowRecord

func (HTTPRequestFlow) Encode

func (f HTTPRequestFlow) Encode(w io.Writer) error

func (HTTPRequestFlow) RecordName

func (f HTTPRequestFlow) RecordName() string

RecordName returns the Name of this flow record

func (HTTPRequestFlow) RecordType

func (f HTTPRequestFlow) RecordType() int

RecordType returns the ID of the sflow flow record

type HardwareAddr

type HardwareAddr net.HardwareAddr

HardwareAddr alias of net.HardwareAddr to be able to add JSON Marhshalling

func (HardwareAddr) MarshalJSON

func (e HardwareAddr) MarshalJSON() ([]byte, error)

MarshalJSON creates a human-readable string representation of a HardwareAddr

func (*HardwareAddr) UnmarshalJSON

func (e *HardwareAddr) UnmarshalJSON(value []byte) error

UnmarshalJSON reads a MAC Address via net.ParseMAC into HardwareAddr

type ICMPHeader

type ICMPHeader struct {
	Type uint8
	Code uint8
}

ICMPHeader as found in RawPacketFlow.Header

type IPv4Header

type IPv4Header struct {
	VersionAndLen uint8
	Tos           uint8
	TotLen        uint16
	ID            uint16
	FragOff       uint16
	TTL           uint8
	Protocol      uint8
	Check         uint16
	SrcAddr       net.IP `ipVersion:"4"`
	DstAddr       net.IP `ipVersion:"4"`
}

IPv4Header as found in RawPacketFlow.Header

type IPv6Header

type IPv6Header struct {
	VersionAndPriority uint8
	Label1             uint8
	Label2             uint8
	Label3             uint8
	PayloadLength      uint16
	NextHeader         uint8
	TTL                uint8
	SrcAddr            net.IP `ipVersion:"6"`
	DstAddr            net.IP `ipVersion:"6"`
}

IPv6Header as found in RawPacketFlow.Header

type PostDecoder

type PostDecoder interface {
	PostDecode() error
}

type RawPacketFlow

type RawPacketFlow struct {
	Protocol      uint32
	FrameLength   uint32
	Stripped      uint32
	HeaderSize    uint32
	Header        []byte
	DecodedHeader map[string]interface{}
}

RawPacketFlow is a raw Ethernet header flow record.

func DecodeRawPacketFlow

func DecodeRawPacketFlow(r io.Reader) (RawPacketFlow, error)

DecodeRawPacketFlow decodes an TypeRawPacketFlowRecord

func (RawPacketFlow) Encode

func (f RawPacketFlow) Encode(w io.Writer) error

Encode create the binary sflow representation of f

func (RawPacketFlow) RecordName

func (f RawPacketFlow) RecordName() string

RecordName returns the Name of this flow record

func (RawPacketFlow) RecordType

func (f RawPacketFlow) RecordType() int

RecordType returns the type of flow record.

func (RawPacketFlow) String

func (f RawPacketFlow) String() string

type Record

type Record interface {
	RecordType() int
	RecordName() string
	Encode(w io.Writer) error
}

func DecodeCounter

func DecodeCounter(r io.Reader, recordType uint32) (Record, error)

func DecodeFlow

func DecodeFlow(r io.Reader, recordType uint32) (Record, error)

type TCPHeader

type TCPHeader struct {
	SrcPort  uint16
	DstPort  uint16
	Seq      uint32
	Ack      uint32
	UnUsed   uint8
	Flags    uint8
	Window   uint16
	Checksum uint16
	Urgent   uint16
}

TCPHeader as found in RawPacketFlow.Header

type UDPHeader

type UDPHeader struct {
	SrcPort  uint16
	DstPort  uint16
	Length   uint16
	Checksum uint16
}

UDPHeader as found in RawPacketFlow.Header

Jump to

Keyboard shortcuts

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