Ryujinx/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/IpAddressSetting.cs
riperiperi 9b5a0c3889
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
2023-02-28 03:41:44 +00:00

24 lines
982 B
C#

using System;
using System.Net.NetworkInformation;
using System.Runtime.InteropServices;
namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.Types
{
[StructLayout(LayoutKind.Sequential, Pack = 1, Size = 0xd)]
struct IpAddressSetting
{
[MarshalAs(UnmanagedType.U1)]
public bool IsDhcpEnabled;
public IpV4Address Address;
public IpV4Address IPv4Mask;
public IpV4Address GatewayAddress;
public IpAddressSetting(IPInterfaceProperties interfaceProperties, UnicastIPAddressInformation unicastIPAddressInformation)
{
IsDhcpEnabled = OperatingSystem.IsMacOS() || interfaceProperties.DhcpServerAddresses.Count != 0;
Address = new IpV4Address(unicastIPAddressInformation.Address);
IPv4Mask = new IpV4Address(unicastIPAddressInformation.IPv4Mask);
GatewayAddress = new IpV4Address(interfaceProperties.GatewayAddresses[0].Address);
}
}
}