ISslConnection.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. using Ryujinx.Common.Logging;
  2. using Ryujinx.HLE.HOS.Services.Ssl.Types;
  3. using System.Text;
  4. namespace Ryujinx.HLE.HOS.Services.Ssl.SslService
  5. {
  6. class ISslConnection : IpcService
  7. {
  8. public ISslConnection() { }
  9. [CommandHipc(0)]
  10. // SetSocketDescriptor(u32) -> u32
  11. public ResultCode SetSocketDescriptor(ServiceCtx context)
  12. {
  13. uint socketFd = context.RequestData.ReadUInt32();
  14. uint duplicateSocketFd = 0;
  15. context.ResponseData.Write(duplicateSocketFd);
  16. Logger.Stub?.PrintStub(LogClass.ServiceSsl, new { socketFd });
  17. return ResultCode.Success;
  18. }
  19. [CommandHipc(1)]
  20. // SetHostName(buffer<bytes, 5>)
  21. public ResultCode SetHostName(ServiceCtx context)
  22. {
  23. ulong hostNameDataPosition = context.Request.SendBuff[0].Position;
  24. ulong hostNameDataSize = context.Request.SendBuff[0].Size;
  25. byte[] hostNameData = new byte[hostNameDataSize];
  26. context.Memory.Read(hostNameDataPosition, hostNameData);
  27. string hostName = Encoding.ASCII.GetString(hostNameData).Trim('\0');
  28. Logger.Stub?.PrintStub(LogClass.ServiceSsl, new { hostName });
  29. return ResultCode.Success;
  30. }
  31. [CommandHipc(2)]
  32. // SetVerifyOption(nn::ssl::sf::VerifyOption)
  33. public ResultCode SetVerifyOption(ServiceCtx context)
  34. {
  35. VerifyOption verifyOption = (VerifyOption)context.RequestData.ReadUInt32();
  36. Logger.Stub?.PrintStub(LogClass.ServiceSsl, new { verifyOption });
  37. return ResultCode.Success;
  38. }
  39. [CommandHipc(3)]
  40. // SetIoMode(nn::ssl::sf::IoMode)
  41. public ResultCode SetIoMode(ServiceCtx context)
  42. {
  43. IoMode ioMode = (IoMode)context.RequestData.ReadUInt32();
  44. Logger.Stub?.PrintStub(LogClass.ServiceSsl, new { ioMode });
  45. return ResultCode.Success;
  46. }
  47. [CommandHipc(8)]
  48. // DoHandshake()
  49. public ResultCode DoHandshake(ServiceCtx context)
  50. {
  51. Logger.Stub?.PrintStub(LogClass.ServiceSsl);
  52. return ResultCode.Success;
  53. }
  54. [CommandHipc(11)]
  55. // Write(buffer<bytes, 5>) -> u32
  56. public ResultCode Write(ServiceCtx context)
  57. {
  58. ulong inputDataPosition = context.Request.SendBuff[0].Position;
  59. ulong inputDataSize = context.Request.SendBuff[0].Size;
  60. byte[] data = new byte[inputDataSize];
  61. context.Memory.Read(inputDataPosition, data);
  62. // NOTE: Tell the guest everything is transferred.
  63. uint transferredSize = (uint)inputDataSize;
  64. context.ResponseData.Write(transferredSize);
  65. Logger.Stub?.PrintStub(LogClass.ServiceSsl);
  66. return ResultCode.Success;
  67. }
  68. [CommandHipc(17)]
  69. // SetSessionCacheMode(nn::ssl::sf::SessionCacheMode)
  70. public ResultCode SetSessionCacheMode(ServiceCtx context)
  71. {
  72. SessionCacheMode sessionCacheMode = (SessionCacheMode)context.RequestData.ReadUInt32();
  73. Logger.Stub?.PrintStub(LogClass.ServiceSsl, new { sessionCacheMode });
  74. return ResultCode.Success;
  75. }
  76. [CommandHipc(22)]
  77. // SetOption(b8, nn::ssl::sf::OptionType)
  78. public ResultCode SetOption(ServiceCtx context)
  79. {
  80. bool optionEnabled = context.RequestData.ReadBoolean();
  81. OptionType optionType = (OptionType)context.RequestData.ReadUInt32();
  82. Logger.Stub?.PrintStub(LogClass.ServiceSsl, new { optionType, optionEnabled });
  83. return ResultCode.Success;
  84. }
  85. }
  86. }