From 5353d539cef716fc6ee922cc993ccfcb0c894748 Mon Sep 17 00:00:00 2001 From: Weiyi Wang Date: Tue, 12 Mar 2019 22:42:17 -0400 Subject: [PATCH] UDS: divide IPC and impl for BeginHostingNetwork --- src/core/hle/service/nwm/nwm_uds.cpp | 35 +++++++++++++++++----------- src/core/hle/service/nwm/nwm_uds.h | 3 +++ 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/core/hle/service/nwm/nwm_uds.cpp b/src/core/hle/service/nwm/nwm_uds.cpp index 3fb9326c5..f93edfc94 100644 --- a/src/core/hle/service/nwm/nwm_uds.cpp +++ b/src/core/hle/service/nwm/nwm_uds.cpp @@ -814,23 +814,14 @@ void NWM_UDS::Unbind(Kernel::HLERequestContext& ctx) { rb.Push(0); } -void NWM_UDS::BeginHostingNetwork(Kernel::HLERequestContext& ctx) { - IPC::RequestParser rp(ctx, 0x1D, 1, 4); - - const u32 passphrase_size = rp.Pop(); - - const std::vector network_info_buffer = rp.PopStaticBuffer(); - ASSERT(network_info_buffer.size() == sizeof(NetworkInfo)); - const std::vector passphrase = rp.PopStaticBuffer(); - ASSERT(passphrase.size() == passphrase_size); - +ResultCode NWM_UDS::BeginHostingNetwork(const u8* network_info_buffer, + std::size_t network_info_size, std::vector passphrase) { // TODO(Subv): Store the passphrase and verify it when attempting a connection. - LOG_DEBUG(Service_NWM, "called"); - { std::lock_guard lock(connection_status_mutex); - std::memcpy(&network_info, network_info_buffer.data(), sizeof(NetworkInfo)); + network_info = {}; + std::memcpy(&network_info, network_info_buffer, network_info_size); // The real UDS module throws a fatal error if this assert fails. ASSERT_MSG(network_info.max_nodes > 1, "Trying to host a network of only one member."); @@ -886,10 +877,26 @@ void NWM_UDS::BeginHostingNetwork(Kernel::HLERequestContext& ctx) { system.CoreTiming().ScheduleEvent(msToCycles(DefaultBeaconInterval * MillisecondsPerTU), beacon_broadcast_event, 0); + return RESULT_SUCCESS; +} + +void NWM_UDS::BeginHostingNetwork(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp(ctx, 0x1D, 1, 4); + + const u32 passphrase_size = rp.Pop(); + + const std::vector network_info_buffer = rp.PopStaticBuffer(); + ASSERT(network_info_buffer.size() == sizeof(NetworkInfo)); + std::vector passphrase = rp.PopStaticBuffer(); + ASSERT(passphrase.size() == passphrase_size); + + LOG_DEBUG(Service_NWM, "called"); + auto result = BeginHostingNetwork(network_info_buffer.data(), network_info_buffer.size(), + std::move(passphrase)); LOG_DEBUG(Service_NWM, "An UDS network has been created."); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); - rb.Push(RESULT_SUCCESS); + rb.Push(result); } void NWM_UDS::UpdateNetworkAttribute(Kernel::HLERequestContext& ctx) { diff --git a/src/core/hle/service/nwm/nwm_uds.h b/src/core/hle/service/nwm/nwm_uds.h index 0b59abd55..61482ac45 100644 --- a/src/core/hle/service/nwm/nwm_uds.h +++ b/src/core/hle/service/nwm/nwm_uds.h @@ -388,6 +388,9 @@ private: u32 sharedmem_size, const NodeInfo& node, u16 version, Kernel::SharedPtr sharedmem); + ResultCode BeginHostingNetwork(const u8* network_info_buffer, std::size_t network_info_size, + std::vector passphrase); + void BeaconBroadcastCallback(u64 userdata, s64 cycles_late); /**