mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
Core: Convert logging over to fmt pt.4
Continues the migration of logging in the Core library. This part finishes up the remaining log calls within the IOS code.
This commit is contained in:
@@ -181,7 +181,7 @@ ReturnCode ES::VerifySign(const std::vector<u8>& hash, const std::vector<u8>& ec
|
||||
return ret;
|
||||
}
|
||||
|
||||
INFO_LOG(IOS_ES, "VerifySign: all checks passed");
|
||||
INFO_LOG_FMT(IOS_ES, "VerifySign: all checks passed");
|
||||
return IPC_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,9 +57,10 @@ template <typename... Args>
|
||||
static void LogResult(ResultCode code, std::string_view format, Args&&... args)
|
||||
{
|
||||
const std::string command = fmt::format(format, std::forward<Args>(args)...);
|
||||
GENERIC_LOG(Common::Log::IOS_FS,
|
||||
(code == ResultCode::Success ? Common::Log::LINFO : Common::Log::LERROR),
|
||||
"%s: result %d", command.c_str(), ConvertResult(code));
|
||||
const auto type = code == ResultCode::Success ? Common::Log::LINFO : Common::Log::LERROR;
|
||||
|
||||
GENERIC_LOG_FMT(Common::Log::IOS_FS, type, "Command: {}: Result {}", command,
|
||||
ConvertResult(code));
|
||||
}
|
||||
|
||||
template <typename T, typename... Args>
|
||||
@@ -544,7 +545,8 @@ IPCCommandResult FS::SetFileVersionControl(const Handle& handle, const IOCtlRequ
|
||||
return GetFSReply(ConvertResult(params.Error()));
|
||||
|
||||
// FS_SetFileVersionControl(ctx->uid, params->path, params->attribute)
|
||||
ERROR_LOG(IOS_FS, "SetFileVersionControl(%s, 0x%x): Stubbed", params->path, params->attribute);
|
||||
ERROR_LOG_FMT(IOS_FS, "SetFileVersionControl({}, {:#x}): Stubbed", params->path,
|
||||
params->attribute);
|
||||
return GetFSReply(IPC_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -586,7 +588,7 @@ IPCCommandResult FS::GetUsage(const Handle& handle, const IOCtlVRequest& request
|
||||
|
||||
IPCCommandResult FS::Shutdown(const Handle& handle, const IOCtlRequest& request)
|
||||
{
|
||||
INFO_LOG(IOS_FS, "Shutdown");
|
||||
INFO_LOG_FMT(IOS_FS, "Shutdown");
|
||||
return GetFSReply(IPC_SUCCESS);
|
||||
}
|
||||
} // namespace IOS::HLE::Device
|
||||
|
||||
@@ -156,7 +156,7 @@ void HostFileSystem::LoadFst()
|
||||
const auto root_entry = parse_entry(parse_entry, 0);
|
||||
if (!root_entry.has_value())
|
||||
{
|
||||
ERROR_LOG(IOS_FS, "Failed to parse FST: at least one of the entries was invalid");
|
||||
ERROR_LOG_FMT(IOS_FS, "Failed to parse FST: at least one of the entries was invalid");
|
||||
return;
|
||||
}
|
||||
m_root_entry = *root_entry;
|
||||
@@ -182,12 +182,12 @@ void HostFileSystem::SaveFst()
|
||||
File::IOFile file{temp_path, "wb"};
|
||||
if (!file.WriteArray(to_write.data(), to_write.size()))
|
||||
{
|
||||
PanicAlert("IOS_FS: Failed to write new FST");
|
||||
PanicAlertFmt("IOS_FS: Failed to write new FST");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!File::Rename(temp_path, dest_path))
|
||||
PanicAlert("IOS_FS: Failed to rename temporary FST file");
|
||||
PanicAlertFmt("IOS_FS: Failed to rename temporary FST file");
|
||||
}
|
||||
|
||||
HostFileSystem::FstEntry* HostFileSystem::GetFstEntryForPath(const std::string& path)
|
||||
@@ -218,7 +218,7 @@ HostFileSystem::FstEntry* HostFileSystem::GetFstEntryForPath(const std::string&
|
||||
// Fall back to dummy data to avoid breaking existing filesystems.
|
||||
// This code path is also reached when creating a new file or directory;
|
||||
// proper metadata is filled in later.
|
||||
INFO_LOG(IOS_FS, "Creating a default entry for %s", complete_path.c_str());
|
||||
INFO_LOG_FMT(IOS_FS, "Creating a default entry for {}", complete_path);
|
||||
entry = &entry->children.emplace_back();
|
||||
entry->name = component;
|
||||
entry->data.modes = {Mode::ReadWrite, Mode::ReadWrite, Mode::ReadWrite};
|
||||
@@ -228,7 +228,7 @@ HostFileSystem::FstEntry* HostFileSystem::GetFstEntryForPath(const std::string&
|
||||
entry->data.is_file = host_file_info.IsFile();
|
||||
if (entry->data.is_file && !entry->children.empty())
|
||||
{
|
||||
WARN_LOG(IOS_FS, "%s is a file but also has children; clearing children", path.c_str());
|
||||
WARN_LOG_FMT(IOS_FS, "{} is a file but also has children; clearing children", path);
|
||||
entry->children.clear();
|
||||
}
|
||||
|
||||
@@ -382,7 +382,7 @@ ResultCode HostFileSystem::CreateFileOrDirectory(Uid uid, Gid gid, const std::st
|
||||
const bool ok = is_file ? File::CreateEmptyFile(host_path) : File::CreateDir(host_path);
|
||||
if (!ok)
|
||||
{
|
||||
ERROR_LOG(IOS_FS, "Failed to create file or directory: %s", host_path.c_str());
|
||||
ERROR_LOG_FMT(IOS_FS, "Failed to create file or directory: {}", host_path);
|
||||
return ResultCode::UnknownError;
|
||||
}
|
||||
|
||||
@@ -510,7 +510,7 @@ ResultCode HostFileSystem::Rename(Uid uid, Gid gid, const std::string& old_path,
|
||||
|
||||
if (!File::Rename(host_old_path, host_new_path))
|
||||
{
|
||||
ERROR_LOG(IOS_FS, "Rename %s to %s - failed", host_old_path.c_str(), host_new_path.c_str());
|
||||
ERROR_LOG_FMT(IOS_FS, "Rename {} to {} - failed", host_old_path, host_new_path);
|
||||
return ResultCode::NotFound;
|
||||
}
|
||||
|
||||
@@ -647,7 +647,7 @@ ResultCode HostFileSystem::SetMetadata(Uid caller_uid, const std::string& path,
|
||||
|
||||
Result<NandStats> HostFileSystem::GetNandStats()
|
||||
{
|
||||
WARN_LOG(IOS_FS, "GET STATS - returning static values for now");
|
||||
WARN_LOG_FMT(IOS_FS, "GET STATS - returning static values for now");
|
||||
|
||||
// TODO: scrape the real amounts from somewhere...
|
||||
NandStats stats{};
|
||||
@@ -681,7 +681,7 @@ Result<DirectoryStats> HostFileSystem::GetDirectoryStats(const std::string& wii_
|
||||
}
|
||||
else
|
||||
{
|
||||
WARN_LOG(IOS_FS, "fsBlock failed, cannot find directory: %s", path.c_str());
|
||||
WARN_LOG_FMT(IOS_FS, "fsBlock failed, cannot find directory: {}", path);
|
||||
}
|
||||
return stats;
|
||||
}
|
||||
|
||||
@@ -47,15 +47,15 @@ std::shared_ptr<File::IOFile> HostFileSystem::OpenHostFile(const std::string& ho
|
||||
while (!file.Open(host_path, "r+b"))
|
||||
{
|
||||
const bool try_again =
|
||||
PanicYesNo("File \"%s\" could not be opened!\n"
|
||||
"This may happen with improper permissions or use by another process.\n"
|
||||
"Press \"Yes\" to make another attempt.",
|
||||
host_path.c_str());
|
||||
PanicYesNoFmt("File \"{}\" could not be opened!\n"
|
||||
"This may happen with improper permissions or use by another process.\n"
|
||||
"Press \"Yes\" to make another attempt.",
|
||||
host_path);
|
||||
|
||||
if (!try_again)
|
||||
{
|
||||
// We've failed to open the file:
|
||||
ERROR_LOG(IOS_FS, "OpenHostFile %s", host_path.c_str());
|
||||
ERROR_LOG_FMT(IOS_FS, "OpenHostFile {}", host_path);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,8 +61,8 @@ enum SOResultCode : s32
|
||||
NetIPTop::NetIPTop(Kernel& ios, const std::string& device_name) : Device(ios, device_name)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
int ret = WSAStartup(MAKEWORD(2, 2), &InitData);
|
||||
INFO_LOG(IOS_NET, "WSAStartup: %d", ret);
|
||||
const int ret = WSAStartup(MAKEWORD(2, 2), &InitData);
|
||||
INFO_LOG_FMT(IOS_NET, "WSAStartup: {}", ret);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ static s32 MapWiiSockOptLevelToNative(u32 level)
|
||||
if (level == 0xFFFF)
|
||||
return SOL_SOCKET;
|
||||
|
||||
INFO_LOG(IOS_NET, "SO_SETSOCKOPT: unknown level %u", level);
|
||||
INFO_LOG_FMT(IOS_NET, "SO_SETSOCKOPT: unknown level {}", level);
|
||||
return level;
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ static s32 MapWiiSockOptNameToNative(u32 optname)
|
||||
return SO_ERROR;
|
||||
}
|
||||
|
||||
INFO_LOG(IOS_NET, "SO_SETSOCKOPT: unknown optname %u", optname);
|
||||
INFO_LOG_FMT(IOS_NET, "SO_SETSOCKOPT: unknown optname {}", optname);
|
||||
return optname;
|
||||
}
|
||||
|
||||
@@ -367,46 +367,47 @@ IPCCommandResult NetIPTop::HandleInitInterfaceRequest(const IOCtlRequest& reques
|
||||
|
||||
IPCCommandResult NetIPTop::HandleSocketRequest(const IOCtlRequest& request)
|
||||
{
|
||||
u32 af = Memory::Read_U32(request.buffer_in);
|
||||
u32 type = Memory::Read_U32(request.buffer_in + 4);
|
||||
u32 prot = Memory::Read_U32(request.buffer_in + 8);
|
||||
const u32 af = Memory::Read_U32(request.buffer_in);
|
||||
const u32 type = Memory::Read_U32(request.buffer_in + 4);
|
||||
const u32 prot = Memory::Read_U32(request.buffer_in + 8);
|
||||
|
||||
WiiSockMan& sm = WiiSockMan::GetInstance();
|
||||
const s32 return_value = sm.NewSocket(af, type, prot);
|
||||
INFO_LOG(IOS_NET,
|
||||
"IOCTL_SO_SOCKET "
|
||||
"Socket: %08x (%d,%d,%d), BufferIn: (%08x, %i), BufferOut: (%08x, %i)",
|
||||
return_value, af, type, prot, request.buffer_in, request.buffer_in_size,
|
||||
request.buffer_out, request.buffer_out_size);
|
||||
INFO_LOG_FMT(IOS_NET,
|
||||
"IOCTL_SO_SOCKET "
|
||||
"Socket: {:08x} ({},{},{}), BufferIn: ({:08x}, {}), BufferOut: ({:08x}, {})",
|
||||
return_value, af, type, prot, request.buffer_in, request.buffer_in_size,
|
||||
request.buffer_out, request.buffer_out_size);
|
||||
|
||||
return GetDefaultReply(return_value);
|
||||
}
|
||||
|
||||
IPCCommandResult NetIPTop::HandleICMPSocketRequest(const IOCtlRequest& request)
|
||||
{
|
||||
u32 pf = Memory::Read_U32(request.buffer_in);
|
||||
const u32 pf = Memory::Read_U32(request.buffer_in);
|
||||
|
||||
WiiSockMan& sm = WiiSockMan::GetInstance();
|
||||
const s32 return_value = sm.NewSocket(pf, SOCK_RAW, IPPROTO_ICMP);
|
||||
INFO_LOG(IOS_NET, "IOCTL_SO_ICMPSOCKET(%x) %d", pf, return_value);
|
||||
INFO_LOG_FMT(IOS_NET, "IOCTL_SO_ICMPSOCKET({:x}) {}", pf, return_value);
|
||||
return GetDefaultReply(return_value);
|
||||
}
|
||||
|
||||
IPCCommandResult NetIPTop::HandleCloseRequest(const IOCtlRequest& request)
|
||||
{
|
||||
u32 fd = Memory::Read_U32(request.buffer_in);
|
||||
const u32 fd = Memory::Read_U32(request.buffer_in);
|
||||
WiiSockMan& sm = WiiSockMan::GetInstance();
|
||||
const s32 return_value = sm.DeleteSocket(fd);
|
||||
INFO_LOG(IOS_NET, "%s(%x) %x",
|
||||
request.request == IOCTL_SO_ICMPCLOSE ? "IOCTL_SO_ICMPCLOSE" : "IOCTL_SO_CLOSE", fd,
|
||||
return_value);
|
||||
const char* const close_fn =
|
||||
request.request == IOCTL_SO_ICMPCLOSE ? "IOCTL_SO_ICMPCLOSE" : "IOCTL_SO_CLOSE";
|
||||
|
||||
INFO_LOG_FMT(IOS_NET, "{}({:x}) {:x}", close_fn, fd, return_value);
|
||||
|
||||
return GetDefaultReply(return_value);
|
||||
}
|
||||
|
||||
IPCCommandResult NetIPTop::HandleDoSockRequest(const IOCtlRequest& request)
|
||||
{
|
||||
u32 fd = Memory::Read_U32(request.buffer_in);
|
||||
const u32 fd = Memory::Read_U32(request.buffer_in);
|
||||
WiiSockMan& sm = WiiSockMan::GetInstance();
|
||||
sm.DoSock(fd, request, static_cast<NET_IOCTL>(request.request));
|
||||
return GetNoReply();
|
||||
@@ -416,8 +417,8 @@ IPCCommandResult NetIPTop::HandleShutdownRequest(const IOCtlRequest& request)
|
||||
{
|
||||
if (request.buffer_in == 0 || request.buffer_in_size < 8)
|
||||
{
|
||||
ERROR_LOG(IOS_NET, "IOCTL_SO_SHUTDOWN = EINVAL, BufferIn: (%08x, %i)", request.buffer_in,
|
||||
request.buffer_in_size);
|
||||
ERROR_LOG_FMT(IOS_NET, "IOCTL_SO_SHUTDOWN = EINVAL, BufferIn: ({:08x}, {})", request.buffer_in,
|
||||
request.buffer_in_size);
|
||||
return GetDefaultReply(-SO_EINVAL);
|
||||
}
|
||||
|
||||
@@ -425,7 +426,8 @@ IPCCommandResult NetIPTop::HandleShutdownRequest(const IOCtlRequest& request)
|
||||
const u32 how = Memory::Read_U32(request.buffer_in + 4);
|
||||
WiiSockMan& sm = WiiSockMan::GetInstance();
|
||||
const s32 return_value = sm.ShutdownSocket(fd, how);
|
||||
INFO_LOG(IOS_NET, "IOCTL_SO_SHUTDOWN(fd=%d, how=%d) = %d", fd, how, return_value);
|
||||
|
||||
INFO_LOG_FMT(IOS_NET, "IOCTL_SO_SHUTDOWN(fd={}, how={}) = {}", fd, how, return_value);
|
||||
return GetDefaultReply(return_value);
|
||||
}
|
||||
|
||||
@@ -474,24 +476,24 @@ IPCCommandResult NetIPTop::HandleGetSockOptRequest(const IOCtlRequest& request)
|
||||
|
||||
IPCCommandResult NetIPTop::HandleSetSockOptRequest(const IOCtlRequest& request)
|
||||
{
|
||||
u32 fd = Memory::Read_U32(request.buffer_in);
|
||||
u32 level = Memory::Read_U32(request.buffer_in + 4);
|
||||
u32 optname = Memory::Read_U32(request.buffer_in + 8);
|
||||
const u32 fd = Memory::Read_U32(request.buffer_in);
|
||||
const u32 level = Memory::Read_U32(request.buffer_in + 4);
|
||||
const u32 optname = Memory::Read_U32(request.buffer_in + 8);
|
||||
u32 optlen = Memory::Read_U32(request.buffer_in + 0xc);
|
||||
u8 optval[20];
|
||||
optlen = std::min(optlen, (u32)sizeof(optval));
|
||||
Memory::CopyFromEmu(optval, request.buffer_in + 0x10, optlen);
|
||||
|
||||
INFO_LOG(IOS_NET,
|
||||
"IOCTL_SO_SETSOCKOPT(%08x, %08x, %08x, %08x) "
|
||||
"BufferIn: (%08x, %i), BufferOut: (%08x, %i)"
|
||||
"%02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx "
|
||||
"%02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx",
|
||||
fd, level, optname, optlen, request.buffer_in, request.buffer_in_size,
|
||||
request.buffer_out, request.buffer_out_size, optval[0], optval[1], optval[2], optval[3],
|
||||
optval[4], optval[5], optval[6], optval[7], optval[8], optval[9], optval[10], optval[11],
|
||||
optval[12], optval[13], optval[14], optval[15], optval[16], optval[17], optval[18],
|
||||
optval[19]);
|
||||
INFO_LOG_FMT(IOS_NET,
|
||||
"IOCTL_SO_SETSOCKOPT({:08x}, {:08x}, {:08x}, {:08x}) "
|
||||
"BufferIn: ({:08x}, {}), BufferOut: ({:08x}, {})"
|
||||
"{:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} "
|
||||
"{:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x}",
|
||||
fd, level, optname, optlen, request.buffer_in, request.buffer_in_size,
|
||||
request.buffer_out, request.buffer_out_size, optval[0], optval[1], optval[2],
|
||||
optval[3], optval[4], optval[5], optval[6], optval[7], optval[8], optval[9],
|
||||
optval[10], optval[11], optval[12], optval[13], optval[14], optval[15], optval[16],
|
||||
optval[17], optval[18], optval[19]);
|
||||
|
||||
// TODO: bug booto about this, 0x2005 most likely timeout related, default value on Wii is ,
|
||||
// 0x2001 is most likely tcpnodelay
|
||||
@@ -499,11 +501,11 @@ IPCCommandResult NetIPTop::HandleSetSockOptRequest(const IOCtlRequest& request)
|
||||
return GetDefaultReply(0);
|
||||
|
||||
// Do the level/optname translation
|
||||
int nat_level = MapWiiSockOptLevelToNative(level);
|
||||
int nat_optname = MapWiiSockOptNameToNative(optname);
|
||||
const int nat_level = MapWiiSockOptLevelToNative(level);
|
||||
const int nat_optname = MapWiiSockOptNameToNative(optname);
|
||||
|
||||
int ret = setsockopt(WiiSockMan::GetInstance().GetHostSocket(fd), nat_level, nat_optname,
|
||||
(char*)optval, optlen);
|
||||
const int ret = setsockopt(WiiSockMan::GetInstance().GetHostSocket(fd), nat_level, nat_optname,
|
||||
reinterpret_cast<char*>(optval), optlen);
|
||||
return GetDefaultReply(WiiSockMan::GetNetErrorCode(ret, "SO_SETSOCKOPT", false));
|
||||
}
|
||||
|
||||
@@ -515,10 +517,10 @@ IPCCommandResult NetIPTop::HandleGetSockNameRequest(const IOCtlRequest& request)
|
||||
|
||||
sockaddr sa;
|
||||
socklen_t sa_len = sizeof(sa);
|
||||
int ret = getsockname(WiiSockMan::GetInstance().GetHostSocket(fd), &sa, &sa_len);
|
||||
const int ret = getsockname(WiiSockMan::GetInstance().GetHostSocket(fd), &sa, &sa_len);
|
||||
|
||||
if (request.buffer_out_size < 2 + sizeof(sa.sa_data))
|
||||
WARN_LOG(IOS_NET, "IOCTL_SO_GETSOCKNAME output buffer is too small. Truncating");
|
||||
WARN_LOG_FMT(IOS_NET, "IOCTL_SO_GETSOCKNAME output buffer is too small. Truncating");
|
||||
|
||||
if (request.buffer_out_size > 0)
|
||||
Memory::Write_U8(request.buffer_out_size, request.buffer_out);
|
||||
@@ -539,10 +541,10 @@ IPCCommandResult NetIPTop::HandleGetPeerNameRequest(const IOCtlRequest& request)
|
||||
|
||||
sockaddr sa;
|
||||
socklen_t sa_len = sizeof(sa);
|
||||
int ret = getpeername(WiiSockMan::GetInstance().GetHostSocket(fd), &sa, &sa_len);
|
||||
const int ret = getpeername(WiiSockMan::GetInstance().GetHostSocket(fd), &sa, &sa_len);
|
||||
|
||||
if (request.buffer_out_size < 2 + sizeof(sa.sa_data))
|
||||
WARN_LOG(IOS_NET, "IOCTL_SO_GETPEERNAME output buffer is too small. Truncating");
|
||||
WARN_LOG_FMT(IOS_NET, "IOCTL_SO_GETPEERNAME output buffer is too small. Truncating");
|
||||
|
||||
if (request.buffer_out_size > 0)
|
||||
Memory::Write_U8(request.buffer_out_size, request.buffer_out);
|
||||
@@ -554,7 +556,7 @@ IPCCommandResult NetIPTop::HandleGetPeerNameRequest(const IOCtlRequest& request)
|
||||
std::min<size_t>(sizeof(sa.sa_data), request.buffer_out_size - 2));
|
||||
}
|
||||
|
||||
INFO_LOG(IOS_NET, "IOCTL_SO_GETPEERNAME(%x)", fd);
|
||||
INFO_LOG_FMT(IOS_NET, "IOCTL_SO_GETPEERNAME({:x})", fd);
|
||||
return GetDefaultReply(ret);
|
||||
}
|
||||
|
||||
@@ -562,40 +564,44 @@ IPCCommandResult NetIPTop::HandleGetHostIDRequest(const IOCtlRequest& request)
|
||||
{
|
||||
const DefaultInterface interface = GetSystemDefaultInterfaceOrFallback();
|
||||
const u32 host_ip = Common::swap32(interface.inet);
|
||||
INFO_LOG(IOS_NET, "IOCTL_SO_GETHOSTID = %u.%u.%u.%u", host_ip >> 24, (host_ip >> 16) & 0xFF,
|
||||
(host_ip >> 8) & 0xFF, host_ip & 0xFF);
|
||||
INFO_LOG_FMT(IOS_NET, "IOCTL_SO_GETHOSTID = {}.{}.{}.{}", host_ip >> 24, (host_ip >> 16) & 0xFF,
|
||||
(host_ip >> 8) & 0xFF, host_ip & 0xFF);
|
||||
return GetDefaultReply(host_ip);
|
||||
}
|
||||
|
||||
IPCCommandResult NetIPTop::HandleInetAToNRequest(const IOCtlRequest& request)
|
||||
{
|
||||
std::string hostname = Memory::GetString(request.buffer_in);
|
||||
const std::string hostname = Memory::GetString(request.buffer_in);
|
||||
struct hostent* remoteHost = gethostbyname(hostname.c_str());
|
||||
|
||||
if (remoteHost == nullptr || remoteHost->h_addr_list == nullptr ||
|
||||
remoteHost->h_addr_list[0] == nullptr)
|
||||
{
|
||||
INFO_LOG(IOS_NET,
|
||||
"IOCTL_SO_INETATON = -1 "
|
||||
"%s, BufferIn: (%08x, %i), BufferOut: (%08x, %i), IP Found: None",
|
||||
hostname.c_str(), request.buffer_in, request.buffer_in_size, request.buffer_out,
|
||||
request.buffer_out_size);
|
||||
INFO_LOG_FMT(IOS_NET,
|
||||
"IOCTL_SO_INETATON = -1 "
|
||||
"{}, BufferIn: ({:08x}, {}), BufferOut: ({:08x}, {}), IP Found: None",
|
||||
hostname, request.buffer_in, request.buffer_in_size, request.buffer_out,
|
||||
request.buffer_out_size);
|
||||
|
||||
return GetDefaultReply(0);
|
||||
}
|
||||
|
||||
Memory::Write_U32(Common::swap32(*(u32*)remoteHost->h_addr_list[0]), request.buffer_out);
|
||||
INFO_LOG(IOS_NET,
|
||||
"IOCTL_SO_INETATON = 0 "
|
||||
"%s, BufferIn: (%08x, %i), BufferOut: (%08x, %i), IP Found: %08X",
|
||||
hostname.c_str(), request.buffer_in, request.buffer_in_size, request.buffer_out,
|
||||
request.buffer_out_size, Common::swap32(*(u32*)remoteHost->h_addr_list[0]));
|
||||
const auto ip = Common::swap32(reinterpret_cast<u8*>(remoteHost->h_addr_list[0]));
|
||||
Memory::Write_U32(ip, request.buffer_out);
|
||||
|
||||
INFO_LOG_FMT(IOS_NET,
|
||||
"IOCTL_SO_INETATON = 0 "
|
||||
"{}, BufferIn: ({:08x}, {}), BufferOut: ({:08x}, {}), IP Found: {:08X}",
|
||||
hostname, request.buffer_in, request.buffer_in_size, request.buffer_out,
|
||||
request.buffer_out_size, ip);
|
||||
|
||||
return GetDefaultReply(1);
|
||||
}
|
||||
|
||||
IPCCommandResult NetIPTop::HandleInetPToNRequest(const IOCtlRequest& request)
|
||||
{
|
||||
std::string address = Memory::GetString(request.buffer_in);
|
||||
INFO_LOG(IOS_NET, "IOCTL_SO_INETPTON (Translating: %s)", address.c_str());
|
||||
const std::string address = Memory::GetString(request.buffer_in);
|
||||
INFO_LOG_FMT(IOS_NET, "IOCTL_SO_INETPTON (Translating: {})", address);
|
||||
return GetDefaultReply(inet_pton(address.c_str(), Memory::GetPointer(request.buffer_out + 4)));
|
||||
}
|
||||
|
||||
@@ -610,8 +616,8 @@ IPCCommandResult NetIPTop::HandleInetNToPRequest(const IOCtlRequest& request)
|
||||
Memory::Read_U8(request.buffer_in + 8 + 1), Memory::Read_U8(request.buffer_in + 8 + 2),
|
||||
Memory::Read_U8(request.buffer_in + 8 + 3));
|
||||
|
||||
INFO_LOG(IOS_NET, "IOCTL_SO_INETNTOP %s", ip_s);
|
||||
Memory::CopyToEmu(request.buffer_out, (u8*)ip_s, strlen(ip_s));
|
||||
INFO_LOG_FMT(IOS_NET, "IOCTL_SO_INETNTOP {}", ip_s);
|
||||
Memory::CopyToEmu(request.buffer_out, reinterpret_cast<u8*>(ip_s), std::strlen(ip_s));
|
||||
return GetDefaultReply(0);
|
||||
}
|
||||
|
||||
@@ -628,7 +634,7 @@ IPCCommandResult NetIPTop::HandlePollRequest(const IOCtlRequest& request)
|
||||
const u32 nfds = request.buffer_out_size / 0xc;
|
||||
if (nfds == 0 || nfds > WII_SOCKET_FD_MAX)
|
||||
{
|
||||
ERROR_LOG(IOS_NET, "IOCTL_SO_POLL failed: Invalid array size %d, ret=%d", nfds, -SO_EINVAL);
|
||||
ERROR_LOG_FMT(IOS_NET, "IOCTL_SO_POLL failed: Invalid array size {}, ret={}", nfds, -SO_EINVAL);
|
||||
return GetDefaultReply(-SO_EINVAL);
|
||||
}
|
||||
|
||||
@@ -643,11 +649,11 @@ IPCCommandResult NetIPTop::HandlePollRequest(const IOCtlRequest& request)
|
||||
|
||||
// Translate Wii to native events
|
||||
ufds[i].events = WiiSockMan::ConvertEvents(events, WiiSockMan::ConvertDirection::WiiToNative);
|
||||
DEBUG_LOG(IOS_NET,
|
||||
"IOCTL_SO_POLL(%d) "
|
||||
"Sock: %08x, Events: %08x, "
|
||||
"NativeEvents: %08x",
|
||||
i, wii_fd, events, ufds[i].events);
|
||||
DEBUG_LOG_FMT(IOS_NET,
|
||||
"IOCTL_SO_POLL({}) "
|
||||
"Sock: {:08x}, Events: {:08x}, "
|
||||
"NativeEvents: {:08x}",
|
||||
i, wii_fd, events, ufds[i].events);
|
||||
|
||||
// Do not pass return-only events to the native poll
|
||||
ufds[i].events &= ~(POLLERR | POLLHUP | POLLNVAL | UNSUPPORTED_WSAPOLL);
|
||||
@@ -662,25 +668,25 @@ IPCCommandResult NetIPTop::HandleGetHostByNameRequest(const IOCtlRequest& reques
|
||||
{
|
||||
if (request.buffer_out_size != 0x460)
|
||||
{
|
||||
ERROR_LOG(IOS_NET, "Bad buffer size for IOCTL_SO_GETHOSTBYNAME");
|
||||
ERROR_LOG_FMT(IOS_NET, "Bad buffer size for IOCTL_SO_GETHOSTBYNAME");
|
||||
return GetDefaultReply(-1);
|
||||
}
|
||||
|
||||
std::string hostname = Memory::GetString(request.buffer_in);
|
||||
const std::string hostname = Memory::GetString(request.buffer_in);
|
||||
hostent* remoteHost = gethostbyname(hostname.c_str());
|
||||
|
||||
INFO_LOG(IOS_NET,
|
||||
"IOCTL_SO_GETHOSTBYNAME "
|
||||
"Address: %s, BufferIn: (%08x, %i), BufferOut: (%08x, %i)",
|
||||
hostname.c_str(), request.buffer_in, request.buffer_in_size, request.buffer_out,
|
||||
request.buffer_out_size);
|
||||
INFO_LOG_FMT(IOS_NET,
|
||||
"IOCTL_SO_GETHOSTBYNAME "
|
||||
"Address: {}, BufferIn: ({:08x}, {}), BufferOut: ({:08x}, {})",
|
||||
hostname, request.buffer_in, request.buffer_in_size, request.buffer_out,
|
||||
request.buffer_out_size);
|
||||
|
||||
if (remoteHost == nullptr)
|
||||
return GetDefaultReply(-1);
|
||||
|
||||
for (int i = 0; remoteHost->h_aliases[i]; ++i)
|
||||
{
|
||||
DEBUG_LOG(IOS_NET, "alias%i:%s", i, remoteHost->h_aliases[i]);
|
||||
DEBUG_LOG_FMT(IOS_NET, "alias{}:{}", i, remoteHost->h_aliases[i]);
|
||||
}
|
||||
|
||||
for (int i = 0; remoteHost->h_addr_list[i]; ++i)
|
||||
@@ -688,17 +694,17 @@ IPCCommandResult NetIPTop::HandleGetHostByNameRequest(const IOCtlRequest& reques
|
||||
const u32 ip = Common::swap32(*(u32*)(remoteHost->h_addr_list[i]));
|
||||
const std::string ip_s =
|
||||
fmt::format("{}.{}.{}.{}", ip >> 24, (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff);
|
||||
DEBUG_LOG(IOS_NET, "addr%i:%s", i, ip_s.c_str());
|
||||
DEBUG_LOG_FMT(IOS_NET, "addr{}:{}", i, ip_s);
|
||||
}
|
||||
|
||||
// Host name; located immediately after struct
|
||||
static const u32 GETHOSTBYNAME_STRUCT_SIZE = 0x10;
|
||||
static const u32 GETHOSTBYNAME_IP_LIST_OFFSET = 0x110;
|
||||
static constexpr u32 GETHOSTBYNAME_STRUCT_SIZE = 0x10;
|
||||
static constexpr u32 GETHOSTBYNAME_IP_LIST_OFFSET = 0x110;
|
||||
// Limit host name length to avoid buffer overflow.
|
||||
u32 name_length = (u32)strlen(remoteHost->h_name) + 1;
|
||||
const auto name_length = static_cast<u32>(strlen(remoteHost->h_name)) + 1;
|
||||
if (name_length > (GETHOSTBYNAME_IP_LIST_OFFSET - GETHOSTBYNAME_STRUCT_SIZE))
|
||||
{
|
||||
ERROR_LOG(IOS_NET, "Hostname too long in IOCTL_SO_GETHOSTBYNAME");
|
||||
ERROR_LOG_FMT(IOS_NET, "Hostname too long in IOCTL_SO_GETHOSTBYNAME");
|
||||
return GetDefaultReply(-1);
|
||||
}
|
||||
Memory::CopyToEmu(request.buffer_out + GETHOSTBYNAME_STRUCT_SIZE, remoteHost->h_name,
|
||||
@@ -746,7 +752,7 @@ IPCCommandResult NetIPTop::HandleGetHostByNameRequest(const IOCtlRequest& reques
|
||||
|
||||
IPCCommandResult NetIPTop::HandleICMPCancelRequest(const IOCtlRequest& request)
|
||||
{
|
||||
ERROR_LOG(IOS_NET, "IOCTL_SO_ICMPCANCEL");
|
||||
ERROR_LOG_FMT(IOS_NET, "IOCTL_SO_ICMPCANCEL");
|
||||
return GetDefaultReply(0);
|
||||
}
|
||||
|
||||
@@ -760,7 +766,7 @@ IPCCommandResult NetIPTop::HandleGetInterfaceOptRequest(const IOCtlVRequest& req
|
||||
|
||||
if (param != 0xfffe)
|
||||
{
|
||||
WARN_LOG(IOS_NET, "GetInterfaceOpt: received invalid request with param0=%08x", param);
|
||||
WARN_LOG_FMT(IOS_NET, "GetInterfaceOpt: received invalid request with param0={:08x}", param);
|
||||
return GetDefaultReply(SO_ERROR_INVALID_REQUEST);
|
||||
}
|
||||
|
||||
@@ -769,13 +775,13 @@ IPCCommandResult NetIPTop::HandleGetInterfaceOptRequest(const IOCtlVRequest& req
|
||||
param5 = Memory::Read_U32(request.io_vectors[0].address + 4);
|
||||
}
|
||||
|
||||
INFO_LOG(IOS_NET,
|
||||
"IOCTLV_SO_GETINTERFACEOPT(%08X, %08X, %X, %X, %X) "
|
||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i) ",
|
||||
param, param2, param3, param4, param5, request.in_vectors[0].address,
|
||||
request.in_vectors[0].size,
|
||||
request.in_vectors.size() > 1 ? request.in_vectors[1].address : 0,
|
||||
request.in_vectors.size() > 1 ? request.in_vectors[1].size : 0);
|
||||
INFO_LOG_FMT(IOS_NET,
|
||||
"IOCTLV_SO_GETINTERFACEOPT({:08X}, {:08X}, {:X}, {:X}, {:X}) "
|
||||
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}) ",
|
||||
param, param2, param3, param4, param5, request.in_vectors[0].address,
|
||||
request.in_vectors[0].size,
|
||||
request.in_vectors.size() > 1 ? request.in_vectors[1].address : 0,
|
||||
request.in_vectors.size() > 1 ? request.in_vectors[1].size : 0);
|
||||
|
||||
switch (param2)
|
||||
{
|
||||
@@ -824,14 +830,13 @@ IPCCommandResult NetIPTop::HandleGetInterfaceOptRequest(const IOCtlVRequest& req
|
||||
if (AdapterList->IfIndex == dwBestIfIndex && AdapterList->FirstDnsServerAddress &&
|
||||
AdapterList->OperStatus == IfOperStatusUp)
|
||||
{
|
||||
INFO_LOG(IOS_NET, "Name of valid interface: %S", AdapterList->FriendlyName);
|
||||
INFO_LOG(
|
||||
IOS_NET, "DNS: %u.%u.%u.%u",
|
||||
(unsigned char)AdapterList->FirstDnsServerAddress->Address.lpSockaddr->sa_data[2],
|
||||
(unsigned char)AdapterList->FirstDnsServerAddress->Address.lpSockaddr->sa_data[3],
|
||||
(unsigned char)AdapterList->FirstDnsServerAddress->Address.lpSockaddr->sa_data[4],
|
||||
(unsigned char)
|
||||
AdapterList->FirstDnsServerAddress->Address.lpSockaddr->sa_data[5]);
|
||||
INFO_LOG_FMT(IOS_NET, "Name of valid interface: {}",
|
||||
WStringToUTF8(AdapterList->FriendlyName));
|
||||
INFO_LOG_FMT(IOS_NET, "DNS: {}.{}.{}.{}",
|
||||
u8(AdapterList->FirstDnsServerAddress->Address.lpSockaddr->sa_data[2]),
|
||||
u8(AdapterList->FirstDnsServerAddress->Address.lpSockaddr->sa_data[3]),
|
||||
u8(AdapterList->FirstDnsServerAddress->Address.lpSockaddr->sa_data[4]),
|
||||
u8(AdapterList->FirstDnsServerAddress->Address.lpSockaddr->sa_data[5]));
|
||||
address = Common::swap32(
|
||||
*(u32*)(&AdapterList->FirstDnsServerAddress->Address.lpSockaddr->sa_data[2]));
|
||||
break;
|
||||
@@ -851,14 +856,14 @@ IPCCommandResult NetIPTop::HandleGetInterfaceOptRequest(const IOCtlVRequest& req
|
||||
if (res_init() == 0)
|
||||
address = ntohl(_res.nsaddr_list[0].sin_addr.s_addr);
|
||||
else
|
||||
WARN_LOG(IOS_NET, "Call to res_init failed");
|
||||
WARN_LOG_FMT(IOS_NET, "Call to res_init failed");
|
||||
}
|
||||
#endif
|
||||
if (address == 0)
|
||||
address = default_main_dns_resolver;
|
||||
|
||||
INFO_LOG(IOS_NET, "Primary DNS: %X", address);
|
||||
INFO_LOG(IOS_NET, "Secondary DNS: %X", default_backup_dns_resolver);
|
||||
INFO_LOG_FMT(IOS_NET, "Primary DNS: {:X}", address);
|
||||
INFO_LOG_FMT(IOS_NET, "Secondary DNS: {:X}", default_backup_dns_resolver);
|
||||
|
||||
Memory::Write_U32(address, request.io_vectors[0].address);
|
||||
Memory::Write_U32(default_backup_dns_resolver, request.io_vectors[0].address + 4);
|
||||
@@ -920,7 +925,7 @@ IPCCommandResult NetIPTop::HandleGetInterfaceOptRequest(const IOCtlVRequest& req
|
||||
break;
|
||||
|
||||
default:
|
||||
ERROR_LOG(IOS_NET, "Unknown param2: %08X", param2);
|
||||
ERROR_LOG_FMT(IOS_NET, "Unknown param2: {:08X}", param2);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1042,13 +1047,13 @@ IPCCommandResult NetIPTop::HandleICMPPingRequest(const IOCtlVRequest& request)
|
||||
u32 ip;
|
||||
} ip_info;
|
||||
|
||||
u32 fd = Memory::Read_U32(request.in_vectors[0].address);
|
||||
u32 num_ip = Memory::Read_U32(request.in_vectors[0].address + 4);
|
||||
u64 timeout = Memory::Read_U64(request.in_vectors[0].address + 8);
|
||||
const u32 fd = Memory::Read_U32(request.in_vectors[0].address);
|
||||
const u32 num_ip = Memory::Read_U32(request.in_vectors[0].address + 4);
|
||||
const u64 timeout = Memory::Read_U64(request.in_vectors[0].address + 8);
|
||||
|
||||
if (num_ip != 1)
|
||||
{
|
||||
INFO_LOG(IOS_NET, "IOCTLV_SO_ICMPPING %i IPs", num_ip);
|
||||
INFO_LOG_FMT(IOS_NET, "IOCTLV_SO_ICMPPING {} IPs", num_ip);
|
||||
}
|
||||
|
||||
ip_info.length = Memory::Read_U8(request.in_vectors[0].address + 16);
|
||||
@@ -1058,13 +1063,13 @@ IPCCommandResult NetIPTop::HandleICMPPingRequest(const IOCtlVRequest& request)
|
||||
|
||||
if (ip_info.length != 8 || ip_info.addr_family != AF_INET)
|
||||
{
|
||||
INFO_LOG(IOS_NET,
|
||||
"IOCTLV_SO_ICMPPING strange IPInfo:\n"
|
||||
"length %x addr_family %x",
|
||||
ip_info.length, ip_info.addr_family);
|
||||
INFO_LOG_FMT(IOS_NET,
|
||||
"IOCTLV_SO_ICMPPING strange IPInfo:\n"
|
||||
"length {:x} addr_family {:x}",
|
||||
ip_info.length, ip_info.addr_family);
|
||||
}
|
||||
|
||||
INFO_LOG(IOS_NET, "IOCTLV_SO_ICMPPING %x", ip_info.ip);
|
||||
INFO_LOG_FMT(IOS_NET, "IOCTLV_SO_ICMPPING {:x}", ip_info.ip);
|
||||
|
||||
sockaddr_in addr;
|
||||
addr.sin_family = AF_INET;
|
||||
|
||||
@@ -30,7 +30,7 @@ void NWC24Config::ReadConfig()
|
||||
{
|
||||
const s32 config_error = CheckNwc24Config();
|
||||
if (config_error)
|
||||
ERROR_LOG(IOS_WC24, "There is an error in the config for for WC24: %d", config_error);
|
||||
ERROR_LOG_FMT(IOS_WC24, "There is an error in the config for for WC24: {}", config_error);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -44,7 +44,7 @@ void NWC24Config::WriteConfig() const
|
||||
m_fs->CreateFullPath(PID_KD, PID_KD, CONFIG_PATH, 0, public_modes);
|
||||
const auto file = m_fs->CreateAndOpenFile(PID_KD, PID_KD, CONFIG_PATH, public_modes);
|
||||
if (!file || !file->Write(&m_data, 1))
|
||||
ERROR_LOG(IOS_WC24, "Failed to open or write WC24 config file");
|
||||
ERROR_LOG_FMT(IOS_WC24, "Failed to open or write WC24 config file");
|
||||
}
|
||||
|
||||
void NWC24Config::ResetConfig()
|
||||
@@ -93,21 +93,21 @@ s32 NWC24Config::CheckNwc24Config() const
|
||||
// 'WcCf' magic
|
||||
if (Magic() != 0x57634366)
|
||||
{
|
||||
ERROR_LOG(IOS_WC24, "Magic mismatch");
|
||||
ERROR_LOG_FMT(IOS_WC24, "Magic mismatch");
|
||||
return -14;
|
||||
}
|
||||
|
||||
const u32 checksum = CalculateNwc24ConfigChecksum();
|
||||
DEBUG_LOG(IOS_WC24, "Checksum: %X", checksum);
|
||||
DEBUG_LOG_FMT(IOS_WC24, "Checksum: {:X}", checksum);
|
||||
if (Checksum() != checksum)
|
||||
{
|
||||
ERROR_LOG(IOS_WC24, "Checksum mismatch expected %X and got %X", checksum, Checksum());
|
||||
ERROR_LOG_FMT(IOS_WC24, "Checksum mismatch expected {:X} and got {:X}", checksum, Checksum());
|
||||
return -14;
|
||||
}
|
||||
|
||||
if (IdGen() > 0x1F)
|
||||
{
|
||||
ERROR_LOG(IOS_WC24, "Id gen error");
|
||||
ERROR_LOG_FMT(IOS_WC24, "Id gen error");
|
||||
return -14;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,16 +39,16 @@ IPCCommandResult NetKDRequest::IOCtl(const IOCtlRequest& request)
|
||||
{
|
||||
case IOCTL_NWC24_SUSPEND_SCHEDULAR:
|
||||
// NWC24iResumeForCloseLib from NWC24SuspendScheduler (Input: none, Output: 32 bytes)
|
||||
INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_SUSPEND_SCHEDULAR - NI");
|
||||
INFO_LOG_FMT(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_SUSPEND_SCHEDULAR - NI");
|
||||
WriteReturnValue(0, request.buffer_out); // no error
|
||||
break;
|
||||
|
||||
case IOCTL_NWC24_EXEC_TRY_SUSPEND_SCHEDULAR: // NWC24iResumeForCloseLib
|
||||
INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_EXEC_TRY_SUSPEND_SCHEDULAR - NI");
|
||||
INFO_LOG_FMT(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_EXEC_TRY_SUSPEND_SCHEDULAR - NI");
|
||||
break;
|
||||
|
||||
case IOCTL_NWC24_EXEC_RESUME_SCHEDULAR: // NWC24iResumeForCloseLib
|
||||
INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_EXEC_RESUME_SCHEDULAR - NI");
|
||||
INFO_LOG_FMT(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_EXEC_RESUME_SCHEDULAR - NI");
|
||||
WriteReturnValue(0, request.buffer_out); // no error
|
||||
break;
|
||||
|
||||
@@ -56,30 +56,30 @@ IPCCommandResult NetKDRequest::IOCtl(const IOCtlRequest& request)
|
||||
WriteReturnValue(0, request.buffer_out);
|
||||
Memory::Write_U32(0, request.buffer_out + 4);
|
||||
return_value = 0;
|
||||
INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_STARTUP_SOCKET - NI");
|
||||
INFO_LOG_FMT(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_STARTUP_SOCKET - NI");
|
||||
break;
|
||||
|
||||
case IOCTL_NWC24_CLEANUP_SOCKET:
|
||||
INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_CLEANUP_SOCKET");
|
||||
INFO_LOG_FMT(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_CLEANUP_SOCKET");
|
||||
WiiSockMan::GetInstance().Clean();
|
||||
break;
|
||||
|
||||
case IOCTL_NWC24_LOCK_SOCKET: // WiiMenu
|
||||
INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_LOCK_SOCKET - NI");
|
||||
INFO_LOG_FMT(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_LOCK_SOCKET - NI");
|
||||
break;
|
||||
|
||||
case IOCTL_NWC24_UNLOCK_SOCKET:
|
||||
INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_UNLOCK_SOCKET - NI");
|
||||
INFO_LOG_FMT(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_UNLOCK_SOCKET - NI");
|
||||
break;
|
||||
|
||||
case IOCTL_NWC24_REQUEST_REGISTER_USER_ID:
|
||||
INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_REQUEST_REGISTER_USER_ID");
|
||||
INFO_LOG_FMT(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_REQUEST_REGISTER_USER_ID");
|
||||
WriteReturnValue(0, request.buffer_out);
|
||||
Memory::Write_U32(0, request.buffer_out + 4);
|
||||
break;
|
||||
|
||||
case IOCTL_NWC24_REQUEST_GENERATED_USER_ID: // (Input: none, Output: 32 bytes)
|
||||
INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_REQUEST_GENERATED_USER_ID");
|
||||
INFO_LOG_FMT(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_REQUEST_GENERATED_USER_ID");
|
||||
if (config.CreationStage() == NWC24::NWC24Config::NWC24_IDCS_INITIAL)
|
||||
{
|
||||
const std::string settings_file_path =
|
||||
@@ -133,11 +133,11 @@ IPCCommandResult NetKDRequest::IOCtl(const IOCtlRequest& request)
|
||||
break;
|
||||
|
||||
case IOCTL_NWC24_GET_SCHEDULAR_STAT:
|
||||
INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_GET_SCHEDULAR_STAT - NI");
|
||||
INFO_LOG_FMT(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_GET_SCHEDULAR_STAT - NI");
|
||||
break;
|
||||
|
||||
case IOCTL_NWC24_SAVE_MAIL_NOW:
|
||||
INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_SAVE_MAIL_NOW - NI");
|
||||
INFO_LOG_FMT(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_SAVE_MAIL_NOW - NI");
|
||||
break;
|
||||
|
||||
case IOCTL_NWC24_REQUEST_SHUTDOWN:
|
||||
@@ -146,11 +146,11 @@ IPCCommandResult NetKDRequest::IOCtl(const IOCtlRequest& request)
|
||||
request.buffer_out == 0 || request.buffer_out % 4 != 0 || request.buffer_out_size < 4)
|
||||
{
|
||||
return_value = IPC_EINVAL;
|
||||
ERROR_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_REQUEST_SHUTDOWN = IPC_EINVAL");
|
||||
ERROR_LOG_FMT(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_REQUEST_SHUTDOWN = IPC_EINVAL");
|
||||
break;
|
||||
}
|
||||
|
||||
INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_REQUEST_SHUTDOWN");
|
||||
INFO_LOG_FMT(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_REQUEST_SHUTDOWN");
|
||||
[[maybe_unused]] const u32 event = Memory::Read_U32(request.buffer_in);
|
||||
// TODO: Advertise shutdown event
|
||||
// TODO: Shutdown USB keyboard LEDs if event == 3
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
#include "Core/IOS/Network/KD/NetKDTime.h"
|
||||
|
||||
#include <cinttypes>
|
||||
#include <string>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
@@ -32,7 +31,7 @@ IPCCommandResult NetKDTime::IOCtl(const IOCtlRequest& request)
|
||||
{
|
||||
const u64 adjusted_utc = GetAdjustedUTC();
|
||||
Memory::Write_U64(adjusted_utc, request.buffer_out + 4);
|
||||
INFO_LOG(IOS_WC24, "IOCTL_NW24_GET_UNIVERSAL_TIME = %d, time = %" PRIu64, result, adjusted_utc);
|
||||
INFO_LOG_FMT(IOS_WC24, "IOCTL_NW24_GET_UNIVERSAL_TIME = {}, time = {}", result, adjusted_utc);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -41,29 +40,28 @@ IPCCommandResult NetKDTime::IOCtl(const IOCtlRequest& request)
|
||||
const u64 adjusted_utc = Memory::Read_U64(request.buffer_in);
|
||||
SetAdjustedUTC(adjusted_utc);
|
||||
update_misc = Memory::Read_U32(request.buffer_in + 8);
|
||||
INFO_LOG(IOS_WC24, "IOCTL_NW24_SET_UNIVERSAL_TIME (%" PRIu64 ", %u) = %d", adjusted_utc,
|
||||
update_misc, result);
|
||||
INFO_LOG_FMT(IOS_WC24, "IOCTL_NW24_SET_UNIVERSAL_TIME ({}, {}) = {}", adjusted_utc, update_misc,
|
||||
result);
|
||||
}
|
||||
break;
|
||||
|
||||
case IOCTL_NW24_SET_RTC_COUNTER:
|
||||
rtc = Memory::Read_U32(request.buffer_in);
|
||||
update_misc = Memory::Read_U32(request.buffer_in + 4);
|
||||
INFO_LOG(IOS_WC24, "IOCTL_NW24_SET_RTC_COUNTER (%" PRIu64 ", %u) = %d", rtc, update_misc,
|
||||
result);
|
||||
INFO_LOG_FMT(IOS_WC24, "IOCTL_NW24_SET_RTC_COUNTER ({}, {}) = {}", rtc, update_misc, result);
|
||||
break;
|
||||
|
||||
case IOCTL_NW24_GET_TIME_DIFF:
|
||||
{
|
||||
const u64 time_diff = GetAdjustedUTC() - rtc;
|
||||
Memory::Write_U64(time_diff, request.buffer_out + 4);
|
||||
INFO_LOG(IOS_WC24, "IOCTL_NW24_GET_TIME_DIFF = %d, time_diff = %" PRIu64, result, time_diff);
|
||||
INFO_LOG_FMT(IOS_WC24, "IOCTL_NW24_GET_TIME_DIFF = {}, time_diff = {}", result, time_diff);
|
||||
}
|
||||
break;
|
||||
|
||||
case IOCTL_NW24_UNIMPLEMENTED:
|
||||
result = -9;
|
||||
INFO_LOG(IOS_WC24, "IOCTL_NW24_UNIMPLEMENTED = %d", result);
|
||||
INFO_LOG_FMT(IOS_WC24, "IOCTL_NW24_UNIMPLEMENTED = {}", result);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -39,14 +39,14 @@ Common::MACAddress GetMACAddress()
|
||||
SaveMACAddress(mac.value());
|
||||
if (!wireless_mac.empty())
|
||||
{
|
||||
ERROR_LOG(IOS_NET,
|
||||
"The MAC provided (%s) is invalid. We have "
|
||||
"generated another one for you.",
|
||||
Common::MacAddressToString(mac.value()).c_str());
|
||||
ERROR_LOG_FMT(IOS_NET,
|
||||
"The MAC provided ({}) is invalid. We have "
|
||||
"generated another one for you.",
|
||||
Common::MacAddressToString(mac.value()));
|
||||
}
|
||||
}
|
||||
|
||||
INFO_LOG(IOS_NET, "Using MAC address: %s", Common::MacAddressToString(mac.value()).c_str());
|
||||
INFO_LOG_FMT(IOS_NET, "Using MAC address: {}", Common::MacAddressToString(mac.value()));
|
||||
return mac.value();
|
||||
}
|
||||
} // namespace IOS::Net
|
||||
|
||||
@@ -36,37 +36,37 @@ IPCCommandResult NetNCDManage::IOCtlV(const IOCtlVRequest& request)
|
||||
break;
|
||||
|
||||
case IOCTLV_NCD_GETCONFIG:
|
||||
INFO_LOG(IOS_NET, "NET_NCD_MANAGE: IOCTLV_NCD_GETCONFIG");
|
||||
INFO_LOG_FMT(IOS_NET, "NET_NCD_MANAGE: IOCTLV_NCD_GETCONFIG");
|
||||
config.WriteToMem(request.io_vectors.at(0).address);
|
||||
common_vector = 1;
|
||||
break;
|
||||
|
||||
case IOCTLV_NCD_SETCONFIG:
|
||||
INFO_LOG(IOS_NET, "NET_NCD_MANAGE: IOCTLV_NCD_SETCONFIG");
|
||||
INFO_LOG_FMT(IOS_NET, "NET_NCD_MANAGE: IOCTLV_NCD_SETCONFIG");
|
||||
config.ReadFromMem(request.in_vectors.at(0).address);
|
||||
break;
|
||||
|
||||
case IOCTLV_NCD_READCONFIG:
|
||||
INFO_LOG(IOS_NET, "NET_NCD_MANAGE: IOCTLV_NCD_READCONFIG");
|
||||
INFO_LOG_FMT(IOS_NET, "NET_NCD_MANAGE: IOCTLV_NCD_READCONFIG");
|
||||
config.ReadConfig(m_ios.GetFS().get());
|
||||
config.WriteToMem(request.io_vectors.at(0).address);
|
||||
break;
|
||||
|
||||
case IOCTLV_NCD_WRITECONFIG:
|
||||
INFO_LOG(IOS_NET, "NET_NCD_MANAGE: IOCTLV_NCD_WRITECONFIG");
|
||||
INFO_LOG_FMT(IOS_NET, "NET_NCD_MANAGE: IOCTLV_NCD_WRITECONFIG");
|
||||
config.ReadFromMem(request.in_vectors.at(0).address);
|
||||
config.WriteConfig(m_ios.GetFS().get());
|
||||
break;
|
||||
|
||||
case IOCTLV_NCD_GETLINKSTATUS:
|
||||
INFO_LOG(IOS_NET, "NET_NCD_MANAGE: IOCTLV_NCD_GETLINKSTATUS");
|
||||
INFO_LOG_FMT(IOS_NET, "NET_NCD_MANAGE: IOCTLV_NCD_GETLINKSTATUS");
|
||||
// Always connected
|
||||
Memory::Write_U32(Net::ConnectionSettings::LINK_WIRED, request.io_vectors.at(0).address + 4);
|
||||
break;
|
||||
|
||||
case IOCTLV_NCD_GETWIRELESSMACADDRESS:
|
||||
{
|
||||
INFO_LOG(IOS_NET, "NET_NCD_MANAGE: IOCTLV_NCD_GETWIRELESSMACADDRESS");
|
||||
INFO_LOG_FMT(IOS_NET, "NET_NCD_MANAGE: IOCTLV_NCD_GETWIRELESSMACADDRESS");
|
||||
|
||||
const Common::MACAddress address = IOS::Net::GetMACAddress();
|
||||
Memory::CopyToEmu(request.io_vectors.at(1).address, address.data(), address.size());
|
||||
@@ -74,7 +74,7 @@ IPCCommandResult NetNCDManage::IOCtlV(const IOCtlVRequest& request)
|
||||
}
|
||||
|
||||
default:
|
||||
INFO_LOG(IOS_NET, "NET_NCD_MANAGE IOCtlV: %#x", request.request);
|
||||
INFO_LOG_FMT(IOS_NET, "NET_NCD_MANAGE IOCtlV: {:#x}", request.request);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ void WiiNetConfig::WriteConfig(FS::FileSystem* fs) const
|
||||
fs->CreateFullPath(PID_NCD, PID_NCD, CONFIG_PATH, 0, public_modes);
|
||||
const auto file = fs->CreateAndOpenFile(PID_NCD, PID_NCD, CONFIG_PATH, public_modes);
|
||||
if (!file || !file->Write(&m_data, 1))
|
||||
ERROR_LOG(IOS_NET, "Failed to write config");
|
||||
ERROR_LOG_FMT(IOS_NET, "Failed to write config");
|
||||
}
|
||||
|
||||
void WiiNetConfig::ResetConfig(FS::FileSystem* fs)
|
||||
|
||||
@@ -106,13 +106,13 @@ static std::vector<u8> ReadCertFile(const std::string& path, const std::array<u8
|
||||
std::vector<u8> bytes(file.GetSize());
|
||||
if (!file.ReadBytes(bytes.data(), bytes.size()))
|
||||
{
|
||||
ERROR_LOG(IOS_SSL, "Failed to read %s", path.c_str());
|
||||
ERROR_LOG_FMT(IOS_SSL, "Failed to read {}", path);
|
||||
if (!silent)
|
||||
{
|
||||
PanicAlertT("IOS: Could not read a file required for SSL services (%s). Please refer to "
|
||||
"https://dolphin-emu.org/docs/guides/wii-network-guide/ for "
|
||||
"instructions on setting up Wii networking.",
|
||||
path.c_str());
|
||||
PanicAlertFmtT("IOS: Could not read a file required for SSL services ({0}). Please refer to "
|
||||
"https://dolphin-emu.org/docs/guides/wii-network-guide/ for "
|
||||
"instructions on setting up Wii networking.",
|
||||
path);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
@@ -121,13 +121,13 @@ static std::vector<u8> ReadCertFile(const std::string& path, const std::array<u8
|
||||
mbedtls_sha256_ret(bytes.data(), bytes.size(), hash.data(), 0);
|
||||
if (hash != correct_hash)
|
||||
{
|
||||
ERROR_LOG(IOS_SSL, "Wrong hash for %s", path.c_str());
|
||||
ERROR_LOG_FMT(IOS_SSL, "Wrong hash for {}", path);
|
||||
if (!silent)
|
||||
{
|
||||
PanicAlertT("IOS: A file required for SSL services (%s) is invalid. Please refer to "
|
||||
"https://dolphin-emu.org/docs/guides/wii-network-guide/ for "
|
||||
"instructions on setting up Wii networking.",
|
||||
path.c_str());
|
||||
PanicAlertFmtT("IOS: A file required for SSL services ({0}) is invalid. Please refer to "
|
||||
"https://dolphin-emu.org/docs/guides/wii-network-guide/ for "
|
||||
"instructions on setting up Wii networking.",
|
||||
path);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
@@ -234,14 +234,14 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
|
||||
WriteReturnValue(SSL_ERR_FAILED, BufferIn);
|
||||
}
|
||||
|
||||
INFO_LOG(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_NEW (%d, %s) "
|
||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
||||
verifyOption, hostname.c_str(), BufferIn, BufferInSize, BufferIn2, BufferInSize2,
|
||||
BufferIn3, BufferInSize3, BufferOut, BufferOutSize, BufferOut2, BufferOutSize2,
|
||||
BufferOut3, BufferOutSize3);
|
||||
INFO_LOG_FMT(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_NEW ({}, {}) "
|
||||
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||
"BufferIn3: ({:08x}, {}), BufferOut: ({:08x}, {}), "
|
||||
"BufferOut2: ({:08x}, {}), BufferOut3: ({:08x}, {})",
|
||||
verifyOption, hostname, BufferIn, BufferInSize, BufferIn2, BufferInSize2,
|
||||
BufferIn3, BufferInSize3, BufferOut, BufferOutSize, BufferOut2, BufferOutSize2,
|
||||
BufferOut3, BufferOutSize3);
|
||||
break;
|
||||
}
|
||||
case IOCTLV_NET_SSL_SHUTDOWN:
|
||||
@@ -272,24 +272,24 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
|
||||
{
|
||||
WriteReturnValue(SSL_ERR_ID, BufferIn);
|
||||
}
|
||||
INFO_LOG(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_SHUTDOWN "
|
||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
|
||||
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||
INFO_LOG_FMT(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_SHUTDOWN "
|
||||
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||
"BufferIn3: ({:08x}, {}), BufferOut: ({:08x}, {}), "
|
||||
"BufferOut2: ({:08x}, {}), BufferOut3: ({:08x}, {})",
|
||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3,
|
||||
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||
break;
|
||||
}
|
||||
case IOCTLV_NET_SSL_SETROOTCA:
|
||||
{
|
||||
INFO_LOG(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_SETROOTCA "
|
||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
|
||||
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||
INFO_LOG_FMT(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_SETROOTCA "
|
||||
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||
"BufferIn3: ({:08x}, {}), BufferOut: ({:08x}, {}), "
|
||||
"BufferOut2: ({:08x}, {}), BufferOut3: ({:08x}, {})",
|
||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3,
|
||||
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||
|
||||
int sslID = Memory::Read_U32(BufferOut) - 1;
|
||||
if (IsSSLIDValid(sslID))
|
||||
@@ -314,7 +314,7 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
|
||||
WriteReturnValue(SSL_OK, BufferIn);
|
||||
}
|
||||
|
||||
INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SETROOTCA = %d", ret);
|
||||
INFO_LOG_FMT(IOS_SSL, "IOCTLV_NET_SSL_SETROOTCA = {}", ret);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -324,13 +324,13 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
|
||||
}
|
||||
case IOCTLV_NET_SSL_SETBUILTINCLIENTCERT:
|
||||
{
|
||||
INFO_LOG(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_SETBUILTINCLIENTCERT "
|
||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
|
||||
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||
INFO_LOG_FMT(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_SETBUILTINCLIENTCERT "
|
||||
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||
"BufferIn3: ({:08x}, {}), BufferOut: ({:08x}, {}), "
|
||||
"BufferOut2: ({:08x}, {}), BufferOut3: ({:08x}, {})",
|
||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3,
|
||||
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||
|
||||
int sslID = Memory::Read_U32(BufferOut) - 1;
|
||||
if (IsSSLIDValid(sslID))
|
||||
@@ -360,24 +360,24 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
|
||||
WriteReturnValue(SSL_OK, BufferIn);
|
||||
}
|
||||
|
||||
INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT = (%d, %d)", ret, pk_ret);
|
||||
INFO_LOG_FMT(IOS_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT = ({}, {})", ret, pk_ret);
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteReturnValue(SSL_ERR_ID, BufferIn);
|
||||
INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT invalid sslID = %d", sslID);
|
||||
INFO_LOG_FMT(IOS_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT invalid sslID = {}", sslID);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IOCTLV_NET_SSL_REMOVECLIENTCERT:
|
||||
{
|
||||
INFO_LOG(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_REMOVECLIENTCERT "
|
||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
|
||||
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||
INFO_LOG_FMT(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_REMOVECLIENTCERT "
|
||||
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||
"BufferIn3: ({:08x}, {}), BufferOut: ({:08x}, {}), "
|
||||
"BufferOut2: ({:08x}, {}), BufferOut3: ({:08x}, {})",
|
||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3,
|
||||
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||
|
||||
int sslID = Memory::Read_U32(BufferOut) - 1;
|
||||
if (IsSSLIDValid(sslID))
|
||||
@@ -392,7 +392,7 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
|
||||
else
|
||||
{
|
||||
WriteReturnValue(SSL_ERR_ID, BufferIn);
|
||||
INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT invalid sslID = %d", sslID);
|
||||
INFO_LOG_FMT(IOS_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT invalid sslID = {}", sslID);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -419,19 +419,19 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
|
||||
mbedtls_ssl_conf_ca_chain(&ssl->config, &ssl->cacert, nullptr);
|
||||
WriteReturnValue(SSL_OK, BufferIn);
|
||||
}
|
||||
INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SETBUILTINROOTCA = %d", ret);
|
||||
INFO_LOG_FMT(IOS_SSL, "IOCTLV_NET_SSL_SETBUILTINROOTCA = {}", ret);
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteReturnValue(SSL_ERR_ID, BufferIn);
|
||||
}
|
||||
INFO_LOG(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_SETBUILTINROOTCA "
|
||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
|
||||
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||
INFO_LOG_FMT(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_SETBUILTINROOTCA "
|
||||
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||
"BufferIn3: ({:08x}, {}), BufferOut: ({:08x}, {}), "
|
||||
"BufferOut2: ({:08x}, {}), BufferOut3: ({:08x}, {})",
|
||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3,
|
||||
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||
break;
|
||||
}
|
||||
case IOCTLV_NET_SSL_CONNECT:
|
||||
@@ -444,7 +444,7 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
|
||||
ssl->sockfd = Memory::Read_U32(BufferOut2);
|
||||
WiiSockMan& sm = WiiSockMan::GetInstance();
|
||||
ssl->hostfd = sm.GetHostSocket(ssl->sockfd);
|
||||
INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_CONNECT socket = %d", ssl->sockfd);
|
||||
INFO_LOG_FMT(IOS_SSL, "IOCTLV_NET_SSL_CONNECT socket = {}", ssl->sockfd);
|
||||
mbedtls_ssl_set_bio(&ssl->ctx, &ssl->hostfd, mbedtls_net_send, mbedtls_net_recv, nullptr);
|
||||
WriteReturnValue(SSL_OK, BufferIn);
|
||||
}
|
||||
@@ -452,13 +452,13 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
|
||||
{
|
||||
WriteReturnValue(SSL_ERR_ID, BufferIn);
|
||||
}
|
||||
INFO_LOG(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_CONNECT "
|
||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
|
||||
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||
INFO_LOG_FMT(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_CONNECT "
|
||||
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||
"BufferIn3: ({:08x}, {}), BufferOut: ({:08x}, {}), "
|
||||
"BufferOut2: ({:08x}, {}), BufferOut3: ({:08x}, {})",
|
||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3,
|
||||
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||
break;
|
||||
}
|
||||
case IOCTLV_NET_SSL_DOHANDSHAKE:
|
||||
@@ -478,7 +478,7 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
|
||||
}
|
||||
case IOCTLV_NET_SSL_WRITE:
|
||||
{
|
||||
int sslID = Memory::Read_U32(BufferOut) - 1;
|
||||
const int sslID = Memory::Read_U32(BufferOut) - 1;
|
||||
if (IsSSLIDValid(sslID))
|
||||
{
|
||||
WiiSockMan& sm = WiiSockMan::GetInstance();
|
||||
@@ -489,14 +489,14 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
|
||||
{
|
||||
WriteReturnValue(SSL_ERR_ID, BufferIn);
|
||||
}
|
||||
INFO_LOG(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_WRITE "
|
||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
|
||||
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||
INFO_LOG(IOS_SSL, "%s", Memory::GetString(BufferOut2).c_str());
|
||||
INFO_LOG_FMT(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_WRITE "
|
||||
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||
"BufferIn3: ({:08x}, {}), BufferOut: ({:08x}, {}), "
|
||||
"BufferOut2: ({:08x}, {}), BufferOut3: ({:08x}, {})",
|
||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3,
|
||||
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||
INFO_LOG_FMT(IOS_SSL, "{}", Memory::GetString(BufferOut2));
|
||||
break;
|
||||
}
|
||||
case IOCTLV_NET_SSL_READ:
|
||||
@@ -514,13 +514,13 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
|
||||
WriteReturnValue(SSL_ERR_ID, BufferIn);
|
||||
}
|
||||
|
||||
INFO_LOG(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_READ(%d)"
|
||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
||||
ret, BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3,
|
||||
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||
INFO_LOG_FMT(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_READ({})"
|
||||
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||
"BufferIn3: ({:08x}, {}), BufferOut: ({:08x}, {}), "
|
||||
"BufferOut2: ({:08x}, {}), BufferOut3: ({:08x}, {})",
|
||||
ret, BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3,
|
||||
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||
break;
|
||||
}
|
||||
case IOCTLV_NET_SSL_SETROOTCADEFAULT:
|
||||
@@ -534,24 +534,24 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
|
||||
{
|
||||
WriteReturnValue(SSL_ERR_ID, BufferIn);
|
||||
}
|
||||
INFO_LOG(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_SETROOTCADEFAULT "
|
||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
|
||||
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||
INFO_LOG_FMT(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_SETROOTCADEFAULT "
|
||||
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||
"BufferIn3: ({:08x}, {}), BufferOut: ({:08x}, {}), "
|
||||
"BufferOut2: ({:08x}, {}), BufferOut3: ({:08x}, {})",
|
||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3,
|
||||
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||
break;
|
||||
}
|
||||
case IOCTLV_NET_SSL_SETCLIENTCERTDEFAULT:
|
||||
{
|
||||
INFO_LOG(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_SETCLIENTCERTDEFAULT "
|
||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
|
||||
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||
INFO_LOG_FMT(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_SETCLIENTCERTDEFAULT "
|
||||
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||
"BufferIn3: ({:08x}, {}), BufferOut: ({:08x}, {}), "
|
||||
"BufferOut2: ({:08x}, {}), BufferOut3: ({:08x}, {})",
|
||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3,
|
||||
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||
|
||||
int sslID = Memory::Read_U32(BufferOut) - 1;
|
||||
if (IsSSLIDValid(sslID))
|
||||
|
||||
@@ -63,7 +63,7 @@ static s32 TranslateErrorCode(s32 native_error, bool is_rw)
|
||||
switch (native_error)
|
||||
{
|
||||
case ERRORCODE(EMSGSIZE):
|
||||
ERROR_LOG(IOS_NET, "Find out why this happened, looks like PEEK failure?");
|
||||
ERROR_LOG_FMT(IOS_NET, "Find out why this happened, looks like PEEK failure?");
|
||||
return -1; // Should be -SO_EMSGSIZE
|
||||
case EITHER(WSAENOTSOCK, EBADF):
|
||||
return -SO_EBADF;
|
||||
@@ -100,12 +100,12 @@ static s32 TranslateErrorCode(s32 native_error, bool is_rw)
|
||||
}
|
||||
|
||||
// Don't use string! (see https://github.com/dolphin-emu/dolphin/pull/3143)
|
||||
s32 WiiSockMan::GetNetErrorCode(s32 ret, const char* caller, bool isRW)
|
||||
s32 WiiSockMan::GetNetErrorCode(s32 ret, std::string_view caller, bool is_rw)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
s32 errorCode = WSAGetLastError();
|
||||
s32 error_code = WSAGetLastError();
|
||||
#else
|
||||
s32 errorCode = errno;
|
||||
s32 error_code = errno;
|
||||
#endif
|
||||
|
||||
if (ret >= 0)
|
||||
@@ -114,13 +114,13 @@ s32 WiiSockMan::GetNetErrorCode(s32 ret, const char* caller, bool isRW)
|
||||
return ret;
|
||||
}
|
||||
|
||||
ERROR_LOG(IOS_NET, "%s failed with error %d: %s, ret= %d", caller, errorCode,
|
||||
DecodeError(errorCode), ret);
|
||||
ERROR_LOG_FMT(IOS_NET, "{} failed with error {}: {}, ret= {}", caller, error_code,
|
||||
DecodeError(error_code), ret);
|
||||
|
||||
s32 ReturnValue = TranslateErrorCode(errorCode, isRW);
|
||||
WiiSockMan::GetInstance().SetLastNetError(ReturnValue);
|
||||
const s32 return_value = TranslateErrorCode(error_code, is_rw);
|
||||
WiiSockMan::GetInstance().SetLastNetError(return_value);
|
||||
|
||||
return ReturnValue;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
WiiSocket::~WiiSocket()
|
||||
@@ -248,10 +248,10 @@ s32 WiiSocket::FCntl(u32 cmd, u32 arg)
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG(IOS_NET, "SO_FCNTL unknown command");
|
||||
ERROR_LOG_FMT(IOS_NET, "SO_FCNTL unknown command");
|
||||
}
|
||||
|
||||
INFO_LOG(IOS_NET, "IOCTL_SO_FCNTL(%08x, %08X, %08X)", wii_fd, cmd, arg);
|
||||
INFO_LOG_FMT(IOS_NET, "IOCTL_SO_FCNTL({:08x}, {:08X}, {:08X})", wii_fd, cmd, arg);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -285,8 +285,8 @@ void WiiSocket::Update(bool read, bool write, bool except)
|
||||
int ret = bind(fd, (sockaddr*)&local_name, sizeof(local_name));
|
||||
ReturnValue = WiiSockMan::GetNetErrorCode(ret, "SO_BIND", false);
|
||||
|
||||
INFO_LOG(IOS_NET, "IOCTL_SO_BIND (%08X, %s:%d) = %d", wii_fd,
|
||||
inet_ntoa(local_name.sin_addr), Common::swap16(local_name.sin_port), ret);
|
||||
INFO_LOG_FMT(IOS_NET, "IOCTL_SO_BIND ({:08X}, {}:{}) = {}", wii_fd,
|
||||
inet_ntoa(local_name.sin_addr), Common::swap16(local_name.sin_port), ret);
|
||||
break;
|
||||
}
|
||||
case IOCTL_SO_CONNECT:
|
||||
@@ -298,8 +298,8 @@ void WiiSocket::Update(bool read, bool write, bool except)
|
||||
int ret = connect(fd, (sockaddr*)&local_name, sizeof(local_name));
|
||||
ReturnValue = WiiSockMan::GetNetErrorCode(ret, "SO_CONNECT", false);
|
||||
|
||||
INFO_LOG(IOS_NET, "IOCTL_SO_CONNECT (%08x, %s:%d) = %d", wii_fd,
|
||||
inet_ntoa(local_name.sin_addr), Common::swap16(local_name.sin_port), ret);
|
||||
INFO_LOG_FMT(IOS_NET, "IOCTL_SO_CONNECT ({:08x}, {}:{}) = {}", wii_fd,
|
||||
inet_ntoa(local_name.sin_addr), Common::swap16(local_name.sin_port), ret);
|
||||
break;
|
||||
}
|
||||
case IOCTL_SO_ACCEPT:
|
||||
@@ -381,12 +381,12 @@ void WiiSocket::Update(bool read, bool write, bool except)
|
||||
case IOCTLV_NET_SSL_DOHANDSHAKE:
|
||||
{
|
||||
mbedtls_ssl_context* ctx = &Device::NetSSL::_SSL[sslID].ctx;
|
||||
int ret = mbedtls_ssl_handshake(ctx);
|
||||
if (ret)
|
||||
const int ret = mbedtls_ssl_handshake(ctx);
|
||||
if (ret != 0)
|
||||
{
|
||||
char error_buffer[256] = "";
|
||||
mbedtls_strerror(ret, error_buffer, sizeof(error_buffer));
|
||||
ERROR_LOG(IOS_SSL, "IOCTLV_NET_SSL_DOHANDSHAKE: %s", error_buffer);
|
||||
ERROR_LOG_FMT(IOS_SSL, "IOCTLV_NET_SSL_DOHANDSHAKE: {}", error_buffer);
|
||||
}
|
||||
switch (ret)
|
||||
{
|
||||
@@ -408,8 +408,8 @@ void WiiSocket::Update(bool read, bool write, bool except)
|
||||
char error_buffer[256] = "";
|
||||
int res = mbedtls_ssl_get_verify_result(ctx);
|
||||
mbedtls_x509_crt_verify_info(error_buffer, sizeof(error_buffer), "", res);
|
||||
ERROR_LOG(IOS_SSL, "MBEDTLS_ERR_X509_CERT_VERIFY_FAILED (verify_result = %d): %s",
|
||||
res, error_buffer);
|
||||
ERROR_LOG_FMT(IOS_SSL, "MBEDTLS_ERR_X509_CERT_VERIFY_FAILED (verify_result = {}): {}",
|
||||
res, error_buffer);
|
||||
|
||||
if (res & MBEDTLS_X509_BADCERT_CN_MISMATCH)
|
||||
res = SSL_ERR_VCOMMONNAME;
|
||||
@@ -447,12 +447,12 @@ void WiiSocket::Update(bool read, bool write, bool except)
|
||||
}
|
||||
}
|
||||
|
||||
INFO_LOG(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_DOHANDSHAKE = (%d) "
|
||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||
"BufferOut: (%08x, %i), BufferOut2: (%08x, %i)",
|
||||
ret, BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferOut,
|
||||
BufferOutSize, BufferOut2, BufferOutSize2);
|
||||
INFO_LOG_FMT(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_DOHANDSHAKE = ({}) "
|
||||
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||
"BufferOut: ({:08x}, {}), BufferOut2: ({:08x}, {})",
|
||||
ret, BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferOut,
|
||||
BufferOutSize, BufferOut2, BufferOutSize2);
|
||||
break;
|
||||
}
|
||||
case IOCTLV_NET_SSL_WRITE:
|
||||
@@ -564,18 +564,19 @@ void WiiSocket::Update(bool read, bool write, bool except)
|
||||
WiiSockMan::Convert(*wii_name, local_name);
|
||||
}
|
||||
|
||||
int ret = sendto(fd, data, BufferInSize, flags,
|
||||
has_destaddr ? (struct sockaddr*)&local_name : nullptr,
|
||||
has_destaddr ? sizeof(sockaddr) : 0);
|
||||
const int ret = sendto(fd, data, BufferInSize, flags,
|
||||
has_destaddr ? (struct sockaddr*)&local_name : nullptr,
|
||||
has_destaddr ? sizeof(sockaddr) : 0);
|
||||
ReturnValue = WiiSockMan::GetNetErrorCode(ret, "SO_SENDTO", true);
|
||||
|
||||
INFO_LOG(IOS_NET,
|
||||
"%s = %d Socket: %08x, BufferIn: (%08x, %i), BufferIn2: (%08x, %i), %u.%u.%u.%u",
|
||||
has_destaddr ? "IOCTLV_SO_SENDTO " : "IOCTLV_SO_SEND ", ReturnValue, wii_fd,
|
||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2,
|
||||
local_name.sin_addr.s_addr & 0xFF, (local_name.sin_addr.s_addr >> 8) & 0xFF,
|
||||
(local_name.sin_addr.s_addr >> 16) & 0xFF,
|
||||
(local_name.sin_addr.s_addr >> 24) & 0xFF);
|
||||
INFO_LOG_FMT(IOS_NET,
|
||||
"{} = {} Socket: {:08x}, BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||
"{}.{}.{}.{}",
|
||||
has_destaddr ? "IOCTLV_SO_SENDTO " : "IOCTLV_SO_SEND ", ReturnValue, wii_fd,
|
||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2,
|
||||
local_name.sin_addr.s_addr & 0xFF, (local_name.sin_addr.s_addr >> 8) & 0xFF,
|
||||
(local_name.sin_addr.s_addr >> 16) & 0xFF,
|
||||
(local_name.sin_addr.s_addr >> 24) & 0xFF);
|
||||
break;
|
||||
}
|
||||
case IOCTLV_SO_RECVFROM:
|
||||
@@ -609,19 +610,19 @@ void WiiSocket::Update(bool read, bool write, bool except)
|
||||
}
|
||||
#endif
|
||||
socklen_t addrlen = sizeof(sockaddr_in);
|
||||
int ret = recvfrom(fd, data, data_len, flags,
|
||||
BufferOutSize2 ? (struct sockaddr*)&local_name : nullptr,
|
||||
BufferOutSize2 ? &addrlen : nullptr);
|
||||
const int ret = recvfrom(fd, data, data_len, flags,
|
||||
BufferOutSize2 ? (struct sockaddr*)&local_name : nullptr,
|
||||
BufferOutSize2 ? &addrlen : nullptr);
|
||||
ReturnValue =
|
||||
WiiSockMan::GetNetErrorCode(ret, BufferOutSize2 ? "SO_RECVFROM" : "SO_RECV", true);
|
||||
|
||||
INFO_LOG(IOS_NET,
|
||||
"%s(%d, %p) Socket: %08X, Flags: %08X, "
|
||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||
"BufferOut: (%08x, %i), BufferOut2: (%08x, %i)",
|
||||
BufferOutSize2 ? "IOCTLV_SO_RECVFROM " : "IOCTLV_SO_RECV ", ReturnValue, data,
|
||||
wii_fd, flags, BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferOut,
|
||||
BufferOutSize, BufferOut2, BufferOutSize2);
|
||||
INFO_LOG_FMT(IOS_NET,
|
||||
"{}({}, {}) Socket: {:08X}, Flags: {:08X}, "
|
||||
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||
"BufferOut: ({:08x}, {}), BufferOut2: ({:08x}, {})",
|
||||
BufferOutSize2 ? "IOCTLV_SO_RECVFROM " : "IOCTLV_SO_RECV ", ReturnValue,
|
||||
fmt::ptr(data), wii_fd, flags, BufferIn, BufferInSize, BufferIn2,
|
||||
BufferInSize2, BufferOut, BufferOutSize, BufferOut2, BufferOutSize2);
|
||||
|
||||
if (BufferOutSize2 != 0)
|
||||
{
|
||||
@@ -647,10 +648,10 @@ void WiiSocket::Update(bool read, bool write, bool except)
|
||||
ReturnValue != -SO_EALREADY) ||
|
||||
(it->is_ssl && ReturnValue != SSL_ERR_WAGAIN && ReturnValue != SSL_ERR_RAGAIN))
|
||||
{
|
||||
DEBUG_LOG(IOS_NET,
|
||||
"IOCTL(V) Sock: %08x ioctl/v: %d returned: %d nonBlock: %d forceNonBlock: %d",
|
||||
wii_fd, it->is_ssl ? (int)it->ssl_type : (int)it->net_type, ReturnValue, nonBlock,
|
||||
forceNonBlock);
|
||||
DEBUG_LOG_FMT(
|
||||
IOS_NET, "IOCTL(V) Sock: {:08x} ioctl/v: {} returned: {} nonBlock: {} forceNonBlock: {}",
|
||||
wii_fd, it->is_ssl ? static_cast<int>(it->ssl_type) : static_cast<int>(it->net_type),
|
||||
ReturnValue, nonBlock, forceNonBlock);
|
||||
|
||||
// TODO: remove the dependency on a running IOS instance.
|
||||
GetIOS()->EnqueueIPCReply(it->request, ReturnValue);
|
||||
@@ -697,7 +698,7 @@ s32 WiiSockMan::AddSocket(s32 fd, bool is_rw)
|
||||
// Close host socket
|
||||
closesocket(fd);
|
||||
wii_fd = -SO_EMFILE;
|
||||
ERROR_LOG(IOS_NET, "%s failed: Too many open sockets, ret=%d", caller, wii_fd);
|
||||
ERROR_LOG_FMT(IOS_NET, "{} failed: Too many open sockets, ret={}", caller, wii_fd);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -708,7 +709,7 @@ s32 WiiSockMan::AddSocket(s32 fd, bool is_rw)
|
||||
#ifdef __APPLE__
|
||||
int opt_no_sigpipe = 1;
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, &opt_no_sigpipe, sizeof(opt_no_sigpipe)) < 0)
|
||||
ERROR_LOG(IOS_NET, "Failed to set SO_NOSIGPIPE on socket");
|
||||
ERROR_LOG_FMT(IOS_NET, "Failed to set SO_NOSIGPIPE on socket");
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -883,8 +884,9 @@ void WiiSockMan::UpdatePollCommands()
|
||||
// Memory::Write_U32(ufds[i].fd, request.buffer_out + 0xc*i); //fd
|
||||
// Memory::Write_U32(events, request.buffer_out + 0xc*i + 4); //events
|
||||
Memory::Write_U32(revents, pcmd.buffer_out + 0xc * i + 8); // revents
|
||||
DEBUG_LOG(IOS_NET, "IOCTL_SO_POLL socket %d wevents %08X events %08X revents %08X", i,
|
||||
revents, pfds[i].events, pfds[i].revents);
|
||||
DEBUG_LOG_FMT(IOS_NET,
|
||||
"IOCTL_SO_POLL socket {} wevents {:08X} events {:08X} revents {:08X}",
|
||||
i, revents, pfds[i].events, pfds[i].revents);
|
||||
}
|
||||
GetIOS()->EnqueueIPCReply(request, ret);
|
||||
return true;
|
||||
@@ -932,7 +934,7 @@ s32 WiiSockMan::ConvertEvents(s32 events, ConvertDirection dir)
|
||||
}
|
||||
}
|
||||
if (unhandled_events)
|
||||
ERROR_LOG(IOS_NET, "SO_POLL: unhandled Wii event types: %04x", unhandled_events);
|
||||
ERROR_LOG_FMT(IOS_NET, "SO_POLL: unhandled Wii event types: {:04x}", unhandled_events);
|
||||
return converted_events;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ typedef struct pollfd pollfd_t;
|
||||
#include <cstdio>
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
|
||||
@@ -229,7 +230,7 @@ public:
|
||||
s64 timeout;
|
||||
};
|
||||
|
||||
static s32 GetNetErrorCode(s32 ret, const char* caller, bool isRW);
|
||||
static s32 GetNetErrorCode(s32 ret, std::string_view caller, bool is_rw);
|
||||
static char* DecodeError(s32 ErrorCode);
|
||||
|
||||
static WiiSockMan& GetInstance()
|
||||
@@ -260,8 +261,8 @@ public:
|
||||
auto socket_entry = WiiSockets.find(sock);
|
||||
if (socket_entry == WiiSockets.end())
|
||||
{
|
||||
ERROR_LOG(IOS_NET, "DoSock: Error, fd not found (%08x, %08X, %08X)", sock, request.address,
|
||||
type);
|
||||
ERROR_LOG_FMT(IOS_NET, "DoSock: Error, fd not found ({:08x}, {:08X}, {:08X})", sock,
|
||||
request.address, type);
|
||||
GetIOS()->EnqueueIPCReply(request, -SO_EBADF);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -27,7 +27,7 @@ SDIOSlot0::SDIOSlot0(Kernel& ios, const std::string& device_name)
|
||||
: Device(ios, device_name), m_sdhc_supported(HasFeature(ios.GetVersion(), Feature::SDv2))
|
||||
{
|
||||
if (!Config::Get(Config::MAIN_ALLOW_SD_WRITES))
|
||||
INFO_LOG(IOS_SD, "Writes to SD card disabled by user");
|
||||
INFO_LOG_FMT(IOS_SD, "Writes to SD card disabled by user");
|
||||
}
|
||||
|
||||
void SDIOSlot0::DoState(PointerWrap& p)
|
||||
@@ -65,16 +65,16 @@ void SDIOSlot0::OpenInternal()
|
||||
m_card.Open(filename, "r+b");
|
||||
if (!m_card)
|
||||
{
|
||||
WARN_LOG(IOS_SD, "Failed to open SD Card image, trying to create a new 128 MB image...");
|
||||
WARN_LOG_FMT(IOS_SD, "Failed to open SD Card image, trying to create a new 128 MB image...");
|
||||
if (Common::SDCardCreate(128, filename))
|
||||
{
|
||||
INFO_LOG(IOS_SD, "Successfully created %s", filename.c_str());
|
||||
INFO_LOG_FMT(IOS_SD, "Successfully created {}", filename);
|
||||
m_card.Open(filename, "r+b");
|
||||
}
|
||||
if (!m_card)
|
||||
{
|
||||
ERROR_LOG(IOS_SD, "Could not open SD Card image or create a new one, are you running "
|
||||
"from a read-only directory?");
|
||||
ERROR_LOG_FMT(IOS_SD, "Could not open SD Card image or create a new one, are you running "
|
||||
"from a read-only directory?");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,7 +119,7 @@ IPCCommandResult SDIOSlot0::IOCtl(const IOCtlRequest& request)
|
||||
case IOCTL_GETOCR:
|
||||
return GetOCRegister(request);
|
||||
default:
|
||||
ERROR_LOG(IOS_SD, "Unknown SD IOCtl command (0x%08x)", request.request);
|
||||
ERROR_LOG_FMT(IOS_SD, "Unknown SD IOCtl command ({:#010x})", request.request);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ IPCCommandResult SDIOSlot0::IOCtlV(const IOCtlVRequest& request)
|
||||
case IOCTLV_SENDCMD:
|
||||
return SendCommand(request);
|
||||
default:
|
||||
ERROR_LOG(IOS_SD, "Unknown SD IOCtlV command 0x%08x", request.request);
|
||||
ERROR_LOG_FMT(IOS_SD, "Unknown SD IOCtlV command {:#010x}", request.request);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ s32 SDIOSlot0::ExecuteCommand(const Request& request, u32 buffer_in, u32 buffer_
|
||||
switch (req.command)
|
||||
{
|
||||
case GO_IDLE_STATE:
|
||||
INFO_LOG(IOS_SD, "GO_IDLE_STATE");
|
||||
INFO_LOG_FMT(IOS_SD, "GO_IDLE_STATE");
|
||||
// Response is R1 (idle state)
|
||||
Memory::Write_U32(0x00, buffer_out);
|
||||
break;
|
||||
@@ -194,7 +194,7 @@ s32 SDIOSlot0::ExecuteCommand(const Request& request, u32 buffer_in, u32 buffer_
|
||||
break;
|
||||
|
||||
case SEND_IF_COND:
|
||||
INFO_LOG(IOS_SD, "SEND_IF_COND");
|
||||
INFO_LOG_FMT(IOS_SD, "SEND_IF_COND");
|
||||
// If the card can operate on the supplied voltage, the response echoes back the supply
|
||||
// voltage and the check pattern that were set in the command argument.
|
||||
// This command is used to differentiate between protocol v1 and v2.
|
||||
@@ -211,7 +211,7 @@ s32 SDIOSlot0::ExecuteCommand(const Request& request, u32 buffer_in, u32 buffer_
|
||||
|
||||
case ALL_SEND_CID:
|
||||
case SEND_CID:
|
||||
INFO_LOG(IOS_SD, "(ALL_)SEND_CID");
|
||||
INFO_LOG_FMT(IOS_SD, "(ALL_)SEND_CID");
|
||||
Memory::Write_U32(0x80114d1c, buffer_out);
|
||||
Memory::Write_U32(0x80080000, buffer_out + 4);
|
||||
Memory::Write_U32(0x8007b520, buffer_out + 8);
|
||||
@@ -244,25 +244,25 @@ s32 SDIOSlot0::ExecuteCommand(const Request& request, u32 buffer_in, u32 buffer_
|
||||
{
|
||||
// Data address (req.arg) is in byte units in a Standard Capacity SD Memory Card
|
||||
// and in block (512 Byte) units in a High Capacity SD Memory Card.
|
||||
INFO_LOG(IOS_SD, "%sRead %i Block(s) from 0x%08x bsize %i into 0x%08x!",
|
||||
req.isDMA ? "DMA " : "", req.blocks, req.arg, req.bsize, req.addr);
|
||||
INFO_LOG_FMT(IOS_SD, "{}Read {} Block(s) from {:#010x} bsize {} into {:#010x}!",
|
||||
req.isDMA ? "DMA " : "", req.blocks, req.arg, req.bsize, req.addr);
|
||||
|
||||
if (m_card)
|
||||
{
|
||||
u32 size = req.bsize * req.blocks;
|
||||
u64 address = GetAddressFromRequest(req.arg);
|
||||
const u32 size = req.bsize * req.blocks;
|
||||
const u64 address = GetAddressFromRequest(req.arg);
|
||||
|
||||
if (!m_card.Seek(address, SEEK_SET))
|
||||
ERROR_LOG(IOS_SD, "Seek failed WTF");
|
||||
ERROR_LOG_FMT(IOS_SD, "Seek failed WTF");
|
||||
|
||||
if (m_card.ReadBytes(Memory::GetPointer(req.addr), size))
|
||||
{
|
||||
DEBUG_LOG(IOS_SD, "Outbuffer size %i got %i", rw_buffer_size, size);
|
||||
DEBUG_LOG_FMT(IOS_SD, "Outbuffer size {} got {}", rw_buffer_size, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG(IOS_SD, "Read Failed - error: %i, eof: %i", ferror(m_card.GetHandle()),
|
||||
feof(m_card.GetHandle()));
|
||||
ERROR_LOG_FMT(IOS_SD, "Read Failed - error: {}, eof: {}", std::ferror(m_card.GetHandle()),
|
||||
std::feof(m_card.GetHandle()));
|
||||
ret = RET_FAIL;
|
||||
}
|
||||
}
|
||||
@@ -274,22 +274,22 @@ s32 SDIOSlot0::ExecuteCommand(const Request& request, u32 buffer_in, u32 buffer_
|
||||
{
|
||||
// Data address (req.arg) is in byte units in a Standard Capacity SD Memory Card
|
||||
// and in block (512 Byte) units in a High Capacity SD Memory Card.
|
||||
INFO_LOG(IOS_SD, "%sWrite %i Block(s) from 0x%08x bsize %i to offset 0x%08x!",
|
||||
req.isDMA ? "DMA " : "", req.blocks, req.addr, req.bsize, req.arg);
|
||||
INFO_LOG_FMT(IOS_SD, "{}Write {} Block(s) from {:#010x} bsize {} to offset {:#010x}!",
|
||||
req.isDMA ? "DMA " : "", req.blocks, req.addr, req.bsize, req.arg);
|
||||
|
||||
if (m_card && SConfig::GetInstance().bEnableMemcardSdWriting &&
|
||||
Config::Get(Config::MAIN_ALLOW_SD_WRITES))
|
||||
{
|
||||
u32 size = req.bsize * req.blocks;
|
||||
u64 address = GetAddressFromRequest(req.arg);
|
||||
const u32 size = req.bsize * req.blocks;
|
||||
const u64 address = GetAddressFromRequest(req.arg);
|
||||
|
||||
if (!m_card.Seek(address, SEEK_SET))
|
||||
ERROR_LOG(IOS_SD, "fseeko failed WTF");
|
||||
ERROR_LOG_FMT(IOS_SD, "fseeko failed WTF");
|
||||
|
||||
if (!m_card.WriteBytes(Memory::GetPointer(req.addr), size))
|
||||
{
|
||||
ERROR_LOG(IOS_SD, "Write Failed - error: %i, eof: %i", ferror(m_card.GetHandle()),
|
||||
feof(m_card.GetHandle()));
|
||||
ERROR_LOG_FMT(IOS_SD, "Write Failed - error: {}, eof: {}", std::ferror(m_card.GetHandle()),
|
||||
std::feof(m_card.GetHandle()));
|
||||
ret = RET_FAIL;
|
||||
}
|
||||
}
|
||||
@@ -298,7 +298,7 @@ s32 SDIOSlot0::ExecuteCommand(const Request& request, u32 buffer_in, u32 buffer_
|
||||
break;
|
||||
|
||||
case EVENT_REGISTER: // async
|
||||
INFO_LOG(IOS_SD, "Register event %x", req.arg);
|
||||
INFO_LOG_FMT(IOS_SD, "Register event {:x}", req.arg);
|
||||
m_event = std::make_unique<Event>(static_cast<EventType>(req.arg), request);
|
||||
ret = RET_EVENT_REGISTER;
|
||||
break;
|
||||
@@ -306,7 +306,7 @@ s32 SDIOSlot0::ExecuteCommand(const Request& request, u32 buffer_in, u32 buffer_
|
||||
// Used to cancel an event that was already registered.
|
||||
case EVENT_UNREGISTER:
|
||||
{
|
||||
INFO_LOG(IOS_SD, "Unregister event %x", req.arg);
|
||||
INFO_LOG_FMT(IOS_SD, "Unregister event {:x}", req.arg);
|
||||
if (!m_event)
|
||||
return IPC_EINVAL;
|
||||
// release returns 0
|
||||
@@ -318,7 +318,7 @@ s32 SDIOSlot0::ExecuteCommand(const Request& request, u32 buffer_in, u32 buffer_
|
||||
}
|
||||
|
||||
default:
|
||||
ERROR_LOG(IOS_SD, "Unknown SD command 0x%08x", req.command);
|
||||
ERROR_LOG_FMT(IOS_SD, "Unknown SD command {:#010x}", req.command);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -327,14 +327,14 @@ s32 SDIOSlot0::ExecuteCommand(const Request& request, u32 buffer_in, u32 buffer_
|
||||
|
||||
IPCCommandResult SDIOSlot0::WriteHCRegister(const IOCtlRequest& request)
|
||||
{
|
||||
u32 reg = Memory::Read_U32(request.buffer_in);
|
||||
u32 val = Memory::Read_U32(request.buffer_in + 16);
|
||||
const u32 reg = Memory::Read_U32(request.buffer_in);
|
||||
const u32 val = Memory::Read_U32(request.buffer_in + 16);
|
||||
|
||||
INFO_LOG(IOS_SD, "IOCTL_WRITEHCR 0x%08x - 0x%08x", reg, val);
|
||||
INFO_LOG_FMT(IOS_SD, "IOCTL_WRITEHCR {:#010x} - {:#010x}", reg, val);
|
||||
|
||||
if (reg >= m_registers.size())
|
||||
{
|
||||
WARN_LOG(IOS_SD, "IOCTL_WRITEHCR out of range");
|
||||
WARN_LOG_FMT(IOS_SD, "IOCTL_WRITEHCR out of range");
|
||||
return GetDefaultReply(IPC_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -359,16 +359,16 @@ IPCCommandResult SDIOSlot0::WriteHCRegister(const IOCtlRequest& request)
|
||||
|
||||
IPCCommandResult SDIOSlot0::ReadHCRegister(const IOCtlRequest& request)
|
||||
{
|
||||
u32 reg = Memory::Read_U32(request.buffer_in);
|
||||
const u32 reg = Memory::Read_U32(request.buffer_in);
|
||||
|
||||
if (reg >= m_registers.size())
|
||||
{
|
||||
WARN_LOG(IOS_SD, "IOCTL_READHCR out of range");
|
||||
WARN_LOG_FMT(IOS_SD, "IOCTL_READHCR out of range");
|
||||
return GetDefaultReply(IPC_SUCCESS);
|
||||
}
|
||||
|
||||
u32 val = m_registers[reg];
|
||||
INFO_LOG(IOS_SD, "IOCTL_READHCR 0x%08x - 0x%08x", reg, val);
|
||||
const u32 val = m_registers[reg];
|
||||
INFO_LOG_FMT(IOS_SD, "IOCTL_READHCR {:#010x} - {:#010x}", reg, val);
|
||||
|
||||
// Just reading the register
|
||||
Memory::Write_U32(val, request.buffer_out);
|
||||
@@ -377,7 +377,7 @@ IPCCommandResult SDIOSlot0::ReadHCRegister(const IOCtlRequest& request)
|
||||
|
||||
IPCCommandResult SDIOSlot0::ResetCard(const IOCtlRequest& request)
|
||||
{
|
||||
INFO_LOG(IOS_SD, "IOCTL_RESETCARD");
|
||||
INFO_LOG_FMT(IOS_SD, "IOCTL_RESETCARD");
|
||||
|
||||
// Returns 16bit RCA and 16bit 0s (meaning success)
|
||||
Memory::Write_U32(m_status, request.buffer_out);
|
||||
@@ -387,21 +387,21 @@ IPCCommandResult SDIOSlot0::ResetCard(const IOCtlRequest& request)
|
||||
|
||||
IPCCommandResult SDIOSlot0::SetClk(const IOCtlRequest& request)
|
||||
{
|
||||
INFO_LOG(IOS_SD, "IOCTL_SETCLK");
|
||||
INFO_LOG_FMT(IOS_SD, "IOCTL_SETCLK");
|
||||
|
||||
// libogc only sets it to 1 and makes sure the return isn't negative...
|
||||
// one half of the sdclk divisor: a power of two or zero.
|
||||
u32 clock = Memory::Read_U32(request.buffer_in);
|
||||
const u32 clock = Memory::Read_U32(request.buffer_in);
|
||||
if (clock != 1)
|
||||
INFO_LOG(IOS_SD, "Setting to %i, interesting", clock);
|
||||
INFO_LOG_FMT(IOS_SD, "Setting to {}, interesting", clock);
|
||||
|
||||
return GetDefaultReply(IPC_SUCCESS);
|
||||
}
|
||||
|
||||
IPCCommandResult SDIOSlot0::SendCommand(const IOCtlRequest& request)
|
||||
{
|
||||
INFO_LOG(IOS_SD, "IOCTL_SENDCMD %x IPC:%08x", Memory::Read_U32(request.buffer_in),
|
||||
request.address);
|
||||
INFO_LOG_FMT(IOS_SD, "IOCTL_SENDCMD {:x} IPC:{:08x}", Memory::Read_U32(request.buffer_in),
|
||||
request.address);
|
||||
|
||||
const s32 return_value = ExecuteCommand(request, request.buffer_in, request.buffer_in_size, 0, 0,
|
||||
request.buffer_out, request.buffer_out_size);
|
||||
@@ -444,10 +444,10 @@ IPCCommandResult SDIOSlot0::GetStatus(const IOCtlRequest& request)
|
||||
const u32 status =
|
||||
SConfig::GetInstance().m_WiiSDCard ? (m_status | CARD_INSERTED) : CARD_NOT_EXIST;
|
||||
|
||||
INFO_LOG(IOS_SD, "IOCTL_GETSTATUS. Replying that %s card is %s%s",
|
||||
(status & CARD_SDHC) ? "SDHC" : "SD",
|
||||
(status & CARD_INSERTED) ? "inserted" : "not present",
|
||||
(status & CARD_INITIALIZED) ? " and initialized" : "");
|
||||
INFO_LOG_FMT(IOS_SD, "IOCTL_GETSTATUS. Replying that {} card is {}{}",
|
||||
(status & CARD_SDHC) ? "SDHC" : "SD",
|
||||
(status & CARD_INSERTED) ? "inserted" : "not present",
|
||||
(status & CARD_INITIALIZED) ? " and initialized" : "");
|
||||
|
||||
Memory::Write_U32(status, request.buffer_out);
|
||||
return GetDefaultReply(IPC_SUCCESS);
|
||||
@@ -455,8 +455,8 @@ IPCCommandResult SDIOSlot0::GetStatus(const IOCtlRequest& request)
|
||||
|
||||
IPCCommandResult SDIOSlot0::GetOCRegister(const IOCtlRequest& request)
|
||||
{
|
||||
u32 ocr = GetOCRegister();
|
||||
INFO_LOG(IOS_SD, "IOCTL_GETOCR. Replying with ocr %x", ocr);
|
||||
const u32 ocr = GetOCRegister();
|
||||
INFO_LOG_FMT(IOS_SD, "IOCTL_GETOCR. Replying with ocr {:x}", ocr);
|
||||
Memory::Write_U32(ocr, request.buffer_out);
|
||||
|
||||
return GetDefaultReply(IPC_SUCCESS);
|
||||
@@ -464,7 +464,7 @@ IPCCommandResult SDIOSlot0::GetOCRegister(const IOCtlRequest& request)
|
||||
|
||||
IPCCommandResult SDIOSlot0::SendCommand(const IOCtlVRequest& request)
|
||||
{
|
||||
DEBUG_LOG(IOS_SD, "IOCTLV_SENDCMD 0x%08x", Memory::Read_U32(request.in_vectors[0].address));
|
||||
DEBUG_LOG_FMT(IOS_SD, "IOCTLV_SENDCMD {:#010x}", Memory::Read_U32(request.in_vectors[0].address));
|
||||
Memory::Memset(request.io_vectors[0].address, 0, request.io_vectors[0].size);
|
||||
|
||||
const s32 return_value =
|
||||
@@ -502,7 +502,7 @@ std::array<u32, 4> SDIOSlot0::GetCSDv1() const
|
||||
size >>= 1;
|
||||
if (++c_size_mult >= 8 + 2 + read_bl_len)
|
||||
{
|
||||
ERROR_LOG(IOS_SD, "SD Card is too big!");
|
||||
ERROR_LOG_FMT(IOS_SD, "SD Card is too big!");
|
||||
// Set max values
|
||||
size = 4096;
|
||||
c_size_mult = 7 + 2 + read_bl_len;
|
||||
@@ -513,9 +513,9 @@ std::array<u32, 4> SDIOSlot0::GetCSDv1() const
|
||||
const u32 c_size(size);
|
||||
|
||||
if (invalid_size)
|
||||
WARN_LOG(IOS_SD, "SD Card size is invalid");
|
||||
WARN_LOG_FMT(IOS_SD, "SD Card size is invalid");
|
||||
else
|
||||
INFO_LOG(IOS_SD, "SD C_SIZE = %u, C_SIZE_MULT = %u", c_size, c_size_mult);
|
||||
INFO_LOG_FMT(IOS_SD, "SD C_SIZE = {}, C_SIZE_MULT = {}", c_size, c_size_mult);
|
||||
|
||||
// 0b00 CSD_STRUCTURE (SDv1)
|
||||
// 0b000000 reserved
|
||||
@@ -574,7 +574,7 @@ std::array<u32, 4> SDIOSlot0::GetCSDv2() const
|
||||
const u64 size = m_card.GetSize();
|
||||
|
||||
if (size % (512 * 1024) != 0)
|
||||
WARN_LOG(IOS_SD, "SDHC Card size cannot be divided by 1024 * 512");
|
||||
WARN_LOG_FMT(IOS_SD, "SDHC Card size cannot be divided by 1024 * 512");
|
||||
|
||||
const u32 c_size(size / (512 * 1024) - 1);
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ IPCCommandResult STMImmediate::IOCtl(const IOCtlRequest& request)
|
||||
{
|
||||
case IOCTL_STM_IDLE:
|
||||
case IOCTL_STM_SHUTDOWN:
|
||||
NOTICE_LOG(IOS_STM, "IOCTL_STM_IDLE or IOCTL_STM_SHUTDOWN received, shutting down");
|
||||
NOTICE_LOG_FMT(IOS_STM, "IOCTL_STM_IDLE or IOCTL_STM_SHUTDOWN received, shutting down");
|
||||
Core::QueueHostJob(&Core::Stop, false);
|
||||
break;
|
||||
|
||||
@@ -39,20 +39,20 @@ IPCCommandResult STMImmediate::IOCtl(const IOCtlRequest& request)
|
||||
break;
|
||||
|
||||
case IOCTL_STM_HOTRESET:
|
||||
INFO_LOG(IOS_STM, "%s - IOCtl:", GetDeviceName().c_str());
|
||||
INFO_LOG(IOS_STM, " IOCTL_STM_HOTRESET");
|
||||
INFO_LOG_FMT(IOS_STM, "{} - IOCtl:", GetDeviceName());
|
||||
INFO_LOG_FMT(IOS_STM, " IOCTL_STM_HOTRESET");
|
||||
break;
|
||||
|
||||
case IOCTL_STM_VIDIMMING: // (Input: 20 bytes, Output: 20 bytes)
|
||||
INFO_LOG(IOS_STM, "%s - IOCtl:", GetDeviceName().c_str());
|
||||
INFO_LOG(IOS_STM, " IOCTL_STM_VIDIMMING");
|
||||
INFO_LOG_FMT(IOS_STM, "{} - IOCtl:", GetDeviceName());
|
||||
INFO_LOG_FMT(IOS_STM, " IOCTL_STM_VIDIMMING");
|
||||
// Memory::Write_U32(1, buffer_out);
|
||||
// return_value = 1;
|
||||
break;
|
||||
|
||||
case IOCTL_STM_LEDMODE: // (Input: 20 bytes, Output: 20 bytes)
|
||||
INFO_LOG(IOS_STM, "%s - IOCtl:", GetDeviceName().c_str());
|
||||
INFO_LOG(IOS_STM, " IOCTL_STM_LEDMODE");
|
||||
INFO_LOG_FMT(IOS_STM, "{} - IOCtl:", GetDeviceName());
|
||||
INFO_LOG_FMT(IOS_STM, " IOCTL_STM_LEDMODE");
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -30,7 +30,7 @@ void BackUpBTInfoSection(const SysConf* sysconf)
|
||||
|
||||
const std::vector<u8>& section = btdinf->bytes;
|
||||
if (!backup.WriteBytes(section.data(), section.size()))
|
||||
ERROR_LOG(IOS_WIIMOTE, "Failed to back up BT.DINF section");
|
||||
ERROR_LOG_FMT(IOS_WIIMOTE, "Failed to back up BT.DINF section");
|
||||
}
|
||||
|
||||
void RestoreBTInfoSection(SysConf* sysconf)
|
||||
@@ -43,7 +43,7 @@ void RestoreBTInfoSection(SysConf* sysconf)
|
||||
auto& section = sysconf->GetOrAddEntry("BT.DINF", SysConf::Entry::Type::BigArray)->bytes;
|
||||
if (!backup.ReadBytes(section.data(), section.size()))
|
||||
{
|
||||
ERROR_LOG(IOS_WIIMOTE, "Failed to read backed up BT.DINF section");
|
||||
ERROR_LOG_FMT(IOS_WIIMOTE, "Failed to read backed up BT.DINF section");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -89,8 +89,8 @@ IPCCommandResult BluetoothReal::Open(const OpenRequest& request)
|
||||
auto config_descriptor = LibusbUtils::MakeConfigDescriptor(device);
|
||||
if (!config_descriptor)
|
||||
{
|
||||
ERROR_LOG(IOS_WIIMOTE, "Failed to get config descriptor for device %04x:%04x",
|
||||
device_descriptor.idVendor, device_descriptor.idProduct);
|
||||
ERROR_LOG_FMT(IOS_WIIMOTE, "Failed to get config descriptor for device {:04x}:{:04x}",
|
||||
device_descriptor.idVendor, device_descriptor.idProduct);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -105,9 +105,9 @@ IPCCommandResult BluetoothReal::Open(const OpenRequest& request)
|
||||
sizeof(product));
|
||||
libusb_get_string_descriptor_ascii(m_handle, device_descriptor.iSerialNumber, serial_number,
|
||||
sizeof(serial_number));
|
||||
NOTICE_LOG(IOS_WIIMOTE, "Using device %04x:%04x (rev %x) for Bluetooth: %s %s %s",
|
||||
device_descriptor.idVendor, device_descriptor.idProduct,
|
||||
device_descriptor.bcdDevice, manufacturer, product, serial_number);
|
||||
NOTICE_LOG_FMT(IOS_WIIMOTE, "Using device {:04x}:{:04x} (rev {:x}) for Bluetooth: {} {} {}",
|
||||
device_descriptor.idVendor, device_descriptor.idProduct,
|
||||
device_descriptor.bcdDevice, manufacturer, product, serial_number);
|
||||
m_is_wii_bt_module =
|
||||
device_descriptor.idVendor == 0x57e && device_descriptor.idProduct == 0x305;
|
||||
return false;
|
||||
@@ -119,16 +119,17 @@ IPCCommandResult BluetoothReal::Open(const OpenRequest& request)
|
||||
{
|
||||
if (m_last_open_error.empty())
|
||||
{
|
||||
CriticalAlertT(
|
||||
CriticalAlertFmtT(
|
||||
"Could not find any usable Bluetooth USB adapter for Bluetooth Passthrough.\n\n"
|
||||
"The emulated console will now stop.");
|
||||
}
|
||||
else
|
||||
{
|
||||
CriticalAlertT("Could not find any usable Bluetooth USB adapter for Bluetooth Passthrough.\n"
|
||||
"The following error occurred when Dolphin tried to use an adapter:\n%s\n\n"
|
||||
"The emulated console will now stop.",
|
||||
m_last_open_error.c_str());
|
||||
CriticalAlertFmtT(
|
||||
"Could not find any usable Bluetooth USB adapter for Bluetooth Passthrough.\n"
|
||||
"The following error occurred when Dolphin tried to use an adapter:\n{0}\n\n"
|
||||
"The emulated console will now stop.",
|
||||
m_last_open_error);
|
||||
}
|
||||
Core::QueueHostJob(Core::Stop);
|
||||
return GetDefaultReply(IPC_ENOENT);
|
||||
@@ -368,7 +369,7 @@ void BluetoothReal::SendHCIResetCommand()
|
||||
const u16 payload[] = {HCI_CMD_RESET};
|
||||
memcpy(packet, payload, sizeof(payload));
|
||||
libusb_control_transfer(m_handle, REQUEST_TYPE, 0, 0, 0, packet, sizeof(packet), TIMEOUT);
|
||||
INFO_LOG(IOS_WIIMOTE, "Sent a reset command to adapter");
|
||||
INFO_LOG_FMT(IOS_WIIMOTE, "Sent a reset command to adapter");
|
||||
}
|
||||
|
||||
void BluetoothReal::SendHCIDeleteLinkKeyCommand()
|
||||
@@ -481,8 +482,8 @@ void BluetoothReal::FakeSyncButtonEvent(USB::V0IntrMessage& ctrl, const u8* payl
|
||||
// This causes the emulated software to perform a BT inquiry and connect to found Wiimotes.
|
||||
void BluetoothReal::FakeSyncButtonPressedEvent(USB::V0IntrMessage& ctrl)
|
||||
{
|
||||
NOTICE_LOG(IOS_WIIMOTE, "Faking 'sync button pressed' (0x08) event packet");
|
||||
const u8 payload[1] = {0x08};
|
||||
NOTICE_LOG_FMT(IOS_WIIMOTE, "Faking 'sync button pressed' (0x08) event packet");
|
||||
constexpr u8 payload[1] = {0x08};
|
||||
FakeSyncButtonEvent(ctrl, payload, sizeof(payload));
|
||||
m_sync_button_state = SyncButtonState::Ignored;
|
||||
}
|
||||
@@ -490,8 +491,8 @@ void BluetoothReal::FakeSyncButtonPressedEvent(USB::V0IntrMessage& ctrl)
|
||||
// When the red sync button is held for 10 seconds, a HCI event with payload 09 is sent.
|
||||
void BluetoothReal::FakeSyncButtonHeldEvent(USB::V0IntrMessage& ctrl)
|
||||
{
|
||||
NOTICE_LOG(IOS_WIIMOTE, "Faking 'sync button held' (0x09) event packet");
|
||||
const u8 payload[1] = {0x09};
|
||||
NOTICE_LOG_FMT(IOS_WIIMOTE, "Faking 'sync button held' (0x09) event packet");
|
||||
constexpr u8 payload[1] = {0x09};
|
||||
FakeSyncButtonEvent(ctrl, payload, sizeof(payload));
|
||||
m_sync_button_state = SyncButtonState::Ignored;
|
||||
}
|
||||
@@ -511,8 +512,9 @@ void BluetoothReal::LoadLinkKeys()
|
||||
std::optional<bdaddr_t> address = Common::StringToMacAddress(address_string);
|
||||
if (!address)
|
||||
{
|
||||
ERROR_LOG(IOS_WIIMOTE, "Malformed MAC address (%s). Skipping loading of current link key.",
|
||||
address_string.c_str());
|
||||
ERROR_LOG_FMT(IOS_WIIMOTE,
|
||||
"Malformed MAC address ({}). Skipping loading of current link key.",
|
||||
address_string);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -598,7 +600,7 @@ void BluetoothReal::HandleCtrlTransfer(libusb_transfer* tr)
|
||||
|
||||
if (tr->status != LIBUSB_TRANSFER_COMPLETED && tr->status != LIBUSB_TRANSFER_NO_DEVICE)
|
||||
{
|
||||
ERROR_LOG(IOS_WIIMOTE, "libusb command transfer failed, status: 0x%02x", tr->status);
|
||||
ERROR_LOG_FMT(IOS_WIIMOTE, "libusb command transfer failed, status: {:#04x}", tr->status);
|
||||
if (!m_showed_failed_transfer.IsSet())
|
||||
{
|
||||
Core::DisplayMessage("Failed to send a command to the Bluetooth adapter.", 10000);
|
||||
@@ -625,7 +627,7 @@ void BluetoothReal::HandleBulkOrIntrTransfer(libusb_transfer* tr)
|
||||
if (tr->status != LIBUSB_TRANSFER_COMPLETED && tr->status != LIBUSB_TRANSFER_TIMED_OUT &&
|
||||
tr->status != LIBUSB_TRANSFER_NO_DEVICE)
|
||||
{
|
||||
ERROR_LOG(IOS_WIIMOTE, "libusb transfer failed, status: 0x%02x", tr->status);
|
||||
ERROR_LOG_FMT(IOS_WIIMOTE, "libusb transfer failed, status: {:#04x}", tr->status);
|
||||
if (!m_showed_failed_transfer.IsSet())
|
||||
{
|
||||
Core::DisplayMessage("Failed to transfer to or from to the Bluetooth adapter.", 10000);
|
||||
|
||||
@@ -12,8 +12,8 @@ namespace IOS::HLE::Device
|
||||
{
|
||||
IPCCommandResult BluetoothStub::Open(const OpenRequest& request)
|
||||
{
|
||||
PanicAlertT("Bluetooth passthrough mode is enabled, but Dolphin was built without libusb."
|
||||
" Passthrough mode cannot be used.");
|
||||
PanicAlertFmtT("Bluetooth passthrough mode is enabled, but Dolphin was built without libusb."
|
||||
" Passthrough mode cannot be used.");
|
||||
return GetDefaultReply(IPC_ENOENT);
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user