diff options
| author | TSRBerry <20988865+TSRBerry@users.noreply.github.com> | 2023-07-16 19:31:14 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-16 19:31:14 +0200 |
| commit | 326749498bed4360e5a4b11fc67d5ec7cb9a3076 (patch) | |
| tree | ae21fb26f99b401ca4e9efaab72b679a81c22369 /src/Ryujinx.HLE/HOS/Services/Sockets | |
| parent | fec8291c17fa106c28f58b56419e90d49a41a1ea (diff) | |
[Ryujinx.HLE] Address dotnet-format issues (#5380)
* dotnet format style --severity info
Some changes were manually reverted.
* dotnet format analyzers --serverity info
Some changes have been minimally adapted.
* Restore a few unused methods and variables
* Silence dotnet format IDE0060 warnings
* Silence dotnet format IDE0052 warnings
* Address or silence dotnet format IDE1006 warnings
* Address dotnet format CA1816 warnings
* Address or silence dotnet format CA2208 warnings
* Address or silence dotnet format CA1806 and a few CA1854 warnings
* Address dotnet format CA2211 warnings
* Address dotnet format CA1822 warnings
* Address or silence dotnet format CA1069 warnings
* Make dotnet format succeed in style mode
* Address or silence dotnet format CA2211 warnings
* Address review comments
* Address dotnet format CA2208 warnings properly
* Make ProcessResult readonly
* Address most dotnet format whitespace warnings
* Apply dotnet format whitespace formatting
A few of them have been manually reverted and the corresponding warning was silenced
* Add previously silenced warnings back
I have no clue how these disappeared
* Revert formatting changes for while and for-loops
* Format if-blocks correctly
* Run dotnet format style after rebase
* Run dotnet format whitespace after rebase
* Run dotnet format style after rebase
* Run dotnet format analyzers after rebase
* Run dotnet format after rebase and remove unused usings
- analyzers
- style
- whitespace
* Disable 'prefer switch expression' rule
* Add comments to disabled warnings
* Fix a few disabled warnings
* Fix naming rule violation, Convert shader properties to auto-property and convert values to const
* Simplify properties and array initialization, Use const when possible, Remove trailing commas
* Start working on disabled warnings
* Fix and silence a few dotnet-format warnings again
* Run dotnet format after rebase
* Use using declaration instead of block syntax
* Address IDE0251 warnings
* Address a few disabled IDE0060 warnings
* Silence IDE0060 in .editorconfig
* Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas"
This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e.
* dotnet format whitespace after rebase
* First dotnet format pass
* Fix naming rule violations
* Fix typo
* Add trailing commas, use targeted new and use array initializer
* Fix build issues
* Fix remaining build issues
* Remove SuppressMessage for CA1069 where possible
* Address dotnet format issues
* Address formatting issues
Co-authored-by: Ac_K <acoustik666@gmail.com>
* Add GetHashCode implementation for RenderingSurfaceInfo
* Explicitly silence CA1822 for every affected method in Syscall
* Address formatting issues in Demangler.cs
* Address review feedback
Co-authored-by: Ac_K <acoustik666@gmail.com>
* Revert marking service methods as static
* Next dotnet format pass
* Address review feedback
---------
Co-authored-by: Ac_K <acoustik666@gmail.com>
Diffstat (limited to 'src/Ryujinx.HLE/HOS/Services/Sockets')
38 files changed, 569 insertions, 524 deletions
diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/BsdContext.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/BsdContext.cs index b0ac6e68..254ad667 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/BsdContext.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/BsdContext.cs @@ -8,11 +8,11 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd { class BsdContext { - private static ConcurrentDictionary<ulong, BsdContext> _registry = new ConcurrentDictionary<ulong, BsdContext>(); + private static readonly ConcurrentDictionary<ulong, BsdContext> _registry = new(); private readonly object _lock = new(); - private List<IFileDescriptor> _fds; + private readonly List<IFileDescriptor> _fds; private BsdContext() { @@ -181,4 +181,4 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd return processContext; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs index b63864c9..d16e7536 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs @@ -7,7 +7,6 @@ using System; using System.Collections.Generic; using System.Net; using System.Net.Sockets; -using System.Numerics; using System.Runtime.CompilerServices; using System.Text; @@ -17,14 +16,14 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd [Service("bsd:u", false)] class IClient : IpcService { - private static readonly List<IPollManager> _pollManagers = new List<IPollManager> + private static readonly List<IPollManager> _pollManagers = new() { EventFileDescriptorPollManager.Instance, - ManagedSocketPollManager.Instance + ManagedSocketPollManager.Instance, }; private BsdContext _context; - private bool _isPrivileged; + private readonly bool _isPrivileged; public IClient(ServiceCtx context, bool isPrivileged) : base(context.Device.System.BsdServer) { @@ -46,19 +45,14 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd private static AddressFamily ConvertBsdAddressFamily(BsdAddressFamily family) { - switch (family) + return family switch { - case BsdAddressFamily.Unspecified: - return AddressFamily.Unspecified; - case BsdAddressFamily.InterNetwork: - return AddressFamily.InterNetwork; - case BsdAddressFamily.InterNetworkV6: - return AddressFamily.InterNetworkV6; - case BsdAddressFamily.Unknown: - return AddressFamily.Unknown; - default: - throw new NotImplementedException(family.ToString()); - } + BsdAddressFamily.Unspecified => AddressFamily.Unspecified, + BsdAddressFamily.InterNetwork => AddressFamily.InterNetwork, + BsdAddressFamily.InterNetworkV6 => AddressFamily.InterNetworkV6, + BsdAddressFamily.Unknown => AddressFamily.Unknown, + _ => throw new NotImplementedException(family.ToString()), + }; } private LinuxError SetResultErrno(IFileDescriptor socket, int result) @@ -68,9 +62,9 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd private ResultCode SocketInternal(ServiceCtx context, bool exempt) { - BsdAddressFamily domain = (BsdAddressFamily)context.RequestData.ReadInt32(); - BsdSocketType type = (BsdSocketType)context.RequestData.ReadInt32(); - ProtocolType protocol = (ProtocolType)context.RequestData.ReadInt32(); + BsdAddressFamily domain = (BsdAddressFamily)context.RequestData.ReadInt32(); + BsdSocketType type = (BsdSocketType)context.RequestData.ReadInt32(); + ProtocolType protocol = (ProtocolType)context.RequestData.ReadInt32(); BsdSocketCreationFlags creationFlags = (BsdSocketCreationFlags)((int)type >> (int)BsdSocketCreationFlags.FlagsShift); type &= BsdSocketType.TypeMask; @@ -101,8 +95,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd } } - ISocket newBsdSocket = new ManagedSocket(netDomain, (SocketType)type, protocol); - newBsdSocket.Blocking = !creationFlags.HasFlag(BsdSocketCreationFlags.NonBlocking); + ISocket newBsdSocket = new ManagedSocket(netDomain, (SocketType)type, protocol) + { + Blocking = !creationFlags.HasFlag(BsdSocketCreationFlags.NonBlocking), + }; LinuxError errno = LinuxError.SUCCESS; @@ -210,7 +206,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd public ResultCode Select(ServiceCtx context) { int fdsCount = context.RequestData.ReadInt32(); - int timeout = context.RequestData.ReadInt32(); + int timeout = context.RequestData.ReadInt32(); (ulong readFdsInBufferPosition, ulong readFdsInBufferSize) = context.Request.GetBufferType0x21(0); (ulong writeFdsInBufferPosition, ulong writeFdsInBufferSize) = context.Request.GetBufferType0x21(1); @@ -220,7 +216,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd (ulong writeFdsOutBufferPosition, ulong writeFdsOutBufferSize) = context.Request.GetBufferType0x22(1); (ulong errorFdsOutBufferPosition, ulong errorFdsOutBufferSize) = context.Request.GetBufferType0x22(2); - List<IFileDescriptor> readFds = _context.RetrieveFileDescriptorsFromMask(context.Memory.GetSpan(readFdsInBufferPosition, (int)readFdsInBufferSize)); + List<IFileDescriptor> readFds = _context.RetrieveFileDescriptorsFromMask(context.Memory.GetSpan(readFdsInBufferPosition, (int)readFdsInBufferSize)); List<IFileDescriptor> writeFds = _context.RetrieveFileDescriptorsFromMask(context.Memory.GetSpan(writeFdsInBufferPosition, (int)writeFdsInBufferSize)); List<IFileDescriptor> errorFds = _context.RetrieveFileDescriptorsFromMask(context.Memory.GetSpan(errorFdsInBufferPosition, (int)errorFdsInBufferSize)); @@ -312,7 +308,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd } } - using var readFdsOut = context.Memory.GetWritableRegion(readFdsOutBufferPosition, (int)readFdsOutBufferSize); + using var readFdsOut = context.Memory.GetWritableRegion(readFdsOutBufferPosition, (int)readFdsOutBufferSize); using var writeFdsOut = context.Memory.GetWritableRegion(writeFdsOutBufferPosition, (int)writeFdsOutBufferSize); using var errorFdsOut = context.Memory.GetWritableRegion(errorFdsOutBufferPosition, (int)errorFdsOutBufferSize); @@ -330,10 +326,12 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd public ResultCode Poll(ServiceCtx context) { int fdsCount = context.RequestData.ReadInt32(); - int timeout = context.RequestData.ReadInt32(); + int timeout = context.RequestData.ReadInt32(); (ulong inputBufferPosition, ulong inputBufferSize) = context.Request.GetBufferType0x21(); +#pragma warning disable IDE0059 // Remove unnecessary value assignment (ulong outputBufferPosition, ulong outputBufferSize) = context.Request.GetBufferType0x22(); +#pragma warning restore IDE0059 if (timeout < -1 || fdsCount < 0 || (ulong)(fdsCount * 8) > inputBufferSize) { @@ -356,7 +354,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd events[i] = new PollEvent(pollEventData, fileDescriptor); } - List<PollEvent> discoveredEvents = new List<PollEvent>(); + List<PollEvent> discoveredEvents = new(); List<PollEvent>[] eventsByPollManager = new List<PollEvent>[_pollManagers.Count]; for (int i = 0; i < eventsByPollManager.Length; i++) @@ -389,7 +387,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd if (fdsCount != 0) { - bool IsUnexpectedLinuxError(LinuxError error) + static bool IsUnexpectedLinuxError(LinuxError error) { return error != LinuxError.SUCCESS && error != LinuxError.ETIMEDOUT; } @@ -478,16 +476,16 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd // Recv(u32 socket, u32 flags) -> (i32 ret, u32 bsd_errno, array<i8, 0x22> message) public ResultCode Recv(ServiceCtx context) { - int socketFd = context.RequestData.ReadInt32(); + int socketFd = context.RequestData.ReadInt32(); BsdSocketFlags socketFlags = (BsdSocketFlags)context.RequestData.ReadInt32(); (ulong receivePosition, ulong receiveLength) = context.Request.GetBufferType0x22(); WritableRegion receiveRegion = context.Memory.GetWritableRegion(receivePosition, (int)receiveLength); - LinuxError errno = LinuxError.EBADF; - ISocket socket = _context.RetrieveSocket(socketFd); - int result = -1; + LinuxError errno = LinuxError.EBADF; + ISocket socket = _context.RetrieveSocket(socketFd); + int result = -1; if (socket != null) { @@ -508,17 +506,17 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd // RecvFrom(u32 sock, u32 flags) -> (i32 ret, u32 bsd_errno, u32 addrlen, buffer<i8, 0x22, 0> message, buffer<nn::socket::sockaddr_in, 0x22, 0x10>) public ResultCode RecvFrom(ServiceCtx context) { - int socketFd = context.RequestData.ReadInt32(); + int socketFd = context.RequestData.ReadInt32(); BsdSocketFlags socketFlags = (BsdSocketFlags)context.RequestData.ReadInt32(); - (ulong receivePosition, ulong receiveLength) = context.Request.GetBufferType0x22(0); + (ulong receivePosition, ulong receiveLength) = context.Request.GetBufferType0x22(0); (ulong sockAddrOutPosition, ulong sockAddrOutSize) = context.Request.GetBufferType0x22(1); WritableRegion receiveRegion = context.Memory.GetWritableRegion(receivePosition, (int)receiveLength); - LinuxError errno = LinuxError.EBADF; - ISocket socket = _context.RetrieveSocket(socketFd); - int result = -1; + LinuxError errno = LinuxError.EBADF; + ISocket socket = _context.RetrieveSocket(socketFd); + int result = -1; if (socket != null) { @@ -530,7 +528,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd receiveRegion.Dispose(); - if (sockAddrOutSize != 0 && sockAddrOutSize >= (ulong) Unsafe.SizeOf<BsdSockAddr>()) + if (sockAddrOutSize != 0 && sockAddrOutSize >= (ulong)Unsafe.SizeOf<BsdSockAddr>()) { context.Memory.Write(sockAddrOutPosition, BsdSockAddr.FromIPEndPoint(endPoint)); } @@ -548,16 +546,16 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd // Send(u32 socket, u32 flags, buffer<i8, 0x21, 0>) -> (i32 ret, u32 bsd_errno) public ResultCode Send(ServiceCtx context) { - int socketFd = context.RequestData.ReadInt32(); + int socketFd = context.RequestData.ReadInt32(); BsdSocketFlags socketFlags = (BsdSocketFlags)context.RequestData.ReadInt32(); (ulong sendPosition, ulong sendSize) = context.Request.GetBufferType0x21(); ReadOnlySpan<byte> sendBuffer = context.Memory.GetSpan(sendPosition, (int)sendSize); - LinuxError errno = LinuxError.EBADF; - ISocket socket = _context.RetrieveSocket(socketFd); - int result = -1; + LinuxError errno = LinuxError.EBADF; + ISocket socket = _context.RetrieveSocket(socketFd); + int result = -1; if (socket != null) { @@ -576,17 +574,19 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd // SendTo(u32 socket, u32 flags, buffer<i8, 0x21, 0>, buffer<nn::socket::sockaddr_in, 0x21, 0x10>) -> (i32 ret, u32 bsd_errno) public ResultCode SendTo(ServiceCtx context) { - int socketFd = context.RequestData.ReadInt32(); + int socketFd = context.RequestData.ReadInt32(); BsdSocketFlags socketFlags = (BsdSocketFlags)context.RequestData.ReadInt32(); - (ulong sendPosition, ulong sendSize) = context.Request.GetBufferType0x21(0); + (ulong sendPosition, ulong sendSize) = context.Request.GetBufferType0x21(0); +#pragma warning disable IDE0059 // Remove unnecessary value assignment (ulong bufferPosition, ulong bufferSize) = context.Request.GetBufferType0x21(1); +#pragma warning restore IDE0059 ReadOnlySpan<byte> sendBuffer = context.Memory.GetSpan(sendPosition, (int)sendSize); - LinuxError errno = LinuxError.EBADF; - ISocket socket = _context.RetrieveSocket(socketFd); - int result = -1; + LinuxError errno = LinuxError.EBADF; + ISocket socket = _context.RetrieveSocket(socketFd); + int result = -1; if (socket != null) { @@ -609,10 +609,12 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd { int socketFd = context.RequestData.ReadInt32(); +#pragma warning disable IDE0059 // Remove unnecessary value assignment (ulong bufferPos, ulong bufferSize) = context.Request.GetBufferType0x22(); +#pragma warning restore IDE0059 - LinuxError errno = LinuxError.EBADF; - ISocket socket = _context.RetrieveSocket(socketFd); + LinuxError errno = LinuxError.EBADF; + ISocket socket = _context.RetrieveSocket(socketFd); if (socket != null) { @@ -652,10 +654,12 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd { int socketFd = context.RequestData.ReadInt32(); +#pragma warning disable IDE0059 // Remove unnecessary value assignment (ulong bufferPosition, ulong bufferSize) = context.Request.GetBufferType0x21(); +#pragma warning restore IDE0059 - LinuxError errno = LinuxError.EBADF; - ISocket socket = _context.RetrieveSocket(socketFd); + LinuxError errno = LinuxError.EBADF; + ISocket socket = _context.RetrieveSocket(socketFd); if (socket != null) { @@ -673,10 +677,12 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd { int socketFd = context.RequestData.ReadInt32(); +#pragma warning disable IDE0059 // Remove unnecessary value assignment (ulong bufferPosition, ulong bufferSize) = context.Request.GetBufferType0x21(); +#pragma warning restore IDE0059 - LinuxError errno = LinuxError.EBADF; - ISocket socket = _context.RetrieveSocket(socketFd); + LinuxError errno = LinuxError.EBADF; + ISocket socket = _context.RetrieveSocket(socketFd); if (socket != null) { @@ -694,10 +700,12 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd { int socketFd = context.RequestData.ReadInt32(); +#pragma warning disable IDE0059 // Remove unnecessary value assignment (ulong bufferPosition, ulong bufferSize) = context.Request.GetBufferType0x22(); +#pragma warning restore IDE0059 - LinuxError errno = LinuxError.EBADF; - ISocket socket = _context.RetrieveSocket(socketFd); + LinuxError errno = LinuxError.EBADF; + ISocket socket = _context.RetrieveSocket(socketFd); if (socket != null) { errno = LinuxError.ENOTCONN; @@ -721,10 +729,12 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd { int socketFd = context.RequestData.ReadInt32(); +#pragma warning disable IDE0059 // Remove unnecessary value assignment (ulong bufferPos, ulong bufferSize) = context.Request.GetBufferType0x22(); +#pragma warning restore IDE0059 - LinuxError errno = LinuxError.EBADF; - ISocket socket = _context.RetrieveSocket(socketFd); + LinuxError errno = LinuxError.EBADF; + ISocket socket = _context.RetrieveSocket(socketFd); if (socket != null) { @@ -742,15 +752,15 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd // GetSockOpt(u32 socket, u32 level, u32 option_name) -> (i32 ret, u32 bsd_errno, u32, buffer<unknown, 0x22, 0>) public ResultCode GetSockOpt(ServiceCtx context) { - int socketFd = context.RequestData.ReadInt32(); - SocketOptionLevel level = (SocketOptionLevel)context.RequestData.ReadInt32(); - BsdSocketOption option = (BsdSocketOption)context.RequestData.ReadInt32(); + int socketFd = context.RequestData.ReadInt32(); + SocketOptionLevel level = (SocketOptionLevel)context.RequestData.ReadInt32(); + BsdSocketOption option = (BsdSocketOption)context.RequestData.ReadInt32(); (ulong bufferPosition, ulong bufferSize) = context.Request.GetBufferType0x22(); WritableRegion optionValue = context.Memory.GetWritableRegion(bufferPosition, (int)bufferSize); - LinuxError errno = LinuxError.EBADF; - ISocket socket = _context.RetrieveSocket(socketFd); + LinuxError errno = LinuxError.EBADF; + ISocket socket = _context.RetrieveSocket(socketFd); if (socket != null) { @@ -770,10 +780,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd public ResultCode Listen(ServiceCtx context) { int socketFd = context.RequestData.ReadInt32(); - int backlog = context.RequestData.ReadInt32(); + int backlog = context.RequestData.ReadInt32(); - LinuxError errno = LinuxError.EBADF; - ISocket socket = _context.RetrieveSocket(socketFd); + LinuxError errno = LinuxError.EBADF; + ISocket socket = _context.RetrieveSocket(socketFd); if (socket != null) { @@ -787,12 +797,14 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd // Ioctl(u32 fd, u32 request, u32 bufcount, buffer<unknown, 0x21, 0>, buffer<unknown, 0x21, 0>, buffer<unknown, 0x21, 0>, buffer<unknown, 0x21, 0>) -> (i32 ret, u32 bsd_errno, buffer<unknown, 0x22, 0>, buffer<unknown, 0x22, 0>, buffer<unknown, 0x22, 0>, buffer<unknown, 0x22, 0>) public ResultCode Ioctl(ServiceCtx context) { - int socketFd = context.RequestData.ReadInt32(); - BsdIoctl cmd = (BsdIoctl)context.RequestData.ReadInt32(); - int bufferCount = context.RequestData.ReadInt32(); + int socketFd = context.RequestData.ReadInt32(); + BsdIoctl cmd = (BsdIoctl)context.RequestData.ReadInt32(); +#pragma warning disable IDE0059 // Remove unnecessary value assignment + int bufferCount = context.RequestData.ReadInt32(); +#pragma warning restore IDE0059 - LinuxError errno = LinuxError.EBADF; - ISocket socket = _context.RetrieveSocket(socketFd); + LinuxError errno = LinuxError.EBADF; + ISocket socket = _context.RetrieveSocket(socketFd); if (socket != null) { @@ -801,7 +813,9 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd case BsdIoctl.AtMark: errno = LinuxError.SUCCESS; +#pragma warning disable IDE0059 // Remove unnecessary value assignment (ulong bufferPosition, ulong bufferSize) = context.Request.GetBufferType0x22(); +#pragma warning restore IDE0059 // FIXME: OOB not implemented. context.Memory.Write(bufferPosition, 0); @@ -823,12 +837,12 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd public ResultCode Fcntl(ServiceCtx context) { int socketFd = context.RequestData.ReadInt32(); - int cmd = context.RequestData.ReadInt32(); - int arg = context.RequestData.ReadInt32(); + int cmd = context.RequestData.ReadInt32(); + int arg = context.RequestData.ReadInt32(); - int result = 0; - LinuxError errno = LinuxError.EBADF; - ISocket socket = _context.RetrieveSocket(socketFd); + int result = 0; + LinuxError errno = LinuxError.EBADF; + ISocket socket = _context.RetrieveSocket(socketFd); if (socket != null) { @@ -856,16 +870,16 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd // SetSockOpt(u32 socket, u32 level, u32 option_name, buffer<unknown, 0x21, 0> option_value) -> (i32 ret, u32 bsd_errno) public ResultCode SetSockOpt(ServiceCtx context) { - int socketFd = context.RequestData.ReadInt32(); - SocketOptionLevel level = (SocketOptionLevel)context.RequestData.ReadInt32(); - BsdSocketOption option = (BsdSocketOption)context.RequestData.ReadInt32(); + int socketFd = context.RequestData.ReadInt32(); + SocketOptionLevel level = (SocketOptionLevel)context.RequestData.ReadInt32(); + BsdSocketOption option = (BsdSocketOption)context.RequestData.ReadInt32(); (ulong bufferPos, ulong bufferSize) = context.Request.GetBufferType0x21(); ReadOnlySpan<byte> optionValue = context.Memory.GetSpan(bufferPos, (int)bufferSize); - LinuxError errno = LinuxError.EBADF; - ISocket socket = _context.RetrieveSocket(socketFd); + LinuxError errno = LinuxError.EBADF; + ISocket socket = _context.RetrieveSocket(socketFd); if (socket != null) { @@ -880,10 +894,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd public ResultCode Shutdown(ServiceCtx context) { int socketFd = context.RequestData.ReadInt32(); - int how = context.RequestData.ReadInt32(); + int how = context.RequestData.ReadInt32(); - LinuxError errno = LinuxError.EBADF; - ISocket socket = _context.RetrieveSocket(socketFd); + LinuxError errno = LinuxError.EBADF; + ISocket socket = _context.RetrieveSocket(socketFd); if (socket != null) { @@ -924,9 +938,9 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd ReadOnlySpan<byte> sendBuffer = context.Memory.GetSpan(sendPosition, (int)sendSize); - LinuxError errno = LinuxError.EBADF; - IFileDescriptor file = _context.RetrieveFileDescriptor(fd); - int result = -1; + LinuxError errno = LinuxError.EBADF; + IFileDescriptor file = _context.RetrieveFileDescriptor(fd); + int result = -1; if (file != null) { @@ -951,9 +965,9 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd WritableRegion receiveRegion = context.Memory.GetWritableRegion(receivePosition, (int)receiveLength); - LinuxError errno = LinuxError.EBADF; - IFileDescriptor file = _context.RetrieveFileDescriptor(fd); - int result = -1; + LinuxError errno = LinuxError.EBADF; + IFileDescriptor file = _context.RetrieveFileDescriptor(fd); + int result = -1; if (file != null) { @@ -990,8 +1004,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd // DuplicateSocket(u32 fd, u64 reserved) -> (i32 ret, u32 bsd_errno) public ResultCode DuplicateSocket(ServiceCtx context) { - int fd = context.RequestData.ReadInt32(); + int fd = context.RequestData.ReadInt32(); +#pragma warning disable IDE0059 // Remove unnecessary value assignment ulong reserved = context.RequestData.ReadUInt64(); +#pragma warning restore IDE0059 LinuxError errno = LinuxError.ENOENT; int newSockFd = -1; @@ -1016,20 +1032,22 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd // RecvMMsg(u32 fd, u32 vlen, u32 flags, u32 reserved, nn::socket::TimeVal timeout) -> (i32 ret, u32 bsd_errno, buffer<bytes, 6> message); public ResultCode RecvMMsg(ServiceCtx context) { - int socketFd = context.RequestData.ReadInt32(); - int vlen = context.RequestData.ReadInt32(); + int socketFd = context.RequestData.ReadInt32(); + int vlen = context.RequestData.ReadInt32(); BsdSocketFlags socketFlags = (BsdSocketFlags)context.RequestData.ReadInt32(); - uint reserved = context.RequestData.ReadUInt32(); - TimeVal timeout = context.RequestData.ReadStruct<TimeVal>(); +#pragma warning disable IDE0059 // Remove unnecessary value assignment + uint reserved = context.RequestData.ReadUInt32(); +#pragma warning restore IDE0059 + TimeVal timeout = context.RequestData.ReadStruct<TimeVal>(); ulong receivePosition = context.Request.ReceiveBuff[0].Position; ulong receiveLength = context.Request.ReceiveBuff[0].Size; WritableRegion receiveRegion = context.Memory.GetWritableRegion(receivePosition, (int)receiveLength); - LinuxError errno = LinuxError.EBADF; - ISocket socket = _context.RetrieveSocket(socketFd); - int result = -1; + LinuxError errno = LinuxError.EBADF; + ISocket socket = _context.RetrieveSocket(socketFd); + int result = -1; if (socket != null) { @@ -1059,8 +1077,8 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd // SendMMsg(u32 fd, u32 vlen, u32 flags) -> (i32 ret, u32 bsd_errno, buffer<bytes, 6> message); public ResultCode SendMMsg(ServiceCtx context) { - int socketFd = context.RequestData.ReadInt32(); - int vlen = context.RequestData.ReadInt32(); + int socketFd = context.RequestData.ReadInt32(); + int vlen = context.RequestData.ReadInt32(); BsdSocketFlags socketFlags = (BsdSocketFlags)context.RequestData.ReadInt32(); ulong receivePosition = context.Request.ReceiveBuff[0].Position; @@ -1068,9 +1086,9 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd WritableRegion receiveRegion = context.Memory.GetWritableRegion(receivePosition, (int)receiveLength); - LinuxError errno = LinuxError.EBADF; - ISocket socket = _context.RetrieveSocket(socketFd); - int result = -1; + LinuxError errno = LinuxError.EBADF; + ISocket socket = _context.RetrieveSocket(socketFd); + int result = -1; if (socket != null) { @@ -1104,7 +1122,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd context.RequestData.BaseStream.Position += 4; // Padding ulong initialValue = context.RequestData.ReadUInt64(); - EventFileDescriptor newEventFile = new EventFileDescriptor(initialValue, flags); + EventFileDescriptor newEventFile = new(initialValue, flags); LinuxError errno = LinuxError.SUCCESS; @@ -1118,4 +1136,4 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd return WriteBsdResult(context, newSockFd, errno); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IFileDescriptor.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IFileDescriptor.cs index 9d4f81ce..dbeb9022 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IFileDescriptor.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IFileDescriptor.cs @@ -12,4 +12,4 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd LinuxError Write(out int writeSize, ReadOnlySpan<byte> buffer); } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/EventFileDescriptor.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/EventFileDescriptor.cs index d7b53158..937d2fd7 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/EventFileDescriptor.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/EventFileDescriptor.cs @@ -150,4 +150,4 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl } } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/EventFileDescriptorPollManager.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/EventFileDescriptorPollManager.cs index e0ab68c6..9039d49a 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/EventFileDescriptorPollManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/EventFileDescriptorPollManager.cs @@ -13,10 +13,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl { get { - if (_instance == null) - { - _instance = new EventFileDescriptorPollManager(); - } + _instance ??= new EventFileDescriptorPollManager(); return _instance; } @@ -31,7 +28,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl { updatedCount = 0; - List<ManualResetEvent> waiters = new List<ManualResetEvent>(); + List<ManualResetEvent> waiters = new(); for (int i = 0; i < events.Count; i++) { @@ -119,4 +116,4 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl return LinuxError.EOPNOTSUPP; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/ManagedSocket.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/ManagedSocket.cs index 75efc49a..dfc2a672 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/ManagedSocket.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/ManagedSocket.cs @@ -462,7 +462,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl if (!CanSupportMMsgHdr(message)) { - Logger.Warning?.Print(LogClass.ServiceBsd, $"Unsupported BsdMMsgHdr"); + Logger.Warning?.Print(LogClass.ServiceBsd, "Unsupported BsdMMsgHdr"); return LinuxError.EOPNOTSUPP; } @@ -500,7 +500,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl if (!CanSupportMMsgHdr(message)) { - Logger.Warning?.Print(LogClass.ServiceBsd, $"Unsupported BsdMMsgHdr"); + Logger.Warning?.Print(LogClass.ServiceBsd, "Unsupported BsdMMsgHdr"); return LinuxError.EOPNOTSUPP; } @@ -527,4 +527,4 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl } } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/ManagedSocketPollManager.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/ManagedSocketPollManager.cs index 1b305dfb..10d9882c 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/ManagedSocketPollManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/ManagedSocketPollManager.cs @@ -13,10 +13,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl { get { - if (_instance == null) - { - _instance = new ManagedSocketPollManager(); - } + _instance ??= new ManagedSocketPollManager(); return _instance; } @@ -29,9 +26,9 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl public LinuxError Poll(List<PollEvent> events, int timeoutMilliseconds, out int updatedCount) { - List<Socket> readEvents = new List<Socket>(); - List<Socket> writeEvents = new List<Socket>(); - List<Socket> errorEvents = new List<Socket>(); + List<Socket> readEvents = new(); + List<Socket> writeEvents = new(); + List<Socket> errorEvents = new(); updatedCount = 0; @@ -174,4 +171,4 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl return LinuxError.SUCCESS; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/WSAError.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/WSAError.cs index 0f24a57f..5f3495df 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/WSAError.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/WSAError.cs @@ -9,77 +9,77 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl * All Windows Sockets error constants are biased by WSABASEERR from * the "normal" */ - WSABASEERR = 10000, + WSABASEERR = 10000, /* * Windows Sockets definitions of regular Microsoft C error constants */ - WSAEINTR = (WSABASEERR + 4), - WSAEBADF = (WSABASEERR + 9), - WSAEACCES = (WSABASEERR + 13), - WSAEFAULT = (WSABASEERR + 14), - WSAEINVAL = (WSABASEERR + 22), - WSAEMFILE = (WSABASEERR + 24), + WSAEINTR = (WSABASEERR + 4), + WSAEBADF = (WSABASEERR + 9), + WSAEACCES = (WSABASEERR + 13), + WSAEFAULT = (WSABASEERR + 14), + WSAEINVAL = (WSABASEERR + 22), + WSAEMFILE = (WSABASEERR + 24), /* * Windows Sockets definitions of regular Berkeley error constants */ - WSAEWOULDBLOCK = (WSABASEERR + 35), - WSAEINPROGRESS = (WSABASEERR + 36), - WSAEALREADY = (WSABASEERR + 37), - WSAENOTSOCK = (WSABASEERR + 38), - WSAEDESTADDRREQ = (WSABASEERR + 39), - WSAEMSGSIZE = (WSABASEERR + 40), - WSAEPROTOTYPE = (WSABASEERR + 41), - WSAENOPROTOOPT = (WSABASEERR + 42), - WSAEPROTONOSUPPORT = (WSABASEERR + 43), - WSAESOCKTNOSUPPORT = (WSABASEERR + 44), - WSAEOPNOTSUPP = (WSABASEERR + 45), - WSAEPFNOSUPPORT = (WSABASEERR + 46), - WSAEAFNOSUPPORT = (WSABASEERR + 47), - WSAEADDRINUSE = (WSABASEERR + 48), - WSAEADDRNOTAVAIL = (WSABASEERR + 49), - WSAENETDOWN = (WSABASEERR + 50), - WSAENETUNREACH = (WSABASEERR + 51), - WSAENETRESET = (WSABASEERR + 52), - WSAECONNABORTED = (WSABASEERR + 53), - WSAECONNRESET = (WSABASEERR + 54), - WSAENOBUFS = (WSABASEERR + 55), - WSAEISCONN = (WSABASEERR + 56), - WSAENOTCONN = (WSABASEERR + 57), - WSAESHUTDOWN = (WSABASEERR + 58), - WSAETOOMANYREFS = (WSABASEERR + 59), - WSAETIMEDOUT = (WSABASEERR + 60), - WSAECONNREFUSED = (WSABASEERR + 61), - WSAELOOP = (WSABASEERR + 62), - WSAENAMETOOLONG = (WSABASEERR + 63), - WSAEHOSTDOWN = (WSABASEERR + 64), - WSAEHOSTUNREACH = (WSABASEERR + 65), - WSAENOTEMPTY = (WSABASEERR + 66), - WSAEPROCLIM = (WSABASEERR + 67), - WSAEUSERS = (WSABASEERR + 68), - WSAEDQUOT = (WSABASEERR + 69), - WSAESTALE = (WSABASEERR + 70), - WSAEREMOTE = (WSABASEERR + 71), + WSAEWOULDBLOCK = (WSABASEERR + 35), + WSAEINPROGRESS = (WSABASEERR + 36), + WSAEALREADY = (WSABASEERR + 37), + WSAENOTSOCK = (WSABASEERR + 38), + WSAEDESTADDRREQ = (WSABASEERR + 39), + WSAEMSGSIZE = (WSABASEERR + 40), + WSAEPROTOTYPE = (WSABASEERR + 41), + WSAENOPROTOOPT = (WSABASEERR + 42), + WSAEPROTONOSUPPORT = (WSABASEERR + 43), + WSAESOCKTNOSUPPORT = (WSABASEERR + 44), + WSAEOPNOTSUPP = (WSABASEERR + 45), + WSAEPFNOSUPPORT = (WSABASEERR + 46), + WSAEAFNOSUPPORT = (WSABASEERR + 47), + WSAEADDRINUSE = (WSABASEERR + 48), + WSAEADDRNOTAVAIL = (WSABASEERR + 49), + WSAENETDOWN = (WSABASEERR + 50), + WSAENETUNREACH = (WSABASEERR + 51), + WSAENETRESET = (WSABASEERR + 52), + WSAECONNABORTED = (WSABASEERR + 53), + WSAECONNRESET = (WSABASEERR + 54), + WSAENOBUFS = (WSABASEERR + 55), + WSAEISCONN = (WSABASEERR + 56), + WSAENOTCONN = (WSABASEERR + 57), + WSAESHUTDOWN = (WSABASEERR + 58), + WSAETOOMANYREFS = (WSABASEERR + 59), + WSAETIMEDOUT = (WSABASEERR + 60), + WSAECONNREFUSED = (WSABASEERR + 61), + WSAELOOP = (WSABASEERR + 62), + WSAENAMETOOLONG = (WSABASEERR + 63), + WSAEHOSTDOWN = (WSABASEERR + 64), + WSAEHOSTUNREACH = (WSABASEERR + 65), + WSAENOTEMPTY = (WSABASEERR + 66), + WSAEPROCLIM = (WSABASEERR + 67), + WSAEUSERS = (WSABASEERR + 68), + WSAEDQUOT = (WSABASEERR + 69), + WSAESTALE = (WSABASEERR + 70), + WSAEREMOTE = (WSABASEERR + 71), /* * Extended Windows Sockets error constant definitions */ - WSASYSNOTREADY = (WSABASEERR + 91), - WSAVERNOTSUPPORTED = (WSABASEERR + 92), - WSANOTINITIALISED = (WSABASEERR + 93), - WSAEDISCON = (WSABASEERR + 101), - WSAENOMORE = (WSABASEERR + 102), - WSAECANCELLED = (WSABASEERR + 103), - WSAEINVALIDPROCTABLE = (WSABASEERR + 104), - WSAEINVALIDPROVIDER = (WSABASEERR + 105), - WSAEPROVIDERFAILEDINIT = (WSABASEERR + 106), - WSASYSCALLFAILURE = (WSABASEERR + 107), - WSASERVICE_NOT_FOUND = (WSABASEERR + 108), - WSATYPE_NOT_FOUND = (WSABASEERR + 109), - WSA_E_NO_MORE = (WSABASEERR + 110), - WSA_E_CANCELLED = (WSABASEERR + 111), - WSAEREFUSED = (WSABASEERR + 112), + WSASYSNOTREADY = (WSABASEERR + 91), + WSAVERNOTSUPPORTED = (WSABASEERR + 92), + WSANOTINITIALISED = (WSABASEERR + 93), + WSAEDISCON = (WSABASEERR + 101), + WSAENOMORE = (WSABASEERR + 102), + WSAECANCELLED = (WSABASEERR + 103), + WSAEINVALIDPROCTABLE = (WSABASEERR + 104), + WSAEINVALIDPROVIDER = (WSABASEERR + 105), + WSAEPROVIDERFAILEDINIT = (WSABASEERR + 106), + WSASYSCALLFAILURE = (WSABASEERR + 107), + WSASERVICE_NOT_FOUND = (WSABASEERR + 108), + WSATYPE_NOT_FOUND = (WSABASEERR + 109), + WSA_E_NO_MORE = (WSABASEERR + 110), + WSA_E_CANCELLED = (WSABASEERR + 111), + WSAEREFUSED = (WSABASEERR + 112), /* * Error return codes from gethostbyname() and gethostbyaddr() @@ -93,42 +93,42 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl */ /* Authoritative Answer: Host not found */ - WSAHOST_NOT_FOUND = (WSABASEERR + 1001), + WSAHOST_NOT_FOUND = (WSABASEERR + 1001), /* Non-Authoritative: Host not found, or SERVERFAIL */ - WSATRY_AGAIN = (WSABASEERR + 1002), + WSATRY_AGAIN = (WSABASEERR + 1002), /* Non-recoverable errors, FORMERR, REFUSED, NOTIMP */ - WSANO_RECOVERY = (WSABASEERR + 1003), + WSANO_RECOVERY = (WSABASEERR + 1003), /* Valid name, no data record of requested type */ - WSANO_DATA = (WSABASEERR + 1004), + WSANO_DATA = (WSABASEERR + 1004), /* * Define QOS related error return codes * */ - WSA_QOS_RECEIVERS = (WSABASEERR + 1005), + WSA_QOS_RECEIVERS = (WSABASEERR + 1005), /* at least one Reserve has arrived */ - WSA_QOS_SENDERS = (WSABASEERR + 1006), + WSA_QOS_SENDERS = (WSABASEERR + 1006), /* at least one Path has arrived */ - WSA_QOS_NO_SENDERS = (WSABASEERR + 1007), + WSA_QOS_NO_SENDERS = (WSABASEERR + 1007), /* there are no senders */ - WSA_QOS_NO_RECEIVERS = (WSABASEERR + 1008), + WSA_QOS_NO_RECEIVERS = (WSABASEERR + 1008), /* there are no receivers */ - WSA_QOS_REQUEST_CONFIRMED = (WSABASEERR + 1009), + WSA_QOS_REQUEST_CONFIRMED = (WSABASEERR + 1009), /* Reserve has been confirmed */ - WSA_QOS_ADMISSION_FAILURE = (WSABASEERR + 1010), + WSA_QOS_ADMISSION_FAILURE = (WSABASEERR + 1010), /* error due to lack of resources */ - WSA_QOS_POLICY_FAILURE = (WSABASEERR + 1011), + WSA_QOS_POLICY_FAILURE = (WSABASEERR + 1011), /* rejected for administrative reasons - bad credentials */ - WSA_QOS_BAD_STYLE = (WSABASEERR + 1012), + WSA_QOS_BAD_STYLE = (WSABASEERR + 1012), /* unknown or conflicting style */ - WSA_QOS_BAD_OBJECT = (WSABASEERR + 1013), + WSA_QOS_BAD_OBJECT = (WSABASEERR + 1013), /* problem with some part of the filterspec or providerspecific * buffer in general */ WSA_QOS_TRAFFIC_CTRL_ERROR = (WSABASEERR + 1014), /* problem with some part of the flowspec */ - WSA_QOS_GENERIC_ERROR = (WSABASEERR + 1015) + WSA_QOS_GENERIC_ERROR = (WSABASEERR + 1015), } } diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/WinSockHelper.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/WinSockHelper.cs index 5668d30b..9df18023 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/WinSockHelper.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/WinSockHelper.cs @@ -1,5 +1,5 @@ using Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types; -using System; +using System; using System.Collections.Generic; using System.Net.Sockets; @@ -88,7 +88,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl // WSAEFAULT { WsaError.WSAEFAULT, LinuxError.EFAULT }, // NOERROR - { 0, 0 } + { 0, 0 }, }; private static readonly Dictionary<int, LinuxError> _errorMapMacOs = new() @@ -136,7 +136,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl { 59, LinuxError.ETOOMANYREFS }, { 92, LinuxError.EILSEQ }, { 89, LinuxError.ECANCELED }, - { 84, LinuxError.EOVERFLOW } + { 84, LinuxError.EOVERFLOW }, }; private static readonly Dictionary<BsdSocketOption, SocketOptionName> _soSocketOptionMap = new() @@ -157,7 +157,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl { BsdSocketOption.SoSndTimeo, SocketOptionName.SendTimeout }, { BsdSocketOption.SoRcvTimeo, SocketOptionName.ReceiveTimeout }, { BsdSocketOption.SoError, SocketOptionName.Error }, - { BsdSocketOption.SoType, SocketOptionName.Type } + { BsdSocketOption.SoType, SocketOptionName.Type }, }; private static readonly Dictionary<BsdSocketOption, SocketOptionName> _ipSocketOptionMap = new() @@ -172,7 +172,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl { BsdSocketOption.IpDropMembership, SocketOptionName.DropMembership }, { BsdSocketOption.IpDontFrag, SocketOptionName.DontFragment }, { BsdSocketOption.IpAddSourceMembership, SocketOptionName.AddSourceMembership }, - { BsdSocketOption.IpDropSourceMembership, SocketOptionName.DropSourceMembership } + { BsdSocketOption.IpDropSourceMembership, SocketOptionName.DropSourceMembership }, }; private static readonly Dictionary<BsdSocketOption, SocketOptionName> _tcpSocketOptionMap = new() @@ -180,7 +180,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl { BsdSocketOption.TcpNoDelay, SocketOptionName.NoDelay }, { BsdSocketOption.TcpKeepIdle, SocketOptionName.TcpKeepAliveTime }, { BsdSocketOption.TcpKeepIntvl, SocketOptionName.TcpKeepAliveInterval }, - { BsdSocketOption.TcpKeepCnt, SocketOptionName.TcpKeepAliveRetryCount } + { BsdSocketOption.TcpKeepCnt, SocketOptionName.TcpKeepAliveRetryCount }, }; public static LinuxError ConvertError(WsaError errorCode) @@ -210,7 +210,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl SocketOptionLevel.Socket => _soSocketOptionMap, SocketOptionLevel.IP => _ipSocketOptionMap, SocketOptionLevel.Tcp => _tcpSocketOptionMap, - _ => null + _ => null, }; if (table == null) @@ -222,4 +222,4 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl return table.TryGetValue(option, out name); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/ServerInterface.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/ServerInterface.cs index 798fc015..9afdf250 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/ServerInterface.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/ServerInterface.cs @@ -5,4 +5,4 @@ { public ServerInterface(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdAddressFamily.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdAddressFamily.cs index 37461bb2..74794638 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdAddressFamily.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdAddressFamily.cs @@ -6,6 +6,6 @@ InterNetwork = 2, InterNetworkV6 = 28, - Unknown = uint.MaxValue + Unknown = uint.MaxValue, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdIoctl.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdIoctl.cs index 1dfa5a5f..9c330e35 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdIoctl.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdIoctl.cs @@ -2,6 +2,6 @@ { enum BsdIoctl { - AtMark = 0x40047307 + AtMark = 0x40047307, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSockAddr.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSockAddr.cs index 67c11e54..af3a44e8 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSockAddr.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSockAddr.cs @@ -16,7 +16,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types public IPEndPoint ToIPEndPoint() { - IPAddress address = new IPAddress(Address.AsSpan()); + IPAddress address = new(Address.AsSpan()); int port = (ushort)IPAddress.NetworkToHostOrder((short)Port); return new IPEndPoint(address, port); @@ -24,11 +24,11 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types public static BsdSockAddr FromIPEndPoint(IPEndPoint endpoint) { - BsdSockAddr result = new BsdSockAddr + BsdSockAddr result = new() { Length = 0, Family = (byte)endpoint.AddressFamily, - Port = (ushort)IPAddress.HostToNetworkOrder((short)endpoint.Port) + Port = (ushort)IPAddress.HostToNetworkOrder((short)endpoint.Port), }; endpoint.Address.GetAddressBytes().AsSpan().CopyTo(result.Address.AsSpan()); diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketCreationFlags.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketCreationFlags.cs index be5991ff..ac79deb3 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketCreationFlags.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketCreationFlags.cs @@ -9,6 +9,6 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types CloseOnExecution = 1, NonBlocking = 2, - FlagsShift = 28 + FlagsShift = 28, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketFlags.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketFlags.cs index 4408c89a..63998129 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketFlags.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketFlags.cs @@ -17,6 +17,6 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types Compat = 0x8000, SoCallbck = 0x10000, NoSignal = 0x20000, - CMsgCloExec = 0x40000 + CMsgCloExec = 0x40000, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketOption.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketOption.cs index 4d0d1dcf..5bc3e81f 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketOption.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketOption.cs @@ -1,5 +1,8 @@ +using System.Diagnostics.CodeAnalysis; + namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types { + [SuppressMessage("Design", "CA1069: Enums values should not be duplicated")] enum BsdSocketOption { SoDebug = 0x1, @@ -114,6 +117,6 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types TcpKeepInit = 128, TcpKeepIdle = 256, TcpKeepIntvl = 512, - TcpKeepCnt = 1024 + TcpKeepCnt = 1024, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketShutdownFlags.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketShutdownFlags.cs index 13230ac3..883e3c31 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketShutdownFlags.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketShutdownFlags.cs @@ -4,6 +4,6 @@ { Receive, Send, - ReceiveAndSend + ReceiveAndSend, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/EventFdFlags.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/EventFdFlags.cs index e01d8226..996facd3 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/EventFdFlags.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/EventFdFlags.cs @@ -7,6 +7,6 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types { None = 0, Semaphore = 1 << 0, - NonBlocking = 1 << 2 + NonBlocking = 1 << 2, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/IPollManager.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/IPollManager.cs index d3663878..66b1bcf1 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/IPollManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/IPollManager.cs @@ -10,4 +10,4 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types LinuxError Select(List<PollEvent> events, int timeout, out int updatedCount); } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/LinuxError.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/LinuxError.cs index 96602830..aaeee44d 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/LinuxError.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/LinuxError.cs @@ -5,44 +5,44 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types [SuppressMessage("ReSharper", "InconsistentNaming")] enum LinuxError { - SUCCESS = 0, - EPERM = 1 /* Operation not permitted */, - ENOENT = 2 /* No such file or directory */, - ESRCH = 3 /* No such process */, - EINTR = 4 /* Interrupted system call */, - EIO = 5 /* I/O error */, - ENXIO = 6 /* No such device or address */, - E2BIG = 7 /* Argument list too long */, - ENOEXEC = 8 /* Exec format error */, - EBADF = 9 /* Bad file number */, - ECHILD = 10 /* No child processes */, - EAGAIN = 11 /* Try again */, - ENOMEM = 12 /* Out of memory */, - EACCES = 13 /* Permission denied */, - EFAULT = 14 /* Bad address */, - ENOTBLK = 15 /* Block device required */, - EBUSY = 16 /* Device or resource busy */, - EEXIST = 17 /* File exists */, - EXDEV = 18 /* Cross-device link */, - ENODEV = 19 /* No such device */, - ENOTDIR = 20 /* Not a directory */, - EISDIR = 21 /* Is a directory */, - EINVAL = 22 /* Invalid argument */, - ENFILE = 23 /* File table overflow */, - EMFILE = 24 /* Too many open files */, - ENOTTY = 25 /* Not a typewriter */, - ETXTBSY = 26 /* Text file busy */, - EFBIG = 27 /* File too large */, - ENOSPC = 28 /* No space left on device */, - ESPIPE = 29 /* Illegal seek */, - EROFS = 30 /* Read-only file system */, - EMLINK = 31 /* Too many links */, - EPIPE = 32 /* Broken pipe */, - EDOM = 33 /* Math argument out of domain of func */, - ERANGE = 34 /* Math result not representable */, - EDEADLK = 35 /* Resource deadlock would occur */, - ENAMETOOLONG = 36 /* File name too long */, - ENOLCK = 37 /* No record locks available */, + SUCCESS = 0, + EPERM = 1 /* Operation not permitted */, + ENOENT = 2 /* No such file or directory */, + ESRCH = 3 /* No such process */, + EINTR = 4 /* Interrupted system call */, + EIO = 5 /* I/O error */, + ENXIO = 6 /* No such device or address */, + E2BIG = 7 /* Argument list too long */, + ENOEXEC = 8 /* Exec format error */, + EBADF = 9 /* Bad file number */, + ECHILD = 10 /* No child processes */, + EAGAIN = 11 /* Try again */, + ENOMEM = 12 /* Out of memory */, + EACCES = 13 /* Permission denied */, + EFAULT = 14 /* Bad address */, + ENOTBLK = 15 /* Block device required */, + EBUSY = 16 /* Device or resource busy */, + EEXIST = 17 /* File exists */, + EXDEV = 18 /* Cross-device link */, + ENODEV = 19 /* No such device */, + ENOTDIR = 20 /* Not a directory */, + EISDIR = 21 /* Is a directory */, + EINVAL = 22 /* Invalid argument */, + ENFILE = 23 /* File table overflow */, + EMFILE = 24 /* Too many open files */, + ENOTTY = 25 /* Not a typewriter */, + ETXTBSY = 26 /* Text file busy */, + EFBIG = 27 /* File too large */, + ENOSPC = 28 /* No space left on device */, + ESPIPE = 29 /* Illegal seek */, + EROFS = 30 /* Read-only file system */, + EMLINK = 31 /* Too many links */, + EPIPE = 32 /* Broken pipe */, + EDOM = 33 /* Math argument out of domain of func */, + ERANGE = 34 /* Math result not representable */, + EDEADLK = 35 /* Resource deadlock would occur */, + ENAMETOOLONG = 36 /* File name too long */, + ENOLCK = 37 /* No record locks available */, /* * This error code is special: arch syscall entry code will return @@ -51,105 +51,105 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types * failures due to attempts to use a nonexistent syscall, syscall * implementations should refrain from returning -ENOSYS. */ - ENOSYS = 38 /* Invalid system call number */, - ENOTEMPTY = 39 /* Directory not empty */, - ELOOP = 40 /* Too many symbolic links encountered */, - EWOULDBLOCK = EAGAIN /* Operation would block */, - ENOMSG = 42 /* No message of desired type */, - EIDRM = 43 /* Identifier removed */, - ECHRNG = 44 /* Channel number out of range */, - EL2NSYNC = 45 /* Level 2 not synchronized */, - EL3HLT = 46 /* Level 3 halted */, - EL3RST = 47 /* Level 3 reset */, - ELNRNG = 48 /* Link number out of range */, - EUNATCH = 49 /* Protocol driver not attached */, - ENOCSI = 50 /* No CSI structure available */, - EL2HLT = 51 /* Level 2 halted */, - EBADE = 52 /* Invalid exchange */, - EBADR = 53 /* Invalid request descriptor */, - EXFULL = 54 /* Exchange full */, - ENOANO = 55 /* No anode */, - EBADRQC = 56 /* Invalid request code */, - EBADSLT = 57 /* Invalid slot */, - EDEADLOCK = EDEADLK, - EBFONT = 59 /* Bad font file format */, - ENOSTR = 60 /* Device not a stream */, - ENODATA = 61 /* No data available */, - ETIME = 62 /* Timer expired */, - ENOSR = 63 /* Out of streams resources */, - ENONET = 64 /* Machine is not on the network */, - ENOPKG = 65 /* Package not installed */, - EREMOTE = 66 /* Object is remote */, - ENOLINK = 67 /* Link has been severed */, - EADV = 68 /* Advertise error */, - ESRMNT = 69 /* Srmount error */, - ECOMM = 70 /* Communication error on send */, - EPROTO = 71 /* Protocol error */, - EMULTIHOP = 72 /* Multihop attempted */, - EDOTDOT = 73 /* RFS specific error */, - EBADMSG = 74 /* Not a data message */, - EOVERFLOW = 75 /* Value too large for defined data type */, - ENOTUNIQ = 76 /* Name not unique on network */, - EBADFD = 77 /* File descriptor in bad state */, - EREMCHG = 78 /* Remote address changed */, - ELIBACC = 79 /* Can not access a needed shared library */, - ELIBBAD = 80 /* Accessing a corrupted shared library */, - ELIBSCN = 81 /* .lib section in a.out corrupted */, - ELIBMAX = 82 /* Attempting to link in too many shared libraries */, - ELIBEXEC = 83 /* Cannot exec a shared library directly */, - EILSEQ = 84 /* Illegal byte sequence */, - ERESTART = 85 /* Interrupted system call should be restarted */, - ESTRPIPE = 86 /* Streams pipe error */, - EUSERS = 87 /* Too many users */, - ENOTSOCK = 88 /* Socket operation on non-socket */, - EDESTADDRREQ = 89 /* Destination address required */, - EMSGSIZE = 90 /* Message too long */, - EPROTOTYPE = 91 /* Protocol wrong type for socket */, - ENOPROTOOPT = 92 /* Protocol not available */, + ENOSYS = 38 /* Invalid system call number */, + ENOTEMPTY = 39 /* Directory not empty */, + ELOOP = 40 /* Too many symbolic links encountered */, + EWOULDBLOCK = EAGAIN /* Operation would block */, + ENOMSG = 42 /* No message of desired type */, + EIDRM = 43 /* Identifier removed */, + ECHRNG = 44 /* Channel number out of range */, + EL2NSYNC = 45 /* Level 2 not synchronized */, + EL3HLT = 46 /* Level 3 halted */, + EL3RST = 47 /* Level 3 reset */, + ELNRNG = 48 /* Link number out of range */, + EUNATCH = 49 /* Protocol driver not attached */, + ENOCSI = 50 /* No CSI structure available */, + EL2HLT = 51 /* Level 2 halted */, + EBADE = 52 /* Invalid exchange */, + EBADR = 53 /* Invalid request descriptor */, + EXFULL = 54 /* Exchange full */, + ENOANO = 55 /* No anode */, + EBADRQC = 56 /* Invalid request code */, + EBADSLT = 57 /* Invalid slot */, + EDEADLOCK = EDEADLK, + EBFONT = 59 /* Bad font file format */, + ENOSTR = 60 /* Device not a stream */, + ENODATA = 61 /* No data available */, + ETIME = 62 /* Timer expired */, + ENOSR = 63 /* Out of streams resources */, + ENONET = 64 /* Machine is not on the network */, + ENOPKG = 65 /* Package not installed */, + EREMOTE = 66 /* Object is remote */, + ENOLINK = 67 /* Link has been severed */, + EADV = 68 /* Advertise error */, + ESRMNT = 69 /* Srmount error */, + ECOMM = 70 /* Communication error on send */, + EPROTO = 71 /* Protocol error */, + EMULTIHOP = 72 /* Multihop attempted */, + EDOTDOT = 73 /* RFS specific error */, + EBADMSG = 74 /* Not a data message */, + EOVERFLOW = 75 /* Value too large for defined data type */, + ENOTUNIQ = 76 /* Name not unique on network */, + EBADFD = 77 /* File descriptor in bad state */, + EREMCHG = 78 /* Remote address changed */, + ELIBACC = 79 /* Can not access a needed shared library */, + ELIBBAD = 80 /* Accessing a corrupted shared library */, + ELIBSCN = 81 /* .lib section in a.out corrupted */, + ELIBMAX = 82 /* Attempting to link in too many shared libraries */, + ELIBEXEC = 83 /* Cannot exec a shared library directly */, + EILSEQ = 84 /* Illegal byte sequence */, + ERESTART = 85 /* Interrupted system call should be restarted */, + ESTRPIPE = 86 /* Streams pipe error */, + EUSERS = 87 /* Too many users */, + ENOTSOCK = 88 /* Socket operation on non-socket */, + EDESTADDRREQ = 89 /* Destination address required */, + EMSGSIZE = 90 /* Message too long */, + EPROTOTYPE = 91 /* Protocol wrong type for socket */, + ENOPROTOOPT = 92 /* Protocol not available */, EPROTONOSUPPORT = 93 /* Protocol not supported */, ESOCKTNOSUPPORT = 94 /* Socket type not supported */, - EOPNOTSUPP = 95 /* Operation not supported on transport endpoint */, - EPFNOSUPPORT = 96 /* Protocol family not supported */, - EAFNOSUPPORT = 97 /* Address family not supported by protocol */, - EADDRINUSE = 98 /* Address already in use */, - EADDRNOTAVAIL = 99 /* Cannot assign requested address */, - ENETDOWN = 100 /* Network is down */, - ENETUNREACH = 101 /* Network is unreachable */, - ENETRESET = 102 /* Network dropped connection because of reset */, - ECONNABORTED = 103 /* Software caused connection abort */, - ECONNRESET = 104 /* Connection reset by peer */, - ENOBUFS = 105 /* No buffer space available */, - EISCONN = 106 /* Transport endpoint is already connected */, - ENOTCONN = 107 /* Transport endpoint is not connected */, - ESHUTDOWN = 108 /* Cannot send after transport endpoint shutdown */, - ETOOMANYREFS = 109 /* Too many references: cannot splice */, - ETIMEDOUT = 110 /* Connection timed out */, - ECONNREFUSED = 111 /* Connection refused */, - EHOSTDOWN = 112 /* Host is down */, - EHOSTUNREACH = 113 /* No route to host */, - EALREADY = 114 /* Operation already in progress */, - EINPROGRESS = 115 /* Operation now in progress */, - ESTALE = 116 /* Stale file handle */, - EUCLEAN = 117 /* Structure needs cleaning */, - ENOTNAM = 118 /* Not a XENIX named type file */, - ENAVAIL = 119 /* No XENIX semaphores available */, - EISNAM = 120 /* Is a named type file */, - EREMOTEIO = 121 /* Remote I/O error */, - EDQUOT = 122 /* Quota exceeded */, - ENOMEDIUM = 123 /* No medium found */, - EMEDIUMTYPE = 124 /* Wrong medium type */, - ECANCELED = 125 /* Operation Canceled */, - ENOKEY = 126 /* Required key not available */, - EKEYEXPIRED = 127 /* Key has expired */, - EKEYREVOKED = 128 /* Key has been revoked */, - EKEYREJECTED = 129 /* Key was rejected by service */, + EOPNOTSUPP = 95 /* Operation not supported on transport endpoint */, + EPFNOSUPPORT = 96 /* Protocol family not supported */, + EAFNOSUPPORT = 97 /* Address family not supported by protocol */, + EADDRINUSE = 98 /* Address already in use */, + EADDRNOTAVAIL = 99 /* Cannot assign requested address */, + ENETDOWN = 100 /* Network is down */, + ENETUNREACH = 101 /* Network is unreachable */, + ENETRESET = 102 /* Network dropped connection because of reset */, + ECONNABORTED = 103 /* Software caused connection abort */, + ECONNRESET = 104 /* Connection reset by peer */, + ENOBUFS = 105 /* No buffer space available */, + EISCONN = 106 /* Transport endpoint is already connected */, + ENOTCONN = 107 /* Transport endpoint is not connected */, + ESHUTDOWN = 108 /* Cannot send after transport endpoint shutdown */, + ETOOMANYREFS = 109 /* Too many references: cannot splice */, + ETIMEDOUT = 110 /* Connection timed out */, + ECONNREFUSED = 111 /* Connection refused */, + EHOSTDOWN = 112 /* Host is down */, + EHOSTUNREACH = 113 /* No route to host */, + EALREADY = 114 /* Operation already in progress */, + EINPROGRESS = 115 /* Operation now in progress */, + ESTALE = 116 /* Stale file handle */, + EUCLEAN = 117 /* Structure needs cleaning */, + ENOTNAM = 118 /* Not a XENIX named type file */, + ENAVAIL = 119 /* No XENIX semaphores available */, + EISNAM = 120 /* Is a named type file */, + EREMOTEIO = 121 /* Remote I/O error */, + EDQUOT = 122 /* Quota exceeded */, + ENOMEDIUM = 123 /* No medium found */, + EMEDIUMTYPE = 124 /* Wrong medium type */, + ECANCELED = 125 /* Operation Canceled */, + ENOKEY = 126 /* Required key not available */, + EKEYEXPIRED = 127 /* Key has expired */, + EKEYREVOKED = 128 /* Key has been revoked */, + EKEYREJECTED = 129 /* Key was rejected by service */, /* for robust mutexes */ - EOWNERDEAD = 130 /* Owner died */, + EOWNERDEAD = 130 /* Owner died */, ENOTRECOVERABLE = 131 /* State not recoverable */, - ERFKILL = 132 /* Operation not possible due to RF-kill */, + ERFKILL = 132 /* Operation not possible due to RF-kill */, - EHWPOISON = 133 /* Memory page has hardware error */ + EHWPOISON = 133, /* Memory page has hardware error */ } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/PollEvent.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/PollEvent.cs index 8b77a6c2..27a96bd8 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/PollEvent.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/PollEvent.cs @@ -11,4 +11,4 @@ FileDescriptor = fileDescriptor; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/PollEventData.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/PollEventData.cs index 546b738e..16d01055 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/PollEventData.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/PollEventData.cs @@ -2,10 +2,10 @@ { struct PollEventData { -#pragma warning disable CS0649 +#pragma warning disable CS0649 // Field is never assigned to public int SocketFd; public PollEventTypeMask InputEvents; #pragma warning restore CS0649 public PollEventTypeMask OutputEvents; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/PollEventTypeMask.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/PollEventTypeMask.cs index f434fa03..d4c96c81 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/PollEventTypeMask.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/PollEventTypeMask.cs @@ -10,6 +10,6 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types Output = 4, Error = 8, Disconnected = 0x10, - Invalid = 0x20 + Invalid = 0x20, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Ethc/IEthInterface.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Ethc/IEthInterface.cs index f5877697..1c216ea5 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Ethc/IEthInterface.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Ethc/IEthInterface.cs @@ -5,4 +5,4 @@ { public IEthInterface(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Ethc/IEthInterfaceGroup.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Ethc/IEthInterfaceGroup.cs index 9832e448..3147a892 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Ethc/IEthInterfaceGroup.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Ethc/IEthInterfaceGroup.cs @@ -5,4 +5,4 @@ { public IEthInterfaceGroup(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/IManager.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/IManager.cs index 0b7adff4..c991db3f 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/IManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/IManager.cs @@ -14,9 +14,11 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd class IManager : IpcService { public static readonly NsdSettings NsdSettings; +#pragma warning disable IDE0052 // Remove unread private member private readonly FqdnResolver _fqdnResolver; +#pragma warning restore IDE0052 - private bool _isInitialized = false; + private readonly bool _isInitialized = false; public IManager(ServiceCtx context) { @@ -43,7 +45,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd { Initialized = true, TestMode = (bool)testMode, - Environment = (string)environmentIdentifier + Environment = (string)environmentIdentifier, }; } @@ -158,7 +160,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd public ResultCode Resolve(ServiceCtx context) { ulong outputPosition = context.Request.ReceiveBuff[0].Position; - ulong outputSize = context.Request.ReceiveBuff[0].Size; + ulong outputSize = context.Request.ReceiveBuff[0].Size; ResultCode result = _fqdnResolver.ResolveEx(context, out _, out string resolvedAddress); @@ -181,7 +183,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd public ResultCode ResolveEx(ServiceCtx context) { ulong outputPosition = context.Request.ReceiveBuff[0].Position; - ulong outputSize = context.Request.ReceiveBuff[0].Size; + ulong outputSize = context.Request.ReceiveBuff[0].Size; ResultCode result = _fqdnResolver.ResolveEx(context, out ResultCode errorCode, out string resolvedAddress); @@ -377,7 +379,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd "sd" => (byte)ApplicationServerEnvironmentType.Sd, "sp" => (byte)ApplicationServerEnvironmentType.Sp, "dp" => (byte)ApplicationServerEnvironmentType.Dp, - _ => (byte)ApplicationServerEnvironmentType.None + _ => (byte)ApplicationServerEnvironmentType.None, }; context.ResponseData.Write(environmentType); @@ -399,4 +401,4 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd throw new ServiceNotImplementedException(this, context); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/Manager/FqdnResolver.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/Manager/FqdnResolver.cs index 4096e431..a8fbcf09 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/Manager/FqdnResolver.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/Manager/FqdnResolver.cs @@ -4,7 +4,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd.Manager { class FqdnResolver { - private const string _dummyAddress = "unknown.dummy.nintendo.net"; + private const string DummyAddress = "unknown.dummy.nintendo.net"; public ResultCode GetEnvironmentIdentifier(out string identifier) { @@ -24,8 +24,8 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd.Manager public static ResultCode Resolve(string address, out string resolvedAddress) { - if (address == "api.sect.srv.nintendo.net" || - address == "ctest.cdn.nintendo.net" || + if (address == "api.sect.srv.nintendo.net" || + address == "ctest.cdn.nintendo.net" || address == "ctest.cdn.n.nintendoswitch.cn" || address == "unknown.dummy.nintendo.net") { @@ -50,6 +50,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd.Manager resolvedAddress = address switch { +#pragma warning disable IDE0055 // Disable formatting "e97b8a9d672e4ce4845ec6947cd66ef6-sb-api.accounts.nintendo.com" => "e97b8a9d672e4ce4845ec6947cd66ef6-sb.baas.nintendo.com", // dp1 environment "api.accounts.nintendo.com" => "e0d67c509fb203858ebcb2fe3f88c2aa.baas.nintendo.com", // dp1 environment "e97b8a9d672e4ce4845ec6947cd66ef6-sb.accounts.nintendo.com" => "e97b8a9d672e4ce4845ec6947cd66ef6-sb.baas.nintendo.com", // lp1 environment @@ -60,6 +61,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd.Manager this + 0x2BE8 => this + 0x2BE8 + 0x300 */ _ => address, +#pragma warning restore IDE0055 }; } @@ -69,7 +71,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd.Manager public ResultCode ResolveEx(ServiceCtx context, out ResultCode resultCode, out string resolvedAddress) { ulong inputPosition = context.Request.SendBuff[0].Position; - ulong inputSize = context.Request.SendBuff[0].Size; + ulong inputSize = context.Request.SendBuff[0].Size; byte[] addressBuffer = new byte[inputSize]; @@ -81,7 +83,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd.Manager if (resultCode != ResultCode.Success) { - resolvedAddress = _dummyAddress; + resolvedAddress = DummyAddress; } if (IManager.NsdSettings.TestMode) @@ -94,4 +96,4 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd.Manager } } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/ResultCode.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/ResultCode.cs index 993fbe8a..5a62922f 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/ResultCode.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/ResultCode.cs @@ -2,18 +2,18 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd { enum ResultCode { - ModuleId = 141, + ModuleId = 141, ErrorCodeShift = 9, Success = 0, - InvalidSettingsValue = ( 1 << ErrorCodeShift) | ModuleId, - InvalidObject1 = ( 3 << ErrorCodeShift) | ModuleId, - InvalidObject2 = ( 4 << ErrorCodeShift) | ModuleId, - NullOutputObject = ( 5 << ErrorCodeShift) | ModuleId, - SettingsNotLoaded = ( 6 << ErrorCodeShift) | ModuleId, - InvalidArgument = ( 8 << ErrorCodeShift) | ModuleId, - SettingsNotInitialized = ( 10 << ErrorCodeShift) | ModuleId, - ServiceNotInitialized = (400 << ErrorCodeShift) | ModuleId, + InvalidSettingsValue = (1 << ErrorCodeShift) | ModuleId, + InvalidObject1 = (3 << ErrorCodeShift) | ModuleId, + InvalidObject2 = (4 << ErrorCodeShift) | ModuleId, + NullOutputObject = (5 << ErrorCodeShift) | ModuleId, + SettingsNotLoaded = (6 << ErrorCodeShift) | ModuleId, + InvalidArgument = (8 << ErrorCodeShift) | ModuleId, + SettingsNotInitialized = (10 << ErrorCodeShift) | ModuleId, + ServiceNotInitialized = (400 << ErrorCodeShift) | ModuleId, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/Types/ApplicationServerEnvironmentType.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/Types/ApplicationServerEnvironmentType.cs index 150bdab4..1acb69fc 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/Types/ApplicationServerEnvironmentType.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/Types/ApplicationServerEnvironmentType.cs @@ -6,6 +6,6 @@ Lp, Sd, Sp, - Dp + Dp, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/Types/NsdSettings.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/Types/NsdSettings.cs index 0a72fa87..08fb15e0 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/Types/NsdSettings.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/Types/NsdSettings.cs @@ -2,8 +2,8 @@ { class NsdSettings { - public bool Initialized; - public bool TestMode; + public bool Initialized; + public bool TestMode; public string Environment; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/IResolver.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/IResolver.cs index 64c3acbb..93960d13 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/IResolver.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/IResolver.cs @@ -28,8 +28,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres public ResultCode SetDnsAddressesPrivateRequest(ServiceCtx context) { uint cancelHandleRequest = context.RequestData.ReadUInt32(); - ulong bufferPosition = context.Request.SendBuff[0].Position; - ulong bufferSize = context.Request.SendBuff[0].Size; +#pragma warning disable IDE0059 // Remove unnecessary value assignment + ulong bufferPosition = context.Request.SendBuff[0].Position; + ulong bufferSize = context.Request.SendBuff[0].Size; +#pragma warning restore IDE0059 // TODO: This is stubbed in 2.0.0+, reverse 1.0.0 version for the sake of completeness. Logger.Stub?.PrintStub(LogClass.ServiceSfdnsres, new { cancelHandleRequest }); @@ -42,8 +44,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres public ResultCode GetDnsAddressPrivateRequest(ServiceCtx context) { uint cancelHandleRequest = context.RequestData.ReadUInt32(); - ulong bufferPosition = context.Request.ReceiveBuff[0].Position; - ulong bufferSize = context.Request.ReceiveBuff[0].Size; +#pragma warning disable IDE0059 // Remove unnecessary value assignment + ulong bufferPosition = context.Request.ReceiveBuff[0].Position; + ulong bufferSize = context.Request.ReceiveBuff[0].Size; +#pragma warning restore IDE0059 // TODO: This is stubbed in 2.0.0+, reverse 1.0.0 version for the sake of completeness. Logger.Stub?.PrintStub(LogClass.ServiceSfdnsres, new { cancelHandleRequest }); @@ -56,10 +60,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres public ResultCode GetHostByNameRequest(ServiceCtx context) { ulong inputBufferPosition = context.Request.SendBuff[0].Position; - ulong inputBufferSize = context.Request.SendBuff[0].Size; + ulong inputBufferSize = context.Request.SendBuff[0].Size; ulong outputBufferPosition = context.Request.ReceiveBuff[0].Position; - ulong outputBufferSize = context.Request.ReceiveBuff[0].Size; + ulong outputBufferSize = context.Request.ReceiveBuff[0].Size; return GetHostByNameRequestImpl(context, inputBufferPosition, inputBufferSize, outputBufferPosition, outputBufferSize, false, 0, 0); } @@ -69,10 +73,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres public ResultCode GetHostByAddrRequest(ServiceCtx context) { ulong inputBufferPosition = context.Request.SendBuff[0].Position; - ulong inputBufferSize = context.Request.SendBuff[0].Size; + ulong inputBufferSize = context.Request.SendBuff[0].Size; ulong outputBufferPosition = context.Request.ReceiveBuff[0].Position; - ulong outputBufferSize = context.Request.ReceiveBuff[0].Size; + ulong outputBufferSize = context.Request.ReceiveBuff[0].Size; return GetHostByAddrRequestImpl(context, inputBufferPosition, inputBufferSize, outputBufferPosition, outputBufferSize, false, 0, 0); } @@ -82,20 +86,20 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres public ResultCode GetHostStringErrorRequest(ServiceCtx context) { ResultCode resultCode = ResultCode.NotAllocated; - NetDbError errorCode = (NetDbError)context.RequestData.ReadInt32(); + NetDbError errorCode = (NetDbError)context.RequestData.ReadInt32(); string errorString = errorCode switch { - NetDbError.Success => "Resolver Error 0 (no error)", + NetDbError.Success => "Resolver Error 0 (no error)", NetDbError.HostNotFound => "Unknown host", - NetDbError.TryAgain => "Host name lookup failure", - NetDbError.NoRecovery => "Unknown server error", - NetDbError.NoData => "No address associated with name", - _ => (errorCode <= NetDbError.Internal) ? "Resolver internal error" : "Unknown resolver error" + NetDbError.TryAgain => "Host name lookup failure", + NetDbError.NoRecovery => "Unknown server error", + NetDbError.NoData => "No address associated with name", + _ => (errorCode <= NetDbError.Internal) ? "Resolver internal error" : "Unknown resolver error", }; ulong bufferPosition = context.Request.ReceiveBuff[0].Position; - ulong bufferSize = context.Request.ReceiveBuff[0].Size; + ulong bufferSize = context.Request.ReceiveBuff[0].Size; if ((ulong)(errorString.Length + 1) <= bufferSize) { @@ -112,7 +116,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres public ResultCode GetGaiStringErrorRequest(ServiceCtx context) { ResultCode resultCode = ResultCode.NotAllocated; - GaiError errorCode = (GaiError)context.RequestData.ReadInt32(); + GaiError errorCode = (GaiError)context.RequestData.ReadInt32(); if (errorCode > GaiError.Max) { @@ -122,25 +126,25 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres string errorString = errorCode switch { GaiError.AddressFamily => "Address family for hostname not supported", - GaiError.Again => "Temporary failure in name resolution", - GaiError.BadFlags => "Invalid value for ai_flags", - GaiError.Fail => "Non-recoverable failure in name resolution", - GaiError.Family => "ai_family not supported", - GaiError.Memory => "Memory allocation failure", - GaiError.NoData => "No address associated with hostname", - GaiError.NoName => "hostname nor servname provided, or not known", - GaiError.Service => "servname not supported for ai_socktype", - GaiError.SocketType => "ai_socktype not supported", - GaiError.System => "System error returned in errno", - GaiError.BadHints => "Invalid value for hints", - GaiError.Protocol => "Resolved protocol is unknown", - GaiError.Overflow => "Argument buffer overflow", - GaiError.Max => "Unknown error", - _ => "Success" + GaiError.Again => "Temporary failure in name resolution", + GaiError.BadFlags => "Invalid value for ai_flags", + GaiError.Fail => "Non-recoverable failure in name resolution", + GaiError.Family => "ai_family not supported", + GaiError.Memory => "Memory allocation failure", + GaiError.NoData => "No address associated with hostname", + GaiError.NoName => "hostname nor servname provided, or not known", + GaiError.Service => "servname not supported for ai_socktype", + GaiError.SocketType => "ai_socktype not supported", + GaiError.System => "System error returned in errno", + GaiError.BadHints => "Invalid value for hints", + GaiError.Protocol => "Resolved protocol is unknown", + GaiError.Overflow => "Argument buffer overflow", + GaiError.Max => "Unknown error", + _ => "Success", }; ulong bufferPosition = context.Request.ReceiveBuff[0].Position; - ulong bufferSize = context.Request.ReceiveBuff[0].Size; + ulong bufferSize = context.Request.ReceiveBuff[0].Size; if ((ulong)(errorString.Length + 1) <= bufferSize) { @@ -157,7 +161,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres public ResultCode GetAddrInfoRequest(ServiceCtx context) { ulong responseBufferPosition = context.Request.ReceiveBuff[0].Position; - ulong responseBufferSize = context.Request.ReceiveBuff[0].Size; + ulong responseBufferSize = context.Request.ReceiveBuff[0].Size; return GetAddrInfoRequestImpl(context, responseBufferPosition, responseBufferSize, false, 0, 0); } @@ -166,8 +170,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres // GetCancelHandleRequest(u64, pid) -> u32 public ResultCode GetCancelHandleRequest(ServiceCtx context) { - ulong pidPlaceHolder = context.RequestData.ReadUInt64(); - uint cancelHandleRequest = 0; +#pragma warning disable IDE0059 // Remove unnecessary value assignment + ulong pidPlaceHolder = context.RequestData.ReadUInt64(); +#pragma warning restore IDE0059 + uint cancelHandleRequest = 0; context.ResponseData.Write(cancelHandleRequest); @@ -180,8 +186,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres // CancelRequest(u32, u64, pid) public ResultCode CancelRequest(ServiceCtx context) { - uint cancelHandleRequest = context.RequestData.ReadUInt32(); - ulong pidPlaceHolder = context.RequestData.ReadUInt64(); + uint cancelHandleRequest = context.RequestData.ReadUInt32(); +#pragma warning disable IDE0059 // Remove unnecessary value assignment + ulong pidPlaceHolder = context.RequestData.ReadUInt64(); +#pragma warning restore IDE0059 Logger.Stub?.PrintStub(LogClass.ServiceSfdnsres, new { cancelHandleRequest }); @@ -192,8 +200,8 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres // GetHostByNameRequestWithOptions(u8, u32, u64, pid, buffer<unknown, 21, 0>, buffer<unknown, 21, 0>) -> (u32, u32, u32, buffer<unknown, 22, 0>) public ResultCode GetHostByNameRequestWithOptions(ServiceCtx context) { - (ulong inputBufferPosition, ulong inputBufferSize) = context.Request.GetBufferType0x21(); - (ulong outputBufferPosition, ulong outputBufferSize) = context.Request.GetBufferType0x22(); + (ulong inputBufferPosition, ulong inputBufferSize) = context.Request.GetBufferType0x21(); + (ulong outputBufferPosition, ulong outputBufferSize) = context.Request.GetBufferType0x22(); (ulong optionsBufferPosition, ulong optionsBufferSize) = context.Request.GetBufferType0x21(); return GetHostByNameRequestImpl( @@ -211,8 +219,8 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres // GetHostByAddrRequestWithOptions(u32, u32, u32, u64, pid, buffer<unknown, 21, 0>, buffer<unknown, 21, 0>) -> (u32, u32, u32, buffer<unknown, 22, 0>) public ResultCode GetHostByAddrRequestWithOptions(ServiceCtx context) { - (ulong inputBufferPosition, ulong inputBufferSize) = context.Request.GetBufferType0x21(); - (ulong outputBufferPosition, ulong outputBufferSize) = context.Request.GetBufferType0x22(); + (ulong inputBufferPosition, ulong inputBufferSize) = context.Request.GetBufferType0x21(); + (ulong outputBufferPosition, ulong outputBufferSize) = context.Request.GetBufferType0x22(); (ulong optionsBufferPosition, ulong optionsBufferSize) = context.Request.GetBufferType0x21(); return GetHostByAddrRequestImpl( @@ -230,7 +238,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres // GetAddrInfoRequestWithOptions(bool enable_nsd_resolve, u32, u64 pid_placeholder, pid, buffer<i8, 5, 0> host, buffer<i8, 5, 0> service, buffer<packed_addrinfo, 5, 0> hints, buffer<unknown, 21, 0>) -> (i32 ret, u32 bsd_errno, u32 unknown, u32 packed_addrinfo_size, buffer<packed_addrinfo, 22, 0> response) public ResultCode GetAddrInfoRequestWithOptions(ServiceCtx context) { - (ulong outputBufferPosition, ulong outputBufferSize) = context.Request.GetBufferType0x22(); + (ulong outputBufferPosition, ulong outputBufferSize) = context.Request.GetBufferType0x22(); (ulong optionsBufferPosition, ulong optionsBufferSize) = context.Request.GetBufferType0x21(); return GetAddrInfoRequestImpl(context, outputBufferPosition, outputBufferSize, true, optionsBufferPosition, optionsBufferSize); @@ -241,7 +249,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres public ResultCode ResolverSetOptionRequest(ServiceCtx context) { ulong bufferPosition = context.Request.SendBuff[0].Position; - ulong bufferSize = context.Request.SendBuff[0].Size; + ulong bufferSize = context.Request.SendBuff[0].Size; ulong unknown = context.RequestData.ReadUInt64(); @@ -254,7 +262,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres Logger.Stub?.PrintStub(LogClass.ServiceSfdnsres, new { unknown }); NetDbError netDbErrorCode = NetDbError.Success; - GaiError errno = GaiError.Success; + GaiError errno = GaiError.Success; context.ResponseData.Write((int)errno); context.ResponseData.Write((int)netDbErrorCode); @@ -294,9 +302,11 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres } // TODO: Use params. - bool enableNsdResolve = (context.RequestData.ReadInt32() & 1) != 0; - int timeOut = context.RequestData.ReadInt32(); - ulong pidPlaceholder = context.RequestData.ReadUInt64(); + bool enableNsdResolve = (context.RequestData.ReadInt32() & 1) != 0; +#pragma warning disable IDE0059 // Remove unnecessary value assignment + int timeOut = context.RequestData.ReadInt32(); + ulong pidPlaceholder = context.RequestData.ReadUInt64(); +#pragma warning restore IDE0059 if (withOptions) { @@ -306,8 +316,8 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres IPHostEntry hostEntry = null; NetDbError netDbErrorCode = NetDbError.Success; - GaiError errno = GaiError.Overflow; - int serializedSize = 0; + GaiError errno = GaiError.Overflow; + int serializedSize = 0; if (host.Length <= byte.MaxValue) { @@ -326,7 +336,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres Logger.Info?.Print(LogClass.ServiceSfdnsres, $"DNS Blocked: {host}"); netDbErrorCode = NetDbError.HostNotFound; - errno = GaiError.NoData; + errno = GaiError.NoData; } else { @@ -339,7 +349,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres catch (SocketException exception) { netDbErrorCode = ConvertSocketErrorCodeToNetDbError(exception.ErrorCode); - errno = ConvertSocketErrorCodeToGaiError(exception.ErrorCode, errno); + errno = ConvertSocketErrorCodeToGaiError(exception.ErrorCode, errno); } } } @@ -354,12 +364,12 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres if (!addresses.Any()) { - errno = GaiError.NoData; + errno = GaiError.NoData; netDbErrorCode = NetDbError.NoAddress; } else { - errno = GaiError.Success; + errno = GaiError.Success; serializedSize = SerializeHostEntries(context, outputBufferPosition, outputBufferSize, hostEntry, addresses); } } @@ -381,7 +391,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres { if (!context.Device.Configuration.EnableInternetAccess) { - Logger.Info?.Print(LogClass.ServiceSfdnsres, $"Guest network access disabled, DNS Blocked."); + Logger.Info?.Print(LogClass.ServiceSfdnsres, "Guest network access disabled, DNS Blocked."); WriteResponse(context, withOptions, 0, GaiError.NoData, NetDbError.HostNotFound); @@ -393,10 +403,12 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres context.Memory.Read(inputBufferPosition, rawIp); // TODO: Use params. - uint socketLength = context.RequestData.ReadUInt32(); - uint type = context.RequestData.ReadUInt32(); - int timeOut = context.RequestData.ReadInt32(); +#pragma warning disable IDE0059 // Remove unnecessary value assignment + uint socketLength = context.RequestData.ReadUInt32(); + uint type = context.RequestData.ReadUInt32(); + int timeOut = context.RequestData.ReadInt32(); ulong pidPlaceholder = context.RequestData.ReadUInt64(); +#pragma warning restore IDE0059 if (withOptions) { @@ -406,21 +418,21 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres IPHostEntry hostEntry = null; NetDbError netDbErrorCode = NetDbError.Success; - GaiError errno = GaiError.AddressFamily; - int serializedSize = 0; + GaiError errno = GaiError.AddressFamily; + int serializedSize = 0; if (rawIp.Length == 4) { try { - IPAddress address = new IPAddress(rawIp); + IPAddress address = new(rawIp); hostEntry = Dns.GetHostEntry(address); } catch (SocketException exception) { netDbErrorCode = ConvertSocketErrorCodeToNetDbError(exception.ErrorCode); - errno = ConvertSocketErrorCodeToGaiError(exception.ErrorCode, errno); + errno = ConvertSocketErrorCodeToGaiError(exception.ErrorCode, errno); } } else @@ -430,7 +442,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres if (hostEntry != null) { - errno = GaiError.Success; + errno = GaiError.Success; serializedSize = SerializeHostEntries(context, outputBufferPosition, outputBufferSize, hostEntry, GetIpv4Addresses(hostEntry)); } @@ -442,7 +454,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres private static int SerializeHostEntries(ServiceCtx context, ulong outputBufferPosition, ulong outputBufferSize, IPHostEntry hostEntry, IEnumerable<IPAddress> addresses = null) { ulong originalBufferPosition = outputBufferPosition; - ulong bufferPosition = originalBufferPosition; + ulong bufferPosition = originalBufferPosition; string hostName = hostEntry.HostName + '\0'; @@ -494,9 +506,11 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres ulong optionsBufferSize) { bool enableNsdResolve = (context.RequestData.ReadInt32() & 1) != 0; - uint cancelHandle = context.RequestData.ReadUInt32(); +#pragma warning disable IDE0059 // Remove unnecessary value assignment + uint cancelHandle = context.RequestData.ReadUInt32(); +#pragma warning restore IDE0059 - string host = MemoryHelper.ReadAsciiString(context.Memory, context.Request.SendBuff[0].Position, (long)context.Request.SendBuff[0].Size); + string host = MemoryHelper.ReadAsciiString(context.Memory, context.Request.SendBuff[0].Position, (long)context.Request.SendBuff[0].Size); string service = MemoryHelper.ReadAsciiString(context.Memory, context.Request.SendBuff[1].Position, (long)context.Request.SendBuff[1].Size); if (!context.Device.Configuration.EnableInternetAccess) @@ -509,21 +523,27 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres } // NOTE: We ignore hints for now. +#pragma warning disable IDE0059 // Remove unnecessary value assignment List<AddrInfoSerialized> hints = DeserializeAddrInfos(context.Memory, context.Request.SendBuff[2].Position, context.Request.SendBuff[2].Size); +#pragma warning restore IDE0059 if (withOptions) { // TODO: Find unknown, Parse and use options. +#pragma warning disable IDE0059 // Remove unnecessary value assignment uint unknown = context.RequestData.ReadUInt32(); +#pragma warning restore IDE0059 } +#pragma warning disable IDE0059 // Remove unnecessary value assignment ulong pidPlaceHolder = context.RequestData.ReadUInt64(); +#pragma warning restore IDE0059 IPHostEntry hostEntry = null; NetDbError netDbErrorCode = NetDbError.Success; - GaiError errno = GaiError.AddressFamily; - int serializedSize = 0; + GaiError errno = GaiError.AddressFamily; + int serializedSize = 0; if (host.Length <= byte.MaxValue) { @@ -542,7 +562,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres Logger.Info?.Print(LogClass.ServiceSfdnsres, $"DNS Blocked: {host}"); netDbErrorCode = NetDbError.HostNotFound; - errno = GaiError.NoData; + errno = GaiError.NoData; } else { @@ -555,7 +575,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres catch (SocketException exception) { netDbErrorCode = ConvertSocketErrorCodeToNetDbError(exception.ErrorCode); - errno = ConvertSocketErrorCodeToGaiError(exception.ErrorCode, errno); + errno = ConvertSocketErrorCodeToGaiError(exception.ErrorCode, errno); } } } @@ -566,10 +586,15 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres if (hostEntry != null) { - int.TryParse(service, out int port); - - errno = GaiError.Success; - serializedSize = SerializeAddrInfos(context, responseBufferPosition, responseBufferSize, hostEntry, port); + if (int.TryParse(service, out int port)) + { + errno = GaiError.Success; + serializedSize = SerializeAddrInfos(context, responseBufferPosition, responseBufferSize, hostEntry, port); + } + else + { + errno = GaiError.Service; + } } WriteResponse(context, withOptions, serializedSize, errno, netDbErrorCode); @@ -601,37 +626,38 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres private static int SerializeAddrInfos(ServiceCtx context, ulong responseBufferPosition, ulong responseBufferSize, IPHostEntry hostEntry, int port) { ulong originalBufferPosition = responseBufferPosition; - ulong bufferPosition = originalBufferPosition; +#pragma warning disable IDE0059 // Remove unnecessary value assignment + ulong bufferPosition = originalBufferPosition; byte[] hostName = Encoding.ASCII.GetBytes(hostEntry.HostName + '\0'); +#pragma warning restore IDE0059 - using (WritableRegion region = context.Memory.GetWritableRegion(responseBufferPosition, (int)responseBufferSize)) - { - Span<byte> data = region.Memory.Span; + using WritableRegion region = context.Memory.GetWritableRegion(responseBufferPosition, (int)responseBufferSize); - for (int i = 0; i < hostEntry.AddressList.Length; i++) - { - IPAddress ip = hostEntry.AddressList[i]; + Span<byte> data = region.Memory.Span; - if (ip.AddressFamily != AddressFamily.InterNetwork) - { - continue; - } - - // NOTE: 0 = Any - AddrInfoSerializedHeader header = new(ip, 0); - AddrInfo4 addr = new(ip, (short)port); - AddrInfoSerialized info = new(header, addr, null, hostEntry.HostName); + for (int i = 0; i < hostEntry.AddressList.Length; i++) + { + IPAddress ip = hostEntry.AddressList[i]; - data = info.Write(data); + if (ip.AddressFamily != AddressFamily.InterNetwork) + { + continue; } - uint sentinel = 0; - MemoryMarshal.Write(data, ref sentinel); - data = data[sizeof(uint)..]; + // NOTE: 0 = Any + AddrInfoSerializedHeader header = new(ip, 0); + AddrInfo4 addr = new(ip, (short)port); + AddrInfoSerialized info = new(header, addr, null, hostEntry.HostName); - return region.Memory.Span.Length - data.Length; + data = info.Write(data); } + + uint sentinel = 0; + MemoryMarshal.Write(data, ref sentinel); + data = data[sizeof(uint)..]; + + return region.Memory.Span.Length - data.Length; } private static void WriteResponse( @@ -669,7 +695,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres 11002 => NetDbError.TryAgain, 11003 => NetDbError.NoRecovery, 11004 => NetDbError.NoData, - _ => NetDbError.Internal + _ => NetDbError.Internal, }; } @@ -679,8 +705,8 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres { 11001 => GaiError.NoData, 10060 => GaiError.Again, - _ => errno + _ => errno, }; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Proxy/DnsBlacklist.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Proxy/DnsBlacklist.cs index 776a6f7c..a2ccd190 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Proxy/DnsBlacklist.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Proxy/DnsBlacklist.cs @@ -19,18 +19,18 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Proxy [GeneratedRegex(@"^accounts\.nintendo\.com$", RegexOpts)] private static partial Regex BlockedHost6(); - private static readonly Regex[] BlockedHosts = { + private static readonly Regex[] _blockedHosts = { BlockedHost1(), BlockedHost2(), BlockedHost3(), BlockedHost4(), BlockedHost5(), - BlockedHost6() + BlockedHost6(), }; public static bool IsHostBlocked(string host) { - foreach (Regex regex in BlockedHosts) + foreach (Regex regex in _blockedHosts) { if (regex.IsMatch(host)) { @@ -41,4 +41,4 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Proxy return false; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Proxy/DnsMitmResolver.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Proxy/DnsMitmResolver.cs index 0e18c570..d17a999d 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Proxy/DnsMitmResolver.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Proxy/DnsMitmResolver.cs @@ -19,8 +19,8 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Proxy public void ReloadEntries(ServiceCtx context) { - string sdPath = context.Device.Configuration.VirtualFileSystem.GetSdCardPath(); - string filePath = context.Device.Configuration.VirtualFileSystem.GetFullPath(sdPath, HostsFilePath); + string sdPath = FileSystem.VirtualFileSystem.GetSdCardPath(); + string filePath = FileSystem.VirtualFileSystem.GetFullPath(sdPath, HostsFilePath); _mitmHostEntries.Clear(); @@ -94,7 +94,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Proxy { AddressList = new[] { hostEntry.Value }, HostName = hostEntry.Key, - Aliases = Array.Empty<string>() + Aliases = Array.Empty<string>(), }; } } @@ -103,4 +103,4 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Proxy return Dns.GetHostEntry(host); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/AddrInfo4.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/AddrInfo4.cs index 0a20e057..68250022 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/AddrInfo4.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/AddrInfo4.cs @@ -10,17 +10,17 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Types [StructLayout(LayoutKind.Sequential, Pack = 1, Size = 0x10)] struct AddrInfo4 { - public byte Length; - public byte Family; - public short Port; + public byte Length; + public byte Family; + public short Port; public Array4<byte> Address; public Array8<byte> Padding; public AddrInfo4(IPAddress address, short port) { - Length = (byte)Unsafe.SizeOf<Array4<byte>>(); - Family = (byte)AddressFamily.InterNetwork; - Port = IPAddress.HostToNetworkOrder(port); + Length = (byte)Unsafe.SizeOf<Array4<byte>>(); + Family = (byte)AddressFamily.InterNetwork; + Port = IPAddress.HostToNetworkOrder(port); Address = new Array4<byte>(); address.TryWriteBytes(Address.AsSpan(), out _); @@ -48,4 +48,4 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Types } } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/AddrInfoSerializedHeader.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/AddrInfoSerializedHeader.cs index 8e304dfa..9c50b1b8 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/AddrInfoSerializedHeader.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/AddrInfoSerializedHeader.cs @@ -10,19 +10,19 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Types struct AddrInfoSerializedHeader { public uint Magic; - public int Flags; - public int Family; - public int SocketType; - public int Protocol; + public int Flags; + public int Family; + public int SocketType; + public int Protocol; public uint AddressLength; public AddrInfoSerializedHeader(IPAddress address, SocketType socketType) { - Magic = SfdnsresContants.AddrInfoMagic; - Flags = 0; - Family = (int)address.AddressFamily; + Magic = SfdnsresContants.AddrInfoMagic; + Flags = 0; + Family = (int)address.AddressFamily; SocketType = (int)socketType; - Protocol = 0; + Protocol = 0; if (address.AddressFamily == AddressFamily.InterNetwork) { @@ -36,22 +36,22 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Types public void ToNetworkOrder() { - Magic = (uint)IPAddress.HostToNetworkOrder((int)Magic); - Flags = IPAddress.HostToNetworkOrder(Flags); - Family = IPAddress.HostToNetworkOrder(Family); - SocketType = IPAddress.HostToNetworkOrder(SocketType); - Protocol = IPAddress.HostToNetworkOrder(Protocol); + Magic = (uint)IPAddress.HostToNetworkOrder((int)Magic); + Flags = IPAddress.HostToNetworkOrder(Flags); + Family = IPAddress.HostToNetworkOrder(Family); + SocketType = IPAddress.HostToNetworkOrder(SocketType); + Protocol = IPAddress.HostToNetworkOrder(Protocol); AddressLength = (uint)IPAddress.HostToNetworkOrder((int)AddressLength); } public void ToHostOrder() { - Magic = (uint)IPAddress.NetworkToHostOrder((int)Magic); - Flags = IPAddress.NetworkToHostOrder(Flags); - Family = IPAddress.NetworkToHostOrder(Family); - SocketType = IPAddress.NetworkToHostOrder(SocketType); - Protocol = IPAddress.NetworkToHostOrder(Protocol); + Magic = (uint)IPAddress.NetworkToHostOrder((int)Magic); + Flags = IPAddress.NetworkToHostOrder(Flags); + Family = IPAddress.NetworkToHostOrder(Family); + SocketType = IPAddress.NetworkToHostOrder(SocketType); + Protocol = IPAddress.NetworkToHostOrder(Protocol); AddressLength = (uint)IPAddress.NetworkToHostOrder((int)AddressLength); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/GaiError.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/GaiError.cs index f9f28b44..46682b3c 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/GaiError.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/GaiError.cs @@ -17,6 +17,6 @@ BadHints, Protocol, Overflow, - Max + Max, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/NetDBError.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/NetDBError.cs index 3c04c049..0ded5960 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/NetDBError.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/NetDBError.cs @@ -8,6 +8,6 @@ TryAgain, NoRecovery, NoData, - NoAddress = NoData + NoAddress = NoData, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/SfdnsresContants.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/SfdnsresContants.cs index d194a3c6..7c51413c 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/SfdnsresContants.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/SfdnsresContants.cs @@ -1,7 +1,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Types { - static class SfdnsresContants + class SfdnsresContants { public const uint AddrInfoMagic = 0xBEEFCAFE; } -}
\ No newline at end of file +} |
