static int populate_table(ft_instance_t ft, int count, of_match_t *match) { int idx; of_flow_add_t *flow_add_base; of_flow_add_t *flow_add; ft_entry_t *entry; flow_add_base = of_flow_add_new(OF_VERSION_1_0); TEST_ASSERT(of_flow_add_OF_VERSION_1_0_populate(flow_add_base, 1) != 0); of_flow_add_flags_set(flow_add_base, 0); TEST_OK(of_flow_add_match_get(flow_add_base, match)); for (idx = 0; idx < count; ++idx) { TEST_ASSERT((flow_add = of_object_dup((of_object_t *)flow_add_base)) != NULL); match->fields.eth_type = TEST_ETH_TYPE(idx); TEST_OK(of_flow_add_match_set(flow_add, match)); TEST_INDIGO_OK(FT_ADD(ft, TEST_KEY(idx), flow_add, &entry)); TEST_ASSERT(check_table_entry_states(ft) == 0); } CHECK_FLOW_COUNT(&ft->status, TEST_FLOW_COUNT); of_flow_add_delete(flow_add_base); return 0; }
/** * Create a copy of elements into a new variable of type of_list_hello_elem_t from * a of_hello instance. * * @param obj Pointer to the source of type of_hello_t * @returns A pointer to a new instance of type of_list_hello_elem_t whose contents * match that of elements from source * @returns NULL if an error occurs */ of_list_hello_elem_t * of_hello_elements_get(of_hello_t *obj) { of_list_hello_elem_t _elements; of_list_hello_elem_t *_elements_ptr; of_hello_elements_bind(obj, &_elements); _elements_ptr = (of_list_hello_elem_t *)of_object_dup(&_elements); return _elements_ptr; }
/** * Create a copy of next_table_ids into a new variable of type of_list_uint8_t from * a of_table_feature_prop_next_tables instance. * * @param obj Pointer to the source of type of_table_feature_prop_next_tables_t * @returns A pointer to a new instance of type of_list_uint8_t whose contents * match that of next_table_ids from source * @returns NULL if an error occurs */ of_list_uint8_t * of_table_feature_prop_next_tables_next_table_ids_get(of_table_feature_prop_next_tables_t *obj) { of_list_uint8_t _next_table_ids; of_list_uint8_t *_next_table_ids_ptr; of_table_feature_prop_next_tables_next_table_ids_bind(obj, &_next_table_ids); _next_table_ids_ptr = (of_list_uint8_t *)of_object_dup(&_next_table_ids); return _next_table_ids_ptr; }
/** * Create a copy of actions into a new variable of type of_list_action_t from * a of_packet_out instance. * * @param obj Pointer to the source of type of_packet_out_t * @returns A pointer to a new instance of type of_list_action_t whose contents * match that of actions from source * @returns NULL if an error occurs */ of_list_action_t * of_packet_out_actions_get(of_packet_out_t *obj) { of_list_action_t _actions; of_list_action_t *_actions_ptr; of_packet_out_actions_bind(obj, &_actions); _actions_ptr = (of_list_action_t *)of_object_dup(&_actions); return _actions_ptr; }
/** * Create a copy of actions into a new variable of type of_list_action_t from * a of_flow_modify instance. * * @param obj Pointer to the source of type of_flow_modify_t * @returns A pointer to a new instance of type of_list_action_t whose contents * match that of actions from source * @returns NULL if an error occurs */ of_list_action_t * of_flow_modify_actions_get(of_flow_modify_t *obj) { of_list_action_t _actions; of_list_action_t *_actions_ptr; of_flow_modify_actions_bind(obj, &_actions); _actions_ptr = (of_list_action_t *)of_object_dup(&_actions); return _actions_ptr; }
/** * Create a copy of entries into a new variable of type of_list_queue_stats_entry_t from * a of_queue_stats_reply instance. * * @param obj Pointer to the source of type of_queue_stats_reply_t * @returns A pointer to a new instance of type of_list_queue_stats_entry_t whose contents * match that of entries from source * @returns NULL if an error occurs */ of_list_queue_stats_entry_t * of_queue_stats_reply_entries_get(of_queue_stats_reply_t *obj) { of_list_queue_stats_entry_t _entries; of_list_queue_stats_entry_t *_entries_ptr; of_queue_stats_reply_entries_bind(obj, &_entries); _entries_ptr = (of_list_queue_stats_entry_t *)of_object_dup(&_entries); return _entries_ptr; }
/** * Create a copy of entries into a new variable of type of_list_bsn_gentable_entry_desc_stats_entry_t from * a of_bsn_gentable_entry_desc_stats_reply instance. * * @param obj Pointer to the source of type of_bsn_gentable_entry_desc_stats_reply_t * @returns A pointer to a new instance of type of_list_bsn_gentable_entry_desc_stats_entry_t whose contents * match that of entries from source * @returns NULL if an error occurs */ of_list_bsn_gentable_entry_desc_stats_entry_t * of_bsn_gentable_entry_desc_stats_reply_entries_get(of_bsn_gentable_entry_desc_stats_reply_t *obj) { of_list_bsn_gentable_entry_desc_stats_entry_t _entries; of_list_bsn_gentable_entry_desc_stats_entry_t *_entries_ptr; of_bsn_gentable_entry_desc_stats_reply_entries_bind(obj, &_entries); _entries_ptr = (of_list_bsn_gentable_entry_desc_stats_entry_t *)of_object_dup(&_entries); return _entries_ptr; }
/** * Create a copy of actions into a new variable of type of_list_action_t from * a of_flow_delete_strict instance. * * @param obj Pointer to the source of type of_flow_delete_strict_t * @returns A pointer to a new instance of type of_list_action_t whose contents * match that of actions from source * @returns NULL if an error occurs */ of_list_action_t * of_flow_delete_strict_actions_get(of_flow_delete_strict_t *obj) { of_list_action_t _actions; of_list_action_t *_actions_ptr; of_flow_delete_strict_actions_bind(obj, &_actions); _actions_ptr = (of_list_action_t *)of_object_dup(&_actions); return _actions_ptr; }
void ind_cxn_bundle_ctrl_handle(connection_t *cxn, of_object_t *obj) { uint32_t bundle_id; uint16_t ctrl_type; uint16_t flags; uint16_t err_code = OFPBFC_UNKNOWN; of_bundle_ctrl_msg_bundle_id_get(obj, &bundle_id); of_bundle_ctrl_msg_bundle_ctrl_type_get(obj, &ctrl_type); of_bundle_ctrl_msg_flags_get(obj, &flags); bundle_t *bundle = find_bundle(cxn, bundle_id); if (ctrl_type == OFPBCT_OPEN_REQUEST) { if (bundle != NULL) { err_code = OFPBFC_BUNDLE_EXIST; goto error; } bundle = find_bundle(cxn, BUNDLE_ID_INVALID); if (bundle == NULL) { err_code = OFPBFC_OUT_OF_BUNDLES; goto error; } bundle->id = bundle_id; bundle->flags = flags; AIM_ASSERT(bundle->count == 0); AIM_ASSERT(bundle->allocated == 0); AIM_ASSERT(bundle->bytes == 0); AIM_ASSERT(bundle->msgs == NULL); } else if (ctrl_type == OFPBCT_CLOSE_REQUEST) { /* Ignored */ } else if (ctrl_type == OFPBCT_COMMIT_REQUEST) { if (bundle == NULL) { err_code = OFPBFC_BAD_ID; goto error; } if (comparator && !(bundle->flags & OFPBF_ORDERED)) { qsort(bundle->msgs, bundle->count, sizeof(bundle->msgs[0]), compare_message); } struct bundle_task_state *state = aim_zmalloc(sizeof(*state)); state->cxn_id = cxn->cxn_id; state->reply = of_object_dup(obj); of_bundle_ctrl_msg_bundle_ctrl_type_set(state->reply, OFPBCT_COMMIT_REPLY); state->id = bundle->id; state->count = bundle->count; state->offset = 0; state->msgs = bundle->msgs; if (ind_soc_task_register(bundle_task, state, IND_SOC_NORMAL_PRIORITY) < 0) { AIM_DIE("Failed to create long running task for bundle"); } ind_cxn_pause(cxn); /* Transfer ownership of msgs to task */ bundle->msgs = NULL; bundle->count = 0; free_bundle(bundle); /* Do not send reply yet */ return; } else if (ctrl_type == OFPBCT_DISCARD_REQUEST) { if (bundle == NULL) { err_code = OFPBFC_BAD_ID; goto error; } free_bundle(bundle); } else { err_code = OFPBFC_BAD_TYPE; goto error; } /* Send reply */ of_object_t *reply = of_object_dup(obj); /* Derive the reply subtype from the request */ of_bundle_ctrl_msg_bundle_ctrl_type_set(reply, ctrl_type+1); indigo_cxn_send_controller_message(cxn->cxn_id, reply); return; error: indigo_cxn_send_error_reply( cxn->cxn_id, obj, OF_ERROR_TYPE_BUNDLE_FAILED, err_code); }