30 min_body = max_body =
sizeof(ofp_flow_stats_request);
33 min_body = max_body =
sizeof(ofp_aggregate_stats_request);
40 std::numeric_limits<size_t>::max();
43 case OFPST_PORT_TABLE:
50 if ((min_body != 0 || max_body != 0) && (body_len < min_body || body_len > max_body))
52 NS_LOG_ERROR(
"stats request type " <<
type <<
" with bad body length " << body_len);
72 case OFPST_PORT_TABLE:
96 case OFPST_PORT_TABLE:
115 case OFPST_AGGREGATE:
116 free((ofp_aggregate_stats_request*)state);
124 case OFPST_PORT_TABLE:
134 ofp_desc_stats* ods = (ofp_desc_stats*)ofpbuf_put_zeros(buffer,
sizeof *ods);
135 strncpy(ods->mfr_desc,
137 sizeof ods->mfr_desc);
144#define MAX_FLOW_STATS_BYTES 4096
149 const ofp_flow_stats_request* fsr = (ofp_flow_stats_request*)body;
152 s->table_idx = fsr->table_id == 0xff ? 0 : fsr->table_id;
153 memset(&s->position, 0,
sizeof s->position);
166 int length =
sizeof *ofs + flow->sf_acts->actions_len;
167 ofs = (ofp_flow_stats*)ofpbuf_put_zeros(s->buffer, length);
168 ofs->length = htons(length);
169 ofs->table_id = s->table_idx;
170 ofs->match.wildcards = htonl(flow->key.wildcards);
171 ofs->match.in_port = flow->key.flow.in_port;
172 memcpy(ofs->match.dl_src, flow->key.flow.dl_src, ETH_ADDR_LEN);
173 memcpy(ofs->match.dl_dst, flow->key.flow.dl_dst, ETH_ADDR_LEN);
174 ofs->match.dl_vlan = flow->key.flow.dl_vlan;
175 ofs->match.dl_type = flow->key.flow.dl_type;
176 ofs->match.nw_src = flow->key.flow.nw_src;
177 ofs->match.nw_dst = flow->key.flow.nw_dst;
178 ofs->match.nw_proto = flow->key.flow.nw_proto;
179 ofs->match.tp_src = flow->key.flow.tp_src;
180 ofs->match.tp_dst = flow->key.flow.tp_dst;
181 ofs->duration = htonl(s->now - flow->created);
182 ofs->priority = htons(flow->priority);
183 ofs->idle_timeout = htons(flow->idle_timeout);
184 ofs->hard_timeout = htons(flow->hard_timeout);
185 ofs->packet_count = htonll(flow->packet_count);
186 ofs->byte_count = htonll(flow->byte_count);
187 memcpy(ofs->actions, flow->sf_acts->actions, flow->sf_acts->actions_len);
195 sw_flow_key match_key;
197 flow_extract_match(&match_key, &s->
rq.match);
201 while (s->
table_idx < swtch->GetChain()->n_tables &&
204 sw_table* table = swtch->GetChain()->tables[s->
table_idx];
206 if (table->iterate(table,
226 *state = (ofp_aggregate_stats_request*)body;
233 ofp_aggregate_stats_reply* s = (ofp_aggregate_stats_reply*)state;
234 s->packet_count += flow->packet_count;
235 s->byte_count += flow->byte_count;
242 ofp_aggregate_stats_request* s,
245 ofp_aggregate_stats_request* rq = s;
246 ofp_aggregate_stats_reply* rpy =
247 (ofp_aggregate_stats_reply*)ofpbuf_put_zeros(buffer,
sizeof *rpy);
248 sw_flow_key match_key;
249 flow_extract_match(&match_key, &rq->match);
250 int table_idx = rq->table_id == 0xff ? 0 : rq->table_id;
252 sw_table_position position;
253 memset(&position, 0,
sizeof position);
255 while (table_idx < swtch->GetChain()->n_tables &&
256 (rq->table_id == 0xff || rq->table_id == table_idx))
258 sw_table* table = swtch->GetChain()->tables[table_idx];
259 int error = table->iterate(table,
271 memset(&position, 0,
sizeof position);
274 rpy->packet_count = htonll(rpy->packet_count);
275 rpy->byte_count = htonll(rpy->byte_count);
276 rpy->flow_count = htonl(rpy->flow_count);
283 sw_chain* ft = swtch->GetChain();
284 for (
int i = 0; i < ft->n_tables; i++)
286 ofp_table_stats* ots = (ofp_table_stats*)ofpbuf_put_zeros(buffer,
sizeof *ots);
287 sw_table_stats stats;
288 ft->tables[i]->stats(ft->tables[i], &stats);
289 strncpy(ots->name, stats.name,
sizeof ots->name);
291 ots->wildcards = htonl(stats.wildcards);
292 ots->max_entries = htonl(stats.max_flows);
293 ots->active_count = htonl(stats.n_flows);
294 ots->lookup_count = htonll(stats.n_lookup);
295 ots->matched_count = htonll(stats.n_matched);
304 ofp_vport_table_stats* opts = (ofp_vport_table_stats*)ofpbuf_put_zeros(buffer,
sizeof *opts);
305 opts->max_vports = htonl(swtch->GetVPortTable().max_vports);
306 opts->active_vports = htonl(swtch->GetVPortTable().active_vports);
307 opts->lookup_count = htonll(swtch->GetVPortTable().lookup_count);
308 opts->port_match_count = htonll(swtch->GetVPortTable().port_match_count);
309 opts->chain_match_count = htonll(swtch->GetVPortTable().chain_match_count);
320 s->ports = (
uint32_t*)xmalloc(body_len);
321 memcpy(s->ports, body, body_len);
322 s->num_ports = body_len /
sizeof(
uint32_t);
335 for (
size_t i = 0; i < s->
num_ports; i++)
339 if (
port <= OFPP_MAX)
341 Port p = swtch->GetSwitchPort(
port);
348 ops = (ofp_port_stats*)ofpbuf_put_zeros(buffer,
sizeof *ops);
349 ops->port_no = htonl(swtch->GetSwitchPortIndex(p));
354 ops->rx_dropped = htonll(-1);
356 ops->rx_errors = htonll(-1);
357 ops->tx_errors = htonll(-1);
358 ops->rx_frame_err = htonll(-1);
359 ops->rx_over_err = htonll(-1);
360 ops->rx_crc_err = htonll(-1);
361 ops->collisions = htonll(-1);
365 else if (
port >= OFPP_VP_START &&
port <= OFPP_VP_END)
368 vport_table_t vt = swtch->GetVPortTable();
369 vport_table_entry* vpe = vport_table_lookup(&vt,
port);
376 ops = (ofp_port_stats*)ofpbuf_put_zeros(buffer,
sizeof *ops);
377 ops->port_no = htonl(vpe->vport);
378 ops->rx_packets = htonll(-1);
379 ops->tx_packets = htonll(vpe->packet_count);
380 ops->rx_bytes = htonll(-1);
381 ops->tx_bytes = htonll(vpe->byte_count);
382 ops->rx_dropped = htonll(-1);
383 ops->tx_dropped = htonll(-1);
384 ops->rx_errors = htonll(-1);
385 ops->tx_errors = htonll(-1);
386 ops->rx_frame_err = htonll(-1);
387 ops->rx_over_err = htonll(-1);
388 ops->rx_crc_err = htonll(-1);
389 ops->collisions = htonll(-1);
390 ops->mpls_ttl0_dropped = htonll(-1);
403 case OFPAT_SET_VLAN_VID:
404 case OFPAT_SET_VLAN_PCP:
405 case OFPAT_STRIP_VLAN:
406 case OFPAT_SET_DL_SRC:
407 case OFPAT_SET_DL_DST:
408 case OFPAT_SET_NW_SRC:
409 case OFPAT_SET_NW_DST:
410 case OFPAT_SET_TP_SRC:
411 case OFPAT_SET_TP_DST:
412 case OFPAT_SET_MPLS_LABEL:
413 case OFPAT_SET_MPLS_EXP:
423 const sw_flow_key* key,
424 const ofp_action_header* ah)
431 if (len !=
sizeof(ofp_action_output))
433 return OFPBAC_BAD_LEN;
436 ofp_action_output* oa = (ofp_action_output*)ah;
441 if (oa->port == OFPP_NONE || oa->port == key->flow.in_port)
443 return OFPBAC_BAD_OUT_PORT;
446 return ACT_VALIDATION_OK;
448 case OFPAT_SET_VLAN_VID:
449 size =
sizeof(ofp_action_vlan_vid);
451 case OFPAT_SET_VLAN_PCP:
452 size =
sizeof(ofp_action_vlan_pcp);
454 case OFPAT_STRIP_VLAN:
455 size =
sizeof(ofp_action_header);
457 case OFPAT_SET_DL_SRC:
458 case OFPAT_SET_DL_DST:
459 size =
sizeof(ofp_action_dl_addr);
461 case OFPAT_SET_NW_SRC:
462 case OFPAT_SET_NW_DST:
463 size =
sizeof(ofp_action_nw_addr);
465 case OFPAT_SET_TP_SRC:
466 case OFPAT_SET_TP_DST:
467 size =
sizeof(ofp_action_tp_port);
469 case OFPAT_SET_MPLS_LABEL:
470 size =
sizeof(ofp_action_mpls_label);
472 case OFPAT_SET_MPLS_EXP:
473 size =
sizeof(ofp_action_mpls_exp);
481 return OFPBAC_BAD_LEN;
483 return ACT_VALIDATION_OK;
487Action::Execute(ofp_action_type type, ofpbuf* buffer, sw_flow_key* key,
const ofp_action_header* ah)
493 case OFPAT_SET_VLAN_VID:
496 case OFPAT_SET_VLAN_PCP:
499 case OFPAT_STRIP_VLAN:
502 case OFPAT_SET_DL_SRC:
503 case OFPAT_SET_DL_DST:
506 case OFPAT_SET_NW_SRC:
507 case OFPAT_SET_NW_DST:
510 case OFPAT_SET_TP_SRC:
511 case OFPAT_SET_TP_DST:
514 case OFPAT_SET_MPLS_LABEL:
517 case OFPAT_SET_MPLS_EXP:
530 case OFPPAT_POP_MPLS:
531 case OFPPAT_PUSH_MPLS:
532 case OFPPAT_SET_MPLS_LABEL:
533 case OFPPAT_SET_MPLS_EXP:
547 case OFPPAT_POP_MPLS:
548 size =
sizeof(ofp_vport_action_pop_mpls);
550 case OFPPAT_PUSH_MPLS:
551 size =
sizeof(ofp_vport_action_push_mpls);
553 case OFPPAT_SET_MPLS_LABEL:
554 size =
sizeof(ofp_vport_action_set_mpls_label);
556 case OFPPAT_SET_MPLS_EXP:
557 size =
sizeof(ofp_vport_action_set_mpls_exp);
565 return OFPBAC_BAD_LEN;
567 return ACT_VALIDATION_OK;
573 const sw_flow_key* key,
574 const ofp_action_header* ah)
578 case OFPPAT_POP_MPLS: {
579 ofp_vport_action_pop_mpls* opapm = (ofp_vport_action_pop_mpls*)ah;
580 pop_mpls_act(
nullptr, buffer, key, &opapm->apm);
583 case OFPPAT_PUSH_MPLS: {
584 ofp_vport_action_push_mpls* opapm = (ofp_vport_action_push_mpls*)ah;
585 push_mpls_act(
nullptr, buffer, key, &opapm->apm);
588 case OFPPAT_SET_MPLS_LABEL: {
589 ofp_vport_action_set_mpls_label* oparml = (ofp_vport_action_set_mpls_label*)ah;
590 set_mpls_label_act(buffer, key, oparml->label_out);
593 case OFPPAT_SET_MPLS_EXP: {
594 ofp_vport_action_set_mpls_exp* oparme = (ofp_vport_action_set_mpls_exp*)ah;
595 set_mpls_exp_act(buffer, key, oparme->exp);
624 size =
sizeof(er_action_pop_mpls);
627 size =
sizeof(er_action_push_mpls);
635 return OFPBAC_BAD_LEN;
637 return ACT_VALIDATION_OK;
643 const sw_flow_key* key,
644 const er_action_header* ah)
648 case ERXT_POP_MPLS: {
649 er_action_pop_mpls* erapm = (er_action_pop_mpls*)ah;
650 pop_mpls_act(
nullptr, buffer, key, &erapm->apm);
653 case ERXT_PUSH_MPLS: {
654 er_action_push_mpls* erapm = (er_action_push_mpls*)ah;
655 push_mpls_act(
nullptr, buffer, key, &erapm->apm);
669 .SetGroupName(
"OpenFlow")
684 NS_LOG_INFO(
"This Controller has already registered this switch!");
697 NS_LOG_ERROR(
"Can't send to this switch, not registered to the Controller.");
701 swtch->ForwardControlInput(msg, length);
713 ofp_flow_mod* ofm = (ofp_flow_mod*)malloc(
sizeof(ofp_flow_mod) + actions_len);
714 ofm->header.version = OFP_VERSION;
715 ofm->header.type = OFPT_FLOW_MOD;
716 ofm->header.length = htons(
sizeof(ofp_flow_mod) + actions_len);
717 ofm->command = htons(command);
718 ofm->idle_timeout = htons(idle_timeout);
719 ofm->hard_timeout = htons(hard_timeout);
720 ofm->buffer_id = htonl(buffer_id);
721 ofm->priority = OFP_DEFAULT_PRIORITY;
722 memcpy(ofm->actions, acts, actions_len);
724 ofm->match.wildcards = key.wildcards;
725 ofm->match.in_port = key.flow.in_port;
726 memcpy(ofm->match.dl_src,
728 sizeof ofm->match.dl_src);
729 memcpy(ofm->match.dl_dst,
731 sizeof ofm->match.dl_dst);
732 ofm->match.dl_vlan = key.flow.dl_vlan;
733 ofm->match.dl_type = key.flow.dl_type;
734 ofm->match.nw_proto = key.flow.nw_proto;
735 ofm->match.nw_src = key.flow.nw_src;
736 ofm->match.nw_dst = key.flow.nw_dst;
737 ofm->match.tp_src = key.flow.tp_src;
738 ofm->match.tp_dst = key.flow.tp_dst;
739 ofm->match.mpls_label1 = key.flow.mpls_label1;
740 ofm->match.mpls_label2 =
741 key.flow.mpls_label1;
749 ofp_header* hdr = (ofp_header*)ofpbuf_try_pull(buffer,
sizeof(ofp_header));
750 uint8_t type = hdr->type;
751 ofpbuf_push_uninit(buffer,
sizeof(ofp_header));
768 NS_LOG_WARN(
"Dump Callback Error: " << strerror(-error));
782 .SetGroupName(
"OpenFlow")
792 NS_LOG_ERROR(
"Can't receive from this switch, not registered to the Controller.");
800 if (type == OFPT_PACKET_IN)
803 ofp_packet_in* opi = (ofp_packet_in*)ofpbuf_try_pull(buffer, offsetof(ofp_packet_in,
data));
804 int port = ntohs(opi->in_port);
809 flow_extract(buffer,
port != -1 ?
port : OFPP_NONE, &key.flow);
826 TypeId(
"ns3::ofi::LearningController")
828 .SetGroupName(
"Openflow")
830 .AddAttribute(
"ExpirationTime",
831 "Time it takes for learned MAC state entry/created flow to expire.",
843 NS_LOG_ERROR(
"Can't receive from this switch, not registered to the Controller.");
851 if (type == OFPT_PACKET_IN)
854 ofp_packet_in* opi = (ofp_packet_in*)ofpbuf_try_pull(buffer, offsetof(ofp_packet_in,
data));
855 int port = ntohs(opi->in_port);
860 flow_extract(buffer,
port != -1 ?
port : OFPP_NONE, &key.flow);
862 uint16_t out_port = OFPP_FLOOD;
863 uint16_t in_port = ntohs(key.flow.in_port);
873 out_port = st->second.port;
877 NS_LOG_INFO(
"Setting to flood; don't know yet what port " << dst_addr
878 <<
" is connected to");
883 NS_LOG_INFO(
"Setting to flood; this packet is a broadcast");
887 ofp_action_output x[1];
888 x[0].type = htons(OFPAT_OUTPUT);
889 x[0].len = htons(
sizeof(ofp_action_output));
890 x[0].port = out_port;
913 NS_LOG_INFO(
"Learned that " << src_addr <<
" can be found over port " << in_port);
916 ofp_action_output x2[1];
917 x2[0].type = htons(OFPAT_OUTPUT);
918 x2[0].len = htons(
sizeof(ofp_action_output));
919 x2[0].port = in_port;
922 src_addr.
CopyTo(key.flow.dl_dst);
923 dst_addr.
CopyTo(key.flow.dl_src);
924 key.flow.in_port = out_port;
943 const ofp_action_header* actions,
954 uint16_t in_port = key->flow.in_port;
955 auto p = (uint8_t*)actions;
959 if (actions_len == 0)
961 NS_LOG_INFO(
"No actions set to this flow. Dropping packet.");
967 while (actions_len > 0)
969 ofp_action_header* ah = (ofp_action_header*)p;
970 size_t len = htons(ah->len);
974 swtch->DoOutput(packet_uid, in_port, max_len, prev_port, ignore_no_fwd);
978 if (ah->type == htons(OFPAT_OUTPUT))
980 ofp_action_output* oa = (ofp_action_output*)p;
983 prev_port = oa->port;
985 max_len = ntohs(oa->max_len);
989 uint16_t type = ntohs(ah->type);
991 (ofp_action_type)type))
995 else if (type == OFPAT_VENDOR)
1005 if (prev_port != -1)
1007 swtch->DoOutput(packet_uid, in_port, max_len, prev_port, ignore_no_fwd);
1012ValidateActions(
const sw_flow_key* key,
const ofp_action_header* actions,
size_t actions_len)
1014 auto p = (uint8_t*)actions;
1017 while (actions_len >=
sizeof(ofp_action_header))
1019 ofp_action_header* ah = (ofp_action_header*)p;
1020 size_t len = ntohs(ah->len);
1025 if ((actions_len < len) || (len % 8) != 0)
1027 return OFPBAC_BAD_LEN;
1030 type = ntohs(ah->type);
1034 if (err != ACT_VALIDATION_OK)
1039 else if (type == OFPAT_VENDOR)
1042 if (err != ACT_VALIDATION_OK)
1049 return OFPBAC_BAD_TYPE;
1057 if (actions_len != 0)
1059 return OFPBAC_BAD_LEN;
1062 return ACT_VALIDATION_OK;
1067 uint64_t packet_uid,
1070 const ofp_action_header* actions,
1079 uint16_t in_port = ntohs(key->flow.in_port);
1080 auto p = (uint8_t*)actions;
1082 ofp_action_output* oa;
1087 while (actions_len > 0)
1089 ofp_action_header* ah = (ofp_action_header*)p;
1090 size_t len = htons(ah->len);
1091 if (prev_port != -1)
1093 swtch->DoOutput(packet_uid, in_port, max_len, prev_port,
false);
1097 if (ah->type == htons(OFPAT_OUTPUT))
1099 oa = (ofp_action_output*)p;
1100 prev_port = ntohl(oa->port);
1101 max_len = ntohs(oa->max_len);
1113 if (prev_port != -1)
1115 swtch->DoOutput(packet_uid, in_port, max_len, prev_port,
false);
1122 auto p = (uint8_t*)actions;
1125 while (actions_len >=
sizeof(ofp_action_header))
1127 ofp_action_header* ah = (ofp_action_header*)p;
1128 size_t len = ntohs(ah->len);
1133 if ((actions_len < len) || (len % 8) != 0)
1135 return OFPBAC_BAD_LEN;
1138 type = ntohs(ah->type);
1140 (ofp_vport_action_type)type))
1143 if (err != ACT_VALIDATION_OK)
1150 return OFPBAC_BAD_TYPE;
1158 if (actions_len != 0)
1160 return OFPBAC_BAD_LEN;
1163 return ACT_VALIDATION_OK;
1167ExecuteVendor(ofpbuf* buffer,
const sw_flow_key* key,
const ofp_action_header* ah)
1169 ofp_action_vendor_header* avh = (ofp_action_vendor_header*)ah;
1171 switch (ntohl(avh->vendor))
1176 case ER_VENDOR_ID: {
1177 const er_action_header* erah = (
const er_action_header*)avh;
1183 NS_LOG_INFO(
"attempt to execute action with unknown vendor: " << ntohl(avh->vendor));
1191 ofp_action_vendor_header* avh;
1192 int ret = ACT_VALIDATION_OK;
1194 if (len <
sizeof(ofp_action_vendor_header))
1196 return OFPBAC_BAD_LEN;
1199 avh = (ofp_action_vendor_header*)ah;
1201 switch (ntohl(avh->vendor))
1204 ret = OFPBAC_BAD_VENDOR_TYPE;
1208 const er_action_header* erah = (
const er_action_header*)avh;
1213 return OFPBAC_BAD_VENDOR;
void CopyFrom(const uint8_t buffer[6])
void CopyTo(uint8_t buffer[6]) const
A base class which provides memory management and object aggregation.
static const char * GetManufacturerDescription()
void StatsDone(ofi::StatsDumpCallback *cb_)
Stats callback is done.
int StatsDump(ofi::StatsDumpCallback *cb_)
Stats callback is ready for a dump.
static const char * GetSoftwareDescription()
static const char * GetHardwareDescription()
static const char * GetSerialNumber()
Smart pointer class similar to boost::intrusive_ptr.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
bool IsZero() const
Exactly equivalent to t == 0.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
An interface for a Controller of OpenFlowSwitchNetDevices.
virtual void SendToSwitch(Ptr< OpenFlowSwitchNetDevice > swtch, void *msg, size_t length)
However the controller is implemented, this method is to be used to pass a message on to a switch.
uint8_t GetPacketType(ofpbuf *buffer)
Get the packet type on the buffer, which can then be used to determine how to handle the buffer.
Switches_t m_switches
The collection of switches registered to this controller.
~Controller() override
Destructor.
static TypeId GetTypeId()
Register this type.
ofp_flow_mod * BuildFlow(sw_flow_key key, uint32_t buffer_id, uint16_t command, void *acts, size_t actions_len, int idle_timeout, int hard_timeout)
Construct flow data from a matching key to build a flow entry for adding, modifying,...
void StartDump(StatsDumpCallback *cb)
Starts a callback-based, reliable, possibly multi-message reply to a request made by the controller.
virtual void AddSwitch(Ptr< OpenFlowSwitchNetDevice > swtch)
Adds a switch to the controller.
Demonstration of a Drop controller.
void ReceiveFromSwitch(Ptr< OpenFlowSwitchNetDevice > swtch, ofpbuf *buffer) override
A switch calls this method to pass a message on to the Controller.
static TypeId GetTypeId()
Register this type.
Demonstration of a Learning controller.
static TypeId GetTypeId()
Register this type.
void ReceiveFromSwitch(Ptr< OpenFlowSwitchNetDevice > swtch, ofpbuf *buffer) override
A switch calls this method to pass a message on to the Controller.
Time m_expirationTime
Time it takes for learned MAC state entry/created flow to expire.
LearnState_t m_learnState
Learned state data.
int PortStatsInit(const void *body, int body_len, void **state)
Initialize the stats.
int PortTableStatsDump(Ptr< OpenFlowSwitchNetDevice > dp, void *state, ofpbuf *buffer)
Dump the stats.
int FlowStatsDump(Ptr< OpenFlowSwitchNetDevice > dp, FlowStatsState *state, ofpbuf *buffer)
Dump the stats.
int(* AggregateDumpCallback)(sw_flow *flow, void *state)
Aggregate dump callback functor.
Stats(ofp_stats_types _type, size_t body_len)
Constructor.
void DoCleanup(void *state)
Cleans any state created by the init or dump functions.
int AggregateStatsInit(const void *body, int body_len, void **state)
Initialize the stats.
int DoDump(Ptr< OpenFlowSwitchNetDevice > swtch, void *state, ofpbuf *buffer)
Appends statistics for OpenFlowSwitchNetDevice to 'buffer'.
int DoInit(const void *body, int body_len, void **state)
Prepares to dump some kind of statistics on the connected OpenFlowSwitchNetDevice.
int AggregateStatsDump(Ptr< OpenFlowSwitchNetDevice > dp, ofp_aggregate_stats_request *state, ofpbuf *buffer)
Dump the stats.
int TableStatsDump(Ptr< OpenFlowSwitchNetDevice > dp, void *state, ofpbuf *buffer)
Dump the stats.
int PortStatsDump(Ptr< OpenFlowSwitchNetDevice > dp, PortStatsState *state, ofpbuf *buffer)
Dump the stats.
ofp_stats_types type
Status type.
int FlowStatsInit(const void *body, int body_len, void **state)
Initialize the stats.
int DescStatsDump(void *state, ofpbuf *buffer)
Dumps the stats description.
int(* FlowDumpCallback)(sw_flow *flow, void *state)
Flow dump callback functor.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Time Seconds(double value)
Construct a Time in the indicated unit.
void ExecuteVPortActions(Ptr< OpenFlowSwitchNetDevice > swtch, uint64_t packet_uid, ofpbuf *buffer, sw_flow_key *key, const ofp_action_header *actions, size_t actions_len)
Executes a list of virtual port table entry actions.
void ExecuteActions(Ptr< OpenFlowSwitchNetDevice > swtch, uint64_t packet_uid, ofpbuf *buffer, sw_flow_key *key, const ofp_action_header *actions, size_t actions_len, int ignore_no_fwd)
Executes a list of flow table actions.
uint16_t ValidateVendor(const sw_flow_key *key, const ofp_action_header *ah, uint16_t len)
Validates a vendor-defined action.
void ExecuteVendor(ofpbuf *buffer, const sw_flow_key *key, const ofp_action_header *ah)
Executes a vendor-defined action.
uint16_t ValidateActions(const sw_flow_key *key, const ofp_action_header *actions, size_t actions_len)
Validates a list of flow table actions.
int Stats_AggregateDumpCallback(sw_flow *flow, void *state)
int Stats_FlowDumpCallback(sw_flow *flow, void *state)
uint16_t ValidateVPortActions(const ofp_action_header *actions, size_t actions_len)
Validates a list of virtual port table entry actions.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
#define MAX_FLOW_STATS_BYTES
void strip_vlan(ofpbuf *buffer, sw_flow_key *key, const ofp_action_header *ah)
void set_mpls_label(ofpbuf *buffer, sw_flow_key *key, const ofp_action_header *ah)
void set_dl_addr(ofpbuf *buffer, sw_flow_key *key, const ofp_action_header *ah)
void set_nw_addr(ofpbuf *buffer, sw_flow_key *key, const ofp_action_header *ah)
void set_vlan_pcp(ofpbuf *buffer, sw_flow_key *key, const ofp_action_header *ah)
void set_tp_port(ofpbuf *buffer, sw_flow_key *key, const ofp_action_header *ah)
void set_mpls_exp(ofpbuf *buffer, sw_flow_key *key, const ofp_action_header *ah)
void set_vlan_vid(ofpbuf *buffer, sw_flow_key *key, const ofp_action_header *ah)
static bool IsValidType(ofp_action_type type)
static void Execute(ofp_action_type type, ofpbuf *buffer, sw_flow_key *key, const ofp_action_header *ah)
Executes the action.
static uint16_t Validate(ofp_action_type type, size_t len, const sw_flow_key *key, const ofp_action_header *ah)
Validates the action on whether its data is valid or not.
static bool IsValidType(er_action_type type)
static void Execute(er_action_type type, ofpbuf *buffer, const sw_flow_key *key, const er_action_header *ah)
Executes the action.
static uint16_t Validate(er_action_type type, size_t len)
Validates the action on whether its data is valid or not.
uint32_t port
Learned port.
Ptr< NetDevice > netdev
NetDevice pointer.
unsigned long long int mpls_ttl0_dropped
Counter of packets dropped due to MPLS TTL.
unsigned long long int tx_packets
Counter of Tx packets.
unsigned long long int tx_bytes
Counter of Tx bytes.
unsigned long long int rx_packets
Counter of Rx packets.
unsigned long long int rx_bytes
Counter of Rx bytes.
unsigned long long int tx_dropped
Counter of Tx dropped packets.
State of the FlowStats request/reply.
ofp_flow_stats_request rq
Stats requests.
sw_table_position position
Table position.
int table_idx
Table index.
State of the PortStats request/reply.
uint32_t * ports
Array of ports in network byte order.
uint32_t num_ports
Number of ports in host byte order.
Callback for a stats dump request.
Ptr< OpenFlowSwitchNetDevice > swtch
The switch that we're requesting data from.
static uint16_t Validate(ofp_vport_action_type type, size_t len, const ofp_action_header *ah)
Validates the action on whether its data is valid or not.
static void Execute(ofp_vport_action_type type, ofpbuf *buffer, const sw_flow_key *key, const ofp_action_header *ah)
Executes the action.
static bool IsValidType(ofp_vport_action_type type)