openflow

package
v0.0.0-...-37bb2bd Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2016 License: MIT Imports: 4 Imported by: 0

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

View Source
const (
	OF10_VERSION = 0x01
	OF11_VERSION = 0x02
	OF12_VERSION = 0x03
	OF13_VERSION = 0x04
	OF14_VERSION = 0x05
)

Openflow version number

View Source
const (
	OF_HEADER_SIZE = 8
)

Variables

View Source
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

func FlipIpEndian

func FlipIpEndian(ip net.IP) (net.IP, error)

func FlipMacEndian

func FlipMacEndian(mac net.HardwareAddr) (net.HardwareAddr, error)

Not used

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 Config

type Config interface {
	Flags() uint16
	SetFlags(uint16)
	MissSendLength() uint16
	SetMissSendLength(uint16)
}

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 FlowCommand

type FlowCommand uint16
const (
	Add FlowCommand = iota
	Modify
	ModifyStrict
	Delete
	DeleteStrict
)

type FlowFlag

type FlowFlag uint16
const (
	SendFlowRem FlowFlag = iota + 0x01
	CheckOverlap
	Emerg
)

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 Header struct {
	// contains filtered or unexported fields
}

Openflow header definition

type HeaderDecoder

type HeaderDecoder interface {
	Version() uint8
	MsgType() uint8
	Length() uint16
	TransactionID() uint32
	SetTransactionID(xid uint32)
}

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

func NewMessage(version uint8, msgType uint8, xid uint32) Message

Create a message with no payload.

func (*Message) Length

func (m *Message) Length() uint16

func (*Message) MarshalBinary

func (m *Message) MarshalBinary() ([]byte, error)

convert Message to binary data

func (*Message) MsgType

func (m *Message) MsgType() uint8

func (*Message) Payload

func (m *Message) Payload() []byte

Member functions to implement MessageDecoder interface

func (*Message) SetPayload

func (m *Message) SetPayload(payload []byte)

func (*Message) SetTransactionID

func (m *Message) SetTransactionID(xid uint32)

func (*Message) TransactionID

func (m *Message) TransactionID() uint32

func (*Message) UnmarshalBinary

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

convert binary data to message

func (*Message) Version

func (m *Message) Version() uint8

Member functions to implement HeaderDecoder interface

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

const (
	Max PortID = 0xFF00

	Table PortID
	Normal
	Flood
	All
	Controller
	Local
	// workaround complier complaining overflow
	None PortID = 0xFFFF
)

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 PortState

type PortState uint32

Port state

const (
	STPListen PortState = 0x00
	LinkDown  PortState = 0x01 << iota
	STPLearn
	STPForward
	STPBlock
	STPMask
)

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 StatsReply

type StatsReply interface {
	StatsRequest
}

response shares the same structure

type StatsRequest

type StatsRequest interface {
	MessageDecoder
	Type() StatsType
	SetType(StatsType)
	Flags() uint16
	SetFlags(uint16)
	StatsPayload() []byte
	SetStatsPayload([]byte)
	encoding.BinaryMarshaler
	encoding.BinaryUnmarshaler
}

type StatsType

type StatsType uint16

StatRequest/Response type

const (
	STATS_Description StatsType = iota
	STATS_Flow
	STATS_Aggregate
	STATS_Table
	STATS_Port
	STATS_Queue
	STATS_Vendor
)

type Vendor

type Vendor interface {
	MessageDecoder
	VendorID() uint32
	SetVendorID(uint32)
	Data() []byte
	SetData(data []byte) error
	encoding.BinaryMarshaler
	encoding.BinaryUnmarshaler
}

Directories

Path Synopsis
Package openflow/v10 implements openflow version 1.0.0
Package openflow/v10 implements openflow version 1.0.0

Jump to

Keyboard shortcuts

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