|
@@ -1,4 +1,5 @@
|
|
|
-using Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types;
|
|
|
|
|
|
|
+using Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types;
|
|
|
|
|
+using System;
|
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
|
using System.Net.Sockets;
|
|
using System.Net.Sockets;
|
|
|
|
|
|
|
@@ -9,85 +10,133 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|
|
private static readonly Dictionary<WsaError, LinuxError> _errorMap = new()
|
|
private static readonly Dictionary<WsaError, LinuxError> _errorMap = new()
|
|
|
{
|
|
{
|
|
|
// WSAEINTR
|
|
// WSAEINTR
|
|
|
- {WsaError.WSAEINTR, LinuxError.EINTR},
|
|
|
|
|
|
|
+ { WsaError.WSAEINTR, LinuxError.EINTR },
|
|
|
// WSAEWOULDBLOCK
|
|
// WSAEWOULDBLOCK
|
|
|
- {WsaError.WSAEWOULDBLOCK, LinuxError.EWOULDBLOCK},
|
|
|
|
|
|
|
+ { WsaError.WSAEWOULDBLOCK, LinuxError.EWOULDBLOCK },
|
|
|
// WSAEINPROGRESS
|
|
// WSAEINPROGRESS
|
|
|
- {WsaError.WSAEINPROGRESS, LinuxError.EINPROGRESS},
|
|
|
|
|
|
|
+ { WsaError.WSAEINPROGRESS, LinuxError.EINPROGRESS },
|
|
|
// WSAEALREADY
|
|
// WSAEALREADY
|
|
|
- {WsaError.WSAEALREADY, LinuxError.EALREADY},
|
|
|
|
|
|
|
+ { WsaError.WSAEALREADY, LinuxError.EALREADY },
|
|
|
// WSAENOTSOCK
|
|
// WSAENOTSOCK
|
|
|
- {WsaError.WSAENOTSOCK, LinuxError.ENOTSOCK},
|
|
|
|
|
|
|
+ { WsaError.WSAENOTSOCK, LinuxError.ENOTSOCK },
|
|
|
// WSAEDESTADDRREQ
|
|
// WSAEDESTADDRREQ
|
|
|
- {WsaError.WSAEDESTADDRREQ, LinuxError.EDESTADDRREQ},
|
|
|
|
|
|
|
+ { WsaError.WSAEDESTADDRREQ, LinuxError.EDESTADDRREQ },
|
|
|
// WSAEMSGSIZE
|
|
// WSAEMSGSIZE
|
|
|
- {WsaError.WSAEMSGSIZE, LinuxError.EMSGSIZE},
|
|
|
|
|
|
|
+ { WsaError.WSAEMSGSIZE, LinuxError.EMSGSIZE },
|
|
|
// WSAEPROTOTYPE
|
|
// WSAEPROTOTYPE
|
|
|
- {WsaError.WSAEPROTOTYPE, LinuxError.EPROTOTYPE},
|
|
|
|
|
|
|
+ { WsaError.WSAEPROTOTYPE, LinuxError.EPROTOTYPE },
|
|
|
// WSAENOPROTOOPT
|
|
// WSAENOPROTOOPT
|
|
|
- {WsaError.WSAENOPROTOOPT, LinuxError.ENOPROTOOPT},
|
|
|
|
|
|
|
+ { WsaError.WSAENOPROTOOPT, LinuxError.ENOPROTOOPT },
|
|
|
// WSAEPROTONOSUPPORT
|
|
// WSAEPROTONOSUPPORT
|
|
|
- {WsaError.WSAEPROTONOSUPPORT, LinuxError.EPROTONOSUPPORT},
|
|
|
|
|
|
|
+ { WsaError.WSAEPROTONOSUPPORT, LinuxError.EPROTONOSUPPORT },
|
|
|
// WSAESOCKTNOSUPPORT
|
|
// WSAESOCKTNOSUPPORT
|
|
|
- {WsaError.WSAESOCKTNOSUPPORT, LinuxError.ESOCKTNOSUPPORT},
|
|
|
|
|
|
|
+ { WsaError.WSAESOCKTNOSUPPORT, LinuxError.ESOCKTNOSUPPORT },
|
|
|
// WSAEOPNOTSUPP
|
|
// WSAEOPNOTSUPP
|
|
|
- {WsaError.WSAEOPNOTSUPP, LinuxError.EOPNOTSUPP},
|
|
|
|
|
|
|
+ { WsaError.WSAEOPNOTSUPP, LinuxError.EOPNOTSUPP },
|
|
|
// WSAEPFNOSUPPORT
|
|
// WSAEPFNOSUPPORT
|
|
|
- {WsaError.WSAEPFNOSUPPORT, LinuxError.EPFNOSUPPORT},
|
|
|
|
|
|
|
+ { WsaError.WSAEPFNOSUPPORT, LinuxError.EPFNOSUPPORT },
|
|
|
// WSAEAFNOSUPPORT
|
|
// WSAEAFNOSUPPORT
|
|
|
- {WsaError.WSAEAFNOSUPPORT, LinuxError.EAFNOSUPPORT},
|
|
|
|
|
|
|
+ { WsaError.WSAEAFNOSUPPORT, LinuxError.EAFNOSUPPORT },
|
|
|
// WSAEADDRINUSE
|
|
// WSAEADDRINUSE
|
|
|
- {WsaError.WSAEADDRINUSE, LinuxError.EADDRINUSE},
|
|
|
|
|
|
|
+ { WsaError.WSAEADDRINUSE, LinuxError.EADDRINUSE },
|
|
|
// WSAEADDRNOTAVAIL
|
|
// WSAEADDRNOTAVAIL
|
|
|
- {WsaError.WSAEADDRNOTAVAIL, LinuxError.EADDRNOTAVAIL},
|
|
|
|
|
|
|
+ { WsaError.WSAEADDRNOTAVAIL, LinuxError.EADDRNOTAVAIL },
|
|
|
// WSAENETDOWN
|
|
// WSAENETDOWN
|
|
|
- {WsaError.WSAENETDOWN, LinuxError.ENETDOWN},
|
|
|
|
|
|
|
+ { WsaError.WSAENETDOWN, LinuxError.ENETDOWN },
|
|
|
// WSAENETUNREACH
|
|
// WSAENETUNREACH
|
|
|
- {WsaError.WSAENETUNREACH, LinuxError.ENETUNREACH},
|
|
|
|
|
|
|
+ { WsaError.WSAENETUNREACH, LinuxError.ENETUNREACH },
|
|
|
// WSAENETRESET
|
|
// WSAENETRESET
|
|
|
- {WsaError.WSAENETRESET, LinuxError.ENETRESET},
|
|
|
|
|
|
|
+ { WsaError.WSAENETRESET, LinuxError.ENETRESET },
|
|
|
// WSAECONNABORTED
|
|
// WSAECONNABORTED
|
|
|
- {WsaError.WSAECONNABORTED, LinuxError.ECONNABORTED},
|
|
|
|
|
|
|
+ { WsaError.WSAECONNABORTED, LinuxError.ECONNABORTED },
|
|
|
// WSAECONNRESET
|
|
// WSAECONNRESET
|
|
|
- {WsaError.WSAECONNRESET, LinuxError.ECONNRESET},
|
|
|
|
|
|
|
+ { WsaError.WSAECONNRESET, LinuxError.ECONNRESET },
|
|
|
// WSAENOBUFS
|
|
// WSAENOBUFS
|
|
|
- {WsaError.WSAENOBUFS, LinuxError.ENOBUFS},
|
|
|
|
|
|
|
+ { WsaError.WSAENOBUFS, LinuxError.ENOBUFS },
|
|
|
// WSAEISCONN
|
|
// WSAEISCONN
|
|
|
- {WsaError.WSAEISCONN, LinuxError.EISCONN},
|
|
|
|
|
|
|
+ { WsaError.WSAEISCONN, LinuxError.EISCONN },
|
|
|
// WSAENOTCONN
|
|
// WSAENOTCONN
|
|
|
- {WsaError.WSAENOTCONN, LinuxError.ENOTCONN},
|
|
|
|
|
|
|
+ { WsaError.WSAENOTCONN, LinuxError.ENOTCONN },
|
|
|
// WSAESHUTDOWN
|
|
// WSAESHUTDOWN
|
|
|
- {WsaError.WSAESHUTDOWN, LinuxError.ESHUTDOWN},
|
|
|
|
|
|
|
+ { WsaError.WSAESHUTDOWN, LinuxError.ESHUTDOWN },
|
|
|
// WSAETOOMANYREFS
|
|
// WSAETOOMANYREFS
|
|
|
- {WsaError.WSAETOOMANYREFS, LinuxError.ETOOMANYREFS},
|
|
|
|
|
|
|
+ { WsaError.WSAETOOMANYREFS, LinuxError.ETOOMANYREFS },
|
|
|
// WSAETIMEDOUT
|
|
// WSAETIMEDOUT
|
|
|
- {WsaError.WSAETIMEDOUT, LinuxError.ETIMEDOUT},
|
|
|
|
|
|
|
+ { WsaError.WSAETIMEDOUT, LinuxError.ETIMEDOUT },
|
|
|
// WSAECONNREFUSED
|
|
// WSAECONNREFUSED
|
|
|
- {WsaError.WSAECONNREFUSED, LinuxError.ECONNREFUSED},
|
|
|
|
|
|
|
+ { WsaError.WSAECONNREFUSED, LinuxError.ECONNREFUSED },
|
|
|
// WSAELOOP
|
|
// WSAELOOP
|
|
|
- {WsaError.WSAELOOP, LinuxError.ELOOP},
|
|
|
|
|
|
|
+ { WsaError.WSAELOOP, LinuxError.ELOOP },
|
|
|
// WSAENAMETOOLONG
|
|
// WSAENAMETOOLONG
|
|
|
- {WsaError.WSAENAMETOOLONG, LinuxError.ENAMETOOLONG},
|
|
|
|
|
|
|
+ { WsaError.WSAENAMETOOLONG, LinuxError.ENAMETOOLONG },
|
|
|
// WSAEHOSTDOWN
|
|
// WSAEHOSTDOWN
|
|
|
- {WsaError.WSAEHOSTDOWN, LinuxError.EHOSTDOWN},
|
|
|
|
|
|
|
+ { WsaError.WSAEHOSTDOWN, LinuxError.EHOSTDOWN },
|
|
|
// WSAEHOSTUNREACH
|
|
// WSAEHOSTUNREACH
|
|
|
- {WsaError.WSAEHOSTUNREACH, LinuxError.EHOSTUNREACH},
|
|
|
|
|
|
|
+ { WsaError.WSAEHOSTUNREACH, LinuxError.EHOSTUNREACH },
|
|
|
// WSAENOTEMPTY
|
|
// WSAENOTEMPTY
|
|
|
- {WsaError.WSAENOTEMPTY, LinuxError.ENOTEMPTY},
|
|
|
|
|
|
|
+ { WsaError.WSAENOTEMPTY, LinuxError.ENOTEMPTY },
|
|
|
// WSAEUSERS
|
|
// WSAEUSERS
|
|
|
- {WsaError.WSAEUSERS, LinuxError.EUSERS},
|
|
|
|
|
|
|
+ { WsaError.WSAEUSERS, LinuxError.EUSERS },
|
|
|
// WSAEDQUOT
|
|
// WSAEDQUOT
|
|
|
- {WsaError.WSAEDQUOT, LinuxError.EDQUOT},
|
|
|
|
|
|
|
+ { WsaError.WSAEDQUOT, LinuxError.EDQUOT },
|
|
|
// WSAESTALE
|
|
// WSAESTALE
|
|
|
- {WsaError.WSAESTALE, LinuxError.ESTALE},
|
|
|
|
|
|
|
+ { WsaError.WSAESTALE, LinuxError.ESTALE },
|
|
|
// WSAEREMOTE
|
|
// WSAEREMOTE
|
|
|
- {WsaError.WSAEREMOTE, LinuxError.EREMOTE},
|
|
|
|
|
|
|
+ { WsaError.WSAEREMOTE, LinuxError.EREMOTE },
|
|
|
// WSAEINVAL
|
|
// WSAEINVAL
|
|
|
- {WsaError.WSAEINVAL, LinuxError.EINVAL},
|
|
|
|
|
|
|
+ { WsaError.WSAEINVAL, LinuxError.EINVAL },
|
|
|
// WSAEFAULT
|
|
// WSAEFAULT
|
|
|
- {WsaError.WSAEFAULT, LinuxError.EFAULT},
|
|
|
|
|
|
|
+ { WsaError.WSAEFAULT, LinuxError.EFAULT },
|
|
|
// NOERROR
|
|
// NOERROR
|
|
|
- {0, 0}
|
|
|
|
|
|
|
+ { 0, 0 }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ private static readonly Dictionary<int, LinuxError> _errorMapMacOs = new()
|
|
|
|
|
+ {
|
|
|
|
|
+ { 35, LinuxError.EAGAIN },
|
|
|
|
|
+ { 11, LinuxError.EDEADLOCK },
|
|
|
|
|
+ { 91, LinuxError.ENOMSG },
|
|
|
|
|
+ { 90, LinuxError.EIDRM },
|
|
|
|
|
+ { 77, LinuxError.ENOLCK },
|
|
|
|
|
+ { 70, LinuxError.ESTALE },
|
|
|
|
|
+ { 36, LinuxError.EINPROGRESS },
|
|
|
|
|
+ { 37, LinuxError.EALREADY },
|
|
|
|
|
+ { 38, LinuxError.ENOTSOCK },
|
|
|
|
|
+ { 39, LinuxError.EDESTADDRREQ },
|
|
|
|
|
+ { 40, LinuxError.EMSGSIZE },
|
|
|
|
|
+ { 41, LinuxError.EPROTOTYPE },
|
|
|
|
|
+ { 42, LinuxError.ENOPROTOOPT },
|
|
|
|
|
+ { 43, LinuxError.EPROTONOSUPPORT },
|
|
|
|
|
+ { 44, LinuxError.ESOCKTNOSUPPORT },
|
|
|
|
|
+ { 45, LinuxError.EOPNOTSUPP },
|
|
|
|
|
+ { 46, LinuxError.EPFNOSUPPORT },
|
|
|
|
|
+ { 47, LinuxError.EAFNOSUPPORT },
|
|
|
|
|
+ { 48, LinuxError.EADDRINUSE },
|
|
|
|
|
+ { 49, LinuxError.EADDRNOTAVAIL },
|
|
|
|
|
+ { 50, LinuxError.ENETDOWN },
|
|
|
|
|
+ { 51, LinuxError.ENETUNREACH },
|
|
|
|
|
+ { 52, LinuxError.ENETRESET },
|
|
|
|
|
+ { 53, LinuxError.ECONNABORTED },
|
|
|
|
|
+ { 54, LinuxError.ECONNRESET },
|
|
|
|
|
+ { 55, LinuxError.ENOBUFS },
|
|
|
|
|
+ { 56, LinuxError.EISCONN },
|
|
|
|
|
+ { 57, LinuxError.ENOTCONN },
|
|
|
|
|
+ { 58, LinuxError.ESHUTDOWN },
|
|
|
|
|
+ { 60, LinuxError.ETIMEDOUT },
|
|
|
|
|
+ { 61, LinuxError.ECONNREFUSED },
|
|
|
|
|
+ { 64, LinuxError.EHOSTDOWN },
|
|
|
|
|
+ { 65, LinuxError.EHOSTUNREACH },
|
|
|
|
|
+ { 68, LinuxError.EUSERS },
|
|
|
|
|
+ { 62, LinuxError.ELOOP },
|
|
|
|
|
+ { 63, LinuxError.ENAMETOOLONG },
|
|
|
|
|
+ { 66, LinuxError.ENOTEMPTY },
|
|
|
|
|
+ { 69, LinuxError.EDQUOT },
|
|
|
|
|
+ { 71, LinuxError.EREMOTE },
|
|
|
|
|
+ { 78, LinuxError.ENOSYS },
|
|
|
|
|
+ { 59, LinuxError.ETOOMANYREFS },
|
|
|
|
|
+ { 92, LinuxError.EILSEQ },
|
|
|
|
|
+ { 89, LinuxError.ECANCELED },
|
|
|
|
|
+ { 84, LinuxError.EOVERFLOW }
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
private static readonly Dictionary<BsdSocketOption, SocketOptionName> _soSocketOptionMap = new()
|
|
private static readonly Dictionary<BsdSocketOption, SocketOptionName> _soSocketOptionMap = new()
|
|
@@ -136,12 +185,22 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|
|
|
|
|
|
|
public static LinuxError ConvertError(WsaError errorCode)
|
|
public static LinuxError ConvertError(WsaError errorCode)
|
|
|
{
|
|
{
|
|
|
- if (!_errorMap.TryGetValue(errorCode, out LinuxError errno))
|
|
|
|
|
|
|
+ if (OperatingSystem.IsMacOS())
|
|
|
|
|
+ {
|
|
|
|
|
+ if (_errorMapMacOs.TryGetValue((int)errorCode, out LinuxError errno))
|
|
|
|
|
+ {
|
|
|
|
|
+ return errno;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
{
|
|
{
|
|
|
- errno = (LinuxError)errorCode;
|
|
|
|
|
|
|
+ if (_errorMap.TryGetValue(errorCode, out LinuxError errno))
|
|
|
|
|
+ {
|
|
|
|
|
+ return errno;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return errno;
|
|
|
|
|
|
|
+ return (LinuxError)errorCode;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public static bool TryConvertSocketOption(BsdSocketOption option, SocketOptionLevel level, out SocketOptionName name)
|
|
public static bool TryConvertSocketOption(BsdSocketOption option, SocketOptionLevel level, out SocketOptionName name)
|