コード例 #1
0
ファイル: bridge_test.c プロジェクト: 1514louluo/lagopus
void
test_bridge_ofp_version(void) {
  uint8_t ver;
  lagopus_result_t rv;

  rv = bridge_ofp_version_get(bridge, &ver);
  TEST_ASSERT_EQUAL(rv, LAGOPUS_RESULT_OK);
  rv = bridge_ofp_version_set(bridge, 0);
  TEST_ASSERT_EQUAL(rv, LAGOPUS_RESULT_INVALID_ARGS);
  rv = bridge_ofp_version_set(bridge, OPENFLOW_VERSION_1_3);
  TEST_ASSERT_EQUAL(rv, LAGOPUS_RESULT_OK);
  rv = bridge_ofp_version_set(bridge, OPENFLOW_VERSION_1_4);
  TEST_ASSERT_EQUAL(rv, LAGOPUS_RESULT_OK);
}
コード例 #2
0
ファイル: dpmgr.c プロジェクト: chenchijung/lagopus
lagopus_result_t
dpmgr_bridge_ofp_version_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_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;
}
コード例 #3
0
ファイル: bridge.c プロジェクト: D-TOKIOKA/lagopus
/* 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;
}