void test_ofp_version_bitmap(void) { int version; uint32_t bitmap; TEST_ASSERT_NOT_NULL(bridge); /* Setting versions. */ for (version = OPENFLOW_VERSION_1_3; version <= OPENFLOW_VERSION_1_4; version++) { TEST_ASSERT_TRUE(LAGOPUS_RESULT_OK == bridge_ofp_version_bitmap_set(bridge, version)); TEST_ASSERT_TRUE(LAGOPUS_RESULT_OK == bridge_ofp_version_bitmap_get(bridge, &bitmap)); TEST_ASSERT_TRUE(0 != (bitmap & (1 << version))); } /* Clearing versions. */ for (version = OPENFLOW_VERSION_1_4; version >= OPENFLOW_VERSION_1_3; version--) { TEST_ASSERT_TRUE(LAGOPUS_RESULT_OK == bridge_ofp_version_bitmap_unset(bridge, version)); TEST_ASSERT_TRUE(LAGOPUS_RESULT_OK == bridge_ofp_version_bitmap_get(bridge, &bitmap)); TEST_ASSERT_TRUE(0 == (bitmap & (1 << version))); } }
lagopus_result_t dpmgr_bridge_ofp_version_bitmap_set(uint64_t dpid, uint8_t version) { lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES; struct dpmgr *dpmgr = NULL; struct bridge *bridge = NULL; dpmgr = dpmgr_get_instance(); if (dpmgr != NULL) { bridge = bridge_lookup_by_dpid(&dpmgr->bridge_list, dpid); if (bridge != NULL) { ret = bridge_ofp_version_bitmap_set(bridge, version); } else { lagopus_msg_warning("Not found bridge.\n"); ret = LAGOPUS_RESULT_NOT_FOUND; } } else { lagopus_msg_warning("Not found dpmgr.\n"); ret = LAGOPUS_RESULT_NOT_FOUND; } return ret; }
/* Allocate a new bridge. */ static struct bridge * bridge_alloc(const char *name) { struct bridge *bridge; /* Allocate memory. */ bridge = (struct bridge *)calloc(1, sizeof(struct bridge)); if (bridge == NULL) { return NULL; } /* Set bridge name. */ strncpy(bridge->name, name, BRIDGE_MAX_NAME_LEN); /* Set default wire protocol version to OpenFlow 1.3. */ bridge_ofp_version_set(bridge, OPENFLOW_VERSION_1_3); bridge_ofp_version_bitmap_set(bridge, OPENFLOW_VERSION_1_3); /* Set default fail mode. */ bridge_fail_mode_set(bridge, FAIL_STANDALONE_MODE); /* Set default features. */ bridge->features.n_buffers = BRIDGE_N_BUFFERS_DEFAULT; bridge->features.n_tables = BRIDGE_N_TABLES_DEFAULT; /* Auxiliary connection id. This value is not used. For * auxiliary_id, please use channel_auxiliary_id_get(). */ bridge->features.auxiliary_id = 0; /* Capabilities. */ SET32_FLAG(bridge->features.capabilities, OFPC_FLOW_STATS); SET32_FLAG(bridge->features.capabilities, OFPC_TABLE_STATS); SET32_FLAG(bridge->features.capabilities, OFPC_PORT_STATS); SET32_FLAG(bridge->features.capabilities, OFPC_GROUP_STATS); UNSET32_FLAG(bridge->features.capabilities, OFPC_IP_REASM); SET32_FLAG(bridge->features.capabilities, OFPC_QUEUE_STATS); UNSET32_FLAG(bridge->features.capabilities, OFPC_PORT_BLOCKED); bridge->switch_config.flags = OFPC_FRAG_NORMAL; bridge->switch_config.miss_send_len = 128; /* Prepare bridge's port vector. */ bridge->ports = vector_alloc(); if (bridge->ports == NULL) { goto out; } /* Allocate flowdb with table 0. */ bridge->flowdb = flowdb_alloc(1); if (bridge->flowdb == NULL) { goto out; } /* Allocate group table. */ bridge->group_table = group_table_alloc(bridge); if (bridge->group_table == NULL) { goto out; } /* Allocate meter table. */ bridge->meter_table = meter_table_alloc(); if (bridge->meter_table == NULL) { goto out; } /* Return bridge. */ return bridge; out: bridge_free(bridge); return NULL; }