static lagopus_result_t features_reply_features_get(struct channel *channel, struct ofp_switch_features *features) { lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES; datastore_bridge_info_t info; size_t i; /* set ids/reserved. */ features->datapath_id = channel_dpid_get(channel); features->auxiliary_id = channel_auxiliary_id_get(channel); features->reserved = 0; if ((ret = ofp_bridgeq_mgr_info_get(features->datapath_id, &info)) != LAGOPUS_RESULT_OK) { lagopus_msg_warning("FAILED (%s).\n", lagopus_error_get_string(ret)); goto done; } /* set max. */ features->n_buffers = info.max_buffered_packets; features->n_tables = info.max_tables; /* set capabilities. */ features->capabilities = 0; for (i = 0; i < capabilities_size; i++) { if ((ret = features_reply_features_capability_set( info.capabilities, i, &features->capabilities)) != LAGOPUS_RESULT_OK) { lagopus_msg_warning("FAILED (%s).\n", lagopus_error_get_string(ret)); goto done; } } done: return ret; }
void test_ofp_bridgeq_mgr_bridge(void) { lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES; uint64_t dpid = 0x01; const char *bridge_name = "test_bridge01"; char *test_bridge_name = NULL; struct ofp_bridgeq *bridgeq = NULL; lagopus_qmuxer_poll_t poll = NULL; datastore_bridge_info_t info = {1LL, 2LL, 3LL, 4LL, 5LL, 6LL, 7LL, 8LL, 9LL, 10LL, 11LL, 12LL}; datastore_bridge_info_t test_info; datastore_bridge_queue_info_t q_info = {1000LL, 1000LL, 1000LL, 1000LL, 1000LL, 1000LL}; /* register bridge. */ ret = ofp_bridgeq_mgr_bridge_register(dpid, bridge_name, &info, &q_info); TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_RESULT_OK, ret, "ofp_bridgeq_mgr_bridge_register error."); /* register same bridge. */ ret = ofp_bridgeq_mgr_bridge_register(dpid, bridge_name, &info, &q_info); TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_RESULT_ALREADY_EXISTS, ret, "ofp_bridgeq_mgr_bridge_register(same bridge) error."); /* lookup. */ ret = ofp_bridgeq_mgr_bridge_lookup(dpid, &bridgeq); TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_RESULT_OK, ret, "ofp_bridgeq_mgr_bridge_lookup error."); TEST_ASSERT_NOT_EQUAL_MESSAGE(NULL, bridgeq, "bridgeq error."); /* get bridge name. */ ret = ofp_bridgeq_mgr_name_get(dpid, &test_bridge_name); TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_RESULT_OK, ret, "ofp_bridgeq_mgr_name_get error."); TEST_ASSERT_EQUAL_MESSAGE(0, strcmp(bridge_name, test_bridge_name), "bad bridge name."); free(test_bridge_name); test_bridge_name = NULL; /* get bridge name (not found). */ ret = ofp_bridgeq_mgr_name_get(0x999, &test_bridge_name); TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_RESULT_NOT_FOUND, ret, "ofp_bridgeq_mgr_name_get error."); TEST_ASSERT_EQUAL_MESSAGE(NULL, test_bridge_name, "bad bridge name."); /* get bridge info. */ ret = ofp_bridgeq_mgr_info_get(dpid, &test_info); TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_RESULT_OK, ret, "ofp_bridgeq_mgr_info_get error."); TEST_ASSERT_EQUAL_MESSAGE(1, ((info.dpid == test_info.dpid) && (info.fail_mode == test_info.fail_mode) && (info.max_buffered_packets == test_info.max_buffered_packets) && (info.max_ports == test_info.max_ports) && (info.max_tables == test_info.max_tables) && (info.max_flows == test_info.max_flows) && (info.capabilities == test_info.capabilities) && (info.action_types == test_info.action_types) && (info.instruction_types == test_info.instruction_types) && (info.reserved_port_types == test_info.reserved_port_types) && (info.group_types == test_info.group_types) && (info.group_capabilities == test_info.group_capabilities)), "bad bridge info."); /* get bridge info (not found). */ ret = ofp_bridgeq_mgr_info_get(0x999, &test_info); TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_RESULT_NOT_FOUND, ret, "ofp_bridgeq_mgr_info_get error."); /* check getter. */ poll = NULL; poll = ofp_bridgeq_mgr_eventq_poll_get(bridgeq); TEST_ASSERT_NOT_EQUAL_MESSAGE(NULL, poll, "ofp_bridgeq_mgr_eventq_poll_get error."); poll = NULL; poll = ofp_bridgeq_mgr_dataq_poll_get(bridgeq); TEST_ASSERT_NOT_EQUAL_MESSAGE(NULL, poll, "ofp_bridgeq_mgr_dataq_poll_get error."); /* decrement refs. */ ofp_bridgeq_mgr_bridgeq_free(bridgeq); /* unregister bridge. */ ret = ofp_bridgeq_mgr_bridge_unregister(dpid); TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_RESULT_OK, ret, "ofp_bridgeq_mgr_bridge_unregister error."); /* lookup. */ bridgeq = NULL; ret = ofp_bridgeq_mgr_bridge_lookup(dpid, &bridgeq); TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_RESULT_NOT_FOUND, ret, "ofp_bridgeq_mgr_bridge_lookup error."); }