The openflow package

[ Tags: library, network ] [ Propose Tags ]

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.

[Skip to Readme]


Versions 0.3.0, 0.3.1
Dependencies aeson (>=, base (>= && <=5), bimap (>=0.2.4), binary (>=0.7.0), bytestring, containers, deepseq, deepseq-generics (>=, hashable (>=, network (>= [details]
License OtherLicense
Author Andreas Voellmy <>
Maintainer Andreas Voellmy
Category Network
Home page
Source repository head: git clone git://
Uploaded Tue Oct 3 05:58:19 UTC 2017 by AndreasVoellmy
Distributions NixOS:0.3.0
Downloads 208 total (43 in the last 30 days)
Rating 0.0 (0 ratings) [clear rating]
  • λ
  • λ
  • λ
Status Docs not available [build log]
Last success reported on 2017-10-03 [all 3 reports]
Hackage Matrix CI


  • Network
    • Data
      • Network.Data.Ethernet
        • Network.Data.Ethernet.AddressResolutionProtocol
        • Network.Data.Ethernet.EthernetAddress
        • Network.Data.Ethernet.EthernetFrame
        • Network.Data.Ethernet.LLDP
      • Network.Data.IPv4
        • Network.Data.IPv4.DHCP
        • Network.Data.IPv4.IPAddress
        • Network.Data.IPv4.IPPacket
        • Network.Data.IPv4.UDP
      • OF13
        • Network.Data.OF13.Message
        • Network.Data.OF13.Server
      • Network.Data.OpenFlow
        • Network.Data.OpenFlow.Action
        • Network.Data.OpenFlow.Error
        • Network.Data.OpenFlow.FlowTable
        • Network.Data.OpenFlow.Match
        • Network.Data.OpenFlow.MatchBuilder
        • Network.Data.OpenFlow.Messages
        • Network.Data.OpenFlow.MessagesBinary
        • Network.Data.OpenFlow.Packet
        • Network.Data.OpenFlow.Port
        • Network.Data.OpenFlow.Statistics
        • Network.Data.OpenFlow.Switch
      • Network.Data.Util


Maintainer's Corner

For package maintainers and hackage trustees

Readme for openflow-0.3.1

[back to package description]

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.


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 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.