Documentation
¶
Overview ¶
Package openflow is an implementation of openflow protocol in go. It supports multiple versions of openflow specifications. For mode details about openflow, please visit Open Networking Foundation https://opennetworking.org/sdn-resources/openflow
Index ¶
- Constants
- Variables
- func FlipIpEndian(ip net.IP) (net.IP, error)
- func FlipMacEndian(mac net.HardwareAddr) (net.HardwareAddr, error)
- type Action
- type BarrierReply
- type BarrierRequest
- type Config
- type Echo
- type Error
- type FeatureAction
- type FeatureCapability
- type FeatureReply
- type FeatureRequest
- type FlowCommand
- type FlowFlag
- type FlowMod
- type FlowRemoved
- type GetConfigReply
- type GetConfigRequest
- type Header
- type HeaderDecoder
- type Hello
- type Match
- type Message
- func (m *Message) Length() uint16
- func (m *Message) MarshalBinary() ([]byte, error)
- func (m *Message) MsgType() uint8
- func (m *Message) Payload() []byte
- func (m *Message) SetPayload(payload []byte)
- func (m *Message) SetTransactionID(xid uint32)
- func (m *Message) TransactionID() uint32
- func (m *Message) UnmarshalBinary(data []byte) error
- func (m *Message) Version() uint8
- type MessageDecoder
- type PacketIn
- type PacketOut
- type Port
- type PortConfig
- type PortFeature
- type PortID
- type PortMod
- type PortReason
- type PortState
- type PortStatus
- type Queue
- type QueueGetConfigReply
- type QueueGetConfigRequest
- type SetConfig
- type StatsReply
- type StatsRequest
- type StatsType
- type Vendor
Constants ¶
const ( OF10_VERSION = 0x01 OF11_VERSION = 0x02 OF12_VERSION = 0x03 OF13_VERSION = 0x04 OF14_VERSION = 0x05 )
Openflow version number
const (
OF_HEADER_SIZE = 8
)
Variables ¶
var ( ErrInvalidPacketLength = errors.New("invalid packet length") ErrUnsupportedVersion = errors.New("unsupported protocol version") ErrUnsupportedMessage = errors.New("unsupported message type") ErrInvalidMACAddress = errors.New("invalid MAC address") ErrInvalidIPAddress = errors.New("invalid IP address") ErrInvalidVlanID = errors.New("invalid vlan id") ErrUnsupportedIPProtocol = errors.New("unsupported IP protocol") ErrUnsupportedEtherType = errors.New("unsupported Ethernet type") ErrMissingIPProtocol = errors.New("missing IP protocol") ErrMissingEtherType = errors.New("missing Ethernet type") ErrUnsupportedMatchType = errors.New("unsupported flow match type") ErrNoDataProvided = errors.New("no data provided") ErrInvalidDataLength = errors.New("invalid data length") ErrInvalidValueProvided = errors.New("invalid value provided") )
Functions ¶
Types ¶
type Action ¶
type Action interface { Type() uint16 SetType(uint16) Length() uint16 Payload() []byte SetPayload([]byte) error encoding.BinaryMarshaler encoding.BinaryUnmarshaler }
general action interface
type BarrierReply ¶
type BarrierReply interface { MessageDecoder encoding.BinaryMarshaler encoding.BinaryUnmarshaler }
type BarrierRequest ¶
type BarrierRequest interface { MessageDecoder encoding.BinaryMarshaler encoding.BinaryUnmarshaler }
type Echo ¶
type Echo interface { MessageDecoder Data() []byte SetData(data []byte) error Error() error encoding.BinaryMarshaler encoding.BinaryUnmarshaler }
Echo message interface (request/reply)
type Error ¶
type Error interface { MessageDecoder Type() uint16 SetType(uint16) error Code() uint16 SetCode(uint16) error Data() []byte SetData(data []byte) error encoding.BinaryMarshaler encoding.BinaryUnmarshaler }
Error message interface
type FeatureAction ¶
type FeatureAction uint32
Features Actions
const ( OUTPUT FeatureAction = 0x1 << iota SET_VLAN_VID SET_VLAN_PCP STRIP_VLAN SET_DL_SRC SET_DL_DST SET_NW_SRC SET_NW_DST SET_NW_TOS SET_TP_SRC SET_TP_DST ENQUEUE )
type FeatureCapability ¶
type FeatureCapability uint32
Features Capabilities
const ( FLOW_STATS FeatureCapability = 0x01 << iota TABLE_STATS PORT_STATS STP RESERVED IP_REASM QUEUE_STATS ARP_MATCH_IP )
type FeatureReply ¶
type FeatureReply interface { MessageDecoder DPID() uint64 SetDPID(uint64) NumBuffers() uint32 SetNumBuffers(uint32) NumTables() uint8 SetNumTables(uint8) Capabilities() FeatureCapability SetCapabilities(FeatureCapability) Actions() FeatureAction SetActions(FeatureAction) Ports() []Port AddPort(Port) encoding.BinaryMarshaler encoding.BinaryUnmarshaler }
type FeatureRequest ¶
type FeatureRequest interface { MessageDecoder encoding.BinaryMarshaler encoding.BinaryUnmarshaler }
type FlowCommand ¶
type FlowCommand uint16
const ( Add FlowCommand = iota Modify ModifyStrict Delete DeleteStrict )
type FlowMod ¶
type FlowMod interface { MessageDecoder Match() Match SetMatch(Match) Cookie() uint64 SetCookie(uint64) error Command() FlowCommand SetCommand(FlowCommand) IdleTimeout() uint16 SetIdleTimeout(uint16) HardTimeout() uint16 SetHardTimeout(uint16) Priority() uint16 SetPriority(uint16) BufferID() uint32 SetBufferID(uint32) OutPort() uint16 SetOutPort(uint16) Flags() FlowFlag SetFlags(FlowFlag) Action() Action SetAction(Action) encoding.BinaryMarshaler encoding.BinaryUnmarshaler }
type FlowRemoved ¶
type FlowRemoved interface { MessageDecoder Match() Match SetMatch(Match) Cookie() uint64 SetCookie(uint64) Priority() uint16 SetPriority(uint16) Reason() uint8 SetReason(uint8) error DurationSec() uint32 SetDurationSec(uint32) DurationNanoSec() uint32 SetDurationNanoSec(uint32) IdleTimeout() uint16 SetIdleTimeout(uint16) PacketCount() uint64 SetPacketCount(uint64) ByteCount() uint64 SetByteCount(uint64) encoding.BinaryMarshaler encoding.BinaryUnmarshaler }
type GetConfigReply ¶
type GetConfigReply interface { MessageDecoder Config encoding.BinaryMarshaler encoding.BinaryUnmarshaler }
type GetConfigRequest ¶
type GetConfigRequest interface { MessageDecoder encoding.BinaryMarshaler encoding.BinaryUnmarshaler }
type Header ¶
type Header struct {
// contains filtered or unexported fields
}
Openflow header definition
type HeaderDecoder ¶
type Hello ¶
type Hello interface { Echo }
Hello message interface Share the same interface and struct as echo
type Match ¶
type Match interface { Wildcards() uint32 // returns wildcard mask for Inport and inport number InPort() (bool, uint16) SetInPort(uint16) SetWildcardInPort() DLSrc() (bool, net.HardwareAddr) SetDLSrc(net.HardwareAddr) SetWildcardDLSrc() DLDst() (bool, net.HardwareAddr) SetDLDst(net.HardwareAddr) SetWildcardDLDst() DLVlan() (bool, uint16) SetDLVlan(uint16) error SetWildcardDLVlan() DLPCP() (bool, uint8) SetDLPCP(uint8) SetWildcardDLVlanPCP() DLType() (bool, uint16) SetDLType(uint16) error SetWildcardDLType() NWTos() (bool, uint8) SetNWTos(uint8) SetWildcardNWTos() NWProto() (bool, uint8) SetNWProto(uint8) error SetWildcardNWProto() // The wildcard mask here is to wildcard src/dst ip address // Set it to 32 is matching the full ip address // Set it to 0 will mask all the ip addr, returns 0.0.0.0 NWSrc() net.IP SetNWSrc(net.IP) SetWildcardNWSrc(int) NWDst() net.IP SetNWDst(net.IP) SetWildcardNWDst(int) // Source and destination port TPSrc() (bool, uint16) SetTPSrc(uint16) SetWildcardTPSrc() TPDst() (bool, uint16) SetTPDst(uint16) SetWildcardTPDst() encoding.BinaryMarshaler encoding.BinaryUnmarshaler }
Match is a structure used in flow related messages
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
func NewMessage ¶
Create a message with no payload.
func (*Message) MarshalBinary ¶
convert Message to binary data
func (*Message) SetPayload ¶
func (*Message) SetTransactionID ¶
func (*Message) TransactionID ¶
func (*Message) UnmarshalBinary ¶
convert binary data to message
type MessageDecoder ¶
type MessageDecoder interface { HeaderDecoder Payload() []byte SetPayload(payload []byte) }
type PacketIn ¶
type PacketIn interface { MessageDecoder BufferID() uint32 SetBufferID(uint32) TotalLength() uint16 InPort() uint16 SetInPort(uint16) TableID() uint8 SetTableID(uint8) Reason() uint8 SetReason(uint8) Cookie() uint64 SetCookie(uint64) Data() []byte SetData([]byte) encoding.BinaryUnmarshaler encoding.BinaryMarshaler }
Packet in message interface
type PacketOut ¶
type PacketOut interface { MessageDecoder BufferID() uint32 SetBufferID(uint32) ActionsLength() uint16 InPort() uint16 SetInPort(uint16) error Data() []byte SetData([]byte) Action() []Action AddAction(Action) encoding.BinaryUnmarshaler encoding.BinaryMarshaler }
Packet in message interface
type Port ¶
type Port interface { PortID() PortID SetPortID(PortID) HWAddr() net.HardwareAddr SetHWAddr(net.HardwareAddr) error Name() string SetName(string) error Config() PortConfig SetConfig(PortConfig) State() PortState SetState(PortState) Curr() PortFeature SetCurr(PortFeature) Advertised() PortFeature SetAdvertised(PortFeature) Supported() PortFeature SetSupported(PortFeature) Peer() PortFeature SetPeer(PortFeature) encoding.BinaryMarshaler encoding.BinaryUnmarshaler }
Port is a structure describes a port
type PortConfig ¶
type PortConfig uint32
Port config
const ( PortDown PortConfig = 0x01 << iota NoSTP NoRecv NoRecvSTP NoFlood NoFwd NoPacketIn )
type PortFeature ¶
type PortFeature uint32
Port feature
const ( HD_10MB PortFeature = 0x01 << iota FD_10MB HD_100MB FD_100MB HD_1GB FD_1GB FD_10GB Copper Fiber AutoNeg Pause PauseAsym )
type PortID ¶
type PortID uint16
Port id reserved values, for other normal ports should specify their own id value
type PortMod ¶
type PortMod interface { MessageDecoder Port() PortID SetPort(PortID) HWAddr() net.HardwareAddr SetHWAddr(net.HardwareAddr) Config() PortConfig SetConfig(PortConfig) Mask() uint32 SetMask(uint32) error Advertise() PortFeature SetAdvertise(PortFeature) encoding.BinaryMarshaler encoding.BinaryUnmarshaler }
type PortReason ¶
type PortReason uint8
Port reason codes
const ( PortAdded PortReason = iota PortDeleted PortModified )
type PortStatus ¶
type PortStatus interface { MessageDecoder Reason() PortReason SetReason(PortReason) Port() Port SetPort(Port) encoding.BinaryMarshaler encoding.BinaryUnmarshaler }
type Queue ¶
type Queue interface { QueueID() uint32 SetQueueID(uint32) Length() uint16 // Openflow 1.0 to 1.3 queue message only has one type of property: MinRate Rate() uint16 SetRate(uint16) encoding.BinaryMarshaler encoding.BinaryUnmarshaler }
type QueueGetConfigReply ¶
type QueueGetConfigReply interface { MessageDecoder Port() uint16 SetPort(uint16) Queue() []Queue AddQueue(Queue) encoding.BinaryMarshaler encoding.BinaryUnmarshaler }
type QueueGetConfigRequest ¶
type QueueGetConfigRequest interface { MessageDecoder Port() uint16 SetPort(uint16) error encoding.BinaryMarshaler encoding.BinaryUnmarshaler }
type SetConfig ¶
type SetConfig interface { MessageDecoder Config encoding.BinaryMarshaler encoding.BinaryUnmarshaler }
type StatsRequest ¶
type StatsRequest interface { MessageDecoder Type() StatsType SetType(StatsType) Flags() uint16 SetFlags(uint16) StatsPayload() []byte SetStatsPayload([]byte) encoding.BinaryMarshaler encoding.BinaryUnmarshaler }
type Vendor ¶
type Vendor interface { MessageDecoder VendorID() uint32 SetVendorID(uint32) Data() []byte SetData(data []byte) error encoding.BinaryMarshaler encoding.BinaryUnmarshaler }