flow

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2017 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CaptureLength uint32 = 256
)
View Source
const (
	Namespace = "Flow"
)

Variables

View Source
var ErrFlowProtocol = errors.New("FlowProtocol invalid")
View Source
var LayerTypeInGRE = gopacket.RegisterLayerType(55555, gopacket.LayerTypeMetadata{Name: "LayerTypeInGRE", Decoder: gopacket.DecodeFunc(decodeInGRELayer)})

Create a layer type, should be unique and high, so it doesn't conflict, giving it a name and a decoder to use.

View Source
var LayerTypeInMplsEthOrIp = gopacket.RegisterLayerType(55556, gopacket.LayerTypeMetadata{Name: "LayerTypeInMplsEthOrIp", Decoder: gopacket.DecodeFunc(decodeInMplsEthOrIpLayer)})

Try to find if the next layer is IPv4, or IPv6. If it fails, it considers it is Ethernet.

Functions

func BPFFilterToRaw added in v0.10.0

func BPFFilterToRaw(linkType layers.LinkType, captureLength uint32, filter string) ([]bpf.RawInstruction, error)

func HashFromValues added in v0.4.0

func HashFromValues(ab interface{}, ba interface{}) []byte

func NewFilterForFlowSet added in v0.10.0

func NewFilterForFlowSet(flowset *FlowSet) *filters.Filter

func NewFilterForNodeTIDs added in v0.10.0

func NewFilterForNodeTIDs(uuids []string) *filters.Filter

func NewFilterForNodes added in v0.5.0

func NewFilterForNodes(nodes []*graph.Node) *filters.Filter

Types

type BPF added in v0.10.0

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

func NewBPF added in v0.10.0

func NewBPF(linkType layers.LinkType, captureLength uint32, filter string) (*BPF, error)

func (*BPF) Matches added in v0.10.0

func (b *BPF) Matches(data []byte) bool

type ExpireUpdateFunc added in v0.3.0

type ExpireUpdateFunc func(f []*Flow)

type FlowEnhancer added in v0.10.0

type FlowEnhancer interface {
	Enhance(flow *Flow)
}

type FlowEnhancerPipeline added in v0.10.0

type FlowEnhancerPipeline struct {
	Enhancers []FlowEnhancer
}

func NewFlowEnhancerPipeline added in v0.10.0

func NewFlowEnhancerPipeline(enhancers ...FlowEnhancer) *FlowEnhancerPipeline

func (*FlowEnhancerPipeline) AddEnhancer added in v0.10.0

func (fe *FlowEnhancerPipeline) AddEnhancer(e FlowEnhancer)

func (*FlowEnhancerPipeline) Enhance added in v0.10.0

func (fe *FlowEnhancerPipeline) Enhance(flows []*Flow)

func (*FlowEnhancerPipeline) EnhanceFlow added in v0.10.0

func (fe *FlowEnhancerPipeline) EnhanceFlow(flow *Flow)

type FlowHandler added in v0.4.0

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

func NewFlowHandler added in v0.4.0

func NewFlowHandler(callback ExpireUpdateFunc, every time.Duration) *FlowHandler

type FlowKey

type FlowKey string

func FlowKeyFromGoPacket added in v0.4.0

func FlowKeyFromGoPacket(p *gopacket.Packet, parentUUID string) FlowKey

func (FlowKey) String

func (f FlowKey) String() string

type FlowPacket added in v0.8.0

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

type FlowPackets added in v0.8.0

type FlowPackets struct {
	Packets   []FlowPacket
	Timestamp int64
}

FlowPackets represents a suite of parent/child FlowPacket

func FlowPacketsFromGoPacket added in v0.8.0

func FlowPacketsFromGoPacket(packet *gopacket.Packet, outerLength int64, t int64, bpf *BPF) *FlowPackets

FlowPacketsFromGoPacket split original packet into multiple packets in case of encapsulation like GRE, VXLAN, etc.

func FlowPacketsFromSFlowSample added in v0.8.0

func FlowPacketsFromSFlowSample(sample *layers.SFlowFlowSample, t int64, bpf *BPF) []*FlowPackets

FlowPacketsFromSFlowSample returns an array of FlowPackets as a sample contains mutlple records which generate a FlowPackets each.

type GetAttr added in v0.5.0

type GetAttr interface {
	GetAttr(name string) interface{}
}

type InGRELayer added in v0.8.0

type InGRELayer struct {
	StrangeHeader []byte
	// contains filtered or unexported fields
}

func (InGRELayer) LayerContents added in v0.8.0

func (m InGRELayer) LayerContents() []byte

func (InGRELayer) LayerPayload added in v0.8.0

func (m InGRELayer) LayerPayload() []byte

func (InGRELayer) LayerType added in v0.8.0

func (m InGRELayer) LayerType() gopacket.LayerType

type MergeContext added in v0.7.0

type MergeContext struct {
	Sort      bool
	SortBy    string
	SortOrder common.SortOrder
	Dedup     bool
	DedupBy   string
}

type PcapWriter added in v0.10.0

type PcapWriter struct {
	sync.WaitGroup
	// contains filtered or unexported fields
}

func NewPcapWriter added in v0.10.0

func NewPcapWriter(r io.ReadCloser, packetsChan chan *FlowPackets, replay bool, bpfFilter string) (*PcapWriter, error)

func (*PcapWriter) FeedFlowTable added in v0.10.0

func (p *PcapWriter) FeedFlowTable()

func (*PcapWriter) Start added in v0.10.0

func (p *PcapWriter) Start()

func (*PcapWriter) Stop added in v0.10.0

func (p *PcapWriter) Stop()

type Table added in v0.4.0

type Table struct {
	PacketsChan chan *FlowPackets
	// contains filtered or unexported fields
}

func NewTable added in v0.4.0

func NewTable(updateHandler *FlowHandler, expireHandler *FlowHandler, pipeline *FlowEnhancerPipeline) *Table

func (*Table) Query added in v0.4.0

func (ft *Table) Query(query *TableQuery) *TableReply

func (*Table) Run added in v0.7.0

func (ft *Table) Run()

func (*Table) SetNodeTID added in v0.9.0

func (ft *Table) SetNodeTID(tid string)

func (*Table) Start added in v0.4.0

func (ft *Table) Start() chan *FlowPackets

func (*Table) Stop added in v0.4.0

func (ft *Table) Stop()

type TableAllocator added in v0.4.0

type TableAllocator struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewTableAllocator added in v0.4.0

func NewTableAllocator(update, expire time.Duration, pipeline *FlowEnhancerPipeline) *TableAllocator

func (*TableAllocator) Alloc added in v0.4.0

func (a *TableAllocator) Alloc(flowCallBack ExpireUpdateFunc) *Table

func (*TableAllocator) QueryTable added in v0.4.0

func (a *TableAllocator) QueryTable(query *TableQuery) *TableReply

func (*TableAllocator) Release added in v0.4.0

func (a *TableAllocator) Release(t *Table)

type TableClient added in v0.4.0

type TableClient struct {
	shttp.DefaultWSServerEventHandler
	WSServer *shttp.WSServer
	// contains filtered or unexported fields
}

func NewTableClient added in v0.4.0

func NewTableClient(w *shttp.WSServer) *TableClient

func (*TableClient) LookupFlows added in v0.5.0

func (f *TableClient) LookupFlows(flowSearchQuery filters.SearchQuery) (*FlowSet, error)

func (*TableClient) LookupFlowsByNodes added in v0.4.0

func (f *TableClient) LookupFlowsByNodes(hnmap topology.HostNodeTIDMap, flowSearchQuery filters.SearchQuery) (*FlowSet, error)

func (*TableClient) OnMessage added in v0.4.0

func (f *TableClient) OnMessage(c *shttp.WSClient, m shttp.WSMessage)

type TableQuery added in v0.4.0

type TableQuery struct {
	Type string
	Obj  []byte
}

TableQuery contains a type and a query obj as an array of bytes. The query can be encoded in different ways according the type.

type TableReply added in v0.4.0

type TableReply struct {
	Obj [][]byte
	// contains filtered or unexported fields
}

TableReply is the response to a TableQuery containing a Status and an array of replies that can be encoded in many ways, ex: json, protobuf.

type TableServer added in v0.4.0

type TableServer struct {
	shttp.DefaultWSClientEventHandler
	WSAsyncClientPool *shttp.WSAsyncClientPool
	TableAllocator    *TableAllocator
}

func NewServer added in v0.4.0

func NewServer(allocator *TableAllocator, wspool *shttp.WSAsyncClientPool) *TableServer

func (*TableServer) OnMessage added in v0.4.0

func (s *TableServer) OnMessage(c *shttp.WSAsyncClient, msg shttp.WSMessage)

func (*TableServer) OnTableQuery added in v0.5.0

func (s *TableServer) OnTableQuery(c *shttp.WSAsyncClient, msg shttp.WSMessage)

Source Files

  • allocator.go
  • bpf.go
  • client.go
  • decoder.go
  • filters.go
  • flow.go
  • hash.go
  • metrics.go
  • pcap.go
  • pipeline.go
  • server.go
  • set.go
  • table.go

Directories

Path Synopsis
afpacket
Package afpacket provides Go bindings for MMap'd AF_PACKET socket reading.
Package afpacket provides Go bindings for MMap'd AF_PACKET socket reading.

Jump to

Keyboard shortcuts

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