From 42b32ac1ea3c6922855627f898176c1de8ef7f3e Mon Sep 17 00:00:00 2001 From: NarcolepticK Date: Fri, 22 Jun 2018 04:16:38 -0400 Subject: [PATCH] service/nwm: Migrate logging macros --- src/core/hle/service/nwm/nwm_uds.cpp | 81 ++++++++++++++------------- src/core/hle/service/nwm/uds_data.cpp | 4 +- 2 files changed, 43 insertions(+), 42 deletions(-) diff --git a/src/core/hle/service/nwm/nwm_uds.cpp b/src/core/hle/service/nwm/nwm_uds.cpp index 1d55bf0b9..9b3cb3cd0 100644 --- a/src/core/hle/service/nwm/nwm_uds.cpp +++ b/src/core/hle/service/nwm/nwm_uds.cpp @@ -238,8 +238,8 @@ static void HandleEAPoLPacket(const Network::WifiPacket& packet) { if (GetEAPoLFrameType(packet.data) == EAPoLStartMagic) { if (connection_status.status != static_cast(NetworkStatus::ConnectedAsHost)) { - LOG_DEBUG(Service_NWM, "Connection sequence aborted, because connection status is %u", - connection_status.status); + NGLOG_DEBUG(Service_NWM, "Connection sequence aborted, because connection status is {}", + connection_status.status); return; } @@ -247,7 +247,7 @@ static void HandleEAPoLPacket(const Network::WifiPacket& packet) { if (connection_status.max_nodes == connection_status.total_nodes) { // Reject connection attempt - LOG_ERROR(Service_NWM, "Reached maximum nodes, but reject packet wasn't sent."); + NGLOG_ERROR(Service_NWM, "Reached maximum nodes, but reject packet wasn't sent."); // TODO(B3N30): Figure out what packet is sent here return; } @@ -425,8 +425,8 @@ void SendAssociationResponseFrame(const MacAddress& address) { { std::lock_guard lock(connection_status_mutex); if (connection_status.status != static_cast(NetworkStatus::ConnectedAsHost)) { - LOG_ERROR(Service_NWM, "Connection sequence aborted, because connection status is %u", - connection_status.status); + NGLOG_ERROR(Service_NWM, "Connection sequence aborted, because connection status is {}", + connection_status.status); return; } @@ -457,9 +457,9 @@ void HandleAuthenticationFrame(const Network::WifiPacket& packet) { { std::lock_guard lock(connection_status_mutex); if (connection_status.status != static_cast(NetworkStatus::ConnectedAsHost)) { - LOG_ERROR(Service_NWM, - "Connection sequence aborted, because connection status is %u", - connection_status.status); + NGLOG_ERROR(Service_NWM, + "Connection sequence aborted, because connection status is {}", + connection_status.status); return; } @@ -477,16 +477,16 @@ void HandleAuthenticationFrame(const Network::WifiPacket& packet) { /// Handles the deauthentication frames sent from clients to hosts, when they leave a session void HandleDeauthenticationFrame(const Network::WifiPacket& packet) { - LOG_DEBUG(Service_NWM, "called"); + NGLOG_DEBUG(Service_NWM, "called"); std::unique_lock hle_lock(HLE::g_hle_lock, std::defer_lock); std::unique_lock lock(connection_status_mutex, std::defer_lock); std::lock(hle_lock, lock); if (connection_status.status != static_cast(NetworkStatus::ConnectedAsHost)) { - LOG_ERROR(Service_NWM, "Got deauthentication frame but we are not the host"); + NGLOG_ERROR(Service_NWM, "Got deauthentication frame but we are not the host"); return; } if (node_map.find(packet.transmitter_address) == node_map.end()) { - LOG_ERROR(Service_NWM, "Got deauthentication frame from unknown node"); + NGLOG_ERROR(Service_NWM, "Got deauthentication frame from unknown node"); return; } @@ -555,7 +555,7 @@ void NWM_UDS::Shutdown(Kernel::HLERequestContext& ctx) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); rb.Push(RESULT_SUCCESS); - LOG_DEBUG(Service_NWM, "called"); + NGLOG_DEBUG(Service_NWM, "called"); } void NWM_UDS::RecvBeaconBroadcastData(Kernel::HLERequestContext& ctx) { @@ -617,10 +617,10 @@ void NWM_UDS::RecvBeaconBroadcastData(Kernel::HLERequestContext& ctx) { rb.Push(RESULT_SUCCESS); rb.PushMappedBuffer(out_buffer); - LOG_DEBUG(Service_NWM, - "called out_buffer_size=0x%08X, wlan_comm_id=0x%08X, id=0x%08X," - "unk1=0x%08X, unk2=0x%08X, offset=%zu", - out_buffer_size, wlan_comm_id, id, unk1, unk2, cur_buffer_size); + NGLOG_DEBUG(Service_NWM, + "called out_buffer_size=0x{:08X}, wlan_comm_id=0x{:08X}, id=0x{:08X}," + "unk1=0x{:08X}, unk2=0x{:08X}, offset={}", + out_buffer_size, wlan_comm_id, id, unk1, unk2, cur_buffer_size); } void NWM_UDS::InitializeWithVersion(Kernel::HLERequestContext& ctx) { @@ -642,7 +642,7 @@ void NWM_UDS::InitializeWithVersion(Kernel::HLERequestContext& ctx) { if (auto room_member = Network::GetRoomMember().lock()) { wifi_packet_received = room_member->BindOnWifiPacketReceived(OnWifiPacketReceived); } else { - LOG_ERROR(Service_NWM, "Network isn't initalized"); + NGLOG_ERROR(Service_NWM, "Network isn't initalized"); } { @@ -660,7 +660,8 @@ void NWM_UDS::InitializeWithVersion(Kernel::HLERequestContext& ctx) { rb.Push(RESULT_SUCCESS); rb.PushCopyObjects(connection_status_event); - LOG_DEBUG(Service_NWM, "called sharedmem_size=0x%08X, version=0x%08X", sharedmem_size, version); + NGLOG_DEBUG(Service_NWM, "called sharedmem_size=0x{:08X}, version=0x{:08X}", sharedmem_size, + version); } void NWM_UDS::GetConnectionStatus(Kernel::HLERequestContext& ctx) { @@ -679,7 +680,7 @@ void NWM_UDS::GetConnectionStatus(Kernel::HLERequestContext& ctx) { connection_status.changed_nodes = 0; } - LOG_DEBUG(Service_NWM, "called"); + NGLOG_DEBUG(Service_NWM, "called"); } void NWM_UDS::GetNodeInformation(Kernel::HLERequestContext& ctx) { @@ -710,7 +711,7 @@ void NWM_UDS::GetNodeInformation(Kernel::HLERequestContext& ctx) { rb.Push(RESULT_SUCCESS); rb.PushRaw(*itr); } - LOG_DEBUG(Service_NWM, "called"); + NGLOG_DEBUG(Service_NWM, "called"); } void NWM_UDS::Bind(Kernel::HLERequestContext& ctx) { @@ -721,14 +722,14 @@ void NWM_UDS::Bind(Kernel::HLERequestContext& ctx) { u8 data_channel = rp.Pop(); u16 network_node_id = rp.Pop(); - LOG_DEBUG(Service_NWM, "called"); + NGLOG_DEBUG(Service_NWM, "called"); if (data_channel == 0 || bind_node_id == 0) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); rb.Push(ResultCode(ErrorDescription::NotAuthorized, ErrorModule::UDS, ErrorSummary::WrongArgument, ErrorLevel::Usage)); - LOG_WARNING(Service_NWM, "data_channel = %d, bind_node_id = %d", data_channel, - bind_node_id); + NGLOG_WARNING(Service_NWM, "data_channel = {}, bind_node_id = {}", data_channel, + bind_node_id); return; } @@ -737,7 +738,7 @@ void NWM_UDS::Bind(Kernel::HLERequestContext& ctx) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); rb.Push(ResultCode(ErrorDescription::OutOfMemory, ErrorModule::UDS, ErrorSummary::OutOfResource, ErrorLevel::Status)); - LOG_WARNING(Service_NWM, "max bind nodes"); + NGLOG_WARNING(Service_NWM, "max bind nodes"); return; } @@ -746,7 +747,7 @@ void NWM_UDS::Bind(Kernel::HLERequestContext& ctx) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); rb.Push(ResultCode(ErrorDescription::TooLarge, ErrorModule::UDS, ErrorSummary::WrongArgument, ErrorLevel::Usage)); - LOG_WARNING(Service_NWM, "MinRecvBufferSize"); + NGLOG_WARNING(Service_NWM, "MinRecvBufferSize"); return; } @@ -807,7 +808,7 @@ void NWM_UDS::BeginHostingNetwork(Kernel::HLERequestContext& ctx) { // TODO(Subv): Store the passphrase and verify it when attempting a connection. - LOG_DEBUG(Service_NWM, "called"); + NGLOG_DEBUG(Service_NWM, "called"); { std::lock_guard lock(connection_status_mutex); @@ -867,7 +868,7 @@ void NWM_UDS::BeginHostingNetwork(Kernel::HLERequestContext& ctx) { CoreTiming::ScheduleEvent(msToCycles(DefaultBeaconInterval * MillisecondsPerTU), beacon_broadcast_event, 0); - LOG_DEBUG(Service_NWM, "An UDS network has been created."); + NGLOG_DEBUG(Service_NWM, "An UDS network has been created."); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); rb.Push(RESULT_SUCCESS); @@ -876,7 +877,7 @@ void NWM_UDS::BeginHostingNetwork(Kernel::HLERequestContext& ctx) { void NWM_UDS::UpdateNetworkAttribute(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp(ctx, 0x07, 2, 0); rp.Skip(2, false); - LOG_WARNING(Service_NWM, "stubbed"); + NGLOG_WARNING(Service_NWM, "stubbed"); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); rb.Push(RESULT_SUCCESS); } @@ -893,7 +894,7 @@ void NWM_UDS::DestroyNetwork(Kernel::HLERequestContext& ctx) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); rb.Push(ResultCode(ErrCodes::WrongStatus, ErrorModule::UDS, ErrorSummary::InvalidState, ErrorLevel::Status)); - LOG_WARNING(Service_NWM, "called with status %u", connection_status.status); + NGLOG_WARNING(Service_NWM, "called with status {}", connection_status.status); return; } @@ -915,7 +916,7 @@ void NWM_UDS::DestroyNetwork(Kernel::HLERequestContext& ctx) { rb.Push(RESULT_SUCCESS); - LOG_DEBUG(Service_NWM, "called"); + NGLOG_DEBUG(Service_NWM, "called"); } void NWM_UDS::DisconnectNetwork(Kernel::HLERequestContext& ctx) { @@ -933,7 +934,7 @@ void NWM_UDS::DisconnectNetwork(Kernel::HLERequestContext& ctx) { connection_status.status = static_cast(NetworkStatus::ConnectedAsHost); connection_status.network_node_id = tmp_node_id; node_map.clear(); - LOG_DEBUG(Service_NWM, "called as a host"); + NGLOG_DEBUG(Service_NWM, "called as a host"); rb.Push(ResultCode(ErrCodes::WrongStatus, ErrorModule::UDS, ErrorSummary::InvalidState, ErrorLevel::Status)); return; @@ -960,7 +961,7 @@ void NWM_UDS::DisconnectNetwork(Kernel::HLERequestContext& ctx) { channel_data.clear(); rb.Push(RESULT_SUCCESS); - LOG_DEBUG(Service_NWM, "called"); + NGLOG_DEBUG(Service_NWM, "called"); } void NWM_UDS::SendTo(Kernel::HLERequestContext& ctx) { @@ -991,7 +992,7 @@ void NWM_UDS::SendTo(Kernel::HLERequestContext& ctx) { } if (dest_node_id == connection_status.network_node_id) { - LOG_ERROR(Service_NWM, "tried to send packet to itself"); + NGLOG_ERROR(Service_NWM, "tried to send packet to itself"); rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::UDS, ErrorSummary::WrongArgument, ErrorLevel::Status)); return; @@ -1000,7 +1001,7 @@ void NWM_UDS::SendTo(Kernel::HLERequestContext& ctx) { Network::MacAddress dest_address; if (flags >> 2) { - LOG_ERROR(Service_NWM, "Unexpected flags 0x%02X", flags); + NGLOG_ERROR(Service_NWM, "Unexpected flags 0x{:02X}", flags); } if ((flags & (0x1 << 1)) || dest_node_id == 0xFFFF) { @@ -1012,7 +1013,7 @@ void NWM_UDS::SendTo(Kernel::HLERequestContext& ctx) { std::find_if(node_map.begin(), node_map.end(), [dest_node_id](const auto& node) { return node.second == dest_node_id; }); if (destination == node_map.end()) { - LOG_ERROR(Service_NWM, "tried to send packet to unknown dest id %u", dest_node_id); + NGLOG_ERROR(Service_NWM, "tried to send packet to unknown dest id {}", dest_node_id); rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::UDS, ErrorSummary::WrongArgument, ErrorLevel::Status)); return; @@ -1132,7 +1133,7 @@ void NWM_UDS::GetChannel(Kernel::HLERequestContext& ctx) { rb.Push(RESULT_SUCCESS); rb.Push(channel); - LOG_DEBUG(Service_NWM, "called"); + NGLOG_DEBUG(Service_NWM, "called"); } void NWM_UDS::ConnectToNetwork(Kernel::HLERequestContext& ctx) { @@ -1162,10 +1163,10 @@ void NWM_UDS::ConnectToNetwork(Kernel::HLERequestContext& ctx) { // TODO(B3N30): Add error handling for host full and timeout IPC::RequestBuilder rb(ctx, 0x1E, 1, 0); rb.Push(RESULT_SUCCESS); - LOG_DEBUG(Service_NWM, "connection sequence finished"); + NGLOG_DEBUG(Service_NWM, "connection sequence finished"); }); - LOG_DEBUG(Service_NWM, "called"); + NGLOG_DEBUG(Service_NWM, "called"); } void NWM_UDS::SetApplicationData(Kernel::HLERequestContext& ctx) { @@ -1176,7 +1177,7 @@ void NWM_UDS::SetApplicationData(Kernel::HLERequestContext& ctx) { const std::vector application_data = rp.PopStaticBuffer(); ASSERT(application_data.size() == size); - LOG_DEBUG(Service_NWM, "called"); + NGLOG_DEBUG(Service_NWM, "called"); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); @@ -1201,7 +1202,7 @@ void NWM_UDS::DecryptBeaconData(Kernel::HLERequestContext& ctx) { const std::vector encrypted_data0_buffer = rp.PopStaticBuffer(); const std::vector encrypted_data1_buffer = rp.PopStaticBuffer(); - LOG_DEBUG(Service_NWM, "called"); + NGLOG_DEBUG(Service_NWM, "called"); NetworkInfo net_info; std::memcpy(&net_info, network_struct_buffer.data(), sizeof(net_info)); diff --git a/src/core/hle/service/nwm/uds_data.cpp b/src/core/hle/service/nwm/uds_data.cpp index 16d20166c..aedcc85d4 100644 --- a/src/core/hle/service/nwm/uds_data.cpp +++ b/src/core/hle/service/nwm/uds_data.cpp @@ -209,7 +209,7 @@ static std::vector DecryptDataFrame(const std::vector& encrypted_payload df.Get(pdata.data(), size); return pdata; } catch (CryptoPP::Exception&) { - LOG_ERROR(Service_NWM, "failed to decrypt"); + NGLOG_ERROR(Service_NWM, "failed to decrypt"); } return {}; @@ -263,7 +263,7 @@ static std::vector EncryptDataFrame(const std::vector& payload, df.Get(cipher.data(), size); return cipher; } catch (CryptoPP::Exception&) { - LOG_ERROR(Service_NWM, "failed to encrypt"); + NGLOG_ERROR(Service_NWM, "failed to encrypt"); } return {};