#include <BaseOFServer.hh>
Public Member Functions | |
| BaseOFServer (const char *address, const int port, const int nevloops=1, const bool secure=false) | |
| virtual bool | start (bool block=false) |
| virtual void | stop () |
| virtual void | base_connection_callback (BaseOFConnection *conn, BaseOFConnection::Event event_type) |
| virtual void | base_message_callback (BaseOFConnection *conn, void *data, size_t len) |
| virtual void | free_data (void *data) |
Friends | |
| class | LibEventBaseOFServer |
A BaseOFServer manages the very basic functions of OpenFlow connections, such as notifying of new messages and network-level events. It is an abstract class that should be overriden by another class to provide OpenFlow features.
| fluid_base::BaseOFServer::BaseOFServer | ( | const char * | address, |
| const int | port, | ||
| const int | nevloops = 1, |
||
| const bool | secure = false |
||
| ) |
Create a BaseOFServer.
| address | address to bind the server |
| port | TCP port on which the server will listen |
| nevloops | number of event loops to run. Connections will be attributed to event loops running on threads on a round-robin fashion. The first event loop will listen for new connections. |
| secure | whether the connections should use TLS. TLS support must compiled into the library and you need to call libfluid_ssl_init before you can use this feature. |
|
virtual |
Start the server. It will listen at the port declared in the constructor, assigning connections to event loops running in threads and optionally blocking the calling thread until BaseOFServer::stop is called.
| block | block the calling thread while the server is running |
Reimplemented in fluid_base::OFServer.
|
virtual |
Stop the server. It will stop listening to new connections and signal the event loops to stop running.
It will eventually unblock BaseOFServer::start if it is blocking.
Reimplemented in fluid_base::OFServer.
|
virtual |
Callback for connection events.
This method blocks the event loop on which the connection is running, preventing other connection's events from being handled. If you want to perform a very long operation, try to queue it and return.
The implementation must be thread-safe, because it may be called by several EventLoop instances, each running in a thread.
| conn | the BaseOFConnection on which the message was received |
| event_type | the event type (see #BaseOFConnectionEvent) |
Implements fluid_base::BaseOFHandler.
Reimplemented in fluid_base::OFServer.
|
inlinevirtual |
Callback for new messages.
This method blocks the event loop on which the connection is running, preventing other connection's events from being handled. If you want to perform a very long operation, try to queue it and return.
The implementation must be thread-safe, because it may be called by several EventLoop instances, each running in a thread.
The message data will not be freed. To free it, you should call BaseOFConnection::free_data when you are done with it.
| conn | the BaseOFConnection on which the message was received |
| data | binary message data |
| len | message length |
Implements fluid_base::BaseOFHandler.
Reimplemented in fluid_base::OFServer.
|
virtual |
Free the data passed to BaseOFHandler::base_message_callback.
Implements fluid_base::BaseOFHandler.
Reimplemented in fluid_base::OFServer.