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; }
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; }
void packet_handle_std_validate(struct packet_handle_std *handle) { struct packet_fields * pktout_inport, *pktout_metadata; uint32_t in_port; uint64_t metadata; if(handle->valid) return; if (nblink_packet_parse(handle->pkt->buffer,&handle->match.match_fields, handle->proto) < 0) return; handle->valid = true; /* Add in_port value to the hash_map */ pktout_inport = (struct packet_fields*) malloc(sizeof(struct packet_fields)); pktout_inport->header = OXM_OF_IN_PORT; pktout_inport->value = (uint8_t*) malloc(sizeof(uint32_t)); memset(pktout_inport->value,0x0,sizeof(uint32_t)); in_port = htonl(handle->pkt->in_port); memcpy(pktout_inport->value,&in_port,sizeof(uint32_t)); hmap_insert(&handle->match.match_fields, &pktout_inport->hmap_node,hash_int(pktout_inport->header, 0)); /*Add metadata value to the hash_map */ pktout_metadata = (struct packet_fields*) malloc(sizeof(struct packet_fields)); pktout_metadata->header = OXM_OF_METADATA; pktout_metadata->value = (uint8_t*) malloc(sizeof(uint64_t) ); metadata = 0xffffffffffffffff; memcpy(pktout_metadata->value, &metadata, sizeof(uint64_t)); hmap_insert(&handle->match.match_fields, &pktout_metadata->hmap_node,hash_int(pktout_metadata->header, 0)); return; }