network

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2019 License: GPL-2.0 Imports: 22 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrClosedDevice = errors.New("already closed device")
)
View Source
var NullMAC = net.HardwareAddr([]byte{0x06, 0xff, 0x01, 0x21, 0x09, 0x03})

NullMAC is a random local MAC address, which does not belong to any host, to disconnect a host from the network.

Functions

func ReservedIP

func ReservedIP(n net.IPNet) (net.IP, error)

ReservedIP returns the IP address reserved for the network.

Types

type Controller

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

func NewController

func NewController(db database) *Controller

func (*Controller) AddConnection

func (r *Controller) AddConnection(ctx context.Context, c net.Conn)

func (*Controller) Announce

func (r *Controller) Announce(ip net.IP, mac net.HardwareAddr) error

func (*Controller) RemoveFlows

func (r *Controller) RemoveFlows() error

func (*Controller) RemoveFlowsByMAC

func (r *Controller) RemoveFlowsByMAC(mac net.HardwareAddr) error

func (*Controller) SetEventListener

func (r *Controller) SetEventListener(l EventListener)

func (*Controller) String

func (r *Controller) String() string

type ControllerEventListener

type ControllerEventListener interface {
	OnPacketIn(Finder, *Port, *protocol.Ethernet) error
	OnPortUp(Finder, *Port) error
	OnPortDown(Finder, *Port) error
	OnDeviceUp(Finder, *Device) error
	OnDeviceDown(Finder, *Device) error
	OnFlowRemoved(Finder, openflow.FlowRemoved) error
}

type Descriptions

type Descriptions struct {
	Manufacturer string
	Hardware     string
	Software     string
	Serial       string
	Description  string
}

type Device

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

func (*Device) Close

func (r *Device) Close()

func (*Device) Descriptions

func (r *Device) Descriptions() Descriptions

func (*Device) Factory

func (r *Device) Factory() openflow.Factory

func (*Device) Features

func (r *Device) Features() Features

func (*Device) Flood

func (r *Device) Flood(ingress *Port, packet []byte) error

Flood broadcasts the packet to all ports of this device, except the ingress port if ingress is not nil.

func (*Device) FlowTableID

func (r *Device) FlowTableID() uint8

func (*Device) ID

func (r *Device) ID() string

func (*Device) IsClosed

func (r *Device) IsClosed() bool

func (*Device) Port

func (r *Device) Port(num uint32) *Port

Port may return nil if there is no port whose number is num

func (*Device) Ports

func (r *Device) Ports() []*Port

func (*Device) RemoveFlow

func (r *Device) RemoveFlow(match openflow.Match, port openflow.OutPort) error

TODO: Remove the flow caches that match the removed flows. This is not a critical issue, but same flows cannot be installed until the caches are expired.

func (*Device) RemoveFlowByMAC

func (r *Device) RemoveFlowByMAC(mac net.HardwareAddr) error

TODO: Remove the flow caches that match the removed flows. This is not a critical issue, but same flows cannot be installed until the caches are expired.

func (*Device) RemoveFlows

func (r *Device) RemoveFlows() error

RemoveFlows removes all the normal flows except special ones for table miss and ARP packets.

func (*Device) SendARPAnnouncement

func (r *Device) SendARPAnnouncement(ip net.IP, mac net.HardwareAddr) error

func (*Device) SendARPDiscovery

func (r *Device) SendARPDiscovery(sha net.HardwareAddr, spa, tpa net.IP) error

func (*Device) SendMessage

func (r *Device) SendMessage(msg encoding.BinaryMarshaler) error

func (*Device) SetFlow

func (r *Device) SetFlow(match openflow.Match, port openflow.OutPort) error

SetFlow installs a normal flow entry for packet switching and routing into the switch device.

func (*Device) String

func (r *Device) String() string

func (*Device) Writer

func (r *Device) Writer() transceiver.Writer

type EventListener

type EventListener interface {
	ControllerEventListener
	TopologyEventListener
}

type Features

type Features struct {
	DPID       uint64
	NumBuffers uint32
	NumTables  uint8
}

type Finder

type Finder interface {
	Device(id string) *Device
	Devices() []*Device
	// IsEnabledBySTP returns whether p is disabled by spanning tree protocol
	IsEnabledBySTP(p *Port) bool
	// IsEdge returns whether p is an edge among two switches
	IsEdge(p *Port) bool
	Node(mac net.HardwareAddr) (*Node, LocationStatus, error)
	Path(srcDeviceID, dstDeviceID string) [][2]*Port
}

type LocationStatus

type LocationStatus int
const (
	// Unregistered MAC address.
	LocationUnregistered LocationStatus = iota
	// Registered MAC address, but we don't know its physical location yet.
	LocationUndiscovered
	// Registered MAC address, and we know its physical location.
	LocationDiscovered
)

type Node

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

func NewNode

func NewNode(p *Port, mac net.HardwareAddr) *Node

func (*Node) MAC

func (r *Node) MAC() net.HardwareAddr

func (*Node) Port

func (r *Node) Port() *Port

func (*Node) String

func (r *Node) String() string

type Port

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

Port represents a switch port and also implements the graph.Point interface.

func NewPort

func NewPort(d *Device, num uint32) *Port

func (*Port) Device

func (r *Port) Device() *Device

func (*Port) ID

func (r *Port) ID() string

func (*Port) Number

func (r *Port) Number() uint32

func (*Port) SetValue

func (r *Port) SetValue(p openflow.Port)

func (*Port) String

func (r *Port) String() string

func (*Port) Value

func (r *Port) Value() openflow.Port

func (*Port) Vertex

func (r *Port) Vertex() graph.Vertex

type TopologyEventListener

type TopologyEventListener interface {
	OnTopologyChange(Finder) error
}

Jump to

Keyboard shortcuts

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