Revised OpenFlow Library  v0.6.0dev
 All Classes Files Functions Variables Friends Groups Pages
coftablefeatures.h
1 /*
2  * coftablestats.h
3  *
4  * Created on: 14.03.2013
5  * Author: andi
6  */
7 
8 #ifndef COFTABLEFEATURES_H_
9 #define COFTABLEFEATURES_H_ 1
10 
11 #include <inttypes.h>
12 
13 #include "rofl/common/cmemory.h"
14 #include "rofl/common/croflexception.h"
15 #include "rofl/common/openflow/openflow.h"
16 #include "rofl/common/openflow/openflow_rofl_exceptions.h"
17 #include "rofl/common/openflow/coftablefeatureprops.h"
18 
19 namespace rofl {
20 namespace openflow {
21 
25 
27  public rofl::cmemory
28 {
29 private:
30 
31  uint8_t ofp_version;
32  rofl::openflow::coftable_feature_props table_feature_props;
33 
34  union {
35  uint8_t* ofhu_table_features_generic;
36  struct rofl::openflow13::ofp_table_features* ofhu_table_features;
37  } ofh_ofhu;
38 
39 #define ofh_tf_generic ofh_ofhu.ofhu_table_features_generic
40 #define ofh_table_features ofh_ofhu.ofhu_table_features
41 
42 
43 public:
44 
49  uint8_t of_version = rofl::openflow::OFP_VERSION_UNKNOWN);
50 
51 
55  virtual
57 
58 
63  coftable_features const& table_features);
64 
69  operator= (
70  coftable_features const& table_features);
71 
72 
73 
77  size_t
78  length() const;
79 
83  void
84  pack(uint8_t* buf, size_t buflen);
85 
89  void
90  unpack(uint8_t* buf, size_t buflen);
91 
92 public:
93 
97  uint8_t
98  get_version() const { return ofp_version; };
99 
103  void
104  set_version(uint8_t ofp_version) { this->ofp_version = ofp_version; };
105 
109  uint16_t
110  get_length() const { return be16toh(ofh_table_features->length); };
111 
115  void
116  set_length(uint16_t length) { ofh_table_features->length = htobe16(length); };
117 
121  uint8_t
122  get_table_id() const { return ofh_table_features->table_id; };
123 
127  void
128  set_table_id(uint8_t table_id) { ofh_table_features->table_id = table_id; };
129 
133  std::string
134  get_name() const {
135  return std::string(ofh_table_features->name, strnlen(ofh_table_features->name, OFP_MAX_TABLE_NAME_LEN));
136  };
137 
141  void
142  set_name(std::string const& name) {
143  memset(ofh_table_features->name, 0, OFP_MAX_TABLE_NAME_LEN);
144  strncpy(ofh_table_features->name, name.c_str(), OFP_MAX_TABLE_NAME_LEN);
145  };
146 
150  uint64_t
151  get_metadata_match() const { return be64toh(ofh_table_features->metadata_match); };
152 
156  void
157  set_metadata_match(uint64_t metadata_match) { ofh_table_features->metadata_match = htobe64(metadata_match); };
158 
162  uint64_t
163  get_metadata_write() const { return be64toh(ofh_table_features->metadata_write); };
164 
168  void
169  set_metadata_write(uint64_t metadata_write) { ofh_table_features->metadata_write = htobe64(metadata_write); };
170 
174  uint32_t
175  get_config() const { return be32toh(ofh_table_features->config); };
176 
180  void
181  set_config(uint32_t config) { ofh_table_features->config = htobe32(config); };
182 
186  uint32_t
187  get_max_entries() const { return be32toh(ofh_table_features->max_entries); };
188 
192  void
193  set_max_entries(uint32_t max_entries) { ofh_table_features->max_entries = htobe32(max_entries); };
194 
199  get_properties() const { return table_feature_props; };
200 
205  set_properties() { return table_feature_props; };
206 
207 public:
208 
209  friend std::ostream&
210  operator<< (std::ostream& os, coftable_features const& msg) {
211  os << indent(0) << "<coftable_features >" << std::endl;
212  os << indent(2) << "<table-id: " << (int)msg.get_table_id() << " >" << std::endl;
213  os << indent(2) << "<name: " << msg.get_name() << " >" << std::endl;
214  os << std::hex;
215  os << indent(2) << "<metadata-match: 0x"<< (unsigned long long)msg.get_metadata_match() << " >" << std::endl;
216  os << indent(2) << "<metadata-write: 0x"<< (unsigned long long)msg.get_metadata_write() << " >" << std::endl;
217  os << indent(2) << "<config: 0x" << (unsigned int)msg.get_config() << " >" << std::endl;
218  os << indent(2) << "<max-entries: 0x" << (unsigned int)msg.get_max_entries() << " >" << std::endl;
219  os << std::dec;
220  indent i(2);
221  os << msg.get_properties();
222  return os;
223  };
224 
225 };
226 
227 }; // end of namespace openflow
228 }; // end of namespace rofl
229 
230 #endif /* COFTABLEFEATURES_H_ */
Definition: coftablefeatures.h:23
Definition: coftablefeatures.h:24
Definition: coftablefeatures.h:26
Definition: openflow13.h:1274
Definition: coftablefeatureprops.h:29
void unpack(uint8_t *buf, size_t buflen)
Copies content of specified buffer into this cmemory instance .
Definition: coftablefeatures.cc:87
C++ abstraction for malloc'ed memory areas.
Definition: cmemory.h:44
void pack(uint8_t *buf, size_t buflen)
Copies content of this cmemory instance to specified buffer.
Definition: coftablefeatures.cc:64
Definition: logging.h:76
Definition: coftablefeatures.h:22
Definition: croflexception.h:27