router

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2015 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChannelSize         = 16
	MaxUDPPacketSize    = 65535
	FastHeartbeat       = 500 * time.Millisecond
	SlowHeartbeat       = 10 * time.Second
	MaxMissedHeartbeats = 6
	HeartbeatTimeout    = MaxMissedHeartbeats * SlowHeartbeat
	MaxDuration         = time.Duration(math.MaxInt64)
	NameSize            = mesh.NameSize
)
View Source
const (
	EthernetOverhead  = 14
	UDPOverhead       = 28 // 20 bytes for IPv4, 8 bytes for UDP
	DefaultMTU        = 65535
	FragTestSize      = 60001
	PMTUDiscoverySize = 60000
	FragTestInterval  = 5 * time.Minute
	MTUVerifyAttempts = 8
	MTUVerifyTimeout  = 10 * time.Millisecond // doubled with each attempt

	ProtocolConnectionEstablished = mesh.ProtocolReserved1
	ProtocolFragmentationReceived = mesh.ProtocolReserved2
	ProtocolPMTUVerified          = mesh.ProtocolReserved3
)
View Source
const (
	FastDatapathHeartbeatAck = iota
)
View Source
const (
	WindowSize = 20 // bits
)

Variables

This section is empty.

Functions

func PosixError

func PosixError(err error) error

Look inside an error produced by the net package to get to the syscall.Errno at the root of the problem.

Types

type Bridge added in v1.2.0

type Bridge interface {
	// Inject a packet to be delivered locally
	InjectPacket(PacketKey) FlowOp

	// Start consuming packets from the bridge.  Injected packets
	// should not be included.
	StartConsumingPackets(BridgeConsumer) error

	String() string
	Stats() map[string]int
}

Interface to packet handling on the local virtual bridge

func NewPcap added in v1.2.0

func NewPcap(iface *net.Interface, bufSz int) (Bridge, error)

type BridgeConsumer added in v1.2.0

type BridgeConsumer func(PacketKey) FlowOp

A function that determines how to handle locally captured packets.

type Decryptor

type Decryptor interface {
	IterateFrames([]byte, FrameConsumer) error
}

type DiscardingFlowOp added in v1.2.0

type DiscardingFlowOp struct{}

func (DiscardingFlowOp) Discards added in v1.2.0

func (DiscardingFlowOp) Discards() bool

func (DiscardingFlowOp) Process added in v1.2.0

func (DiscardingFlowOp) Process([]byte, *EthernetDecoder, bool)

type Encryptor

type Encryptor interface {
	FrameOverhead() int
	PacketOverhead() int
	Bytes() ([]byte, error)
	AppendFrame(src []byte, dst []byte, frame []byte)
	TotalLen() int
}

type EthernetDecoder

type EthernetDecoder struct {
	Eth layers.Ethernet
	IP  layers.IPv4
	// contains filtered or unexported fields
}

func NewEthernetDecoder

func NewEthernetDecoder() *EthernetDecoder

func (*EthernetDecoder) DF added in v1.1.0

func (dec *EthernetDecoder) DF() bool

func (*EthernetDecoder) DecodeLayers

func (dec *EthernetDecoder) DecodeLayers(data []byte)

func (*EthernetDecoder) IsSpecial added in v0.9.0

func (dec *EthernetDecoder) IsSpecial() bool

func (*EthernetDecoder) PacketKey added in v1.2.0

func (dec *EthernetDecoder) PacketKey() (key PacketKey)

type FastDatapath added in v1.2.0

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

func NewFastDatapath added in v1.2.0

func NewFastDatapath(config FastDatapathConfig) (*FastDatapath, error)

func (*FastDatapath) Bridge added in v1.2.0

func (fastdp *FastDatapath) Bridge() Bridge

func (*FastDatapath) Close added in v1.2.0

func (fastdp *FastDatapath) Close() error

func (*FastDatapath) Error added in v1.2.0

func (fastdp *FastDatapath) Error(err error, stopped bool)

func (*FastDatapath) Miss added in v1.2.0

func (fastdp *FastDatapath) Miss(packet []byte, fks odp.FlowKeys) error

func (*FastDatapath) Overlay added in v1.2.0

func (fastdp *FastDatapath) Overlay() NetworkOverlay

func (*FastDatapath) VportCreated added in v1.2.0

func (fastdp *FastDatapath) VportCreated(dpid odp.DatapathID, vport odp.Vport) error

func (*FastDatapath) VportDeleted added in v1.2.0

func (fastdp *FastDatapath) VportDeleted(dpid odp.DatapathID, vport odp.Vport) error

type FastDatapathConfig added in v1.2.0

type FastDatapathConfig struct {
	DatapathName        string
	Port                int
	ExpireFlowsInterval time.Duration
	ExpireMACsInterval  time.Duration
}

type FlowOp added in v1.2.0

type FlowOp interface {
	// The caller must supply an EthernetDecoder specific to this
	// thread, which has already been used to decode the frame.
	// The broadcast parameter is a hint whether the packet is
	// being broadcast.
	Process(frame []byte, dec *EthernetDecoder, broadcast bool)

	// Does the FlowOp discard the packet?
	Discards() bool
}

func FlattenFlowOp added in v1.2.0

func FlattenFlowOp(fop FlowOp) []FlowOp

type FlowStatus added in v1.2.0

type FlowStatus odp.FlowInfo

func (*FlowStatus) MarshalJSON added in v1.2.0

func (flowStatus *FlowStatus) MarshalJSON() ([]byte, error)

type ForwardPacketKey added in v1.2.0

type ForwardPacketKey struct {
	SrcPeer *mesh.Peer
	DstPeer *mesh.Peer
	PacketKey
}

type FrameConsumer

type FrameConsumer func(src []byte, dst []byte, frame []byte)

type MAC added in v1.2.0

type MAC [6]byte

func (MAC) String added in v1.2.0

func (mac MAC) String() string

type MACStatus added in v1.1.0

type MACStatus struct {
	Mac      string
	Name     string
	NickName string
	LastSeen time.Time
}

func NewMACStatusSlice added in v1.1.0

func NewMACStatusSlice(cache *MacCache) []MACStatus

type MacCache

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

func NewMacCache

func NewMacCache(maxAge time.Duration, onExpiry func(net.HardwareAddr, *mesh.Peer)) *MacCache

func (*MacCache) Add added in v1.2.0

func (cache *MacCache) Add(mac net.HardwareAddr, peer *mesh.Peer) (bool, *mesh.Peer)

func (*MacCache) AddForced added in v1.2.0

func (cache *MacCache) AddForced(mac net.HardwareAddr, peer *mesh.Peer) (bool, *mesh.Peer)

func (*MacCache) Delete

func (cache *MacCache) Delete(peer *mesh.Peer) bool

func (*MacCache) Lookup

func (cache *MacCache) Lookup(mac net.HardwareAddr) *mesh.Peer

type MacCacheEntry

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

type MultiFlowOp added in v1.2.0

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

func NewMultiFlowOp added in v1.2.0

func NewMultiFlowOp(broadcast bool, ops ...FlowOp) *MultiFlowOp

func (*MultiFlowOp) Add added in v1.2.0

func (mfop *MultiFlowOp) Add(op FlowOp)

func (*MultiFlowOp) Discards added in v1.2.0

func (mfop *MultiFlowOp) Discards() bool

func (*MultiFlowOp) Process added in v1.2.0

func (mfop *MultiFlowOp) Process(frame []byte, dec *EthernetDecoder, broadcast bool)

type NaClDecryptor

type NaClDecryptor struct {
	NonDecryptor
	// contains filtered or unexported fields
}

func NewNaClDecryptor

func NewNaClDecryptor(sessionKey *[32]byte, outbound bool) *NaClDecryptor

func (*NaClDecryptor) IterateFrames

func (nd *NaClDecryptor) IterateFrames(packet []byte, consumer FrameConsumer) error

type NaClDecryptorInstance

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

func NewNaClDecryptorInstance added in v0.11.0

func NewNaClDecryptorInstance(outbound bool) *NaClDecryptorInstance

type NaClEncryptor

type NaClEncryptor struct {
	NonEncryptor
	// contains filtered or unexported fields
}

func NewNaClEncryptor

func NewNaClEncryptor(prefix []byte, sessionKey *[32]byte, outbound bool, df bool) *NaClEncryptor

func (*NaClEncryptor) Bytes

func (ne *NaClEncryptor) Bytes() ([]byte, error)

func (*NaClEncryptor) PacketOverhead

func (ne *NaClEncryptor) PacketOverhead() int

func (*NaClEncryptor) TotalLen

func (ne *NaClEncryptor) TotalLen() int

type NetworkConfig added in v1.3.0

type NetworkConfig struct {
	BufSz         int
	PacketLogging PacketLogging
	Bridge        Bridge
}

type NetworkOverlay added in v1.3.0

type NetworkOverlay interface {
	mesh.Overlay

	// The routes have changed, so any cached information should
	// be discarded.
	InvalidateRoutes()

	// A mapping of a short id to a peer has changed
	InvalidateShortIDs()

	// Start consuming forwarded packets.
	StartConsumingPackets(*mesh.Peer, *mesh.Peers, OverlayConsumer) error
}

Interface to overlay network packet handling

func NewSleeveOverlay added in v1.2.0

func NewSleeveOverlay(localPort int) NetworkOverlay

type NetworkRouter added in v1.3.0

type NetworkRouter struct {
	*mesh.Router
	NetworkConfig
	Macs *MacCache
}

func NewNetworkRouter added in v1.3.0

func NewNetworkRouter(config mesh.Config, networkConfig NetworkConfig, name mesh.PeerName, nickName string, overlay NetworkOverlay) *NetworkRouter

func (*NetworkRouter) HandleHTTP added in v1.3.0

func (router *NetworkRouter) HandleHTTP(muxRouter *mux.Router)

func (*NetworkRouter) Start added in v1.3.0

func (router *NetworkRouter) Start()

Start listening for TCP connections, locally captured packets, and forwarded packets.

type NetworkRouterStatus added in v1.3.0

type NetworkRouterStatus struct {
	*mesh.Status
	Interface    string
	CaptureStats map[string]int
	MACs         []MACStatus
}

func NewNetworkRouterStatus added in v1.3.0

func NewNetworkRouterStatus(router *NetworkRouter) *NetworkRouterStatus

type NonDecryptor

type NonDecryptor struct {
}

func NewNonDecryptor

func NewNonDecryptor() *NonDecryptor

func (*NonDecryptor) IterateFrames

func (nd *NonDecryptor) IterateFrames(packet []byte, consumer FrameConsumer) error

type NonDiscardingFlowOp added in v1.2.0

type NonDiscardingFlowOp struct{}

func (NonDiscardingFlowOp) Discards added in v1.2.0

func (NonDiscardingFlowOp) Discards() bool

type NonEncryptor

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

func NewNonEncryptor

func NewNonEncryptor(prefix []byte) *NonEncryptor

func (*NonEncryptor) AppendFrame

func (ne *NonEncryptor) AppendFrame(src []byte, dst []byte, frame []byte)

func (*NonEncryptor) Bytes

func (ne *NonEncryptor) Bytes() ([]byte, error)

func (*NonEncryptor) FrameOverhead

func (ne *NonEncryptor) FrameOverhead() int

func (*NonEncryptor) PacketOverhead

func (ne *NonEncryptor) PacketOverhead() int

func (*NonEncryptor) TotalLen

func (ne *NonEncryptor) TotalLen() int

type NullBridge added in v1.2.0

type NullBridge struct{}

func (NullBridge) InjectPacket added in v1.2.0

func (NullBridge) InjectPacket(PacketKey) FlowOp

func (NullBridge) StartConsumingPackets added in v1.2.0

func (NullBridge) StartConsumingPackets(BridgeConsumer) error

func (NullBridge) Stats added in v1.2.0

func (NullBridge) Stats() map[string]int

func (NullBridge) String added in v1.2.0

func (NullBridge) String() string

type NullNetworkOverlay added in v1.3.0

type NullNetworkOverlay struct{ mesh.NullOverlay }

func (NullNetworkOverlay) Forward added in v1.3.0

func (NullNetworkOverlay) InvalidateRoutes added in v1.3.0

func (NullNetworkOverlay) InvalidateRoutes()

func (NullNetworkOverlay) InvalidateShortIDs added in v1.3.0

func (NullNetworkOverlay) InvalidateShortIDs()

func (NullNetworkOverlay) StartConsumingPackets added in v1.3.0

func (NullNetworkOverlay) StartConsumingPackets(*mesh.Peer, *mesh.Peers, OverlayConsumer) error

type OverlayConsumer added in v1.2.0

type OverlayConsumer func(ForwardPacketKey) FlowOp

When a consumer is called, the decoder will already have been used to decode the frame.

type OverlayForwarder added in v1.2.0

type OverlayForwarder interface {
	mesh.OverlayConnection
	// Forward a packet across the connection.  May be called as soon
	// as the overlay connection is created, in particular before
	// Confirm().  The return value nil means the key could not be
	// handled by this forwarder.
	Forward(ForwardPacketKey) FlowOp
}

All of the machinery to forward packets to a particular peer

type OverlaySwitch added in v1.2.0

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

func NewOverlaySwitch added in v1.2.0

func NewOverlaySwitch() *OverlaySwitch

func (*OverlaySwitch) Add added in v1.2.0

func (osw *OverlaySwitch) Add(name string, overlay NetworkOverlay)

func (*OverlaySwitch) AddFeaturesTo added in v1.2.0

func (osw *OverlaySwitch) AddFeaturesTo(features map[string]string)

func (*OverlaySwitch) Diagnostics added in v1.2.0

func (osw *OverlaySwitch) Diagnostics() interface{}

func (*OverlaySwitch) InvalidateRoutes added in v1.2.0

func (osw *OverlaySwitch) InvalidateRoutes()

func (*OverlaySwitch) InvalidateShortIDs added in v1.2.0

func (osw *OverlaySwitch) InvalidateShortIDs()

func (*OverlaySwitch) PrepareConnection added in v1.3.0

func (osw *OverlaySwitch) PrepareConnection(params mesh.OverlayConnectionParams) (mesh.OverlayConnection, error)

func (*OverlaySwitch) SetCompatOverlay added in v1.2.0

func (osw *OverlaySwitch) SetCompatOverlay(overlay NetworkOverlay)

func (*OverlaySwitch) StartConsumingPackets added in v1.2.0

func (osw *OverlaySwitch) StartConsumingPackets(localPeer *mesh.Peer, peers *mesh.Peers, consumer OverlayConsumer) error

type PacketDecodingError

type PacketDecodingError struct {
	Desc string
}

func (PacketDecodingError) Error

func (pde PacketDecodingError) Error() string

type PacketKey added in v1.2.0

type PacketKey struct {
	SrcMAC MAC
	DstMAC MAC
}

type PacketLogging added in v1.2.0

type PacketLogging interface {
	LogPacket(string, PacketKey)
	LogForwardPacket(string, ForwardPacketKey)
}

type Pcap added in v1.2.0

type Pcap struct {
	NonDiscardingFlowOp
	// contains filtered or unexported fields
}

func (*Pcap) InjectPacket added in v1.2.0

func (p *Pcap) InjectPacket(PacketKey) FlowOp

func (*Pcap) Process added in v1.2.0

func (p *Pcap) Process(frame []byte, dec *EthernetDecoder, broadcast bool)

func (*Pcap) StartConsumingPackets added in v1.2.0

func (p *Pcap) StartConsumingPackets(consumer BridgeConsumer) error

func (*Pcap) Stats added in v1.2.0

func (p *Pcap) Stats() map[string]int

func (*Pcap) String added in v1.2.0

func (p *Pcap) String() string

type SleeveOverlay added in v1.2.0

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

func (*SleeveOverlay) AddFeaturesTo added in v1.2.0

func (*SleeveOverlay) AddFeaturesTo(map[string]string)

func (*SleeveOverlay) Diagnostics added in v1.2.0

func (*SleeveOverlay) Diagnostics() interface{}

func (*SleeveOverlay) InvalidateRoutes added in v1.2.0

func (*SleeveOverlay) InvalidateRoutes()

func (*SleeveOverlay) InvalidateShortIDs added in v1.2.0

func (*SleeveOverlay) InvalidateShortIDs()

func (*SleeveOverlay) PrepareConnection added in v1.3.0

func (sleeve *SleeveOverlay) PrepareConnection(params mesh.OverlayConnectionParams) (mesh.OverlayConnection, error)

func (*SleeveOverlay) StartConsumingPackets added in v1.2.0

func (sleeve *SleeveOverlay) StartConsumingPackets(localPeer *mesh.Peer, peers *mesh.Peers, consumer OverlayConsumer) error

type VportStatus added in v1.2.0

type VportStatus odp.Vport

func (*VportStatus) MarshalJSON added in v1.2.0

func (vport *VportStatus) MarshalJSON() ([]byte, error)

Jump to

Keyboard shortcuts

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