libfluid
The ONF OpenFlow driver
of10msg.hh
1 #ifndef OF10MSG_H
2 #define OF10MSG_H 1
3 
4 #include "fluid/ofcommon/msg.hh"
5 #include "of10/of10common.hh"
6 #include "of10/of10action.hh"
7 
11 namespace fluid_msg {
12 
16 namespace of10 {
17 
21 class Hello: public OFMsg {
22 public:
23  Hello();
24  Hello(uint32_t xid);
25  ~Hello() {
26  }
27  uint8_t* pack();
28  of_error unpack(uint8_t *buffer);
29 };
30 
34 class Error: public ErrorCommon {
35 public:
36  Error();
37  Error(uint32_t xid, uint16_t err_type, uint16_t code);
38  Error(uint32_t xid, uint16_t err_type, uint16_t code, uint8_t *data,
39  size_t data_len);
40  ~Error() {
41  }
42 };
43 
47 class EchoRequest: public EchoCommon {
48 public:
49  EchoRequest()
50  : EchoCommon(of10::OFP_VERSION, of10::OFPT_ECHO_REQUEST) {
51  }
52  EchoRequest(uint32_t xid);
53  ~EchoRequest() {
54  }
55 };
56 
60 class EchoReply: public EchoCommon {
61 public:
62  EchoReply()
63  : EchoCommon(of10::OFP_VERSION, of10::OFPT_ECHO_REPLY) {
64  }
65  EchoReply(uint32_t xid);
66  ~EchoReply() {
67  }
68 };
69 
74 class Vendor: public OFMsg {
75 protected:
76  uint32_t vendor_;
77 public:
78  Vendor();
79  Vendor(uint32_t xid, uint32_t vendor);
80  ~Vendor() {
81  }
82  uint8_t* pack();
83  of_error unpack(uint8_t *buffer);
84  uint32_t vendor() {
85  return this->vendor_;
86  }
87  void vendor(uint32_t vendor) {
88  this->vendor_ = vendor;
89  }
90 };
91 
95 class FeaturesRequest: public OFMsg {
96 public:
98  FeaturesRequest(uint32_t xid);
99  ~FeaturesRequest() {
100  }
101  uint8_t* pack();
102  of_error unpack(uint8_t *buffer);
103 };
104 
109 private:
110  uint32_t actions_;
111  std::vector<of10::Port> ports_;
112 public:
113  FeaturesReply();
114  FeaturesReply(uint32_t xid, uint64_t datapath_id, uint32_t n_buffers,
115  uint8_t n_tables, uint32_t capabilities, uint32_t actions);
116  FeaturesReply(uint32_t xid, uint64_t datapath_id, uint32_t n_buffers,
117  uint8_t n_tables, uint32_t capabilities, uint32_t actions,
118  std::vector<of10::Port> ports);
119  bool operator==(const FeaturesReply &other) const;
120  bool operator!=(const FeaturesReply &other) const;
121  ~FeaturesReply() {
122  }
123  uint8_t* pack();
124  of_error unpack(uint8_t *buffer);
125  uint32_t actions() {
126  return this->actions_;
127  }
128  std::vector<of10::Port> ports() {
129  return this->ports_;
130  }
131  void actions(uint32_t actions) {
132  this->actions_ = actions;
133  }
134  void ports(std::vector<of10::Port> ports);
135  size_t ports_length();
136  void add_port(of10::Port port);
137 };
138 
142 class GetConfigRequest: public OFMsg {
143 public:
145  GetConfigRequest(uint32_t xid);
146  ~GetConfigRequest() {
147  }
148  uint8_t* pack();
149  of_error unpack(uint8_t *buffer);
150 };
151 
156 public:
157  GetConfigReply();
158  GetConfigReply(uint32_t xid, uint16_t flags, uint16_t miss_send_len);
159  ~GetConfigReply() {
160  }
161 };
162 
167 public:
168  SetConfig();
169  SetConfig(uint32_t xid, uint16_t flags, uint16_t miss_send_len);
170  ~SetConfig() {
171  }
172 };
173 
177 class FlowMod: public FlowModCommon {
178 private:
179  uint16_t command_;
180  uint16_t out_port_;
181  of10::Match match_;
182  ActionList actions_;
183 public:
184  FlowMod();
185  FlowMod(uint32_t xid, uint64_t cookie, uint16_t command,
186  uint16_t idle_timeout, uint16_t hard_timeout, uint16_t priority,
187  uint32_t buffer_id, uint16_t out_port, uint16_t flags);
188  FlowMod(uint32_t xid, uint64_t cookie, uint16_t command,
189  uint16_t idle_timeout, uint16_t hard_timeout, uint16_t priority,
190  uint32_t buffer_id, uint16_t out_port, uint16_t flags,
191  of10::Match match);
192  FlowMod(uint32_t xid, uint64_t cookie, uint16_t command,
193  uint16_t idle_timeout, uint16_t hard_timeout, uint16_t priority,
194  uint32_t buffer_id, uint16_t out_port, uint16_t flags,
195  of10::Match match, ActionList actions);
196  ~FlowMod() {
197  }
198  bool operator==(const FlowMod &other) const;
199  bool operator!=(const FlowMod &other) const;
200  uint8_t* pack();
201  of_error unpack(uint8_t *buffer);
202  uint16_t command(){
203  return this->command_;
204  }
205  of10::Match match() {
206  return this->match_;
207  }
208  ActionList actions() {
209  return this->actions_;
210  }
211  uint16_t out_port() {
212  return this->out_port_;
213  }
214  void command(uint16_t command){
215  this->command_ = command;
216  }
217  void out_port(uint16_t out_port) {
218  this->out_port_ = out_port;
219  }
220  void match(const of10::Match& match) {
221  this->match_ = match;
222  }
223  void actions(const ActionList &actions);
224  void add_action(Action &action);
225  void add_action(Action* action);
226 };
227 
231 class PacketOut: public PacketOutCommon {
232 private:
233  uint16_t in_port_;
234 public:
235  PacketOut();
236  PacketOut(uint32_t xid, uint32_t buffer_id, uint16_t in_port);
237  ~PacketOut() {
238  }
239  bool operator==(const PacketOut &other) const;
240  bool operator!=(const PacketOut &other) const;
241  uint8_t* pack();
242  of_error unpack(uint8_t *buffer);
243  uint16_t in_port() {
244  return this->in_port_;
245  }
246  void in_port(uint16_t in_port) {
247  this->in_port_ = in_port;
248  }
249 };
250 
254 class PacketIn: public PacketInCommon {
255 private:
256  uint16_t in_port_;
257 public:
258  PacketIn();
259  PacketIn(uint32_t xid, uint32_t buffer_id, uint16_t in_port,
260  uint16_t total_len, uint8_t reason);
261  ~PacketIn() {
262  }
263  bool operator==(const PacketIn &other) const;
264  bool operator!=(const PacketIn &other) const;
265  uint8_t* pack();
266  of_error unpack(uint8_t *buffer);
267  uint16_t in_port() {
268  return this->in_port_;
269  }
270  void in_port(uint16_t in_port) {
271  this->in_port_ = in_port;
272  }
273 };
274 
279 private:
280  of10::Match match_;
281 public:
282  FlowRemoved();
283  FlowRemoved(uint32_t xid, uint64_t cookie, uint16_t priority,
284  uint8_t reason, uint32_t duration_sec, uint32_t duration_nsec,
285  uint16_t idle_timeout, uint64_t packet_count, uint64_t byte_count);
286  FlowRemoved(uint32_t xid, uint64_t cookie, uint16_t priority,
287  uint8_t reason, uint32_t duration_sec, uint32_t duration_nsec,
288  uint16_t idle_timeout, uint64_t packet_count, uint64_t byte_count,
289  of10::Match match);
290  ~FlowRemoved() {
291  }
292  bool operator==(const FlowRemoved &other) const;
293  bool operator!=(const FlowRemoved &other) const;
294  uint8_t* pack();
295  of_error unpack(uint8_t *buffer);
296  of10::Match match() {
297  return this->match_;
298  }
299  void match(of10::Match match) {
300  this->match_ = match;
301  }
302 };
303 
308 private:
309  of10::Port desc_;
310 public:
311  PortStatus();
312  PortStatus(uint32_t xid, uint8_t reason, of10::Port desc);
313  ~PortStatus() {
314  }
315  bool operator==(const PortStatus &other) const;
316  bool operator!=(const PortStatus &other) const;
317  uint8_t* pack();
318  of_error unpack(uint8_t *buffer);
319  of10::Port desc() {
320  return this->desc_;
321  }
322  void desc(of10::Port desc) {
323  this->desc_ = desc;
324  }
325 };
326 
330 class PortMod: public PortModCommon {
331 private:
332  uint16_t port_no_;
333 public:
334  PortMod();
335  PortMod(uint32_t xid, uint16_t port_no, EthAddress hw_addr, uint32_t config,
336  uint32_t mask, uint32_t advertise);
337  ~PortMod() {
338  }
339  bool operator==(const PortMod &other) const;
340  bool operator!=(const PortMod &other) const;
341  uint8_t* pack();
342  of_error unpack(uint8_t *buffer);
343  uint16_t port_no() {
344  return this->port_no_;
345  }
346  void port_no(uint16_t port_no) {
347  this->port_no_ = port_no;
348  }
349 };
350 
355 class StatsRequest: public OFMsg {
356 protected:
357  uint16_t stats_type_;
358  uint16_t flags_;
359 public:
360  StatsRequest();
361  StatsRequest(uint16_t);
362  StatsRequest(uint32_t xid, uint16_t type, uint16_t flags);
363  ~StatsRequest() {
364  }
365  bool operator==(const StatsRequest &other) const;
366  bool operator!=(const StatsRequest &other) const;
367  uint8_t* pack();
368  of_error unpack(uint8_t *buffer);
369  uint16_t stats_type() {
370  return this->stats_type_;
371  }
372  uint16_t flags() {
373  return this->flags_;
374  }
375  void stats_type(uint16_t type) {
376  this->stats_type_ = type;
377  }
378  void flags(uint16_t flags) {
379  this->flags_ = flags;
380  }
381 };
382 
387 class StatsReply: public OFMsg {
388 protected:
389  uint16_t stats_type_;
390  uint16_t flags_;
391 public:
392  StatsReply();
393  StatsReply(uint16_t type);
394  StatsReply(uint32_t xid, uint16_t type, uint16_t flags);
395  ~StatsReply() {
396  }
397  bool operator==(const StatsReply &other) const;
398  bool operator!=(const StatsReply &other) const;
399  uint8_t* pack();
400  of_error unpack(uint8_t *buffer);
401  uint16_t stats_type() {
402  return this->stats_type_;
403  }
404  uint16_t flags() {
405  return this->flags_;
406  }
407  void stats_type(uint16_t type) {
408  this->stats_type_ = type;
409  }
410  void flags(uint16_t flags) {
411  this->flags_ = flags;
412  }
413 };
414 
419 public:
421  StatsRequestDesc(uint32_t xid, uint16_t flags);
422  ~StatsRequestDesc() {
423  }
424  uint8_t* pack();
425  of_error unpack(uint8_t *buffer);
426 };
427 
431 class StatsReplyDesc: public StatsReply {
432 private:
433  SwitchDesc desc_;
434 public:
435  StatsReplyDesc();
436  StatsReplyDesc(uint32_t xid, uint16_t flags, SwitchDesc desc);
437  StatsReplyDesc(uint32_t xid, uint16_t flags, std::string mfr_desc,
438  std::string hw_desc, std::string sw_desc, std::string serial_num,
439  std::string dp_desc);
440  ~StatsReplyDesc() {
441  }
442  bool operator==(const StatsReplyDesc &other) const;
443  bool operator!=(const StatsReplyDesc &other) const;
444  uint8_t* pack();
445  of_error unpack(uint8_t *buffer);
446  SwitchDesc desc() {
447  return this->desc_;
448  }
449  void desc(SwitchDesc desc);
450 };
451 
456 private:
457  of10::Match match_;
458  uint8_t table_id_;
459  uint16_t out_port_;
460 public:
462  StatsRequestFlow(uint32_t xid, uint16_t flags, uint8_t table_id,
463  uint16_t out_port);
464  StatsRequestFlow(uint32_t xid, uint16_t flags, of10::Match match,
465  uint8_t table_id, uint16_t out_port);
466  virtual ~StatsRequestFlow() {
467  }
468  bool operator==(const StatsRequestFlow &other) const;
469  bool operator!=(const StatsRequestFlow &other) const;
470  uint8_t* pack();
471  of_error unpack(uint8_t *buffer);
472  of10::Match match() {
473  return this->match_;
474  }
475  uint8_t table_id() {
476  return this->table_id_;
477  }
478  uint16_t out_port() {
479  return this->out_port_;
480  }
481  void match(of10::Match match) {
482  this->match_ = match;
483  }
484  void table_id(uint8_t table_id) {
485  this->table_id_ = table_id;
486  }
487  void out_port(uint16_t out_port) {
488  this->out_port_ = out_port;
489  }
490 };
491 
495 class StatsReplyFlow: public StatsReply {
496 private:
497  std::vector<of10::FlowStats> flow_stats_;
498 public:
499  StatsReplyFlow();
500  StatsReplyFlow(uint32_t xid, uint16_t flags);
501  StatsReplyFlow(uint32_t xid, uint16_t flags,
502  std::vector<of10::FlowStats> flow_stats);
503  virtual ~StatsReplyFlow() {
504  }
505  bool operator==(const StatsReplyFlow &other) const;
506  bool operator!=(const StatsReplyFlow &other) const;
507  uint8_t* pack();
508  of_error unpack(uint8_t *buffer);
509  std::vector<of10::FlowStats> flow_stats() {
510  return this->flow_stats_;
511  }
512  void flow_stats(std::vector<of10::FlowStats> flow_stats);
513  void add_flow_stats(of10::FlowStats);
514 };
515 
520 private:
521  of10::Match match_;
522  uint8_t table_id_;
523  uint16_t out_port_;
524 public:
526  StatsRequestAggregate(uint32_t xid, uint16_t flags, uint8_t table_id,
527  uint16_t out_port);
528  StatsRequestAggregate(uint32_t xid, uint16_t flags, of10::Match match,
529  uint8_t table_id, uint16_t out_port);
531  }
532  bool operator==(const StatsRequestAggregate &other) const;
533  bool operator!=(const StatsRequestAggregate &other) const;
534  uint8_t* pack();
535  of_error unpack(uint8_t *buffer);
536  of10::Match match() {
537  return this->match_;
538  }
539  uint8_t table_id() {
540  return this->table_id_;
541  }
542  uint16_t out_port() {
543  return this->out_port_;
544  }
545  void match(of10::Match match) {
546  this->match_ = match;
547  }
548  void table_id(uint8_t table_id) {
549  this->table_id_ = table_id;
550  }
551  void out_port(uint16_t out_port) {
552  this->out_port_ = out_port;
553  }
554 };
555 
560 private:
561  uint64_t packet_count_;
562  uint64_t byte_count_;
563  uint32_t flow_count_;
564 public:
566  StatsReplyAggregate(uint32_t xid, uint16_t flags, uint64_t packet_count,
567  uint64_t byte_count, uint32_t flow_count);
569  }
570  bool operator==(const StatsReplyAggregate &other) const;
571  bool operator!=(const StatsReplyAggregate &other) const;
572  uint8_t* pack();
573  of_error unpack(uint8_t *buffer);
574  uint64_t packet_count() {
575  return this->packet_count_;
576  }
577  uint64_t byte_count() {
578  return this->byte_count_;
579  }
580  uint32_t flow_count() {
581  return this->flow_count_;
582  }
583  void packet_count(uint64_t packet_count) {
584  this->packet_count_ = packet_count;
585  }
586  void byte_count(uint64_t byte_count) {
587  this->byte_count_ = byte_count;
588  }
589  void flow_count(uint32_t flow_count) {
590  this->flow_count_ = flow_count;
591  }
592 };
593 
598 public:
600  StatsRequestTable(uint32_t xid, uint16_t flags);
601  ~StatsRequestTable() {
602  }
603  uint8_t* pack();
604  of_error unpack(uint8_t *buffer);
605 };
606 
611 private:
612  std::vector<of10::TableStats> table_stats_;
613 public:
614  StatsReplyTable();
615  StatsReplyTable(uint32_t xid, uint16_t flags);
616  StatsReplyTable(uint32_t xid, uint16_t flags,
617  std::vector<of10::TableStats> table_stats);
618  ~StatsReplyTable() {
619  }
620  bool operator==(const StatsReplyTable &other) const;
621  bool operator!=(const StatsReplyTable &other) const;
622  uint8_t* pack();
623  of_error unpack(uint8_t *buffer);
624  std::vector<of10::TableStats> table_stats() {
625  return this->table_stats_;
626  }
627  void table_stats(std::vector<of10::TableStats> table_stats);
628  void add_table_stat(of10::TableStats stat);
629 };
630 
635 private:
636  uint16_t port_no_;
637 public:
639  StatsRequestPort(uint32_t xid, uint16_t flags, uint16_t port_no);
640  ~StatsRequestPort() {
641  }
642  bool operator==(const StatsRequestPort &other) const;
643  bool operator!=(const StatsRequestPort &other) const;
644  uint8_t* pack();
645  of_error unpack(uint8_t *buffer);
646  uint16_t port_no() {
647  return this->port_no_;
648  }
649  void port_no(uint16_t port_no) {
650  this->port_no_ = port_no;
651  }
652 };
653 
657 class StatsReplyPort: public StatsReply {
658 private:
659  std::vector<PortStats> port_stats_;
660 public:
661  StatsReplyPort();
662  StatsReplyPort(uint32_t xid, uint16_t flags);
663  StatsReplyPort(uint32_t xid, uint16_t flags,
664  std::vector<of10::PortStats> port_stats);
665  ~StatsReplyPort() {
666  }
667  bool operator==(const StatsReplyPort &other) const;
668  bool operator!=(const StatsReplyPort &other) const;
669  uint8_t* pack();
670  of_error unpack(uint8_t *buffer);
671  std::vector<of10::PortStats> port_stats() {
672  return this->port_stats_;
673  }
674  void port_stats(std::vector<of10::PortStats> port_stats);
675  void add_port_stat(of10::PortStats stat);
676 };
677 
682 private:
683  uint16_t port_no_;
684  uint32_t queue_id_;
685 public:
687  StatsRequestQueue(uint32_t xid, uint16_t flags, uint16_t port_no,
688  uint32_t queue_id);
689  ~StatsRequestQueue() {
690  }
691  bool operator==(const StatsRequestQueue &other) const;
692  bool operator!=(const StatsRequestQueue &other) const;
693  uint8_t* pack();
694  of_error unpack(uint8_t *buffer);
695  uint16_t port_no() {
696  return this->port_no_;
697  }
698  uint32_t queue_id() {
699  return this->queue_id_;
700  }
701  void port_no(uint16_t port_no) {
702  this->port_no_ = port_no;
703  }
704  void queue_id(uint32_t queue_id) {
705  this->queue_id_ = queue_id;
706  }
707 };
708 
713 private:
714  std::vector<of10::QueueStats> queue_stats_;
715 public:
716  StatsReplyQueue();
717  StatsReplyQueue(uint32_t xid, uint16_t flags);
718  StatsReplyQueue(uint32_t xid, uint16_t flags,
719  std::vector<of10::QueueStats> queue_stats);
720  ~StatsReplyQueue() {
721  }
722  bool operator==(const StatsReplyQueue &other) const;
723  bool operator!=(const StatsReplyQueue &other) const;
724  uint8_t* pack();
725  of_error unpack(uint8_t *buffer);
726  std::vector<of10::QueueStats> queue_stats() {
727  return this->queue_stats_;
728  }
729  void queue_stats(std::vector<of10::QueueStats> queue_stats_);
730  void add_queue_stat(of10::QueueStats stat);
731 };
732 
738 protected:
739  uint32_t vendor_;
740 public:
742  StatsRequestVendor(uint32_t xid, uint16_t flags, uint32_t vendor);
743  virtual ~StatsRequestVendor() {
744  }
745  bool operator==(const StatsRequestVendor &other) const;
746  bool operator!=(const StatsRequestVendor &other) const;
747  uint8_t* pack();
748  of_error unpack(uint8_t *buffer);
749  uint32_t vendor() {
750  return this->vendor_;
751  }
752  void vendor(uint32_t vendor) {
753  this->vendor_ = vendor;
754  }
755 };
756 
762 protected:
763  uint32_t vendor_;
764 public:
766  StatsReplyVendor(uint32_t xid, uint16_t flags, uint32_t vendor);
767  virtual ~StatsReplyVendor() {
768  }
769  bool operator==(const StatsReplyVendor &other) const;
770  bool operator!=(const StatsReplyVendor &other) const;
771  uint8_t* pack();
772  of_error unpack(uint8_t *buffer);
773  uint32_t vendor() {
774  return this->vendor_;
775  }
776  void vendor(uint32_t vendor) {
777  this->vendor_ = vendor;
778  }
779 };
780 
785 private:
786  uint16_t port_;
787 public:
789  QueueGetConfigRequest(uint32_t xid, uint16_t port);
791  }
792  bool operator==(const QueueGetConfigRequest &other) const;
793  bool operator!=(const QueueGetConfigRequest &other) const;
794  uint8_t* pack();
795  of_error unpack(uint8_t *buffer);
796  uint16_t port() {
797  return this->port_;
798  }
799  void port(uint16_t port) {
800  this->port_ = port;
801  }
802 };
803 
807 class QueueGetConfigReply: public OFMsg {
808 private:
809  uint16_t port_;
810  std::list<of10::PacketQueue> queues_;
811 public:
813  QueueGetConfigReply(uint32_t xid, uint16_t port);
814  QueueGetConfigReply(uint32_t xid, uint16_t port,
815  std::list<of10::PacketQueue> queues);
817  }
818  bool operator==(const QueueGetConfigReply &other) const;
819  bool operator!=(const QueueGetConfigReply &other) const;
820  uint8_t* pack();
821  of_error unpack(uint8_t *buffer);
822  uint16_t port() {
823  return this->port_;
824  }
825  std::list<of10::PacketQueue> queues() {
826  return this->queues_;
827  }
828  void port(uint32_t port) {
829  this->port_ = port;
830  }
831  void queues(std::list<PacketQueue> queues);
832  void add_queue(PacketQueue queue);
833  size_t queues_len();
834 };
835 
839 class BarrierRequest: public OFMsg {
840 public:
841  BarrierRequest();
842  BarrierRequest(uint32_t xid);
843  ~BarrierRequest() {
844  }
845  uint8_t* pack();
846  of_error unpack(uint8_t* buffer);
847 };
848 
851 class BarrierReply: public OFMsg {
852 public:
853  BarrierReply();
854  BarrierReply(uint32_t xid);
855  ~BarrierReply() {
856  }
857  uint8_t* pack();
858  of_error unpack(uint8_t* buffer);
859 };
860 
861 } //end of namespace of10
862 } //End of namespace fluid_msg
863 
864 #endif
865