ofctrl

package
v0.0.0-...-009dab0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2018 License: Apache-2.0 Imports: 10 Imported by: 11

Documentation

Index

Constants

View Source
const IP_PROTO_TCP = 6
View Source
const IP_PROTO_UDP = 17

Variables

This section is empty.

Functions

This section is empty.

Types

type ConsumerInterface

type ConsumerInterface interface {
	// A Switch connected to the controller
	SwitchConnected(sw *OFSwitch)

	// Switch disconnected from the controller
	SwitchDisconnected(sw *OFSwitch)

	// Controller received a packet from the switch
	PacketRcvd(sw *OFSwitch, pkt *openflow13.PacketIn)

	// Controller received a multi-part reply from the switch
	MultipartReply(sw *OFSwitch, rep *openflow13.MultipartReply)

	// Port stats change UP/down
	PortStatusChange(sw *OFSwitch, portStatus *openflow13.PortStatus)

	// Flow removed, this could be helpful at the case many controllers manage the bridge
	FlowRemoved(sw *OFSwitch, flowRemoved *openflow13.FlowRemoved)
}

type Controller

type Controller struct {
	Bridge *OFSwitch
	// contains filtered or unexported fields
}

func NewController

func NewController(consumer ConsumerInterface) *Controller

Create a new controller

func (*Controller) Delete

func (c *Controller) Delete()

Cleanup the controller

func (*Controller) Listen

func (c *Controller) Listen(port string)

Listen on a port

func (*Controller) Parse

func (c *Controller) Parse(b []byte) (message util.Message, err error)

Demux based on message version

type Flow

type Flow struct {
	TableId     uint8         // FLow Table
	Match       FlowMatch     // Fields to be matched
	FlowID      uint64        // Unique ID for the flow
	FlowActions []*FlowAction // List of flow actions
	FlowOutput  []*FlowOutput

	IdleTimeout uint16 /* Idle time before discarding (seconds). */
	HardTimeout uint16 /* Max time before discarding (seconds). */
	// contains filtered or unexported fields
}

func NewFlow

func NewFlow(tblID uint8) *Flow

func (*Flow) FlowKey

func (self *Flow) FlowKey() string

string key for the flow

func (*Flow) GetFlowInstructions

func (self *Flow) GetFlowInstructions() openflow13.Instruction

func (*Flow) GetMatchFields

func (self *Flow) GetMatchFields() openflow13.Match

Get all defined match openflow match fields

func (*Flow) GetWriteMetaDataFlowInstruction

func (self *Flow) GetWriteMetaDataFlowInstruction() (*openflow13.InstrWriteMetadata, error)

func (*Flow) PopVlan

func (self *Flow) PopVlan()

func (*Flow) SetDropAction

func (self *Flow) SetDropAction()

func (*Flow) SetDscp

func (self *Flow) SetDscp(dscp uint8)

func (*Flow) SetFloodAction

func (self *Flow) SetFloodAction()

func (*Flow) SetGotoControllerAction

func (self *Flow) SetGotoControllerAction()

func (*Flow) SetGotoTableAction

func (self *Flow) SetGotoTableAction(tblID uint8)

func (*Flow) SetIPField

func (self *Flow) SetIPField(ip net.IP, field string)

func (*Flow) SetL4Field

func (self *Flow) SetL4Field(port uint16, field string)

field should has one of the following values TCPSrc, TCPDst, UDPSrc or UDPDst

func (*Flow) SetMacDa

func (self *Flow) SetMacDa(macDa net.HardwareAddr)

func (*Flow) SetMacSa

func (self *Flow) SetMacSa(macSa net.HardwareAddr)

func (*Flow) SetMetadata

func (self *Flow) SetMetadata(metadata, metadataMask uint64)

func (*Flow) SetNormalAction

func (self *Flow) SetNormalAction()

func (*Flow) SetOutputPortAction

func (self *Flow) SetOutputPortAction(portNo uint32)

func (*Flow) SetTunnelId

func (self *Flow) SetTunnelId(tunnelId uint64)

func (*Flow) SetVlan

func (self *Flow) SetVlan(vlanId uint16)

func (*Flow) UnsetDscp

func (self *Flow) UnsetDscp()

type FlowAction

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

type FlowMatch

type FlowMatch struct {
	Priority     uint16            // Priority of the flow
	InputPort    uint32            // Input port number
	MacDa        *net.HardwareAddr // Mac dest
	MacDaMask    *net.HardwareAddr // Mac dest mask
	MacSa        *net.HardwareAddr // Mac source
	MacSaMask    *net.HardwareAddr // Mac source mask
	Ethertype    uint16            // Ethertype
	VlanId       uint16            // vlan id
	ArpOper      uint16            // ARP Oper type
	IpSa         *net.IP           // IPv4 source addr
	IpSaMask     *net.IP           // IPv4 source mask
	IpDa         *net.IP           // IPv4 dest addr
	IpDaMask     *net.IP           // IPv4 dest mask
	Ipv6Sa       *net.IP           // IPv6 source addr
	Ipv6SaMask   *net.IP           // IPv6 source mask
	Ipv6Da       *net.IP           // IPv6 dest addr
	Ipv6DaMask   *net.IP           // IPv6 dest mask
	IpProto      uint8             // IP protocol
	IpDscp       uint8             // DSCP/TOS field
	TcpSrcPort   uint16            // TCP source port
	TcpDstPort   uint16            // TCP dest port
	UdpSrcPort   uint16            // UDP source port
	UdpDstPort   uint16            // UDP dest port
	Metadata     *uint64           // OVS metadata
	MetadataMask *uint64           // Metadata mask
	TunnelId     uint64            // Vxlan Tunnel id i.e. VNI
	TcpFlags     *uint16           // TCP flags
	TcpFlagsMask *uint16           // Mask for TCP flags
}

type FlowOutput

type FlowOutput struct {
	OutputType string // Output type: "toController", "flood", "gotoTable" or "outPort"
	OutPortNo  uint32 // Output port number
	TblId      uint8  // goto table id
}

type OFSwitch

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

func NewSwitch

func NewSwitch(stream *util.MessageStream, dpid net.HardwareAddr, consumer ConsumerInterface) *OFSwitch

Builds and populates a Switch struct then starts listening for OpenFlow messages on conn.

func (*OFSwitch) DPID

func (self *OFSwitch) DPID() net.HardwareAddr

Returns the dpid of Switch s.

func (*OFSwitch) DeleteFlow

func (self *OFSwitch) DeleteFlow(flow Flow)

func (*OFSwitch) Disconnect

func (self *OFSwitch) Disconnect()

func (*OFSwitch) InstallFlow

func (self *OFSwitch) InstallFlow(flow *Flow)

func (*OFSwitch) Send

func (self *OFSwitch) Send(req util.Message)

Sends an OpenFlow message to the Switch.

Jump to

Keyboard shortcuts

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