NetworkInterface.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using Ryujinx.Common.Logging;
  2. using Ryujinx.HLE.HOS.Kernel.Threading;
  3. using Ryujinx.HLE.HOS.Services.Ldn.Types;
  4. using System.Net;
  5. namespace Ryujinx.HLE.HOS.Services.Ldn
  6. {
  7. internal class NetworkInterface
  8. {
  9. public ResultCode NifmState { get; set; }
  10. public KEvent StateChangeEvent { get; private set; }
  11. private NetworkState _state;
  12. public NetworkInterface(Horizon system)
  13. {
  14. // TODO(Ac_K): Determine where the internal state is set.
  15. NifmState = ResultCode.Success;
  16. StateChangeEvent = new KEvent(system.KernelContext);
  17. _state = NetworkState.None;
  18. }
  19. public ResultCode Initialize(int unknown, int version, IPAddress ipv4Address, IPAddress subnetMaskAddress)
  20. {
  21. // TODO(Ac_K): Call nn::nifm::InitializeSystem().
  22. // If the call failed, it returns the result code.
  23. // If the call succeed, it signal and clear an event then start a new thread named nn.ldn.NetworkInterfaceMonitor.
  24. Logger.Stub?.PrintStub(LogClass.ServiceLdn, new { version });
  25. // NOTE: Since we don't support ldn for now, we can return this following result code to make it disabled.
  26. return ResultCode.DeviceDisabled;
  27. }
  28. public ResultCode GetState(out NetworkState state)
  29. {
  30. // Return ResultCode.InvalidArgument if _state is null, doesn't occur in our case.
  31. state = _state;
  32. return ResultCode.Success;
  33. }
  34. public ResultCode Finalize()
  35. {
  36. // TODO(Ac_K): Finalize nifm service then kill the thread named nn.ldn.NetworkInterfaceMonitor.
  37. _state = NetworkState.None;
  38. StateChangeEvent.WritableEvent.Signal();
  39. StateChangeEvent.WritableEvent.Clear();
  40. Logger.Stub?.PrintStub(LogClass.ServiceLdn);
  41. return ResultCode.Success;
  42. }
  43. }
  44. }