aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Services/Nifm/StaticService
diff options
context:
space:
mode:
authorAc_K <Acoustik666@gmail.com>2021-04-13 03:04:18 +0200
committerGitHub <noreply@github.com>2021-04-13 03:04:18 +0200
commitb662a26c7e2b66d916986b1ed9ffae3b918619d1 (patch)
tree130908b7c94802ee747560929f43c8403b52d203 /Ryujinx.HLE/HOS/Services/Nifm/StaticService
parent73881fad1995e079eae3e728cb2f4c657886e476 (diff)
nifm/ssl: Implement GetCurrentNetworkProfile and stub Ssl Service (#2186)
* nifm/ssl: Implement GetCurrentNetworkProfile and stub Ssl Service * remove InterfaceVersion
Diffstat (limited to 'Ryujinx.HLE/HOS/Services/Nifm/StaticService')
-rw-r--r--Ryujinx.HLE/HOS/Services/Nifm/StaticService/IGeneralService.cs47
-rw-r--r--Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/DnsSetting.cs15
-rw-r--r--Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/IpSettingData.cs13
-rw-r--r--Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/NetworkProfileData.cs17
-rw-r--r--Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/ProxySetting.cs27
-rw-r--r--Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/WirelessSettingData.cs15
6 files changed, 122 insertions, 12 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/IGeneralService.cs b/Ryujinx.HLE/HOS/Services/Nifm/StaticService/IGeneralService.cs
index 944186d3..2614a54c 100644
--- a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/IGeneralService.cs
+++ b/Ryujinx.HLE/HOS/Services/Nifm/StaticService/IGeneralService.cs
@@ -2,8 +2,11 @@ using Ryujinx.Common;
using Ryujinx.Common.Logging;
using Ryujinx.HLE.HOS.Services.Nifm.StaticService.GeneralService;
using Ryujinx.HLE.HOS.Services.Nifm.StaticService.Types;
+using Ryujinx.HLE.Utilities;
using System;
using System.Net.NetworkInformation;
+using System.Runtime.CompilerServices;
+using System.Text;
namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService
{
@@ -51,6 +54,38 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService
return ResultCode.Success;
}
+ [Command(5)]
+ // GetCurrentNetworkProfile() -> buffer<nn::nifm::detail::sf::NetworkProfileData, 0x1a, 0x17c>
+ public ResultCode GetCurrentNetworkProfile(ServiceCtx context)
+ {
+ long networkProfileDataPosition = context.Request.RecvListBuff[0].Position;
+
+ (IPInterfaceProperties interfaceProperties, UnicastIPAddressInformation unicastAddress) = GetLocalInterface();
+
+ if (interfaceProperties == null || unicastAddress == null)
+ {
+ return ResultCode.NoInternetConnection;
+ }
+
+ Logger.Info?.Print(LogClass.ServiceNifm, $"Console's local IP is \"{unicastAddress.Address}\".");
+
+ context.Response.PtrBuff[0] = context.Response.PtrBuff[0].WithSize(Unsafe.SizeOf<NetworkProfileData>());
+
+ NetworkProfileData networkProfile = new NetworkProfileData
+ {
+ Uuid = new UInt128(Guid.NewGuid().ToByteArray())
+ };
+
+ networkProfile.IpSettingData.IpAddressSetting = new IpAddressSetting(interfaceProperties, unicastAddress);
+ networkProfile.IpSettingData.DnsSetting = new DnsSetting(interfaceProperties);
+
+ Encoding.ASCII.GetBytes("RyujinxNetwork").CopyTo(networkProfile.Name.ToSpan());
+
+ context.Memory.Write((ulong)networkProfileDataPosition, networkProfile);
+
+ return ResultCode.Success;
+ }
+
[Command(12)]
// GetCurrentIpAddress() -> nn::nifm::IpV4Address
public ResultCode GetCurrentIpAddress(ServiceCtx context)
@@ -75,7 +110,7 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService
{
(IPInterfaceProperties interfaceProperties, UnicastIPAddressInformation unicastAddress) = GetLocalInterface();
- if (interfaceProperties == null)
+ if (interfaceProperties == null || unicastAddress == null)
{
return ResultCode.NoInternetConnection;
}
@@ -138,11 +173,11 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService
foreach (NetworkInterface adapter in interfaces)
{
// Ignore loopback and non IPv4 capable interface.
- if (adapter.NetworkInterfaceType != NetworkInterfaceType.Loopback && adapter.Supports(NetworkInterfaceComponent.IPv4))
+ if (targetProperties == null && adapter.NetworkInterfaceType != NetworkInterfaceType.Loopback && adapter.Supports(NetworkInterfaceComponent.IPv4))
{
IPInterfaceProperties properties = adapter.GetIPProperties();
- if (properties.GatewayAddresses.Count > 0 && properties.DnsAddresses.Count > 1)
+ if (properties.GatewayAddresses.Count > 0 && properties.DnsAddresses.Count > 0)
{
foreach (UnicastIPAddressInformation info in properties.UnicastAddresses)
{
@@ -156,12 +191,6 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService
}
}
}
-
- // Found the target interface, stop here.
- if (targetProperties != null)
- {
- break;
- }
}
}
diff --git a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/DnsSetting.cs b/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/DnsSetting.cs
index 96f99dfa..d6381fba 100644
--- a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/DnsSetting.cs
+++ b/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/DnsSetting.cs
@@ -14,8 +14,17 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.Types
public DnsSetting(IPInterfaceProperties interfaceProperties)
{
IsDynamicDnsEnabled = interfaceProperties.IsDynamicDnsEnabled;
- PrimaryDns = new IpV4Address(interfaceProperties.DnsAddresses[0]);
- SecondaryDns = new IpV4Address(interfaceProperties.DnsAddresses[1]);
+
+ if (interfaceProperties.DnsAddresses.Count == 0)
+ {
+ PrimaryDns = new IpV4Address();
+ SecondaryDns = new IpV4Address();
+ }
+ else
+ {
+ PrimaryDns = new IpV4Address(interfaceProperties.DnsAddresses[0]);
+ SecondaryDns = new IpV4Address(interfaceProperties.DnsAddresses[interfaceProperties.DnsAddresses.Count > 1 ? 1 : 0]);
+ }
}
}
-}
+} \ No newline at end of file
diff --git a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/IpSettingData.cs b/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/IpSettingData.cs
new file mode 100644
index 00000000..8ffe824c
--- /dev/null
+++ b/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/IpSettingData.cs
@@ -0,0 +1,13 @@
+using System.Runtime.InteropServices;
+
+namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.Types
+{
+ [StructLayout(LayoutKind.Sequential, Pack = 1, Size = 0xc2)]
+ struct IpSettingData
+ {
+ public IpAddressSetting IpAddressSetting;
+ public DnsSetting DnsSetting;
+ public ProxySetting ProxySetting;
+ public short Mtu;
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/NetworkProfileData.cs b/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/NetworkProfileData.cs
new file mode 100644
index 00000000..3c86aed5
--- /dev/null
+++ b/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/NetworkProfileData.cs
@@ -0,0 +1,17 @@
+using Ryujinx.Common.Memory;
+using Ryujinx.HLE.Utilities;
+using System.Runtime.InteropServices;
+
+namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.Types
+{
+ [StructLayout(LayoutKind.Sequential, Pack = 1, Size = 0x17C)]
+ struct NetworkProfileData
+ {
+ public IpSettingData IpSettingData;
+ public UInt128 Uuid;
+ public Array64<byte> Name;
+ public Array4<byte> Unknown;
+ public WirelessSettingData WirelessSettingData;
+ public byte Padding;
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/ProxySetting.cs b/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/ProxySetting.cs
new file mode 100644
index 00000000..827520f1
--- /dev/null
+++ b/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/ProxySetting.cs
@@ -0,0 +1,27 @@
+using LibHac.Common;
+using Ryujinx.Common.Memory;
+using System;
+using System.Runtime.InteropServices;
+
+namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.Types
+{
+ [StructLayout(LayoutKind.Sequential, Pack = 1, Size = 0xaa)]
+ public struct ProxySetting
+ {
+ [MarshalAs(UnmanagedType.I1)]
+ public bool Enabled;
+ private byte _padding;
+ public short Port;
+ private NameStruct _name;
+ [MarshalAs(UnmanagedType.I1)]
+ public bool AutoAuthEnabled;
+ public Array32<byte> User;
+ public Array32<byte> Pass;
+ private byte _padding2;
+
+ [StructLayout(LayoutKind.Sequential, Size = 0x64)]
+ private struct NameStruct { }
+
+ public Span<byte> Name => SpanHelpers.AsSpan<NameStruct, byte>(ref _name);
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/WirelessSettingData.cs b/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/WirelessSettingData.cs
new file mode 100644
index 00000000..8aa122c7
--- /dev/null
+++ b/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/WirelessSettingData.cs
@@ -0,0 +1,15 @@
+using Ryujinx.Common.Memory;
+using System.Runtime.InteropServices;
+
+namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.Types
+{
+ [StructLayout(LayoutKind.Sequential, Pack = 1, Size = 0x65)]
+ struct WirelessSettingData
+ {
+ public byte SsidLength;
+ public Array32<byte> Ssid;
+ public Array3<byte> Unknown;
+ public Array64<byte> Passphrase1;
+ public byte Passphrase2;
+ }
+} \ No newline at end of file