static void __of1x_destroy_instruction(of1x_instruction_t* inst){ //Check if empty if(inst->type == OF1X_IT_NO_INSTRUCTION) return; if(inst->apply_actions) of1x_destroy_action_group(inst->apply_actions); if(inst->write_actions) __of1x_destroy_write_actions(inst->write_actions); }
//Update apply/write rofl_result_t __of1x_update_apply_actions(of1x_action_group_t** group, of1x_action_group_t* new_group){ of1x_action_group_t* old_group = *group; //Transfer *group = new_group; //Release if necessary if(old_group) of1x_destroy_action_group(old_group); return ROFL_SUCCESS; }
of1x_action_group_t* __of1x_copy_action_group(of1x_action_group_t* origin){ of1x_action_group_t* copy; of1x_packet_action_t* it; if( unlikely(origin==NULL) ) return NULL; copy = platform_malloc_shared(sizeof(of1x_action_group_t)); if( unlikely(copy==NULL) ) return NULL; copy->head = copy->tail = NULL; copy->num_of_actions = origin->num_of_actions; copy->num_of_output_actions = origin->num_of_output_actions; //Copy al apply actions for(it=origin->head;it;it=it->next){ of1x_packet_action_t* act; act = __of1x_copy_packet_action(it); if(unlikely(act == NULL)){ of1x_destroy_action_group(copy); return NULL; } //Insert in the double linked-list if(!copy->tail){ copy->head = act; act->prev = NULL; }else{ act->prev = copy->tail; copy->tail->next = act; } act->next = NULL; copy->tail = act; } return copy; }