Revised OpenFlow Library  v0.6.0dev
 All Classes Files Functions Variables Friends Groups Pages
cflowentry.h
1 /*
2  * cflow.h
3  *
4  * Created on: 15.08.2014
5  * Author: andreas
6  */
7 
8 #ifndef CFLOW_H_
9 #define CFLOW_H_
10 
11 #include <ostream>
12 #include <inttypes.h>
13 
14 #include <rofl/common/ciosrv.h>
15 #include <rofl/common/caddress.h>
16 #include <rofl/common/crofbase.h>
17 #include <rofl/common/crofdpt.h>
18 #include <rofl/common/logging.h>
19 #include <rofl/common/ctimerid.h>
20 
21 namespace rofl {
22 namespace examples {
23 namespace ethswctld {
24 
25 namespace exceptions {
32 class eFlowBase : public std::runtime_error {
33 public:
34  eFlowBase(const std::string& __arg) : std::runtime_error(__arg) {};
35 };
36 
43 class eFlowInval : public eFlowBase {
44 public:
45  eFlowInval(const std::string& __arg) : eFlowBase(__arg) {};
46 };
47 
54 class eFlowNotFound : public eFlowBase {
55 public:
56  eFlowNotFound(const std::string& __arg) : eFlowBase(__arg) {};
57 };
58 
59 }; // namespace exceptions
60 
61 
62 
63 class cflowentry; // forward declaration
64 
72  friend class cflowentry;
73 public:
74 
78  virtual
80  {};
81 
82 protected:
83 
87  virtual void
89  const cflowentry& entry) = 0;
90 };
91 
92 
109 class cflowentry : public rofl::ciosrv {
110 public:
111 
121  cflowentry(
122  cflowentry_env *flowenv,
123  const rofl::cdptid& dptid,
124  const rofl::caddress_ll& src,
125  const rofl::caddress_ll& dst,
126  uint32_t port_no);
127 
131  virtual
132  ~cflowentry();
133 
134 public:
135 
147  uint32_t
149  { return port_no; };
150 
156  void
158  uint32_t out_port_no);
159 
165  const rofl::caddress_ll&
166  get_dst() const
167  { return dst; };
168 
174  const rofl::caddress_ll&
175  get_src() const
176  { return src; };
177 
180 private:
181 
182  void
183  flow_mod_add();
184 
185  void
186  flow_mod_delete();
187 
188  void
189  flow_mod_modify();
190 
191 private:
192 
193  virtual void
194  handle_timeout(
195  int opaque,
196  void* data = (void*)NULL);
197 
198 public:
199 
203  friend std::ostream&
204  operator<< (std::ostream& os, const cflowentry& entry) {
205  os << rofl::indent(0) << "<cflowentry portno: " << (unsigned int)entry.port_no << " >" << std::endl;
206  rofl::indent i(2);
207  os << entry.src;
208  os << entry.dst;
209  return os;
210  };
211 
212 private:
213 
214  static const long CFLOWENTRY_DEFAULT_TIMEOUT = 60;
215 
216  enum cflowentry_timer_t {
217  CFLOWENTRY_ENTRY_EXPIRED = 1,
218  };
219 
220  cflowentry_env* env;
221  rofl::cdptid dptid;
222  uint32_t port_no;
223  rofl::caddress_ll src;
224  rofl::caddress_ll dst;
225  int entry_timeout;
226  rofl::ctimerid expiration_timer_id;
227 };
228 
229 }; // namespace ethswctld
230 }; // namespace examples
231 }; // namespace rofl
232 
233 #endif /* CFLOW_H_ */
Element not found.
Definition: cflowentry.h:54
Definition: caddress.h:152
Defines the environment expected by an instance of class cflowentry.
Definition: cflowentry.h:71
friend std::ostream & operator<<(std::ostream &os, const cflowentry &entry)
Output operator.
Definition: cflowentry.h:204
Timer handle used by class rofl::cioloop.
Definition: ctimerid.h:21
void set_out_port_no(uint32_t out_port_no)
Update port number stored for this flow.
Definition: cflowentry.cc:53
rofl-common's internal remote datapath handle.
Definition: cdptid.h:24
virtual ~cflowentry()
cflowentry destructor
Definition: cflowentry.cc:32
Invalid parameter specified.
Definition: cflowentry.h:43
Stores an active flow entry.
Definition: cflowentry.h:109
uint32_t get_out_port_no() const
Returns outgoing port number stored for this flow.
Definition: cflowentry.h:148
Base class for all exceptions thrown by class cflowtable.
Definition: cflowentry.h:32
const rofl::caddress_ll & get_dst() const
Returns ethernet hardware address identifying the destination host.
Definition: cflowentry.h:166
virtual ~cflowentry_env()
cflowentry_env destructor
Definition: cflowentry.h:79
Base class for IO services.
Definition: ciosrv.h:491
Definition: logging.h:76
const rofl::caddress_ll & get_src() const
Returns ethernet hardware address identifying the source host.
Definition: cflowentry.h:175
cflowentry(cflowentry_env *flowenv, const rofl::cdptid &dptid, const rofl::caddress_ll &src, const rofl::caddress_ll &dst, uint32_t port_no)
cflowentry constructor
Definition: cflowentry.cc:12
virtual void flow_timer_expired(const cflowentry &entry)=0
Called once the timer for this flow entry has expired.