32   size_t min_body = 0, max_body = 0;
 
   39       min_body = max_body = 
sizeof(ofp_flow_stats_request);
 
   42       min_body = max_body = 
sizeof(ofp_aggregate_stats_request);
 
   48       max_body = std::numeric_limits<size_t>::max (); 
 
   50     case OFPST_PORT_TABLE:
 
   57   if ((min_body != 0 || max_body != 0) && (body_len < min_body || body_len > max_body))
 
   59       NS_LOG_ERROR (
"stats request type " << 
type << 
" with bad body length " << body_len);
 
   79     case OFPST_PORT_TABLE:
 
   89 Stats::DoDump (Ptr<OpenFlowSwitchNetDevice> swtch, 
void *state, ofpbuf *buffer)
 
   96       return FlowStatsDump (swtch, (FlowStatsState *)state, buffer);
 
  102       return PortStatsDump (swtch, (PortStatsState *)state, buffer);
 
  103     case OFPST_PORT_TABLE:
 
  120       free ((FlowStatsState *)state);
 
  122     case OFPST_AGGREGATE:
 
  123       free ((ofp_aggregate_stats_request *)state);
 
  128       free (((PortStatsState *)state)->ports);
 
  129       free ((PortStatsState *)state);
 
  131     case OFPST_PORT_TABLE:
 
  141   ofp_desc_stats *ods = (ofp_desc_stats*)ofpbuf_put_zeros (buffer, 
sizeof *ods);
 
  149 #define MAX_FLOW_STATS_BYTES 4096 
  154   const ofp_flow_stats_request *fsr = (ofp_flow_stats_request*)body;
 
  155   FlowStatsState *
s = (FlowStatsState*)xmalloc (
sizeof *s);
 
  157   s->table_idx = fsr->table_id == 0xff ? 0 : fsr->table_id;
 
  158   memset (&s->position, 0, 
sizeof s->position);
 
  165 Stats_FlowDumpCallback (sw_flow *flow, 
void* state)
 
  167   Stats::FlowStatsState *s = (Stats::FlowStatsState*)state;
 
  171   int length = 
sizeof *ofs + flow->sf_acts->actions_len;
 
  172   ofs = (ofp_flow_stats*)ofpbuf_put_zeros (s->buffer, length);
 
  173   ofs->length          = htons (length);
 
  174   ofs->table_id        = s->table_idx;
 
  175   ofs->match.wildcards = htonl (flow->key.wildcards);
 
  176   ofs->match.in_port   = flow->key.flow.in_port;
 
  177   memcpy (ofs->match.dl_src, flow->key.flow.dl_src, ETH_ADDR_LEN);
 
  178   memcpy (ofs->match.dl_dst, flow->key.flow.dl_dst, ETH_ADDR_LEN);
 
  179   ofs->match.dl_vlan   = flow->key.flow.dl_vlan;
 
  180   ofs->match.dl_type   = flow->key.flow.dl_type;
 
  181   ofs->match.nw_src    = flow->key.flow.nw_src;
 
  182   ofs->match.nw_dst    = flow->key.flow.nw_dst;
 
  183   ofs->match.nw_proto  = flow->key.flow.nw_proto;
 
  184   ofs->match.tp_src    = flow->key.flow.tp_src;
 
  185   ofs->match.tp_dst    = flow->key.flow.tp_dst;
 
  186   ofs->duration        = htonl (s->now - flow->created);
 
  187   ofs->priority        = htons (flow->priority);
 
  188   ofs->idle_timeout    = htons (flow->idle_timeout);
 
  189   ofs->hard_timeout    = htons (flow->hard_timeout);
 
  190   ofs->packet_count    = htonll (flow->packet_count);
 
  191   ofs->byte_count      = htonll (flow->byte_count);
 
  192   memcpy (ofs->actions, flow->sf_acts->actions, flow->sf_acts->actions_len);
 
  194   return s->buffer->size >= MAX_FLOW_STATS_BYTES;
 
  200   sw_flow_key match_key;
 
  202   flow_extract_match (&match_key, &s->rq.match);
 
  205   s->now = time_now ();
 
  206   while (s->table_idx < swtch->GetChain ()->n_tables
 
  207          && (s->rq.table_id == 0xff || s->rq.table_id == s->table_idx))
 
  209       sw_table *table = swtch->GetChain ()->tables[s->table_idx];
 
  217       memset (&s->position, 0, 
sizeof s->position);
 
  219   return s->buffer->size >= MAX_FLOW_STATS_BYTES;
 
  226   *state = (ofp_aggregate_stats_request*)body;
 
  231 Stats_AggregateDumpCallback (sw_flow *flow, 
void *state)
 
  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;
 
  243   ofp_aggregate_stats_request *rq = 
s;
 
  244   ofp_aggregate_stats_reply *rpy = (ofp_aggregate_stats_reply*)ofpbuf_put_zeros (buffer, 
sizeof *rpy);
 
  245   sw_flow_key match_key;
 
  246   flow_extract_match (&match_key, &rq->match);
 
  247   int table_idx = rq->table_id == 0xff ? 0 : rq->table_id;
 
  249   sw_table_position position;
 
  250   memset (&position, 0, 
sizeof position);
 
  252   while (table_idx < swtch->GetChain ()->n_tables
 
  253          && (rq->table_id == 0xff || rq->table_id == table_idx))
 
  255       sw_table *table = swtch->GetChain ()->tables[table_idx];
 
  263       memset (&position, 0, 
sizeof position);
 
  266   rpy->packet_count = htonll (rpy->packet_count);
 
  267   rpy->byte_count = htonll (rpy->byte_count);
 
  268   rpy->flow_count = htonl (rpy->flow_count);
 
  275   sw_chain* ft = swtch->GetChain ();
 
  276   for (
int i = 0; i < ft->n_tables; i++)
 
  278       ofp_table_stats *ots = (ofp_table_stats*)ofpbuf_put_zeros (buffer, 
sizeof *ots);
 
  279       sw_table_stats stats;
 
  280       ft->tables[i]->stats (ft->tables[i], &stats);
 
  281       strncpy (ots->name, stats.name, 
sizeof ots->name);
 
  283       ots->wildcards = htonl (stats.wildcards);
 
  284       ots->max_entries = htonl (stats.max_flows);
 
  285       ots->active_count = htonl (stats.n_flows);
 
  286       ots->lookup_count = htonll (stats.n_lookup);
 
  287       ots->matched_count = htonll (stats.n_matched);
 
  296   ofp_vport_table_stats *opts = (ofp_vport_table_stats*)ofpbuf_put_zeros (buffer, 
sizeof *opts);
 
  297   opts->max_vports = htonl (swtch->GetVPortTable ().max_vports);
 
  298   opts->active_vports = htonl (swtch->GetVPortTable ().active_vports);
 
  299   opts->lookup_count = htonll (swtch->GetVPortTable ().lookup_count);
 
  300   opts->port_match_count = htonll (swtch->GetVPortTable ().port_match_count);
 
  301   opts->chain_match_count = htonll (swtch->GetVPortTable ().chain_match_count);
 
  309   PortStatsState *s = (PortStatsState*)xmalloc (
sizeof *s);
 
  312   s->ports = (uint32_t*)xmalloc (body_len);
 
  313   memcpy (s->ports, body, body_len);
 
  314   s->num_ports = body_len / 
sizeof(uint32_t);
 
  327   for (
size_t i = 0; i < s->num_ports; i++)
 
  329       port = ntohl (s->ports[i]);
 
  331       if (port <= OFPP_MAX)
 
  333           Port p = swtch->GetSwitchPort (port);
 
  340           ops = (ofp_port_stats*)ofpbuf_put_zeros (buffer, 
sizeof *ops);
 
  341           ops->port_no = htonl (swtch->GetSwitchPortIndex (p));
 
  342           ops->rx_packets   = htonll (p.rx_packets);
 
  343           ops->tx_packets   = htonll (p.tx_packets);
 
  344           ops->rx_bytes     = htonll (p.rx_bytes);
 
  345           ops->tx_bytes     = htonll (p.tx_bytes);
 
  346           ops->rx_dropped   = htonll (-1);
 
  347           ops->tx_dropped   = htonll (p.tx_dropped);
 
  348           ops->rx_errors    = htonll (-1);
 
  349           ops->tx_errors    = htonll (-1);
 
  350           ops->rx_frame_err = htonll (-1);
 
  351           ops->rx_over_err  = htonll (-1);
 
  352           ops->rx_crc_err   = htonll (-1);
 
  353           ops->collisions   = htonll (-1);
 
  354           ops->mpls_ttl0_dropped = htonll (p.mpls_ttl0_dropped);
 
  357       else if (port >= OFPP_VP_START && port <= OFPP_VP_END) 
 
  360           vport_table_t vt = swtch->GetVPortTable ();
 
  361           vport_table_entry *vpe = vport_table_lookup (&vt, port);
 
  368           ops = (ofp_port_stats*)ofpbuf_put_zeros (buffer, 
sizeof *ops);
 
  369           ops->port_no = htonl (vpe->vport);
 
  370           ops->rx_packets   = htonll (-1);
 
  371           ops->tx_packets   = htonll (vpe->packet_count);
 
  372           ops->rx_bytes     = htonll (-1);
 
  373           ops->tx_bytes     = htonll (vpe->byte_count);
 
  374           ops->rx_dropped   = htonll (-1);
 
  375           ops->tx_dropped   = htonll (-1);
 
  376           ops->rx_errors    = htonll (-1);
 
  377           ops->tx_errors    = htonll (-1);
 
  378           ops->rx_frame_err = htonll (-1);
 
  379           ops->rx_over_err  = htonll (-1);
 
  380           ops->rx_crc_err   = htonll (-1);
 
  381           ops->collisions   = htonll (-1);
 
  382           ops->mpls_ttl0_dropped = htonll (-1);
 
  395     case OFPAT_SET_VLAN_VID:
 
  396     case OFPAT_SET_VLAN_PCP:
 
  397     case OFPAT_STRIP_VLAN:
 
  398     case OFPAT_SET_DL_SRC:
 
  399     case OFPAT_SET_DL_DST:
 
  400     case OFPAT_SET_NW_SRC:
 
  401     case OFPAT_SET_NW_DST:
 
  402     case OFPAT_SET_TP_SRC:
 
  403     case OFPAT_SET_TP_DST:
 
  404     case OFPAT_SET_MPLS_LABEL:
 
  405     case OFPAT_SET_MPLS_EXP:
 
  413 Action::Validate (ofp_action_type type, 
size_t len, 
const sw_flow_key *key, 
const ofp_action_header *ah)
 
  421         if (len != 
sizeof(ofp_action_output))
 
  423             return OFPBAC_BAD_LEN;
 
  426         ofp_action_output *oa = (ofp_action_output *)ah;
 
  431         if (oa->port == OFPP_NONE || oa->port == key->flow.in_port) 
 
  433             return OFPBAC_BAD_OUT_PORT;
 
  436         return ACT_VALIDATION_OK;
 
  438     case OFPAT_SET_VLAN_VID:
 
  439       size = 
sizeof(ofp_action_vlan_vid);
 
  441     case OFPAT_SET_VLAN_PCP:
 
  442       size = 
sizeof(ofp_action_vlan_pcp);
 
  444     case OFPAT_STRIP_VLAN:
 
  445       size = 
sizeof(ofp_action_header);
 
  447     case OFPAT_SET_DL_SRC:
 
  448     case OFPAT_SET_DL_DST:
 
  449       size = 
sizeof(ofp_action_dl_addr);
 
  451     case OFPAT_SET_NW_SRC:
 
  452     case OFPAT_SET_NW_DST:
 
  453       size = 
sizeof(ofp_action_nw_addr);
 
  455     case OFPAT_SET_TP_SRC:
 
  456     case OFPAT_SET_TP_DST:
 
  457       size = 
sizeof(ofp_action_tp_port);
 
  459     case OFPAT_SET_MPLS_LABEL:
 
  460       size = 
sizeof(ofp_action_mpls_label);
 
  462     case OFPAT_SET_MPLS_EXP:
 
  463       size = 
sizeof(ofp_action_mpls_exp);
 
  471       return OFPBAC_BAD_LEN;
 
  473   return ACT_VALIDATION_OK;
 
  477 Action::Execute (ofp_action_type type, ofpbuf *buffer, sw_flow_key *key, 
const ofp_action_header *ah)
 
  483     case OFPAT_SET_VLAN_VID:
 
  486     case OFPAT_SET_VLAN_PCP:
 
  489     case OFPAT_STRIP_VLAN:
 
  492     case OFPAT_SET_DL_SRC:
 
  493     case OFPAT_SET_DL_DST:
 
  496     case OFPAT_SET_NW_SRC:
 
  497     case OFPAT_SET_NW_DST:
 
  500     case OFPAT_SET_TP_SRC:
 
  501     case OFPAT_SET_TP_DST:
 
  504     case OFPAT_SET_MPLS_LABEL:
 
  507     case OFPAT_SET_MPLS_EXP:
 
  520     case OFPPAT_POP_MPLS:
 
  521     case OFPPAT_PUSH_MPLS:
 
  522     case OFPPAT_SET_MPLS_LABEL:
 
  523     case OFPPAT_SET_MPLS_EXP:
 
  537     case OFPPAT_POP_MPLS:
 
  538       size = 
sizeof(ofp_vport_action_pop_mpls);
 
  540     case OFPPAT_PUSH_MPLS:
 
  541       size = 
sizeof(ofp_vport_action_push_mpls);
 
  543     case OFPPAT_SET_MPLS_LABEL:
 
  544       size = 
sizeof(ofp_vport_action_set_mpls_label);
 
  546     case OFPPAT_SET_MPLS_EXP:
 
  547       size = 
sizeof(ofp_vport_action_set_mpls_exp);
 
  555       return OFPBAC_BAD_LEN;
 
  557   return ACT_VALIDATION_OK;
 
  561 VPortAction::Execute (ofp_vport_action_type type, ofpbuf *buffer, 
const sw_flow_key *key, 
const ofp_action_header *ah)
 
  565     case OFPPAT_POP_MPLS:
 
  567         ofp_vport_action_pop_mpls *opapm = (ofp_vport_action_pop_mpls *)ah;
 
  568         pop_mpls_act (0, buffer, key, &opapm->apm);
 
  571     case OFPPAT_PUSH_MPLS:
 
  573         ofp_vport_action_push_mpls *opapm = (ofp_vport_action_push_mpls *)ah;
 
  574         push_mpls_act (0, buffer, key, &opapm->apm);
 
  577     case OFPPAT_SET_MPLS_LABEL:
 
  579         ofp_vport_action_set_mpls_label *oparml = (ofp_vport_action_set_mpls_label *)ah;
 
  580         set_mpls_label_act (buffer, key, oparml->label_out);
 
  583     case OFPPAT_SET_MPLS_EXP:
 
  585         ofp_vport_action_set_mpls_exp *oparme = (ofp_vport_action_set_mpls_exp *)ah;
 
  586         set_mpls_exp_act (buffer, key, oparme->exp);
 
  615       size = 
sizeof(er_action_pop_mpls);
 
  618       size = 
sizeof(er_action_push_mpls);
 
  626       return OFPBAC_BAD_LEN;
 
  628   return ACT_VALIDATION_OK;
 
  632 EricssonAction::Execute (er_action_type type, ofpbuf *buffer, 
const sw_flow_key *key, 
const er_action_header *ah)
 
  638         er_action_pop_mpls *erapm = (er_action_pop_mpls *)ah;
 
  639         pop_mpls_act (0, buffer, key, &erapm->apm);
 
  644         er_action_push_mpls *erapm = (er_action_push_mpls *)ah;
 
  645         push_mpls_act (0, buffer, key, &erapm->apm);
 
  658       NS_LOG_INFO (
"This Controller has already registered this switch!");
 
  671       NS_LOG_ERROR (
"Can't send to this switch, not registered to the Controller.");
 
  675   swtch->ForwardControlInput (msg, length);
 
  679 Controller::BuildFlow (sw_flow_key key, uint32_t buffer_id, uint16_t command, 
void* acts, 
size_t actions_len, 
int idle_timeout, 
int hard_timeout)
 
  681   ofp_flow_mod* ofm = (ofp_flow_mod*)malloc (
sizeof(ofp_flow_mod) + actions_len);
 
  682   ofm->header.version = OFP_VERSION;
 
  683   ofm->header.type = OFPT_FLOW_MOD;
 
  684   ofm->header.length = htons (
sizeof(ofp_flow_mod) + actions_len);
 
  685   ofm->command = htons (command);
 
  686   ofm->idle_timeout = htons (idle_timeout);
 
  687   ofm->hard_timeout = htons (hard_timeout);
 
  688   ofm->buffer_id = htonl (buffer_id);
 
  689   ofm->priority = OFP_DEFAULT_PRIORITY;
 
  690   memcpy (ofm->actions,acts,actions_len);
 
  692   ofm->match.wildcards = key.wildcards;                                 
 
  693   ofm->match.in_port = key.flow.in_port;                                
 
  694   memcpy (ofm->match.dl_src, key.flow.dl_src, 
sizeof ofm->match.dl_src); 
 
  695   memcpy (ofm->match.dl_dst, key.flow.dl_dst, 
sizeof ofm->match.dl_dst); 
 
  696   ofm->match.dl_vlan = key.flow.dl_vlan;                                
 
  697   ofm->match.dl_type = key.flow.dl_type;                                
 
  698   ofm->match.nw_proto = key.flow.nw_proto;                              
 
  699   ofm->match.nw_src = key.flow.nw_src;                                  
 
  700   ofm->match.nw_dst = key.flow.nw_dst;                                  
 
  701   ofm->match.tp_src = key.flow.tp_src;                                  
 
  702   ofm->match.tp_dst = key.flow.tp_dst;                                  
 
  703   ofm->match.mpls_label1 = key.flow.mpls_label1;                        
 
  704   ofm->match.mpls_label2 = key.flow.mpls_label1;                        
 
  712   ofp_header* hdr = (ofp_header*)ofpbuf_try_pull (buffer, 
sizeof (ofp_header));
 
  713   uint8_t type = hdr->type;
 
  714   ofpbuf_push_uninit (buffer, 
sizeof (ofp_header));
 
  726           error = cb->swtch->StatsDump (cb);
 
  731           NS_LOG_WARN (
"Dump Callback Error: " << strerror (-error));
 
  735       cb->swtch->StatsDone (cb);
 
  744       NS_LOG_ERROR (
"Can't receive from this switch, not registered to the Controller.");
 
  751   if (type == OFPT_PACKET_IN) 
 
  753       ofp_packet_in * opi = (ofp_packet_in*)ofpbuf_try_pull (buffer, offsetof (ofp_packet_in, 
data));
 
  754       int port = ntohs (opi->in_port);
 
  759       flow_extract (buffer, port != -1 ? port : OFPP_NONE, &key.flow);
 
  761       ofp_flow_mod* ofm = 
BuildFlow (key, opi->buffer_id, OFPFC_ADD, 0, 0, OFP_FLOW_PERMANENT, OFP_FLOW_PERMANENT);
 
  768   static TypeId tid = TypeId (
"ns3::ofi::LearningController")
 
  771     .AddAttribute (
"ExpirationTime",
 
  772                    "Time it takes for learned MAC state entry/created flow to expire.",
 
  773                    TimeValue (Seconds (0)),
 
  785       NS_LOG_ERROR (
"Can't receive from this switch, not registered to the Controller.");
 
  792   if (type == OFPT_PACKET_IN) 
 
  794       ofp_packet_in * opi = (ofp_packet_in*)ofpbuf_try_pull (buffer, offsetof (ofp_packet_in, 
data));
 
  795       int port = ntohs (opi->in_port);
 
  800       flow_extract (buffer, port != -1 ? port : OFPP_NONE, &key.flow);
 
  802       uint16_t out_port = OFPP_FLOOD;
 
  803       uint16_t in_port = ntohs (key.flow.in_port);
 
  806       Mac48Address dst_addr;
 
  807       dst_addr.CopyFrom (key.flow.dl_dst);
 
  808       if (!dst_addr.IsBroadcast ())
 
  810           LearnState_t::iterator st = 
m_learnState.find (dst_addr);
 
  813               out_port = st->second.port;
 
  817               NS_LOG_INFO (
"Setting to flood; don't know yet what port " << dst_addr << 
" is connected to");
 
  822           NS_LOG_INFO (
"Setting to flood; this packet is a broadcast");
 
  826       ofp_action_output 
x[1];
 
  827       x[0].type = htons (OFPAT_OUTPUT);
 
  828       x[0].len = htons (
sizeof(ofp_action_output));
 
  829       x[0].port = out_port;
 
  836       Mac48Address src_addr;
 
  837       src_addr.CopyFrom (key.flow.dl_src);
 
  838       LearnState_t::iterator st = 
m_learnState.find (src_addr);
 
  844           NS_LOG_INFO (
"Learned that " << src_addr << 
" can be found over port " << in_port);
 
  847           ofp_action_output x2[1];
 
  848           x2[0].type = htons (OFPAT_OUTPUT);
 
  849           x2[0].len = htons (
sizeof(ofp_action_output));
 
  850           x2[0].port = in_port;
 
  853           src_addr.CopyTo (key.flow.dl_dst);
 
  854           dst_addr.CopyTo (key.flow.dl_src);
 
  855           key.flow.in_port = out_port;
 
  863 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)
 
  872   uint16_t in_port = key->flow.in_port; 
 
  873   uint8_t *p = (uint8_t *)actions;
 
  877   if (actions_len == 0)
 
  879       NS_LOG_INFO (
"No actions set to this flow. Dropping packet.");
 
  885   while (actions_len > 0)
 
  887       ofp_action_header *ah = (ofp_action_header *)p;
 
  888       size_t len = htons (ah->len);
 
  892           swtch->DoOutput (packet_uid, in_port, max_len, prev_port, ignore_no_fwd);
 
  896       if (ah->type == htons (OFPAT_OUTPUT))
 
  898           ofp_action_output *oa = (ofp_action_output *)p;
 
  901           prev_port = oa->port; 
 
  903           max_len = ntohs (oa->max_len);
 
  907           uint16_t type = ntohs (ah->type);
 
  912           else if (type == OFPAT_VENDOR)
 
  924       swtch->DoOutput (packet_uid, in_port, max_len, prev_port, ignore_no_fwd);
 
  929 ValidateActions (
const sw_flow_key *key, 
const ofp_action_header *actions, 
size_t actions_len)
 
  931   uint8_t *p = (uint8_t *)actions;
 
  934   while (actions_len >= 
sizeof(ofp_action_header))
 
  936       ofp_action_header *ah = (ofp_action_header *)p;
 
  937       size_t len = ntohs (ah->len);
 
  942       if ((actions_len < len) || (len % 8) != 0)
 
  944           return OFPBAC_BAD_LEN;
 
  947       type = ntohs (ah->type);
 
  951           if (err != ACT_VALIDATION_OK)
 
  956       else if (type == OFPAT_VENDOR)
 
  959           if (err != ACT_VALIDATION_OK)
 
  966           return OFPBAC_BAD_TYPE;
 
  974   if (actions_len != 0)
 
  976       return OFPBAC_BAD_LEN;
 
  979   return ACT_VALIDATION_OK;
 
  983 ExecuteVPortActions (Ptr<OpenFlowSwitchNetDevice> swtch, uint64_t packet_uid, ofpbuf* buffer, sw_flow_key *key, 
const ofp_action_header *actions, 
size_t actions_len)
 
  991   uint16_t in_port = ntohs (key->flow.in_port);
 
  992   uint8_t *p = (uint8_t *)actions;
 
  994   ofp_action_output *oa;
 
  999   while (actions_len > 0)
 
 1001       ofp_action_header *ah = (ofp_action_header *)p;
 
 1002       size_t len = htons (ah->len);
 
 1003       if (prev_port != -1)
 
 1005           swtch->DoOutput (packet_uid, in_port, max_len, prev_port, 
false);
 
 1009       if (ah->type == htons (OFPAT_OUTPUT))
 
 1011           oa = (ofp_action_output *)p;
 
 1012           prev_port = ntohl (oa->port);
 
 1013           max_len = ntohs (oa->max_len);
 
 1025   if (prev_port != -1)
 
 1027       swtch->DoOutput (packet_uid, in_port, max_len, prev_port, 
false);
 
 1034   uint8_t *p = (uint8_t *)actions;
 
 1037   while (actions_len >= 
sizeof(ofp_action_header))
 
 1039       ofp_action_header *ah = (ofp_action_header *)p;
 
 1040       size_t len = ntohs (ah->len);
 
 1045       if ((actions_len < len) || (len % 8) != 0)
 
 1047           return OFPBAC_BAD_LEN;
 
 1050       type = ntohs (ah->type);
 
 1054           if (err != ACT_VALIDATION_OK)
 
 1061           return OFPBAC_BAD_TYPE;
 
 1069   if (actions_len != 0)
 
 1071       return OFPBAC_BAD_LEN;
 
 1074   return ACT_VALIDATION_OK;
 
 1078 ExecuteVendor (ofpbuf *buffer, 
const sw_flow_key *key, 
const ofp_action_header *ah)
 
 1080   ofp_action_vendor_header *avh = (ofp_action_vendor_header *)ah;
 
 1082   switch (ntohl (avh->vendor))
 
 1089         const er_action_header *erah = (
const er_action_header *)avh;
 
 1095       NS_LOG_INFO (
"attempt to execute action with unknown vendor: " << ntohl (avh->vendor));
 
 1101 ValidateVendor (
const sw_flow_key *key, 
const ofp_action_header *ah, uint16_t len)
 
 1103   ofp_action_vendor_header *avh;
 
 1104   int ret = ACT_VALIDATION_OK;
 
 1106   if (len < 
sizeof(ofp_action_vendor_header))
 
 1108       return OFPBAC_BAD_LEN;
 
 1111   avh = (ofp_action_vendor_header *)ah;
 
 1113   switch (ntohl (avh->vendor))
 
 1116       ret = OFPBAC_BAD_VENDOR_TYPE;   
 
 1120         const er_action_header *erah = (
const er_action_header *)avh;
 
 1125       return OFPBAC_BAD_VENDOR;
 
 1135 #endif // NS3_OPENFLOW 
void StartDump(StatsDumpCallback *cb)
Starts a callback-based, reliable, possibly multi-message reply to a request made by the controller...
 
void strip_vlan(ofpbuf *buffer, sw_flow_key *key, const ofp_action_header *ah)
 
static bool IsValidType(ofp_action_type type)
 
TypeId AddConstructor(void)
 
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. 
 
static const char * GetSerialNumber()
 
static TypeId GetTypeId(void)
 
int DoInit(const void *body, int body_len, void **state)
Prepares to dump some kind of statistics on the connected OpenFlowSwitchNetDevice. 
 
int AggregateStatsInit(const void *body, int body_len, void **state)
 
static const char * GetHardwareDescription()
 
#define NS_LOG_FUNCTION_NOARGS()
 
void ReceiveFromSwitch(Ptr< OpenFlowSwitchNetDevice > swtch, ofpbuf *buffer)
 
int AggregateStatsDump(Ptr< OpenFlowSwitchNetDevice > dp, ofp_aggregate_stats_request *s, ofpbuf *buffer)
 
void ReceiveFromSwitch(Ptr< OpenFlowSwitchNetDevice > swtch, ofpbuf *buffer)
 
Stats(ofp_stats_types _type, size_t body_len)
 
int PortTableStatsDump(Ptr< OpenFlowSwitchNetDevice > dp, void *state, ofpbuf *buffer)
 
void set_dl_addr(ofpbuf *buffer, sw_flow_key *key, const ofp_action_header *ah)
 
int TableStatsDump(Ptr< OpenFlowSwitchNetDevice > dp, void *state, ofpbuf *buffer)
 
double GetSeconds(void) const 
 
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 const char * GetManufacturerDescription()
 
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. 
 
static void Execute(er_action_type type, ofpbuf *buffer, const sw_flow_key *key, const er_action_header *ah)
Executes the action. 
 
LearnState_t m_learnState
Learned state data. 
 
static bool IsValidType(er_action_type type)
 
static void Execute(ofp_vport_action_type type, ofpbuf *buffer, const sw_flow_key *key, const ofp_action_header *ah)
Executes the action. 
 
static TypeId GetTypeId(void)
 
Switches_t m_switches
The collection of switches registered to this controller. 
 
static uint16_t Validate(er_action_type type, size_t len)
Validates the action on whether its data is valid or not. 
 
static const char * GetSoftwareDescription()
 
int DoDump(Ptr< OpenFlowSwitchNetDevice > swtch, void *state, ofpbuf *buffer)
Appends statistics for OpenFlowSwitchNetDevice to 'buffer'. 
 
void set_tp_port(ofpbuf *buffer, sw_flow_key *key, const ofp_action_header *ah)
 
int PortStatsDump(Ptr< OpenFlowSwitchNetDevice > dp, PortStatsState *s, ofpbuf *buffer)
 
virtual void SendToSwitch(Ptr< OpenFlowSwitchNetDevice > swtch, void *msg, size_t length)
 
void set_mpls_exp(ofpbuf *buffer, sw_flow_key *key, const ofp_action_header *ah)
 
int FlowStatsInit(const void *body, int body_len, void **state)
 
uint16_t ValidateActions(const sw_flow_key *key, const ofp_action_header *actions, size_t actions_len)
Validates a list of flow table actions. 
 
virtual void AddSwitch(Ptr< OpenFlowSwitchNetDevice > swtch)
 
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)
 
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. 
 
NS_LOG_COMPONENT_DEFINE("PacketLossCounter")
 
void set_vlan_pcp(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)
 
Time m_expirationTime
Time it takes for learned MAC state entry/created flow to expire. 
 
uint8_t GetPacketType(ofpbuf *buffer)
 
int DescStatsDump(void *state, ofpbuf *buffer)
 
int PortStatsInit(const void *body, int body_len, void **state)
 
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range. Both limits are inclusive. 
 
#define NS_LOG_ERROR(msg)
 
void set_mpls_label(ofpbuf *buffer, sw_flow_key *key, const ofp_action_header *ah)
 
static bool IsValidType(ofp_vport_action_type type)
 
int(* AggregateDumpCallback)(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. 
 
void ExecuteVendor(ofpbuf *buffer, const sw_flow_key *key, const ofp_action_header *ah)
Executes a vendor-defined action. 
 
int(* FlowDumpCallback)(sw_flow *flow, void *state)
 
int FlowStatsDump(Ptr< OpenFlowSwitchNetDevice > dp, FlowStatsState *s, ofpbuf *buffer)
 
static void Execute(ofp_action_type type, ofpbuf *buffer, sw_flow_key *key, const ofp_action_header *ah)
Executes the action. 
 
TypeId SetParent(TypeId tid)
 
void DoCleanup(void *state)
Cleans any state created by the init or dump functions. 
 
uint16_t ValidateVendor(const sw_flow_key *key, const ofp_action_header *ah, uint16_t len)
Validates a vendor-defined action. 
 
void set_vlan_vid(ofpbuf *buffer, sw_flow_key *key, const ofp_action_header *ah)