1 #ifndef OPENFLOW_MATCH_H
2 #define OPENFLOW_MATCH_H 1
6 #include "fluid/util/ethaddr.hh"
7 #include "fluid/util/ipaddr.hh"
8 #include "openflow-13.h"
28 virtual size_t pack(uint8_t *buffer);
29 virtual of_error unpack(uint8_t *buffer);
36 void type(uint16_t type) {
39 void length(uint16_t length) {
40 this->length_ = length;
45 uint16_t eth_type_req[2];
57 void create_oxm_req(uint16_t eth_type1, uint16_t eth_type2,
58 uint8_t ip_proto, uint8_t icmp);
61 OXMTLV(uint16_t class_, uint8_t field,
bool has_mask, uint8_t length);
64 virtual bool equals(
const OXMTLV & other);
65 virtual bool operator==(
const OXMTLV &other)
const;
66 virtual bool operator!=(
const OXMTLV &other)
const;
71 virtual size_t pack(uint8_t *buffer);
72 virtual of_error unpack(uint8_t *buffer);
80 return this->has_mask_;
89 void class_(uint16_t class_) {
90 this->class__ = class_;
92 void field(uint8_t field) {
95 void has_mask(
bool has_mask) {
96 this->has_mask_ = has_mask;
98 void length(uint8_t length) {
99 this->length_ = length;
101 static uint32_t make_header(uint16_t class_, uint8_t field,
bool has_mask,
103 static uint16_t oxm_class(uint32_t header);
104 static uint8_t oxm_field(uint32_t header);
105 static bool oxm_has_mask(uint32_t header);
106 static uint8_t oxm_length(uint32_t header);
114 create_oxm_req(0, 0, 0, 0);
119 virtual bool equals(
const OXMTLV & other);
124 size_t pack(uint8_t *buffer);
125 of_error unpack(uint8_t *buffer);
129 void value(uint32_t value) {
130 this->value_ = value;
139 create_oxm_req(0, 0, 0, 0);
144 virtual bool equals(
const OXMTLV & other);
149 size_t pack(uint8_t *buffer);
150 of_error unpack(uint8_t *buffer);
154 void value(uint32_t value) {
155 this->value_ = value;
165 create_oxm_req(0, 0, 0, 0);
168 Metadata(uint64_t value, uint64_t mask);
171 virtual bool equals(
const OXMTLV & other);
176 size_t pack(uint8_t *buffer);
177 of_error unpack(uint8_t *buffer);
184 void value(uint64_t value) {
185 this->value_ = value;
187 void mask(uint64_t mask) {
198 create_oxm_req(0, 0, 0, 0);
204 virtual bool equals(
const OXMTLV & other);
209 size_t pack(uint8_t *buffer);
210 of_error unpack(uint8_t *buffer);
218 this->value_ = value;
231 create_oxm_req(0, 0, 0, 0);
237 virtual bool equals(
const OXMTLV & other);
242 size_t pack(uint8_t *buffer);
243 of_error unpack(uint8_t *buffer);
251 this->value_ = value;
263 create_oxm_req(0, 0, 0, 0);
268 virtual bool equals(
const OXMTLV & other);
273 size_t pack(uint8_t *buffer);
274 of_error unpack(uint8_t *buffer);
278 void value(uint16_t value) {
279 this->value_ = value;
289 create_oxm_req(0, 0, 0, 0);
292 VLANVid(uint16_t value, uint16_t mask);
295 virtual bool equals(
const OXMTLV & other);
300 size_t pack(uint8_t *buffer);
301 of_error unpack(uint8_t *buffer);
308 void value(uint16_t value) {
309 this->value_ = value;
311 void mask(uint16_t mask) {
321 create_oxm_req(0, 0, 0, 0);
326 virtual bool equals(
const OXMTLV & other);
331 size_t pack(uint8_t *buffer);
332 of_error unpack(uint8_t *buffer);
336 void value(uint8_t value) {
337 this->value_ = value;
346 create_oxm_req(0x0800, 0x86dd, 0, 0);
351 virtual bool equals(
const OXMTLV & other);
356 size_t pack(uint8_t *buffer);
357 of_error unpack(uint8_t *buffer);
361 void value(uint8_t value) {
362 this->value_ = value;
371 create_oxm_req(0x0800, 0x86dd, 0, 0);
373 IPECN(uint8_t value);
376 virtual bool equals(
const OXMTLV & other);
378 virtual IPECN* clone() {
379 return new IPECN(*
this);
381 size_t pack(uint8_t *buffer);
382 of_error unpack(uint8_t *buffer);
386 void value(uint8_t value) {
387 this->value_ = value;
396 create_oxm_req(0x0800, 0x86dd, 0, 0);
401 virtual bool equals(
const OXMTLV & other);
406 size_t pack(uint8_t *buffer);
407 of_error unpack(uint8_t *buffer);
411 void value(uint8_t value) {
412 this->value_ = value;
422 : value_((uint32_t) 0),
423 mask_((uint32_t) 0) {
424 create_oxm_req(0x0800, 0, 0, 0);
430 virtual bool equals(
const OXMTLV & other);
435 size_t pack(uint8_t *buffer);
436 of_error unpack(uint8_t *buffer);
443 void value(uint32_t value) {
444 this->value_ = value;
446 void mask(uint32_t mask) {
457 : value_((uint32_t) 0),
458 mask_((uint32_t) 0) {
459 create_oxm_req(0x0800, 0, 0, 0);
465 virtual bool equals(
const OXMTLV & other);
470 size_t pack(uint8_t *buffer);
471 of_error unpack(uint8_t *buffer);
479 this->value_ = value;
491 create_oxm_req(0x0800, 0x86dd, 6, 0);
496 virtual bool equals(
const OXMTLV & other);
501 size_t pack(uint8_t *buffer);
502 of_error unpack(uint8_t *buffer);
506 void value(uint16_t value) {
507 this->value_ = value;
517 create_oxm_req(0x0800, 0x86dd, 6, 0);
522 virtual bool equals(
const OXMTLV & other);
527 size_t pack(uint8_t *buffer);
528 of_error unpack(uint8_t *buffer);
532 void value(uint16_t value) {
533 this->value_ = value;
542 create_oxm_req(0x0800, 0x86dd, 17, 0);
547 virtual bool equals(
const OXMTLV & other);
552 size_t pack(uint8_t *buffer);
553 of_error unpack(uint8_t *buffer);
557 void value(uint16_t value) {
558 this->value_ = value;
567 create_oxm_req(0x0800, 0x86dd, 17, 0);
572 virtual bool equals(
const OXMTLV & other);
577 size_t pack(uint8_t *buffer);
578 of_error unpack(uint8_t *buffer);
582 void value(uint16_t value) {
583 this->value_ = value;
592 create_oxm_req(0x0800, 0x86dd, 132, 0);
597 virtual bool equals(
const OXMTLV & other);
602 size_t pack(uint8_t *buffer);
603 of_error unpack(uint8_t *buffer);
607 void value(uint16_t value) {
608 this->value_ = value;
618 create_oxm_req(0x0800, 0x86dd, 132, 0);
623 virtual bool equals(
const OXMTLV & other);
628 size_t pack(uint8_t *buffer);
629 of_error unpack(uint8_t *buffer);
633 void value(uint16_t value) {
634 this->value_ = value;
643 create_oxm_req(0x0800, 0, 1, 0);
648 virtual bool equals(
const OXMTLV & other);
653 size_t pack(uint8_t *buffer);
654 of_error unpack(uint8_t *buffer);
658 void value(uint8_t value) {
659 this->value_ = value;
668 create_oxm_req(0x0800, 0, 1, 0);
673 virtual bool equals(
const OXMTLV & other);
678 size_t pack(uint8_t *buffer);
679 of_error unpack(uint8_t *buffer);
683 void value(uint8_t value) {
684 this->value_ = value;
693 create_oxm_req(0x0806, 0, 0, 0);
695 ARPOp(uint16_t value);
698 virtual bool equals(
const OXMTLV & other);
700 virtual ARPOp* clone() {
701 return new ARPOp(*
this);
703 size_t pack(uint8_t *buffer);
704 of_error unpack(uint8_t *buffer);
708 void value(uint16_t value) {
709 this->value_ = value;
719 create_oxm_req(0x0806, 0, 0, 0);
725 virtual bool equals(
const OXMTLV & other);
730 size_t pack(uint8_t *buffer);
731 of_error unpack(uint8_t *buffer);
739 this->value_ = value;
753 create_oxm_req(0x0806, 0, 0, 0);
759 virtual bool equals(
const OXMTLV & other);
764 size_t pack(uint8_t *buffer);
765 of_error unpack(uint8_t *buffer);
773 this->value_ = value;
786 create_oxm_req(0x0806, 0, 0, 0);
792 virtual bool equals(
const OXMTLV & other);
797 size_t pack(uint8_t *buffer);
798 of_error unpack(uint8_t *buffer);
806 this->value_ = value;
816 create_oxm_req(0x0806, 0, 0, 0);
822 virtual bool equals(
const OXMTLV & other);
827 size_t pack(uint8_t *buffer);
828 of_error unpack(uint8_t *buffer);
836 this->value_ = value;
847 create_oxm_req(0, 0x86dd, 0, 0);
853 virtual bool equals(
const OXMTLV & other);
858 size_t pack(uint8_t *buffer);
859 of_error unpack(uint8_t *buffer);
867 this->value_ = value;
880 create_oxm_req(0, 0x86dd, 0, 0);
886 virtual bool equals(
const OXMTLV & other);
891 size_t pack(uint8_t *buffer);
892 of_error unpack(uint8_t *buffer);
900 this->value_ = value;
913 create_oxm_req(0, 0x86dd, 0, 0);
919 virtual bool equals(
const OXMTLV & other);
924 size_t pack(uint8_t *buffer);
925 of_error unpack(uint8_t *buffer);
932 void value(uint32_t value) {
933 this->value_ = value;
935 void mask(uint32_t mask) {
945 create_oxm_req(0, 0x86dd, 58, 0);
950 virtual bool equals(
const OXMTLV & other);
955 size_t pack(uint8_t *buffer);
956 of_error unpack(uint8_t *buffer);
960 void value(uint8_t value) {
961 this->value_ = value;
970 create_oxm_req(0, 0x86dd, 58, 0);
975 virtual bool equals(
const OXMTLV & other);
980 size_t pack(uint8_t *buffer);
981 of_error unpack(uint8_t *buffer);
985 void value(uint8_t value) {
986 this->value_ = value;
995 create_oxm_req(0, 0x86dd, 58, 135);
1000 virtual bool equals(
const OXMTLV & other);
1005 size_t pack(uint8_t *buffer);
1006 of_error unpack(uint8_t *buffer);
1008 return this->value_;
1011 this->value_ = value;
1020 create_oxm_req(0, 0x86dd, 58, 136);
1025 virtual bool equals(
const OXMTLV & other);
1030 size_t pack(uint8_t *buffer);
1031 of_error unpack(uint8_t *buffer);
1033 return this->value_;
1036 this->value_ = value;
1045 create_oxm_req(0, 0x86dd, 58, 136);
1050 virtual bool equals(
const OXMTLV & other);
1055 size_t pack(uint8_t *buffer);
1056 of_error unpack(uint8_t *buffer);
1058 return this->value_;
1061 this->value_ = value;
1070 create_oxm_req(0x8847, 0x8848, 0, 0);
1075 virtual bool equals(
const OXMTLV & other);
1080 size_t pack(uint8_t *buffer);
1081 of_error unpack(uint8_t *buffer);
1083 return this->value_;
1085 void value(uint32_t value) {
1086 this->value_ = value;
1095 create_oxm_req(0x8847, 0x8848, 0, 0);
1100 virtual bool equals(
const OXMTLV & other);
1102 virtual MPLSTC* clone() {
1103 return new MPLSTC(*
this);
1105 size_t pack(uint8_t *buffer);
1106 of_error unpack(uint8_t *buffer);
1108 return this->value_;
1110 void value(uint8_t value) {
1111 this->value_ = value;
1120 create_oxm_req(0x8847, 0x8848, 0, 0);
1125 virtual bool equals(
const OXMTLV & other);
1130 size_t pack(uint8_t *buffer);
1131 of_error unpack(uint8_t *buffer);
1133 return this->value_;
1135 void value(uint8_t value) {
1136 this->value_ = value;
1146 create_oxm_req(0x88E7, 0, 0, 0);
1149 PBBIsid(uint32_t value, uint32_t mask);
1152 virtual bool equals(
const OXMTLV & other);
1157 size_t pack(uint8_t *buffer);
1158 of_error unpack(uint8_t *buffer);
1160 return this->value_;
1165 void value(uint32_t value) {
1166 this->value_ = value;
1168 void mask(uint32_t mask) {
1179 create_oxm_req(0, 0, 0, 0);
1182 TUNNELId(uint64_t value, uint64_t mask);
1185 virtual bool equals(
const OXMTLV & other);
1190 size_t pack(uint8_t *buffer);
1191 of_error unpack(uint8_t *buffer);
1193 return this->value_;
1195 void value(uint64_t value) {
1196 this->value_ = value;
1206 create_oxm_req(0, 0x86dd, 0, 0);
1212 virtual bool equals(
const OXMTLV & other);
1217 size_t pack(uint8_t *buffer);
1218 of_error unpack(uint8_t *buffer);
1220 return this->value_;
1225 void value(uint16_t value) {
1226 this->value_ = value;
1228 void mask(uint16_t mask) {
1236 std::vector<uint8_t> curr_tlvs_;
1238 std::vector<OXMTLV*> oxm_tlvs_;
1244 bool operator==(
const Match &other)
const;
1245 bool operator!=(
const Match &other)
const;
1247 size_t pack(uint8_t *buffer);
1248 of_error unpack(uint8_t *buffer);
1249 OXMTLV *oxm_field(uint8_t field);
1250 bool check_pre_req(
OXMTLV *tlv);
1251 bool check_dup(
OXMTLV *tlv);
1252 void add_oxm_field(
OXMTLV &tlv);
1253 void add_oxm_field(
OXMTLV* tlv);
1254 uint16_t oxm_fields_len();
1255 static OXMTLV * make_oxm_tlv(uint8_t field);