libfluid
The ONF OpenFlow driver
GitHub:
libfluid
|
libfluid_base
|
libfluid_msg
Mailing list
Home
Documentation
API reference
libfluid_base
fluid
OFServer.hh
1
2
#ifndef __OFSERVER_HH__
3
#define __OFSERVER_HH__
4
5
#include <pthread.h>
6
7
#include <map>
8
9
#include "base/BaseOFConnection.hh"
10
#include "base/BaseOFServer.hh"
11
#include "OFConnection.hh"
12
#include "OFServerSettings.hh"
13
18
namespace
fluid_base {
28
class
OFServer
:
private
BaseOFServer
,
public
OFHandler
{
29
public
:
44
OFServer
(
const
char
* address,
45
const
int
port,
46
const
int
nthreads = 4,
47
const
bool
secure =
false
,
48
const
struct
OFServerSettings
ofsc =
OFServerSettings
());
49
virtual
~
OFServer
();
50
58
// We reimplement this so that SWIG bindings don't have know BaseOFServer
59
virtual
bool
start
(
bool
block =
false
);
60
67
virtual
void
stop
();
68
75
OFConnection
*
get_ofconnection
(
int
id
);
76
90
void
set_config
(
OFServerSettings
ofsc);
91
92
virtual
void
connection_callback
(
OFConnection
* conn,
OFConnection::Event
event_type) {};
93
virtual
void
message_callback
(
OFConnection
* conn, uint8_t type,
void
* data,
size_t
len) {};
94
virtual
void
free_data
(
void
* data);
95
96
protected
:
97
OFServerSettings
ofsc;
98
std::map<int, OFConnection*> ofconnections;
99
pthread_mutex_t ofconnections_lock;
100
101
inline
void
lock_ofconnections() {
102
pthread_mutex_lock(&ofconnections_lock);
103
}
104
105
inline
void
unlock_ofconnections() {
106
pthread_mutex_unlock(&ofconnections_lock);
107
}
108
109
void
base_message_callback
(BaseOFConnection* c,
void
* data,
size_t
len);
110
void
base_connection_callback
(BaseOFConnection* c,
BaseOFConnection::Event
event_type);
111
static
void
* send_echo(
void
* arg);
112
};
113
114
}
115
116
#endif