Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/netrack/openflow
The OpenFlow middleware library
https://github.com/netrack/openflow
go networking nfv openflow sdn
Last synced: about 2 months ago
JSON representation
The OpenFlow middleware library
- Host: GitHub
- URL: https://github.com/netrack/openflow
- Owner: netrack
- License: mit
- Created: 2015-01-13T18:44:34.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2019-03-19T11:35:29.000Z (over 5 years ago)
- Last Synced: 2024-02-07T20:33:06.228Z (5 months ago)
- Topics: go, networking, nfv, openflow, sdn
- Language: Go
- Homepage:
- Size: 380 KB
- Stars: 84
- Watchers: 8
- Forks: 22
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-sdn - Netrack - An OpenFlow controller framework in Go. (Uncategorized / Uncategorized)
- awesome-sdn - Netrack - An OpenFlow controller framework in Go. (Uncategorized / Uncategorized)
README
# openflow - The OpenFlow protocol library
[![Build Status][BuildStatus]](https://travis-ci.org/netrack/openflow)
[![Documentation][Documentation]](https://godoc.org/github.com/netrack/openflow)The openflow library is a pure Go implementation of the OpenFlow protocol.
The ideas of the programming interface mostly borrowed from the Go standard
HTTP library.# Installation
```bash
$ go get github.com/netrack/openflow
```# Usage
The usage is pretty similar to the handling HTTP request, but instead of routes
we are using message types.```go
package mainimport (
of "github.com/netrack/openflow"
)func main() {
// Define the OpenFlow handler for hello messages.
of.HandleFunc(of.TypeHello, func(rw of.ResponseWriter, r *of.Request) {
// Send back hello response.
rw.Write(&of.Header{Type: of.TypeHello}, nil)
})// Start the TCP server on 6633 port.
of.ListenAndServe(":6633", nil)
}
``````go
package mainimport (
"github.com/netrack/openflow/ofp"
of "github.com/netrack/openflow"
)func main() {
pattern := of.TypeMatcher(of.TypePacketIn)mux := of.NewServeMux()
mux.HandleFunc(pattern, func(rw of.ResponseWriter, r *of.Request) {
var packet ofp.PacketIn
packet.ReadFrom(r.Body)apply := &ofp.InstructionApplyActions{
ofp.Actions{&ofp.ActionOutput{ofp.PortFlood, 0}},
}// For each incoming packet-in request, create a
// respective flow modification command.
fmod := ofp.NewFlowMod(ofp.FlowAdd, packet)
fmod.Instructions = ofp.Instructions{apply}rw.Write(&of.Header{Type: of.TypeFlowMod}, fmod)
})of.ListenAndServe(":6633", mux)
}
```# License
The openflow library is distributed under MIT license, therefore you are free
to do with code whatever you want. See the [LICENSE](LICENSE) file for full
license text.[BuildStatus]: https://travis-ci.org/netrack/openflow.svg?branch=master
[Documentation]: https://godoc.org/github.com/netrack/openflow?status.svg