Implement GetCurrentIpAddress()

...and stub GetCurrentNetworkProfile()
This commit is contained in:
simonmkwii-dev 2018-07-15 20:51:54 +10:00 committed by GitHub
parent 063fae50fe
commit 122f7fae5e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,9 @@
using Ryujinx.HLE.Logging;
using Ryujinx.HLE.OsHle.Ipc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
namespace Ryujinx.HLE.OsHle.Services.Nifm
{
@ -14,7 +17,9 @@ namespace Ryujinx.HLE.OsHle.Services.Nifm
{
m_Commands = new Dictionary<int, ServiceProcessRequest>()
{
{ 4, CreateRequest }
{ 4, CreateRequest },
{ 5, GetCurrentNetworkProfile },
{ 12, GetCurrentIpAddress }
};
}
@ -29,5 +34,30 @@ namespace Ryujinx.HLE.OsHle.Services.Nifm
return 0;
}
public long GetCurrentNetworkProfile(ServiceCtx Context)
{
Context.Ns.Log.PrintStub(LogClass.ServiceNifm, "Stubbed.");
return 0;
}
public long GetCurrentIpAddress(ServiceCtx Context)
{
string HostName = Dns.GetHostName();
IPHostEntry HostEntry = Dns.GetHostEntry(HostName);
IPAddress[] Address = HostEntry.AddressList;
var IP = Address.Where(x => x.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork).FirstOrDefault();
Console.WriteLine(IP.ToString());
string BEHexStr = string.Concat(IP.ToString().Split('.').Select(x => int.Parse(x).ToString("X2")));
uint BENum = Convert.ToUInt32(BEHexStr, 16);
byte[] Bytes = BitConverter.GetBytes(BENum);
string LENum = "";
foreach (byte b in Bytes)
LENum += b.ToString("X2");
uint LocalIP = System.Convert.ToUInt32(LENum, 16);
MakeObject(Context, new IRequest());
return LocalIP;
}
}
}
}