2022-04-23 08:59:50 +00:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2018-07-26 05:16:08 +00:00
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
2022-08-07 21:54:51 +00:00
|
|
|
#include "core/core.h"
|
2022-07-31 02:46:26 +00:00
|
|
|
#include "core/hle/service/ldn/lan_discovery.h"
|
2018-07-26 05:16:08 +00:00
|
|
|
#include "core/hle/service/ldn/ldn.h"
|
2022-08-12 04:12:32 +00:00
|
|
|
#include "core/hle/service/ldn/ldn_results.h"
|
|
|
|
#include "core/hle/service/ldn/ldn_types.h"
|
2023-02-18 21:26:48 +00:00
|
|
|
#include "core/hle/service/server_manager.h"
|
2022-08-07 21:54:51 +00:00
|
|
|
#include "core/internal_network/network.h"
|
|
|
|
#include "core/internal_network/network_interface.h"
|
2022-07-31 02:46:26 +00:00
|
|
|
#include "network/network.h"
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-08-08 17:49:48 +00:00
|
|
|
// This is defined by synchapi.h and conflicts with ServiceContext::CreateEvent
|
2022-08-07 21:54:51 +00:00
|
|
|
#undef CreateEvent
|
2018-07-26 05:16:08 +00:00
|
|
|
|
|
|
|
namespace Service::LDN {
|
|
|
|
|
|
|
|
class IMonitorService final : public ServiceFramework<IMonitorService> {
|
|
|
|
public:
|
2020-11-26 20:19:08 +00:00
|
|
|
explicit IMonitorService(Core::System& system_) : ServiceFramework{system_, "IMonitorService"} {
|
2018-07-26 05:16:08 +00: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 20:19:08 +00:00
|
|
|
explicit LDNM(Core::System& system_) : ServiceFramework{system_, "ldn:m"} {
|
2018-07-26 05:16:08 +00:00
|
|
|
// clang-format off
|
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, &LDNM::CreateMonitorService, "CreateMonitorService"}
|
|
|
|
};
|
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
2023-02-19 19:42:12 +00:00
|
|
|
void CreateMonitorService(HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_DEBUG(Service_LDN, "called");
|
|
|
|
|
2018-07-26 05:16:08 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
2021-05-21 05:05:04 +00:00
|
|
|
rb.Push(ResultSuccess);
|
2020-11-26 20:19:08 +00:00
|
|
|
rb.PushIpcInterface<IMonitorService>(system);
|
2018-07-26 05:16:08 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-04-10 18:48:37 +00:00
|
|
|
class ISystemLocalCommunicationService final
|
|
|
|
: public ServiceFramework<ISystemLocalCommunicationService> {
|
2018-07-26 05:16:08 +00:00
|
|
|
public:
|
2020-11-26 20:19:08 +00:00
|
|
|
explicit ISystemLocalCommunicationService(Core::System& system_)
|
|
|
|
: ServiceFramework{system_, "ISystemLocalCommunicationService"} {
|
2018-07-26 05:16:08 +00: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 10:50:56 +00:00
|
|
|
{104, nullptr, "SetWirelessControllerRestriction"},
|
2018-07-26 05:16:08 +00: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 18:48:37 +00:00
|
|
|
{402, nullptr, "SetOperationMode"},
|
|
|
|
{403, nullptr, "InitializeSystem2"},
|
|
|
|
};
|
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-08-12 04:12:32 +00:00
|
|
|
class IUserLocalCommunicationService final
|
|
|
|
: public ServiceFramework<IUserLocalCommunicationService> {
|
|
|
|
public:
|
|
|
|
explicit IUserLocalCommunicationService(Core::System& system_)
|
2023-02-18 21:26:48 +00:00
|
|
|
: ServiceFramework{system_, "IUserLocalCommunicationService"},
|
2022-07-31 02:46:26 +00:00
|
|
|
service_context{system, "IUserLocalCommunicationService"},
|
|
|
|
room_network{system_.GetRoomNetwork()}, lan_discovery{room_network} {
|
2022-08-12 04:12:32 +00:00
|
|
|
// clang-format off
|
2019-04-10 18:48:37 +00:00
|
|
|
static const FunctionInfo functions[] = {
|
2021-02-14 05:45:09 +00:00
|
|
|
{0, &IUserLocalCommunicationService::GetState, "GetState"},
|
2022-08-07 21:54:51 +00:00
|
|
|
{1, &IUserLocalCommunicationService::GetNetworkInfo, "GetNetworkInfo"},
|
2022-07-31 02:46:26 +00:00
|
|
|
{2, &IUserLocalCommunicationService::GetIpv4Address, "GetIpv4Address"},
|
2022-08-07 21:54:51 +00:00
|
|
|
{3, &IUserLocalCommunicationService::GetDisconnectReason, "GetDisconnectReason"},
|
|
|
|
{4, &IUserLocalCommunicationService::GetSecurityParameter, "GetSecurityParameter"},
|
|
|
|
{5, &IUserLocalCommunicationService::GetNetworkConfig, "GetNetworkConfig"},
|
|
|
|
{100, &IUserLocalCommunicationService::AttachStateChangeEvent, "AttachStateChangeEvent"},
|
|
|
|
{101, &IUserLocalCommunicationService::GetNetworkInfoLatestUpdate, "GetNetworkInfoLatestUpdate"},
|
|
|
|
{102, &IUserLocalCommunicationService::Scan, "Scan"},
|
|
|
|
{103, &IUserLocalCommunicationService::ScanPrivate, "ScanPrivate"},
|
2022-07-31 02:46:26 +00:00
|
|
|
{104, &IUserLocalCommunicationService::SetWirelessControllerRestriction, "SetWirelessControllerRestriction"},
|
2022-08-07 21:54:51 +00:00
|
|
|
{200, &IUserLocalCommunicationService::OpenAccessPoint, "OpenAccessPoint"},
|
|
|
|
{201, &IUserLocalCommunicationService::CloseAccessPoint, "CloseAccessPoint"},
|
|
|
|
{202, &IUserLocalCommunicationService::CreateNetwork, "CreateNetwork"},
|
|
|
|
{203, &IUserLocalCommunicationService::CreateNetworkPrivate, "CreateNetworkPrivate"},
|
|
|
|
{204, &IUserLocalCommunicationService::DestroyNetwork, "DestroyNetwork"},
|
2019-04-10 18:48:37 +00:00
|
|
|
{205, nullptr, "Reject"},
|
2022-08-07 21:54:51 +00:00
|
|
|
{206, &IUserLocalCommunicationService::SetAdvertiseData, "SetAdvertiseData"},
|
|
|
|
{207, &IUserLocalCommunicationService::SetStationAcceptPolicy, "SetStationAcceptPolicy"},
|
|
|
|
{208, &IUserLocalCommunicationService::AddAcceptFilterEntry, "AddAcceptFilterEntry"},
|
2019-04-10 18:48:37 +00:00
|
|
|
{209, nullptr, "ClearAcceptFilter"},
|
2022-08-07 21:54:51 +00:00
|
|
|
{300, &IUserLocalCommunicationService::OpenStation, "OpenStation"},
|
|
|
|
{301, &IUserLocalCommunicationService::CloseStation, "CloseStation"},
|
|
|
|
{302, &IUserLocalCommunicationService::Connect, "Connect"},
|
2019-04-10 18:48:37 +00:00
|
|
|
{303, nullptr, "ConnectPrivate"},
|
2022-08-07 21:54:51 +00:00
|
|
|
{304, &IUserLocalCommunicationService::Disconnect, "Disconnect"},
|
|
|
|
{400, &IUserLocalCommunicationService::Initialize, "Initialize"},
|
|
|
|
{401, &IUserLocalCommunicationService::Finalize, "Finalize"},
|
|
|
|
{402, &IUserLocalCommunicationService::Initialize2, "Initialize2"},
|
2018-07-26 05:16:08 +00:00
|
|
|
};
|
2022-08-12 04:12:32 +00:00
|
|
|
// clang-format on
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-08-12 04:12:32 +00:00
|
|
|
RegisterHandlers(functions);
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-08-12 04:12:32 +00:00
|
|
|
state_change_event =
|
|
|
|
service_context.CreateEvent("IUserLocalCommunicationService:StateChangeEvent");
|
|
|
|
}
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-08-12 04:12:32 +00:00
|
|
|
~IUserLocalCommunicationService() {
|
2022-07-31 02:46:26 +00:00
|
|
|
if (is_initialized) {
|
|
|
|
if (auto room_member = room_network.GetRoomMember().lock()) {
|
|
|
|
room_member->Unbind(ldn_packet_received);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-12 04:12:32 +00:00
|
|
|
service_context.CloseEvent(state_change_event);
|
|
|
|
}
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-07-31 02:46:26 +00:00
|
|
|
/// Callback to parse and handle a received LDN packet.
|
|
|
|
void OnLDNPacketReceived(const Network::LDNPacket& packet) {
|
|
|
|
lan_discovery.ReceivePacket(packet);
|
|
|
|
}
|
|
|
|
|
2022-08-12 04:12:32 +00:00
|
|
|
void OnEventFired() {
|
2022-10-13 00:26:04 +00:00
|
|
|
state_change_event->Signal();
|
2022-08-12 04:12:32 +00:00
|
|
|
}
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2023-02-19 19:42:12 +00:00
|
|
|
void GetState(HLERequestContext& ctx) {
|
2022-08-12 04:12:32 +00:00
|
|
|
State state = State::Error;
|
2022-07-31 02:46:26 +00:00
|
|
|
|
|
|
|
if (is_initialized) {
|
|
|
|
state = lan_discovery.GetState();
|
|
|
|
}
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-08-12 04:12:32 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
rb.Push(ResultSuccess);
|
|
|
|
rb.PushEnum(state);
|
2018-07-26 05:16:08 +00:00
|
|
|
}
|
2020-02-16 06:24:34 +00:00
|
|
|
|
2023-02-19 19:42:12 +00:00
|
|
|
void GetNetworkInfo(HLERequestContext& ctx) {
|
2022-08-12 04:12:32 +00:00
|
|
|
const auto write_buffer_size = ctx.GetWriteBufferSize();
|
|
|
|
|
|
|
|
if (write_buffer_size != sizeof(NetworkInfo)) {
|
|
|
|
LOG_ERROR(Service_LDN, "Invalid buffer size {}", write_buffer_size);
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(ResultBadInput);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
NetworkInfo network_info{};
|
2022-07-31 02:46:26 +00:00
|
|
|
const auto rc = lan_discovery.GetNetworkInfo(network_info);
|
2022-08-12 04:12:32 +00:00
|
|
|
if (rc.IsError()) {
|
|
|
|
LOG_ERROR(Service_LDN, "NetworkInfo is not valid {}", rc.raw);
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(rc);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx.WriteBuffer<NetworkInfo>(network_info);
|
2022-08-07 21:54:51 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2022-07-31 02:46:26 +00:00
|
|
|
rb.Push(ResultSuccess);
|
2022-08-07 21:54:51 +00:00
|
|
|
}
|
2021-02-13 10:32:13 +00:00
|
|
|
|
2023-02-19 19:42:12 +00:00
|
|
|
void GetIpv4Address(HLERequestContext& ctx) {
|
2022-07-31 02:46:26 +00:00
|
|
|
const auto network_interface = Network::GetSelectedNetworkInterface();
|
|
|
|
|
|
|
|
if (!network_interface) {
|
|
|
|
LOG_ERROR(Service_LDN, "No network interface available");
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(ResultNoIpAddress);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Ipv4Address current_address{Network::TranslateIPv4(network_interface->ip_address)};
|
|
|
|
Ipv4Address subnet_mask{Network::TranslateIPv4(network_interface->subnet_mask)};
|
|
|
|
|
|
|
|
// When we're connected to a room, spoof the hosts IP address
|
|
|
|
if (auto room_member = room_network.GetRoomMember().lock()) {
|
|
|
|
if (room_member->IsConnected()) {
|
|
|
|
current_address = room_member->GetFakeIpAddress();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::reverse(std::begin(current_address), std::end(current_address)); // ntohl
|
|
|
|
std::reverse(std::begin(subnet_mask), std::end(subnet_mask)); // ntohl
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 4};
|
|
|
|
rb.Push(ResultSuccess);
|
|
|
|
rb.PushRaw(current_address);
|
|
|
|
rb.PushRaw(subnet_mask);
|
|
|
|
}
|
2021-02-14 05:45:09 +00:00
|
|
|
|
2023-02-19 19:42:12 +00:00
|
|
|
void GetDisconnectReason(HLERequestContext& ctx) {
|
2022-08-12 04:12:32 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
rb.Push(ResultSuccess);
|
2022-07-31 02:46:26 +00:00
|
|
|
rb.PushEnum(lan_discovery.GetDisconnectReason());
|
2022-08-12 04:12:32 +00:00
|
|
|
}
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2023-02-19 19:42:12 +00:00
|
|
|
void GetSecurityParameter(HLERequestContext& ctx) {
|
2022-08-12 04:12:32 +00:00
|
|
|
SecurityParameter security_parameter{};
|
|
|
|
NetworkInfo info{};
|
2022-07-31 02:46:26 +00:00
|
|
|
const Result rc = lan_discovery.GetNetworkInfo(info);
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-08-12 04:12:32 +00:00
|
|
|
if (rc.IsError()) {
|
|
|
|
LOG_ERROR(Service_LDN, "NetworkInfo is not valid {}", rc.raw);
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(rc);
|
|
|
|
return;
|
|
|
|
}
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-08-12 04:12:32 +00:00
|
|
|
security_parameter.session_id = info.network_id.session_id;
|
|
|
|
std::memcpy(security_parameter.data.data(), info.ldn.security_parameter.data(),
|
|
|
|
sizeof(SecurityParameter::data));
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-08-12 04:12:32 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 10};
|
2022-08-07 21:54:51 +00:00
|
|
|
rb.Push(rc);
|
2022-08-12 04:12:32 +00:00
|
|
|
rb.PushRaw<SecurityParameter>(security_parameter);
|
2021-02-14 05:45:09 +00:00
|
|
|
}
|
|
|
|
|
2023-02-19 19:42:12 +00:00
|
|
|
void GetNetworkConfig(HLERequestContext& ctx) {
|
2022-08-12 04:12:32 +00:00
|
|
|
NetworkConfig config{};
|
|
|
|
NetworkInfo info{};
|
2022-07-31 02:46:26 +00:00
|
|
|
const Result rc = lan_discovery.GetNetworkInfo(info);
|
2022-08-12 04:12:32 +00:00
|
|
|
|
|
|
|
if (rc.IsError()) {
|
|
|
|
LOG_ERROR(Service_LDN, "NetworkConfig is not valid {}", rc.raw);
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(rc);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
config.intent_id = info.network_id.intent_id;
|
|
|
|
config.channel = info.common.channel;
|
|
|
|
config.node_count_max = info.ldn.node_count_max;
|
|
|
|
config.local_communication_version = info.ldn.nodes[0].local_communication_version;
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 10};
|
|
|
|
rb.Push(rc);
|
|
|
|
rb.PushRaw<NetworkConfig>(config);
|
|
|
|
}
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2023-02-19 19:42:12 +00:00
|
|
|
void AttachStateChangeEvent(HLERequestContext& ctx) {
|
2022-08-12 04:12:32 +00:00
|
|
|
LOG_INFO(Service_LDN, "called");
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-08-12 04:12:32 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 1};
|
|
|
|
rb.Push(ResultSuccess);
|
|
|
|
rb.PushCopyObjects(state_change_event->GetReadableEvent());
|
2020-02-16 06:24:34 +00:00
|
|
|
}
|
2021-02-14 05:45:09 +00:00
|
|
|
|
2023-02-19 19:42:12 +00:00
|
|
|
void GetNetworkInfoLatestUpdate(HLERequestContext& ctx) {
|
2022-08-12 04:12:32 +00:00
|
|
|
const std::size_t network_buffer_size = ctx.GetWriteBufferSize(0);
|
2022-11-23 18:25:14 +00:00
|
|
|
const std::size_t node_buffer_count = ctx.GetWriteBufferNumElements<NodeLatestUpdate>(1);
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-08-12 04:12:32 +00:00
|
|
|
if (node_buffer_count == 0 || network_buffer_size != sizeof(NetworkInfo)) {
|
2022-07-31 02:46:26 +00:00
|
|
|
LOG_ERROR(Service_LDN, "Invalid buffer, size = {}, count = {}", network_buffer_size,
|
2022-08-12 04:12:32 +00:00
|
|
|
node_buffer_count);
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(ResultBadInput);
|
|
|
|
return;
|
|
|
|
}
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-07-31 02:46:26 +00:00
|
|
|
NetworkInfo info{};
|
2022-08-12 04:12:32 +00:00
|
|
|
std::vector<NodeLatestUpdate> latest_update(node_buffer_count);
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-07-31 02:46:26 +00:00
|
|
|
const auto rc = lan_discovery.GetNetworkInfo(info, latest_update, latest_update.size());
|
2022-08-12 04:12:32 +00:00
|
|
|
if (rc.IsError()) {
|
|
|
|
LOG_ERROR(Service_LDN, "NetworkInfo is not valid {}", rc.raw);
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(rc);
|
|
|
|
return;
|
|
|
|
}
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-08-12 04:12:32 +00:00
|
|
|
ctx.WriteBuffer(info, 0);
|
|
|
|
ctx.WriteBuffer(latest_update, 1);
|
2022-08-07 21:54:51 +00:00
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2022-08-12 04:12:32 +00:00
|
|
|
rb.Push(ResultSuccess);
|
2022-08-07 21:54:51 +00:00
|
|
|
}
|
|
|
|
|
2023-02-19 19:42:12 +00:00
|
|
|
void Scan(HLERequestContext& ctx) {
|
2022-08-12 04:12:32 +00:00
|
|
|
ScanImpl(ctx);
|
2022-08-07 21:54:51 +00:00
|
|
|
}
|
|
|
|
|
2023-02-19 19:42:12 +00:00
|
|
|
void ScanPrivate(HLERequestContext& ctx) {
|
2022-08-12 04:12:32 +00:00
|
|
|
ScanImpl(ctx, true);
|
|
|
|
}
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2023-02-19 19:42:12 +00:00
|
|
|
void ScanImpl(HLERequestContext& ctx, bool is_private = false) {
|
2022-08-12 04:12:32 +00:00
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
const auto channel{rp.PopEnum<WifiChannel>()};
|
|
|
|
const auto scan_filter{rp.PopRaw<ScanFilter>()};
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-11-23 18:25:14 +00:00
|
|
|
const std::size_t network_info_size = ctx.GetWriteBufferNumElements<NetworkInfo>();
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-08-12 04:12:32 +00:00
|
|
|
if (network_info_size == 0) {
|
|
|
|
LOG_ERROR(Service_LDN, "Invalid buffer size {}", network_info_size);
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(ResultBadInput);
|
|
|
|
return;
|
|
|
|
}
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-08-12 04:12:32 +00:00
|
|
|
u16 count = 0;
|
|
|
|
std::vector<NetworkInfo> network_infos(network_info_size);
|
2022-07-31 02:46:26 +00:00
|
|
|
Result rc = lan_discovery.Scan(network_infos, count, scan_filter);
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-07-31 02:46:26 +00:00
|
|
|
LOG_INFO(Service_LDN,
|
|
|
|
"called, channel={}, filter_scan_flag={}, filter_network_type={}, is_private={}",
|
|
|
|
channel, scan_filter.flag, scan_filter.network_type, is_private);
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-08-12 04:12:32 +00:00
|
|
|
ctx.WriteBuffer(network_infos);
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-08-12 04:12:32 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
2022-07-31 02:46:26 +00:00
|
|
|
rb.Push(rc);
|
2022-08-12 04:12:32 +00:00
|
|
|
rb.Push<u32>(count);
|
2022-08-07 21:54:51 +00:00
|
|
|
}
|
|
|
|
|
2023-02-19 19:42:12 +00:00
|
|
|
void SetWirelessControllerRestriction(HLERequestContext& ctx) {
|
2022-08-12 04:12:32 +00:00
|
|
|
LOG_WARNING(Service_LDN, "(STUBBED) called");
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-08-12 04:12:32 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(ResultSuccess);
|
|
|
|
}
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2023-02-19 19:42:12 +00:00
|
|
|
void OpenAccessPoint(HLERequestContext& ctx) {
|
2022-07-31 02:46:26 +00:00
|
|
|
LOG_INFO(Service_LDN, "called");
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(lan_discovery.OpenAccessPoint());
|
|
|
|
}
|
|
|
|
|
2023-02-19 19:42:12 +00:00
|
|
|
void CloseAccessPoint(HLERequestContext& ctx) {
|
2022-07-31 02:46:26 +00:00
|
|
|
LOG_INFO(Service_LDN, "called");
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-08-12 04:12:32 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2022-07-31 02:46:26 +00:00
|
|
|
rb.Push(lan_discovery.CloseAccessPoint());
|
2022-08-12 04:12:32 +00:00
|
|
|
}
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2023-02-19 19:42:12 +00:00
|
|
|
void CreateNetwork(HLERequestContext& ctx) {
|
2022-07-31 02:46:26 +00:00
|
|
|
LOG_INFO(Service_LDN, "called");
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-07-31 02:46:26 +00:00
|
|
|
CreateNetworkImpl(ctx);
|
|
|
|
}
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2023-02-19 19:42:12 +00:00
|
|
|
void CreateNetworkPrivate(HLERequestContext& ctx) {
|
2022-07-31 02:46:26 +00:00
|
|
|
LOG_INFO(Service_LDN, "called");
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-07-31 02:46:26 +00:00
|
|
|
CreateNetworkImpl(ctx, true);
|
2022-08-12 04:12:32 +00:00
|
|
|
}
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2023-02-19 19:42:12 +00:00
|
|
|
void CreateNetworkImpl(HLERequestContext& ctx, bool is_private = false) {
|
2022-08-12 04:12:32 +00:00
|
|
|
IPC::RequestParser rp{ctx};
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-07-31 02:46:26 +00:00
|
|
|
const auto security_config{rp.PopRaw<SecurityConfig>()};
|
|
|
|
[[maybe_unused]] const auto security_parameter{is_private ? rp.PopRaw<SecurityParameter>()
|
|
|
|
: SecurityParameter{}};
|
|
|
|
const auto user_config{rp.PopRaw<UserConfig>()};
|
|
|
|
rp.Pop<u32>(); // Padding
|
|
|
|
const auto network_Config{rp.PopRaw<NetworkConfig>()};
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-08-12 04:12:32 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2022-07-31 02:46:26 +00:00
|
|
|
rb.Push(lan_discovery.CreateNetwork(security_config, user_config, network_Config));
|
2022-08-12 04:12:32 +00:00
|
|
|
}
|
2022-08-08 17:49:48 +00:00
|
|
|
|
2023-02-19 19:42:12 +00:00
|
|
|
void DestroyNetwork(HLERequestContext& ctx) {
|
2022-07-31 02:46:26 +00:00
|
|
|
LOG_INFO(Service_LDN, "called");
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-08-12 04:12:32 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2022-07-31 02:46:26 +00:00
|
|
|
rb.Push(lan_discovery.DestroyNetwork());
|
2022-08-12 04:12:32 +00:00
|
|
|
}
|
2022-08-08 17:49:48 +00:00
|
|
|
|
2023-02-19 19:42:12 +00:00
|
|
|
void SetAdvertiseData(HLERequestContext& ctx) {
|
2023-02-03 05:08:45 +00:00
|
|
|
const auto read_buffer = ctx.ReadBuffer();
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-08-12 04:12:32 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2022-07-31 02:46:26 +00:00
|
|
|
rb.Push(lan_discovery.SetAdvertiseData(read_buffer));
|
2022-08-12 04:12:32 +00:00
|
|
|
}
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2023-02-19 19:42:12 +00:00
|
|
|
void SetStationAcceptPolicy(HLERequestContext& ctx) {
|
2022-08-12 04:12:32 +00:00
|
|
|
LOG_WARNING(Service_LDN, "(STUBBED) called");
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-08-12 04:12:32 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(ResultSuccess);
|
|
|
|
}
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2023-02-19 19:42:12 +00:00
|
|
|
void AddAcceptFilterEntry(HLERequestContext& ctx) {
|
2022-08-12 04:12:32 +00:00
|
|
|
LOG_WARNING(Service_LDN, "(STUBBED) called");
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-08-12 04:12:32 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(ResultSuccess);
|
|
|
|
}
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2023-02-19 19:42:12 +00:00
|
|
|
void OpenStation(HLERequestContext& ctx) {
|
2022-07-31 02:46:26 +00:00
|
|
|
LOG_INFO(Service_LDN, "called");
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-08-12 04:12:32 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2022-07-31 02:46:26 +00:00
|
|
|
rb.Push(lan_discovery.OpenStation());
|
2022-08-12 04:12:32 +00:00
|
|
|
}
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2023-02-19 19:42:12 +00:00
|
|
|
void CloseStation(HLERequestContext& ctx) {
|
2022-07-31 02:46:26 +00:00
|
|
|
LOG_INFO(Service_LDN, "called");
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-08-12 04:12:32 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2022-07-31 02:46:26 +00:00
|
|
|
rb.Push(lan_discovery.CloseStation());
|
2022-08-12 04:12:32 +00:00
|
|
|
}
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2023-02-19 19:42:12 +00:00
|
|
|
void Connect(HLERequestContext& ctx) {
|
2022-08-12 04:12:32 +00:00
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
struct Parameters {
|
|
|
|
SecurityConfig security_config;
|
|
|
|
UserConfig user_config;
|
|
|
|
u32 local_communication_version;
|
|
|
|
u32 option;
|
|
|
|
};
|
|
|
|
static_assert(sizeof(Parameters) == 0x7C, "Parameters has incorrect size.");
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-08-12 04:12:32 +00:00
|
|
|
const auto parameters{rp.PopRaw<Parameters>()};
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-07-31 02:46:26 +00:00
|
|
|
LOG_INFO(Service_LDN,
|
|
|
|
"called, passphrase_size={}, security_mode={}, "
|
|
|
|
"local_communication_version={}",
|
|
|
|
parameters.security_config.passphrase_size,
|
|
|
|
parameters.security_config.security_mode, parameters.local_communication_version);
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2023-02-03 05:08:45 +00:00
|
|
|
const auto read_buffer = ctx.ReadBuffer();
|
2022-08-12 04:12:32 +00:00
|
|
|
if (read_buffer.size() != sizeof(NetworkInfo)) {
|
|
|
|
LOG_ERROR(Frontend, "NetworkInfo doesn't match read_buffer size!");
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(ResultBadInput);
|
|
|
|
return;
|
|
|
|
}
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-07-31 02:46:26 +00:00
|
|
|
NetworkInfo network_info{};
|
2022-08-12 04:12:32 +00:00
|
|
|
std::memcpy(&network_info, read_buffer.data(), read_buffer.size());
|
2022-08-07 21:54:51 +00:00
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2022-07-31 02:46:26 +00:00
|
|
|
rb.Push(lan_discovery.Connect(network_info, parameters.user_config,
|
|
|
|
static_cast<u16>(parameters.local_communication_version)));
|
2022-08-07 21:54:51 +00:00
|
|
|
}
|
|
|
|
|
2023-02-19 19:42:12 +00:00
|
|
|
void Disconnect(HLERequestContext& ctx) {
|
2022-07-31 02:46:26 +00:00
|
|
|
LOG_INFO(Service_LDN, "called");
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-08-12 04:12:32 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2022-07-31 02:46:26 +00:00
|
|
|
rb.Push(lan_discovery.Disconnect());
|
2022-08-12 04:12:32 +00:00
|
|
|
}
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2023-02-19 19:42:12 +00:00
|
|
|
void Initialize(HLERequestContext& ctx) {
|
2022-08-12 04:12:32 +00:00
|
|
|
const auto rc = InitializeImpl(ctx);
|
2022-07-31 02:46:26 +00:00
|
|
|
if (rc.IsError()) {
|
|
|
|
LOG_ERROR(Service_LDN, "Network isn't initialized, rc={}", rc.raw);
|
|
|
|
}
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-08-12 04:12:32 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(rc);
|
|
|
|
}
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2023-02-19 19:42:12 +00:00
|
|
|
void Finalize(HLERequestContext& ctx) {
|
2022-07-31 02:46:26 +00:00
|
|
|
if (auto room_member = room_network.GetRoomMember().lock()) {
|
|
|
|
room_member->Unbind(ldn_packet_received);
|
|
|
|
}
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-08-12 04:12:32 +00:00
|
|
|
is_initialized = false;
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-08-12 04:12:32 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2022-07-31 02:46:26 +00:00
|
|
|
rb.Push(lan_discovery.Finalize());
|
2022-08-12 04:12:32 +00:00
|
|
|
}
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2023-02-19 19:42:12 +00:00
|
|
|
void Initialize2(HLERequestContext& ctx) {
|
2022-08-12 04:12:32 +00:00
|
|
|
const auto rc = InitializeImpl(ctx);
|
2022-07-31 02:46:26 +00:00
|
|
|
if (rc.IsError()) {
|
|
|
|
LOG_ERROR(Service_LDN, "Network isn't initialized, rc={}", rc.raw);
|
|
|
|
}
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-08-12 04:12:32 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(rc);
|
|
|
|
}
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2023-02-19 19:42:12 +00:00
|
|
|
Result InitializeImpl(HLERequestContext& ctx) {
|
2022-08-12 04:12:32 +00:00
|
|
|
const auto network_interface = Network::GetSelectedNetworkInterface();
|
|
|
|
if (!network_interface) {
|
|
|
|
LOG_ERROR(Service_LDN, "No network interface is set");
|
|
|
|
return ResultAirplaneModeEnabled;
|
|
|
|
}
|
2022-08-07 21:54:51 +00:00
|
|
|
|
2022-07-31 02:46:26 +00:00
|
|
|
if (auto room_member = room_network.GetRoomMember().lock()) {
|
|
|
|
ldn_packet_received = room_member->BindOnLdnPacketReceived(
|
|
|
|
[this](const Network::LDNPacket& packet) { OnLDNPacketReceived(packet); });
|
|
|
|
} else {
|
|
|
|
LOG_ERROR(Service_LDN, "Couldn't bind callback!");
|
|
|
|
return ResultAirplaneModeEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
lan_discovery.Initialize([&]() { OnEventFired(); });
|
2022-08-12 04:12:32 +00:00
|
|
|
is_initialized = true;
|
2022-07-31 02:46:26 +00:00
|
|
|
return ResultSuccess;
|
2022-08-07 21:54:51 +00:00
|
|
|
}
|
|
|
|
|
2022-08-12 04:12:32 +00:00
|
|
|
KernelHelpers::ServiceContext service_context;
|
|
|
|
Kernel::KEvent* state_change_event;
|
|
|
|
Network::RoomNetwork& room_network;
|
2022-07-31 02:46:26 +00:00
|
|
|
LANDiscovery lan_discovery;
|
|
|
|
|
|
|
|
// Callback identifier for the OnLDNPacketReceived event.
|
|
|
|
Network::RoomMember::CallbackHandle<Network::LDNPacket> ldn_packet_received;
|
2022-08-12 04:12:32 +00:00
|
|
|
|
|
|
|
bool is_initialized{};
|
|
|
|
};
|
2018-07-26 05:16:08 +00:00
|
|
|
|
|
|
|
class LDNS final : public ServiceFramework<LDNS> {
|
|
|
|
public:
|
2020-11-26 20:19:08 +00:00
|
|
|
explicit LDNS(Core::System& system_) : ServiceFramework{system_, "ldn:s"} {
|
2018-07-26 05:16:08 +00:00
|
|
|
// clang-format off
|
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, &LDNS::CreateSystemLocalCommunicationService, "CreateSystemLocalCommunicationService"},
|
|
|
|
};
|
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
2023-02-19 19:42:12 +00:00
|
|
|
void CreateSystemLocalCommunicationService(HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_DEBUG(Service_LDN, "called");
|
|
|
|
|
2018-07-26 05:16:08 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
2021-05-21 05:05:04 +00:00
|
|
|
rb.Push(ResultSuccess);
|
2020-11-26 20:19:08 +00:00
|
|
|
rb.PushIpcInterface<ISystemLocalCommunicationService>(system);
|
2018-07-26 05:16:08 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class LDNU final : public ServiceFramework<LDNU> {
|
|
|
|
public:
|
2020-11-26 20:19:08 +00:00
|
|
|
explicit LDNU(Core::System& system_) : ServiceFramework{system_, "ldn:u"} {
|
2018-07-26 05:16:08 +00:00
|
|
|
// clang-format off
|
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, &LDNU::CreateUserLocalCommunicationService, "CreateUserLocalCommunicationService"},
|
|
|
|
};
|
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
2023-02-19 19:42:12 +00:00
|
|
|
void CreateUserLocalCommunicationService(HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_DEBUG(Service_LDN, "called");
|
|
|
|
|
2018-07-26 05:16:08 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
2021-05-21 05:05:04 +00:00
|
|
|
rb.Push(ResultSuccess);
|
2020-11-26 20:19:08 +00:00
|
|
|
rb.PushIpcInterface<IUserLocalCommunicationService>(system);
|
2018-07-26 05:16:08 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-05-26 13:42:57 +00: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);
|
|
|
|
}
|
|
|
|
|
2023-02-19 19:42:12 +00:00
|
|
|
void Initialize(HLERequestContext& ctx) {
|
2021-05-26 13:42:57 +00:00
|
|
|
LOG_WARNING(Service_LDN, "(STUBBED) called");
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2022-08-07 21:54:51 +00:00
|
|
|
rb.Push(ResultDisabled);
|
2021-05-26 13:42:57 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2023-02-19 19:42:12 +00:00
|
|
|
void CreateNetworkervice(HLERequestContext& ctx) {
|
2021-05-26 13:42:57 +00:00
|
|
|
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};
|
2021-05-21 05:05:04 +00:00
|
|
|
rb.Push(ResultSuccess);
|
2021-05-26 13:42:57 +00:00
|
|
|
rb.PushIpcInterface<INetworkService>(system);
|
|
|
|
}
|
|
|
|
|
2023-02-19 19:42:12 +00:00
|
|
|
void CreateMonitorService(HLERequestContext& ctx) {
|
2021-05-26 13:42:57 +00:00
|
|
|
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};
|
2021-05-21 05:05:04 +00:00
|
|
|
rb.Push(ResultSuccess);
|
2021-05-26 13:42:57 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2023-02-19 19:42:12 +00:00
|
|
|
void CreateNetworkervice(HLERequestContext& ctx) {
|
2021-05-26 13:42:57 +00:00
|
|
|
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};
|
2021-05-21 05:05:04 +00:00
|
|
|
rb.Push(ResultSuccess);
|
2021-05-26 13:42:57 +00:00
|
|
|
rb.PushIpcInterface<INetworkService>(system);
|
|
|
|
}
|
|
|
|
|
2023-02-19 19:42:12 +00:00
|
|
|
void CreateMonitorService(HLERequestContext& ctx) {
|
2021-05-26 13:42:57 +00:00
|
|
|
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};
|
2021-05-21 05:05:04 +00:00
|
|
|
rb.Push(ResultSuccess);
|
2021-05-26 13:42:57 +00:00
|
|
|
rb.PushIpcInterface<INetworkServiceMonitor>(system);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-02-18 21:26:48 +00:00
|
|
|
void LoopProcess(Core::System& system) {
|
|
|
|
auto server_manager = std::make_unique<ServerManager>(system);
|
|
|
|
|
|
|
|
server_manager->RegisterNamedService("ldn:m", std::make_shared<LDNM>(system));
|
|
|
|
server_manager->RegisterNamedService("ldn:s", std::make_shared<LDNS>(system));
|
|
|
|
server_manager->RegisterNamedService("ldn:u", std::make_shared<LDNU>(system));
|
|
|
|
server_manager->RegisterNamedService("lp2p:app", std::make_shared<LP2PAPP>(system));
|
|
|
|
server_manager->RegisterNamedService("lp2p:sys", std::make_shared<LP2PSYS>(system));
|
|
|
|
ServerManager::RunServer(std::move(server_manager));
|
2018-07-26 05:16:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Service::LDN
|