Documentation ¶
Overview ¶
OpenFlow protocol.
Index ¶
- Constants
- func ActionLen(a Action) uint16
- type Action
- type ActionEnqueue
- type ActionNwAddrDst
- type ActionNwAddrSrc
- type ActionNwTos
- type ActionOutput
- type ActionSetDlDst
- type ActionSetDlSrc
- type ActionTpPortDst
- type ActionTpPortSrc
- type ActionType
- type ActionVlanPcp
- type ActionVlanVid
- type ConfigFlags
- type DescStats
- type EchoReply
- type EchoRequest
- type Error
- type ErrorType
- type FlowMod
- type FlowModCommand
- type FlowRemoved
- type FlowRemovedPart
- type FlowRemovedReason
- type FlowStatsRequest
- type FromSwitch
- type Header
- type Hello
- type Match
- type PacketIn
- type PacketOut
- type PhyPort
- type PortMod
- type PortStatus
- type Ppr
- type Stat
- type StatsReply
- type StatsReplyFlags
- type StatsRequest
- type StatsType
- type SwitchConfig
- type SwitchFeatures
- type SwitchFeaturesRequest
- type ToSwitch
- type Type
Constants ¶
const ( /* Maximum number of physical switch ports. */ OFPP_MAX = 0xff00 /* Fake output "ports". */ OFPP_IN_PORT = 0xfff8 /* Send the packet out the input port. This virtual port must be explicitly used in order to send back out of the input port. */ OFPP_TABLE = 0xfff9 /* Perform actions in flow table. NB: This can only be the destination port for packet-out messages. */ OFPP_NORMAL = 0xfffa /* Process with normal L2/L3 switching. */ PortFlood = 0xfffb /* All physical ports except input port and those disabled by STP. */ OFPP_ALL = 0xfffc /* All physical ports except input port. */ OFPP_CONTROLLER = 0xfffd /* Send to controller. */ OFPP_LOCAL = 0xfffe /* Local openflow "port". */ OFPP_NONE = 0xffff /* Not associated with a physical port. */ )
Port numbering. Physical ports are numbered starting from 1.
const ( FlowStats = 1 << 0 /* Flow statistics. */ TableStats = 1 << 1 /* Table statistics. */ PortStats = 1 << 2 /* Port statistics. */ STP = 1 << 3 /* 802.1d spanning tree. */ IpReasm = 1 << 5 /* Can reassemble IP fragments. */ QueueStats = 1 << 6 /* Queue statistics. */ ArpMatchIp = 1 << 7 /* Match IP addresses in ARP pkts. */ )
Capabilities supported by the datapath.
const ( OfppcPortDown uint32 = 1 << 0 // port is administratively down OfppcNoStp uint32 = 1 << 1 // disable 802.1d spanning tree on port OfppcNoRecv uint32 = 1 << 2 // drop all packets except spanning tree packets OfppcNoRecvStp uint32 = 1 << 3 // drop received 802.1d stp packets OfppcNoFlood uint32 = 1 << 4 // do not include this port when flooding OfppcNoFwd uint32 = 1 << 5 // drop packets forwarded to port OfppcNoPacketIn uint32 = 1 << 6 // do not send packet-in msgs for port )
Flags to indicate behavior of the physical port. These flags are used in PhyPort to describe the current configuration. They are used in the PortMod message to configure the port's behavior.
const ( OfppsLinkDown uint32 = 1 << 0 /* No physical link present. */ // The OfppsStp* bits have no effect on switch operation. The // controller must adjust OfppcNoRecv, OfppcNoFwd, // OfppcNoPacketIn appropriately to fully implement an 802.1D spanning // tree. OfppsStpListen uint32 = 0 << 8 // Not learning or relaying frames OfppsStpLearn uint32 = 1 << 8 // learning but not relaying frames OfppsStpForward uint32 = 2 << 8 // learning and relaying frames OfppsStpBlock uint32 = 3 << 8 // not part of spanning tree OfppsStpMask uint32 = 3 << 8 // bit mask for ofpps_stp_* values )
Current state of the physical port. These are not configurable from the controller.
const ( Ppf10MBHd uint32 = 1 << 0 /* 10 Mb half-duplex rate support. */ Ppf10MBFd uint32 = 1 << 1 /* 10 Mb full-duplex rate support. */ Ppf100MBHd uint32 = 1 << 2 /* 100 Mb half-duplex rate support. */ Ppf100MBFd uint32 = 1 << 3 /* 100 Mb full-duplex rate support. */ Ppf1GBHd uint32 = 1 << 4 /* 1 Gb half-duplex rate support. */ Ppf1GBFd uint32 = 1 << 5 /* 1 Gb full-duplex rate support. */ Ppf10GBFd uint32 = 1 << 6 /* 10 Gb full-duplex rate support. */ PpfCopper uint32 = 1 << 7 /* Copper medium. */ PpfFiber uint32 = 1 << 8 /* Fiber medium. */ PpfAutoneg uint32 = 1 << 9 /* Auto-negotiation. */ PpfPause uint32 = 1 << 10 /* Pause. */ PpfPauseAsym uint32 = 1 << 11 /* Asymmetric pause. */ )
Features of physical ports available in a datapath
const ( ReasonNoMatch uint8 = iota /* No matching flow. */ ReasonAction /* Action explicitly output to controller. */ )
Why is this packet being sent to the controller?
const ( FCAdd = iota /* New flow. */ FCModify /* Modify all matching flows. */ FCModifyStrict /* Modify entry strictly matching wildcards */ FCDelete /* Delete all matching flows. */ FCDeleteStrict /* Strictly match wildcards and priority. */ )
const ( FwInPort uint32 = 1 << 0 /* Switch input port. */ FwDlVlan uint32 = 1 << 1 /* VLAN id. */ FwDlSrc uint32 = 1 << 2 /* Ethernet source address. */ FwDlDst uint32 = 1 << 3 /* Ethernet destination address. */ FwDlType uint32 = 1 << 4 /* Ethernet frame type. */ FwNwProto uint32 = 1 << 5 /* IP protocol. */ FwTpSrc uint32 = 1 << 6 /* TCP/UDP source port. */ FwTpDst uint32 = 1 << 7 /* TCP/UDP destination port. */ /* IP source address wildcard bit count. 0 is exact match 1 ignores the * LSB 2 ignores the 2 least-significant bits ... 32 and higher wildcard * the entire field. This is the *opposite* of the usual convention where * e.g. /24 indicates that 8 bits (not 24 bits) are wildcarded. */ FwNwSrcShift uint32 = 8 FwNwSrcBits uint32 = 6 FwNwSrcMask uint32 = ((1 << FwNwSrcBits) - 1) << FwNwSrcShift FwNwSrcAll uint32 = 32 << FwNwSrcShift /* IP destination address wildcard bit count. Same format as source. */ FwNwDstShift uint32 = 14 FwNwDstBits uint32 = 6 FwNwDstMask uint32 = ((1 << FwNwDstBits) - 1) << FwNwDstShift FwNwDstAll uint32 = 32 << FwNwDstShift FwDlVlanPcp uint32 = 1 << 20 /* VLAN priority. */ FwNwTos uint32 = 1 << 21 /* IP ToS (DSCP field 6 bits). */ FwAll uint32 = ((1 << 22) - 1) // Wildcard all fields )
Flow wildcards.
const ( SendFlowRem uint16 = 1 << 0 /* Send flow removed message when flow * expires or is deleted. */ CheckOverlap uint16 = 1 << 1 /* Check for overlapping entries first. */ Emergency uint16 = 1 << 2 /* Remark this is for emergency. */ )
const DescStrLen = 256
const EthAlen = 6 /* Bytes in an Ethernet address. */
const FW_ICMP_CODE = FwTpDst
const FW_ICMP_TYPE = FwTpSrc
The wildcards for ICMP type and code fields use the transport source * and destination port fields respectively.
const FlowPermanent = 0
Value used in "idle_timeout" and "hard_timeout" to indicate that the entry * is permanent.
const HeaderSize = 8
const OFP_DEFAULT_MISS_SEND_LEN uint16 = 128
const OFP_DL_TYPE_ETH2_CUTOFF = 0x0600
Values below this cutoff are 802.3 packets and the two bytes * following MAC addresses are used as a frame length. Otherwise the * two bytes are used as the Ethernet type.
const OFP_DL_TYPE_NOT_ETH_TYPE = 0x05ff
Value of dl_type to indicate that the frame does not include an * Ethernet type.
const OFP_MAX_PORT_NAME_LEN = 16
const OFP_MAX_TABLE_NAME_LEN = 32
const OFP_SSL_PORT = 6633
const OFP_TCP_PORT = 6633
const OFP_VERSION = 0x01
Version number: * Non-experimental versions released: 0x01 * Experimental versions released: 0x81 -- 0x99 * * The most significant bit being set in the version field indicates an * experimental OpenFlow version.
const OFP_VLAN_NONE = 0xffff
The VLAN id is 12-bits so we can use the entire 16 bits to indicate * special conditions. All ones indicates that no VLAN id was set.
const SerialNumLen = 32
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ActionEnqueue ¶
type ActionEnqueue struct { Port uint16 /* Output port. */ QueueId uint32 /* Where to enqueue the packets. */ // contains filtered or unexported fields }
Action structure for OFPAT_ENQUEUE.
func (*ActionEnqueue) WriteAction ¶
func (m *ActionEnqueue) WriteAction(w io.Writer) error
type ActionNwAddrDst ¶
type ActionNwAddrDst struct {
NwAddr uint32 /* IP address. */
}
func (*ActionNwAddrDst) WriteAction ¶
func (m *ActionNwAddrDst) WriteAction(w io.Writer) error
type ActionNwAddrSrc ¶
type ActionNwAddrSrc struct {
NwAddr uint32 /* IP address. */
}
func (*ActionNwAddrSrc) WriteAction ¶
func (m *ActionNwAddrSrc) WriteAction(w io.Writer) error
type ActionNwTos ¶
type ActionNwTos struct { NwTos uint8 /* IP ToS (DSCP field 6 bits). */ // contains filtered or unexported fields }
Action structure for OFPAT_SET_NW_TOS.
func (*ActionNwTos) WriteAction ¶
func (m *ActionNwTos) WriteAction(w io.Writer) error
type ActionOutput ¶
type ActionOutput struct { Port uint16 /* Output port. */ MaxLen uint16 /* Max length to send to controller. */ }
Action structure for OFPAT_OUTPUT which sends packets out 'port'. * When the 'port' is the OFPP_CONTROLLER 'MaxLen' indicates the max * number of bytes to send. A 'MaxLen' of zero means no bytes of the * packet should be sent.
func (*ActionOutput) WriteAction ¶
func (m *ActionOutput) WriteAction(w io.Writer) error
type ActionSetDlDst ¶
type ActionSetDlDst struct { DlAddr [EthAlen]uint8 /* Ethernet address. */ // contains filtered or unexported fields }
func (*ActionSetDlDst) WriteAction ¶
func (m *ActionSetDlDst) WriteAction(w io.Writer) error
type ActionSetDlSrc ¶
type ActionSetDlSrc struct { DlAddr [EthAlen]uint8 /* Ethernet address. */ // contains filtered or unexported fields }
func (*ActionSetDlSrc) WriteAction ¶
func (m *ActionSetDlSrc) WriteAction(w io.Writer) error
type ActionTpPortDst ¶
type ActionTpPortDst struct { TpPort uint16 /* TCP/UDP port. */ // contains filtered or unexported fields }
func (*ActionTpPortDst) WriteAction ¶
func (m *ActionTpPortDst) WriteAction(w io.Writer) error
type ActionTpPortSrc ¶
type ActionTpPortSrc struct { TpPort uint16 /* TCP/UDP port. */ // contains filtered or unexported fields }
func (*ActionTpPortSrc) WriteAction ¶
func (m *ActionTpPortSrc) WriteAction(w io.Writer) error
type ActionType ¶
type ActionType uint16
const ( OFPAT_OUTPUT ActionType = iota /* Output to switch port. */ OFPAT_SET_VLAN_VID /* Set the 802.1q VLAN id. */ OFPAT_SET_VLAN_PCP /* Set the 802.1q priority. */ OFPAT_STRIP_VLAN /* Strip the 802.1q header. */ OFPAT_SET_DL_SRC /* Ethernet source address. */ OFPAT_SET_DL_DST /* Ethernet destination address. */ OFPAT_SET_NW_SRC /* IP source address. */ OFPAT_SET_NW_DST /* IP destination address. */ OFPAT_SET_NW_TOS /* IP ToS (DSCP field 6 bits). */ OFPAT_SET_TP_SRC /* TCP/UDP source port. */ OFPAT_SET_TP_DST /* TCP/UDP destination port. */ OFPAT_ENQUEUE /* Output to queue. */ OFPAT_VENDOR ActionType = 0xffff )
type ActionVlanPcp ¶
type ActionVlanPcp struct { VlanPcp uint8 /* VLAN priority. */ // contains filtered or unexported fields }
func (*ActionVlanPcp) WriteAction ¶
func (m *ActionVlanPcp) WriteAction(w io.Writer) error
type ActionVlanVid ¶
type ActionVlanVid struct { VlanVid uint16 /* VLAN id. */ // contains filtered or unexported fields }
func (*ActionVlanVid) WriteAction ¶
func (m *ActionVlanVid) WriteAction(w io.Writer) error
type ConfigFlags ¶
type ConfigFlags uint16
const ( FragNormal ConfigFlags = 0 // No special handling for IP fragments. FragDrop ConfigFlags = 1 // Drop fragments. FragReasm ConfigFlags = 2 // Reassemble (only if OFPC_IP_REASM set). )
type DescStats ¶
type DescStats struct { MfrDesc [DescStrLen]byte /* Manufacturer description. */ HwDesc [DescStrLen]byte /* Hardware description. */ SwDesc [DescStrLen]byte /* Software description. */ SerialNum [SerialNumLen]byte /* Serial number. */ DpDesc [DescStrLen]byte /* Human readable description of datapath. */ }
Body of reply to OFPST_DESC request. Each entry is a NULL-terminated * ASCII string.
type EchoRequest ¶
type Error ¶
type ErrorType ¶
type ErrorType uint16
Values for 'type' in ofp_error_message. These values are immutable: they * will not change in future versions of the protocol (although new values may * be added).
type FlowMod ¶
type FlowMod struct { Xid uint32 Match Match Cookie uint64 /* Opaque controller-issued identifier. */ Command FlowModCommand /* One of OFPFC_*. */ IdleTimeout uint16 /* Idle time before discarding (seconds). */ HardTimeout uint16 /* Max time before discarding (seconds). */ Priority uint16 /* Priority level of flow entry. */ BufferId uint32 /* Buffered packet to apply to (or -1). Not meaningful for OFPFC_DELETE*. */ OutPort uint16 /* For OFPFC_DELETE* commands require matching entries to include this as an output port. A value of OFPP_NONE indicates no restriction. */ Flags uint16 /* One of OFPFF_*. */ Actions []Action // Flow actions. }
Flow setup and teardown (controller -> datapath).
type FlowModCommand ¶
type FlowModCommand uint16
type FlowRemoved ¶
type FlowRemoved struct { Header FlowRemovedPart }
Message sent from datapath to controller when a flow is removed.
type FlowRemovedPart ¶
type FlowRemovedPart struct { Match /* Description of fields. */ Cookie uint64 /* Opaque controller-issued identifier. */ Priority uint16 /* Priority level of flow entry. */ Reason FlowRemovedReason /* One of OFPRR_*. */ DurationSec uint32 /* Time flow was alive in seconds. */ DurationNsec uint32 /* Time flow was alive in nanoseconds beyond duration_sec. */ IdleTimeout uint16 /* Idle timeout from original flow mod. */ PacketCount uint64 ByteCount uint64 // contains filtered or unexported fields }
type FlowRemovedReason ¶
type FlowRemovedReason uint8
Why was this flow removed?
const ( // Flow idle time exceeded idle_timeout. RemovedReasonIdleTimeout FlowRemovedReason = iota RemovedReasonHardTimeout /* Time exceeded hard_timeout. */ RemovedReasonDelete /* Evicted by a DELETE flow mod. */ )
type FlowStatsRequest ¶
type FlowStatsRequest struct { Match /* Fields to match. */ TableId uint8 /* ID of table to read (from ofpTableStats) 0xff for all tables or 0xfe for emergency. */ OutPort uint16 /* Require matching entries to include this as an output port. A value of OFPP_NONE indicates no restriction. */ // contains filtered or unexported fields }
Body for ofpStatsRequest of type OFPST_FLOW.
type FromSwitch ¶
Messages from the switch to the controller support this interface.
type Header ¶
type Header struct { Version uint8 /* OFP_VERSION. */ Type Type /* One of the OFPT_ constants. */ Length uint16 /* Length including this Header. */ Xid uint32 /* Transaction id associated with this packet. Replies use the same id as was in the request to facilitate pairing. */ }
Header on all OpenFlow packets.
type Hello ¶
type Hello struct {
Header
}
OFPT_HELLO. This message has an empty body but implementations must * ignore any data included in the body to allow for future extensions.
type Match ¶
type Match struct { Wildcards uint32 /* Wildcard fields. */ InPort uint16 /* Input switch port. */ DlSrc [EthAlen]uint8 /* Ethernet source address. */ DlDst [EthAlen]uint8 /* Ethernet destination address. */ VLanID uint16 /* Input VLAN id. */ VLanPCP uint8 /* Input VLAN priority. */ Pad0 uint8 /* Align to 64-bits */ EthFrameType uint16 /* Ethernet frame type. */ NwTOS uint8 /* IP ToS (actually DSCP field 6 bits). */ NwProto uint8 /* IP protocol or lower 8 bits of ARP opcode. */ Pad1 uint16 /* Align to 64-bits */ NwSrc uint32 /* IP source address. */ NwDst uint32 /* IP destination address. */ TpSrc uint16 /* TCP/UDP source port. */ TpDst uint16 /* TCP/UDP destination port. */ }
Fields to match against flows
type PacketIn ¶
type PacketIn struct { *Header BufferId uint32 // ID assigned by datapath TotalLen uint16 // Full length of frame InPort uint16 // Port on which frame was received Reason uint8 // Reason packet is being sent (one of Reason*) Pad uint8 /* Ethernet frame halfway through 32-bit word so the IP header is 32-bit aligned. The amount of data is inferred from the length field in the header. Because of padding offsetof(struct PacketIn data) == sizeof(struct PacketIn) - 2. */ EthFrame *packets.EthFrame }
Packet received on port (datapath -> controller).
func (*PacketIn) PacketNotMatched ¶
type PacketOut ¶
type PhyPort ¶
type PhyPort struct { PortNo uint16 HwAddr [EthAlen]uint8 Name [OFP_MAX_PORT_NAME_LEN]uint8 /* Null-terminated */ Config uint32 /* Bitmap of Ofppc* flags. */ State uint32 /* Bitmap of Ofpps* flags. */ // Bitmaps of Ppf* that describe features. All bits zeroed if // unsupported or unavailable. Curr uint32 /* Current features. */ Advertised uint32 /* Features being advertised by the port. */ Supported uint32 /* Features supported by the port. */ Peer uint32 /* Features advertised by peer. */ }
Description of a physical port
type PortMod ¶
type PortMod struct { Xid uint32 PortNo uint16 // The hardware address is not configurable. This is used to sanity-check the // request so it must be the same as returned in an PhyPort struct. HwAddr [EthAlen]uint8 Config uint32 // Bitmap of Ofppc* flags. Mask uint32 // Bitmap of Ofppc* flags to be changed. Advertise uint32 // Bitmap of Ofppc* flags. Zero all to prevent any action. }
Modify behavior of the physical port.
type PortStatus ¶
type PortStatus struct { *Header Reason Ppr // One of Ppr* Pad [7]uint8 // Align to 64-bits Desc PhyPort }
A physical port has changed in the datapath
type StatsReply ¶
type StatsReply struct { Header Type uint16 /* One of the OFPST_* constants. */ Flags StatsReplyFlags /* OFPSF_REPLY_* flags. */ Body []byte /* Body of the reply. */ }
type StatsReplyFlags ¶
type StatsReplyFlags uint16
const (
StatsReplyMore StatsReplyFlags = 1 << 0 /* More replies to follow. */
)
type StatsRequest ¶
type StatsType ¶
type StatsType uint16
const ( /* Description of this OpenFlow switch. * The request body is empty. * The reply body is struct ofpDescStats. */ StatsDesc StatsType = iota /* Individual flow statistics. * The request body is struct ofpFlowStatsRequest. * The reply body is an array of struct ofpFlowStats. */ StatsFlow /* Aggregate flow statistics. * The request body is struct ofpAggregateStatsRequest. * The reply body is struct ofpAggregateStatsReply. */ StatsAggregate /* Flow table statistics. * The request body is empty. * The reply body is an array of struct ofpTableStats. */ StatsTable /* Physical port statistics. * The request body is struct ofpPortStatsRequest. * The reply body is an array of struct ofpPortStats. */ StatsPort /* Queue statistics for a port * The request body defines the port * The reply body is an array of struct ofpQueueStats */ StatsQueue /* Vendor extension. * The request and reply bodies begin with a 32-bit vendor ID which takes * the same form as in "struct ofpVendorHeader". The request and reply * bodies are otherwise vendor-defined. */ StatsVendor StatsType = 0xffff )
type SwitchConfig ¶
type SwitchConfig struct { Xid uint32 Flags ConfigFlags // OFPC_* flags MissSendLen uint16 // Max bytes of new flow to send to the controller }
type SwitchFeatures ¶
type SwitchFeatures struct { *Header DatapathId uint64 /* Datapath unique ID. The lower 48-bits are for a MAC address while the upper 16-bits are implementer-defined. */ NBuffers uint32 /* Max packets buffered at once. */ NTables uint8 /* Number of tables supported by datapath. */ Pad [3]byte Capabilities uint32 /* Bitmap of support "Capabilities". */ Actions ActionType /* Bitmap of supported "ActionType"s. */ Ports []PhyPort // Port definitions. }
type SwitchFeaturesRequest ¶
type SwitchFeaturesRequest struct {
Xid uint32
}
type Type ¶
type Type uint8
const ( /* Immutable messages. */ OFPT_HELLO Type = iota /* Symmetric message */ OFPT_ERROR /* Symmetric message */ OFPT_ECHO_REQUEST /* Symmetric message */ OFPT_ECHO_REPLY /* Symmetric message */ OFPT_VENDOR /* Symmetric message */ /* Switch configuration messages. */ OFPT_FEATURES_REQUEST /* Controller/switch message */ OFPT_FEATURES_REPLY /* Controller/switch message */ OFPT_GET_CONFIG_REQUEST /* Controller/switch message */ OFPT_GET_CONFIG_REPLY /* Controller/switch message */ OFPT_SET_CONFIG /* Controller/switch message */ /* Asynchronous messages. */ OFPT_PACKET_IN /* Async message */ OFPT_FLOW_REMOVED /* Async message */ OFPT_PORT_STATUS /* Async message */ /* Controller command messages. */ OFPT_PACKET_OUT /* Controller/switch message */ OFPT_FLOW_MOD /* Controller/switch message */ OFPT_PORT_MOD /* Controller/switch message */ /* Statistics messages. */ OFPT_STATS_REQUEST /* Controller/switch message */ OFPT_STATS_REPLY /* Controller/switch message */ /* Barrier messages. */ OFPT_BARRIER_REQUEST /* Controller/switch message */ OFPT_BARRIER_REPLY /* Controller/switch message */ /* Queue Configuration messages. */ OFPT_QUEUE_GET_CONFIG_REQUEST /* Controller/switch message */ OFPT_QUEUE_GET_CONFIG_REPLY /* Controller/switch message */ )