#include <OFConnection.hh>
Public Types | |
enum | State { STATE_HANDSHAKE, STATE_RUNNING, STATE_FAILED, STATE_DOWN } |
enum | Event { EVENT_STARTED, EVENT_ESTABLISHED, EVENT_FAILED_NEGOTIATION, EVENT_CLOSED, EVENT_DEAD } |
Public Member Functions | |
OFConnection (BaseOFConnection *c, OFHandler *ofhandler) | |
int | get_id () |
bool | is_alive () |
void | set_alive (bool alive) |
uint8_t | get_state () |
void | set_state (OFConnection::State state) |
uint8_t | get_version () |
void | set_version (uint8_t version) |
OFHandler * | get_ofhandler () |
void | send (void *data, size_t len) |
void | add_timed_callback (void *(*cb)(void *), int interval, void *arg) |
void * | get_application_data () |
void | set_application_data (void *data) |
void | close () |
An OFConnection represents an OpenFlow connection with basic protocol knowledge. It wraps a BaseOFConnection object, providing further abstractions on top of it.
Represents the state of an OFConnection.
Enumerator | |
---|---|
STATE_HANDSHAKE |
Sent hello message, waiting for reply |
STATE_RUNNING |
Version negotiation done, features request received |
STATE_FAILED |
Version negotiation failed, connection closed |
STATE_DOWN |
OFConnection is down, unable to send/receive data (it will be closed automatically). It represents a disconnection event at the controller level. |
OFConnection events. In the descriptions below, "safe to use" means that messages can be sent and received normally according to the OpenFlow specification.
fluid_base::OFConnection::OFConnection | ( | BaseOFConnection * | c, |
OFHandler * | ofhandler | ||
) |
Create an OFConnection.
c | the BaseOFConnection object that this OFConnection will represent |
ofhandler | the OFHandler instance responsible for this OFConnection |
int fluid_base::OFConnection::get_id | ( | ) |
Get the connection ID.
bool fluid_base::OFConnection::is_alive | ( | ) |
Check if the connection is alive (responding to echo requests).
void fluid_base::OFConnection::set_alive | ( | bool | alive) |
Update the liveness state of the connection.
uint8_t fluid_base::OFConnection::get_state | ( | ) |
Get the connection state. See #OFConnection::State.
void fluid_base::OFConnection::set_state | ( | OFConnection::State | state) |
Set the connection state. See #OFConnection::State.
state | the new state. |
uint8_t fluid_base::OFConnection::get_version | ( | ) |
Get the negotiated OpenFlow version for the connection (OpenFlow protocol version number). Note that this is not an OFVersion value. It is the value that goes into the OpenFlow header (e.g.: 4 for OpenFlow 1.3).
void fluid_base::OFConnection::set_version | ( | uint8_t | version) |
Set a negotiated version for the connection. (OpenFlow protocol version number). Note that this is not an OFVersion value. It is the value that goes into the OpenFlow header (e.g.: 4 for OpenFlow 1.3).
version | an OpenFlow version number |
OFHandler* fluid_base::OFConnection::get_ofhandler | ( | ) |
Return the OFHandler instance responsible for the connection.
void fluid_base::OFConnection::send | ( | void * | data, |
size_t | len | ||
) |
Send data to through the connection.
data | the binary data to send |
len | length of the binary data (in bytes) |
void fluid_base::OFConnection::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 is a utility function provided for no specific use case, but rather because it is frequently needed.
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::OFConnection::get_application_data | ( | ) |
Get application data. This data is any piece of data you might want to associated with this OFConnection object.
void fluid_base::OFConnection::set_application_data | ( | void * | data) |
Set application data.
See OFConnection::get_application_data.
data | a pointer to application data |
void fluid_base::OFConnection::close | ( | ) |
Close the connection. This will not trigger OFServer::connection_callback.