From a2c6a2a4ff6c5ed804f9761f8dd1b82941d2ced0 Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Thu, 9 Jul 2020 14:35:51 +0100 Subject: [PATCH] Add a base socket (bsd) services implementation This stubs enough to pass SMO's socket init. --- app/CMakeLists.txt | 1 + .../main/cpp/skyline/services/base_service.h | 2 ++ .../main/cpp/skyline/services/serviceman.cpp | 4 +++ .../skyline/services/socket/bsd/IClient.cpp | 17 ++++++++++++ .../cpp/skyline/services/socket/bsd/IClient.h | 27 +++++++++++++++++++ 5 files changed, 51 insertions(+) create mode 100644 app/src/main/cpp/skyline/services/socket/bsd/IClient.cpp create mode 100644 app/src/main/cpp/skyline/services/socket/bsd/IClient.h diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index d8026c83..da56ac3d 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -122,6 +122,7 @@ add_library(skyline SHARED ${source_DIR}/skyline/services/nifm/IStaticService.cpp ${source_DIR}/skyline/services/nifm/IGeneralService.cpp ${source_DIR}/skyline/services/nifm/IRequest.cpp + ${source_DIR}/skyline/services/socket/bsd/IClient.cpp ${source_DIR}/skyline/vfs/partition_filesystem.cpp ${source_DIR}/skyline/vfs/rom_filesystem.cpp ${source_DIR}/skyline/vfs/os_backing.cpp diff --git a/app/src/main/cpp/skyline/services/base_service.h b/app/src/main/cpp/skyline/services/base_service.h index a9de1b6c..43ee6e60 100644 --- a/app/src/main/cpp/skyline/services/base_service.h +++ b/app/src/main/cpp/skyline/services/base_service.h @@ -78,6 +78,7 @@ namespace skyline::service { nifm_IStaticService, nifm_IGeneralService, nifm_IRequest, + socket_IClient, }; /** @@ -115,6 +116,7 @@ namespace skyline::service { {"friend:u", Service::friends_IServiceCreator}, {"nfp:user", Service::nfp_IUserManager}, {"nifm:u", Service::nifm_IStaticService}, + {"bsd:u", Service::socket_IClient}, }; class ServiceManager; diff --git a/app/src/main/cpp/skyline/services/serviceman.cpp b/app/src/main/cpp/skyline/services/serviceman.cpp index 303f15ec..30ff6cc5 100644 --- a/app/src/main/cpp/skyline/services/serviceman.cpp +++ b/app/src/main/cpp/skyline/services/serviceman.cpp @@ -24,6 +24,7 @@ #include "friends/IServiceCreator.h" #include "nfp/IUserManager.h" #include "nifm/IStaticService.h" +#include "socket/bsd/IClient.h" #include "serviceman.h" namespace skyline::service { @@ -102,6 +103,9 @@ namespace skyline::service { case Service::nifm_IStaticService: serviceObj = std::make_shared(state, *this); break; + case Service::socket_IClient: + serviceObj = std::make_shared(state, *this); + break; default: throw exception("CreateService called on missing object, type: {}", serviceType); } diff --git a/app/src/main/cpp/skyline/services/socket/bsd/IClient.cpp b/app/src/main/cpp/skyline/services/socket/bsd/IClient.cpp new file mode 100644 index 00000000..6a03d3a6 --- /dev/null +++ b/app/src/main/cpp/skyline/services/socket/bsd/IClient.cpp @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: MPL-2.0 +// Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/) + +#include "IClient.h" + +namespace skyline::service::socket { + IClient::IClient(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::socket_IClient, "socket:IClient", { + {0x0, SFUNC(IClient::RegisterClient)}, + {0x1, SFUNC(IClient::StartMonitoring)}, + }) {} + + void IClient::RegisterClient(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + response.Push(0); + } + + void IClient::StartMonitoring(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {} +} \ No newline at end of file diff --git a/app/src/main/cpp/skyline/services/socket/bsd/IClient.h b/app/src/main/cpp/skyline/services/socket/bsd/IClient.h new file mode 100644 index 00000000..7a5b5caa --- /dev/null +++ b/app/src/main/cpp/skyline/services/socket/bsd/IClient.h @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: MPL-2.0 +// Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/) + +#pragma once + +#include +#include + +namespace skyline::service::socket { + /** + * @brief IClient or bsd:u is used by applications create network sockets (https://switchbrew.org/wiki/Sockets_services#bsd:u.2C_bsd:s) + */ + class IClient : public BaseService { + public: + IClient(const DeviceState &state, ServiceManager &manager); + + /** + * @brief This initializes a socket client with the given parameters (https://switchbrew.org/wiki/Sockets_services#Initialize) + */ + void RegisterClient(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + + /** + * @brief This starts the monitoring of the socket + */ + void StartMonitoring(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + }; +} \ No newline at end of file