예제 #1
0
void
setUp(void) {

  /* Event manager allocation. */
  /* init datapath. */
  TEST_ASSERT_EQUAL(dp_api_init(), LAGOPUS_RESULT_OK);

  /* interface. */
  interface_info.type = DATASTORE_INTERFACE_TYPE_ETHERNET_RAWSOCK;
  interface_info.eth_rawsock.port_number = 0;
  interface_info.eth_dpdk_phy.device = strdup("eth0");
  if (interface_info.eth_dpdk_phy.device == NULL) {
    TEST_FAIL_MESSAGE("device is NULL.");
  }
  TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK,
                    dp_interface_create(interface_name));
  dp_interface_info_set(interface_name, &interface_info);

  /* port. */
  TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK,
                    dp_port_create(port_name));
  TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK,
                    dp_port_interface_set(port_name, interface_name));

  /* bridge. */
  bridge_info.dpid = dpid;
  bridge_info.fail_mode = DATASTORE_BRIDGE_FAIL_MODE_SECURE;
  bridge_info.max_buffered_packets = UINT32_MAX;
  bridge_info.max_ports = UINT16_MAX;
  bridge_info.max_tables = UINT8_MAX;
  bridge_info.max_flows = UINT32_MAX;
  bridge_info.capabilities = UINT64_MAX;
  bridge_info.action_types = UINT64_MAX;
  bridge_info.instruction_types = UINT64_MAX;
  bridge_info.reserved_port_types = UINT64_MAX;
  bridge_info.group_types = UINT64_MAX;
  bridge_info.group_capabilities = UINT64_MAX;
  TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK,
                    dp_bridge_create(bridge_name, &bridge_info));
  TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK,
                    dp_bridge_port_set(bridge_name, port_name, 0));
}
예제 #2
0
struct channel *
create_data_channel(void) {
  static uint8_t cnt;
  char buf[256];
  struct channel *channel;
  lagopus_session_t session;
  struct addrunion addr;
  uint64_t dpid = 0xabc;

  if (s_is_init == false) {
    s_is_init = true;

    /* init dataplane. */
    TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK, dp_api_init());

    /* interface. */
    s_interface_info.type = DATASTORE_INTERFACE_TYPE_ETHERNET_RAWSOCK;
    s_interface_info.eth_rawsock.port_number = 0;
    s_interface_info.eth_dpdk_phy.device = strdup("eth0");
    if (s_interface_info.eth_dpdk_phy.device == NULL) {
      TEST_FAIL_MESSAGE("device is NULL.");
    }
    TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK,
                      dp_interface_create(interface_name));
    dp_interface_info_set(interface_name, &s_interface_info);

    /* port. */
    TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK,
                      dp_port_create(port_name));
    TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK,
                      dp_port_interface_set(port_name, interface_name));

    /* bridge. */
    ofp_bridgeq_mgr_initialize(NULL);
    s_bridge_info.dpid = dpid;
    s_bridge_info.fail_mode = DATASTORE_BRIDGE_FAIL_MODE_SECURE;
    s_bridge_info.max_buffered_packets = UINT32_MAX;
    s_bridge_info.max_ports = UINT16_MAX;
    s_bridge_info.max_tables = UINT8_MAX;
    s_bridge_info.max_flows = UINT32_MAX;
    s_bridge_info.capabilities = UINT64_MAX;
    s_bridge_info.action_types = UINT64_MAX;
    s_bridge_info.instruction_types = UINT64_MAX;
    s_bridge_info.reserved_port_types = UINT64_MAX;
    s_bridge_info.group_types = UINT64_MAX;
    s_bridge_info.group_capabilities = UINT64_MAX;
    TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK,
                      dp_bridge_create(bridge_name, &s_bridge_info));
    TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK,
                      dp_bridge_port_set(bridge_name, port_name, 0));
    TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK,
                      ofp_bridgeq_mgr_bridge_register(
                          dpid,
                          bridge_name,
                          &s_bridge_info,
                          &s_queue_info));
    channel_mgr_initialize();
  }

  snprintf(buf, sizeof(buf), "127.0.0.%u", cnt++);//XXX
  addrunion_ipv4_set(&addr, buf);
  channel_mgr_channel_add(bridge_name, dpid, &addr);
  channel_mgr_channel_lookup(bridge_name, &addr, &channel);


  session = channel_session_get(channel);
  session_write_set(session, s_write_tcp);
  session_sockfd_set(session, 3);

  channel_version_set(channel, 0x04);
  channel_xid_set(channel, s_xid);

  return channel;
}
예제 #3
0
void
setUp(void) {
  struct sockaddr_storage so = {0,0,{0}};
  struct sockaddr_in *sin = (struct sockaddr_in *)&so;
  struct sockaddr_in6 *sin6;

  if (s4 != -1) {
    return;
  }

  sin->sin_family = AF_INET;
  sin->sin_port = htons(10022);
  sin->sin_addr.s_addr = INADDR_ANY;

  s4 = socket(AF_INET, SOCK_STREAM, 0);
  if (s4 < 0) {
    perror("socket");
    exit(1);
  }

  if (bind(s4, (struct sockaddr *) sin, sizeof(*sin)) < 0) {
    perror("bind");
    exit(1);
  }

  if (listen(s4, 5) < 0) {
    perror("listen");
    exit(1);
  }

  sin6 = (struct sockaddr_in6 *)&so;
  sin6->sin6_family = AF_INET6;
  sin6->sin6_port = htons(10023);
  sin6->sin6_addr = in6addr_any;

  s6 = socket(AF_INET6, SOCK_STREAM, 0);
  if (s6 < 0) {
    perror("socket");
    exit(1);
  }

  if (bind(s6, (struct sockaddr *) sin6, sizeof(*sin6)) < 0) {
    perror("bind");
    exit(1);
  }

  if (listen(s6, 5) < 0) {
    perror("listen");
    exit(1);
  }

  /* init datapath. */
  TEST_ASSERT_EQUAL(dp_api_init(), LAGOPUS_RESULT_OK);

  /* interface. */
  interface_info.type = DATASTORE_INTERFACE_TYPE_ETHERNET_RAWSOCK;
  interface_info.eth_rawsock.port_number = 0;
  interface_info.eth_dpdk_phy.device = strdup("eth0");
  if (interface_info.eth_dpdk_phy.device == NULL) {
    TEST_FAIL_MESSAGE("device is NULL.");
  }
  TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK,
                    dp_interface_create(interface_name));
  dp_interface_info_set(interface_name, &interface_info);

  /* port. */
  TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK,
                    dp_port_create(port_name));
  TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK,
                    dp_port_interface_set(port_name, interface_name));

  /* bridge. */
  bridge_info.dpid = dpid;
  bridge_info.fail_mode = DATASTORE_BRIDGE_FAIL_MODE_SECURE;
  bridge_info.max_buffered_packets = UINT32_MAX;
  bridge_info.max_ports = UINT16_MAX;
  bridge_info.max_tables = UINT8_MAX;
  bridge_info.max_flows = UINT32_MAX;
  bridge_info.capabilities = UINT64_MAX;
  bridge_info.action_types = UINT64_MAX;
  bridge_info.instruction_types = UINT64_MAX;
  bridge_info.reserved_port_types = UINT64_MAX;
  bridge_info.group_types = UINT64_MAX;
  bridge_info.group_capabilities = UINT64_MAX;
  TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK,
                    dp_bridge_create(bridge_name, &bridge_info));
  TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK,
                    dp_bridge_port_set(bridge_name, port_name, 0));


  printf("setup end\n");
}