Kmotiko / gofc

OpenFlow Controller written in go.
MIT License
56 stars 25 forks source link

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

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

Match Field

Instructions

Actions

MeterBand

Multipart Message

License

This software is distributed with MIT license.

Copyright (c) 2016 Kmotiko