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.
- data OpenFlowServer
- type ServerPortNumber = Word16
- type HostName = String
- startOpenFlowServer :: Maybe HostName -> ServerPortNumber -> IO OpenFlowServer
- acceptSwitch :: OpenFlowServer -> IO (SwitchHandle, SwitchFeatures)
- closeServer :: OpenFlowServer -> IO ()
- data SwitchHandle
- handle2SwitchID :: SwitchHandle -> SwitchID
- switchSockAddr :: SwitchHandle -> SockAddr
- receiveFromSwitch :: SwitchHandle -> IO (Maybe (TransactionID, SCMessage))
- receiveBatch :: SwitchHandle -> IO [(TransactionID, SCMessage)]
- sendToSwitch :: SwitchHandle -> (TransactionID, CSMessage) -> IO ()
- sendBatch :: SwitchHandle -> Int -> [(TransactionID, CSMessage)] -> IO ()
- sendBatches :: SwitchHandle -> Int -> [[(TransactionID, CSMessage)]] -> IO ()
- sendToSwitchWithID :: OpenFlowServer -> SwitchID -> (TransactionID, CSMessage) -> IO ()
- closeSwitchHandle :: SwitchHandle -> IO ()
- untilNothing :: IO (Maybe a) -> (a -> IO ()) -> IO ()
OpenFlow Server
data OpenFlowServer Source
Abstract type containing the state of the OpenFlow server.
type ServerPortNumber = Word16Source
Either a host name e.g., "haskell.org"
or a numeric host
address string consisting of a dotted decimal IPv4 address or an
IPv6 address e.g., "192.168.0.1"
.
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 10.1.30.127, 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.
receiveBatch :: SwitchHandle -> IO [(TransactionID, SCMessage)]Source
sendToSwitch :: SwitchHandle -> (TransactionID, CSMessage) -> IO ()Source
Send a message to the switch.
sendBatch :: SwitchHandle -> Int -> [(TransactionID, CSMessage)] -> IO ()Source
sendBatches :: SwitchHandle -> Int -> [[(TransactionID, CSMessage)]] -> IO ()Source
sendToSwitchWithID :: OpenFlowServer -> SwitchID -> (TransactionID, CSMessage) -> IO ()Source
closeSwitchHandle :: SwitchHandle -> IO ()Source
Close a switch connection.