aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Services/Ssl/SslService/ISslConnection.cs
blob: 24f3d066f46fb458d20a313ef6d50f46986d8757 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
using Ryujinx.Common.Logging;
using Ryujinx.HLE.HOS.Services.Ssl.Types;
using System.Text;

namespace Ryujinx.HLE.HOS.Services.Ssl.SslService
{
    class ISslConnection : IpcService
    {
        public ISslConnection() { }

        [CommandHipc(0)]
        // SetSocketDescriptor(u32) -> u32
        public ResultCode SetSocketDescriptor(ServiceCtx context)
        {
            uint socketFd          = context.RequestData.ReadUInt32();
            uint duplicateSocketFd = 0;

            context.ResponseData.Write(duplicateSocketFd);

            Logger.Stub?.PrintStub(LogClass.ServiceSsl, new { socketFd });

            return ResultCode.Success;
        }

        [CommandHipc(1)]
        // SetHostName(buffer<bytes, 5>)
        public ResultCode SetHostName(ServiceCtx context)
        {
            ulong hostNameDataPosition = context.Request.SendBuff[0].Position;
            ulong hostNameDataSize     = context.Request.SendBuff[0].Size;

            byte[] hostNameData = new byte[hostNameDataSize];

            context.Memory.Read(hostNameDataPosition, hostNameData);

            string hostName = Encoding.ASCII.GetString(hostNameData).Trim('\0');

            Logger.Stub?.PrintStub(LogClass.ServiceSsl, new { hostName });

            return ResultCode.Success;
        }

        [CommandHipc(2)]
        // SetVerifyOption(nn::ssl::sf::VerifyOption)
        public ResultCode SetVerifyOption(ServiceCtx context)
        {
            VerifyOption verifyOption = (VerifyOption)context.RequestData.ReadUInt32();

            Logger.Stub?.PrintStub(LogClass.ServiceSsl, new { verifyOption });

            return ResultCode.Success;
        }

        [CommandHipc(3)]
        // SetIoMode(nn::ssl::sf::IoMode)
        public ResultCode SetIoMode(ServiceCtx context)
        {
            IoMode ioMode = (IoMode)context.RequestData.ReadUInt32();

            Logger.Stub?.PrintStub(LogClass.ServiceSsl, new { ioMode });

            return ResultCode.Success;
        }

        [CommandHipc(8)]
        // DoHandshake()
        public ResultCode DoHandshake(ServiceCtx context)
        {
            Logger.Stub?.PrintStub(LogClass.ServiceSsl);

            return ResultCode.Success;
        }

        [CommandHipc(11)]
        // Write(buffer<bytes, 5>) -> u32
        public ResultCode Write(ServiceCtx context)
        {
            ulong inputDataPosition = context.Request.SendBuff[0].Position;
            ulong inputDataSize     = context.Request.SendBuff[0].Size;

            byte[] data = new byte[inputDataSize];

            context.Memory.Read(inputDataPosition, data);

            // NOTE: Tell the guest everything is transferred.
            uint transferredSize = (uint)inputDataSize;

            context.ResponseData.Write(transferredSize);

            Logger.Stub?.PrintStub(LogClass.ServiceSsl);

            return ResultCode.Success;
        }

        [CommandHipc(17)]
        // SetSessionCacheMode(nn::ssl::sf::SessionCacheMode)
        public ResultCode SetSessionCacheMode(ServiceCtx context)
        {
            SessionCacheMode sessionCacheMode = (SessionCacheMode)context.RequestData.ReadUInt32();

            Logger.Stub?.PrintStub(LogClass.ServiceSsl, new { sessionCacheMode });

            return ResultCode.Success;
        }

        [CommandHipc(22)]
        // SetOption(b8, nn::ssl::sf::OptionType)
        public ResultCode SetOption(ServiceCtx context)
        {
            bool       optionEnabled = context.RequestData.ReadBoolean();
            OptionType optionType    = (OptionType)context.RequestData.ReadUInt32();

            Logger.Stub?.PrintStub(LogClass.ServiceSsl, new { optionType, optionEnabled });

            return ResultCode.Success;
        }
    }
}