gofc

package module
v0.0.0-...-857358e Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2019 License: MIT Imports: 5 Imported by: 7

README

gofc

Build Status

What is this?

OpenFlow Controller written in golang. Now, only support OpenFlow 1.3.

How to use

To run OpenFlow Controller with gofc, you have to follow the steps outlined bellow.

  • Implement Handler
  • Regist and Run Controller
Implement Handler

First, Implement handler interface. For example, if you want to handle PacketIn message, you should implement HandlePacketIn like bellow.

import (
	"github.com/Kmotiko/gofc"
	"github.com/Kmotiko/gofc/ofprotocol/ofp13"
)

type SampleController struct {
	// add any paramter used in controller.
}

func (c *SampleController) HandlePacketIn(msg *ofp13.OfpPacketIn, dp *gofc.Datapath) {
	// create flow mod
	fm := ofp13.NewOfpFlowMod(
		0,
		0,
		0,
		ofp13.OFPFC_ADD,
		0,
		0,
		0,
		ofp13.OFP_NO_BUFFER,
		ofp13.OFPP_ANY,
		ofp13.OFPG_ANY,
		ofp13.OFPFF_SEND_FLOW_REM)

	// TODO: set match field and instructions.

	// send FlowMod message
	dp.Send(fm)
}

Defenition of gofc interfaces is written in ofp13_handler.go.

Regist and Run Controller

If you complete to implement of handlers, you can regist that to gofc and start it.

func main() {
	// regist app
	ofc := NewSampleController()
	gofc.GetAppManager().RegistApplication(ofc)

	// start Controller
	gofc.ServerLoop()
}

OpenFlow Messages Support Status

Messages
  • Hello
  • OfpErroMsg
  • OfpExperimenterMsg
  • EchoRequest
  • EchoReply
  • FeaturesRequest
  • FeaturesReply
  • GetConfigRequest
  • GetConfigReply
  • SetConfig
  • PacketIn
  • FlowRemoved
  • PortStatus
  • PacketOut
  • FlowMod
  • GroupMod
  • PortMod
  • TableMod
  • MultipartRequest
  • MultipartReply
  • BarrierRequest
  • BarrierReply
  • QueueGetConfigRequest
  • QueueGetConfigReply
  • RoleRequest
  • RoleReply
  • GetAsyncRequest
  • GetAsyncReply
  • SetAsync
  • MeterMod
Match Field
  • In Port
  • In Phy Port
  • Metadata
  • Eth Dst
  • Eth Src
  • Eth Type
  • Vlan ID
  • Vlan PCP
  • IP Dscp
  • IP ECN
  • IP Proto
  • IPv4 Src
  • IPv4 Dst
  • TCP Src
  • TCP Dst
  • UDP Src
  • UDP Dst
  • SCTP Src
  • SCTP Dst
  • ICMPv4 Type
  • ICMPv4 Code
  • Arp Op
  • Arp SPA
  • Arp TPA
  • Arp SHA
  • Arp THA
  • IPv6 Src
  • IPv6 Dst
  • IPv6 FLabel
  • IPv6 Type
  • IPv6 Code
  • IPv6 ND Target
  • IPv6 ND SLL
  • IPv6 ND TLL
  • MPLS Label
  • MPLS TC
  • MPLS BOS
  • PBB ISID
  • TUNNEL ID
  • IPv6 ExtraHeader
Instructions
  • Go to table
  • Write Metadata
  • Action
  • Meter
Actions
  • Output
  • Copy TTL OUT
  • Copy TTL IN
  • Set MPLS TTL
  • Dec MPLS TTL
  • PUSH VLAN
  • PUSH MPLS
  • PUSH PBB
  • POP VLAN
  • POP MPLS
  • POP PBB
  • Group
  • Set NW TTL
  • Dec NW TTL
  • Set Field
  • Experimenter Header
MeterBand
  • MeterBandDrop
  • MeterBandDscpRemark
  • MeterBandExperimenter
Multipart Message
  • DescStats
  • FlowStats
  • AggregateStats
  • TableStats
  • PortStats
  • QueueStats
  • GroupStats
  • GroupDescStats
  • GroupFeaturesStats
  • MeterStats
  • MeterConfigStats
  • MeterFeaturesStats
  • TableFeaturesStats
  • PortDescStats
  • ExperimenterStats

License

This software is distributed with MIT license.

Copyright (c) 2016 Kmotiko

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DEFAULT_PORT = 6653

Functions

func ServerLoop

func ServerLoop(listenPort int)

Types

type AppManager

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

func GetAppManager

func GetAppManager() *AppManager

func (*AppManager) GetApplications

func (manager *AppManager) GetApplications() []interface{}

func (*AppManager) RegistApplication

func (manager *AppManager) RegistApplication(app interface{})

type Datapath

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

datapath

func NewDatapath

func NewDatapath(conn *net.TCPConn) *Datapath

*

  • ctor

func (*Datapath) Send

func (dp *Datapath) Send(message ofp13.OFMessage) bool

*

*

type IFMap

type IFMap map[string]interface{}

type OFController

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

*

  • basic controller

func NewOFController

func NewOFController() *OFController

func (*OFController) ConnectionDown

func (c *OFController) ConnectionDown()

func (*OFController) ConnectionUp

func (c *OFController) ConnectionUp()

func (*OFController) HandleEchoRequest

func (c *OFController) HandleEchoRequest(msg *ofp13.OfpHeader, dp *Datapath)

func (*OFController) HandleSwitchFeatures

func (c *OFController) HandleSwitchFeatures(msg *ofp13.OfpSwitchFeatures, dp *Datapath)

type Of13AggregateStatsReplyHandler

type Of13AggregateStatsReplyHandler interface {
	HandleAggregateStatsReply(*ofp13.OfpMultipartReply, *Datapath)
}

***************************************************

OfpAggregateStatsReply

***************************************************

type Of13AsyncConfigHandler

type Of13AsyncConfigHandler interface {
	HandleAsyncConfig(*ofp13.OfpAsyncConfig, *Datapath)
}

***************************************************

GetAsyncReply Message

***************************************************

type Of13BarrierReplyHandler

type Of13BarrierReplyHandler interface {
	HandleBarrierReply(*ofp13.OfpHeader, *Datapath)
}

***************************************************

BarrierReply Message

***************************************************

type Of13DescStatsReplyHandler

type Of13DescStatsReplyHandler interface {
	HandleDescStatsReply(*ofp13.OfpMultipartReply, *Datapath)
}

***************************************************

OfpDescStatsReply

***************************************************

type Of13EchoReplyHandler

type Of13EchoReplyHandler interface {
	HandleEchoReply(*ofp13.OfpHeader, *Datapath)
}

type Of13EchoRequestHandler

type Of13EchoRequestHandler interface {
	HandleEchoRequest(*ofp13.OfpHeader, *Datapath)
}

***************************************************

Echo Message

***************************************************

type Of13ErrorMsgHandler

type Of13ErrorMsgHandler interface {
	HandleErrorMsg(*ofp13.OfpErrorMsg, *Datapath)
}

***************************************************

OfpErrorMsg

***************************************************

type Of13FlowRemovedHandler

type Of13FlowRemovedHandler interface {
	HandleFlowRemoved(*ofp13.OfpFlowRemoved, *Datapath)
}

***************************************************

OfpFlowRemoved

***************************************************

type Of13FlowStatsReplyHandler

type Of13FlowStatsReplyHandler interface {
	HandleFlowStatsReply(*ofp13.OfpMultipartReply, *Datapath)
}

***************************************************

OfpFlowStatsReply

***************************************************

type Of13GroupDescStatsReplyHandler

type Of13GroupDescStatsReplyHandler interface {
	HandleGroupDescStatsReply(*ofp13.OfpMultipartReply, *Datapath)
}

***************************************************

OfpGroupDescStatsReply

***************************************************

type Of13GroupFeaturesStatsReplyHandler

type Of13GroupFeaturesStatsReplyHandler interface {
	HandleGroupFeaturesStatsReply(*ofp13.OfpMultipartReply, *Datapath)
}

***************************************************

OfpGroupFeaturesStatsReply

***************************************************

type Of13GroupStatsReplyHandler

type Of13GroupStatsReplyHandler interface {
	HandleGroupStatsReply(*ofp13.OfpMultipartReply, *Datapath)
}

***************************************************

OfpGroupStatsReply

***************************************************

type Of13MeterConfigStatsReplyHandler

type Of13MeterConfigStatsReplyHandler interface {
	HandleMeterConfigStatsReply(*ofp13.OfpMultipartReply, *Datapath)
}

***************************************************

OfpMeterConfigStatsReply

***************************************************

type Of13MeterFeaturesStatsReplyHandler

type Of13MeterFeaturesStatsReplyHandler interface {
	HandleMeterFeaturesStatsReply(*ofp13.OfpMultipartReply, *Datapath)
}

***************************************************

OfpMeterFeaturesStatsReply

***************************************************

type Of13MeterStatsReplyHandler

type Of13MeterStatsReplyHandler interface {
	HandleMeterStatsReply(*ofp13.OfpMultipartReply, *Datapath)
}

***************************************************

OfpMeterStatsReply

***************************************************

type Of13PacketInHandler

type Of13PacketInHandler interface {
	HandlePacketIn(*ofp13.OfpPacketIn, *Datapath)
}

***************************************************

OfpPacketIn

***************************************************

type Of13PortDescStatsReplyHandler

type Of13PortDescStatsReplyHandler interface {
	HandlePortDescStatsReply(*ofp13.OfpMultipartReply, *Datapath)
}

***************************************************

OfpPortDescStatsReply

***************************************************

type Of13PortStatsReplyHandler

type Of13PortStatsReplyHandler interface {
	HandlePortStatsReply(*ofp13.OfpMultipartReply, *Datapath)
}

***************************************************

OfpPortStatsReply

***************************************************

type Of13QueueStatsReplyHandler

type Of13QueueStatsReplyHandler interface {
	HandleQueueStatsReply(*ofp13.OfpMultipartReply, *Datapath)
}

***************************************************

OfpQueueStatsReply

***************************************************

type Of13RoleReplyHandler

type Of13RoleReplyHandler interface {
	HandleRoleReply(*ofp13.OfpRole, *Datapath)
}

***************************************************

RoleReply Message

***************************************************

type Of13SwitchConfigHandler

type Of13SwitchConfigHandler interface {
	HandleSwitchConfig(*ofp13.OfpSwitchConfig, *Datapath)
}

***************************************************

OfpSwitchConfig

***************************************************

type Of13SwitchFeaturesHandler

type Of13SwitchFeaturesHandler interface {
	HandleSwitchFeatures(*ofp13.OfpSwitchFeatures, *Datapath)
}

***************************************************

OfpSwitchFeatures

***************************************************

type Of13TableFeaturesStatsReplyHandler

type Of13TableFeaturesStatsReplyHandler interface {
	HandleTableFeaturesStatsReply(*ofp13.OfpMultipartReply, *Datapath)
}

***************************************************

OfpTableFeaturesStatsReply

***************************************************

type Of13TableStatsReplyHandler

type Of13TableStatsReplyHandler interface {
	HandleTableStatsReply(*ofp13.OfpMultipartReply, *Datapath)
}

***************************************************

OfpTableStatsReply

***************************************************

Directories

Path Synopsis
ofprotocol

Jump to

Keyboard shortcuts

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