libfluid
The ONF OpenFlow driver
GitHub:
libfluid
|
libfluid_base
|
libfluid_msg
Mailing list
Home
Documentation
API reference
libfluid_base
fluid
OFConnection.hh
1
2
#ifndef __OFCONNECTION_HH__
3
#define __OFCONNECTION_HH__
4
5
#include <stdint.h>
6
#include <stdlib.h>
7
8
namespace
fluid_base {
9
class
BaseOFConnection;
10
class
OFHandler;
11
17
class
OFConnection
{
18
public
:
25
OFConnection
(
BaseOFConnection
* c,
OFHandler
* ofhandler);
26
28
enum
State
{
30
STATE_HANDSHAKE
,
32
STATE_RUNNING
,
34
STATE_FAILED
,
38
STATE_DOWN
39
};
40
46
enum
Event
{
49
EVENT_STARTED
,
50
53
EVENT_ESTABLISHED
,
54
57
EVENT_FAILED_NEGOTIATION
,
58
61
EVENT_CLOSED
,
62
65
EVENT_DEAD
,
66
};
67
69
int
get_id
();
70
72
bool
is_alive
();
73
75
void
set_alive
(
bool
alive);
76
80
uint8_t
get_state
();
81
87
void
set_state
(
OFConnection::State
state);
88
93
uint8_t
get_version
();
94
102
void
set_version
(uint8_t version);
103
107
OFHandler
*
get_ofhandler
();
108
115
void
send
(
void
* data,
size_t
len);
116
129
void
add_timed_callback
(
void
* (*cb)(
void
*),
int
interval,
void
* arg);
130
// TODO: add the option for the function to unschedule itself by returning
131
// false
132
137
void
*
get_application_data
();
138
146
void
set_application_data
(
void
* data);
147
152
void
close
();
153
154
private
:
155
BaseOFConnection
* conn;
156
int
id;
157
State
state;
158
uint8_t version;
159
bool
alive;
160
OFHandler
* ofhandler;
161
void
* application_data;
162
};
163
169
class
OFHandler
{
170
public
:
171
virtual
~
OFHandler
() {}
172
186
virtual
void
connection_callback
(
OFConnection
* conn,
OFConnection::Event
event_type) = 0;
187
206
virtual
void
message_callback
(
OFConnection
* conn, uint8_t type,
void
* data,
size_t
len) = 0;
207
211
virtual
void
free_data
(
void
* data) = 0;
212
};
213
214
}
215
216
#endif