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

#include <BaseOFServer.hh>

Inheritance diagram for fluid_base::BaseOFServer:
fluid_base::BaseOFHandler fluid_base::OFServer

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
 

Detailed Description

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.

Constructor & Destructor Documentation

fluid_base::BaseOFServer::BaseOFServer ( const char *  address,
const int  port,
const int  nevloops = 1,
const bool  secure = false 
)

Create a BaseOFServer.

Parameters
addressaddress to bind the server
portTCP port on which the server will listen
nevloopsnumber 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.
securewhether 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.

Member Function Documentation

virtual bool fluid_base::BaseOFServer::start ( bool  block = false)
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.

Parameters
blockblock the calling thread while the server is running

Reimplemented in fluid_base::OFServer.

virtual void fluid_base::BaseOFServer::stop ( )
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 void fluid_base::BaseOFServer::base_connection_callback ( BaseOFConnection conn,
BaseOFConnection::Event  event_type 
)
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.

Parameters
connthe BaseOFConnection on which the message was received
event_typethe event type (see #BaseOFConnectionEvent)

Implements fluid_base::BaseOFHandler.

Reimplemented in fluid_base::OFServer.

virtual void fluid_base::BaseOFServer::base_message_callback ( BaseOFConnection conn,
void *  data,
size_t  len 
)
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.

Parameters
connthe BaseOFConnection on which the message was received
databinary message data
lenmessage length

Implements fluid_base::BaseOFHandler.

Reimplemented in fluid_base::OFServer.

virtual void fluid_base::BaseOFServer::free_data ( void *  data)
virtual

Free the data passed to BaseOFHandler::base_message_callback.

Implements fluid_base::BaseOFHandler.

Reimplemented in fluid_base::OFServer.


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