MyNixOS website logo
Description

OpenFlow.

This package implements the OpenFlow 1.0 and a large part of the OpenFlow 1.3 protocols. It defines a collection of data types representing the logical contents of OpenFlow messages, defines serialization and deserialization methods using the binary package, and provides some simple servers that can be used with these data types.

OpenFlow Build Status

OpenFlow is a Haskell library that implements OpenFlow protocols 1.0 and 1.3. It defines data types that model the logical content of the various OpenFlow protocol messages and provides serialization and deserialization methods using the binary package. It also provides basic functions to start servers that use these representations.

Installation

To build a controller using this library, you need to install GHC and install this library. For information on how to install Haskell, head over to https://www.haskell.org. To install this library, clone this repository, enter the cloned directory, and then run cabal install.

Getting Started

To write an OpenFlow 1.3 controller, start with the following template, and then fill in the messageHandler function:

import Network.Data.OF13.Message
import Network.Data.OF13.Server

main :: IO ()
main = runServerOne 6633 factory
  where factory sw = handshake sw >> return (messageHandler sw)

handshake :: Switch -> IO ()
handshake sw = sendMessage sw [Hello { xid = 0, len = 8 }]

messageHandler :: Switch -> Maybe Message -> IO ()
messageHandler _ Nothing = putStrLn "Disconnecting"
messageHandler sw (Just msg) = print msg >> sendMessage sw [FeatureRequest 1]

Place the above source into a file, for example, Main.hs. Assuming you have installed ghc and this library, you can then run ghc --make Main.hs to build an executable from Main.hs. You can then run it as Main.

The above main program calls runServerOne which will wait for a single OpenFlow 1.3 server to connect on port 6633 and then will run the given factory function. The factory function performs an initial handshake, which, in this bare bones example, consists of sending a Hello message to the switch, and then returns a message handler function messageHandler that will be used to interact with that switch until the connection is terminated. When the server receives an OpenFlow 1.3 message m, it will run messageHandler (Just m) and when the connection is terminated, the server runs messageHandler Nothing. The message handler can do anything, but typically it sends messages to the switch. To do this, use the sendMessage function.

Metadata

Version

0.3.1

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows