mirror of
https://github.com/GreemDev/Ryujinx.git
synced 2024-12-12 18:21:07 +01:00
a0720b5681
* Refactoring HOS folder structure Refactoring HOS folder structure: - Added some subfolders when needed (Following structure decided in private). - Added some `Types` folders when needed. - Little cleanup here and there. - Add services placeholders for every HOS services (close #766 and #753). * Remove Types namespaces
93 lines
3.0 KiB
C#
93 lines
3.0 KiB
C#
using Ryujinx.Common.Logging;
|
|
using Ryujinx.HLE.HOS.Services.Nifm.StaticService.GeneralService;
|
|
using System;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Net.NetworkInformation;
|
|
using System.Net.Sockets;
|
|
|
|
namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService
|
|
{
|
|
class IGeneralService : IpcService, IDisposable
|
|
{
|
|
private GeneralServiceDetail _generalServiceDetail;
|
|
|
|
public IGeneralService()
|
|
{
|
|
_generalServiceDetail = new GeneralServiceDetail
|
|
{
|
|
ClientId = GeneralServiceManager.Count,
|
|
IsAnyInternetRequestAccepted = true // NOTE: Why not accept any internet request?
|
|
};
|
|
|
|
GeneralServiceManager.Add(_generalServiceDetail);
|
|
}
|
|
|
|
[Command(1)]
|
|
// GetClientId() -> buffer<nn::nifm::ClientId, 0x1a, 4>
|
|
public ResultCode GetClientId(ServiceCtx context)
|
|
{
|
|
long position = context.Request.RecvListBuff[0].Position;
|
|
long size = context.Request.RecvListBuff[0].Size;
|
|
|
|
context.Memory.WriteInt32(position, _generalServiceDetail.ClientId);
|
|
|
|
return ResultCode.Success;
|
|
}
|
|
|
|
[Command(4)]
|
|
// CreateRequest(u32 version) -> object<nn::nifm::detail::IRequest>
|
|
public ResultCode CreateRequest(ServiceCtx context)
|
|
{
|
|
uint version = context.RequestData.ReadUInt32();
|
|
|
|
MakeObject(context, new IRequest(context.Device.System, version));
|
|
|
|
// Doesn't occur in our case.
|
|
// return ResultCode.ObjectIsNull;
|
|
|
|
Logger.PrintStub(LogClass.ServiceNifm, new { version });
|
|
|
|
return ResultCode.Success;
|
|
}
|
|
|
|
[Command(12)]
|
|
// GetCurrentIpAddress() -> nn::nifm::IpV4Address
|
|
public ResultCode GetCurrentIpAddress(ServiceCtx context)
|
|
{
|
|
if (!NetworkInterface.GetIsNetworkAvailable())
|
|
{
|
|
return ResultCode.NoInternetConnection;
|
|
}
|
|
|
|
IPHostEntry host = Dns.GetHostEntry(Dns.GetHostName());
|
|
|
|
IPAddress address = host.AddressList.FirstOrDefault(a => a.AddressFamily == AddressFamily.InterNetwork);
|
|
|
|
context.ResponseData.Write(BitConverter.ToUInt32(address.GetAddressBytes()));
|
|
|
|
Logger.PrintInfo(LogClass.ServiceNifm, $"Console's local IP is \"{address}\".");
|
|
|
|
return ResultCode.Success;
|
|
}
|
|
|
|
[Command(21)]
|
|
// IsAnyInternetRequestAccepted(buffer<nn::nifm::ClientId, 0x19, 4>) -> bool
|
|
public ResultCode IsAnyInternetRequestAccepted(ServiceCtx context)
|
|
{
|
|
long position = context.Request.PtrBuff[0].Position;
|
|
long size = context.Request.PtrBuff[0].Size;
|
|
|
|
int clientId = context.Memory.ReadInt32(position);
|
|
|
|
context.ResponseData.Write(GeneralServiceManager.Get(clientId).IsAnyInternetRequestAccepted);
|
|
|
|
return ResultCode.Success;
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
GeneralServiceManager.Remove(_generalServiceDetail.ClientId);
|
|
}
|
|
}
|
|
} |