2018-07-26 01:16:08 -04:00
|
|
|
// Copyright 2018 yuzu emulator team
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
#include "core/hle/ipc_helpers.h"
|
|
|
|
#include "core/hle/result.h"
|
2021-02-13 05:32:13 -05:00
|
|
|
#include "core/hle/service/ldn/errors.h"
|
2018-07-26 01:16:08 -04:00
|
|
|
#include "core/hle/service/ldn/ldn.h"
|
|
|
|
#include "core/hle/service/sm/sm.h"
|
|
|
|
|
|
|
|
namespace Service::LDN {
|
|
|
|
|
|
|
|
class IMonitorService final : public ServiceFramework<IMonitorService> {
|
|
|
|
public:
|
2020-11-26 15:19:08 -05:00
|
|
|
explicit IMonitorService(Core::System& system_) : ServiceFramework{system_, "IMonitorService"} {
|
2018-07-26 01:16:08 -04:00
|
|
|
// clang-format off
|
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, nullptr, "GetStateForMonitor"},
|
|
|
|
{1, nullptr, "GetNetworkInfoForMonitor"},
|
|
|
|
{2, nullptr, "GetIpv4AddressForMonitor"},
|
|
|
|
{3, nullptr, "GetDisconnectReasonForMonitor"},
|
|
|
|
{4, nullptr, "GetSecurityParameterForMonitor"},
|
|
|
|
{5, nullptr, "GetNetworkConfigForMonitor"},
|
|
|
|
{100, nullptr, "InitializeMonitor"},
|
|
|
|
{101, nullptr, "FinalizeMonitor"},
|
|
|
|
};
|
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class LDNM final : public ServiceFramework<LDNM> {
|
|
|
|
public:
|
2020-11-26 15:19:08 -05:00
|
|
|
explicit LDNM(Core::System& system_) : ServiceFramework{system_, "ldn:m"} {
|
2018-07-26 01:16:08 -04:00
|
|
|
// clang-format off
|
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, &LDNM::CreateMonitorService, "CreateMonitorService"}
|
|
|
|
};
|
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CreateMonitorService(Kernel::HLERequestContext& ctx) {
|
2018-11-26 01:06:13 -05:00
|
|
|
LOG_DEBUG(Service_LDN, "called");
|
|
|
|
|
2018-07-26 01:16:08 -04:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2020-11-26 15:19:08 -05:00
|
|
|
rb.PushIpcInterface<IMonitorService>(system);
|
2018-07-26 01:16:08 -04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-04-10 14:48:37 -04:00
|
|
|
class ISystemLocalCommunicationService final
|
|
|
|
: public ServiceFramework<ISystemLocalCommunicationService> {
|
2018-07-26 01:16:08 -04:00
|
|
|
public:
|
2020-11-26 15:19:08 -05:00
|
|
|
explicit ISystemLocalCommunicationService(Core::System& system_)
|
|
|
|
: ServiceFramework{system_, "ISystemLocalCommunicationService"} {
|
2018-07-26 01:16:08 -04:00
|
|
|
// clang-format off
|
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, nullptr, "GetState"},
|
|
|
|
{1, nullptr, "GetNetworkInfo"},
|
|
|
|
{2, nullptr, "GetIpv4Address"},
|
|
|
|
{3, nullptr, "GetDisconnectReason"},
|
|
|
|
{4, nullptr, "GetSecurityParameter"},
|
|
|
|
{5, nullptr, "GetNetworkConfig"},
|
|
|
|
{100, nullptr, "AttachStateChangeEvent"},
|
|
|
|
{101, nullptr, "GetNetworkInfoLatestUpdate"},
|
|
|
|
{102, nullptr, "Scan"},
|
|
|
|
{103, nullptr, "ScanPrivate"},
|
2020-06-27 06:50:56 -04:00
|
|
|
{104, nullptr, "SetWirelessControllerRestriction"},
|
2018-07-26 01:16:08 -04:00
|
|
|
{200, nullptr, "OpenAccessPoint"},
|
|
|
|
{201, nullptr, "CloseAccessPoint"},
|
|
|
|
{202, nullptr, "CreateNetwork"},
|
|
|
|
{203, nullptr, "CreateNetworkPrivate"},
|
|
|
|
{204, nullptr, "DestroyNetwork"},
|
|
|
|
{205, nullptr, "Reject"},
|
|
|
|
{206, nullptr, "SetAdvertiseData"},
|
|
|
|
{207, nullptr, "SetStationAcceptPolicy"},
|
|
|
|
{208, nullptr, "AddAcceptFilterEntry"},
|
|
|
|
{209, nullptr, "ClearAcceptFilter"},
|
|
|
|
{300, nullptr, "OpenStation"},
|
|
|
|
{301, nullptr, "CloseStation"},
|
|
|
|
{302, nullptr, "Connect"},
|
|
|
|
{303, nullptr, "ConnectPrivate"},
|
|
|
|
{304, nullptr, "Disconnect"},
|
|
|
|
{400, nullptr, "InitializeSystem"},
|
|
|
|
{401, nullptr, "FinalizeSystem"},
|
2019-04-10 14:48:37 -04:00
|
|
|
{402, nullptr, "SetOperationMode"},
|
|
|
|
{403, nullptr, "InitializeSystem2"},
|
|
|
|
};
|
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class IUserLocalCommunicationService final
|
|
|
|
: public ServiceFramework<IUserLocalCommunicationService> {
|
|
|
|
public:
|
2020-11-26 15:19:08 -05:00
|
|
|
explicit IUserLocalCommunicationService(Core::System& system_)
|
|
|
|
: ServiceFramework{system_, "IUserLocalCommunicationService"} {
|
2019-04-10 14:48:37 -04:00
|
|
|
// clang-format off
|
|
|
|
static const FunctionInfo functions[] = {
|
2021-02-14 00:45:09 -05:00
|
|
|
{0, &IUserLocalCommunicationService::GetState, "GetState"},
|
2019-04-10 14:48:37 -04:00
|
|
|
{1, nullptr, "GetNetworkInfo"},
|
|
|
|
{2, nullptr, "GetIpv4Address"},
|
|
|
|
{3, nullptr, "GetDisconnectReason"},
|
|
|
|
{4, nullptr, "GetSecurityParameter"},
|
|
|
|
{5, nullptr, "GetNetworkConfig"},
|
|
|
|
{100, nullptr, "AttachStateChangeEvent"},
|
|
|
|
{101, nullptr, "GetNetworkInfoLatestUpdate"},
|
|
|
|
{102, nullptr, "Scan"},
|
|
|
|
{103, nullptr, "ScanPrivate"},
|
|
|
|
{104, nullptr, "SetWirelessControllerRestriction"},
|
|
|
|
{200, nullptr, "OpenAccessPoint"},
|
|
|
|
{201, nullptr, "CloseAccessPoint"},
|
|
|
|
{202, nullptr, "CreateNetwork"},
|
|
|
|
{203, nullptr, "CreateNetworkPrivate"},
|
|
|
|
{204, nullptr, "DestroyNetwork"},
|
|
|
|
{205, nullptr, "Reject"},
|
|
|
|
{206, nullptr, "SetAdvertiseData"},
|
|
|
|
{207, nullptr, "SetStationAcceptPolicy"},
|
|
|
|
{208, nullptr, "AddAcceptFilterEntry"},
|
|
|
|
{209, nullptr, "ClearAcceptFilter"},
|
|
|
|
{300, nullptr, "OpenStation"},
|
|
|
|
{301, nullptr, "CloseStation"},
|
|
|
|
{302, nullptr, "Connect"},
|
|
|
|
{303, nullptr, "ConnectPrivate"},
|
|
|
|
{304, nullptr, "Disconnect"},
|
|
|
|
{400, nullptr, "Initialize"},
|
|
|
|
{401, nullptr, "Finalize"},
|
2020-02-16 01:24:34 -05:00
|
|
|
{402, &IUserLocalCommunicationService::Initialize2, "Initialize2"}, // 7.0.0+
|
2018-07-26 01:16:08 -04:00
|
|
|
};
|
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
2020-02-16 01:24:34 -05:00
|
|
|
|
2021-02-14 00:45:09 -05:00
|
|
|
void GetState(Kernel::HLERequestContext& ctx) {
|
2020-02-16 01:24:34 -05:00
|
|
|
LOG_WARNING(Service_LDN, "(STUBBED) called");
|
2021-02-13 05:32:13 -05:00
|
|
|
|
2021-02-14 00:45:09 -05:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
|
|
|
|
// Indicate a network error, as we do not actually emulate LDN
|
|
|
|
rb.Push(static_cast<u32>(State::Error));
|
|
|
|
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Initialize2(Kernel::HLERequestContext& ctx) {
|
|
|
|
LOG_DEBUG(Service_LDN, "called");
|
|
|
|
|
|
|
|
is_initialized = true;
|
|
|
|
|
2020-02-16 01:24:34 -05:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2021-02-27 14:59:29 -05:00
|
|
|
rb.Push(ERROR_DISABLED);
|
2020-02-16 01:24:34 -05:00
|
|
|
}
|
2021-02-14 00:45:09 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
enum class State {
|
|
|
|
None,
|
|
|
|
Initialized,
|
|
|
|
AccessPointOpened,
|
|
|
|
AccessPointCreated,
|
|
|
|
StationOpened,
|
|
|
|
StationConnected,
|
|
|
|
Error,
|
|
|
|
};
|
|
|
|
|
|
|
|
bool is_initialized{};
|
2018-07-26 01:16:08 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
class LDNS final : public ServiceFramework<LDNS> {
|
|
|
|
public:
|
2020-11-26 15:19:08 -05:00
|
|
|
explicit LDNS(Core::System& system_) : ServiceFramework{system_, "ldn:s"} {
|
2018-07-26 01:16:08 -04:00
|
|
|
// clang-format off
|
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, &LDNS::CreateSystemLocalCommunicationService, "CreateSystemLocalCommunicationService"},
|
|
|
|
};
|
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CreateSystemLocalCommunicationService(Kernel::HLERequestContext& ctx) {
|
2018-11-26 01:06:13 -05:00
|
|
|
LOG_DEBUG(Service_LDN, "called");
|
|
|
|
|
2018-07-26 01:16:08 -04:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2020-11-26 15:19:08 -05:00
|
|
|
rb.PushIpcInterface<ISystemLocalCommunicationService>(system);
|
2018-07-26 01:16:08 -04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class LDNU final : public ServiceFramework<LDNU> {
|
|
|
|
public:
|
2020-11-26 15:19:08 -05:00
|
|
|
explicit LDNU(Core::System& system_) : ServiceFramework{system_, "ldn:u"} {
|
2018-07-26 01:16:08 -04:00
|
|
|
// clang-format off
|
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, &LDNU::CreateUserLocalCommunicationService, "CreateUserLocalCommunicationService"},
|
|
|
|
};
|
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CreateUserLocalCommunicationService(Kernel::HLERequestContext& ctx) {
|
2018-11-26 01:06:13 -05:00
|
|
|
LOG_DEBUG(Service_LDN, "called");
|
|
|
|
|
2018-07-26 01:16:08 -04:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2020-11-26 15:19:08 -05:00
|
|
|
rb.PushIpcInterface<IUserLocalCommunicationService>(system);
|
2018-07-26 01:16:08 -04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-05-26 09:42:57 -04:00
|
|
|
class INetworkService final : public ServiceFramework<INetworkService> {
|
|
|
|
public:
|
|
|
|
explicit INetworkService(Core::System& system_) : ServiceFramework{system_, "INetworkService"} {
|
|
|
|
// clang-format off
|
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, nullptr, "Initialize"},
|
|
|
|
{256, nullptr, "AttachNetworkInterfaceStateChangeEvent"},
|
|
|
|
{264, nullptr, "GetNetworkInterfaceLastError"},
|
|
|
|
{272, nullptr, "GetRole"},
|
|
|
|
{280, nullptr, "GetAdvertiseData"},
|
|
|
|
{288, nullptr, "GetGroupInfo"},
|
|
|
|
{296, nullptr, "GetGroupInfo2"},
|
|
|
|
{304, nullptr, "GetGroupOwner"},
|
|
|
|
{312, nullptr, "GetIpConfig"},
|
|
|
|
{320, nullptr, "GetLinkLevel"},
|
|
|
|
{512, nullptr, "Scan"},
|
|
|
|
{768, nullptr, "CreateGroup"},
|
|
|
|
{776, nullptr, "DestroyGroup"},
|
|
|
|
{784, nullptr, "SetAdvertiseData"},
|
|
|
|
{1536, nullptr, "SendToOtherGroup"},
|
|
|
|
{1544, nullptr, "RecvFromOtherGroup"},
|
|
|
|
{1552, nullptr, "AddAcceptableGroupId"},
|
|
|
|
{1560, nullptr, "ClearAcceptableGroupId"},
|
|
|
|
};
|
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class INetworkServiceMonitor final : public ServiceFramework<INetworkServiceMonitor> {
|
|
|
|
public:
|
|
|
|
explicit INetworkServiceMonitor(Core::System& system_)
|
|
|
|
: ServiceFramework{system_, "INetworkServiceMonitor"} {
|
|
|
|
// clang-format off
|
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, &INetworkServiceMonitor::Initialize, "Initialize"},
|
|
|
|
{256, nullptr, "AttachNetworkInterfaceStateChangeEvent"},
|
|
|
|
{264, nullptr, "GetNetworkInterfaceLastError"},
|
|
|
|
{272, nullptr, "GetRole"},
|
|
|
|
{280, nullptr, "GetAdvertiseData"},
|
|
|
|
{281, nullptr, "GetAdvertiseData2"},
|
|
|
|
{288, nullptr, "GetGroupInfo"},
|
|
|
|
{296, nullptr, "GetGroupInfo2"},
|
|
|
|
{304, nullptr, "GetGroupOwner"},
|
|
|
|
{312, nullptr, "GetIpConfig"},
|
|
|
|
{320, nullptr, "GetLinkLevel"},
|
|
|
|
{328, nullptr, "AttachJoinEvent"},
|
|
|
|
{336, nullptr, "GetMembers"},
|
|
|
|
};
|
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Initialize(Kernel::HLERequestContext& ctx) {
|
|
|
|
LOG_WARNING(Service_LDN, "(STUBBED) called");
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(ERROR_DISABLED);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class LP2PAPP final : public ServiceFramework<LP2PAPP> {
|
|
|
|
public:
|
|
|
|
explicit LP2PAPP(Core::System& system_) : ServiceFramework{system_, "lp2p:app"} {
|
|
|
|
// clang-format off
|
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, &LP2PAPP::CreateMonitorService, "CreateNetworkService"},
|
|
|
|
{8, &LP2PAPP::CreateMonitorService, "CreateNetworkServiceMonitor"},
|
|
|
|
};
|
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CreateNetworkervice(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
const u64 reserved_input = rp.Pop<u64>();
|
|
|
|
const u32 input = rp.Pop<u32>();
|
|
|
|
|
|
|
|
LOG_WARNING(Service_LDN, "(STUBBED) called reserved_input={} input={}", reserved_input,
|
|
|
|
input);
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushIpcInterface<INetworkService>(system);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CreateMonitorService(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
const u64 reserved_input = rp.Pop<u64>();
|
|
|
|
|
|
|
|
LOG_WARNING(Service_LDN, "(STUBBED) called reserved_input={}", reserved_input);
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushIpcInterface<INetworkServiceMonitor>(system);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class LP2PSYS final : public ServiceFramework<LP2PSYS> {
|
|
|
|
public:
|
|
|
|
explicit LP2PSYS(Core::System& system_) : ServiceFramework{system_, "lp2p:sys"} {
|
|
|
|
// clang-format off
|
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, &LP2PSYS::CreateMonitorService, "CreateNetworkService"},
|
|
|
|
{8, &LP2PSYS::CreateMonitorService, "CreateNetworkServiceMonitor"},
|
|
|
|
};
|
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CreateNetworkervice(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
const u64 reserved_input = rp.Pop<u64>();
|
|
|
|
const u32 input = rp.Pop<u32>();
|
|
|
|
|
|
|
|
LOG_WARNING(Service_LDN, "(STUBBED) called reserved_input={} input={}", reserved_input,
|
|
|
|
input);
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushIpcInterface<INetworkService>(system);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CreateMonitorService(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
const u64 reserved_input = rp.Pop<u64>();
|
|
|
|
|
|
|
|
LOG_WARNING(Service_LDN, "(STUBBED) called reserved_input={}", reserved_input);
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushIpcInterface<INetworkServiceMonitor>(system);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-11-26 15:19:08 -05:00
|
|
|
void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) {
|
|
|
|
std::make_shared<LDNM>(system)->InstallAsService(sm);
|
|
|
|
std::make_shared<LDNS>(system)->InstallAsService(sm);
|
|
|
|
std::make_shared<LDNU>(system)->InstallAsService(sm);
|
2021-05-26 09:42:57 -04:00
|
|
|
std::make_shared<LP2PAPP>(system)->InstallAsService(sm);
|
|
|
|
std::make_shared<LP2PSYS>(system)->InstallAsService(sm);
|
2018-07-26 01:16:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Service::LDN
|