15 #include "../endian_conversion.h"
18 #include "rofl/common/openflow/openflow_common.h"
19 #include "rofl/common/openflow/openflow.h"
20 #include "rofl/common/cmemory.h"
21 #include "rofl/common/croflexception.h"
22 #include "rofl/common/caddress.h"
23 #include "rofl/common/openflow/openflow_rofl_exceptions.h"
24 #include "rofl/common/openflow/cofportstats.h"
28 #ifndef OFPP_UNSPECIFIED
29 #define OFPP_UNSPECIFIED 0
68 #define ofh_port ofp_ofpu.ofpu_port
69 #define ofh10_port ofp_ofpu.ofpu10_port
70 #define ofh12_port ofp_ofpu.ofpu12_port
71 #define ofh13_port ofp_ofpu.ofpu13_port
84 uint8_t of_version = openflow::OFP_VERSION_UNKNOWN);
91 uint8_t ofp_version, uint8_t *buf,
size_t buflen);
122 uint8_t *buf,
size_t buflen);
131 uint8_t *buf,
size_t buflen);
166 set_port_no(uint32_t port_no);
190 set_name(std::string name);
201 set_config(uint32_t config);
212 set_state(uint32_t state);
224 set_curr(uint32_t curr);
230 get_advertised()
const;
236 set_advertised(uint32_t advertised);
242 get_supported()
const;
248 set_supported(uint32_t supported);
260 set_peer(uint32_t peer);
266 get_curr_speed()
const;
272 set_curr_speed(uint32_t curr_speed);
278 get_max_speed()
const;
284 set_max_speed(uint32_t max_speed);
291 link_state_set_blocked();
298 link_state_clr_blocked();
305 link_state_is_blocked()
const;
312 link_state_set_live();
319 link_state_clr_live();
326 link_state_is_live()
const;
333 link_state_set_link_down();
340 link_state_clr_link_down();
347 link_state_is_link_down()
const;
354 link_state_phy_down();
368 link_state_phy_is_up()
const;
375 config_is_port_down()
const;
432 operator<< (std::ostream& os,
cofport const& port) {
433 switch (port.ofp_version) {
434 case openflow10::OFP_VERSION: {
435 os <<
indent(0) <<
"<cofport >" << std::endl;
436 os <<
indent(2) <<
"<portno:" << (int)port.get_port_no() <<
" >" << std::endl;
437 os <<
indent(2) <<
"<hwaddr: >" << std::endl;
439 os <<
indent(2) <<
"<name:" << port.get_name() <<
" >" << std::endl;
440 os <<
indent(2) <<
"<config:" << (int)port.get_config() <<
" >" << std::endl;
441 os <<
indent(2) <<
"<state:" << (int)port.get_state() <<
" >" << std::endl;
442 os <<
indent(2) <<
"<curr:" << (int)port.get_curr() <<
" >" << std::endl;
443 os <<
indent(2) <<
"<advertised:" << (int)port.get_advertised() <<
" >" << std::endl;
444 os <<
indent(2) <<
"<supported:" << (int)port.get_supported() <<
" >" << std::endl;
445 os <<
indent(2) <<
"<peer:" << (int)port.get_peer() <<
" >" << std::endl;
447 case openflow12::OFP_VERSION: {
448 os <<
indent(0) <<
"<cofport >" << std::endl;
449 os <<
indent(2) <<
"<portno:" << (int)port.get_port_no() <<
" >" << std::endl;
450 os <<
indent(2) <<
"<hwaddr: >" << std::endl;
452 os <<
indent(2) <<
"<name:" << port.get_name() <<
" >" << std::endl;
453 os <<
indent(2) <<
"<config:" << (int)port.get_config() <<
" >" << std::endl;
454 os <<
indent(2) <<
"<state:" << (int)port.get_state() <<
" >" << std::endl;
455 os <<
indent(2) <<
"<curr:" << (int)port.get_curr() <<
" >" << std::endl;
456 os <<
indent(2) <<
"<advertised:" << (int)port.get_advertised() <<
" >" << std::endl;
457 os <<
indent(2) <<
"<supported:" << (int)port.get_supported() <<
" >" << std::endl;
458 os <<
indent(2) <<
"<peer:" << (int)port.get_peer() <<
" >" << std::endl;
459 os <<
indent(2) <<
"<curr-speed:" << (int)port.get_curr_speed() <<
" >" << std::endl;
460 os <<
indent(2) <<
"<max-speed:" << (int)port.get_max_speed() <<
" >" << std::endl;
461 os <<
indent(2) <<
"<state-blocked:" << (int)port.link_state_is_blocked() <<
" >" << std::endl;
462 os <<
indent(2) <<
"<state-live:" << (int)port.link_state_is_live() <<
" >" << std::endl;
463 os <<
indent(2) <<
"<state-link-down:" << (int)port.link_state_is_link_down() <<
" >" << std::endl;
464 os <<
indent(2) <<
"<config-port-down:" << (int)port.config_is_port_down() <<
" >" << std::endl;
466 case openflow13::OFP_VERSION: {
467 os <<
indent(0) <<
"<cofport >" << std::endl;
468 os <<
indent(2) <<
"<portno:" << (int)port.get_port_no() <<
" >" << std::endl;
469 os <<
indent(2) <<
"<hwaddr: >" << std::endl;
471 os <<
indent(2) <<
"<name:" << port.get_name() <<
" >" << std::endl;
472 os <<
indent(2) <<
"<config:" << (int)port.get_config() <<
" >" << std::endl;
473 os <<
indent(2) <<
"<state:" << (int)port.get_state() <<
" >" << std::endl;
474 os <<
indent(2) <<
"<curr:" << (int)port.get_curr() <<
" >" << std::endl;
475 os <<
indent(2) <<
"<advertised:" << (int)port.get_advertised() <<
" >" << std::endl;
476 os <<
indent(2) <<
"<supported:" << (int)port.get_supported() <<
" >" << std::endl;
477 os <<
indent(2) <<
"<peer:" << (int)port.get_peer() <<
" >" << std::endl;
478 os <<
indent(2) <<
"<curr-speed:" << (int)port.get_curr_speed() <<
" >" << std::endl;
479 os <<
indent(2) <<
"<max-speed:" << (int)port.get_max_speed() <<
" >" << std::endl;
480 os <<
indent(2) <<
"<state-blocked:" << (int)port.link_state_is_blocked() <<
" >" << std::endl;
481 os <<
indent(2) <<
"<state-live:" << (int)port.link_state_is_live() <<
" >" << std::endl;
482 os <<
indent(2) <<
"<state-link-down:" << (int)port.link_state_is_link_down() <<
" >" << std::endl;
483 os <<
indent(2) <<
"<config-port-down:" << (int)port.config_is_port_down() <<
" >" << std::endl;
486 os <<
"<cofport unknown OFP version>" << std::endl;
498 port_no(_port_no) {};
499 bool operator() (
cofport *ofport) {
500 return (ofport->get_port_no() == port_no);
502 bool operator() (std::pair<uint32_t, cofport*>
const& p) {
503 return (p.second->get_port_no() == port_no);
509 std::string port_name;
512 port_name(_port_name) {};
513 bool operator() (
cofport *ofport) {
514 std::string name(ofport->get_name());
515 return (name == port_name);
517 bool operator() (std::pair<uint32_t, cofport*>
const& p) {
518 std::string name(p.second->get_name());
519 return (name == port_name);
530 bool operator() (
cofport *ofport) {
531 cmacaddr hwaddr(ofport->get_hwaddr());
532 return (maddr == hwaddr);
534 bool operator() (std::pair<uint32_t, cofport*>
const& p) {
535 cmacaddr hwaddr(p.second->get_hwaddr());
536 return (maddr == hwaddr);
545 bool operator() (
cofport const& ofport) {
546 return (ofport.get_port_no() == port_no);
Definition: caddress.h:152
Definition: cofport.h:525
Definition: openflow12.h:288
Definition: cofport.h:508
Definition: openflow10.h:243
void pack(uint8_t *buf, size_t buflen)
Copies content of this cmemory instance to specified buffer.
Definition: cofport.cc:103
void unpack(uint8_t *buf, size_t buflen)
Copies content of specified buffer into this cmemory instance .
Definition: cofport.cc:115
C++ abstraction for malloc'ed memory areas.
Definition: cmemory.h:44
Definition: cofportstats.h:125
Definition: openflow13.h:116
Definition: cofport.h:541
Definition: cofport.h:494
Definition: croflexception.h:27