void packet_handle_std_validate(struct packet_handle_std *handle) { struct ofl_match_tlv * iter, *next; if(handle->valid) return; HMAP_FOR_EACH_SAFE(iter, next, struct ofl_match_tlv, hmap_node, &handle->match.match_fields){ free(iter->value); free(iter); } ofl_structs_match_init(&handle->match); if (nblink_packet_parse(handle->pkt->buffer,&handle->match, handle->proto) < 0) return; handle->valid = true; /* Add in_port value to the hash_map */ ofl_structs_match_put32(&handle->match, OXM_OF_IN_PORT, handle->pkt->in_port); /*Add metadata value to the hash_map */ ofl_structs_match_put64(&handle->match, OXM_OF_METADATA, 0x0000000000000000); /* Add global register value to the hash_map */ if (DP_SUPPORTED_CAPABILITIES & OFPC_OPENSTATE){ ofl_structs_match_put32(&handle->match, OXM_OF_STATE, 0x00000000); ofl_structs_match_put32(&handle->match, OXM_OF_FLAGS, OFP_GLOBAL_STATES_DEFAULT); } return; }
/* Sends a packet to the controller in a packet_in message */ static void send_packet_to_controller(struct pipeline *pl, struct packet *pkt, uint8_t table_id, uint8_t reason) { dp_buffers_save(pl->dp->buffers, pkt); { struct ofl_msg_packet_in msg = {{.type = OFPT_PACKET_IN}, .buffer_id = pkt->buffer_id, .total_len = pkt->buffer->size, .reason = reason, .table_id = table_id, .data_length = MIN(pl->dp->config.miss_send_len, pkt->buffer->size), .data = pkt->buffer->data}; struct ofl_match *m = xmalloc (sizeof(struct ofl_match)); ofl_structs_match_init(m); /* In this implementation the fields in_port and in_phy_port always will be the same, because we are not considering logical ports */ ofl_structs_match_put32(m,OXM_OF_IN_PORT,pkt->in_port); ofl_structs_match_put32(m,OXM_OF_IN_PHY_PORT,pkt->in_port); msg.match = (struct ofl_match_header*)m; dp_send_message(pl->dp, (struct ofl_msg_header *)&msg, NULL); }
void packet_handle_std_validate(struct packet_handle_std *handle) { if(handle->valid) return; struct ofl_match_tlv * iter, *next; HMAP_FOR_EACH_SAFE(iter, next, struct ofl_match_tlv, hmap_node, &handle->match.match_fields){ free(iter->value); free(iter); } // hsh hmap_destroy(&handle->match.match_fields); //end ofl_structs_match_init(&handle->match); if (nblink_packet_parse(handle->pkt->buffer,&handle->match, handle->proto) < 0) return; handle->valid = true; /* Add in_port value to the hash_map */ ofl_structs_match_put32(&handle->match, OXM_OF_IN_PORT, handle->pkt->in_port); /*Add metadata value to the hash_map */ ofl_structs_match_put64(&handle->match, OXM_OF_METADATA, 0xffffffffffffffff); return; }