int main(int argc, char* argv[]) { int rv = 0; auto options = handleCmdLine(argc, argv); handleProfileMap(options.profileMapFile); handlePortMap(options.portMapFile); sai_api_initialize(0, &test_services); sai_api_query(SAI_API_SWITCH, (void**)&sai_switch_api); constexpr std::uint32_t attrSz = 6; sai_attribute_t attr[attrSz]; std::memset(attr, '\0', sizeof(attr)); attr[0].id = SAI_SWITCH_ATTR_INIT_SWITCH; attr[0].value.booldata = true; attr[1].id = SAI_SWITCH_ATTR_SWITCH_STATE_CHANGE_NOTIFY; attr[1].value.ptr = reinterpret_cast<sai_pointer_t>(&on_switch_state_change); attr[2].id = SAI_SWITCH_ATTR_SHUTDOWN_REQUEST_NOTIFY; attr[2].value.ptr = reinterpret_cast<sai_pointer_t>(&on_shutdown_request); attr[3].id = SAI_SWITCH_ATTR_FDB_EVENT_NOTIFY; attr[3].value.ptr = reinterpret_cast<sai_pointer_t>(&on_fdb_event); attr[4].id = SAI_SWITCH_ATTR_PORT_STATE_CHANGE_NOTIFY; attr[4].value.ptr = reinterpret_cast<sai_pointer_t>(&on_port_state_change); attr[5].id = SAI_SWITCH_ATTR_PACKET_EVENT_NOTIFY; attr[5].value.ptr = reinterpret_cast<sai_pointer_t>(&on_packet_event); sai_status_t status = sai_switch_api->create_switch(&gSwitchId, attrSz, attr); if (status != SAI_STATUS_SUCCESS) { exit(EXIT_FAILURE); } handleInitScript(options.initScript); #ifdef BRCMSAI std::thread bcm_diag_shell_thread = std::thread(sai_diag_shell); bcm_diag_shell_thread.detach(); #endif start_sai_thrift_rpc_server(SWITCH_SAI_THRIFT_RPC_SERVER_PORT); sai_log_set(SAI_API_SWITCH, SAI_LOG_LEVEL_NOTICE); sai_log_set(SAI_API_BRIDGE, SAI_LOG_LEVEL_NOTICE); sai_log_set(SAI_API_FDB, SAI_LOG_LEVEL_NOTICE); sai_log_set(SAI_API_PORT, SAI_LOG_LEVEL_NOTICE); sai_log_set(SAI_API_VLAN, SAI_LOG_LEVEL_NOTICE); sai_log_set(SAI_API_ROUTE, SAI_LOG_LEVEL_NOTICE); sai_log_set(SAI_API_VIRTUAL_ROUTER, SAI_LOG_LEVEL_NOTICE); sai_log_set(SAI_API_ROUTER_INTERFACE, SAI_LOG_LEVEL_NOTICE); sai_log_set(SAI_API_NEXT_HOP, SAI_LOG_LEVEL_NOTICE); sai_log_set(SAI_API_NEXT_HOP_GROUP, SAI_LOG_LEVEL_NOTICE); sai_log_set(SAI_API_NEIGHBOR, SAI_LOG_LEVEL_NOTICE); sai_log_set(SAI_API_ACL, SAI_LOG_LEVEL_NOTICE); sai_log_set(SAI_API_MIRROR, SAI_LOG_LEVEL_NOTICE); sai_log_set(SAI_API_LAG, SAI_LOG_LEVEL_NOTICE); sai_log_set(SAI_API_BUFFER, SAI_LOG_LEVEL_NOTICE); sai_log_set(SAI_API_POLICER, SAI_LOG_LEVEL_NOTICE); sai_log_set(SAI_API_WRED, SAI_LOG_LEVEL_NOTICE); sai_log_set(SAI_API_QOS_MAP, SAI_LOG_LEVEL_NOTICE); while (1) pause(); return rv; }
void stpTest ::SetUpTestCase (void) { sai_switch_notification_t notification; memset (¬ification, 0, sizeof(sai_switch_notification_t)); memset(¬ification, 0, sizeof(sai_switch_notification_t)); /* * Query and populate the SAI Switch API Table. */ EXPECT_EQ (SAI_STATUS_SUCCESS, sai_api_query (SAI_API_SWITCH, (static_cast<void**> (static_cast<void*>(&p_sai_switch_api_tbl))))); ASSERT_TRUE (p_sai_switch_api_tbl != NULL); /* * Switch Initialization. */ ASSERT_TRUE(p_sai_switch_api_tbl->initialize_switch != NULL); /* * Fill in notification callback routines with stubs. */ notification.on_switch_state_change = sai_switch_operstate_callback; notification.on_fdb_event = sai_fdb_evt_callback; notification.on_port_state_change = sai_port_state_evt_callback; notification.on_switch_shutdown_request = sai_switch_shutdown_callback; notification.on_packet_event = sai_packet_event_callback; notification.on_port_event = sai_port_evt_callback; EXPECT_EQ (SAI_STATUS_SUCCESS, (p_sai_switch_api_tbl->initialize_switch (0, NULL, NULL, ¬ification))); /* * Query and populate the SAI Virtual Router API Table. */ EXPECT_EQ (SAI_STATUS_SUCCESS, sai_api_query (SAI_API_VLAN, (static_cast<void**> (static_cast<void*> (&p_sai_vlan_api_tbl))))); ASSERT_TRUE (p_sai_vlan_api_tbl != NULL); /* * Query and populate the SAI Virtual Router API Table. */ EXPECT_EQ (SAI_STATUS_SUCCESS, sai_api_query (SAI_API_STP, (static_cast<void**> (static_cast<void*> (&p_sai_stp_api_tbl))))); ASSERT_TRUE (p_sai_stp_api_tbl != NULL); sai_port_id_1 = sai_stp_port_id_get (0); }
static void SetUpTestCase() { sai_switch_api_t *p_sai_switch_api_tbl = NULL; sai_switch_notification_t notification; memset (¬ification, 0, sizeof(sai_switch_notification_t)); /* * Query and populate the SAI Switch API Table. */ EXPECT_EQ (SAI_STATUS_SUCCESS, sai_api_query (SAI_API_SWITCH, (static_cast<void**> (static_cast<void*>(&p_sai_switch_api_tbl))))); ASSERT_TRUE (p_sai_switch_api_tbl != NULL); /* * Switch Initialization. * Fill in notification callback routines with stubs. */ notification.on_switch_state_change = sai_switch_operstate_callback; notification.on_fdb_event = sai_fdb_evt_callback; notification.on_port_state_change = sai_port_state_evt_callback; notification.on_switch_shutdown_request = sai_switch_shutdown_callback; notification.on_port_event = sai_port_evt_callback; notification.on_packet_event = sai_packet_event_callback; ASSERT_TRUE(p_sai_switch_api_tbl->initialize_switch != NULL); EXPECT_EQ (SAI_STATUS_SUCCESS, (p_sai_switch_api_tbl->initialize_switch (0, NULL, NULL, ¬ification))); ASSERT_EQ(NULL,sai_api_query(SAI_API_FDB, (static_cast<void**>(static_cast<void*>(&sai_fdb_api_table))))); ASSERT_TRUE(sai_fdb_api_table != NULL); EXPECT_TRUE(sai_fdb_api_table->create_fdb_entry != NULL); EXPECT_TRUE(sai_fdb_api_table->remove_fdb_entry != NULL); EXPECT_TRUE(sai_fdb_api_table->get_fdb_entry_attribute != NULL); EXPECT_TRUE(sai_fdb_api_table->set_fdb_entry_attribute != NULL); EXPECT_TRUE(sai_fdb_api_table->flush_fdb_entries != NULL); port_id_1 = port_list[0]; port_id_2 = port_list[port_count-1]; }
void test_enable_recording() { SWSS_LOG_ENTER(); sai_attribute_t attr; attr.id = SAI_REDIS_SWITCH_ATTR_RECORD; attr.value.booldata = true; sai_switch_api_t *sai_switch_api = NULL; sai_api_query(SAI_API_SWITCH, (void**)&sai_switch_api); sai_status_t status = sai_switch_api->set_switch_attribute(SAI_NULL_OBJECT_ID, &attr); ASSERT_SUCCESS("Failed to enable recording"); }
void test_bulk_route_set() { SWSS_LOG_ENTER(); swss::Logger::getInstance().setMinPrio(swss::Logger::SWSS_NOTICE); clearDB(); meta_init_db(); redis_clear_switch_ids(); swss::Logger::getInstance().setMinPrio(swss::Logger::SWSS_DEBUG); sai_status_t status; sai_route_api_t *sai_route_api = NULL; sai_switch_api_t *sai_switch_api = NULL; sai_api_query(SAI_API_ROUTE, (void**)&sai_route_api); sai_api_query(SAI_API_SWITCH, (void**)&sai_switch_api); uint32_t count = 3; std::vector<sai_route_entry_t> routes; std::vector<sai_attribute_t> attrs; uint32_t index = 15; sai_attribute_t swattr; swattr.id = SAI_SWITCH_ATTR_INIT_SWITCH; swattr.value.booldata = true; sai_object_id_t switch_id; status = sai_switch_api->create_switch(&switch_id, 1, &swattr); ASSERT_SUCCESS("Failed to create switch"); std::vector<std::vector<sai_attribute_t>> route_attrs; std::vector<sai_attribute_t *> route_attrs_array; std::vector<uint32_t> route_attrs_count; for (uint32_t i = index; i < index + count; ++i) { sai_route_entry_t route_entry; // virtual router sai_object_id_t vr = create_dummy_object_id(SAI_OBJECT_TYPE_VIRTUAL_ROUTER); object_reference_insert(vr); sai_object_meta_key_t meta_key_vr = { .objecttype = SAI_OBJECT_TYPE_VIRTUAL_ROUTER, .objectkey = { .key = { .object_id = vr } } }; std::string vr_key = sai_serialize_object_meta_key(meta_key_vr); ObjectAttrHash[vr_key] = { }; // next hop sai_object_id_t hop = create_dummy_object_id(SAI_OBJECT_TYPE_NEXT_HOP); object_reference_insert(hop); sai_object_meta_key_t meta_key_hop = { .objecttype = SAI_OBJECT_TYPE_NEXT_HOP, .objectkey = { .key = { .object_id = hop } } }; std::string hop_key = sai_serialize_object_meta_key(meta_key_hop); ObjectAttrHash[hop_key] = { }; route_entry.destination.addr_family = SAI_IP_ADDR_FAMILY_IPV4; route_entry.destination.addr.ip4 = htonl(0x0a000000 | i); route_entry.destination.mask.ip4 = htonl(0xffffffff); route_entry.vr_id = vr; route_entry.switch_id = switch_id; route_entry.destination.addr_family = SAI_IP_ADDR_FAMILY_IPV4; routes.push_back(route_entry); std::vector<sai_attribute_t> list(2); sai_attribute_t &attr1 = list[0]; sai_attribute_t &attr2 = list[1]; attr1.id = SAI_ROUTE_ENTRY_ATTR_NEXT_HOP_ID; attr1.value.oid = hop; attr2.id = SAI_ROUTE_ENTRY_ATTR_PACKET_ACTION; attr2.value.s32 = SAI_PACKET_ACTION_FORWARD; route_attrs.push_back(list); route_attrs_count.push_back(2); } for (size_t j = 0; j < route_attrs.size(); j++) { route_attrs_array.push_back(route_attrs[j].data()); } std::vector<sai_status_t> statuses(count); status = sai_bulk_create_route_entry(count, routes.data(), route_attrs_count.data(), route_attrs_array.data() , SAI_BULK_OP_TYPE_INGORE_ERROR, statuses.data()); ASSERT_SUCCESS("Failed to create route"); for (size_t j = 0; j < statuses.size(); j++) { status = statuses[j]; ASSERT_SUCCESS("Failed to create route # %zu", j); } for (uint32_t i = index; i < index + count; ++i) { sai_attribute_t attr; attr.id = SAI_ROUTE_ENTRY_ATTR_PACKET_ACTION; attr.value.s32 = SAI_PACKET_ACTION_DROP; status = sai_route_api->set_route_entry_attribute(&routes[i - index], &attr); attrs.push_back(attr); ASSERT_SUCCESS("Failed to set route"); } statuses.clear(); statuses.resize(attrs.size()); for (auto &attr: attrs) { attr.value.s32 = SAI_PACKET_ACTION_FORWARD; } status = sai_bulk_set_route_entry_attribute( count, routes.data(), attrs.data(), SAI_BULK_OP_TYPE_INGORE_ERROR, statuses.data()); ASSERT_SUCCESS("Failed to bulk set route"); for (auto s: statuses) { status = s; ASSERT_SUCCESS("Failed to bulk set route on one of the routes"); } // TODO we need to add consumer producer test here to see // if after consume we get pop we get expectd parameters // Remove route entry status = sai_bulk_remove_route_entry(count, routes.data(), SAI_BULK_OP_TYPE_INGORE_ERROR, statuses.data()); ASSERT_SUCCESS("Failed to bulk remove route entry"); }
void test_bulk_fdb_create() { SWSS_LOG_ENTER(); swss::Logger::getInstance().setMinPrio(swss::Logger::SWSS_NOTICE); clearDB(); meta_init_db(); redis_clear_switch_ids(); swss::Logger::getInstance().setMinPrio(swss::Logger::SWSS_DEBUG); sai_status_t status; sai_route_api_t *sai_fdb_api = NULL; sai_switch_api_t *sai_switch_api = NULL; sai_api_query(SAI_API_FDB, (void**)&sai_fdb_api); sai_api_query(SAI_API_SWITCH, (void**)&sai_switch_api); uint32_t count = 3; std::vector<sai_fdb_entry_t> fdbs; uint32_t index = 15; sai_attribute_t swattr; swattr.id = SAI_SWITCH_ATTR_INIT_SWITCH; swattr.value.booldata = true; sai_object_id_t switch_id; status = sai_switch_api->create_switch(&switch_id, 1, &swattr); ASSERT_SUCCESS("Failed to create switch"); std::vector<std::vector<sai_attribute_t>> fdb_attrs; std::vector<sai_attribute_t *> fdb_attrs_array; std::vector<uint32_t> fdb_attrs_count; for (uint32_t i = index; i < index + count; ++i) { // virtual router sai_object_id_t vr = create_dummy_object_id(SAI_OBJECT_TYPE_VIRTUAL_ROUTER); object_reference_insert(vr); sai_object_meta_key_t meta_key_vr = { .objecttype = SAI_OBJECT_TYPE_VIRTUAL_ROUTER, .objectkey = { .key = { .object_id = vr } } }; std::string vr_key = sai_serialize_object_meta_key(meta_key_vr); ObjectAttrHash[vr_key] = { }; // bridge port sai_object_id_t bridge_port = create_dummy_object_id(SAI_OBJECT_TYPE_BRIDGE_PORT); object_reference_insert(bridge_port); sai_object_meta_key_t meta_key_bridge_port = { .objecttype = SAI_OBJECT_TYPE_BRIDGE_PORT, .objectkey = { .key = { .object_id = bridge_port } } }; std::string bridge_port_key = sai_serialize_object_meta_key(meta_key_bridge_port); ObjectAttrHash[bridge_port_key] = { }; sai_fdb_entry_t fdb_entry; fdb_entry.switch_id = switch_id; memset(fdb_entry.mac_address, 0, sizeof(sai_mac_t)); fdb_entry.mac_address[0] = 0xD; fdb_entry.bridge_type = SAI_FDB_ENTRY_BRIDGE_TYPE_1Q; fdb_entry.vlan_id = (unsigned short)(1011 + i); fdb_entry.bridge_id = SAI_NULL_OBJECT_ID; fdbs.push_back(fdb_entry); std::vector<sai_attribute_t> attrs; sai_attribute_t attr; attr.id = SAI_FDB_ENTRY_ATTR_TYPE; attr.value.s32 = (i % 2) ? SAI_FDB_ENTRY_TYPE_DYNAMIC : SAI_FDB_ENTRY_TYPE_STATIC; attrs.push_back(attr); attr.id = SAI_FDB_ENTRY_ATTR_BRIDGE_PORT_ID; attr.value.oid = bridge_port; attrs.push_back(attr); attr.id = SAI_FDB_ENTRY_ATTR_PACKET_ACTION; attr.value.s32 = SAI_PACKET_ACTION_FORWARD; attrs.push_back(attr); fdb_attrs.push_back(attrs); fdb_attrs_count.push_back((unsigned int)attrs.size()); } for (size_t j = 0; j < fdb_attrs.size(); j++) { fdb_attrs_array.push_back(fdb_attrs[j].data()); } std::vector<sai_status_t> statuses(count); status = sai_bulk_create_fdb_entry(count, fdbs.data(), fdb_attrs_count.data(), fdb_attrs_array.data() , SAI_BULK_OP_TYPE_INGORE_ERROR, statuses.data()); ASSERT_SUCCESS("Failed to create fdb"); for (size_t j = 0; j < statuses.size(); j++) { status = statuses[j]; ASSERT_SUCCESS("Failed to create route # %zu", j); } // Remove route entry status = sai_bulk_remove_fdb_entry(count, fdbs.data(), SAI_BULK_OP_TYPE_INGORE_ERROR, statuses.data()); ASSERT_SUCCESS("Failed to bulk remove route entry"); }
void test_bulk_next_hop_group_member_create() { SWSS_LOG_ENTER(); swss::Logger::getInstance().setMinPrio(swss::Logger::SWSS_NOTICE); clearDB(); meta_init_db(); redis_clear_switch_ids(); auto consumerThreads = new std::thread(bulk_nhgm_consumer_worker); swss::Logger::getInstance().setMinPrio(swss::Logger::SWSS_DEBUG); sai_status_t status; sai_next_hop_group_api_t *sai_next_hop_group_api = NULL; sai_switch_api_t *sai_switch_api = NULL; sai_api_query(SAI_API_NEXT_HOP_GROUP, (void**)&sai_next_hop_group_api); sai_api_query(SAI_API_SWITCH, (void**)&sai_switch_api); uint32_t count = 3; std::vector<sai_route_entry_t> routes; std::vector<sai_attribute_t> attrs; sai_attribute_t swattr; swattr.id = SAI_SWITCH_ATTR_INIT_SWITCH; swattr.value.booldata = true; sai_object_id_t switch_id; status = sai_switch_api->create_switch(&switch_id, 1, &swattr); ASSERT_SUCCESS("Failed to create switch"); std::vector<std::vector<sai_attribute_t>> nhgm_attrs; std::vector<sai_attribute_t *> nhgm_attrs_array; std::vector<uint32_t> nhgm_attrs_count; // next hop group sai_object_id_t hopgroup = create_dummy_object_id(SAI_OBJECT_TYPE_NEXT_HOP_GROUP); object_reference_insert(hopgroup); sai_object_meta_key_t meta_key_hopgruop = { .objecttype = SAI_OBJECT_TYPE_NEXT_HOP_GROUP, .objectkey = { .key = { .object_id = hopgroup } } }; std::string hopgroup_key = sai_serialize_object_meta_key(meta_key_hopgruop); ObjectAttrHash[hopgroup_key] = { }; sai_object_id_t hopgroup_vid = translate_rid_to_vid(hopgroup, switch_id); for (uint32_t i = 0; i < count; ++i) { // next hop sai_object_id_t hop = create_dummy_object_id(SAI_OBJECT_TYPE_NEXT_HOP); object_reference_insert(hop); sai_object_meta_key_t meta_key_hop = { .objecttype = SAI_OBJECT_TYPE_NEXT_HOP, .objectkey = { .key = { .object_id = hop } } }; std::string hop_key = sai_serialize_object_meta_key(meta_key_hop); ObjectAttrHash[hop_key] = { }; sai_object_id_t hop_vid = translate_rid_to_vid(hop, switch_id); std::vector<sai_attribute_t> list(2); sai_attribute_t &attr1 = list[0]; sai_attribute_t &attr2 = list[1]; attr1.id = SAI_NEXT_HOP_GROUP_MEMBER_ATTR_NEXT_HOP_GROUP_ID; attr1.value.oid = hopgroup_vid; attr2.id = SAI_NEXT_HOP_GROUP_MEMBER_ATTR_NEXT_HOP_ID; attr2.value.oid = hop_vid; nhgm_attrs.push_back(list); nhgm_attrs_count.push_back(2); } for (size_t j = 0; j < nhgm_attrs.size(); j++) { nhgm_attrs_array.push_back(nhgm_attrs[j].data()); } std::vector<sai_status_t> statuses(count); std::vector<sai_object_id_t> object_id(count); sai_bulk_create_next_hop_group_members(switch_id, count, nhgm_attrs_count.data(), nhgm_attrs_array.data() , SAI_BULK_OP_TYPE_INGORE_ERROR, object_id.data(), statuses.data()); ASSERT_SUCCESS("Failed to bulk create nhgm"); for (size_t j = 0; j < statuses.size(); j++) { status = statuses[j]; ASSERT_SUCCESS("Failed to create nhgm # %zu", j); } consumerThreads->join(); delete consumerThreads; // check the created nhgm for (size_t i = 0; i < created_next_hop_group_member.size(); i++) { auto& created = created_next_hop_group_member[i]; auto& created_attrs = std::get<2>(created); assert(created_attrs.size() == 2); assert(created_attrs[1].value.oid == nhgm_attrs[i][1].value.oid); } status = sai_bulk_remove_next_hop_group_members(count, object_id.data(), SAI_BULK_OP_TYPE_INGORE_ERROR, statuses.data()); ASSERT_SUCCESS("Failed to bulk remove nhgm"); }
void sai_simple_setup( void ) { // printf("Simple SAI setup\n"); sai_api_query(SAI_API_SWITCH, (void **)&switch_api); if(switch_api) { sai_attribute_t attr1[2]; attr1[0].id = SAI_SWITCH_ATTR_OPER_STATUS; attr1[0].value.u32 = 1; attr1[1].id = SAI_SWITCH_ATTR_SRC_MAC_ADDRESS; attr1[1].value.u32 = 0x22222200; switch_api->create_switch(2, attr1); } sai_api_query(SAI_API_PORT, (void **)&port_api); if(port_api) { sai_port_entry_t port1 = {1}; sai_attribute_t attr1[2]; attr1[0].id = SAI_PORT_ATTR_OPER_STATUS; attr1[0].value.u32 = 1; attr1[1].id = SAI_PORT_ATTR_FDB_LEARNING; attr1[1].value.u32 = 2; port_api->create_port(&port1, 2, attr1); } sai_api_query(SAI_API_ROUTER_INTERFACE, (void **)&router_interface_api); if(router_interface_api) { sai_router_interface_entry_t router1 = {{0x00, 0x12, 0x34, 0x56, 0x78, 0x90}}; sai_attribute_t attr1[2]; attr1[0].id = SAI_ROUTER_INTERFACE_ATTR_PORT_ID; attr1[0].value.u32 = 2; attr1[1].id = SAI_ROUTER_INTERFACE_ATTR_VIRTUAL_ROUTER_ID; attr1[1].value.u32 = 10; router_interface_api->create_router_interface(&router1, 2, attr1); } sai_api_query(SAI_API_FDB, (void **)&fdb_api); if(fdb_api) { sai_fdb_entry_t fdb1 = {0, {0x00, 0x11, 0x11, 0x11, 0x11, 0x11}}; sai_attribute_t attr1; attr1.id = SAI_FDB_ATTR_PORT_ID; attr1.value.u32 = 2; fdb_api->create_fdb(&fdb1, 1, &attr1); } sai_api_query(SAI_API_VIRTUAL_ROUTER, (void **)&virtual_router_api); if(virtual_router_api) { sai_virtual_router_entry_t virtual_router1 = {10}; sai_attribute_t attr1[2]; attr1[0].id = SAI_VIRTUAL_ROUTER_ATTR_ADMIN_V4_STATE; attr1[0].value.u32 = 1; attr1[1].id = SAI_VIRTUAL_ROUTER_ATTR_SRC_MAC_ADDRESS; attr1[1].value.u32 = 0x22222200; virtual_router_api->create_virtual_router(&virtual_router1, 2, attr1); } sai_api_query(SAI_API_ROUTE, (void **)&route_api); if(route_api) { sai_route_entry_t route1 = {10, 0x0a000001}; sai_attribute_t attr1; attr1.id = SAI_ROUTE_ATTR_NEXT_HOP_ID; attr1.value.u32 = 1; route_api->create_route(&route1, 1, &attr1); } sai_api_query(SAI_API_NEXT_HOP, (void **)&next_hop_api); if(next_hop_api) { sai_next_hop_entry_t nexthop1 = {1}; sai_attribute_t attr1; attr1.id = SAI_NEXT_HOP_ATTR_ROUTER_INTERFACE_ID; attr1.value.u32 = 2; next_hop_api->create_next_hop(&nexthop1, 1, &attr1); } sai_api_query(SAI_API_NEIGHBOR, (void **)&neighbor_api); if(neighbor_api) { sai_neighbor_entry_t neighbor1 = {10, 0x0a000001, 2}; sai_attribute_t attr1[2]; attr1[0].id = SAI_NEIGHBOR_ATTR_PORT_ID; attr1[0].value.u32 = 3; attr1[1].id = SAI_NEIGHBOR_ATTR_DST_MAC_ADDRESS; attr1[1].value.u32 = 2; neighbor_api->create_neighbor(&neighbor1, 2, attr1); } }
void switchlink_api_init() { sai_status_t status = SAI_STATUS_SUCCESS; sai_initialize(); status = sai_api_query(SAI_API_SWITCH, (void **)&switch_api); assert(status == SAI_STATUS_SUCCESS); status = sai_api_query(SAI_API_VIRTUAL_ROUTER, (void **)&vrf_api); assert(status == SAI_STATUS_SUCCESS); status = sai_api_query(SAI_API_VLAN, (void **)&vlan_api); assert(status == SAI_STATUS_SUCCESS); status = sai_api_query(SAI_API_STP, (void **)&stp_api); assert(status == SAI_STATUS_SUCCESS); status = sai_api_query(SAI_API_FDB, (void **)&fdb_api); assert(status == SAI_STATUS_SUCCESS); status = sai_api_query(SAI_API_ROUTER_INTERFACE, (void **)&rintf_api); assert(status == SAI_STATUS_SUCCESS); status = sai_api_query(SAI_API_NEIGHBOR, (void **)&neigh_api); assert(status == SAI_STATUS_SUCCESS); status = sai_api_query(SAI_API_NEXT_HOP, (void **)&nhop_api); assert(status == SAI_STATUS_SUCCESS); status = sai_api_query(SAI_API_NEXT_HOP_GROUP, (void **)&nhop_group_api); assert(status == SAI_STATUS_SUCCESS); status = sai_api_query(SAI_API_ROUTE, (void **)&route_api); assert(status == SAI_STATUS_SUCCESS); status = sai_api_query(SAI_API_IPMC, (void **)&ipmc_api); assert(status == SAI_STATUS_SUCCESS); status = sai_api_query(SAI_API_L2MC, (void **)&l2mc_api); assert(status == SAI_STATUS_SUCCESS); status = sai_api_query(SAI_API_HOST_INTERFACE, (void **)&host_intf_api); assert(status == SAI_STATUS_SUCCESS); status = sai_api_query(SAI_API_ACL, (void **)&acl_api); assert(status == SAI_STATUS_SUCCESS); register_sai_notifications(); register_sai_traps(); get_port_list(); }