libfluid
The ONF OpenFlow driver
Classes | Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
fluid_base::BaseOFConnection Class Reference

#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
 

Detailed Description

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.

Member Enumeration Documentation

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

Constructor & Destructor Documentation

fluid_base::BaseOFConnection::BaseOFConnection ( int  id,
BaseOFHandler ofhandler,
EventLoop evloop,
int  fd,
bool  secure 
)

Create a BaseOFConnection.

Parameters
idconnection id
ofhandlerthe BaseOFHandler for this connection
evloopthe EventLoop that will run this connection
fdthe OS-level file descriptor for this connection
securewhether 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.

Member Function Documentation

void fluid_base::BaseOFConnection::send ( void *  data,
size_t  len 
)

Send a message through this connection.

This method is thread-safe.

Parameters
databinary message data
lenmessage 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.

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::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.

Parameters
managerthe 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 void fluid_base::BaseOFConnection::free_data ( void *  data)
static

Free the dynamically allocated data sent to the message callback.

Parameters
datadynamically allocated data sent to the message callback

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