/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include "htcs_manager_service_object.hpp" #include "htcs_socket_service_object.hpp" #include "htcs_service_object_allocator.hpp" #include "../impl/htcs_manager.hpp" #include "../impl/htcs_impl.hpp" namespace ams::htcs::server { namespace { class StaticAllocatorInitializer { public: StaticAllocatorInitializer() { ServiceObjectAllocator::Initialize(lmem::CreateOption_ThreadSafe); } } g_static_allocator_initializer; } Result ManagerServiceObject::GetPeerNameAny(sf::Out out) { *out = impl::GetPeerNameAny(); R_SUCCEED(); } Result ManagerServiceObject::GetDefaultHostName(sf::Out out) { *out = impl::GetDefaultHostName(); R_SUCCEED(); } Result ManagerServiceObject::CreateSocketOld(sf::Out out_err, sf::Out> out) { return this->CreateSocket(out_err, out, false); } Result ManagerServiceObject::CreateSocket(sf::Out out_err, sf::Out> out, bool enable_disconnection_emulation) { /* Get the htcs manager. */ auto *manager = impl::HtcsManagerHolder::GetHtcsManager(); /* Create a new socket. */ s32 desc; manager->Socket(out_err.GetPointer(), std::addressof(desc), enable_disconnection_emulation); /* If an error occurred, we're done. */ R_SUCCEED_IF(*out_err != 0); /* Create a new socket object. */ *out = ServiceObjectFactory::CreateSharedEmplaced(this, desc); R_SUCCEED(); } Result ManagerServiceObject::RegisterProcessId(const sf::ClientProcessId &client_pid) { /* NOTE: Nintendo does nothing here. */ AMS_UNUSED(client_pid); R_SUCCEED(); } Result ManagerServiceObject::MonitorManager(const sf::ClientProcessId &client_pid) { /* NOTE: Nintendo does nothing here. */ AMS_UNUSED(client_pid); R_SUCCEED(); } Result ManagerServiceObject::StartSelect(sf::Out out_task_id, sf::OutCopyHandle out_event, const sf::InMapAliasArray &read_handles, const sf::InMapAliasArray &write_handles, const sf::InMapAliasArray &exception_handles, s64 tv_sec, s64 tv_usec) { /* Get the htcs manager. */ auto *manager = impl::HtcsManagerHolder::GetHtcsManager(); /* Start the select. */ os::NativeHandle event_handle; R_TRY(manager->StartSelect(out_task_id.GetPointer(), std::addressof(event_handle), read_handles.ToSpan(), write_handles.ToSpan(), exception_handles.ToSpan(), tv_sec, tv_usec)); /* Set the output event handle. */ out_event.SetValue(event_handle, true); R_SUCCEED(); } Result ManagerServiceObject::EndSelect(sf::Out out_err, sf::Out out_count, const sf::OutMapAliasArray &read_handles, const sf::OutMapAliasArray &write_handles, const sf::OutMapAliasArray &exception_handles, u32 task_id) { /* Get the htcs manager. */ auto *manager = impl::HtcsManagerHolder::GetHtcsManager(); /* End the select. */ return manager->EndSelect(out_err.GetPointer(), out_count.GetPointer(), read_handles.ToSpan(), write_handles.ToSpan(), exception_handles.ToSpan(), task_id); } }