Implement GetCurrentIpAddress()
...and stub GetCurrentNetworkProfile()
This commit is contained in:
parent
063fae50fe
commit
122f7fae5e
1 changed files with 32 additions and 2 deletions
|
@ -1,6 +1,9 @@
|
||||||
using Ryujinx.HLE.Logging;
|
using Ryujinx.HLE.Logging;
|
||||||
using Ryujinx.HLE.OsHle.Ipc;
|
using Ryujinx.HLE.OsHle.Ipc;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
namespace Ryujinx.HLE.OsHle.Services.Nifm
|
namespace Ryujinx.HLE.OsHle.Services.Nifm
|
||||||
{
|
{
|
||||||
|
@ -14,7 +17,9 @@ namespace Ryujinx.HLE.OsHle.Services.Nifm
|
||||||
{
|
{
|
||||||
m_Commands = new Dictionary<int, ServiceProcessRequest>()
|
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;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue