Files
eden/src/core/hle/service/ldn/ldn.cpp
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

215 lines
8.6 KiB
C++
Raw Normal View History

// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
2018-07-26 01:16:08 -04:00
2022-08-07 23:54:51 +02:00
#include "core/core.h"
#include "core/hle/service/cmif_serialization.h"
2018-07-26 01:16:08 -04:00
#include "core/hle/service/ldn/ldn.h"
#include "core/hle/service/ldn/monitor_service.h"
#include "core/hle/service/ldn/sf_monitor_service.h"
#include "core/hle/service/ldn/sf_service_monitor.h"
#include "core/hle/service/ldn/system_local_communication_service.h"
#include "core/hle/service/ldn/user_local_communication_service.h"
2018-07-26 01:16:08 -04:00
namespace Service::LDN {
class IClientProcessMonitor final
: public ServiceFramework<IClientProcessMonitor> {
public:
explicit IClientProcessMonitor(Core::System& system_) : ServiceFramework{system_, "IClientProcessMonitor"} {}
std::optional<FunctionInfoBase> FindRequest(u32 key) override {
return HandlerTableGenerateWithFind(key, functions);
}
~IClientProcessMonitor() override = default;
private:
Result RegisterClient(ClientProcessId pid) {
LOG_WARNING(Service_LDN, "(STUBBED) called");
R_SUCCEED();
}
static constexpr auto functions = CreateStaticMap(
FunctionInfo{0, D<&IClientProcessMonitor::RegisterClient>, "RegisterClient"}
);
};
class IMonitorServiceCreator final : public ServiceFramework<IMonitorServiceCreator> {
2018-07-26 01:16:08 -04:00
public:
explicit IMonitorServiceCreator(Core::System& system_) : ServiceFramework{system_, "ldn:m"} {}
std::optional<FunctionInfoBase> FindRequest(u32 key) override {
return HandlerTableGenerateWithFind(key, functions);
}
private:
Result CreateMonitorService(OutInterface<IMonitorService> out_interface) {
LOG_DEBUG(Service_LDN, "called");
*out_interface = std::make_shared<IMonitorService>(system);
R_SUCCEED();
2018-07-26 01:16:08 -04:00
}
static constexpr auto functions = CreateStaticMap(
FunctionInfo{0, C<&IMonitorServiceCreator::CreateMonitorService>, "CreateMonitorService"}
);
2018-07-26 01:16:08 -04:00
};
class ISystemServiceCreator final : public ServiceFramework<ISystemServiceCreator> {
2018-07-26 01:16:08 -04:00
public:
explicit ISystemServiceCreator(Core::System& system_) : ServiceFramework{system_, "ldn:s"} {}
2019-04-10 14:48:37 -04:00
std::optional<FunctionInfoBase> FindRequest(u32 key) override {
return HandlerTableGenerateWithFind(key, functions);
2019-04-10 14:48:37 -04:00
}
private:
Result CreateSystemLocalCommunicationService(
OutInterface<ISystemLocalCommunicationService> out_interface) {
LOG_DEBUG(Service_LDN, "called");
*out_interface = std::make_shared<ISystemLocalCommunicationService>(system);
R_SUCCEED();
2018-07-26 01:16:08 -04:00
}
Result CreateClientProcessMonitor(
OutInterface<IClientProcessMonitor> out_interface) {
LOG_DEBUG(Service_LDN, "called");
*out_interface = std::make_shared<IClientProcessMonitor>(system);
R_SUCCEED();
}
static constexpr auto functions = CreateStaticMap(
FunctionInfo{0, C<&ISystemServiceCreator::CreateSystemLocalCommunicationService>, "CreateSystemLocalCommunicationService"},
FunctionInfo{1, C<&ISystemServiceCreator::CreateClientProcessMonitor>, "CreateClientProcessMonitor", MakeVersionGate({18,0,0})}
);
2018-07-26 01:16:08 -04:00
};
class IUserServiceCreator final : public ServiceFramework<IUserServiceCreator> {
2018-07-26 01:16:08 -04:00
public:
explicit IUserServiceCreator(Core::System& system_) : ServiceFramework{system_, "ldn:u"} {}
2018-07-26 01:16:08 -04:00
std::optional<FunctionInfoBase> FindRequest(u32 key) override {
return HandlerTableGenerateWithFind(key, functions);
2018-07-26 01:16:08 -04:00
}
private:
Result CreateUserLocalCommunicationService(
OutInterface<IUserLocalCommunicationService> out_interface) {
LOG_DEBUG(Service_LDN, "called");
*out_interface = std::make_shared<IUserLocalCommunicationService>(system);
R_SUCCEED();
2018-07-26 01:16:08 -04:00
}
Result CreateClientProcessMonitor(
OutInterface<IClientProcessMonitor> out_interface) {
LOG_DEBUG(Service_LDN, "called");
*out_interface = std::make_shared<IClientProcessMonitor>(system);
R_SUCCEED();
}
static constexpr auto functions = CreateStaticMap(
FunctionInfo{0, D<&IUserServiceCreator::CreateUserLocalCommunicationService>, "CreateUserLocalCommunicationService"},
FunctionInfo{1, D<&IUserServiceCreator::CreateClientProcessMonitor>, "CreateClientProcessMonitor", MakeVersionGate({18,0,0})}
);
};
class ISfService final : public ServiceFramework<ISfService> {
public:
explicit ISfService(Core::System& system_) : ServiceFramework{system_, "ISfService"} {}
~ISfService() override = default;
std::optional<FunctionInfoBase> FindRequest(u32 key) override {
return HandlerTableGenerateWithFind(key, functions);
}
static constexpr auto functions = CreateStaticMap(
FunctionInfo{0, nullptr, "Initialize"},
FunctionInfo{256, nullptr, "AttachNetworkInterfaceStateChangeEvent"},
FunctionInfo{264, nullptr, "GetNetworkInterfaceLastError"},
FunctionInfo{272, nullptr, "GetRole"},
FunctionInfo{280, nullptr, "GetAdvertiseData"},
FunctionInfo{288, nullptr, "GetGroupInfo"},
FunctionInfo{296, nullptr, "GetGroupInfo2"},
FunctionInfo{304, nullptr, "GetGroupOwner"},
FunctionInfo{312, nullptr, "GetIpConfig"},
FunctionInfo{320, nullptr, "GetLinkLevel"},
FunctionInfo{512, nullptr, "Scan"},
FunctionInfo{768, nullptr, "CreateGroup"},
FunctionInfo{776, nullptr, "DestroyGroup"},
FunctionInfo{784, nullptr, "SetAdvertiseData"},
FunctionInfo{1536, nullptr, "SendToOtherGroup"},
FunctionInfo{1544, nullptr, "RecvFromOtherGroup"},
FunctionInfo{1552, nullptr, "AddAcceptableGroupId"},
FunctionInfo{1560, nullptr, "ClearAcceptableGroupId"}
);
};
class ISfServiceCreator final : public ServiceFramework<ISfServiceCreator> {
public:
explicit ISfServiceCreator(Core::System& system_, bool is_system_, const char* name_) : ServiceFramework{system_, name_}, is_system{is_system_} {}
std::optional<FunctionInfoBase> FindRequest(u32 key) override {
return HandlerTableGenerateWithFind(key, functions);
}
private:
Result CreateNetworkService(OutInterface<ISfService> out_interface, u32 input,
u64 reserved_input) {
LOG_WARNING(Service_LDN, "(STUBBED) called reserved_input={} input={}", reserved_input,
input);
*out_interface = std::make_shared<ISfService>(system);
R_SUCCEED();
}
Result CreateNetworkServiceMonitor(OutInterface<ISfServiceMonitor> out_interface,
u64 reserved_input) {
LOG_WARNING(Service_LDN, "(STUBBED) called reserved_input={}", reserved_input);
*out_interface = std::make_shared<ISfServiceMonitor>(system);
R_SUCCEED();
}
static constexpr auto functions = CreateStaticMap(
FunctionInfo{0, C<&ISfServiceCreator::CreateNetworkService>, "CreateNetworkService"},
FunctionInfo{8, C<&ISfServiceCreator::CreateNetworkServiceMonitor>, "CreateNetworkServiceMonitor"}
);
bool is_system{};
};
class ISfMonitorServiceCreator final : public ServiceFramework<ISfMonitorServiceCreator> {
public:
explicit ISfMonitorServiceCreator(Core::System& system_) : ServiceFramework{system_, "lp2p:m"} {}
std::optional<FunctionInfoBase> FindRequest(u32 key) override {
return HandlerTableGenerateWithFind(key, functions);
}
private:
Result CreateMonitorService(OutInterface<ISfMonitorService> out_interface, u64 reserved_input) {
LOG_INFO(Service_LDN, "called, reserved_input={}", reserved_input);
*out_interface = std::make_shared<ISfMonitorService>(system);
R_SUCCEED();
}
static constexpr auto functions = CreateStaticMap(
FunctionInfo{0, C<&ISfMonitorServiceCreator::CreateMonitorService>, "CreateMonitorService"}
);
};
2023-02-18 16:26:48 -05:00
void LoopProcess(Core::System& system) {
auto server_manager = std::make_unique<ServerManager>(system);
server_manager->RegisterNamedService("ldn:m", std::make_shared<IMonitorServiceCreator>(system));
server_manager->RegisterNamedService("ldn:s", std::make_shared<ISystemServiceCreator>(system));
server_manager->RegisterNamedService("ldn:u", std::make_shared<IUserServiceCreator>(system));
server_manager->RegisterNamedService("lp2p:app", std::make_shared<ISfServiceCreator>(system, false, "lp2p:app"));
server_manager->RegisterNamedService("lp2p:sys", std::make_shared<ISfServiceCreator>(system, true, "lp2p:sys"));
server_manager->RegisterNamedService("lp2p:m", std::make_shared<ISfMonitorServiceCreator>(system));
2023-02-18 16:26:48 -05:00
ServerManager::RunServer(std::move(server_manager));
2018-07-26 01:16:08 -04:00
}
} // namespace Service::LDN