#include <BaseOFConnection.hh>
Public Types | |
enum | Event { EVENT_UP, EVENT_DOWN, EVENT_CLOSED } |
Public Member Functions | |
BaseOFConnection (int id, BaseOFHandler *ofhandler, EventLoop *evloop, int fd, bool secure) | |
void | send (void *data, size_t len) |
void | add_timed_callback (void *(*cb)(void *), int interval, void *arg) |
void | set_manager (void *manager) |
void * | get_manager () |
int | get_id () |
void | close () |
Static Public Member Functions | |
static void | free_data (void *data) |
Friends | |
class | LibEventBaseOFConnection |
A BaseOFConnection wraps the basic functionalities of a network connection with OpenFlow-oriented messaging features. It uses an OFReadBuffer for building the messages being read and dispatches events to a BaseOFHandler (who created it).
This connection will tipically be wrapped by a higher-level connection object (a manager object) providing further protocol semantics on top of it.
BaseOFConnection events.
Enumerator | |
---|---|
EVENT_UP |
The connection has been successfully established |
EVENT_DOWN |
The other end has ended the connection |
EVENT_CLOSED |
The connection resources have been released and freed |
fluid_base::BaseOFConnection::BaseOFConnection | ( | int | id, |
BaseOFHandler * | ofhandler, | ||
EventLoop * | evloop, | ||
int | fd, | ||
bool | secure | ||
) |
Create a BaseOFConnection.
id | connection id |
ofhandler | the BaseOFHandler for this connection |
evloop | the EventLoop that will run this connection |
fd | the OS-level file descriptor for this connection |
secure | whether the connection should use TLS. TLS support must compiled into the library and you need to call libfluid_ssl_init before you can use this feature. |
void fluid_base::BaseOFConnection::send | ( | void * | data, |
size_t | len | ||
) |
Send a message through this connection.
This method is thread-safe.
data | binary message data |
len | message length in bytes |
void fluid_base::BaseOFConnection::add_timed_callback | ( | void *(*)(void *) | cb, |
int | interval, | ||
void * | arg | ||
) |
Set up a function to be called forever with an argument at a regular interval.
This method is thread-safe.
cb | the callback function. It should accept a void* argument and return a void*. |
interval | interval in milisseconds |
arg | an argument to the callback function |
void fluid_base::BaseOFConnection::set_manager | ( | void * | manager) |
Set the manager for this connection. A manager provides further protocol semantics on top of a BaseOFConnection. This manager will tipically be used by an upper-level abstraction on top of BaseOFHandler to create its own representation of an OpenFlow connection that uses this connection.
This method is not thread-safe.
manager | the manager object |
void* fluid_base::BaseOFConnection::get_manager | ( | ) |
Get the manager for this connection. See BaseOFConnection::set_manager.
This method is not thread-safe.
int fluid_base::BaseOFConnection::get_id | ( | ) |
Get the connection id.
void fluid_base::BaseOFConnection::close | ( | ) |
Close this connection. It won't be closed immediately (remaining connection and message callbacks may still be called).
After it is closed, the resources associated with this connection will be freed, and no more callbacks will be invoked. Performing any further operations on this connection will lead to undefined behavior.
This method is thread-safe.
|
static |
Free the dynamically allocated data sent to the message callback.
data | dynamically allocated data sent to the message callback |