openflow

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LastTableID uint8 = 0xff
	TableIDAll        = LastTableID
)
View Source
const (
	NxmFieldSrcMAC      = "NXM_OF_ETH_SRC"
	NxmFieldDstMAC      = "NXM_OF_ETH_DST"
	NxmFieldARPSha      = "NXM_NX_ARP_SHA"
	NxmFieldARPTha      = "NXM_NX_ARP_THA"
	NxmFieldARPSpa      = "NXM_OF_ARP_SPA"
	NxmFieldARPTpa      = "NXM_OF_ARP_TPA"
	NxmFieldCtLabel     = "NXM_NX_CT_LABEL"
	NxmFieldCtMark      = "NXM_NX_CT_MARK"
	NxmFieldARPOp       = "NXM_OF_ARP_OP"
	NxmFieldReg         = "NXM_NX_REG"
	NxmFieldTunMetadata = "NXM_NX_TUN_METADATA"
	NxmFieldIPToS       = "NXM_OF_IP_TOS"
	NxmFieldXXReg       = "NXM_NX_XXREG"
	NxmFieldPktMark     = "NXM_NX_PKT_MARK"
	NxmFieldSrcIPv4     = "NXM_OF_IP_SRC"
	NxmFieldDstIPv4     = "NXM_OF_IP_DST"
	NxmFieldSrcIPv6     = "NXM_NX_IPV6_SRC"
	NxmFieldDstIPv6     = "NXM_NX_IPV6_DST"
	NxmFieldTunIPv4Src  = "NXM_NX_TUN_IPV4_SRC"
	NxmFieldEthType     = "NXM_OF_ETH_TYPE"
	NxmFieldIPProto     = "NXM_OF_IP_PROTO"

	OxmFieldVLANVID = "OXM_OF_VLAN_VID"
	OxmFieldInPort  = "OXM_OF_IN_PORT"
	OxmFieldTCPDst  = "OXM_OF_TCP_DST"
	OxmFieldUDPDst  = "OXM_OF_UDP_DST"
	OxmFieldSCTPDst = "OXM_OF_SCTP_DST"
	OxmFieldTCPSrc  = "OXM_OF_TCP_SRC"
	OxmFieldUDPSrc  = "OXM_OF_UDP_SRC"
	OxmFieldSCTPSrc = "OXM_OF_SCTP_SRC"
)

Variables

View Source
var IPDSCPToSRange = &Range{2, 7}

IPDSCPToSRange stores the DSCP bits in ToS field of IP header.

View Source
var (
	MaxBucketsPerMessage = 800
)
View Source
var TableNameCache map[uint8]string

TableNameCache is for testing.

View Source
var VLANVIDRange = &Range{0, 11}

VLANVIDRange stores the VLAN VID range

Functions

func FlowModMatchString added in v1.12.0

func FlowModMatchString(flowMod *openflow15.FlowMod) string

func FlowModToString added in v1.12.0

func FlowModToString(flowMod *openflow15.FlowMod) string

func GetMgmtAddress

func GetMgmtAddress(ovsRunDir, brName string) string

func GetTCPDNSData added in v1.11.0

func GetTCPDNSData(tcpPkt *protocol.TCP) (data []byte, length int, err error)

func GetTCPHeaderData

func GetTCPHeaderData(ipPkt util.Message) (tcpSrcPort, tcpDstPort uint16, tcpSeqNum, tcpAckNum uint32, tcpHdrLen uint8, tcpFlags uint8, tcpWinSize uint16, err error)

func GetTCPPacketFromIPMessage added in v1.11.0

func GetTCPPacketFromIPMessage(ipPkt util.Message) (tcpPkt *protocol.TCP, err error)

GetTCPPacketFromIPMessage gets a TCP struct from an IP message.

func GetUDPHeaderData added in v1.3.0

func GetUDPHeaderData(ipPkt util.Message) (udpSrcPort, udpDstPort uint16, err error)

func GroupModToString added in v1.12.0

func GroupModToString(groupMod *openflow15.GroupMod) string

func NextTableID added in v1.6.0

func NextTableID() (id uint8)

func ResetTableID added in v1.6.0

func ResetTableID()

ResetTableID is used to reset the initial tableID so that the table ID increases from 0. This function is only for test.

Types

type Action

type Action interface {
	LoadARPOperation(value uint16) FlowBuilder
	LoadToRegField(field *RegField, value uint32) FlowBuilder
	LoadRegMark(marks ...*RegMark) FlowBuilder
	LoadPktMarkRange(value uint32, to *Range) FlowBuilder
	LoadIPDSCP(value uint8) FlowBuilder
	Move(from, to string) FlowBuilder
	MoveRange(fromName, toName string, from, to Range) FlowBuilder
	ResubmitToTables(tables ...uint8) FlowBuilder
	CT(commit bool, tableID uint8, zone int, zoneSrcField *RegField) CTAction
	Drop() FlowBuilder
	Output(port uint32) FlowBuilder
	OutputFieldRange(from string, rng *Range) FlowBuilder
	OutputToRegField(field *RegField) FlowBuilder
	OutputInPort() FlowBuilder
	SetDstMAC(addr net.HardwareAddr) FlowBuilder
	SetSrcMAC(addr net.HardwareAddr) FlowBuilder
	SetARPSha(addr net.HardwareAddr) FlowBuilder
	SetARPTha(addr net.HardwareAddr) FlowBuilder
	SetARPSpa(addr net.IP) FlowBuilder
	SetARPTpa(addr net.IP) FlowBuilder
	SetSrcIP(addr net.IP) FlowBuilder
	SetDstIP(addr net.IP) FlowBuilder
	SetTunnelDst(addr net.IP) FlowBuilder
	SetTunnelID(tunnelID uint64) FlowBuilder
	PopVLAN() FlowBuilder
	PushVLAN(etherType uint16) FlowBuilder
	SetVLAN(vlanID uint16) FlowBuilder
	DecTTL() FlowBuilder
	Normal() FlowBuilder
	Conjunction(conjID uint32, clauseID uint8, nClause uint8) FlowBuilder
	Group(id GroupIDType) FlowBuilder
	Learn(id uint8, priority uint16, idleTimeout, hardTimeout, finIdleTimeout, finHardTimeout uint16, cookieID uint64) LearnAction
	GotoTable(table uint8) FlowBuilder
	NextTable() FlowBuilder
	GotoStage(stage StageID) FlowBuilder
	SendToController(userdata []byte, pause bool) FlowBuilder
	Note(notes string) FlowBuilder
	Meter(meterID uint32) FlowBuilder
}

type Bridge

type Bridge interface {
	NewTable(table Table, next uint8, missAction MissActionType) Table
	GetTableByID(id uint8) (Table, error)
	NewGroupTypeAll(id GroupIDType) Group
	NewGroup(id GroupIDType) Group
	NewMeter(id MeterIDType, flags ofctrl.MeterFlag) Meter
	DeleteMeterAll() error
	GetMeterStats(handleMeterStatsReply func(meterID int, packetCount int64)) error
	DumpTableStatus() []TableStatus
	// DumpFlows queries the Openflow entries from OFSwitch. The filter of the query is Openflow cookieID; the result is
	// a map from flow cookieID to FlowStates.
	DumpFlows(cookieID, cookieMask uint64) (map[uint64]*FlowStates, error)
	// DeleteFlowsByCookie removes Openflow entries from OFSwitch. The removed Openflow entries use the specific CookieID.
	DeleteFlowsByCookie(cookieID, cookieMask uint64) error
	// AddFlowsInBundle syncs multiple Openflow entries in a single transaction. This operation could add new flows in
	// "addFlows", modify flows in "modFlows", and remove flows in "delFlows" in the same bundle.
	AddFlowsInBundle(addflows, modFlows, delFlows []*openflow15.FlowMod) error
	// AddOFEntriesInBundle syncs multiple Openflow entries(including Flow and Group) in a single transaction. This
	// operation could add new entries in "addEntries", modify entries in "modEntries", and remove entries in
	// "delEntries" in the same bundle.
	AddOFEntriesInBundle(addEntries []OFEntry, modEntries []OFEntry, delEntries []OFEntry) error
	// Connect initiates connection to the OFSwitch. It will block until the connection is established. connectCh is used to
	// send notification whenever the switch is connected or reconnected.
	Connect(maxRetrySec int, connectCh chan struct{}) error
	// Disconnect stops connection to the OFSwitch.
	Disconnect() error
	// IsConnected returns the OFSwitch's connection status. The result is true if the OFSwitch is connected.
	IsConnected() bool
	// SubscribePacketIn registers a consumer to listen to PacketIn messages matching the provided reason. When the
	// Bridge receives a PacketIn message with the specified reason, it sends the message to the consumer using the
	// provided channel.
	SubscribePacketIn(category uint8, pktInQueue *PacketInQueue) error
	// SendPacketOut sends a packetOut message to the OVS Bridge.
	SendPacketOut(packetOut *ofctrl.PacketOut) error
	// ResumePacket resumes a paused packetIn.
	ResumePacket(packetIn *ofctrl.PacketIn) error
	// BuildPacketOut returns a new PacketOutBuilder.
	BuildPacketOut() PacketOutBuilder
}

Bridge defines operations on an openflow bridge.

type BucketBuilder

type BucketBuilder interface {
	Weight(val uint16) BucketBuilder
	LoadXXReg(regID int, data []byte) BucketBuilder
	LoadToRegField(field *RegField, data uint32) BucketBuilder
	LoadRegMark(mark *RegMark) BucketBuilder
	ResubmitToTable(tableID uint8) BucketBuilder
	SetTunnelDst(addr net.IP) BucketBuilder
	Done() Group
}

type CTAction

type CTAction interface {
	LoadToCtMark(marks ...*CtMark) CTAction
	// LoadToLabelField loads a data into ct_label field. If the expected label is larger than the max value of uint64
	// (0xffffffffffffffff), call this function twice: one is to set the low 64 bits, and the other is to set the high
	// 64 bits.
	LoadToLabelField(value uint64, labelField *CtLabel) CTAction
	MoveToLabel(fromName string, fromRng, labelRng *Range) CTAction
	MoveToCtMarkField(fromRegField *RegField, ctMark *CtMarkField) CTAction
	// NAT action translates the packet in the way that the connection was committed into the conntrack zone, e.g., if
	// a connection was committed with SNAT, the later packets would be translated with the earlier SNAT configurations.
	NAT() CTAction
	// SNAT actions is used to translate the source IP to a specific address or address in a pool when committing the
	// packet into the conntrack zone. If a single IP is used as the target address, StartIP and EndIP in the range
	// should be the same. portRange could be nil.
	SNAT(ipRange *IPRange, portRange *PortRange) CTAction
	// DNAT actions is used to translate the destination IP to a specific address or address in a pool when committing
	// the packet into the conntrack zone. If a single IP is used as the target address, StartIP and EndIP in the range
	// should be the same. portRange could be nil.
	DNAT(ipRange *IPRange, portRange *PortRange) CTAction
	CTDone() FlowBuilder
}

type CtLabel added in v1.3.0

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

func NewCTLabel added in v1.3.0

func NewCTLabel(start, end uint32) *CtLabel

func (*CtLabel) GetNXFieldName added in v1.3.0

func (f *CtLabel) GetNXFieldName() string

func (*CtLabel) GetRange added in v1.3.0

func (f *CtLabel) GetRange() *Range

type CtMark added in v1.3.0

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

CtMark is used to indicate the connection characteristics.

func NewCTMark added in v1.3.0

func NewCTMark(field *CtMarkField, value uint32) *CtMark

func NewOneBitCTMark added in v1.5.1

func NewOneBitCTMark(bit uint32) *CtMark

func NewOneBitZeroCTMark added in v1.5.1

func NewOneBitZeroCTMark(bit uint32) *CtMark

func (*CtMark) GetRange added in v1.3.0

func (m *CtMark) GetRange() *Range

func (*CtMark) GetValue added in v1.3.0

func (m *CtMark) GetValue() uint32

GetValue gets CT mark value with offset since CT mark is used by bit. E.g, CT_MARK_REG[3]==1, the return value of this function is 0b1000.

type CtMarkField added in v1.5.1

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

CtMarkField specifies a bit range of a CT mark. rng is the range of bits taken by the field. The OF client could use a CtMarkField to cache or match varied value.

func NewCTMarkField added in v1.5.1

func NewCTMarkField(start, end uint32) *CtMarkField

type EntryType

type EntryType string
const (
	FlowEntry  EntryType = "FlowEntry"
	GroupEntry EntryType = "GroupEntry"
	MeterEntry EntryType = "MeterEntry"
)

type Flow

type Flow interface {
	OFEntry
	// Returns the flow priority associated with OFEntry
	FlowPriority() uint16
	FlowProtocol() Protocol
	MatchString() string
	// CopyToBuilder returns a new FlowBuilder that copies the matches of the Flow.
	// It copies the original actions of the Flow only if copyActions is set to true, and
	// resets the priority in the new FlowBuilder if the provided priority is not 0.
	CopyToBuilder(priority uint16, copyActions bool) FlowBuilder
}

type FlowBuilder

type FlowBuilder interface {
	MatchPriority(uint16) FlowBuilder
	MatchProtocol(name Protocol) FlowBuilder
	MatchIPProtocolValue(isIPv6 bool, protoValue uint8) FlowBuilder
	MatchXXReg(regID int, data []byte) FlowBuilder
	MatchRegMark(marks ...*RegMark) FlowBuilder
	MatchRegFieldWithValue(field *RegField, data uint32) FlowBuilder
	MatchInPort(inPort uint32) FlowBuilder
	MatchDstIP(ip net.IP) FlowBuilder
	MatchDstIPNet(ipNet net.IPNet) FlowBuilder
	MatchSrcIP(ip net.IP) FlowBuilder
	MatchSrcIPNet(ipNet net.IPNet) FlowBuilder
	MatchDstMAC(mac net.HardwareAddr) FlowBuilder
	MatchSrcMAC(mac net.HardwareAddr) FlowBuilder
	MatchARPSha(mac net.HardwareAddr) FlowBuilder
	MatchARPTha(mac net.HardwareAddr) FlowBuilder
	MatchARPSpa(ip net.IP) FlowBuilder
	MatchARPTpa(ip net.IP) FlowBuilder
	MatchARPOp(op uint16) FlowBuilder
	MatchIPDSCP(dscp uint8) FlowBuilder
	MatchCTStateNew(isSet bool) FlowBuilder
	MatchCTStateRel(isSet bool) FlowBuilder
	MatchCTStateRpl(isSet bool) FlowBuilder
	MatchCTStateEst(isSet bool) FlowBuilder
	MatchCTStateTrk(isSet bool) FlowBuilder
	MatchCTStateInv(isSet bool) FlowBuilder
	MatchCTStateDNAT(isSet bool) FlowBuilder
	MatchCTStateSNAT(isSet bool) FlowBuilder
	MatchCTMark(marks ...*CtMark) FlowBuilder
	MatchCTLabelField(high, low uint64, field *CtLabel) FlowBuilder
	MatchPktMark(value uint32, mask *uint32) FlowBuilder
	MatchConjID(value uint32) FlowBuilder
	MatchDstPort(port uint16, portMask *uint16) FlowBuilder
	MatchSrcPort(port uint16, portMask *uint16) FlowBuilder
	MatchTCPFlags(flag, mask uint16) FlowBuilder
	MatchICMPType(icmpType byte) FlowBuilder
	MatchICMPCode(icmpCode byte) FlowBuilder
	MatchICMPv6Type(icmp6Type byte) FlowBuilder
	MatchICMPv6Code(icmp6Code byte) FlowBuilder
	MatchTunnelDst(dstIP net.IP) FlowBuilder
	MatchTunnelID(tunnelID uint64) FlowBuilder
	MatchVLAN(nonVLAN bool, vlanId uint16, vlanMask *uint16) FlowBuilder
	// MatchCTSrcIP matches the source IPv4 address of the connection tracker original direction tuple.
	MatchCTSrcIP(ip net.IP) FlowBuilder
	// MatchCTSrcIPNet matches the source IPv4 address of the connection tracker original direction tuple with IP masking.
	MatchCTSrcIPNet(ipnet net.IPNet) FlowBuilder
	// MatchCTDstIP matches the destination IPv4 address of the connection tracker original direction tuple.
	MatchCTDstIP(ip net.IP) FlowBuilder
	// MatchCTDstIP matches the destination IPv4 address of the connection tracker original direction tuple with IP masking.
	MatchCTDstIPNet(ipNet net.IPNet) FlowBuilder
	// MatchCTSrcPort matches the transport source port of the connection tracker original direction tuple.
	MatchCTSrcPort(port uint16) FlowBuilder
	// MatchCTDstPort matches the transport destination port of the connection tracker original direction tuple.
	MatchCTDstPort(port uint16) FlowBuilder
	// MatchCTProtocol matches the IP protocol type of the connection tracker original direction tuple.
	MatchCTProtocol(proto Protocol) FlowBuilder
	Cookie(cookieID uint64) FlowBuilder
	SetHardTimeout(timout uint16) FlowBuilder
	SetIdleTimeout(timeout uint16) FlowBuilder
	Action() Action
	Done() Flow
}

type FlowStates

type FlowStates struct {
	TableID         uint8
	PacketCount     uint64
	DurationNSecond uint32
}

type Group

type Group interface {
	OFEntry
	ResetBuckets() Group
	Bucket() BucketBuilder
	GetID() GroupIDType
}

type GroupIDType

type GroupIDType uint32

type IPRange

type IPRange struct {
	StartIP net.IP
	EndIP   net.IP
}

type LearnAction

type LearnAction interface {
	DeleteLearned() LearnAction
	MatchEthernetProtocol(isIPv6 bool) LearnAction
	MatchIPProtocol(protocol Protocol) LearnAction
	MatchLearnedDstPort(protocol Protocol) LearnAction
	MatchLearnedSrcPort(protocol Protocol) LearnAction
	MatchLearnedSrcIP(isIPv6 bool) LearnAction
	MatchLearnedDstIP(isIPv6 bool) LearnAction
	MatchRegMark(marks ...*RegMark) LearnAction
	LoadRegMark(marks ...*RegMark) LearnAction
	LoadFieldToField(fromField, toField *RegField) LearnAction
	LoadXXRegToXXReg(fromXXField, toXXField *XXRegField) LearnAction
	Done() FlowBuilder
}

type Meter added in v1.2.0

type Meter interface {
	OFEntry
	ResetMeterBands() Meter
	MeterBand() MeterBandBuilder
}

type MeterBandBuilder added in v1.2.0

type MeterBandBuilder interface {
	MeterType(meterType ofctrl.MeterType) MeterBandBuilder
	Rate(rate uint32) MeterBandBuilder
	Burst(burst uint32) MeterBandBuilder
	PrecLevel(precLevel uint8) MeterBandBuilder
	Experimenter(experimenter uint32) MeterBandBuilder
	Done() Meter
}

type MeterIDType added in v1.2.0

type MeterIDType uint32

type MissActionType

type MissActionType uint32
const (
	TableMissActionNone MissActionType = iota
	TableMissActionDrop
	TableMissActionNormal
	TableMissActionNext
)

type OFBridge

type OFBridge struct {

	// sync.RWMutex protects tableCache from concurrent modification and iteration.
	sync.RWMutex
	// contains filtered or unexported fields
}

OFBridge implements openflow.Bridge.

func NewOFBridge

func NewOFBridge(br string, mgmtAddr string) *OFBridge

func (*OFBridge) AddFlowsInBundle

func (b *OFBridge) AddFlowsInBundle(addflows, modFlows, delFlows []*openflow15.FlowMod) error

func (*OFBridge) AddOFEntriesInBundle

func (b *OFBridge) AddOFEntriesInBundle(addEntries []OFEntry, modEntries []OFEntry, delEntries []OFEntry) error

func (*OFBridge) BuildPacketOut

func (b *OFBridge) BuildPacketOut() PacketOutBuilder

func (*OFBridge) Connect

func (b *OFBridge) Connect(maxRetrySec int, connectionCh chan struct{}) error

Connect initiates the connection to the OFSwitch, and initializes ofTables after connected.

func (*OFBridge) DeleteFlowsByCookie

func (b *OFBridge) DeleteFlowsByCookie(cookieID, cookieMask uint64) error

DeleteFlowsByCookie removes Openflow entries from OFSwitch. The removed Openflow entries use the specific CookieID.

func (*OFBridge) DeleteMeterAll added in v1.2.0

func (b *OFBridge) DeleteMeterAll() error

func (*OFBridge) Disconnect

func (b *OFBridge) Disconnect() error

Disconnect stops connection to the OFSwitch.

func (*OFBridge) DumpFlows

func (b *OFBridge) DumpFlows(cookieID, cookieMask uint64) (map[uint64]*FlowStates, error)

DumpFlows queries the Openflow entries from OFSwitch, the filter of the query is Openflow cookieID. The result is a map from flow cookieID to FlowStates.

func (*OFBridge) DumpTableStatus

func (b *OFBridge) DumpTableStatus() []TableStatus

DumpTableStatus dumps table status from local cache.

func (*OFBridge) FlowGraphEnabledOnSwitch added in v1.12.1

func (b *OFBridge) FlowGraphEnabledOnSwitch() bool

func (*OFBridge) GetMeterStats added in v1.13.0

func (b *OFBridge) GetMeterStats(handleMeterStatsReply func(meterID int, packetCount int64)) error

func (*OFBridge) GetTableByID added in v1.12.0

func (b *OFBridge) GetTableByID(id uint8) (Table, error)

GetTableByID returns the existing table by the given id. If no table exists, an error is returned.

func (*OFBridge) Initialize added in v1.10.0

func (b *OFBridge) Initialize()

Initialize creates ofctrl.Table for each table in the tableCache.

func (*OFBridge) IsConnected

func (b *OFBridge) IsConnected() bool

func (*OFBridge) MaxRetry

func (b *OFBridge) MaxRetry() int

MaxRetry is a callback from OFController. It sets the max retry count that OFController attempts to connect to OFSwitch.

func (*OFBridge) MultipartReply

func (b *OFBridge) MultipartReply(sw *ofctrl.OFSwitch, rep *openflow15.MultipartReply)

MultipartReply is a callback when multipartReply message is received on ofctrl.OFSwitch is connected. Client uses this method to handle the reply message if it has customized MultipartRequest message.

func (*OFBridge) NewGroup added in v1.13.0

func (b *OFBridge) NewGroup(id GroupIDType) Group

func (*OFBridge) NewGroupTypeAll added in v1.13.0

func (b *OFBridge) NewGroupTypeAll(id GroupIDType) Group

func (*OFBridge) NewMeter added in v1.13.0

func (b *OFBridge) NewMeter(id MeterIDType, flags ofctrl.MeterFlag) Meter

func (*OFBridge) NewTable added in v1.13.0

func (b *OFBridge) NewTable(table Table, next uint8, missAction MissActionType) Table

func (*OFBridge) PacketRcvd

func (b *OFBridge) PacketRcvd(sw *ofctrl.OFSwitch, packet *ofctrl.PacketIn)

PacketRcvd is a callback when a packetIn is received on ofctrl.OFSwitch.

func (*OFBridge) ResumePacket added in v1.12.0

func (b *OFBridge) ResumePacket(packetIn *ofctrl.PacketIn) error

func (*OFBridge) RetryInterval

func (b *OFBridge) RetryInterval() time.Duration

RetryInterval is a callback from OFController. It sets the interval in that the OFController will initiate next connection to OFSwitch if it fails this time.

func (*OFBridge) SendPacketOut

func (b *OFBridge) SendPacketOut(packetOut *ofctrl.PacketOut) error

func (*OFBridge) SetOFSwitch added in v1.10.0

func (b *OFBridge) SetOFSwitch(sw *ofctrl.OFSwitch)

func (*OFBridge) SubscribePacketIn

func (b *OFBridge) SubscribePacketIn(category uint8, pktInQueue *PacketInQueue) error

func (*OFBridge) SwitchConnected

func (b *OFBridge) SwitchConnected(sw *ofctrl.OFSwitch)

SwitchConnected is a callback when the remote OFSwitch is connected.

func (*OFBridge) SwitchDisconnected

func (b *OFBridge) SwitchDisconnected(sw *ofctrl.OFSwitch)

func (*OFBridge) TLVMapEnabledOnSwitch added in v1.12.1

func (b *OFBridge) TLVMapEnabledOnSwitch() bool

type OFEntry

type OFEntry interface {
	Add() error
	Modify() error
	Delete() error
	Type() EntryType
	// Reset ensures that the entry is "correct" and that the Add /
	// Modify / Delete methods can be called on this object. This method
	// should be called if a reconnection event happened.
	Reset()
	// GetBundleMessages returns a slice of ofctrl.OpenFlowModMessage which can be used in Bundle messages. operation
	// specifies what operation is expected to be taken on the OFEntry.
	GetBundleMessages(operation OFOperation) ([]ofctrl.OpenFlowModMessage, error)
}

type OFOperation

type OFOperation int
const (
	AddMessage OFOperation = iota
	ModifyMessage
	DeleteMessage
)

type Packet

type Packet struct {
	IsIPv6          bool
	DestinationMAC  net.HardwareAddr
	SourceMAC       net.HardwareAddr
	DestinationIP   net.IP
	SourceIP        net.IP
	IPLength        uint16
	IPProto         uint8
	IPFlags         uint16
	TTL             uint8
	DestinationPort uint16
	SourcePort      uint16
	TCPFlags        uint8
	ICMPType        uint8
	ICMPCode        uint8
	ICMPEchoID      uint16
	ICMPEchoSeq     uint16
}

func ParsePacketIn

func ParsePacketIn(pktIn *ofctrl.PacketIn) (*Packet, error)

type PacketInQueue

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

func NewPacketInQueue

func NewPacketInQueue(size int, r rate.Limit) *PacketInQueue

func (*PacketInQueue) AddOrDrop

func (q *PacketInQueue) AddOrDrop(packet *ofctrl.PacketIn) bool

func (*PacketInQueue) GetRateLimited

func (q *PacketInQueue) GetRateLimited(stopCh <-chan struct{}) *ofctrl.PacketIn

type PacketOutBuilder

type PacketOutBuilder interface {
	SetSrcMAC(mac net.HardwareAddr) PacketOutBuilder
	SetDstMAC(mac net.HardwareAddr) PacketOutBuilder
	SetSrcIP(ip net.IP) PacketOutBuilder
	SetDstIP(ip net.IP) PacketOutBuilder
	SetIPProtocol(protocol Protocol) PacketOutBuilder
	SetIPProtocolValue(isIPv6 bool, protoValue uint8) PacketOutBuilder
	SetTTL(ttl uint8) PacketOutBuilder
	SetIPFlags(flags uint16) PacketOutBuilder
	SetIPHeaderID(id uint16) PacketOutBuilder
	SetTCPSrcPort(port uint16) PacketOutBuilder
	SetTCPDstPort(port uint16) PacketOutBuilder
	SetTCPFlags(flags uint8) PacketOutBuilder
	SetTCPSeqNum(seqNum uint32) PacketOutBuilder
	SetTCPAckNum(ackNum uint32) PacketOutBuilder
	SetTCPHdrLen(hdrLen uint8) PacketOutBuilder
	SetTCPWinSize(winSize uint16) PacketOutBuilder
	SetTCPData(data []byte) PacketOutBuilder
	SetUDPSrcPort(port uint16) PacketOutBuilder
	SetUDPDstPort(port uint16) PacketOutBuilder
	SetUDPData(data []byte) PacketOutBuilder
	SetICMPType(icmpType uint8) PacketOutBuilder
	SetICMPCode(icmpCode uint8) PacketOutBuilder
	SetICMPID(id uint16) PacketOutBuilder
	SetICMPSequence(seq uint16) PacketOutBuilder
	SetICMPData(data []byte) PacketOutBuilder
	SetInport(inPort uint32) PacketOutBuilder
	SetOutport(outport uint32) PacketOutBuilder
	// AddSetIPTOSAction sets the IP_TOS field in the packet-out message. The action clears the two ECN bits as 0,
	// and only 2-7 bits of the DSCP field in IP header is set.
	AddSetIPTOSAction(data uint8) PacketOutBuilder
	AddLoadRegMark(mark *RegMark) PacketOutBuilder
	AddResubmitAction(inPort *uint16, table *uint8) PacketOutBuilder
	SetL4Packet(packet util.Message) PacketOutBuilder
	SetEthPacket(packet *protocol.Ethernet) PacketOutBuilder
	Done() *ofctrl.PacketOut
}

type Pipeline added in v1.6.0

type Pipeline interface {
	GetFirstTableInStage(id StageID) Table
	GetFirstTable() Table
	ListAllTables() []Table
	IsLastTable(t Table) bool
}

func NewPipeline added in v1.6.0

func NewPipeline(id PipelineID, ofTables []Table) Pipeline

type PipelineID added in v1.6.0

type PipelineID uint8

type PortRange

type PortRange struct {
	StartPort uint16
	EndPort   uint16
}

type Protocol

type Protocol string
const (
	ProtocolIP     Protocol = "ip"
	ProtocolIPv6   Protocol = "ipv6"
	ProtocolARP    Protocol = "arp"
	ProtocolTCP    Protocol = "tcp"
	ProtocolTCPv6  Protocol = "tcpv6"
	ProtocolUDP    Protocol = "udp"
	ProtocolUDPv6  Protocol = "udpv6"
	ProtocolSCTP   Protocol = "sctp"
	ProtocolSCTPv6 Protocol = "sctpv6"
	ProtocolICMP   Protocol = "icmp"
	ProtocolICMPv6 Protocol = "icmpv6"
	ProtocolIGMP   Protocol = "igmp"
)

type Range

type Range [2]uint32

func (*Range) Length

func (r *Range) Length() uint32

func (*Range) Offset added in v1.5.0

func (r *Range) Offset() uint32

func (*Range) ToNXRange

func (r *Range) ToNXRange() *openflow15.NXRange

type RegField added in v1.3.0

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

RegField specifies a bit range of a register. regID is the register number, and rng is the range of bits taken by the field. The OF client could use a RegField to cache or match varied value.

func NewRegField added in v1.3.0

func NewRegField(id int, start, end uint32) *RegField

func (*RegField) GetNXFieldName added in v1.3.0

func (f *RegField) GetNXFieldName() string

func (*RegField) GetRange added in v1.3.0

func (f *RegField) GetRange() *Range

func (*RegField) GetRegID added in v1.3.0

func (f *RegField) GetRegID() int

type RegMark added in v1.3.0

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

RegMark is a value saved in a RegField. A RegMark is used to indicate the traffic has some expected characteristics.

func NewOneBitRegMark added in v1.3.0

func NewOneBitRegMark(id int, bit uint32) *RegMark

func NewOneBitZeroRegMark added in v1.4.0

func NewOneBitZeroRegMark(id int, bit uint32) *RegMark

func NewRegMark added in v1.3.0

func NewRegMark(field *RegField, value uint32) *RegMark

func (*RegMark) GetField added in v1.3.0

func (m *RegMark) GetField() *RegField

func (*RegMark) GetValue added in v1.3.0

func (m *RegMark) GetValue() uint32

type StageID added in v1.6.0

type StageID uint8

type Table

type Table interface {
	GetID() uint8
	GetName() string
	BuildFlow(priority uint16) FlowBuilder
	GetMissAction() MissActionType
	Status() TableStatus
	GetNext() uint8
	SetNext(next uint8)
	SetMissAction(action MissActionType)
	GetStageID() StageID
	// SetTable is used only for testing.
	SetTable()
}

func NewOFTable added in v1.4.0

func NewOFTable(id uint8, name string, stageID StageID, pipelineID PipelineID, missAction MissActionType) Table

type TableStatus

type TableStatus struct {
	ID         uint      `json:"id"`
	Name       string    `json:"name"`
	FlowCount  uint      `json:"flowCount"`
	UpdateTime time.Time `json:"updateTime"`
}

TableStatus represents the status of a specific flow table. The status is useful for debugging.

type XXRegField added in v1.3.0

type XXRegField RegField

XXRegField specifies a xxreg with a required bit range.

func NewXXRegField added in v1.3.0

func NewXXRegField(id int, start, end uint32) *XXRegField

func (*XXRegField) GetNXFieldName added in v1.3.0

func (f *XXRegField) GetNXFieldName() string

func (*XXRegField) GetRange added in v1.3.0

func (f *XXRegField) GetRange() *Range

func (*XXRegField) GetRegID added in v1.3.0

func (f *XXRegField) GetRegID() int

Directories

Path Synopsis
Package testing is a generated GoMock package.
Package testing is a generated GoMock package.

Jump to

Keyboard shortcuts

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