service/nwm: Migrate logging macros

This commit is contained in:
NarcolepticK 2018-06-22 04:16:38 -04:00
parent 4c67f1c7c6
commit 42b32ac1ea
2 changed files with 43 additions and 42 deletions

View file

@ -238,7 +238,7 @@ static void HandleEAPoLPacket(const Network::WifiPacket& packet) {
if (GetEAPoLFrameType(packet.data) == EAPoLStartMagic) { if (GetEAPoLFrameType(packet.data) == EAPoLStartMagic) {
if (connection_status.status != static_cast<u32>(NetworkStatus::ConnectedAsHost)) { if (connection_status.status != static_cast<u32>(NetworkStatus::ConnectedAsHost)) {
LOG_DEBUG(Service_NWM, "Connection sequence aborted, because connection status is %u", NGLOG_DEBUG(Service_NWM, "Connection sequence aborted, because connection status is {}",
connection_status.status); connection_status.status);
return; return;
} }
@ -247,7 +247,7 @@ static void HandleEAPoLPacket(const Network::WifiPacket& packet) {
if (connection_status.max_nodes == connection_status.total_nodes) { if (connection_status.max_nodes == connection_status.total_nodes) {
// Reject connection attempt // 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 // TODO(B3N30): Figure out what packet is sent here
return; return;
} }
@ -425,7 +425,7 @@ void SendAssociationResponseFrame(const MacAddress& address) {
{ {
std::lock_guard<std::mutex> lock(connection_status_mutex); std::lock_guard<std::mutex> lock(connection_status_mutex);
if (connection_status.status != static_cast<u32>(NetworkStatus::ConnectedAsHost)) { if (connection_status.status != static_cast<u32>(NetworkStatus::ConnectedAsHost)) {
LOG_ERROR(Service_NWM, "Connection sequence aborted, because connection status is %u", NGLOG_ERROR(Service_NWM, "Connection sequence aborted, because connection status is {}",
connection_status.status); connection_status.status);
return; return;
} }
@ -457,8 +457,8 @@ void HandleAuthenticationFrame(const Network::WifiPacket& packet) {
{ {
std::lock_guard<std::mutex> lock(connection_status_mutex); std::lock_guard<std::mutex> lock(connection_status_mutex);
if (connection_status.status != static_cast<u32>(NetworkStatus::ConnectedAsHost)) { if (connection_status.status != static_cast<u32>(NetworkStatus::ConnectedAsHost)) {
LOG_ERROR(Service_NWM, NGLOG_ERROR(Service_NWM,
"Connection sequence aborted, because connection status is %u", "Connection sequence aborted, because connection status is {}",
connection_status.status); connection_status.status);
return; 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 /// Handles the deauthentication frames sent from clients to hosts, when they leave a session
void HandleDeauthenticationFrame(const Network::WifiPacket& packet) { void HandleDeauthenticationFrame(const Network::WifiPacket& packet) {
LOG_DEBUG(Service_NWM, "called"); NGLOG_DEBUG(Service_NWM, "called");
std::unique_lock<std::recursive_mutex> hle_lock(HLE::g_hle_lock, std::defer_lock); std::unique_lock<std::recursive_mutex> hle_lock(HLE::g_hle_lock, std::defer_lock);
std::unique_lock<std::mutex> lock(connection_status_mutex, std::defer_lock); std::unique_lock<std::mutex> lock(connection_status_mutex, std::defer_lock);
std::lock(hle_lock, lock); std::lock(hle_lock, lock);
if (connection_status.status != static_cast<u32>(NetworkStatus::ConnectedAsHost)) { if (connection_status.status != static_cast<u32>(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; return;
} }
if (node_map.find(packet.transmitter_address) == node_map.end()) { 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; return;
} }
@ -555,7 +555,7 @@ void NWM_UDS::Shutdown(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
LOG_DEBUG(Service_NWM, "called"); NGLOG_DEBUG(Service_NWM, "called");
} }
void NWM_UDS::RecvBeaconBroadcastData(Kernel::HLERequestContext& ctx) { void NWM_UDS::RecvBeaconBroadcastData(Kernel::HLERequestContext& ctx) {
@ -617,9 +617,9 @@ void NWM_UDS::RecvBeaconBroadcastData(Kernel::HLERequestContext& ctx) {
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
rb.PushMappedBuffer(out_buffer); rb.PushMappedBuffer(out_buffer);
LOG_DEBUG(Service_NWM, NGLOG_DEBUG(Service_NWM,
"called out_buffer_size=0x%08X, wlan_comm_id=0x%08X, id=0x%08X," "called out_buffer_size=0x{:08X}, wlan_comm_id=0x{:08X}, id=0x{:08X},"
"unk1=0x%08X, unk2=0x%08X, offset=%zu", "unk1=0x{:08X}, unk2=0x{:08X}, offset={}",
out_buffer_size, wlan_comm_id, id, unk1, unk2, cur_buffer_size); out_buffer_size, wlan_comm_id, id, unk1, unk2, cur_buffer_size);
} }
@ -642,7 +642,7 @@ void NWM_UDS::InitializeWithVersion(Kernel::HLERequestContext& ctx) {
if (auto room_member = Network::GetRoomMember().lock()) { if (auto room_member = Network::GetRoomMember().lock()) {
wifi_packet_received = room_member->BindOnWifiPacketReceived(OnWifiPacketReceived); wifi_packet_received = room_member->BindOnWifiPacketReceived(OnWifiPacketReceived);
} else { } 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.Push(RESULT_SUCCESS);
rb.PushCopyObjects(connection_status_event); 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) { void NWM_UDS::GetConnectionStatus(Kernel::HLERequestContext& ctx) {
@ -679,7 +680,7 @@ void NWM_UDS::GetConnectionStatus(Kernel::HLERequestContext& ctx) {
connection_status.changed_nodes = 0; connection_status.changed_nodes = 0;
} }
LOG_DEBUG(Service_NWM, "called"); NGLOG_DEBUG(Service_NWM, "called");
} }
void NWM_UDS::GetNodeInformation(Kernel::HLERequestContext& ctx) { void NWM_UDS::GetNodeInformation(Kernel::HLERequestContext& ctx) {
@ -710,7 +711,7 @@ void NWM_UDS::GetNodeInformation(Kernel::HLERequestContext& ctx) {
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
rb.PushRaw<NodeInfo>(*itr); rb.PushRaw<NodeInfo>(*itr);
} }
LOG_DEBUG(Service_NWM, "called"); NGLOG_DEBUG(Service_NWM, "called");
} }
void NWM_UDS::Bind(Kernel::HLERequestContext& ctx) { void NWM_UDS::Bind(Kernel::HLERequestContext& ctx) {
@ -721,13 +722,13 @@ void NWM_UDS::Bind(Kernel::HLERequestContext& ctx) {
u8 data_channel = rp.Pop<u8>(); u8 data_channel = rp.Pop<u8>();
u16 network_node_id = rp.Pop<u16>(); u16 network_node_id = rp.Pop<u16>();
LOG_DEBUG(Service_NWM, "called"); NGLOG_DEBUG(Service_NWM, "called");
if (data_channel == 0 || bind_node_id == 0) { if (data_channel == 0 || bind_node_id == 0) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrorDescription::NotAuthorized, ErrorModule::UDS, rb.Push(ResultCode(ErrorDescription::NotAuthorized, ErrorModule::UDS,
ErrorSummary::WrongArgument, ErrorLevel::Usage)); ErrorSummary::WrongArgument, ErrorLevel::Usage));
LOG_WARNING(Service_NWM, "data_channel = %d, bind_node_id = %d", data_channel, NGLOG_WARNING(Service_NWM, "data_channel = {}, bind_node_id = {}", data_channel,
bind_node_id); bind_node_id);
return; return;
} }
@ -737,7 +738,7 @@ void NWM_UDS::Bind(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrorDescription::OutOfMemory, ErrorModule::UDS, rb.Push(ResultCode(ErrorDescription::OutOfMemory, ErrorModule::UDS,
ErrorSummary::OutOfResource, ErrorLevel::Status)); ErrorSummary::OutOfResource, ErrorLevel::Status));
LOG_WARNING(Service_NWM, "max bind nodes"); NGLOG_WARNING(Service_NWM, "max bind nodes");
return; return;
} }
@ -746,7 +747,7 @@ void NWM_UDS::Bind(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrorDescription::TooLarge, ErrorModule::UDS, rb.Push(ResultCode(ErrorDescription::TooLarge, ErrorModule::UDS,
ErrorSummary::WrongArgument, ErrorLevel::Usage)); ErrorSummary::WrongArgument, ErrorLevel::Usage));
LOG_WARNING(Service_NWM, "MinRecvBufferSize"); NGLOG_WARNING(Service_NWM, "MinRecvBufferSize");
return; return;
} }
@ -807,7 +808,7 @@ void NWM_UDS::BeginHostingNetwork(Kernel::HLERequestContext& ctx) {
// TODO(Subv): Store the passphrase and verify it when attempting a connection. // 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<std::mutex> lock(connection_status_mutex); std::lock_guard<std::mutex> lock(connection_status_mutex);
@ -867,7 +868,7 @@ void NWM_UDS::BeginHostingNetwork(Kernel::HLERequestContext& ctx) {
CoreTiming::ScheduleEvent(msToCycles(DefaultBeaconInterval * MillisecondsPerTU), CoreTiming::ScheduleEvent(msToCycles(DefaultBeaconInterval * MillisecondsPerTU),
beacon_broadcast_event, 0); 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); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
@ -876,7 +877,7 @@ void NWM_UDS::BeginHostingNetwork(Kernel::HLERequestContext& ctx) {
void NWM_UDS::UpdateNetworkAttribute(Kernel::HLERequestContext& ctx) { void NWM_UDS::UpdateNetworkAttribute(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx, 0x07, 2, 0); IPC::RequestParser rp(ctx, 0x07, 2, 0);
rp.Skip(2, false); rp.Skip(2, false);
LOG_WARNING(Service_NWM, "stubbed"); NGLOG_WARNING(Service_NWM, "stubbed");
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
} }
@ -893,7 +894,7 @@ void NWM_UDS::DestroyNetwork(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrCodes::WrongStatus, ErrorModule::UDS, ErrorSummary::InvalidState, rb.Push(ResultCode(ErrCodes::WrongStatus, ErrorModule::UDS, ErrorSummary::InvalidState,
ErrorLevel::Status)); ErrorLevel::Status));
LOG_WARNING(Service_NWM, "called with status %u", connection_status.status); NGLOG_WARNING(Service_NWM, "called with status {}", connection_status.status);
return; return;
} }
@ -915,7 +916,7 @@ void NWM_UDS::DestroyNetwork(Kernel::HLERequestContext& ctx) {
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
LOG_DEBUG(Service_NWM, "called"); NGLOG_DEBUG(Service_NWM, "called");
} }
void NWM_UDS::DisconnectNetwork(Kernel::HLERequestContext& ctx) { void NWM_UDS::DisconnectNetwork(Kernel::HLERequestContext& ctx) {
@ -933,7 +934,7 @@ void NWM_UDS::DisconnectNetwork(Kernel::HLERequestContext& ctx) {
connection_status.status = static_cast<u32>(NetworkStatus::ConnectedAsHost); connection_status.status = static_cast<u32>(NetworkStatus::ConnectedAsHost);
connection_status.network_node_id = tmp_node_id; connection_status.network_node_id = tmp_node_id;
node_map.clear(); 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, rb.Push(ResultCode(ErrCodes::WrongStatus, ErrorModule::UDS, ErrorSummary::InvalidState,
ErrorLevel::Status)); ErrorLevel::Status));
return; return;
@ -960,7 +961,7 @@ void NWM_UDS::DisconnectNetwork(Kernel::HLERequestContext& ctx) {
channel_data.clear(); channel_data.clear();
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
LOG_DEBUG(Service_NWM, "called"); NGLOG_DEBUG(Service_NWM, "called");
} }
void NWM_UDS::SendTo(Kernel::HLERequestContext& ctx) { 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) { 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, rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::UDS,
ErrorSummary::WrongArgument, ErrorLevel::Status)); ErrorSummary::WrongArgument, ErrorLevel::Status));
return; return;
@ -1000,7 +1001,7 @@ void NWM_UDS::SendTo(Kernel::HLERequestContext& ctx) {
Network::MacAddress dest_address; Network::MacAddress dest_address;
if (flags >> 2) { 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) { 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(), std::find_if(node_map.begin(), node_map.end(),
[dest_node_id](const auto& node) { return node.second == dest_node_id; }); [dest_node_id](const auto& node) { return node.second == dest_node_id; });
if (destination == node_map.end()) { 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, rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::UDS,
ErrorSummary::WrongArgument, ErrorLevel::Status)); ErrorSummary::WrongArgument, ErrorLevel::Status));
return; return;
@ -1132,7 +1133,7 @@ void NWM_UDS::GetChannel(Kernel::HLERequestContext& ctx) {
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
rb.Push(channel); rb.Push(channel);
LOG_DEBUG(Service_NWM, "called"); NGLOG_DEBUG(Service_NWM, "called");
} }
void NWM_UDS::ConnectToNetwork(Kernel::HLERequestContext& ctx) { 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 // TODO(B3N30): Add error handling for host full and timeout
IPC::RequestBuilder rb(ctx, 0x1E, 1, 0); IPC::RequestBuilder rb(ctx, 0x1E, 1, 0);
rb.Push(RESULT_SUCCESS); 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) { void NWM_UDS::SetApplicationData(Kernel::HLERequestContext& ctx) {
@ -1176,7 +1177,7 @@ void NWM_UDS::SetApplicationData(Kernel::HLERequestContext& ctx) {
const std::vector<u8> application_data = rp.PopStaticBuffer(); const std::vector<u8> application_data = rp.PopStaticBuffer();
ASSERT(application_data.size() == size); ASSERT(application_data.size() == size);
LOG_DEBUG(Service_NWM, "called"); NGLOG_DEBUG(Service_NWM, "called");
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
@ -1201,7 +1202,7 @@ void NWM_UDS::DecryptBeaconData(Kernel::HLERequestContext& ctx) {
const std::vector<u8> encrypted_data0_buffer = rp.PopStaticBuffer(); const std::vector<u8> encrypted_data0_buffer = rp.PopStaticBuffer();
const std::vector<u8> encrypted_data1_buffer = rp.PopStaticBuffer(); const std::vector<u8> encrypted_data1_buffer = rp.PopStaticBuffer();
LOG_DEBUG(Service_NWM, "called"); NGLOG_DEBUG(Service_NWM, "called");
NetworkInfo net_info; NetworkInfo net_info;
std::memcpy(&net_info, network_struct_buffer.data(), sizeof(net_info)); std::memcpy(&net_info, network_struct_buffer.data(), sizeof(net_info));

View file

@ -209,7 +209,7 @@ static std::vector<u8> DecryptDataFrame(const std::vector<u8>& encrypted_payload
df.Get(pdata.data(), size); df.Get(pdata.data(), size);
return pdata; return pdata;
} catch (CryptoPP::Exception&) { } catch (CryptoPP::Exception&) {
LOG_ERROR(Service_NWM, "failed to decrypt"); NGLOG_ERROR(Service_NWM, "failed to decrypt");
} }
return {}; return {};
@ -263,7 +263,7 @@ static std::vector<u8> EncryptDataFrame(const std::vector<u8>& payload,
df.Get(cipher.data(), size); df.Get(cipher.data(), size);
return cipher; return cipher;
} catch (CryptoPP::Exception&) { } catch (CryptoPP::Exception&) {
LOG_ERROR(Service_NWM, "failed to encrypt"); NGLOG_ERROR(Service_NWM, "failed to encrypt");
} }
return {}; return {};