Revised OpenFlow Library  v0.6.0dev
 All Classes Files Functions Variables Friends Groups Pages
cetherswitch.h
1 #ifndef ETHERSWITCH_H
2 #define ETHERSWITCH_H 1
3 
4 #include <inttypes.h>
5 #include <map>
6 
7 #include <rofl.h>
8 #include <rofl/common/caddress.h>
9 #include <rofl/common/crofbase.h>
10 #include <rofl/common/crofdpt.h>
11 #include <rofl/platform/unix/cunixenv.h>
12 #include <rofl/platform/unix/cdaemon.h>
13 #include <rofl/common/cparams.h>
14 
15 #include "cfibtable.h"
16 #include "cflowtable.h"
17 
18 namespace rofl {
19 namespace examples {
20 namespace ethswctld {
21 
22 
23 
32 class cetherswitch : public rofl::crofbase {
33 public:
34 
43  static
44  int
45  run(
46  int argc, char** argv);
47 
48 private:
49 
54  const rofl::openflow::cofhello_elem_versionbitmap& versionbitmap);
55 
59  virtual
60  ~cetherswitch();
61 
62 
65 private:
66 
75  virtual void
76  handle_dpt_open(
77  rofl::crofdpt& dpt);
78 
90  virtual void
91  handle_dpt_close(
92  rofl::crofdpt& dpt);
93 
101  virtual void
102  handle_packet_in(
103  rofl::crofdpt& dpt,
104  const rofl::cauxid& auxid,
106 
114  virtual void
115  handle_flow_stats_reply(
116  rofl::crofdpt& dpt,
117  const rofl::cauxid& auxid,
119 
129  virtual void
130  handle_flow_stats_reply_timeout(
131  rofl::crofdpt& dpt,
132  uint32_t xid);
133 
136 private:
137 
146  virtual void
147  handle_timeout(
148  int opaque,
149  void* data = (void*)NULL);
150 
154  void
155  dump_packet_in(
156  rofl::crofdpt& dpt,
158 
159 public:
160 
161  friend std::ostream&
162  operator<< (std::ostream& os, const cetherswitch& sw) {
163  try {
164  os << rofl::indent(0) << "<ethswitch dpid: "
165  << rofl::crofdpt::get_dpt(sw.dptid).get_dpid().str() << " >" << std::endl;
166  } catch (rofl::eRofDptNotFound& e) {
167  os << rofl::indent(0) << "<ethswitch dptid: " << sw.dptid << " >" << std::endl;
168  }
169  rofl::indent i(2);
170  os << cfibtable::set_fib(sw.dptid);
171  os << cflowtable::get_flowtable(sw.dptid);
172  return os;
173  };
174 
175 private:
176 
177  enum cetherswitch_timer_t {
178  TIMER_DUMP_FIB = 1,
179  TIMER_GET_FLOW_STATS = 2,
180  };
181 
182  rofl::cdptid dptid;
183 
184  rofl::ctimerid timer_id_dump_fib;
185  unsigned int dump_fib_interval;
186  static const unsigned int DUMP_FIB_DEFAULT_INTERVAL = 60; // seconds
187 
188  rofl::ctimerid timer_id_get_flow_stats;
189  unsigned int get_flow_stats_interval;
190  static const unsigned int GET_FLOW_STATS_DEFAULT_INTERVAL = 30; // seconds
191 };
192 
193 }; // namespace ethswctld
194 }; // namespace examples
195 }; // namespace rofl
196 
197 #endif
Definition: cauxid.h:30
Definition: cofmsg_flow_stats.h:164
static const cflowtable & get_flowtable(const rofl::cdptid &dptid)
Returns const reference to existing cflowtable instance or throws exception.
Definition: cflowtable.h:106
static int run(int argc, char **argv)
Static main routine for class cetherswitch.
Definition: cetherswitch.cc:9
Definition: crofdpt.h:51
Timer handle used by class rofl::cioloop.
Definition: ctimerid.h:21
Definition: cofhelloelemversionbitmap.h:22
rofl-common's internal remote datapath handle.
Definition: cdptid.h:24
const rofl::cdpid & get_dpid() const
Returns OpenFlow datapath identifier for this instance.
Definition: crofdpt.h:1259
Definition: cofmsg_packet_in.h:21
static cfibtable & set_fib(const rofl::cdptid &dptid)
Returns reference to existing cfibtable instance or creates a new empty one.
Definition: cfibtable.h:83
Definition: logging.h:76
Class representing a remote datapath element.
Definition: crofdpt.h:973
A very simple controller for forwarding Ethernet flows.
Definition: cetherswitch.h:32
static rofl::crofdpt & get_dpt(const rofl::cdptid &dptid)
Returns reference to rofl::crofdpt instance identified by rofl-common's internal identifier.
Definition: crofdpt.cc:17
Base class for revised OpenFlow library.
Definition: crofbase.h:100