diff options
-rw-r--r-- | src/core/hle/service/ldn/ldn.cpp | 565 | ||||
-rw-r--r-- | src/core/hle/service/ldn/ldn.h | 66 |
2 files changed, 297 insertions, 334 deletions
diff --git a/src/core/hle/service/ldn/ldn.cpp b/src/core/hle/service/ldn/ldn.cpp index ff4169f8e..c11daff54 100644 --- a/src/core/hle/service/ldn/ldn.cpp +++ b/src/core/hle/service/ldn/ldn.cpp @@ -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,11 +100,14 @@ public: } }; -IUserLocalCommunicationService::IUserLocalCommunicationService(Core::System& system_) - : ServiceFramework{system_, "IUserLocalCommunicationService", ServiceThreadType::CreateNew}, - service_context{system, "IUserLocalCommunicationService"}, room_network{ - system_.GetRoomNetwork()} { - // clang-format off +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()} { + // clang-format off static const FunctionInfo functions[] = { {0, &IUserLocalCommunicationService::GetState, "GetState"}, {1, &IUserLocalCommunicationService::GetNetworkInfo, "GetNetworkInfo"}, @@ -134,362 +139,386 @@ IUserLocalCommunicationService::IUserLocalCommunicationService(Core::System& sys {401, &IUserLocalCommunicationService::Finalize, "Finalize"}, {402, &IUserLocalCommunicationService::Initialize2, "Initialize2"}, }; - // clang-format on - - RegisterHandlers(functions); - - state_change_event = - service_context.CreateEvent("IUserLocalCommunicationService:StateChangeEvent"); -} + // clang-format on -IUserLocalCommunicationService::~IUserLocalCommunicationService() { - service_context.CloseEvent(state_change_event); -} + RegisterHandlers(functions); -void IUserLocalCommunicationService::OnEventFired() { - state_change_event->GetWritableEvent().Signal(); -} + state_change_event = + service_context.CreateEvent("IUserLocalCommunicationService:StateChangeEvent"); + } -void IUserLocalCommunicationService::GetState(Kernel::HLERequestContext& ctx) { - State state = State::Error; - LOG_WARNING(Service_LDN, "(STUBBED) called, state = {}", state); + ~IUserLocalCommunicationService() { + service_context.CloseEvent(state_change_event); + } - IPC::ResponseBuilder rb{ctx, 3}; - rb.Push(ResultSuccess); - rb.PushEnum(state); -} + void OnEventFired() { + state_change_event->GetWritableEvent().Signal(); + } -void IUserLocalCommunicationService::GetNetworkInfo(Kernel::HLERequestContext& ctx) { - const auto write_buffer_size = ctx.GetWriteBufferSize(); + void GetState(Kernel::HLERequestContext& ctx) { + State state = State::Error; + LOG_WARNING(Service_LDN, "(STUBBED) called, state = {}", state); - 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; + IPC::ResponseBuilder rb{ctx, 3}; + rb.Push(ResultSuccess); + rb.PushEnum(state); } - NetworkInfo network_info{}; - const auto rc = ResultSuccess; - if (rc.IsError()) { - LOG_ERROR(Service_LDN, "NetworkInfo is not valid {}", rc.raw); + void GetNetworkInfo(Kernel::HLERequestContext& ctx) { + 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{}; + const auto rc = ResultSuccess; + if (rc.IsError()) { + LOG_ERROR(Service_LDN, "NetworkInfo is not valid {}", rc.raw); + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(rc); + return; + } + + LOG_WARNING(Service_LDN, "(STUBBED) called, ssid='{}', nodes={}", + network_info.common.ssid.GetStringValue(), network_info.ldn.node_count); + + ctx.WriteBuffer<NetworkInfo>(network_info); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(rc); - return; } - LOG_WARNING(Service_LDN, "(STUBBED) called, ssid='{}', nodes={}", - network_info.common.ssid.GetStringValue(), network_info.ldn.node_count); + void GetDisconnectReason(Kernel::HLERequestContext& ctx) { + const auto disconnect_reason = DisconnectReason::None; - ctx.WriteBuffer<NetworkInfo>(network_info); - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(rc); -} + LOG_WARNING(Service_LDN, "(STUBBED) called, disconnect_reason={}", disconnect_reason); -void IUserLocalCommunicationService::GetDisconnectReason(Kernel::HLERequestContext& ctx) { - const auto disconnect_reason = DisconnectReason::None; + IPC::ResponseBuilder rb{ctx, 3}; + rb.Push(ResultSuccess); + rb.PushEnum(disconnect_reason); + } - LOG_WARNING(Service_LDN, "(STUBBED) called, disconnect_reason={}", disconnect_reason); + void GetSecurityParameter(Kernel::HLERequestContext& ctx) { + SecurityParameter security_parameter{}; + NetworkInfo info{}; + const Result rc = ResultSuccess; - IPC::ResponseBuilder rb{ctx, 3}; - rb.Push(ResultSuccess); - rb.PushEnum(disconnect_reason); -} + if (rc.IsError()) { + LOG_ERROR(Service_LDN, "NetworkInfo is not valid {}", rc.raw); + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(rc); + return; + } -void IUserLocalCommunicationService::GetSecurityParameter(Kernel::HLERequestContext& ctx) { - SecurityParameter security_parameter; - NetworkInfo info; - const Result rc = ResultSuccess; + security_parameter.session_id = info.network_id.session_id; + std::memcpy(security_parameter.data.data(), info.ldn.security_parameter.data(), + sizeof(SecurityParameter::data)); - if (rc.IsError()) { - LOG_ERROR(Service_LDN, "NetworkInfo is not valid {}", rc.raw); - IPC::ResponseBuilder rb{ctx, 2}; + LOG_WARNING(Service_LDN, "(STUBBED) called"); + + IPC::ResponseBuilder rb{ctx, 10}; rb.Push(rc); - return; + rb.PushRaw<SecurityParameter>(security_parameter); } - security_parameter.session_id = info.network_id.session_id; - std::memcpy(security_parameter.data.data(), info.ldn.security_parameter.data(), - sizeof(SecurityParameter::data)); - - LOG_WARNING(Service_LDN, "(STUBBED) called"); - - IPC::ResponseBuilder rb{ctx, 10}; - rb.Push(rc); - rb.PushRaw<SecurityParameter>(security_parameter); -} + void GetNetworkConfig(Kernel::HLERequestContext& ctx) { + NetworkConfig config{}; + NetworkInfo info{}; + const Result rc = ResultSuccess; + + 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; + + 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); + + IPC::ResponseBuilder rb{ctx, 10}; + rb.Push(rc); + rb.PushRaw<NetworkConfig>(config); + } -void IUserLocalCommunicationService::GetNetworkConfig(Kernel::HLERequestContext& ctx) { - NetworkConfig config; - NetworkInfo info; - const Result rc = ResultSuccess; + void AttachStateChangeEvent(Kernel::HLERequestContext& ctx) { + LOG_INFO(Service_LDN, "called"); - if (rc.IsError()) { - LOG_ERROR(Service_LDN, "NetworkConfig is not valid {}", rc.raw); - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(rc); - return; + IPC::ResponseBuilder rb{ctx, 2, 1}; + rb.Push(ResultSuccess); + rb.PushCopyObjects(state_change_event->GetReadableEvent()); } - 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; + 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); - 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); + if (node_buffer_count == 0 || network_buffer_size != sizeof(NetworkInfo)) { + LOG_ERROR(Service_LDN, "Invalid buffer size {}, {}", network_buffer_size, + node_buffer_count); + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultBadInput); + return; + } - IPC::ResponseBuilder rb{ctx, 10}; - rb.Push(rc); - rb.PushRaw<NetworkConfig>(config); -} + NetworkInfo info; + std::vector<NodeLatestUpdate> latest_update(node_buffer_count); -void IUserLocalCommunicationService::AttachStateChangeEvent(Kernel::HLERequestContext& ctx) { - LOG_INFO(Service_LDN, "called"); + const auto rc = ResultSuccess; + if (rc.IsError()) { + LOG_ERROR(Service_LDN, "NetworkInfo is not valid {}", rc.raw); + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(rc); + return; + } - IPC::ResponseBuilder rb{ctx, 2, 1}; - rb.Push(ResultSuccess); - rb.PushCopyObjects(state_change_event->GetReadableEvent()); -} + LOG_WARNING(Service_LDN, "(STUBBED) called, ssid='{}', nodes={}", + info.common.ssid.GetStringValue(), info.ldn.node_count); -void IUserLocalCommunicationService::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); + ctx.WriteBuffer(info, 0); + ctx.WriteBuffer(latest_update, 1); - if (node_buffer_count == 0 || network_buffer_size != sizeof(NetworkInfo)) { - LOG_ERROR(Service_LDN, "Invalid buffer size {}, {}", network_buffer_size, - node_buffer_count); IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultBadInput); - return; + rb.Push(ResultSuccess); } - NetworkInfo info; - std::vector<NodeLatestUpdate> latest_update(node_buffer_count); - - const auto rc = ResultSuccess; - if (rc.IsError()) { - LOG_ERROR(Service_LDN, "NetworkInfo is not valid {}", rc.raw); - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(rc); - return; + void Scan(Kernel::HLERequestContext& ctx) { + ScanImpl(ctx); } - LOG_WARNING(Service_LDN, "(STUBBED) called, ssid='{}', nodes={}", - info.common.ssid.GetStringValue(), info.ldn.node_count); + void ScanPrivate(Kernel::HLERequestContext& ctx) { + ScanImpl(ctx, true); + } - ctx.WriteBuffer(info, 0); - ctx.WriteBuffer(latest_update, 1); + 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>()}; - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSuccess); -} + const std::size_t network_info_size = ctx.GetWriteBufferSize() / sizeof(NetworkInfo); -void IUserLocalCommunicationService::Scan(Kernel::HLERequestContext& ctx) { - ScanImpl(ctx); -} + if (network_info_size == 0) { + LOG_ERROR(Service_LDN, "Invalid buffer size {}", network_info_size); + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultBadInput); + return; + } -void IUserLocalCommunicationService::ScanPrivate(Kernel::HLERequestContext& ctx) { - ScanImpl(ctx, true); -} + u16 count = 0; + std::vector<NetworkInfo> network_infos(network_info_size); -void IUserLocalCommunicationService::ScanImpl(Kernel::HLERequestContext& ctx, bool is_private) { - IPC::RequestParser rp{ctx}; - const auto channel{rp.PopEnum<WifiChannel>()}; - const auto scan_filter{rp.PopRaw<ScanFilter>()}; + LOG_WARNING(Service_LDN, + "(STUBBED) called, channel={}, filter_scan_flag={}, filter_network_type={}", + channel, scan_filter.flag, scan_filter.network_type); - const std::size_t network_info_size = ctx.GetWriteBufferSize() / sizeof(NetworkInfo); + ctx.WriteBuffer(network_infos); - if (network_info_size == 0) { - LOG_ERROR(Service_LDN, "Invalid buffer size {}", network_info_size); - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultBadInput); - return; + IPC::ResponseBuilder rb{ctx, 3}; + rb.Push(ResultSuccess); + rb.Push<u32>(count); } - u16 count = 0; - std::vector<NetworkInfo> network_infos(network_info_size); - - LOG_WARNING(Service_LDN, - "(STUBBED) called, channel={}, filter_scan_flag={}, filter_network_type={}", - channel, scan_filter.flag, scan_filter.network_type); + void OpenAccessPoint(Kernel::HLERequestContext& ctx) { + LOG_WARNING(Service_LDN, "(STUBBED) called"); - ctx.WriteBuffer(network_infos); + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); + } - IPC::ResponseBuilder rb{ctx, 3}; - rb.Push(ResultSuccess); - rb.Push<u32>(count); -} + void CloseAccessPoint(Kernel::HLERequestContext& ctx) { + LOG_WARNING(Service_LDN, "(STUBBED) called"); -void IUserLocalCommunicationService::OpenAccessPoint(Kernel::HLERequestContext& ctx) { - LOG_WARNING(Service_LDN, "(STUBBED) called"); + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); + } - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSuccess); -} + void CreateNetwork(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp{ctx}; + struct Parameters { + SecurityConfig security_config; + UserConfig user_config; + INSERT_PADDING_WORDS_NOINIT(1); + NetworkConfig network_config; + }; + static_assert(sizeof(Parameters) == 0x98, "Parameters has incorrect size."); -void IUserLocalCommunicationService::CloseAccessPoint(Kernel::HLERequestContext& ctx) { - LOG_WARNING(Service_LDN, "(STUBBED) called"); + const auto parameters{rp.PopRaw<Parameters>()}; - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSuccess); -} + 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); -void IUserLocalCommunicationService::CreateNetwork(Kernel::HLERequestContext& ctx) { - IPC::RequestParser rp{ctx}; - struct Parameters { - SecurityConfig security_config; - UserConfig user_config; - INSERT_PADDING_WORDS_NOINIT(1); - NetworkConfig network_config; - }; - static_assert(sizeof(Parameters) == 0x98, "Parameters has incorrect size."); + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); + } - LOG_WARNING(Service_LDN, "(STUBBED) called"); + void CreateNetworkPrivate(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp{ctx}; + struct Parameters { + SecurityConfig security_config; + SecurityParameter security_parameter; + UserConfig user_config; + NetworkConfig network_config; + }; + static_assert(sizeof(Parameters) == 0xB8, "Parameters has incorrect size."); - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSuccess); -} + const auto parameters{rp.PopRaw<Parameters>()}; -void IUserLocalCommunicationService::CreateNetworkPrivate(Kernel::HLERequestContext& ctx) { - IPC::RequestParser rp{ctx}; - struct Parameters { - SecurityConfig security_config; - SecurityParameter security_parameter; - UserConfig user_config; - NetworkConfig network_config; - }; - static_assert(sizeof(Parameters) == 0xB8, "Parameters has incorrect size."); + 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); - const auto parameters{rp.PopRaw<Parameters>()}; + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); + } - LOG_WARNING(Service_LDN, "(STUBBED) called"); + void DestroyNetwork(Kernel::HLERequestContext& ctx) { + LOG_WARNING(Service_LDN, "(STUBBED) called"); - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSuccess); -} + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); + } -void IUserLocalCommunicationService::DestroyNetwork(Kernel::HLERequestContext& ctx) { - LOG_WARNING(Service_LDN, "(STUBBED) called"); + void SetAdvertiseData(Kernel::HLERequestContext& ctx) { + std::vector<u8> read_buffer = ctx.ReadBuffer(); - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSuccess); -} + LOG_WARNING(Service_LDN, "(STUBBED) called, size {}", read_buffer.size()); -void IUserLocalCommunicationService::SetAdvertiseData(Kernel::HLERequestContext& ctx) { - std::vector<u8> read_buffer = ctx.ReadBuffer(); + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); + } - LOG_WARNING(Service_LDN, "(STUBBED) called, size {}", read_buffer.size()); + void SetStationAcceptPolicy(Kernel::HLERequestContext& ctx) { + LOG_WARNING(Service_LDN, "(STUBBED) called"); - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSuccess); -} + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); + } -void IUserLocalCommunicationService::SetStationAcceptPolicy(Kernel::HLERequestContext& ctx) { - LOG_WARNING(Service_LDN, "(STUBBED) called"); + void AddAcceptFilterEntry(Kernel::HLERequestContext& ctx) { + LOG_WARNING(Service_LDN, "(STUBBED) called"); - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSuccess); -} + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); + } -void IUserLocalCommunicationService::AddAcceptFilterEntry(Kernel::HLERequestContext& ctx) { - LOG_WARNING(Service_LDN, "(STUBBED) called"); + void OpenStation(Kernel::HLERequestContext& ctx) { + LOG_WARNING(Service_LDN, "(STUBBED) called"); - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSuccess); -} + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); + } -void IUserLocalCommunicationService::OpenStation(Kernel::HLERequestContext& ctx) { - LOG_WARNING(Service_LDN, "(STUBBED) called"); + void CloseStation(Kernel::HLERequestContext& ctx) { + LOG_WARNING(Service_LDN, "(STUBBED) called"); - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSuccess); -} + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); + } -void IUserLocalCommunicationService::CloseStation(Kernel::HLERequestContext& ctx) { - LOG_WARNING(Service_LDN, "(STUBBED) called"); + void Connect(Kernel::HLERequestContext& ctx) { + 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."); - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSuccess); -} + const auto parameters{rp.PopRaw<Parameters>()}; -void IUserLocalCommunicationService::Connect(Kernel::HLERequestContext& ctx) { - LOG_WARNING(Service_LDN, "(STUBBED) called"); + 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); - 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."); + const std::vector<u8> read_buffer = ctx.ReadBuffer(); + NetworkInfo network_info{}; - const auto parameters{rp.PopRaw<Parameters>()}; + 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; + } - const std::vector<u8> read_buffer = ctx.ReadBuffer(); - NetworkInfo network_info{}; + std::memcpy(&network_info, read_buffer.data(), read_buffer.size()); - 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; + rb.Push(ResultSuccess); } - std::memcpy(&network_info, read_buffer.data(), read_buffer.size()); - - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSuccess); -} + void Disconnect(Kernel::HLERequestContext& ctx) { + LOG_WARNING(Service_LDN, "(STUBBED) called"); -void IUserLocalCommunicationService::Disconnect(Kernel::HLERequestContext& ctx) { - LOG_WARNING(Service_LDN, "(STUBBED) called"); + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); + } + void Initialize(Kernel::HLERequestContext& ctx) { + LOG_WARNING(Service_LDN, "(STUBBED) called"); - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSuccess); -} -void IUserLocalCommunicationService::Initialize(Kernel::HLERequestContext& ctx) { - LOG_WARNING(Service_LDN, "(STUBBED) called"); + const auto rc = InitializeImpl(ctx); - const auto rc = InitializeImpl(ctx); + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(rc); + } - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(rc); -} + void Finalize(Kernel::HLERequestContext& ctx) { + LOG_WARNING(Service_LDN, "(STUBBED) called"); -void IUserLocalCommunicationService::Finalize(Kernel::HLERequestContext& ctx) { - LOG_WARNING(Service_LDN, "(STUBBED) called"); + is_initialized = false; - is_initialized = false; + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); + } - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSuccess); -} + void Initialize2(Kernel::HLERequestContext& ctx) { + LOG_WARNING(Service_LDN, "(STUBBED) called"); -void IUserLocalCommunicationService::Initialize2(Kernel::HLERequestContext& ctx) { - LOG_WARNING(Service_LDN, "(STUBBED) called"); + const auto rc = InitializeImpl(ctx); - const auto rc = InitializeImpl(ctx); + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(rc); + } - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(rc); -} + Result InitializeImpl(Kernel::HLERequestContext& ctx) { + const auto network_interface = Network::GetSelectedNetworkInterface(); + if (!network_interface) { + LOG_ERROR(Service_LDN, "No network interface is set"); + return ResultAirplaneModeEnabled; + } -Result IUserLocalCommunicationService::InitializeImpl(Kernel::HLERequestContext& ctx) { - const auto network_interface = Network::GetSelectedNetworkInterface(); - if (!network_interface) { - LOG_ERROR(Service_LDN, "No network interface is set"); + is_initialized = true; + // TODO (flTobi): Change this to ResultSuccess when LDN is fully implemented return ResultAirplaneModeEnabled; } - is_initialized = true; - // TODO (flTobi): Change this to ResultSuccess when LDN is fully implemented - 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: diff --git a/src/core/hle/service/ldn/ldn.h b/src/core/hle/service/ldn/ldn.h index 4ab8f7a9b..6afe2ea6f 100644 --- a/src/core/hle/service/ldn/ldn.h +++ b/src/core/hle/service/ldn/ldn.h @@ -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 |