ofctrl

package
Version: v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2022 License: Apache-2.0 Imports: 19 Imported by: 6

README

Ofctrl

This library implements a simple Openflow1.3 controller API

Usage

// Create a controller
ctrler := ofctrl.NewController(&app)

// Listen for connections
ctrler.Listen(":6633")

This creates a new controller and registers the app for event callbacks. The app needs to implement following interface to get callbacks when an openflow switch connects to the controller.

type AppInterface 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 *PacketIn)
}

Example app

type OfApp struct {
    Switch *ofctrl.OFSwitch
}

func (o *OfApp) PacketRcvd(sw *ofctrl.OFSwitch, packet *openflow15.PacketIn) {
    log.Printf("App: Received packet: %+v", packet)
}

func (o *OfApp) SwitchConnected(sw *ofctrl.OFSwitch) {
    log.Printf("App: Switch connected: %v", sw.DPID())

    // Store switch for later use
    o.Switch = sw
}

func (o *OfApp) SwitchDisconnected(sw *ofctrl.OFSwitch) {
    log.Printf("App: Switch connected: %v", sw.DPID())
}

// Main app
var app OfApp

// Create a controller
ctrler := ofctrl.NewController(&app)

// start listening
ctrler.Listen(":6633")

Working with OpenVswitch

Command to make ovs connect to controller:

ovs-vsctl set-controller <bridge-name> tcp:<ip-addr>:<port>

Example:

sudo ovs-vsctl set-controller ovsbr0 tcp:127.0.0.1:6633
To enable openflow1.3 support in OVS:

ovs-vsctl set bridge <bridge-name> protocols=OpenFlow10,OpenFlow11,OpenFlow12,OpenFlow13

Example:

sudo ovs-vsctl set bridge ovsbr0 protocols=OpenFlow10,OpenFlow11,OpenFlow12,OpenFlow13

Forwarding Graph API

An app can install flow table entries into the Openflow switch by using forwarding graph API. Forwarding graph is made up of forwarding elements which determine how a packet lookups are done. Forwarding graph is a higher level interface that is converted to Openflow1.3 flows, instructions, groups and actions by the library

Forwarding graph is specific to each switch. It is roughly structured as follows

         +------------+
         | Controller |
         +------------+
                |
      +---------+---------+
      |                   |
 +----------+        +----------+
 | Switch 1 |        | Switch 2 |
 +----------+        +----------+
       |
       +--------------+---------------+
       |              |               |
       V              V
 +---------+      +---------+     +---------+
 | Table 1 |  +-->| Table 2 |  +->| Table 3 |
 +---------+  |   +---------+  |  +---------+
      |       |        |       |      |
 +---------+  |   +---------+  |  +--------+     +------+
 | Flow 1  +--+   | Flow 1  +--+  | Flow 1 +---->| Drop |
 +---------+      +---------+     +--------+     +------+
      |
 +---------+            +----------+
 | Flow 2  +----------->+ OutPut 1 |
 +---------+            +----------+
      |
 +---------+                 +----------+
 | Flow 3  +---------------->| Output 2 |
 +---------+                 +----------+
      |                            ^
 +---------+       +---------+     |      +----------+
 | Flow 4  +------>| Flood 1 +-----+----->| Output 3 |
 +---------+       +---------+     |      +----------+
      |                            |
 +---------+     +-----------+     |      +----------+
 | Flow 5  +---->| Multipath |     +----->| Output 4 |
 +---------+     +-----+-----+            +----------+
                       |
          +------------+-------------+
          |            |             |
    +----------+  +----------+  +----------+
    | Output 5 |  | Output 6 |  | Output 7 |
    +----------+  +----------+  +----------+

Forwarding graph is made up of Fgraph elements. Currently there are four kinds of elements.

1. Table - Represents a flow table
2. Flow - Represents a specific flow
3. Output - Represents an output action either drop or send it on a port
4. Flood - Represents flood to list of ports

In future we will support an additional type.

5. Multipath - Represents load balancing across a set of ports

Forwarding Graph elements are linked together as follows

  • Each Switch has a set of Tables. Switch has a special DefaultTable where all packet lookups start.
  • Each Table contains list of Flows. Each Flow has a Match condition which determines the packets that match the flow and a NextElem which it points to
  • A Flow can point to following elements
    1. Table - This moves the forwarding lookup to specified table
    2. Output - This causes the packet to be sent out or dropped
    3. Flood - This causes the packet to be flooded to list of ports
    4. Multipath - This causes packet to be load balanced across set of ports. This can be used for link aggregation and ECMP
  • There are three kinds of outputs
    1. drop - which causes the packet to be dropped
    2. toController - sends the packet to controller
    3. port - sends the packet out of specified port. Tunnels like Vxlan VTEP are also represented as ports.
  • A flow can have additional actions like:
    1. Set Vlan tag
    2. Set metadata Which is used for setting VRF for a packet
    3. Set VNI/tunnel header etc

Example usage:

     // Find the switch we want to operate on
     switch := app.Switch

     // Create all tables
     rxVlanTbl := switch.NewTable(1)
     macSaTable := switch.NewTable(2)
     macDaTable := switch.NewTable(3)
     ipTable := switch.NewTable(4)
     inpTable := switch.DefaultTable() // table 0. i.e starting table

     // Discard mcast source mac
     dscrdMcastSrc := inpTable.NewFlow(FlowMatch{
                                      &McastSrc: { 0x01, 0, 0, 0, 0, 0 }
                                      &McastSrcMask: { 0x01, 0, 0, 0, 0, 0 }
                                      }, 100)
     dscrdMcastSrc.Next(switch.DropAction())

     // All valid packets go to vlan table
     validInputPkt := inpTable.NewFlow(FlowMatch{}, 1)
     validInputPkt.Next(rxVlanTbl)

     // Set access vlan for port 1 and go to mac lookup
     tagPort := rxVlanTbl.NewFlow(FlowMatch{
                                  InputPort: Port(1)
                                  }, 100)
     tagPort.SetVlan(10)
     tagPort.Next(macSaTable)

     // Match on IP dest addr and forward to a port
     ipFlow := ipTable.NewFlow(FlowParams{
                               Ethertype: 0x0800,
                               IpDa: &net.IPv4("10.10.10.10")
                              }, 100)

     outPort := switch.NewOutputPort(10)
     ipFlow.Next(outPort)

Documentation

Overview

** Copyright 2014 Cisco Systems Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

** Copyright 2014 Cisco Systems Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

** Copyright 2014 Cisco Systems Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

** Copyright 2014 Cisco Systems Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

** Copyright 2014 Cisco Systems Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

** Copyright 2014 Cisco Systems Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

#nosec G404: random number generator not used for security purposes

** Copyright 2014 Cisco Systems Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	MeterKbps  MeterFlag = 0b0001
	MeterPktps MeterFlag = 0b0010
	MeterBurst MeterFlag = 0b0100
	MeterStats MeterFlag = 0b1000

	MeterDrop         MeterType = 1      /* Drop packet. */
	MeterDSCPRemark   MeterType = 2      /* Remark DSCP in the IP header. */
	MeterExperimenter MeterType = 0xFFFF /* Experimenter meter band. */
)
View Source
const (
	ActTypePushVlan       = "pushVlan"
	ActTypeSetVlan        = "setVlan"
	ActTypePopVlan        = "popVlan"
	ActTypePopMpls        = "popMpls"
	ActTypePushMpls       = "pushMpls"
	ActTypeSetDstMac      = "setMacDa"
	ActTypeSetSrcMac      = "setMacSa"
	ActTypeSetTunnelID    = "setTunnelId"
	ActTypeMetatdata      = "setMetadata"
	ActTypeSetSrcIP       = "setIPSa"
	ActTypeSetDstIP       = "setIPDa"
	ActTypeSetTunnelSrcIP = "setTunSa"
	ActTypeSetTunnelDstIP = "setTunDa"
	ActTypeSetDSCP        = "setDscp"
	ActTypeSetARPOper     = "setARPOper"
	ActTypeSetARPSHA      = "setARPSha"
	ActTypeSetARPTHA      = "setARPTha"
	ActTypeSetARPSPA      = "setARPSpa"
	ActTypeSetARPTPA      = "setARPTpa"
	ActTypeSetTCPsPort    = "setTCPSrc"
	ActTypeSetTCPdPort    = "setTCPDst"
	ActTypeSetTCPFlags    = "setTCPFlags"
	ActTypeSetUDPsPort    = "setUDPSrc"
	ActTypeSetUDPdPort    = "setUDPDst"
	ActTypeSetSCTPsPort   = "setSCTPSrc"
	ActTypeSetSCTPdPort   = "setSCTPDst"
	ActTypeSetNDTarget    = "setNDTarget"
	ActTypeSetNDSLL       = "setNDSLL"
	ActTypeSetNDTLL       = "setNDTLL"
	ActTypeSetICMP6Type   = "setICMPv6Type"
	ActTypeSetICMP6Code   = "setICMPv6Code"
	ActTypeSetICMP4Type   = "setICMPv4Type"
	ActTypeSetICMP4Code   = "setICMPv4Code"
	ActTypeNXLoad         = "loadReg"
	ActTypeNXMove         = "moveReg"
	ActTypeNXCT           = "ct"
	ActTypeNXConjunction  = "conjunction"
	ActTypeDecTTL         = "decTTL"
	ActTypeNXResubmit     = "resubmit"
	ActTypeGroup          = "group"
	ActTypeNXLearn        = "learn"
	ActTypeNXNote         = "note"
	ActTypeController     = "controller"
	ActTypeOutput         = "output"
	ActTypeNXOutput       = "nxOutput"
	ActTypeSetField       = "setField"
	ActTypeCopyField      = "copyField"
	ActTypeMeter          = "meter"
)
View Source
const (
	OF   = uint32(0)
	OFEx = uint32(0x4f4e4600)
)
View Source
const (
	InitConnection = iota
	ReConnection
	CompleteConnection
)

Connection operation type

View Source
const IP_PROTO_SCTP = 132
View Source
const IP_PROTO_TCP = 6
View Source
const IP_PROTO_UDP = 17
View Source
const (
	PC_NO_FLOOD = 1 << 4
)

Variables

View Source
var (
	EmptyFlowActionError    = errors.New("flow Actions is empty")
	UnknownElementTypeError = errors.New("unknown Fgraph element type")
	UnknownActionTypeError  = errors.New("unknown action type")
)

Functions

func DialUnixOrNamedPipe

func DialUnixOrNamedPipe(address string) (net.Conn, error)

func GenerateICMPHeader

func GenerateICMPHeader(icmpType, icmpCode *uint8) *protocol.ICMP

func GenerateTCPHeader

func GenerateTCPHeader(dstPort, srcPort uint16, flags *uint8) *protocol.TCP

func GetErrorMessage

func GetErrorMessage(errType, errCode uint16, vendor uint32) string

func GetErrorMessageType

func GetErrorMessageType(errData util.Buffer) string

func GetUint32ValueWithRange

func GetUint32ValueWithRange(data uint32, rng *openflow15.NXRange) uint32

func GetUint32ValueWithRangeFromBytes

func GetUint32ValueWithRangeFromBytes(data []byte, rng *openflow15.NXRange) (uint32, error)

func GetUint64ValueWithRange

func GetUint64ValueWithRange(data uint64, rng *openflow15.NXRange) uint64

func GetUint64ValueWithRangeFromBytes

func GetUint64ValueWithRangeFromBytes(data []byte, rng *openflow15.NXRange) (uint64, error)

func NewTunnelIpv6DstField

func NewTunnelIpv6DstField(tunnelIpDst net.IP, tunnelIpDstMask *net.IP) *openflow15.MatchField

func NewTunnelIpv6SrcField

func NewTunnelIpv6SrcField(tunnelIpSrc net.IP, tunnelIpSrcMask *net.IP) *openflow15.MatchField

func ResetFieldLength

func ResetFieldLength(field *openflow15.MatchField, tlvMapStatus *TLVTableStatus) *openflow15.MatchField

Types

type AppInterface

type AppInterface 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 *PacketIn)

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

type CTStatesChecker

type CTStatesChecker Uint32WithMask

func (*CTStatesChecker) IsDNAT

func (s *CTStatesChecker) IsDNAT() bool

func (*CTStatesChecker) IsEst

func (s *CTStatesChecker) IsEst() bool

func (*CTStatesChecker) IsInv

func (s *CTStatesChecker) IsInv() bool

func (*CTStatesChecker) IsNew

func (s *CTStatesChecker) IsNew() bool

func (*CTStatesChecker) IsRel

func (s *CTStatesChecker) IsRel() bool

func (*CTStatesChecker) IsRpl

func (s *CTStatesChecker) IsRpl() bool

func (*CTStatesChecker) IsSNAT

func (s *CTStatesChecker) IsSNAT() bool

func (*CTStatesChecker) IsTrk

func (s *CTStatesChecker) IsTrk() bool

func (*CTStatesChecker) IsUnDNAT

func (s *CTStatesChecker) IsUnDNAT() bool

func (*CTStatesChecker) IsUnEst

func (s *CTStatesChecker) IsUnEst() bool

func (*CTStatesChecker) IsUnInv

func (s *CTStatesChecker) IsUnInv() bool

func (*CTStatesChecker) IsUnNew

func (s *CTStatesChecker) IsUnNew() bool

func (*CTStatesChecker) IsUnRel

func (s *CTStatesChecker) IsUnRel() bool

func (*CTStatesChecker) IsUnRpl

func (s *CTStatesChecker) IsUnRpl() bool

func (*CTStatesChecker) IsUnSNAT

func (s *CTStatesChecker) IsUnSNAT() bool

func (*CTStatesChecker) IsUnTrk

func (s *CTStatesChecker) IsUnTrk() bool

type ConnectionMode

type ConnectionMode int
const (
	ServerMode ConnectionMode = iota
	ClientMode
)

type ConnectionRetryControl

type ConnectionRetryControl interface {
	MaxRetry() int
	RetryInterval() time.Duration
}

type Controller

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

func NewController

func NewController(app AppInterface) *Controller

Create a new controller

func (*Controller) Connect

func (c *Controller) Connect(sock string) error

Linux: Connect to Unix Domain Socket file Windows: Connect to named pipe

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 CopyFieldAction added in v0.6.0

type CopyFieldAction struct {
	SrcOxmId  openflow15.OxmId
	DstOxmId  openflow15.OxmId
	NBits     uint16
	SrcOffset uint16
	DstOffset uint16
}

func NewCopyFieldAction added in v0.6.0

func NewCopyFieldAction(nBits uint16, srcOffset uint16, dstOffset uint16, srcOxmId *openflow15.OxmId, dstOxmId *openflow15.OxmId) *CopyFieldAction

func (*CopyFieldAction) GetActionMessage added in v0.6.0

func (a *CopyFieldAction) GetActionMessage() openflow15.Action

func (*CopyFieldAction) GetActionType added in v0.6.0

func (a *CopyFieldAction) GetActionType() string

func (*CopyFieldAction) ResetDstFieldLength added in v0.6.0

func (a *CopyFieldAction) ResetDstFieldLength(ofSwitch *OFSwitch)

func (*CopyFieldAction) ResetFieldsLength added in v0.6.0

func (a *CopyFieldAction) ResetFieldsLength(ofSwitch *OFSwitch)

func (*CopyFieldAction) ResetSrcFieldLength added in v0.6.0

func (a *CopyFieldAction) ResetSrcFieldLength(ofSwitch *OFSwitch)

type DataWithMask

type DataWithMask struct {
	Value []byte
	Mask  []byte
}

type DecTTLAction

type DecTTLAction struct {
}

func (*DecTTLAction) GetActionMessage

func (a *DecTTLAction) GetActionMessage() openflow15.Action

func (*DecTTLAction) GetActionType

func (a *DecTTLAction) GetActionType() string

type EmptyElem

type EmptyElem struct {
}

func NewEmptyElem

func NewEmptyElem() *EmptyElem

func (*EmptyElem) GetFlowInstr

func (self *EmptyElem) GetFlowInstr() openflow15.Instruction

instruction set for NXOutput element

func (*EmptyElem) Type

func (self *EmptyElem) Type() string

Fgraph element type for the NXOutput

type FgraphElem

type FgraphElem interface {
	// Returns the type of fw graph element
	Type() string

	// Returns the formatted instruction set.
	// This is used by the previous Fgraph element to install instruction set
	// in the flow entry
	GetFlowInstr() openflow15.Instruction
}

type Flood

type Flood struct {
	Switch  *OFSwitch // Switch where this flood entry is present
	GroupId uint32    // Unique id for the openflow group

	FloodList []FloodOutput // List of output ports to flood to
	// contains filtered or unexported fields
}

Flood Fgraph element

func (*Flood) AddOutput

func (self *Flood) AddOutput(out *Output) error

Add a new Output to group element

func (*Flood) AddTunnelOutput

func (self *Flood) AddTunnelOutput(out *Output, tunnelId uint64) error

Add a new Output to group element

func (*Flood) Delete

func (self *Flood) Delete() error

Delete a flood list

func (*Flood) GetFlowInstr

func (self *Flood) GetFlowInstr() openflow15.Instruction

instruction set for output element

func (*Flood) NumOutput

func (self *Flood) NumOutput() int

Return number of ports in flood list

func (*Flood) RemoveOutput

func (self *Flood) RemoveOutput(out *Output) error

Remove a port from flood list

func (*Flood) Type

func (self *Flood) Type() string

Fgraph element type for the output

type FloodOutput

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

type Flow

type Flow struct {
	Table       *Table     // Table where this flow resides
	Match       FlowMatch  // Fields to be matched
	NextElem    FgraphElem // Next fw graph element
	HardTimeout uint16     // Timeout to remove the flow after it is installed in the switch
	IdleTimeout uint16     // Timeout to remove the flow after its last hit

	CookieID   uint64  // Cookie ID for flowMod message
	CookieMask *uint64 // Cookie Mask for flowMod message
	// contains filtered or unexported fields
}

State of a flow entry

func (*Flow) AddConjunction

func (self *Flow) AddConjunction(conjID uint32, clause uint8, nClause uint8) error

Special Actions to to the flow to set conjunctions Note:

  1. nclause should be in [2, 64].
  2. clause value should be less than or equals to ncluase, and its value should be started from 1. actual clause in libopenflow messages is started from 0, here would decrement 1 to keep the display value is consistent with expected configuration

func (*Flow) ApplyAction

func (self *Flow) ApplyAction(action OFAction)

func (*Flow) ApplyActions

func (self *Flow) ApplyActions(actions []OFAction)

func (*Flow) ClearActions

func (self *Flow) ClearActions()

func (*Flow) ConnTrack

func (self *Flow) ConnTrack(commit bool, force bool, tableID *uint8, zoneID *uint16, execActions ...openflow15.Action) error

Special actions on the flow for connection trackng

func (*Flow) Controller

func (self *Flow) Controller(reason uint8) error

func (*Flow) CopyActionsToNewFlow

func (self *Flow) CopyActionsToNewFlow(newFlow *Flow)

func (*Flow) CopyField added in v0.6.0

func (self *Flow) CopyField(nBits uint16, srcOffset uint16, dstOffset uint16,
	srcOxmId *openflow15.OxmId, dstOxmId *openflow15.OxmId) error

func (*Flow) DecTTL

func (self *Flow) DecTTL() error

Special Actions to the flow to dec TTL

func (*Flow) DelConjunction

func (self *Flow) DelConjunction(conjID uint32) error

func (*Flow) Delete

func (self *Flow) Delete() error

Delete the flow

func (*Flow) Drop

func (self *Flow) Drop()

func (*Flow) GenerateFlowModMessage

func (self *Flow) GenerateFlowModMessage(commandType int) (flowMod *openflow15.FlowMod, err error)

GenerateFlowModMessage translates the Flow a FlowMod message according to the commandType.

func (*Flow) GetBundleMessage

func (self *Flow) GetBundleMessage(command int) (*FlowBundleMessage, error)

func (*Flow) GetFlowInstr

func (self *Flow) GetFlowInstr() openflow15.Instruction

instruction set for flow element

func (*Flow) Goto

func (self *Flow) Goto(tableID uint8)

func (*Flow) IsRealized

func (self *Flow) IsRealized() bool

IsRealized gets flow realized status

func (*Flow) Learn

func (self *Flow) Learn(learn *FlowLearn) error

Special Actions to the flow to learn from the current packet and generate a new flow entry.

func (*Flow) LoadReg

func (self *Flow) LoadReg(fieldName string, data uint64, dataRange *openflow15.NXRange) error

Special Actions on the flow to load data into OXM/NXM field

func (*Flow) MonitorRealizeStatus

func (self *Flow) MonitorRealizeStatus()

MonitorRealizeStatus sends MultipartRequest to get current flow status, it is calling if needs to check flow's realized status

func (*Flow) MoveRegs

func (self *Flow) MoveRegs(srcName string, dstName string, srcRange *openflow15.NXRange, dstRange *openflow15.NXRange) error

Special Actions on the flow to move data from src_field[rng] to dst_field[rng]

func (*Flow) Next

func (self *Flow) Next(elem FgraphElem) error

Set Next element in the Fgraph. This determines what actions will be part of the flow's instruction set

func (*Flow) Note

func (self *Flow) Note(data []byte) error

func (*Flow) OutputReg

func (self *Flow) OutputReg(name string, start int, end int) error

func (*Flow) PopMpls added in v0.5.6

func (self *Flow) PopMpls(etherType uint16) error

Special action on the flow to pop mpls ethertype

func (*Flow) PopVlan

func (self *Flow) PopVlan() error

Special action on the flow to set vlan id

func (*Flow) PushMpls added in v0.5.6

func (self *Flow) PushMpls(etherType uint16) error

Special action on the flow to push mpls ethertype

func (*Flow) ResetApplyActions

func (self *Flow) ResetApplyActions(actions []OFAction)

func (*Flow) ResetWriteActions

func (self *Flow) ResetWriteActions(actions []OFAction)

func (*Flow) Resubmit

func (self *Flow) Resubmit(ofPort uint16, tableID uint8) error

func (*Flow) Send

func (self *Flow) Send(operationType int) error

Send generates a FlowMod message according the operationType, and then sends it to the OFSwitch.

func (*Flow) SetARPOper

func (self *Flow) SetARPOper(arpOp uint16) error

func (*Flow) SetARPSha

func (self *Flow) SetARPSha(arpSha net.HardwareAddr) error

Special action on the flow to set ARP source host addr

func (*Flow) SetARPSpa

func (self *Flow) SetARPSpa(ip net.IP) error

Special action on the flow to set arp_spa field

func (*Flow) SetARPTha

func (self *Flow) SetARPTha(arpTha net.HardwareAddr) error

Special action on the flow to set ARP target host addr

func (*Flow) SetARPTpa

func (self *Flow) SetARPTpa(ip net.IP) error

Special action on the flow to set arp_spa field

func (*Flow) SetDscp

func (self *Flow) SetDscp(dscp uint8) error

Special actions on the flow to set dscp field

func (*Flow) SetField added in v0.6.0

func (self *Flow) SetField(field *openflow15.MatchField) error

func (*Flow) SetIPField

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

Special action on the flow to set an ip field

func (*Flow) SetL4Field

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

Special action on the flow to set a L4 field

func (*Flow) SetMacDa

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

Special action on the flow to set mac dest addr

func (*Flow) SetMacSa

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

Special action on the flow to set mac source addr

func (*Flow) SetMetadata

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

Special actions on the flow to set metadata

func (*Flow) SetRealized

func (self *Flow) SetRealized()

func (*Flow) SetTunnelId

func (self *Flow) SetTunnelId(tunnelId uint64) error

Special actions on the flow to set vlan id

func (*Flow) SetVlan

func (self *Flow) SetVlan(vlanId uint16) error

Special action on the flow to set vlan id

func (*Flow) Type

func (self *Flow) Type() string

Fgraph element type for the flow

func (*Flow) UnsetDscp

func (self *Flow) UnsetDscp() error

unset dscp field

func (*Flow) UpdateInstallStatus

func (self *Flow) UpdateInstallStatus(installed bool)

updateInstallStatus changes isInstalled value.

func (*Flow) WriteAction

func (self *Flow) WriteAction(action OFAction)

func (*Flow) WriteActions

func (self *Flow) WriteActions(actions []OFAction)

func (*Flow) WriteMetadata

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

type FlowAction

type FlowAction struct {
	ActionType string // Type of action "setVlan", "setMetadata"
	// contains filtered or unexported fields
}

additional Actions in flow's instruction set

type FlowBundleMessage

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

type FlowLearn

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

func NewLearnAction

func NewLearnAction(tableID uint8, priority, idleTimeout, hardTimeout, finIdleTimeout, finHardTimeout uint16, cookieID uint64) *FlowLearn

func (*FlowLearn) AddLoadAction

func (l *FlowLearn) AddLoadAction(toField *LearnField, learnBits uint16, fromField *LearnField, fromValue []byte) error

func (*FlowLearn) AddMatch

func (l *FlowLearn) AddMatch(matchField *LearnField, learnBits uint16, fromField *LearnField, fromValue []byte) error

func (*FlowLearn) AddOutputAction

func (l *FlowLearn) AddOutputAction(toField *LearnField, learnBits uint16) error

func (*FlowLearn) DeleteLearnedFlowsAfterDeletion

func (l *FlowLearn) DeleteLearnedFlowsAfterDeletion()

func (*FlowLearn) GetActionMessage

func (l *FlowLearn) GetActionMessage() openflow15.Action

func (*FlowLearn) GetActionType

func (l *FlowLearn) GetActionType() string

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
	NonVlan       bool                 // Non-vlan
	VlanId        *uint16              // vlan id
	VlanMask      *uint16              // Mask for vlan id
	ArpOper       uint16               // ARP Oper type
	ArpSha        *net.HardwareAddr    // ARP source host address
	ArpTha        *net.HardwareAddr    // ARP target host address
	ArpSpa        *net.IP              // ARP source protocol address
	ArpTpa        *net.IP              // ARP target protocol address
	IpSa          *net.IP              // IPv4 source addr
	IpSaMask      *net.IP              // IPv4 source mask
	IpDa          *net.IP              // IPv4 dest addr
	IpDaMask      *net.IP              // IPv4 dest mask
	CtIpSa        *net.IP              // IPv4 source addr in ct
	CtIpSaMask    *net.IP              // IPv4 source mask in ct
	CtIpDa        *net.IP              // IPv4 dest addr in ct
	CtIpDaMask    *net.IP              // IPv4 dest mask in ct
	CtIpv6Sa      *net.IP              // IPv6 source addr
	CtIpv6Da      *net.IP              // IPv6 dest addr in ct
	IpProto       uint8                // IP protocol
	CtIpProto     uint8                // IP protocol in ct
	IpDscp        uint8                // DSCP/TOS field
	SrcPort       uint16               // Source port in transport layer
	SrcPortMask   *uint16              // Mask for source port in transport layer
	DstPort       uint16               // Dest port in transport layer
	DstPortMask   *uint16              // Mask for dest port in transport layer
	CtTpSrcPort   uint16               // Source port in the transport layer in ct
	CtTpDstPort   uint16               // Dest port in the transport layer in ct
	Icmp6Code     *uint8               // ICMPv6 code
	Icmp6Type     *uint8               // ICMPv6 type
	Icmp4Code     *uint8               // ICMPv4 code
	Icmp4Type     *uint8               // ICMPv4 type
	NdTarget      *net.IP              // ICMPv6 Neighbor Discovery Target
	NdTargetMask  *net.IP              // Mask for ICMPv6 Neighbor Discovery Target
	NdSll         *net.HardwareAddr    // ICMPv6 Neighbor Discovery Source Ethernet Address
	NdTll         *net.HardwareAddr    // ICMPv6 Neighbor DIscovery Target Ethernet Address
	IpTtl         *uint8               // IPV4 TTL
	Metadata      *uint64              // OVS metadata
	MetadataMask  *uint64              // Metadata mask
	TunnelId      uint64               // Vxlan Tunnel id i.e. VNI
	TunnelDst     *net.IP              // Tunnel destination addr
	TcpFlags      *uint16              // TCP flags
	TcpFlagsMask  *uint16              // Mask for TCP flags
	ConjunctionID *uint32              // Add AddConjunction ID
	CtStates      *openflow15.CTStates // Connection tracking states
	NxRegs        []*NXRegister        // regX or regX[m..n]
	XxRegs        []*XXRegister        // xxregN or xxRegN[m..n]
	CtMark        uint32               // conn_track mark
	CtMarkMask    *uint32              // Mask of conn_track mark
	CtLabelLo     uint64               // conntrack label [0..63]
	CtLabelHi     uint64               // conntrack label [64..127]
	CtLabelLoMask uint64               // conntrack label masks [0..63]
	CtLabelHiMask uint64               // conntrack label masks [64..127]
	ActsetOutput  uint32               // Output port number
	TunMetadatas  []*NXTunMetadata     // tun_metadataX or tun_metadataX[m..n]
	PktMark       uint32               // Packet mark
	PktMarkMask   *uint32              // Packet mark mask
}

Small subset of openflow fields we currently support

type Group

type Group struct {
	Switch    *OFSwitch
	ID        uint32
	GroupType GroupType
	Buckets   []*openflow15.Bucket
	// contains filtered or unexported fields
}

func (*Group) AddBuckets

func (self *Group) AddBuckets(buckets ...*openflow15.Bucket)

func (*Group) Delete

func (self *Group) Delete() error

func (*Group) GetActionMessage

func (self *Group) GetActionMessage() openflow15.Action

func (*Group) GetActionType

func (self *Group) GetActionType() string

func (*Group) GetBundleMessage

func (self *Group) GetBundleMessage(command int) *GroupBundleMessage

func (*Group) GetFlowInstr

func (self *Group) GetFlowInstr() openflow15.Instruction

func (*Group) Install

func (self *Group) Install() error

func (*Group) ResetBuckets

func (self *Group) ResetBuckets(buckets ...*openflow15.Bucket)

func (*Group) Type

func (self *Group) Type() string

type GroupBundleMessage

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

type GroupType

type GroupType int
const (
	GroupAll GroupType = iota
	GroupSelect
	GroupIndirect
	GroupFF
)

type LearnField

type LearnField struct {
	Name  string
	Start uint16
}

type MatchField

type MatchField struct {
	*openflow15.MatchField
	// contains filtered or unexported fields
}

func NewMatchField

func NewMatchField(mf *openflow15.MatchField) *MatchField

func (*MatchField) GetName

func (m *MatchField) GetName() string

func (*MatchField) GetNickName

func (m *MatchField) GetNickName() string

func (*MatchField) GetValue

func (m *MatchField) GetValue() interface{}

type Matchers

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

func (*Matchers) GetMatch

func (m *Matchers) GetMatch(class uint16, field uint8) *MatchField

func (*Matchers) GetMatchByName

func (m *Matchers) GetMatchByName(name string) *MatchField

type MessageResult

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

func (*MessageResult) GetErrorCode

func (r *MessageResult) GetErrorCode() uint16

func (*MessageResult) GetErrorType

func (r *MessageResult) GetErrorType() uint16

func (*MessageResult) GetExperimenterID

func (r *MessageResult) GetExperimenterID() int32

func (*MessageResult) GetXid

func (r *MessageResult) GetXid() uint32

func (*MessageResult) IsSucceed

func (r *MessageResult) IsSucceed() bool

type MessageType

type MessageType int
const (
	UnknownMessage MessageType = iota
	BundleControlMessage
	BundleAddMessage
)

type Meter

type Meter struct {
	Switch     *OFSwitch
	ID         uint32
	Flags      MeterFlag
	MeterBands []*util.Message
	// contains filtered or unexported fields
}

func (*Meter) AddMeterBand

func (self *Meter) AddMeterBand(meterBands ...*util.Message)

func (*Meter) Delete

func (self *Meter) Delete() error

func (*Meter) GetBundleMessage

func (self *Meter) GetBundleMessage(command int) *MeterBundleMessage

func (*Meter) Install

func (self *Meter) Install() error

func (*Meter) Type

func (self *Meter) Type() string

type MeterAction added in v0.6.0

type MeterAction struct {
	MeterId uint32
}

func NewMeterAction added in v0.6.0

func NewMeterAction(meterId uint32) *MeterAction

func (*MeterAction) GetActionMessage added in v0.6.0

func (a *MeterAction) GetActionMessage() openflow15.Action

func (*MeterAction) GetActionType added in v0.6.0

func (a *MeterAction) GetActionType() string

type MeterBundleMessage

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

type MeterFlag

type MeterFlag int

type MeterType

type MeterType uint16

type NXConjunctionAction

type NXConjunctionAction struct {
	ID      uint32
	Clause  uint8
	NClause uint8
}

func NewNXConjunctionAction

func NewNXConjunctionAction(conjID uint32, clause uint8, nClause uint8) (*NXConjunctionAction, error)

func (*NXConjunctionAction) GetActionMessage

func (a *NXConjunctionAction) GetActionMessage() openflow15.Action

func (*NXConjunctionAction) GetActionType

func (a *NXConjunctionAction) GetActionType() string

type NXConnTrackAction

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

func NewNXConnTrackAction

func NewNXConnTrackAction(commit bool, force bool, table *uint8, zone *uint16, actions ...openflow15.Action) *NXConnTrackAction

This function only support immediate number for ct_zone

func NewNXConnTrackActionWithZoneField added in v0.5.0

func NewNXConnTrackActionWithZoneField(commit bool, force bool, table *uint8, zoneImm *uint16, zoneSrcFieldName string, zoneSrcRange *openflow15.NXRange, actions ...openflow15.Action) *NXConnTrackAction

This function support immediate number and field or subfield for ct_zone

func (*NXConnTrackAction) GetActionMessage

func (a *NXConnTrackAction) GetActionMessage() openflow15.Action

func (*NXConnTrackAction) GetActionType

func (a *NXConnTrackAction) GetActionType() string

type NXController

type NXController struct {
	ControllerID uint16
	Reason       uint8
}

func (*NXController) GetActionMessage

func (a *NXController) GetActionMessage() openflow15.Action

func (*NXController) GetActionType

func (a *NXController) GetActionType() string

type NXLoadAction

type NXLoadAction struct {
	Field *openflow15.MatchField
	Value uint64
	Range *openflow15.NXRange
}

func NewNXLoadAction

func NewNXLoadAction(fieldName string, data uint64, dataRange *openflow15.NXRange) (*NXLoadAction, error)

func (*NXLoadAction) GetActionMessage

func (a *NXLoadAction) GetActionMessage() openflow15.Action

func (*NXLoadAction) GetActionType

func (a *NXLoadAction) GetActionType() string

func (*NXLoadAction) ResetFieldLength

func (a *NXLoadAction) ResetFieldLength(ofSwitch *OFSwitch)

type NXLoadXXRegAction

type NXLoadXXRegAction struct {
	FieldNumber uint8
	Value       []byte
	Mask        []byte
}

func (*NXLoadXXRegAction) GetActionMessage

func (a *NXLoadXXRegAction) GetActionMessage() openflow15.Action

func (*NXLoadXXRegAction) GetActionType

func (a *NXLoadXXRegAction) GetActionType() string

type NXMoveAction

type NXMoveAction struct {
	SrcField  *openflow15.MatchField
	DstField  *openflow15.MatchField
	SrcStart  uint16
	DstStart  uint16
	MoveNbits uint16
}

func NewNXMoveAction

func NewNXMoveAction(srcName string, dstName string, srcRange *openflow15.NXRange, dstRange *openflow15.NXRange) (*NXMoveAction, error)

func (*NXMoveAction) GetActionMessage

func (a *NXMoveAction) GetActionMessage() openflow15.Action

func (*NXMoveAction) GetActionType

func (a *NXMoveAction) GetActionType() string

func (*NXMoveAction) ResetFieldsLength

func (a *NXMoveAction) ResetFieldsLength(ofSwitch *OFSwitch)

type NXNoteAction

type NXNoteAction struct {
	Notes []byte
}

func (*NXNoteAction) GetActionMessage

func (a *NXNoteAction) GetActionMessage() openflow15.Action

func (*NXNoteAction) GetActionType

func (a *NXNoteAction) GetActionType() string

type NXOutput

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

func NewNXOutput

func NewNXOutput(name string, start int, end int) (*NXOutput, error)

func (*NXOutput) GetActionMessage

func (self *NXOutput) GetActionMessage() openflow15.Action

Return a NXOutput action

func (*NXOutput) GetActionType

func (self *NXOutput) GetActionType() string

type NXRegister

type NXRegister struct {
	ID    int                 // ID of NXM_NX_REG, value should be from 0 to 15
	Data  uint32              // Data to cache in register. Note: Don't shift Data to its offset in caller
	Mask  uint32              // Bitwise mask of data
	Range *openflow15.NXRange // Range of bits in register
}

Matches data either exactly or with optional mask in register number ID. The mask could be calculated according to range automatically

type NXTunMetadata

type NXTunMetadata struct {
	ID    int                 // ID of NXM_NX_TUN_METADATA, value should be from 0 to 7. OVS supports 64 tun_metadata, but only 0-7 is implemented in libOpenflow
	Data  interface{}         // Data to set in the register
	Range *openflow15.NXRange // Range of bits in the field
}

type OFAction

type OFAction interface {
	GetActionMessage() openflow15.Action
	GetActionType() string
}

type OFError

type OFError struct {
	Type     uint8
	Code     uint8
	VendorID uint32
	Message  string
}

type OFSwitch

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

func NewSwitch

func NewSwitch(stream *util.MessageStream, dpid net.HardwareAddr, app AppInterface, connCh chan int, ctrlID uint16) *OFSwitch

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

func (*OFSwitch) AddTunnelTLVMap

func (s *OFSwitch) AddTunnelTLVMap(optClass uint16, optType uint8, optLength uint8, tunMetadataIndex uint16) error

func (*OFSwitch) CheckStatus

func (self *OFSwitch) CheckStatus(timeout time.Duration) bool

func (*OFSwitch) ClearTunnelTLVMap

func (s *OFSwitch) ClearTunnelTLVMap(tlvMaps []*openflow15.TLVTableMap) error

func (*OFSwitch) DPID

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

Returns the dpid of Switch s.

func (*OFSwitch) DefaultTable

func (self *OFSwitch) DefaultTable() *Table

Return table 0 which is the starting table for all packets

func (*OFSwitch) DeleteGroup

func (self *OFSwitch) DeleteGroup(groupId uint32) error

Delete a group. Return an error if there are flows refer pointing at it

func (*OFSwitch) DeleteMeter

func (self *OFSwitch) DeleteMeter(meterId uint32) error

Delete a meter. Return an error if there are flows refer pointing at it

func (*OFSwitch) DeleteTable

func (self *OFSwitch) DeleteTable(tableId uint8) error

Delete a table. Return an error if there are fgraph nodes pointing at it

func (*OFSwitch) DeleteTunnelTLVMap

func (s *OFSwitch) DeleteTunnelTLVMap(tlvMaps []*openflow15.TLVTableMap) error

func (*OFSwitch) DisableOFPortForwarding

func (self *OFSwitch) DisableOFPortForwarding(port int, portMAC net.HardwareAddr) error

func (*OFSwitch) Disconnect

func (self *OFSwitch) Disconnect()

func (*OFSwitch) DropAction

func (self *OFSwitch) DropAction() *Output

Return the drop graph element

func (*OFSwitch) DumpFlowStats

func (self *OFSwitch) DumpFlowStats(cookieID uint64, cookieMask *uint64, flowMatch *FlowMatch, tableID *uint8) ([]*openflow15.FlowDesc, error)

func (*OFSwitch) EnableMonitor

func (self *OFSwitch) EnableMonitor()

func (*OFSwitch) EnableOFPortForwarding

func (self *OFSwitch) EnableOFPortForwarding(port int, portMAC net.HardwareAddr) error

func (*OFSwitch) GetControllerID

func (self *OFSwitch) GetControllerID() uint16

func (*OFSwitch) GetGroup

func (self *OFSwitch) GetGroup(groupId uint32) *Group

GetGroup Returns a group

func (*OFSwitch) GetMeter

func (self *OFSwitch) GetMeter(meterId uint32) *Meter

GetGroup Returns a meter

func (*OFSwitch) GetTLVMapTableStatus

func (s *OFSwitch) GetTLVMapTableStatus() *TLVTableStatus

func (*OFSwitch) GetTable

func (self *OFSwitch) GetTable(tableId uint8) *Table

GetTable Returns a table

func (*OFSwitch) IsReady

func (self *OFSwitch) IsReady() bool

func (*OFSwitch) NewFlood

func (self *OFSwitch) NewFlood() (*Flood, error)

Create a new flood list

func (*OFSwitch) NewGroup

func (self *OFSwitch) NewGroup(groupId uint32, groupType GroupType) (*Group, error)

Create a new group. return an error if it already exists

func (*OFSwitch) NewMeter

func (self *OFSwitch) NewMeter(meterId uint32, flags MeterFlag) (*Meter, error)

Create a new meter. return an error if it already exists

func (*OFSwitch) NewTable

func (self *OFSwitch) NewTable(tableId uint8) (*Table, error)

Create a new table. return an error if it already exists

func (*OFSwitch) NewTransaction

func (self *OFSwitch) NewTransaction(flag TransactionType) *Transaction

NewTransaction creates a transaction on the switch. It will assign a bundle ID, and sets the bundle flags.

func (*OFSwitch) NormalLookup

func (self *OFSwitch) NormalLookup() *Output

NormalLookup Return normal lookup graph element

func (*OFSwitch) OutputPort

func (self *OFSwitch) OutputPort(portNo uint32) (*Output, error)

Return a output graph element for the port

func (*OFSwitch) Send

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

Sends an OpenFlow message to this Switch.

func (*OFSwitch) SendToController

func (self *OFSwitch) SendToController() *Output

SendToController Return send to controller graph element

type OpenFlowModMessage

type OpenFlowModMessage interface {
	// contains filtered or unexported methods
}

type Output

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

func NewOutputController

func NewOutputController() *Output

func NewOutputInPort

func NewOutputInPort() *Output

func NewOutputNormal

func NewOutputNormal() *Output

func NewOutputPort

func NewOutputPort(portNo uint32) *Output

func (*Output) GetActionMessage

func (self *Output) GetActionMessage() openflow15.Action

Return an output action (Used by group mods)

func (*Output) GetActionType

func (self *Output) GetActionType() string

func (*Output) GetFlowInstr

func (self *Output) GetFlowInstr() openflow15.Instruction

instruction set for output element

func (*Output) Type

func (self *Output) Type() string

Fgraph element type for the output

type OvsDriver

type OvsDriver struct {

	// Name of the OVS bridge
	OvsBridgeName string
	// contains filtered or unexported fields
}

OVS driver state

func NewOvsDriver

func NewOvsDriver(bridgeName string) *OvsDriver

Create a new OVS driver

func (*OvsDriver) AddController

func (self *OvsDriver) AddController(ipAddr string, portNo uint16) error

Add controller configuration to OVS

func (*OvsDriver) CreateBridge

func (self *OvsDriver) CreateBridge(bridgeName string) error

**************** OVS driver API ********************

func (*OvsDriver) CreatePort

func (self *OvsDriver) CreatePort(intfName, intfType string, vlanTag uint) error

Create an internal port in OVS

func (*OvsDriver) CreateVtep

func (self *OvsDriver) CreateVtep(intfName string, vtepRemoteIP string) error

Create a VTEP port on the OVS

func (*OvsDriver) Delete

func (d *OvsDriver) Delete() error

Delete : Cleanup the ovsdb driver. delete the bridge we created.

func (*OvsDriver) DeleteBridge

func (self *OvsDriver) DeleteBridge(bridgeName string) error

Delete a bridge from ovs

func (*OvsDriver) DeletePort

func (self *OvsDriver) DeletePort(intfName string) error

Delete a port from OVS

func (*OvsDriver) DeleteVtep

func (self *OvsDriver) DeleteVtep(intfName string) error

Delete a VTEP port

func (*OvsDriver) Disconnected

func (self *OvsDriver) Disconnected(ovsClient *libovsdb.OvsdbClient)

func (*OvsDriver) Echo

func (self *OvsDriver) Echo([]interface{})

func (*OvsDriver) GetOfpPortNo

func (self *OvsDriver) GetOfpPortNo(intfName string) (uint32, error)

Return OFP port number for an interface

func (*OvsDriver) IsBridgePresent

func (self *OvsDriver) IsBridgePresent(bridgeName string) bool

Check if the bridge entry already exists

func (*OvsDriver) IsControllerPresent

func (self *OvsDriver) IsControllerPresent(ipAddr string, portNo uint16) bool

Check if Controller already exists

func (*OvsDriver) IsPortNamePresent

func (self *OvsDriver) IsPortNamePresent(intfName string) bool

Check the local cache and see if the portname is taken already HACK alert: This is used to pick next port number instead of managing

port number space actively across agent restarts

func (*OvsDriver) IsVtepPresent

func (self *OvsDriver) IsVtepPresent(remoteIP string) (bool, string)

Check if VTEP already exists

func (*OvsDriver) Locked

func (self *OvsDriver) Locked([]interface{})

func (*OvsDriver) PrintCache

func (self *OvsDriver) PrintCache()

Dump the contents of the cache into stdout

func (*OvsDriver) RemoveController

func (self *OvsDriver) RemoveController(target string) error

func (*OvsDriver) Stolen

func (self *OvsDriver) Stolen([]interface{})

func (*OvsDriver) Update

func (self *OvsDriver) Update(context interface{}, tableUpdates libovsdb.TableUpdates)

************************ Notification handler for OVS DB changes ****************

type PacketIn

type PacketIn openflow15.PacketIn

func (*PacketIn) GetMatches

func (p *PacketIn) GetMatches() *Matchers

type PacketOut

type PacketOut struct {
	InPort  uint32
	OutPort uint32
	Actions []OFAction

	SrcMAC     net.HardwareAddr
	DstMAC     net.HardwareAddr
	IPHeader   *protocol.IPv4
	IPv6Header *protocol.IPv6
	TCPHeader  *protocol.TCP
	UDPHeader  *protocol.UDP
	ICMPHeader *protocol.ICMP

	ARPHeader *protocol.ARP
}

func GenerateSimpleIPPacket

func GenerateSimpleIPPacket(srcMAC, dstMAC net.HardwareAddr, srcIP, dstIP net.IP) *PacketOut

func GenerateTCPPacket

func GenerateTCPPacket(srcMAC, dstMAC net.HardwareAddr, srcIP, dstIP net.IP, dstPort, srcPort uint16, tcpFlags *uint8) *PacketOut

func (*PacketOut) GetMessage

func (p *PacketOut) GetMessage() util.Message

type PopMPLSAction added in v0.5.6

type PopMPLSAction struct {
	EtherType uint16
}

func (*PopMPLSAction) GetActionMessage added in v0.5.6

func (a *PopMPLSAction) GetActionMessage() openflow15.Action

func (*PopMPLSAction) GetActionType added in v0.5.6

func (a *PopMPLSAction) GetActionType() string

type PopVLANAction

type PopVLANAction struct {
}

func (*PopVLANAction) GetActionMessage

func (a *PopVLANAction) GetActionMessage() openflow15.Action

func (*PopVLANAction) GetActionType

func (a *PopVLANAction) GetActionType() string

type PortField

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

func (*PortField) Len

func (m *PortField) Len() uint16

func (*PortField) MarshalBinary

func (m *PortField) MarshalBinary() (data []byte, err error)

func (*PortField) UnmarshalBinary

func (m *PortField) UnmarshalBinary(data []byte) error

type ProtocolField

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

func (*ProtocolField) Len

func (m *ProtocolField) Len() uint16

func (*ProtocolField) MarshalBinary

func (m *ProtocolField) MarshalBinary() (data []byte, err error)

func (*ProtocolField) UnmarshalBinary

func (m *ProtocolField) UnmarshalBinary(data []byte) error

type PushMPLSAction added in v0.5.6

type PushMPLSAction struct {
	EtherType uint16
}

func (*PushMPLSAction) GetActionMessage added in v0.5.6

func (a *PushMPLSAction) GetActionMessage() openflow15.Action

func (*PushMPLSAction) GetActionType added in v0.5.6

func (a *PushMPLSAction) GetActionType() string

type PushVLANAction added in v0.4.0

type PushVLANAction struct {
	EtherType uint16
}

func (*PushVLANAction) GetActionMessage added in v0.4.0

func (a *PushVLANAction) GetActionMessage() openflow15.Action

func (*PushVLANAction) GetActionType added in v0.4.0

func (a *PushVLANAction) GetActionType() string

type Resubmit

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

func NewResubmit

func NewResubmit(inPort *uint16, table *uint8) *Resubmit

func NewResubmitWithCT added in v0.5.3

func NewResubmitWithCT(inPort *uint16, table *uint8) *Resubmit

func (*Resubmit) GetActionMessage

func (self *Resubmit) GetActionMessage() openflow15.Action

Return a resubmit action (Used as a last action by flows in the table pipeline)

func (*Resubmit) GetActionType

func (self *Resubmit) GetActionType() string

func (*Resubmit) GetFlowInstr

func (self *Resubmit) GetFlowInstr() openflow15.Instruction

instruction set for resubmit element

func (*Resubmit) Type

func (self *Resubmit) Type() string

Fgraph element type for the Resubmit

type SetARPOpAction

type SetARPOpAction struct {
	Value uint16
}

func (*SetARPOpAction) GetActionMessage

func (a *SetARPOpAction) GetActionMessage() openflow15.Action

func (*SetARPOpAction) GetActionType

func (a *SetARPOpAction) GetActionType() string

type SetARPShaAction

type SetARPShaAction struct {
	MAC net.HardwareAddr
}

func (*SetARPShaAction) GetActionMessage

func (a *SetARPShaAction) GetActionMessage() openflow15.Action

func (*SetARPShaAction) GetActionType

func (a *SetARPShaAction) GetActionType() string

type SetARPSpaAction

type SetARPSpaAction struct {
	IP net.IP
}

func (*SetARPSpaAction) GetActionMessage

func (a *SetARPSpaAction) GetActionMessage() openflow15.Action

func (*SetARPSpaAction) GetActionType

func (a *SetARPSpaAction) GetActionType() string

type SetARPThaAction

type SetARPThaAction struct {
	MAC net.HardwareAddr
}

func (*SetARPThaAction) GetActionMessage

func (a *SetARPThaAction) GetActionMessage() openflow15.Action

func (*SetARPThaAction) GetActionType

func (a *SetARPThaAction) GetActionType() string

type SetARPTpaAction

type SetARPTpaAction struct {
	IP net.IP
}

func (*SetARPTpaAction) GetActionMessage

func (a *SetARPTpaAction) GetActionMessage() openflow15.Action

func (*SetARPTpaAction) GetActionType

func (a *SetARPTpaAction) GetActionType() string

type SetDSCPAction

type SetDSCPAction struct {
	Value uint8
	Mask  *uint8
}

func (*SetDSCPAction) GetActionMessage

func (a *SetDSCPAction) GetActionMessage() openflow15.Action

func (*SetDSCPAction) GetActionType

func (a *SetDSCPAction) GetActionType() string

type SetDstIPAction

type SetDstIPAction struct {
	IP     net.IP
	IPMask *net.IP
}

func (*SetDstIPAction) GetActionMessage

func (a *SetDstIPAction) GetActionMessage() openflow15.Action

func (*SetDstIPAction) GetActionType

func (a *SetDstIPAction) GetActionType() string

type SetDstMACAction

type SetDstMACAction struct {
	MAC net.HardwareAddr
}

func (*SetDstMACAction) GetActionMessage

func (a *SetDstMACAction) GetActionMessage() openflow15.Action

func (*SetDstMACAction) GetActionType

func (a *SetDstMACAction) GetActionType() string

type SetFieldAction added in v0.6.0

type SetFieldAction struct {
	Field *openflow15.MatchField
}

func NewSetFieldAction added in v0.6.0

func NewSetFieldAction(field *openflow15.MatchField) *SetFieldAction

func (*SetFieldAction) GetActionMessage added in v0.6.0

func (a *SetFieldAction) GetActionMessage() openflow15.Action

func (*SetFieldAction) GetActionType added in v0.6.0

func (a *SetFieldAction) GetActionType() string

type SetICMPv4CodeAction added in v0.2.5

type SetICMPv4CodeAction struct {
	Code uint8
}

Currently, we only support Flow.Send() function to generate ICMP match/set flow message. We can also support Flow.Next() function to generate ICMP match/set flow message in future once libOpenflow support NewICMPXxxxField API.

func (*SetICMPv4CodeAction) GetActionMessage added in v0.2.5

func (a *SetICMPv4CodeAction) GetActionMessage() openflow15.Action

func (*SetICMPv4CodeAction) GetActionType added in v0.2.5

func (a *SetICMPv4CodeAction) GetActionType() string

type SetICMPv4TypeAction added in v0.2.5

type SetICMPv4TypeAction struct {
	Type uint8
}

Currently, we only support Flow.Send() function to generate ICMP match/set flow message. We can also support Flow.Next() function to generate ICMP match/set flow message in future once libOpenflow support NewICMPXxxxField API.

func (*SetICMPv4TypeAction) GetActionMessage added in v0.2.5

func (a *SetICMPv4TypeAction) GetActionMessage() openflow15.Action

func (*SetICMPv4TypeAction) GetActionType added in v0.2.5

func (a *SetICMPv4TypeAction) GetActionType() string

type SetICMPv6CodeAction

type SetICMPv6CodeAction struct {
	Code uint8
}

func (*SetICMPv6CodeAction) GetActionMessage

func (a *SetICMPv6CodeAction) GetActionMessage() openflow15.Action

func (*SetICMPv6CodeAction) GetActionType

func (a *SetICMPv6CodeAction) GetActionType() string

type SetICMPv6TypeAction

type SetICMPv6TypeAction struct {
	Type uint8
}

func (*SetICMPv6TypeAction) GetActionMessage

func (a *SetICMPv6TypeAction) GetActionMessage() openflow15.Action

func (*SetICMPv6TypeAction) GetActionType

func (a *SetICMPv6TypeAction) GetActionType() string

type SetNDSLLAction

type SetNDSLLAction struct {
	MAC net.HardwareAddr
}

func (*SetNDSLLAction) GetActionMessage

func (a *SetNDSLLAction) GetActionMessage() openflow15.Action

func (*SetNDSLLAction) GetActionType

func (a *SetNDSLLAction) GetActionType() string

type SetNDTLLAction

type SetNDTLLAction struct {
	MAC net.HardwareAddr
}

func (*SetNDTLLAction) GetActionMessage

func (a *SetNDTLLAction) GetActionMessage() openflow15.Action

func (*SetNDTLLAction) GetActionType

func (a *SetNDTLLAction) GetActionType() string

type SetNDTargetAction

type SetNDTargetAction struct {
	Target net.IP
}

func (*SetNDTargetAction) GetActionMessage

func (a *SetNDTargetAction) GetActionMessage() openflow15.Action

func (*SetNDTargetAction) GetActionType

func (a *SetNDTargetAction) GetActionType() string

type SetSCTPDstAction

type SetSCTPDstAction struct {
	Port uint16
}

func (*SetSCTPDstAction) GetActionMessage

func (a *SetSCTPDstAction) GetActionMessage() openflow15.Action

func (*SetSCTPDstAction) GetActionType

func (a *SetSCTPDstAction) GetActionType() string

type SetSCTPSrcAction

type SetSCTPSrcAction struct {
	Port uint16
}

func (*SetSCTPSrcAction) GetActionMessage

func (a *SetSCTPSrcAction) GetActionMessage() openflow15.Action

func (*SetSCTPSrcAction) GetActionType

func (a *SetSCTPSrcAction) GetActionType() string

type SetSrcIPAction

type SetSrcIPAction struct {
	IP     net.IP
	IPMask *net.IP
}

func (*SetSrcIPAction) GetActionMessage

func (a *SetSrcIPAction) GetActionMessage() openflow15.Action

func (*SetSrcIPAction) GetActionType

func (a *SetSrcIPAction) GetActionType() string

type SetSrcMACAction

type SetSrcMACAction struct {
	MAC net.HardwareAddr
}

func (*SetSrcMACAction) GetActionMessage

func (a *SetSrcMACAction) GetActionMessage() openflow15.Action

func (*SetSrcMACAction) GetActionType

func (a *SetSrcMACAction) GetActionType() string

type SetTCPDstPortAction

type SetTCPDstPortAction struct {
	Port uint16
}

func (*SetTCPDstPortAction) GetActionMessage

func (a *SetTCPDstPortAction) GetActionMessage() openflow15.Action

func (*SetTCPDstPortAction) GetActionType

func (a *SetTCPDstPortAction) GetActionType() string

type SetTCPFlagsAction

type SetTCPFlagsAction struct {
	Flags    uint16
	FlagMask *uint16
}

func (*SetTCPFlagsAction) GetActionMessage

func (a *SetTCPFlagsAction) GetActionMessage() openflow15.Action

func (*SetTCPFlagsAction) GetActionType

func (a *SetTCPFlagsAction) GetActionType() string

type SetTCPSrcPortAction

type SetTCPSrcPortAction struct {
	Port uint16
}

func (*SetTCPSrcPortAction) GetActionMessage

func (a *SetTCPSrcPortAction) GetActionMessage() openflow15.Action

func (*SetTCPSrcPortAction) GetActionType

func (a *SetTCPSrcPortAction) GetActionType() string

type SetTunnelDstAction

type SetTunnelDstAction struct {
	IP net.IP
}

func (*SetTunnelDstAction) GetActionMessage

func (a *SetTunnelDstAction) GetActionMessage() openflow15.Action

func (*SetTunnelDstAction) GetActionType

func (a *SetTunnelDstAction) GetActionType() string

type SetTunnelIDAction

type SetTunnelIDAction struct {
	TunnelID uint64
}

func (*SetTunnelIDAction) GetActionMessage

func (a *SetTunnelIDAction) GetActionMessage() openflow15.Action

func (*SetTunnelIDAction) GetActionType

func (a *SetTunnelIDAction) GetActionType() string

type SetTunnelSrcAction

type SetTunnelSrcAction struct {
	IP net.IP
}

func (*SetTunnelSrcAction) GetActionMessage

func (a *SetTunnelSrcAction) GetActionMessage() openflow15.Action

func (*SetTunnelSrcAction) GetActionType

func (a *SetTunnelSrcAction) GetActionType() string

type SetUDPDstPortAction

type SetUDPDstPortAction struct {
	Port uint16
}

func (*SetUDPDstPortAction) GetActionMessage

func (a *SetUDPDstPortAction) GetActionMessage() openflow15.Action

func (*SetUDPDstPortAction) GetActionType

func (a *SetUDPDstPortAction) GetActionType() string

type SetUDPSrcPortAction

type SetUDPSrcPortAction struct {
	Port uint16
}

func (*SetUDPSrcPortAction) GetActionMessage

func (a *SetUDPSrcPortAction) GetActionMessage() openflow15.Action

func (*SetUDPSrcPortAction) GetActionType

func (a *SetUDPSrcPortAction) GetActionType() string

type SetVLANAction

type SetVLANAction struct {
	VlanID uint16
}

func (*SetVLANAction) GetActionMessage

func (a *SetVLANAction) GetActionMessage() openflow15.Action

func (*SetVLANAction) GetActionType

func (a *SetVLANAction) GetActionType() string

type TLVStatusManager

type TLVStatusManager interface {
	TLVMapReplyRcvd(ofSwitch *OFSwitch, status *TLVTableStatus)
}

type TLVTableStatus

type TLVTableStatus openflow15.TLVTableReply

func (*TLVTableStatus) AddTLVMap

func (t *TLVTableStatus) AddTLVMap(m *openflow15.TLVTableMap)

func (*TLVTableStatus) GetAllocatedResources

func (t *TLVTableStatus) GetAllocatedResources() (space uint32, indexes []uint16)

func (*TLVTableStatus) GetMaxFields

func (t *TLVTableStatus) GetMaxFields() uint16

func (*TLVTableStatus) GetMaxSpace

func (t *TLVTableStatus) GetMaxSpace() uint32

func (*TLVTableStatus) GetTLVMap

func (t *TLVTableStatus) GetTLVMap(index uint16) *openflow15.TLVTableMap

func (*TLVTableStatus) GetTLVMapString

func (t *TLVTableStatus) GetTLVMapString(m *openflow15.TLVTableMap) string

func (*TLVTableStatus) String

func (t *TLVTableStatus) String() string

type Table

type Table struct {
	Switch  *OFSwitch
	TableId uint8
	// contains filtered or unexported fields
}

Fgraph table element

func (*Table) Delete

func (self *Table) Delete() error

Delete the table

func (*Table) DeleteFlow

func (self *Table) DeleteFlow(flowKey string) error

Delete a flow from the table

func (*Table) GetFlowInstr

func (self *Table) GetFlowInstr() openflow15.Instruction

instruction set for table element

func (*Table) NewFlow

func (self *Table) NewFlow(match FlowMatch) (*Flow, error)

Create a new flow on the table

func (*Table) Type

func (self *Table) Type() string

Fgraph element type for table

type Transaction

type Transaction struct {
	ID uint32
	// contains filtered or unexported fields
}

func (*Transaction) Abort

func (tx *Transaction) Abort() error

Abort discards the bundle configuration. If transaction is not closed, it sends OFPBCT_CLOSE_REQUEST in advance.

func (*Transaction) AddFlow

func (tx *Transaction) AddFlow(flowMod *openflow15.FlowMod) error

func (*Transaction) AddMessage

func (tx *Transaction) AddMessage(modMessage OpenFlowModMessage) error

AddMessage adds messages in the bundle.

func (*Transaction) Begin

func (tx *Transaction) Begin() error

Begin opens a bundle configuration.

func (*Transaction) Commit

func (tx *Transaction) Commit() error

Commit commits the bundle configuration. If transaction is not closed, it sends OFPBCT_CLOSE_REQUEST in advance.

func (*Transaction) Complete

func (tx *Transaction) Complete() (int, error)

Complete closes the bundle configuration. It returns the number of successful messages added in the bundle.

type TransactionType

type TransactionType uint16

type Uint32WithMask

type Uint32WithMask struct {
	Value uint32
	Mask  uint32
}

type Uint64WithMask

type Uint64WithMask struct {
	Value uint64
	Mask  uint64
}

type XXRegister

type XXRegister struct {
	ID   int    // ID of NXM_NX_XXREG, value should be from 0 to 3
	Data []byte // Data to cache in xxreg
}

Jump to

Keyboard shortcuts

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