libfluid
The ONF OpenFlow driver
of10common.hh
1 #ifndef OF10OPENFLOW_COMMON_H
2 #define OF10OPENFLOW_COMMON_H 1
3 
4 #include <vector>
5 #include <string>
6 #include "fluid/util/util.h"
7 #include "fluid/ofcommon/common.hh"
8 #include "openflow-10.h"
9 #include "of10action.hh"
10 #include "of10match.hh"
11 
12 
13 namespace fluid_msg {
14 
15 namespace of10 {
16 
17 class Port: public PortCommon {
18 private:
19  uint16_t port_no_;
20 public:
21  Port() {
22  }
23  Port(uint16_t port_no, EthAddress hw_addr, std::string name,
24  uint32_t config, uint32_t state, uint32_t curr, uint32_t advertised,
25  uint32_t supported, uint32_t peer);
26  ~Port() {
27  }
28  bool operator==(const Port &other) const;
29  bool operator!=(const Port &other) const;
30  size_t pack(uint8_t* buffer);
31  of_error unpack(uint8_t* buffer);
32  void port_no(uint16_t port_no) {
33  this->port_no_ = port_no;
34  }
35  uint16_t port_no() {
36  return this->port_no_;
37  }
38 };
39 
41 public:
43  : QueuePropRate(of10::OFPQT_MIN_RATE) {
44  }
45  QueuePropMinRate(uint16_t rate);
46  ~QueuePropMinRate() {
47  }
48  virtual bool equals(const QueueProperty & other);
49  virtual QueuePropMinRate* clone() {
50  return new QueuePropMinRate(*this);
51  }
52  size_t pack(uint8_t* buffer);
53  of_error unpack(uint8_t* buffer);
54 };
55 
56 /* Queue description*/
58 public:
59  PacketQueue() {
60  }
61  PacketQueue(uint32_t queue_id);
62  PacketQueue(uint32_t queue_id, QueuePropertyList properties);
63  ~PacketQueue() {
64  }
65  size_t pack(uint8_t* buffer);
66  of_error unpack(uint8_t* buffer);
67 };
68 
69 class FlowStats: public FlowStatsCommon {
70 private:
71  of10::Match match_;
72  ActionList actions_;
73 public:
74  FlowStats() {
75  }
76  FlowStats(uint8_t table_id, uint32_t duration_sec, uint32_t duration_nsec,
77  uint16_t priority, uint16_t idle_timeout, uint16_t hard_timeout,
78  uint64_t cookie, uint64_t packet_count, uint64_t byte_count);
79  FlowStats(uint8_t table_id, uint32_t duration_sec, uint32_t duration_nsec,
80  uint16_t priority, uint16_t idle_timeout, uint16_t hard_timeout,
81  uint64_t cookie, uint64_t packet_count, uint64_t byte_count,
82  of10::Match match, ActionList actions);
83  ~FlowStats() {
84  }
85 
86  bool operator==(const FlowStats &other) const;
87  bool operator!=(const FlowStats &other) const;
88  size_t pack(uint8_t* buffer);
89  of_error unpack(uint8_t* buffer);
90  of10::Match match() {
91  return this->match_;
92  }
93  ActionList actions() {
94  return this->actions_;
95  }
96 
97  void match(of10::Match match) {
98  this->match_ = match;
99  }
100  void actions(ActionList actions);
101  void add_action(Action &action);
102  void add_action(Action* action);
103 };
104 
106 private:
107  std::string name_;
108  uint32_t wildcards_;
109  uint32_t max_entries_;
110 public:
111  TableStats() {
112  }
113 
114  TableStats(uint8_t table_id, std::string name, uint32_t wildcards,
115  uint32_t max_entries, uint32_t active_count, uint64_t lookup_count,
116  uint64_t matched_count);
117  ~TableStats() {
118  }
119 
120  bool operator==(const TableStats &other) const;
121  bool operator!=(const TableStats &other) const;
122  size_t pack(uint8_t* buffer);
123  of_error unpack(uint8_t* buffer);
124  std::string name() {
125  return this->name_;
126  }
127  uint32_t wildcards() {
128  return this->wildcards_;
129  }
130  uint32_t max_entries() {
131  return this->max_entries_;
132  }
133  void name(std::string name) {
134  this->name_ = name;
135  }
136  void wildcards(uint32_t wildcards) {
137  this->wildcards_ = wildcards;
138  }
139  void max_entries(uint32_t max_entries) {
140  this->max_entries_ = max_entries;
141  }
142 };
143 
144 class PortStats: public PortStatsCommon {
145 private:
146  uint16_t port_no_;
147 public:
148  PortStats() {
149  }
150 
151  PortStats(uint16_t port_no, struct port_rx_tx_stats tx_stats,
152  struct port_err_stats err_stats, uint64_t collisions);
153  ~PortStats() {
154  }
155 
156  bool operator==(const PortStats &other) const;
157  bool operator!=(const PortStats &other) const;
158  size_t pack(uint8_t* buffer);
159  of_error unpack(uint8_t* buffer);
160  uint16_t port_no() {
161  return this->port_no_;
162  }
163  void port_no(uint16_t port_no) {
164  this->port_no_ = port_no;
165  }
166 };
167 
169 private:
170  uint16_t port_no_;
171 public:
172  QueueStats() {
173  }
174 
175  QueueStats(uint16_t port_no, uint32_t queue_id, uint64_t tx_bytes,
176  uint64_t tx_packets, uint64_t tx_errors);
177  ~QueueStats() {
178  }
179 
180  bool operator==(const QueueStats &other) const;
181  bool operator!=(const QueueStats &other) const;
182  size_t pack(uint8_t* buffer);
183  of_error unpack(uint8_t* buffer);
184  uint16_t port_no() {
185  return this->port_no_;
186  }
187  void port_no(uint16_t port_no) {
188  this->port_no_ = port_no;
189  }
190 };
191 
192 } //End of namespace of10
193 } //End of namespace fluid_msg
194 
195 #endif