mirror of
https://github.com/yuzu-emu/yuzu-mainline.git
synced 2024-12-23 08:45:27 +00:00
core: ldn: Address review comments part 2
This commit is contained in:
parent
8eb2c73381
commit
56115f7732
|
@ -5,6 +5,8 @@
|
|||
|
||||
#include "core/core.h"
|
||||
#include "core/hle/service/ldn/ldn.h"
|
||||
#include "core/hle/service/ldn/ldn_results.h"
|
||||
#include "core/hle/service/ldn/ldn_types.h"
|
||||
#include "core/internal_network/network.h"
|
||||
#include "core/internal_network/network_interface.h"
|
||||
|
||||
|
@ -98,7 +100,10 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
IUserLocalCommunicationService::IUserLocalCommunicationService(Core::System& system_)
|
||||
class IUserLocalCommunicationService final
|
||||
: public ServiceFramework<IUserLocalCommunicationService> {
|
||||
public:
|
||||
explicit IUserLocalCommunicationService(Core::System& system_)
|
||||
: ServiceFramework{system_, "IUserLocalCommunicationService", ServiceThreadType::CreateNew},
|
||||
service_context{system, "IUserLocalCommunicationService"}, room_network{
|
||||
system_.GetRoomNetwork()} {
|
||||
|
@ -142,15 +147,15 @@ IUserLocalCommunicationService::IUserLocalCommunicationService(Core::System& sys
|
|||
service_context.CreateEvent("IUserLocalCommunicationService:StateChangeEvent");
|
||||
}
|
||||
|
||||
IUserLocalCommunicationService::~IUserLocalCommunicationService() {
|
||||
~IUserLocalCommunicationService() {
|
||||
service_context.CloseEvent(state_change_event);
|
||||
}
|
||||
|
||||
void IUserLocalCommunicationService::OnEventFired() {
|
||||
void OnEventFired() {
|
||||
state_change_event->GetWritableEvent().Signal();
|
||||
}
|
||||
|
||||
void IUserLocalCommunicationService::GetState(Kernel::HLERequestContext& ctx) {
|
||||
void GetState(Kernel::HLERequestContext& ctx) {
|
||||
State state = State::Error;
|
||||
LOG_WARNING(Service_LDN, "(STUBBED) called, state = {}", state);
|
||||
|
||||
|
@ -159,7 +164,7 @@ void IUserLocalCommunicationService::GetState(Kernel::HLERequestContext& ctx) {
|
|||
rb.PushEnum(state);
|
||||
}
|
||||
|
||||
void IUserLocalCommunicationService::GetNetworkInfo(Kernel::HLERequestContext& ctx) {
|
||||
void GetNetworkInfo(Kernel::HLERequestContext& ctx) {
|
||||
const auto write_buffer_size = ctx.GetWriteBufferSize();
|
||||
|
||||
if (write_buffer_size != sizeof(NetworkInfo)) {
|
||||
|
@ -186,7 +191,7 @@ void IUserLocalCommunicationService::GetNetworkInfo(Kernel::HLERequestContext& c
|
|||
rb.Push(rc);
|
||||
}
|
||||
|
||||
void IUserLocalCommunicationService::GetDisconnectReason(Kernel::HLERequestContext& ctx) {
|
||||
void GetDisconnectReason(Kernel::HLERequestContext& ctx) {
|
||||
const auto disconnect_reason = DisconnectReason::None;
|
||||
|
||||
LOG_WARNING(Service_LDN, "(STUBBED) called, disconnect_reason={}", disconnect_reason);
|
||||
|
@ -196,9 +201,9 @@ void IUserLocalCommunicationService::GetDisconnectReason(Kernel::HLERequestConte
|
|||
rb.PushEnum(disconnect_reason);
|
||||
}
|
||||
|
||||
void IUserLocalCommunicationService::GetSecurityParameter(Kernel::HLERequestContext& ctx) {
|
||||
SecurityParameter security_parameter;
|
||||
NetworkInfo info;
|
||||
void GetSecurityParameter(Kernel::HLERequestContext& ctx) {
|
||||
SecurityParameter security_parameter{};
|
||||
NetworkInfo info{};
|
||||
const Result rc = ResultSuccess;
|
||||
|
||||
if (rc.IsError()) {
|
||||
|
@ -219,9 +224,9 @@ void IUserLocalCommunicationService::GetSecurityParameter(Kernel::HLERequestCont
|
|||
rb.PushRaw<SecurityParameter>(security_parameter);
|
||||
}
|
||||
|
||||
void IUserLocalCommunicationService::GetNetworkConfig(Kernel::HLERequestContext& ctx) {
|
||||
NetworkConfig config;
|
||||
NetworkInfo info;
|
||||
void GetNetworkConfig(Kernel::HLERequestContext& ctx) {
|
||||
NetworkConfig config{};
|
||||
NetworkInfo info{};
|
||||
const Result rc = ResultSuccess;
|
||||
|
||||
if (rc.IsError()) {
|
||||
|
@ -239,15 +244,15 @@ void IUserLocalCommunicationService::GetNetworkConfig(Kernel::HLERequestContext&
|
|||
LOG_WARNING(Service_LDN,
|
||||
"(STUBBED) called, intent_id={}/{}, channel={}, node_count_max={}, "
|
||||
"local_communication_version={}",
|
||||
config.intent_id.local_communication_id, config.intent_id.scene_id, config.channel,
|
||||
config.node_count_max, config.local_communication_version);
|
||||
config.intent_id.local_communication_id, config.intent_id.scene_id,
|
||||
config.channel, config.node_count_max, config.local_communication_version);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 10};
|
||||
rb.Push(rc);
|
||||
rb.PushRaw<NetworkConfig>(config);
|
||||
}
|
||||
|
||||
void IUserLocalCommunicationService::AttachStateChangeEvent(Kernel::HLERequestContext& ctx) {
|
||||
void AttachStateChangeEvent(Kernel::HLERequestContext& ctx) {
|
||||
LOG_INFO(Service_LDN, "called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 1};
|
||||
|
@ -255,7 +260,7 @@ void IUserLocalCommunicationService::AttachStateChangeEvent(Kernel::HLERequestCo
|
|||
rb.PushCopyObjects(state_change_event->GetReadableEvent());
|
||||
}
|
||||
|
||||
void IUserLocalCommunicationService::GetNetworkInfoLatestUpdate(Kernel::HLERequestContext& ctx) {
|
||||
void GetNetworkInfoLatestUpdate(Kernel::HLERequestContext& ctx) {
|
||||
const std::size_t network_buffer_size = ctx.GetWriteBufferSize(0);
|
||||
const std::size_t node_buffer_count = ctx.GetWriteBufferSize(1) / sizeof(NodeLatestUpdate);
|
||||
|
||||
|
@ -288,15 +293,15 @@ void IUserLocalCommunicationService::GetNetworkInfoLatestUpdate(Kernel::HLEReque
|
|||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void IUserLocalCommunicationService::Scan(Kernel::HLERequestContext& ctx) {
|
||||
void Scan(Kernel::HLERequestContext& ctx) {
|
||||
ScanImpl(ctx);
|
||||
}
|
||||
|
||||
void IUserLocalCommunicationService::ScanPrivate(Kernel::HLERequestContext& ctx) {
|
||||
void ScanPrivate(Kernel::HLERequestContext& ctx) {
|
||||
ScanImpl(ctx, true);
|
||||
}
|
||||
|
||||
void IUserLocalCommunicationService::ScanImpl(Kernel::HLERequestContext& ctx, bool is_private) {
|
||||
void ScanImpl(Kernel::HLERequestContext& ctx, bool is_private = false) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto channel{rp.PopEnum<WifiChannel>()};
|
||||
const auto scan_filter{rp.PopRaw<ScanFilter>()};
|
||||
|
@ -324,21 +329,21 @@ void IUserLocalCommunicationService::ScanImpl(Kernel::HLERequestContext& ctx, bo
|
|||
rb.Push<u32>(count);
|
||||
}
|
||||
|
||||
void IUserLocalCommunicationService::OpenAccessPoint(Kernel::HLERequestContext& ctx) {
|
||||
void OpenAccessPoint(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_LDN, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void IUserLocalCommunicationService::CloseAccessPoint(Kernel::HLERequestContext& ctx) {
|
||||
void CloseAccessPoint(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_LDN, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void IUserLocalCommunicationService::CreateNetwork(Kernel::HLERequestContext& ctx) {
|
||||
void CreateNetwork(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
struct Parameters {
|
||||
SecurityConfig security_config;
|
||||
|
@ -348,13 +353,20 @@ void IUserLocalCommunicationService::CreateNetwork(Kernel::HLERequestContext& ct
|
|||
};
|
||||
static_assert(sizeof(Parameters) == 0x98, "Parameters has incorrect size.");
|
||||
|
||||
LOG_WARNING(Service_LDN, "(STUBBED) called");
|
||||
const auto parameters{rp.PopRaw<Parameters>()};
|
||||
|
||||
LOG_WARNING(Service_LDN,
|
||||
"(STUBBED) called, passphrase_size={}, security_mode={}, "
|
||||
"local_communication_version={}",
|
||||
parameters.security_config.passphrase_size,
|
||||
parameters.security_config.security_mode,
|
||||
parameters.network_config.local_communication_version);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void IUserLocalCommunicationService::CreateNetworkPrivate(Kernel::HLERequestContext& ctx) {
|
||||
void CreateNetworkPrivate(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
struct Parameters {
|
||||
SecurityConfig security_config;
|
||||
|
@ -366,20 +378,25 @@ void IUserLocalCommunicationService::CreateNetworkPrivate(Kernel::HLERequestCont
|
|||
|
||||
const auto parameters{rp.PopRaw<Parameters>()};
|
||||
|
||||
LOG_WARNING(Service_LDN,
|
||||
"(STUBBED) called, passphrase_size={}, security_mode={}, "
|
||||
"local_communication_version={}",
|
||||
parameters.security_config.passphrase_size,
|
||||
parameters.security_config.security_mode,
|
||||
parameters.network_config.local_communication_version);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void DestroyNetwork(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_LDN, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void IUserLocalCommunicationService::DestroyNetwork(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_LDN, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void IUserLocalCommunicationService::SetAdvertiseData(Kernel::HLERequestContext& ctx) {
|
||||
void SetAdvertiseData(Kernel::HLERequestContext& ctx) {
|
||||
std::vector<u8> read_buffer = ctx.ReadBuffer();
|
||||
|
||||
LOG_WARNING(Service_LDN, "(STUBBED) called, size {}", read_buffer.size());
|
||||
|
@ -388,37 +405,35 @@ void IUserLocalCommunicationService::SetAdvertiseData(Kernel::HLERequestContext&
|
|||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void IUserLocalCommunicationService::SetStationAcceptPolicy(Kernel::HLERequestContext& ctx) {
|
||||
void SetStationAcceptPolicy(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_LDN, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void IUserLocalCommunicationService::AddAcceptFilterEntry(Kernel::HLERequestContext& ctx) {
|
||||
void AddAcceptFilterEntry(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_LDN, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void IUserLocalCommunicationService::OpenStation(Kernel::HLERequestContext& ctx) {
|
||||
void OpenStation(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_LDN, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void IUserLocalCommunicationService::CloseStation(Kernel::HLERequestContext& ctx) {
|
||||
void CloseStation(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_LDN, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void IUserLocalCommunicationService::Connect(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_LDN, "(STUBBED) called");
|
||||
|
||||
void Connect(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
struct Parameters {
|
||||
SecurityConfig security_config;
|
||||
|
@ -430,6 +445,13 @@ void IUserLocalCommunicationService::Connect(Kernel::HLERequestContext& ctx) {
|
|||
|
||||
const auto parameters{rp.PopRaw<Parameters>()};
|
||||
|
||||
LOG_WARNING(Service_LDN,
|
||||
"(STUBBED) called, passphrase_size={}, security_mode={}, "
|
||||
"local_communication_version={}",
|
||||
parameters.security_config.passphrase_size,
|
||||
parameters.security_config.security_mode,
|
||||
parameters.local_communication_version);
|
||||
|
||||
const std::vector<u8> read_buffer = ctx.ReadBuffer();
|
||||
NetworkInfo network_info{};
|
||||
|
||||
|
@ -446,13 +468,13 @@ void IUserLocalCommunicationService::Connect(Kernel::HLERequestContext& ctx) {
|
|||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void IUserLocalCommunicationService::Disconnect(Kernel::HLERequestContext& ctx) {
|
||||
void Disconnect(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_LDN, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
void IUserLocalCommunicationService::Initialize(Kernel::HLERequestContext& ctx) {
|
||||
void Initialize(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_LDN, "(STUBBED) called");
|
||||
|
||||
const auto rc = InitializeImpl(ctx);
|
||||
|
@ -461,7 +483,7 @@ void IUserLocalCommunicationService::Initialize(Kernel::HLERequestContext& ctx)
|
|||
rb.Push(rc);
|
||||
}
|
||||
|
||||
void IUserLocalCommunicationService::Finalize(Kernel::HLERequestContext& ctx) {
|
||||
void Finalize(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_LDN, "(STUBBED) called");
|
||||
|
||||
is_initialized = false;
|
||||
|
@ -470,7 +492,7 @@ void IUserLocalCommunicationService::Finalize(Kernel::HLERequestContext& ctx) {
|
|||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void IUserLocalCommunicationService::Initialize2(Kernel::HLERequestContext& ctx) {
|
||||
void Initialize2(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_LDN, "(STUBBED) called");
|
||||
|
||||
const auto rc = InitializeImpl(ctx);
|
||||
|
@ -479,7 +501,7 @@ void IUserLocalCommunicationService::Initialize2(Kernel::HLERequestContext& ctx)
|
|||
rb.Push(rc);
|
||||
}
|
||||
|
||||
Result IUserLocalCommunicationService::InitializeImpl(Kernel::HLERequestContext& ctx) {
|
||||
Result InitializeImpl(Kernel::HLERequestContext& ctx) {
|
||||
const auto network_interface = Network::GetSelectedNetworkInterface();
|
||||
if (!network_interface) {
|
||||
LOG_ERROR(Service_LDN, "No network interface is set");
|
||||
|
@ -491,6 +513,13 @@ Result IUserLocalCommunicationService::InitializeImpl(Kernel::HLERequestContext&
|
|||
return ResultAirplaneModeEnabled;
|
||||
}
|
||||
|
||||
KernelHelpers::ServiceContext service_context;
|
||||
Kernel::KEvent* state_change_event;
|
||||
Network::RoomNetwork& room_network;
|
||||
|
||||
bool is_initialized{};
|
||||
};
|
||||
|
||||
class LDNS final : public ServiceFramework<LDNS> {
|
||||
public:
|
||||
explicit LDNS(Core::System& system_) : ServiceFramework{system_, "ldn:s"} {
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
#include "core/hle/kernel/k_event.h"
|
||||
#include "core/hle/result.h"
|
||||
#include "core/hle/service/kernel_helpers.h"
|
||||
#include "core/hle/service/ldn/ldn_results.h"
|
||||
#include "core/hle/service/ldn/ldn_types.h"
|
||||
#include "core/hle/service/sm/sm.h"
|
||||
|
||||
namespace Core {
|
||||
|
@ -24,68 +22,4 @@ namespace Service::LDN {
|
|||
/// Registers all LDN services with the specified service manager.
|
||||
void InstallInterfaces(SM::ServiceManager& sm, Core::System& system);
|
||||
|
||||
class IUserLocalCommunicationService final
|
||||
: public ServiceFramework<IUserLocalCommunicationService> {
|
||||
public:
|
||||
explicit IUserLocalCommunicationService(Core::System& system_);
|
||||
~IUserLocalCommunicationService() override;
|
||||
|
||||
void GetState(Kernel::HLERequestContext& ctx);
|
||||
|
||||
void GetNetworkInfo(Kernel::HLERequestContext& ctx);
|
||||
|
||||
void GetDisconnectReason(Kernel::HLERequestContext& ctx);
|
||||
|
||||
void GetSecurityParameter(Kernel::HLERequestContext& ctx);
|
||||
|
||||
void GetNetworkConfig(Kernel::HLERequestContext& ctx);
|
||||
|
||||
void AttachStateChangeEvent(Kernel::HLERequestContext& ctx);
|
||||
|
||||
void GetNetworkInfoLatestUpdate(Kernel::HLERequestContext& ctx);
|
||||
|
||||
void Scan(Kernel::HLERequestContext& ctx);
|
||||
void ScanPrivate(Kernel::HLERequestContext& ctx);
|
||||
void ScanImpl(Kernel::HLERequestContext& ctx, bool is_private = false);
|
||||
|
||||
void OpenAccessPoint(Kernel::HLERequestContext& ctx);
|
||||
|
||||
void CloseAccessPoint(Kernel::HLERequestContext& ctx);
|
||||
|
||||
void CreateNetwork(Kernel::HLERequestContext& ctx);
|
||||
void CreateNetworkPrivate(Kernel::HLERequestContext& ctx);
|
||||
|
||||
void DestroyNetwork(Kernel::HLERequestContext& ctx);
|
||||
|
||||
void SetAdvertiseData(Kernel::HLERequestContext& ctx);
|
||||
|
||||
void SetStationAcceptPolicy(Kernel::HLERequestContext& ctx);
|
||||
|
||||
void AddAcceptFilterEntry(Kernel::HLERequestContext& ctx);
|
||||
|
||||
void OpenStation(Kernel::HLERequestContext& ctx);
|
||||
|
||||
void CloseStation(Kernel::HLERequestContext& ctx);
|
||||
|
||||
void Disconnect(Kernel::HLERequestContext& ctx);
|
||||
|
||||
void Connect(Kernel::HLERequestContext& ctx);
|
||||
|
||||
void Initialize(Kernel::HLERequestContext& ctx);
|
||||
|
||||
void Finalize(Kernel::HLERequestContext& ctx);
|
||||
|
||||
void Initialize2(Kernel::HLERequestContext& ctx);
|
||||
Result InitializeImpl(Kernel::HLERequestContext& ctx);
|
||||
|
||||
private:
|
||||
void OnEventFired();
|
||||
|
||||
KernelHelpers::ServiceContext service_context;
|
||||
Kernel::KEvent* state_change_event;
|
||||
Network::RoomNetwork& room_network;
|
||||
|
||||
bool is_initialized{};
|
||||
};
|
||||
|
||||
} // namespace Service::LDN
|
||||
|
|
Loading…
Reference in a new issue