1 #ifndef OF13OPENFLOW_COMMON_H
2 #define OF13OPENFLOW_COMMON_H 1
7 #include "fluid/ofcommon/common.hh"
8 #include "fluid/util/util.h"
9 #include "openflow-13.h"
10 #include "of13action.hh"
11 #include "of13instruction.hh"
24 HelloElem(uint16_t type, uint16_t length);
27 bool operator==(
const HelloElem &other)
const;
28 bool operator!=(
const HelloElem &other)
const;
35 void type(uint16_t type) {
38 void length(uint16_t length) {
39 this->length_ = length;
45 std::list<uint32_t> bitmaps_;
49 sizeof(
struct of13::ofp_hello_elem_versionbitmap)) {
54 size_t pack(uint8_t* buffer);
55 of_error unpack(uint8_t *data);
56 std::list<uint32_t> bitmaps() {
57 return this->bitmaps_;
59 void bitmaps(std::list<uint32_t> bitmaps) {
60 this->bitmaps_ = bitmaps;
62 void add_bitmap(uint32_t bitmap);
73 uint32_t config, uint32_t state, uint32_t curr, uint32_t advertised,
74 uint32_t supported, uint32_t peer, uint32_t curr_speed,
78 bool operator==(
const Port &other)
const;
79 bool operator!=(
const Port &other)
const;
80 size_t pack(uint8_t* buffer);
81 of_error unpack(uint8_t* buffer);
83 return this->port_no_;
85 uint32_t curr_speed() {
86 return this->curr_speed_;
88 uint32_t max_speed() {
89 return this->max_speed_;
91 void port_no(uint32_t port_no) {
92 this->port_no_ = port_no;
94 void curr_speed(uint32_t curr_speed) {
95 this->curr_speed_ = curr_speed;
97 void max_speed(uint32_t max_speed) {
98 this->max_speed_ = max_speed;
114 size_t pack(uint8_t* buffer);
115 of_error unpack(uint8_t* buffer);
130 size_t pack(uint8_t* buffer);
131 of_error unpack(uint8_t* buffer);
136 uint32_t experimenter_;
146 size_t pack(uint8_t* buffer);
147 of_error unpack(uint8_t* buffer);
148 uint32_t get_experimenter() {
149 return this->experimenter_;
151 void set_experimenter(uint32_t experimenter) {
152 this->experimenter_ = experimenter;
168 size_t pack(uint8_t* buffer);
169 of_error unpack(uint8_t* buffer);
173 void port(uint32_t port) {
182 uint32_t watch_port_;
183 uint32_t watch_group_;
187 Bucket(uint16_t weight, uint32_t watch_port, uint32_t watch_group);
188 Bucket(uint16_t weight, uint32_t watch_port, uint32_t watch_group,
192 bool operator==(
const Bucket &other)
const;
193 bool operator!=(
const Bucket &other)
const;
194 size_t pack(uint8_t* buffer);
195 of_error unpack(uint8_t* buffer);
197 return this->length_;
200 return this->weight_;
202 uint32_t watch_port() {
203 return this->watch_port_;
205 uint32_t watch_group() {
206 return this->watch_group_;
209 return this->actions_;
211 void weight(uint16_t weight) {
212 this->weight_ = weight;
214 void watch_port(uint32_t watch_port) {
215 this->watch_port_ = watch_port;
217 void watch_group(uint32_t watch_group) {
218 this->watch_group_ = watch_group;
221 void add_action(
Action &action);
222 void add_action(
Action* action);
232 FlowStats(uint8_t table_id, uint32_t duration_sec, uint32_t duration_nsec,
233 uint16_t priority, uint16_t idle_timeout, uint16_t hard_timeout,
234 uint16_t flags, uint64_t cookie, uint64_t packet_count,
235 uint64_t byte_count);
238 bool operator==(
const FlowStats &other)
const;
239 bool operator!=(
const FlowStats &other)
const;
240 size_t pack(uint8_t* buffer);
241 of_error unpack(uint8_t* buffer);
242 uint16_t get_flags() {
245 void set_flags(uint16_t flags) {
246 this->flags_ = flags;
252 OXMTLV * get_oxm_field(uint8_t field);
260 TableStats(uint8_t table_id, uint32_t active_count, uint64_t lookup_count,
261 uint64_t matched_count);
264 size_t pack(uint8_t* buffer);
265 of_error unpack(uint8_t* buffer);
271 uint32_t duration_sec_;
272 uint32_t duration_nsec_;
277 uint32_t duration_sec, uint32_t duration_nsec);
280 bool operator==(
const PortStats &other)
const;
281 bool operator!=(
const PortStats &other)
const;
282 size_t pack(uint8_t* buffer);
283 of_error unpack(uint8_t* buffer);
285 return this->port_no_;
287 uint32_t duration_sec() {
288 return this->duration_sec_;
290 uint32_t duration_nsec() {
291 return this->duration_nsec_;
293 void port_no(uint32_t port_no) {
294 this->port_no_ = port_no;
296 void duration_sec(uint32_t duration_sec) {
297 this->duration_sec_ = duration_sec;
299 void duration_nsec(uint32_t duration_nsec) {
300 this->duration_nsec_ = duration_nsec;
307 uint32_t duration_sec_;
308 uint32_t duration_nsec_;
311 QueueStats(uint32_t port_no, uint32_t queue_id, uint64_t tx_bytes,
312 uint64_t tx_packets, uint64_t tx_errors, uint32_t duration_sec,
313 uint32_t duration_nsec);
316 bool operator==(
const QueueStats &other)
const;
317 bool operator!=(
const QueueStats &other)
const;
318 size_t pack(uint8_t* buffer);
319 of_error unpack(uint8_t* buffer);
321 return this->port_no_;
323 uint32_t duration_sec() {
324 return this->duration_sec_;
326 uint32_t duration_nsec() {
327 return this->duration_nsec_;
329 void port_no(uint32_t port_no) {
330 this->port_no_ = port_no;
332 void duration_sec(uint32_t duration_sec) {
333 this->duration_sec_ = duration_sec;
335 void duration_nsec(uint32_t duration_nsec) {
336 this->duration_nsec_ = duration_nsec;
342 uint64_t packet_count_;
343 uint64_t byte_count_;
346 BucketStats(uint64_t packet_count, uint64_t byte_count);
351 size_t pack(uint8_t* buffer);
352 of_error unpack(uint8_t* buffer);
353 uint64_t packet_count() {
354 return this->packet_count_;
356 uint64_t byte_count() {
357 return this->byte_count_;
366 uint64_t packet_count_;
367 uint64_t byte_count_;
368 uint32_t duration_sec_;
369 uint32_t duration_nsec_;
370 std::vector<BucketStats> bucket_stats_;
373 : length_(
sizeof(
struct of13::ofp_group_stats)) {
375 GroupStats(uint32_t group_id, uint32_t ref_count, uint64_t packet_count,
376 uint64_t byte_count, uint32_t duration_sec, uint32_t duration_nsec);
377 GroupStats(uint32_t group_id, uint32_t ref_count, uint64_t packet_count,
378 uint64_t byte_count, uint32_t duration_sec, uint32_t duration_nsec,
379 std::vector<BucketStats> bucket_stats);
382 bool operator==(
const GroupStats &other)
const;
383 bool operator!=(
const GroupStats &other)
const;
384 size_t pack(uint8_t* buffer);
385 of_error unpack(uint8_t* buffer);
387 return this->length_;
389 uint32_t group_id() {
390 return this->group_id_;
392 uint32_t ref_count() {
393 return this->ref_count_;
395 uint64_t packet_count() {
396 return this->packet_count_;
398 uint64_t byte_count() {
399 return this->byte_count_;
401 uint32_t duration_sec() {
402 return this->duration_sec_;
404 uint32_t duration_nsec() {
405 return this->duration_nsec_;
407 void group_id(uint32_t group_id) {
408 this->group_id_ = group_id;
410 void ref_count(uint32_t ref_count) {
411 this->ref_count_ = ref_count;
413 void packet_count(uint64_t packet_count) {
414 this->packet_count_ = packet_count;
416 void byte_count(uint64_t byte_count) {
417 this->byte_count_ = byte_count;
419 void duration_sec(uint32_t duration_sec) {
420 this->duration_sec_ = duration_sec;
422 void duration_nsec(uint64_t duration_nsec) {
423 this->duration_nsec_ = duration_nsec;
425 void bucket_stats(std::vector<BucketStats> bucket_stats);
434 std::vector<of13::Bucket> buckets_;
437 : length_(
sizeof(
struct of13::ofp_group_desc_stats)) {
439 GroupDesc(uint8_t type, uint32_t group_id);
440 GroupDesc(uint8_t type, uint32_t group_id,
441 std::vector<of13::Bucket> buckets);
444 bool operator==(
const GroupDesc &other)
const;
445 bool operator!=(
const GroupDesc &other)
const;
446 size_t pack(uint8_t* buffer);
447 of_error unpack(uint8_t* buffer);
449 return this->length_;
454 uint32_t group_id() {
455 return this->group_id_;
457 std::vector<of13::Bucket> buckets() {
458 return this->buckets_;
460 void type(uint8_t type) {
463 void group_id(uint32_t group_id) {
464 this->group_id_ = group_id;
466 void buckets(std::vector<Bucket> buckets);
467 void add_bucket(
Bucket bucket);
468 size_t buckets_len();
474 uint32_t capabilities_;
475 uint32_t max_groups_[4];
476 uint32_t actions_[4];
480 GroupFeatures(uint32_t types, uint32_t capabilities, uint32_t max_groups[4],
481 uint32_t actions[4]);
486 size_t pack(uint8_t* buffer);
487 of_error unpack(uint8_t* buffer);
491 uint32_t capabilities() {
492 return this->capabilities_;
494 uint32_t* max_groups() {
495 return this->max_groups_;
497 uint32_t* actions() {
498 return this->actions_;
500 void types(uint32_t types) {
501 this->types_ = types;
503 void capabilities(uint32_t capabilities) {
504 this->capabilities_ = capabilities;
506 void max_groups(uint32_t max_groups[4]) {
507 memcpy(this->max_groups_, max_groups, 16);
509 void actions(uint32_t actions[4]) {
510 memcpy(this->actions_, actions, 16);
521 : length_(
sizeof(
struct ofp_table_feature_prop_header)),
533 virtual size_t pack(uint8_t* buffer);
534 virtual of_error unpack(uint8_t* buffer);
539 return this->length_;
542 return this->padding_;
544 void type(uint16_t type) {
547 void length(uint16_t length) {
548 this->length_ = length;
558 std::vector<Instruction> instruction_ids_;
567 std::vector<Instruction> instruction_ids);
574 size_t pack(uint8_t* buffer);
575 of_error unpack(uint8_t* buffer);
576 std::vector<Instruction> instruction_ids() {
577 return this->instruction_ids_;
579 void instruction_ids(std::vector<Instruction> instruction_ids);
584 std::vector<uint8_t> next_table_ids_;
593 std::vector<uint8_t> next_table_ids);
600 size_t pack(uint8_t* buffer);
601 of_error unpack(uint8_t* buffer);
602 std::vector<uint8_t> next_table_ids() {
603 return this->next_table_ids_;
605 void table_ids(std::vector<uint8_t> table_ids);
610 std::vector<Action> action_ids_;
625 size_t pack(uint8_t* buffer);
626 of_error unpack(uint8_t* buffer);
627 std::vector<Action> action_ids() {
628 return this->action_ids_;
630 void action_ids(std::vector<Action> action_ids);
635 std::vector<uint32_t> oxm_ids_;
650 size_t pack(uint8_t* buffer);
651 of_error unpack(uint8_t* buffer);
652 void oxm_ids(std::vector<uint32_t> oxm_ids);
657 uint32_t experimenter_;
671 size_t pack(uint8_t* buffer);
672 of_error unpack(uint8_t* buffer);
678 std::list<TableFeatureProp*> property_list_;
689 size_t pack(uint8_t* buffer);
690 of_error unpack(uint8_t* buffer);
693 return this->length_;
695 std::list<TableFeatureProp*> property_list() {
696 return this->property_list_;
698 void property_list(std::list<TableFeatureProp*> property_list);
699 void length(uint16_t length) {
700 this->length_ = length;
710 uint64_t metadata_match_;
711 uint64_t metadata_write_;
713 uint32_t max_entries_;
717 : length_(
sizeof(
struct of13::ofp_table_features)) {
719 TableFeatures(uint8_t table_id, std::string name, uint64_t metadata_match,
720 uint64_t metadata_write, uint32_t config, uint32_t max_entries);
725 size_t pack(uint8_t* buffer);
726 of_error unpack(uint8_t* buffer);
729 return this->table_id_;
734 uint64_t metadata_match() {
735 return this->metadata_match_;
737 uint64_t metadata_write() {
738 return this->metadata_write_;
741 return this->config_;
743 uint32_t max_entries() {
744 return this->max_entries_;
747 return this->properties_;
749 void table_id(uint8_t table_id) {
750 this->table_id_ = table_id;
752 void name(std::string name) {
755 void metadata_match(uint64_t metadata_match) {
756 this->metadata_match_ = metadata_match;