libfluid
The ONF OpenFlow driver
Public Types | Public Member Functions | List of all members
fluid_base::OFConnection Class Reference

#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)
 
OFHandlerget_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 ()
 

Detailed Description

An OFConnection represents an OpenFlow connection with basic protocol knowledge. It wraps a BaseOFConnection object, providing further abstractions on top of it.

Member Enumeration Documentation

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.

Enumerator
EVENT_STARTED 

The connection has been started, but it is still waiting for the OpenFlow handshake. It is not safe to use the connection.

EVENT_ESTABLISHED 

The connection has been established (OpenFlow handshake complete). It is safe to use the connection.

EVENT_FAILED_NEGOTIATION 

The version negotiation has failed because the parts cannot talk in a common OpenFlow version. It is not safe to use the connection.

EVENT_CLOSED 

The connection has been closed. It is not safe to use the connection.

EVENT_DEAD 

The connection has been closed due to inactivity (no response to echo requests). It is not safe to use the connection.

Constructor & Destructor Documentation

fluid_base::OFConnection::OFConnection ( BaseOFConnection c,
OFHandler ofhandler 
)

Create an OFConnection.

Parameters
cthe BaseOFConnection object that this OFConnection will represent
ofhandlerthe OFHandler instance responsible for this OFConnection

Member Function Documentation

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.

Parameters
statethe 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).

Parameters
versionan 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.

Parameters
datathe binary data to send
lenlength 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.

Parameters
cbthe callback function. It should accept a void* argument and return a void*.
intervalinterval in milisseconds
argan 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.

Parameters
dataa pointer to application data
void fluid_base::OFConnection::close ( )

Close the connection. This will not trigger OFServer::connection_callback.


The documentation for this class was generated from the following file: