Revised OpenFlow Library  v0.6.0dev
 All Classes Files Functions Variables Friends Groups Pages
cfibentry.h
1 /*
2  * cfibentry.h
3  *
4  * Created on: 15.07.2013
5  * Author: andreas
6  */
7 
8 #ifndef CFIBENTRY_H_
9 #define CFIBENTRY_H_ 1
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 {
26 
32 class eFibBase : public std::runtime_error {
33 public:
34  eFibBase(const std::string& __arg) : std::runtime_error(__arg) {};
35 };
36 
42 class eFibInval : public eFibBase {
43 public:
44  eFibInval(const std::string& __arg) : eFibBase(__arg) {};
45 };
46 
52 class eFibNotFound : public eFibBase {
53 public:
54  eFibNotFound(const std::string& __arg) : eFibBase(__arg) {};
55 };
56 
57 }; // namespace exceptions
58 
59 
60 class cfibentry; // forward declaration
61 
62 
70  friend class cfibentry;
71 public:
72 
76  virtual
78  {};
79 
80 protected:
81 
85  virtual void
87  const rofl::caddress_ll& hwaddr) = 0;
88 
92  virtual void
94  const cfibentry& entry) = 0;
95 };
96 
97 
98 
113 class cfibentry : public rofl::ciosrv {
114 public:
115 
124  cfibentry(
125  cfibentry_env *env,
126  const rofl::cdptid& dptid,
127  const rofl::caddress_ll& hwaddr,
128  uint32_t port_no);
129 
133  virtual
134  ~cfibentry();
135 
136 public:
137 
149  uint32_t
150  get_port_no() const
151  { return port_no; };
152 
158  void
159  set_port_no(uint32_t port_no);
160 
166  const rofl::caddress_ll&
167  get_hwaddr() const
168  { return hwaddr; };
169 
172 private:
173 
187  virtual void
188  handle_timeout(
189  int opaque,
190  void* data = (void*)NULL);
191 
192 public:
193 
197  friend std::ostream&
198  operator<< (std::ostream& os, cfibentry const& entry) {
199  os << rofl::indent(0) << "<cfibentry portno: "
200  << entry.port_no << " >" << std::endl;
201  rofl::indent i(2);
202  os << entry.hwaddr;
203  return os;
204  };
205 
206 private:
207 
208 #define CFIBENTRY_DEFAULT_TIMEOUT 60
209 
210  enum cfibentry_timer_t {
211  CFIBENTRY_ENTRY_EXPIRED = 1,
212  };
213 
214  // pointer to class defining the environment for this cfibentry
215  cfibentry_env* env;
216  // rofl-common's internal datapath handle
217  rofl::cdptid dptid;
218 
219  // OpenFlow port number pointing towards port
220  uint32_t port_no;
221  // station ethernet hardware address
222  rofl::caddress_ll hwaddr;
223 
224  // timeout value in seconds for this FIB entry
225  int entry_timeout;
226  // timer handle obtained from rofl::ciosrv when registering this timer
227  rofl::ctimerid expiration_timer_id;
228 };
229 
230 }; // namespace ethswctld
231 }; // namespace examples
232 }; // namespace rofl
233 
234 #endif /* CFIBENTRY_H_ */
cfibentry(cfibentry_env *env, const rofl::cdptid &dptid, const rofl::caddress_ll &hwaddr, uint32_t port_no)
cfibentry constructor
Definition: cfibentry.cc:12
Base class for all exceptions thrown by class cfibtable.
Definition: cfibentry.h:32
Definition: caddress.h:152
const rofl::caddress_ll & get_hwaddr() const
Returns ethernet hardware address identifying this host.
Definition: cfibentry.h:167
Timer handle used by class rofl::cioloop.
Definition: ctimerid.h:21
rofl-common's internal remote datapath handle.
Definition: cdptid.h:24
uint32_t get_port_no() const
Returns port number stored for this host.
Definition: cfibentry.h:150
virtual ~cfibentry()
cfibentry destructor
Definition: cfibentry.cc:29
virtual ~cfibentry_env()
cfibentry_env destructor
Definition: cfibentry.h:77
Defines the environment expected by an instance of class cfibentry.
Definition: cfibentry.h:69
Stores a FIB entry mapping host hwaddr to switch port number.
Definition: cfibentry.h:113
virtual void fib_timer_expired(const rofl::caddress_ll &hwaddr)=0
Called when this FIB entry has expired.
Invalid parameter specified.
Definition: cfibentry.h:42
void set_port_no(uint32_t port_no)
Update port number stored for this host.
Definition: cfibentry.cc:49
friend std::ostream & operator<<(std::ostream &os, cfibentry const &entry)
output operator for class cfibentry
Definition: cfibentry.h:198
Base class for IO services.
Definition: ciosrv.h:491
Definition: logging.h:76
Element not found.
Definition: cfibentry.h:52
virtual void fib_port_update(const cfibentry &entry)=0
Called when this FIB entry's port number has been updated.