Sockets: Properly convert error codes on MacOS (#4491)
* Sockets: Properly convert error codes on MacOS The error codes for MacOS are very different to how they are on windows or linux. An alternate mapping is used when the host operating system is MacOS. This PR also defaults IsDhcpEnabled to true when interfaceProperties.DhcpServerAddresses is not available. This change was already in `macos1`. * Address feedback
This commit is contained in:
parent
80b4972139
commit
9b5a0c3889
@ -15,7 +15,7 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.Types
|
|||||||
|
|
||||||
public IpAddressSetting(IPInterfaceProperties interfaceProperties, UnicastIPAddressInformation unicastIPAddressInformation)
|
public IpAddressSetting(IPInterfaceProperties interfaceProperties, UnicastIPAddressInformation unicastIPAddressInformation)
|
||||||
{
|
{
|
||||||
IsDhcpEnabled = !OperatingSystem.IsMacOS() && interfaceProperties.DhcpServerAddresses.Count != 0;
|
IsDhcpEnabled = OperatingSystem.IsMacOS() || interfaceProperties.DhcpServerAddresses.Count != 0;
|
||||||
Address = new IpV4Address(unicastIPAddressInformation.Address);
|
Address = new IpV4Address(unicastIPAddressInformation.Address);
|
||||||
IPv4Mask = new IpV4Address(unicastIPAddressInformation.IPv4Mask);
|
IPv4Mask = new IpV4Address(unicastIPAddressInformation.IPv4Mask);
|
||||||
GatewayAddress = new IpV4Address(interfaceProperties.GatewayAddresses[0].Address);
|
GatewayAddress = new IpV4Address(interfaceProperties.GatewayAddresses[0].Address);
|
||||||
|
@ -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;
|
||||||
|
|
||||||
@ -90,6 +91,54 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|||||||
{ 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()
|
||||||
{
|
{
|
||||||
{ BsdSocketOption.SoDebug, SocketOptionName.Debug },
|
{ BsdSocketOption.SoDebug, SocketOptionName.Debug },
|
||||||
@ -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())
|
||||||
{
|
{
|
||||||
errno = (LinuxError)errorCode;
|
if (_errorMapMacOs.TryGetValue((int)errorCode, out LinuxError errno))
|
||||||
|
{
|
||||||
|
return errno;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user