struct channel * create_data_channel(void) { static uint8_t cnt; char buf[256]; struct channel *channel; struct session *session; struct addrunion addr; struct port port; uint64_t dpid = 0xabc; uint8_t port_hw_addr[OFP_ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; if (s_dpmgr == NULL) { s_dpmgr = dpmgr_alloc(); dpmgr_bridge_add(s_dpmgr, "br0", dpid); dpmgr_controller_add(s_dpmgr, "br0", "127.0.0.1"); port.ofp_port.port_no = 0; memcpy(port.ofp_port.hw_addr, port_hw_addr, OFP_ETH_ALEN); port.ifindex = 0; dpmgr_port_add(s_dpmgr, &port); dpmgr_bridge_port_add(s_dpmgr, "br0", 0, 0); } if (s_bridge == NULL) { s_bridge = dpmgr_bridge_lookup(s_dpmgr, "br0"); } if (s_event_manager == NULL) { s_event_manager = event_manager_alloc(); channel_mgr_initialize(s_event_manager); } snprintf(buf, sizeof(buf), "127.0.0.%u", cnt++);//XXX addrunion_ipv4_set(&addr, buf); channel_mgr_channel_add(s_bridge, dpid, &addr); channel_mgr_channel_lookup(s_bridge, &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; }
struct channel * s_create_data_channel(void) { uint64_t dpid = 0x01; struct channel *channel; lagopus_session_t session; struct addrunion addr = {0,{{0}}}; addrunion_ipv4_set(&addr, "127.0.0.1"); channel = channel_alloc(&addr, dpid); (void) session_create(SESSION_TCP|SESSION_ACTIVE, &session); session_write_set(session, write_tcp); channel_version_set(channel, 0x04); channel_session_set(channel, session); channel_xid_set(channel, 0x10); return channel; }
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; }