nettle-openflow-0.2.0: OpenFlow protocol messages, binary formats, and servers.




Provides a simple, basic, and efficient server which provides methods to listen for new switches to connect, and to receive and send OpenFlow messages to switches. This server handles the initialization procedure with switches and handles echo requests from switches.


OpenFlow Server

data OpenFlowServer Source

Abstract type containing the state of the OpenFlow server.

type HostName = String

Either a host name e.g., "" or a numeric host address string consisting of a dotted decimal IPv4 address or an IPv6 address e.g., "".

startOpenFlowServer :: Maybe HostName -> ServerPortNumber -> IO OpenFlowServerSource

Starts an OpenFlow server. The server socket will be bound to a wildcard IP address if the first argument is Nothing and will be bound to a particular address if the first argument is Just something. The HostName value can either be an IP address in dotted quad notation, like, or a host name, whose IP address will be looked up. The server port must be specified.

acceptSwitch :: OpenFlowServer -> IO (SwitchHandle, SwitchFeatures)Source

Blocks until a switch connects to the server and returns the switch handle.

closeServer :: OpenFlowServer -> IO ()Source

Closes the OpenFlow server.

Switch connection

data SwitchHandle Source

Abstract type managing the state of the switch connection.

switchSockAddr :: SwitchHandle -> SockAddrSource

Returns the socket address of the switch connection.

receiveFromSwitch :: SwitchHandle -> IO (Maybe (TransactionID, SCMessage))Source

Blocks until a message is received from the switch or the connection is closed. Returns Nothing only if the connection is closed.

sendToSwitch :: SwitchHandle -> (TransactionID, CSMessage) -> IO ()Source

Send a message to the switch.

closeSwitchHandle :: SwitchHandle -> IO ()Source

Close a switch connection.


untilNothing :: IO (Maybe a) -> (a -> IO ()) -> IO ()Source

Repeatedly perform the first action, passing its result to the second action, until the result of the first action is Nothing, at which point the computation returns.