topology

package
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OwnershipLink = "ownership"
	Layer2Link    = "layer2"
)

ErrNetworkPathNotFound

Variables

View Source
var (
	// IPv4DefaultRoute default IPv4 route
	IPv4DefaultRoute = net.IPNet{IP: net.IPv4zero, Mask: net.CIDRMask(0, 8*net.IPv4len)}

	// IPv6DefaultRoute default IPv6 route
	IPv6DefaultRoute = net.IPNet{IP: net.IPv6zero, Mask: net.CIDRMask(0, 8*net.IPv6len)}
)
View Source
var ErrInvalidSchema = errors.New("Invalid schema")

ErrInvalidSchema is return when a JSON schema is invalid

View Source
var (
	// ErrNoPathToHost is called when no host could be found as the parent of a node
	ErrNoPathToHost = func(name string) error { return fmt.Errorf("Failed to determine network namespace path for %s", name) }
)

Functions

func AddLayer2Link(g *graph.Graph, node1 *graph.Node, node2 *graph.Node, metadata graph.Metadata) (*graph.Edge, error)

AddLayer2Link links the parent and the child node

func AddLink(g *graph.Graph, node1 *graph.Node, node2 *graph.Node, relationType string, metadata graph.Metadata) (*graph.Edge, error)

AddLink links the parent and the child node with the specified relation type and metadata

func AddOwnershipLink(g *graph.Graph, parent *graph.Node, child *graph.Node, metadata graph.Metadata) (*graph.Edge, error)

AddOwnershipLink Link between the parent and the child node, the child can have only one parent, previous will be overwritten

func GetOwnershipLink(g *graph.Graph, parent *graph.Node, child *graph.Node) *graph.Edge

GetOwnershipLink get ownership Link between the parent and the child node or nil

func HaveLayer2Link(g *graph.Graph, node1 *graph.Node, node2 *graph.Node) bool

HaveLayer2Link returns true if parent and child have the same layer 2

func HaveLink(g *graph.Graph, node1 *graph.Node, node2 *graph.Node, relationType string) bool

HaveLink returns true if parent and child are linked

func HaveOwnershipLink(g *graph.Graph, parent *graph.Node, child *graph.Node) bool

HaveOwnershipLink returns true if parent and child have an ownership link

func InterfaceMetricMetadataDecoder added in v0.21.0

func InterfaceMetricMetadataDecoder(raw json.RawMessage) (common.Getter, error)

InterfaceMetricMetadataDecoder implements a json message raw decoder

func IsInterfaceUp added in v0.21.0

func IsInterfaceUp(node *graph.Node) bool

IsInterfaceUp returns whether an interface has the flag UP set

func IsOwnershipLinked added in v0.13.0

func IsOwnershipLinked(g *graph.Graph, node *graph.Node) bool

IsOwnershipLinked checks whether the node has an OwnershipLink

func Layer2Metadata added in v0.11.0

func Layer2Metadata() graph.Metadata

Layer2Metadata returns metadata for a layer2 link

func NamespaceFromNode added in v0.12.0

func NamespaceFromNode(g *graph.Graph, n *graph.Node) (string, string, error)

NamespaceFromNode returns the namespace name and the path of a node in the graph

func NeighborMetadataDecoder added in v0.24.0

func NeighborMetadataDecoder(raw json.RawMessage) (common.Getter, error)

NeighborMetadataDecoder implements a json message raw decoder

func NewLink(g *graph.Graph, node1 *graph.Node, node2 *graph.Node, relationType string, metadata graph.Metadata) (*graph.Edge, error)

NewLink creates a link between a parent and a child node with the specified relation type and metadata

func NewNetNSContextByNode added in v0.8.0

func NewNetNSContextByNode(g *graph.Graph, n *graph.Node) (*common.NetNSContext, error)

NewNetNSContextByNode creates a new network namespace context based on the node

func OwnershipMetadata added in v0.11.0

func OwnershipMetadata() graph.Metadata

OwnershipMetadata returns metadata for an ownership link

func RoutingTablesMetadataDecoder added in v0.24.0

func RoutingTablesMetadataDecoder(raw json.RawMessage) (common.Getter, error)

RoutingTablesMetadataDecoder implements a json message raw decoder

Types

type HostNodeTIDMap added in v0.9.0

type HostNodeTIDMap map[string][]string

HostNodeTIDMap a map that store the value node TID and the key node host

func BuildHostNodeTIDMap added in v0.9.0

func BuildHostNodeTIDMap(nodes []*graph.Node) HostNodeTIDMap

BuildHostNodeTIDMap creates a new node and host (key) map

type InterfaceMetric added in v0.16.0

type InterfaceMetric struct {
	Collisions        int64 `json:"Collisions,omitempty"`
	Multicast         int64 `json:"Multicast,omitempty"`
	RxBytes           int64 `json:"RxBytes,omitempty"`
	RxCompressed      int64 `json:"RxCompressed,omitempty"`
	RxCrcErrors       int64 `json:"RxCrcErrors,omitempty"`
	RxDropped         int64 `json:"RxDropped,omitempty"`
	RxErrors          int64 `json:"RxErrors,omitempty"`
	RxFifoErrors      int64 `json:"RxFifoErrors,omitempty"`
	RxFrameErrors     int64 `json:"RxFrameErrors,omitempty"`
	RxLengthErrors    int64 `json:"RxLengthErrors,omitempty"`
	RxMissedErrors    int64 `json:"RxMissedErrors,omitempty"`
	RxOverErrors      int64 `json:"RxOverErrors,omitempty"`
	RxPackets         int64 `json:"RxPackets,omitempty"`
	TxAbortedErrors   int64 `json:"TxAbortedErrors,omitempty"`
	TxBytes           int64 `json:"TxBytes,omitempty"`
	TxCarrierErrors   int64 `json:"TxCarrierErrors,omitempty"`
	TxCompressed      int64 `json:"TxCompressed,omitempty"`
	TxDropped         int64 `json:"TxDropped,omitempty"`
	TxErrors          int64 `json:"TxErrors,omitempty"`
	TxFifoErrors      int64 `json:"TxFifoErrors,omitempty"`
	TxHeartbeatErrors int64 `json:"TxHeartbeatErrors,omitempty"`
	TxPackets         int64 `json:"TxPackets,omitempty"`
	TxWindowErrors    int64 `json:"TxWindowErrors,omitempty"`
	Start             int64 `json:"Start,omitempty"`
	Last              int64 `json:"Last,omitempty"`
}

InterfaceMetric the interface packets counters easyjson:json gendecoder

func (*InterfaceMetric) Add added in v0.16.0

Add sum two metrics and return a new Metrics object

func (*InterfaceMetric) GetLast added in v0.16.0

func (im *InterfaceMetric) GetLast() int64

GetLast returns last time

func (*InterfaceMetric) GetStart added in v0.16.0

func (im *InterfaceMetric) GetStart() int64

GetStart returns start time

func (*InterfaceMetric) IsZero added in v0.16.0

func (im *InterfaceMetric) IsZero() bool

IsZero returns true if all the values are equal to zero

func (*InterfaceMetric) SetLast added in v0.16.0

func (im *InterfaceMetric) SetLast(last int64)

SetLast set last tome

func (*InterfaceMetric) SetStart added in v0.16.0

func (im *InterfaceMetric) SetStart(start int64)

SetStart set start time

func (*InterfaceMetric) Split added in v0.17.0

func (im *InterfaceMetric) Split(cut int64) (common.Metric, common.Metric)

Split splits a metric into two parts

func (*InterfaceMetric) Sub added in v0.16.0

Sub subtracts two metrics and return a new metrics object

type Neighbor added in v0.24.0

type Neighbor struct {
	Flags   []string `json:"Flags,omitempty"`
	MAC     string   `json:"MAC,omitempty"`
	IP      net.IP   `json:"IP,omitempty"`
	State   []string `json:"State,omitempty"`
	Vlan    int64    `json:"Vlan,omitempty"`
	VNI     int64    `json:"VNI,omitempty"`
	IfIndex int64
}

Neighbor describes a member of the forwarding database easyjson:json gendecoder

type Neighbors added in v0.24.0

type Neighbors []*Neighbor

Neighbors describes a list of neighbors easyjson:json gendecoder

type NextHop added in v0.24.0

type NextHop struct {
	Priority int64  `json:"Priority"`
	IP       net.IP `json:"IP,omitempty"`
	MAC      string `json:"MAC,omitempty"`
	IfIndex  int64  `json:"IfIndex"`
}

NextHop describes a next hop easyjson:json gendecoder

func GetNextHop added in v0.24.0

func GetNextHop(node *graph.Node, ip net.IP) (*NextHop, error)

GetNextHop returns the next hop to reach a specified IP

type Prefix added in v0.24.0

type Prefix net.IPNet

Prefix describes prefix

func (*Prefix) IsDefaultRoute added in v0.24.0

func (p *Prefix) IsDefaultRoute() bool

IsDefaultRoute return whether the given cidr is a default route

func (*Prefix) MarshalJSON added in v0.24.0

func (p *Prefix) MarshalJSON() ([]byte, error)

MarshalJSON custom marshal function

func (*Prefix) String added in v0.24.0

func (p *Prefix) String() string

func (*Prefix) UnmarshalJSON added in v0.24.0

func (p *Prefix) UnmarshalJSON(b []byte) error

UnmarshalJSON custom unmarshal function

type Route added in v0.24.0

type Route struct {
	Protocol int64      `json:"Protocol"`
	Prefix   Prefix     `json:"Prefix"`
	NextHops []*NextHop `json:"NextHops"`
}

Route describes a route easyjson:json gendecoder

func (*Route) GetNextHop added in v0.24.0

func (r *Route) GetNextHop(ip net.IP, ifIndex int64) *NextHop

GetNextHop returns the nexthop for the given ip and ifindex

func (*Route) GetOrCreateNextHop added in v0.24.0

func (r *Route) GetOrCreateNextHop(ip net.IP, ifIndex int64, priority int64) *NextHop

GetOrCreateNextHop creates if not existing a new nexthop and returns it

type RoutingTable added in v0.24.0

type RoutingTable struct {
	ID     int64    `json:"ID"`
	Src    net.IP   `json:"Src"`
	Routes []*Route `json:"Routes"`
}

RoutingTable describes a list of Routes easyjson:json gendecoder

func (*RoutingTable) GetOrCreateRoute added in v0.24.0

func (rt *RoutingTable) GetOrCreateRoute(protocol int64, prefix net.IPNet) *Route

GetOrCreateRoute creates if not existing a new route and returns it

func (*RoutingTable) GetRoute added in v0.24.0

func (rt *RoutingTable) GetRoute(protocol int64, prefix net.IPNet) *Route

GetRoute returns route for the given protocol and prefix

type RoutingTables added in v0.24.0

type RoutingTables []*RoutingTable

RoutingTables describes a list of routing table easyjson:json gendecoder

type SchemaValidator added in v0.20.0

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

SchemaValidator validates graph nodes and edges using a JSON schema

func NewSchemaValidator added in v0.20.0

func NewSchemaValidator() (*SchemaValidator, error)

NewSchemaValidator returns a new JSON schema validator for graph nodes and edges. based on JSON schema bundled with go-bindata

func (*SchemaValidator) ValidateEdge added in v0.20.0

func (v *SchemaValidator) ValidateEdge(edge *graph.Edge) error

ValidateEdge valides a graph edge

func (*SchemaValidator) ValidateNode added in v0.20.0

func (v *SchemaValidator) ValidateNode(node *graph.Node) error

ValidateNode valides a graph node

type TIDMapper added in v0.6.0

type TIDMapper struct {
	graph.DefaultGraphListener
	Graph *graph.Graph
	// contains filtered or unexported fields
}

TIDMapper describes the hostID nodes stored in a graph the mapper will broadcast node event to the registered listeners

func NewTIDMapper added in v0.6.0

func NewTIDMapper(g *graph.Graph) *TIDMapper

NewTIDMapper creates a new node mapper in the graph g

func (*TIDMapper) OnEdgeAdded added in v0.6.0

func (t *TIDMapper) OnEdgeAdded(e *graph.Edge)

OnEdgeAdded event

func (*TIDMapper) OnEdgeDeleted added in v0.11.0

func (t *TIDMapper) OnEdgeDeleted(e *graph.Edge)

OnEdgeDeleted event

func (*TIDMapper) OnEdgeUpdated added in v0.6.0

func (t *TIDMapper) OnEdgeUpdated(e *graph.Edge)

OnEdgeUpdated event

func (*TIDMapper) OnNodeAdded added in v0.6.0

func (t *TIDMapper) OnNodeAdded(n *graph.Node)

OnNodeAdded evetn

func (*TIDMapper) OnNodeUpdated added in v0.6.0

func (t *TIDMapper) OnNodeUpdated(n *graph.Node)

OnNodeUpdated event

func (*TIDMapper) Start added in v0.6.0

func (t *TIDMapper) Start()

Start the mapper

func (*TIDMapper) Stop added in v0.6.0

func (t *TIDMapper) Stop()

Stop the mapper

Jump to

Keyboard shortcuts

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