aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Services/Bsd/IClient.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx.HLE/HOS/Services/Bsd/IClient.cs')
-rw-r--r--Ryujinx.HLE/HOS/Services/Bsd/IClient.cs959
1 files changed, 480 insertions, 479 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Bsd/IClient.cs b/Ryujinx.HLE/HOS/Services/Bsd/IClient.cs
index aac85021..37d0fcfd 100644
--- a/Ryujinx.HLE/HOS/Services/Bsd/IClient.cs
+++ b/Ryujinx.HLE/HOS/Services/Bsd/IClient.cs
@@ -11,101 +11,101 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
class IClient : IpcService
{
- private static Dictionary<WsaError, LinuxError> _errorMap = new Dictionary<WsaError, LinuxError>
+ private static Dictionary<WSAError, LinuxError> ErrorMap = new Dictionary<WSAError, LinuxError>
{
// WSAEINTR
- {WsaError.WSAEINTR, LinuxError.EINTR},
+ {WSAError.WSAEINTR, LinuxError.EINTR},
// WSAEWOULDBLOCK
- {WsaError.WSAEWOULDBLOCK, LinuxError.EWOULDBLOCK},
+ {WSAError.WSAEWOULDBLOCK, LinuxError.EWOULDBLOCK},
// WSAEINPROGRESS
- {WsaError.WSAEINPROGRESS, LinuxError.EINPROGRESS},
+ {WSAError.WSAEINPROGRESS, LinuxError.EINPROGRESS},
// WSAEALREADY
- {WsaError.WSAEALREADY, LinuxError.EALREADY},
+ {WSAError.WSAEALREADY, LinuxError.EALREADY},
// WSAENOTSOCK
- {WsaError.WSAENOTSOCK, LinuxError.ENOTSOCK},
+ {WSAError.WSAENOTSOCK, LinuxError.ENOTSOCK},
// WSAEDESTADDRREQ
- {WsaError.WSAEDESTADDRREQ, LinuxError.EDESTADDRREQ},
+ {WSAError.WSAEDESTADDRREQ, LinuxError.EDESTADDRREQ},
// WSAEMSGSIZE
- {WsaError.WSAEMSGSIZE, LinuxError.EMSGSIZE},
+ {WSAError.WSAEMSGSIZE, LinuxError.EMSGSIZE},
// WSAEPROTOTYPE
- {WsaError.WSAEPROTOTYPE, LinuxError.EPROTOTYPE},
+ {WSAError.WSAEPROTOTYPE, LinuxError.EPROTOTYPE},
// WSAENOPROTOOPT
- {WsaError.WSAENOPROTOOPT, LinuxError.ENOPROTOOPT},
+ {WSAError.WSAENOPROTOOPT, LinuxError.ENOPROTOOPT},
// WSAEPROTONOSUPPORT
- {WsaError.WSAEPROTONOSUPPORT, LinuxError.EPROTONOSUPPORT},
+ {WSAError.WSAEPROTONOSUPPORT, LinuxError.EPROTONOSUPPORT},
// WSAESOCKTNOSUPPORT
- {WsaError.WSAESOCKTNOSUPPORT, LinuxError.ESOCKTNOSUPPORT},
+ {WSAError.WSAESOCKTNOSUPPORT, LinuxError.ESOCKTNOSUPPORT},
// WSAEOPNOTSUPP
- {WsaError.WSAEOPNOTSUPP, LinuxError.EOPNOTSUPP},
+ {WSAError.WSAEOPNOTSUPP, LinuxError.EOPNOTSUPP},
// WSAEPFNOSUPPORT
- {WsaError.WSAEPFNOSUPPORT, LinuxError.EPFNOSUPPORT},
+ {WSAError.WSAEPFNOSUPPORT, LinuxError.EPFNOSUPPORT},
// WSAEAFNOSUPPORT
- {WsaError.WSAEAFNOSUPPORT, LinuxError.EAFNOSUPPORT},
+ {WSAError.WSAEAFNOSUPPORT, LinuxError.EAFNOSUPPORT},
// WSAEADDRINUSE
- {WsaError.WSAEADDRINUSE, LinuxError.EADDRINUSE},
+ {WSAError.WSAEADDRINUSE, LinuxError.EADDRINUSE},
// WSAEADDRNOTAVAIL
- {WsaError.WSAEADDRNOTAVAIL, LinuxError.EADDRNOTAVAIL},
+ {WSAError.WSAEADDRNOTAVAIL, LinuxError.EADDRNOTAVAIL},
// WSAENETDOWN
- {WsaError.WSAENETDOWN, LinuxError.ENETDOWN},
+ {WSAError.WSAENETDOWN, LinuxError.ENETDOWN},
// WSAENETUNREACH
- {WsaError.WSAENETUNREACH, LinuxError.ENETUNREACH},
+ {WSAError.WSAENETUNREACH, LinuxError.ENETUNREACH},
// WSAENETRESET
- {WsaError.WSAENETRESET, LinuxError.ENETRESET},
+ {WSAError.WSAENETRESET, LinuxError.ENETRESET},
// WSAECONNABORTED
- {WsaError.WSAECONNABORTED, LinuxError.ECONNABORTED},
+ {WSAError.WSAECONNABORTED, LinuxError.ECONNABORTED},
// WSAECONNRESET
- {WsaError.WSAECONNRESET, LinuxError.ECONNRESET},
+ {WSAError.WSAECONNRESET, LinuxError.ECONNRESET},
// WSAENOBUFS
- {WsaError.WSAENOBUFS, LinuxError.ENOBUFS},
+ {WSAError.WSAENOBUFS, LinuxError.ENOBUFS},
// WSAEISCONN
- {WsaError.WSAEISCONN, LinuxError.EISCONN},
+ {WSAError.WSAEISCONN, LinuxError.EISCONN},
// WSAENOTCONN
- {WsaError.WSAENOTCONN, LinuxError.ENOTCONN},
+ {WSAError.WSAENOTCONN, LinuxError.ENOTCONN},
// WSAESHUTDOWN
- {WsaError.WSAESHUTDOWN, LinuxError.ESHUTDOWN},
+ {WSAError.WSAESHUTDOWN, LinuxError.ESHUTDOWN},
// WSAETOOMANYREFS
- {WsaError.WSAETOOMANYREFS, LinuxError.ETOOMANYREFS},
+ {WSAError.WSAETOOMANYREFS, LinuxError.ETOOMANYREFS},
// WSAETIMEDOUT
- {WsaError.WSAETIMEDOUT, LinuxError.ETIMEDOUT},
+ {WSAError.WSAETIMEDOUT, LinuxError.ETIMEDOUT},
// WSAECONNREFUSED
- {WsaError.WSAECONNREFUSED, LinuxError.ECONNREFUSED},
+ {WSAError.WSAECONNREFUSED, LinuxError.ECONNREFUSED},
// WSAELOOP
- {WsaError.WSAELOOP, LinuxError.ELOOP},
+ {WSAError.WSAELOOP, LinuxError.ELOOP},
// WSAENAMETOOLONG
- {WsaError.WSAENAMETOOLONG, LinuxError.ENAMETOOLONG},
+ {WSAError.WSAENAMETOOLONG, LinuxError.ENAMETOOLONG},
// WSAEHOSTDOWN
- {WsaError.WSAEHOSTDOWN, LinuxError.EHOSTDOWN},
+ {WSAError.WSAEHOSTDOWN, LinuxError.EHOSTDOWN},
// WSAEHOSTUNREACH
- {WsaError.WSAEHOSTUNREACH, LinuxError.EHOSTUNREACH},
+ {WSAError.WSAEHOSTUNREACH, LinuxError.EHOSTUNREACH},
// WSAENOTEMPTY
- {WsaError.WSAENOTEMPTY, LinuxError.ENOTEMPTY},
+ {WSAError.WSAENOTEMPTY, LinuxError.ENOTEMPTY},
// WSAEUSERS
- {WsaError.WSAEUSERS, LinuxError.EUSERS},
+ {WSAError.WSAEUSERS, LinuxError.EUSERS},
// WSAEDQUOT
- {WsaError.WSAEDQUOT, LinuxError.EDQUOT},
+ {WSAError.WSAEDQUOT, LinuxError.EDQUOT},
// WSAESTALE
- {WsaError.WSAESTALE, LinuxError.ESTALE},
+ {WSAError.WSAESTALE, LinuxError.ESTALE},
// WSAEREMOTE
- {WsaError.WSAEREMOTE, LinuxError.EREMOTE},
+ {WSAError.WSAEREMOTE, LinuxError.EREMOTE},
// WSAEINVAL
- {WsaError.WSAEINVAL, LinuxError.EINVAL},
+ {WSAError.WSAEINVAL, LinuxError.EINVAL},
// WSAEFAULT
- {WsaError.WSAEFAULT, LinuxError.EFAULT},
+ {WSAError.WSAEFAULT, LinuxError.EFAULT},
// NOERROR
{0, 0}
};
- private Dictionary<int, ServiceProcessRequest> _commands;
+ private Dictionary<int, ServiceProcessRequest> m_Commands;
- public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
+ public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
- private bool _isPrivileged;
+ private bool IsPrivileged;
- private List<BsdSocket> _sockets = new List<BsdSocket>();
+ private List<BsdSocket> Sockets = new List<BsdSocket>();
- public IClient(bool isPrivileged)
+ public IClient(bool IsPrivileged)
{
- _commands = new Dictionary<int, ServiceProcessRequest>
+ m_Commands = new Dictionary<int, ServiceProcessRequest>()
{
{ 0, RegisterClient },
{ 1, StartMonitoring },
@@ -134,60 +134,60 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
{ 24, Write },
{ 25, Read },
{ 26, Close },
- { 27, DuplicateSocket }
+ { 27, DuplicateSocket },
};
- _isPrivileged = isPrivileged;
+ this.IsPrivileged = IsPrivileged;
}
- private LinuxError ConvertError(WsaError errorCode)
+ private LinuxError ConvertError(WSAError ErrorCode)
{
- LinuxError errno;
+ LinuxError Errno;
- if (!_errorMap.TryGetValue(errorCode, out errno))
+ if (!ErrorMap.TryGetValue(ErrorCode, out Errno))
{
- errno = (LinuxError)errorCode;
+ Errno = (LinuxError)ErrorCode;
}
- return errno;
+ return Errno;
}
- private long WriteWinSock2Error(ServiceCtx context, WsaError errorCode)
+ private long WriteWinSock2Error(ServiceCtx Context, WSAError ErrorCode)
{
- return WriteBsdResult(context, -1, ConvertError(errorCode));
+ return WriteBsdResult(Context, -1, ConvertError(ErrorCode));
}
- private long WriteBsdResult(ServiceCtx context, int result, LinuxError errorCode = 0)
+ private long WriteBsdResult(ServiceCtx Context, int Result, LinuxError ErrorCode = 0)
{
- if (errorCode != LinuxError.SUCCESS)
+ if (ErrorCode != LinuxError.SUCCESS)
{
- result = -1;
+ Result = -1;
}
- context.ResponseData.Write(result);
- context.ResponseData.Write((int)errorCode);
+ Context.ResponseData.Write(Result);
+ Context.ResponseData.Write((int)ErrorCode);
return 0;
}
- private BsdSocket RetrieveSocket(int socketFd)
+ private BsdSocket RetrieveSocket(int SocketFd)
{
- if (socketFd >= 0 && _sockets.Count > socketFd)
+ if (SocketFd >= 0 && Sockets.Count > SocketFd)
{
- return _sockets[socketFd];
+ return Sockets[SocketFd];
}
return null;
}
- private LinuxError SetResultErrno(Socket socket, int result)
+ private LinuxError SetResultErrno(Socket Socket, int Result)
{
- return result == 0 && !socket.Blocking ? LinuxError.EWOULDBLOCK : LinuxError.SUCCESS;
+ return Result == 0 && !Socket.Blocking ? LinuxError.EWOULDBLOCK : LinuxError.SUCCESS;
}
- private AddressFamily ConvertFromBsd(int domain)
+ private AddressFamily ConvertFromBsd(int Domain)
{
- if (domain == 2)
+ if (Domain == 2)
{
return AddressFamily.InterNetwork;
}
@@ -196,70 +196,70 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
return AddressFamily.Unknown;
}
- private long SocketInternal(ServiceCtx context, bool exempt)
+ private long SocketInternal(ServiceCtx Context, bool Exempt)
{
- AddressFamily domain = (AddressFamily)context.RequestData.ReadInt32();
- SocketType type = (SocketType)context.RequestData.ReadInt32();
- ProtocolType protocol = (ProtocolType)context.RequestData.ReadInt32();
+ AddressFamily Domain = (AddressFamily)Context.RequestData.ReadInt32();
+ SocketType Type = (SocketType)Context.RequestData.ReadInt32();
+ ProtocolType Protocol = (ProtocolType)Context.RequestData.ReadInt32();
- if (domain == AddressFamily.Unknown)
+ if (Domain == AddressFamily.Unknown)
{
- return WriteBsdResult(context, -1, LinuxError.EPROTONOSUPPORT);
+ return WriteBsdResult(Context, -1, LinuxError.EPROTONOSUPPORT);
}
- else if ((type == SocketType.Seqpacket || type == SocketType.Raw) && !_isPrivileged)
+ else if ((Type == SocketType.Seqpacket || Type == SocketType.Raw) && !IsPrivileged)
{
- if (domain != AddressFamily.InterNetwork || type != SocketType.Raw || protocol != ProtocolType.Icmp)
+ if (Domain != AddressFamily.InterNetwork || Type != SocketType.Raw || Protocol != ProtocolType.Icmp)
{
- return WriteBsdResult(context, -1, LinuxError.ENOENT);
+ return WriteBsdResult(Context, -1, LinuxError.ENOENT);
}
}
- BsdSocket newBsdSocket = new BsdSocket
+ BsdSocket NewBsdSocket = new BsdSocket
{
- Family = (int)domain,
- Type = (int)type,
- Protocol = (int)protocol,
- Handle = new Socket(domain, type, protocol)
+ Family = (int)Domain,
+ Type = (int)Type,
+ Protocol = (int)Protocol,
+ Handle = new Socket(Domain, Type, Protocol)
};
- _sockets.Add(newBsdSocket);
+ Sockets.Add(NewBsdSocket);
- if (exempt)
+ if (Exempt)
{
- newBsdSocket.Handle.Disconnect(true);
+ NewBsdSocket.Handle.Disconnect(true);
}
- return WriteBsdResult(context, _sockets.Count - 1);
+ return WriteBsdResult(Context, Sockets.Count - 1);
}
- private IPEndPoint ParseSockAddr(ServiceCtx context, long bufferPosition, long bufferSize)
+ private IPEndPoint ParseSockAddr(ServiceCtx Context, long BufferPosition, long BufferSize)
{
- int size = context.Memory.ReadByte(bufferPosition);
- int family = context.Memory.ReadByte(bufferPosition + 1);
- int port = EndianSwap.Swap16(context.Memory.ReadUInt16(bufferPosition + 2));
+ int Size = Context.Memory.ReadByte(BufferPosition);
+ int Family = Context.Memory.ReadByte(BufferPosition + 1);
+ int Port = EndianSwap.Swap16(Context.Memory.ReadUInt16(BufferPosition + 2));
- byte[] rawIp = context.Memory.ReadBytes(bufferPosition + 4, 4);
+ byte[] RawIp = Context.Memory.ReadBytes(BufferPosition + 4, 4);
- return new IPEndPoint(new IPAddress(rawIp), port);
+ return new IPEndPoint(new IPAddress(RawIp), Port);
}
- private void WriteSockAddr(ServiceCtx context, long bufferPosition, IPEndPoint endPoint)
+ private void WriteSockAddr(ServiceCtx Context, long BufferPosition, IPEndPoint EndPoint)
{
- context.Memory.WriteByte(bufferPosition, 0);
- context.Memory.WriteByte(bufferPosition + 1, (byte)endPoint.AddressFamily);
- context.Memory.WriteUInt16(bufferPosition + 2, EndianSwap.Swap16((ushort)endPoint.Port));
- context.Memory.WriteBytes(bufferPosition + 4, endPoint.Address.GetAddressBytes());
+ Context.Memory.WriteByte(BufferPosition, 0);
+ Context.Memory.WriteByte(BufferPosition + 1, (byte)EndPoint.AddressFamily);
+ Context.Memory.WriteUInt16(BufferPosition + 2, EndianSwap.Swap16((ushort)EndPoint.Port));
+ Context.Memory.WriteBytes(BufferPosition + 4, EndPoint.Address.GetAddressBytes());
}
- private void WriteSockAddr(ServiceCtx context, long bufferPosition, BsdSocket socket, bool isRemote)
+ private void WriteSockAddr(ServiceCtx Context, long BufferPosition, BsdSocket Socket, bool IsRemote)
{
- IPEndPoint endPoint = (isRemote ? socket.Handle.RemoteEndPoint : socket.Handle.LocalEndPoint) as IPEndPoint;
+ IPEndPoint EndPoint = (IsRemote ? Socket.Handle.RemoteEndPoint : Socket.Handle.LocalEndPoint) as IPEndPoint;
- WriteSockAddr(context, bufferPosition, endPoint);
+ WriteSockAddr(Context, BufferPosition, EndPoint);
}
// Initialize(nn::socket::BsdBufferConfig config, u64 pid, u64 transferMemorySize, KObject<copy, transfer_memory>, pid) -> u32 bsd_errno
- public long RegisterClient(ServiceCtx context)
+ public long RegisterClient(ServiceCtx Context)
{
/*
typedef struct {
@@ -275,7 +275,7 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
*/
// bsd_error
- context.ResponseData.Write(0);
+ Context.ResponseData.Write(0);
Logger.PrintStub(LogClass.ServiceBsd, "Stubbed.");
@@ -283,49 +283,49 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
}
// StartMonitoring(u64, pid)
- public long StartMonitoring(ServiceCtx context)
+ public long StartMonitoring(ServiceCtx Context)
{
- ulong unknown0 = context.RequestData.ReadUInt64();
+ ulong Unknown0 = Context.RequestData.ReadUInt64();
- Logger.PrintStub(LogClass.ServiceBsd, $"Stubbed. Unknown0: {unknown0}");
+ Logger.PrintStub(LogClass.ServiceBsd, $"Stubbed. Unknown0: {Unknown0}");
return 0;
}
// Socket(u32 domain, u32 type, u32 protocol) -> (i32 ret, u32 bsd_errno)
- public long Socket(ServiceCtx context)
+ public long Socket(ServiceCtx Context)
{
- return SocketInternal(context, false);
+ return SocketInternal(Context, false);
}
// SocketExempt(u32 domain, u32 type, u32 protocol) -> (i32 ret, u32 bsd_errno)
- public long SocketExempt(ServiceCtx context)
+ public long SocketExempt(ServiceCtx Context)
{
- return SocketInternal(context, true);
+ return SocketInternal(Context, true);
}
// Open(u32 flags, array<unknown, 0x21> path) -> (i32 ret, u32 bsd_errno)
- public long Open(ServiceCtx context)
+ public long Open(ServiceCtx Context)
{
- (long bufferPosition, long bufferSize) = context.Request.GetBufferType0x21();
+ (long BufferPosition, long BufferSize) = Context.Request.GetBufferType0x21();
- int flags = context.RequestData.ReadInt32();
+ int Flags = Context.RequestData.ReadInt32();
- byte[] rawPath = context.Memory.ReadBytes(bufferPosition, bufferSize);
- string path = Encoding.ASCII.GetString(rawPath);
+ byte[] RawPath = Context.Memory.ReadBytes(BufferPosition, BufferSize);
+ string Path = Encoding.ASCII.GetString(RawPath);
- WriteBsdResult(context, -1, LinuxError.EOPNOTSUPP);
+ WriteBsdResult(Context, -1, LinuxError.EOPNOTSUPP);
- Logger.PrintStub(LogClass.ServiceBsd, $"Stubbed. Path: {path} - " +
- $"Flags: {flags}");
+ Logger.PrintStub(LogClass.ServiceBsd, $"Stubbed. Path: {Path} - " +
+ $"Flags: {Flags}");
return 0;
}
// Select(u32 nfds, nn::socket::timeout timeout, buffer<nn::socket::fd_set, 0x21, 0> readfds_in, buffer<nn::socket::fd_set, 0x21, 0> writefds_in, buffer<nn::socket::fd_set, 0x21, 0> errorfds_in) -> (i32 ret, u32 bsd_errno, buffer<nn::socket::fd_set, 0x22, 0> readfds_out, buffer<nn::socket::fd_set, 0x22, 0> writefds_out, buffer<nn::socket::fd_set, 0x22, 0> errorfds_out)
- public long Select(ServiceCtx context)
+ public long Select(ServiceCtx Context)
{
- WriteBsdResult(context, -1, LinuxError.EOPNOTSUPP);
+ WriteBsdResult(Context, -1, LinuxError.EOPNOTSUPP);
Logger.PrintStub(LogClass.ServiceBsd, $"Stubbed.");
@@ -333,134 +333,135 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
}
// Poll(u32 nfds, u32 timeout, buffer<unknown, 0x21, 0> fds) -> (i32 ret, u32 bsd_errno, buffer<unknown, 0x22, 0>)
- public long Poll(ServiceCtx context)
+ public long Poll(ServiceCtx Context)
{
- int fdsCount = context.RequestData.ReadInt32();
- int timeout = context.RequestData.ReadInt32();
+ int FdsCount = Context.RequestData.ReadInt32();
+ int Timeout = Context.RequestData.ReadInt32();
- (long bufferPosition, long bufferSize) = context.Request.GetBufferType0x21();
+ (long BufferPosition, long BufferSize) = Context.Request.GetBufferType0x21();
- if (timeout < -1 || fdsCount < 0 || (fdsCount * 8) > bufferSize)
+ if (Timeout < -1 || FdsCount < 0 || (FdsCount * 8) > BufferSize)
{
- return WriteBsdResult(context, -1, LinuxError.EINVAL);
+ return WriteBsdResult(Context, -1, LinuxError.EINVAL);
}
- PollEvent[] events = new PollEvent[fdsCount];
+ PollEvent[] Events = new PollEvent[FdsCount];
- for (int i = 0; i < fdsCount; i++)
+ for (int i = 0; i < FdsCount; i++)
{
- int socketFd = context.Memory.ReadInt32(bufferPosition + i * 8);
+ int SocketFd = Context.Memory.ReadInt32(BufferPosition + i * 8);
- BsdSocket socket = RetrieveSocket(socketFd);
+ BsdSocket Socket = RetrieveSocket(SocketFd);
- if (socket == null)
+ if (Socket == null)
{
- return WriteBsdResult(context, -1, LinuxError.EBADF);}
+ return WriteBsdResult(Context, -1, LinuxError.EBADF);
+ }
- PollEvent.EventTypeMask inputEvents = (PollEvent.EventTypeMask)context.Memory.ReadInt16(bufferPosition + i * 8 + 4);
- PollEvent.EventTypeMask outputEvents = (PollEvent.EventTypeMask)context.Memory.ReadInt16(bufferPosition + i * 8 + 6);
+ PollEvent.EventTypeMask InputEvents = (PollEvent.EventTypeMask)Context.Memory.ReadInt16(BufferPosition + i * 8 + 4);
+ PollEvent.EventTypeMask OutputEvents = (PollEvent.EventTypeMask)Context.Memory.ReadInt16(BufferPosition + i * 8 + 6);
- events[i] = new PollEvent(socketFd, socket, inputEvents, outputEvents);
+ Events[i] = new PollEvent(SocketFd, Socket, InputEvents, OutputEvents);
}
- List<Socket> readEvents = new List<Socket>();
- List<Socket> writeEvents = new List<Socket>();
- List<Socket> errorEvents = new List<Socket>();
+ List<Socket> ReadEvents = new List<Socket>();
+ List<Socket> WriteEvents = new List<Socket>();
+ List<Socket> ErrorEvents = new List<Socket>();
- foreach (PollEvent Event in events)
+ foreach (PollEvent Event in Events)
{
- bool isValidEvent = false;
+ bool IsValidEvent = false;
if ((Event.InputEvents & PollEvent.EventTypeMask.Input) != 0)
{
- readEvents.Add(Event.Socket.Handle);
- errorEvents.Add(Event.Socket.Handle);
+ ReadEvents.Add(Event.Socket.Handle);
+ ErrorEvents.Add(Event.Socket.Handle);
- isValidEvent = true;
+ IsValidEvent = true;
}
if ((Event.InputEvents & PollEvent.EventTypeMask.UrgentInput) != 0)
{
- readEvents.Add(Event.Socket.Handle);
- errorEvents.Add(Event.Socket.Handle);
+ ReadEvents.Add(Event.Socket.Handle);
+ ErrorEvents.Add(Event.Socket.Handle);
- isValidEvent = true;
+ IsValidEvent = true;
}
if ((Event.InputEvents & PollEvent.EventTypeMask.Output) != 0)
{
- writeEvents.Add(Event.Socket.Handle);
- errorEvents.Add(Event.Socket.Handle);
+ WriteEvents.Add(Event.Socket.Handle);
+ ErrorEvents.Add(Event.Socket.Handle);
- isValidEvent = true;
+ IsValidEvent = true;
}
if ((Event.InputEvents & PollEvent.EventTypeMask.Error) != 0)
{
- errorEvents.Add(Event.Socket.Handle);
- isValidEvent = true;
+ ErrorEvents.Add(Event.Socket.Handle);
+ IsValidEvent = true;
}
- if (!isValidEvent)
+ if (!IsValidEvent)
{
Logger.PrintWarning(LogClass.ServiceBsd, $"Unsupported Poll input event type: {Event.InputEvents}");
- return WriteBsdResult(context, -1, LinuxError.EINVAL);
+ return WriteBsdResult(Context, -1, LinuxError.EINVAL);
}
}
try
{
- System.Net.Sockets.Socket.Select(readEvents, writeEvents, errorEvents, timeout);
+ System.Net.Sockets.Socket.Select(ReadEvents, WriteEvents, ErrorEvents, Timeout);
}
- catch (SocketException exception)
+ catch (SocketException Exception)
{
- return WriteWinSock2Error(context, (WsaError)exception.ErrorCode);
+ return WriteWinSock2Error(Context, (WSAError)Exception.ErrorCode);
}
- for (int i = 0; i < fdsCount; i++)
+ for (int i = 0; i < FdsCount; i++)
{
- PollEvent Event = events[i];
- context.Memory.WriteInt32(bufferPosition + i * 8, Event.SocketFd);
- context.Memory.WriteInt16(bufferPosition + i * 8 + 4, (short)Event.InputEvents);
+ PollEvent Event = Events[i];
+ Context.Memory.WriteInt32(BufferPosition + i * 8, Event.SocketFd);
+ Context.Memory.WriteInt16(BufferPosition + i * 8 + 4, (short)Event.InputEvents);
- PollEvent.EventTypeMask outputEvents = 0;
+ PollEvent.EventTypeMask OutputEvents = 0;
- Socket socket = Event.Socket.Handle;
+ Socket Socket = Event.Socket.Handle;
- if (errorEvents.Contains(socket))
+ if (ErrorEvents.Contains(Socket))
{
- outputEvents |= PollEvent.EventTypeMask.Error;
+ OutputEvents |= PollEvent.EventTypeMask.Error;
- if (!socket.Connected || !socket.IsBound)
+ if (!Socket.Connected || !Socket.IsBound)
{
- outputEvents |= PollEvent.EventTypeMask.Disconnected;
+ OutputEvents |= PollEvent.EventTypeMask.Disconnected;
}
}
- if (readEvents.Contains(socket))
+ if (ReadEvents.Contains(Socket))
{
if ((Event.InputEvents & PollEvent.EventTypeMask.Input) != 0)
{
- outputEvents |= PollEvent.EventTypeMask.Input;
+ OutputEvents |= PollEvent.EventTypeMask.Input;
}
}
- if (writeEvents.Contains(socket))
+ if (WriteEvents.Contains(Socket))
{
- outputEvents |= PollEvent.EventTypeMask.Output;
+ OutputEvents |= PollEvent.EventTypeMask.Output;
}
- context.Memory.WriteInt16(bufferPosition + i * 8 + 6, (short)outputEvents);
+ Context.Memory.WriteInt16(BufferPosition + i * 8 + 6, (short)OutputEvents);
}
- return WriteBsdResult(context, readEvents.Count + writeEvents.Count + errorEvents.Count, LinuxError.SUCCESS);
+ return WriteBsdResult(Context, ReadEvents.Count + WriteEvents.Count + ErrorEvents.Count, LinuxError.SUCCESS);
}
// Sysctl(buffer<unknown, 0x21, 0>, buffer<unknown, 0x21, 0>) -> (i32 ret, u32 bsd_errno, u32, buffer<unknown, 0x22, 0>)
- public long Sysctl(ServiceCtx context)
+ public long Sysctl(ServiceCtx Context)
{
- WriteBsdResult(context, -1, LinuxError.EOPNOTSUPP);
+ WriteBsdResult(Context, -1, LinuxError.EOPNOTSUPP);
Logger.PrintStub(LogClass.ServiceBsd, $"Stubbed.");
@@ -468,452 +469,452 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
}
// Recv(u32 socket, u32 flags) -> (i32 ret, u32 bsd_errno, array<i8, 0x22> message)
- public long Recv(ServiceCtx context)
+ public long Recv(ServiceCtx Context)
{
- int socketFd = context.RequestData.ReadInt32();
- SocketFlags socketFlags = (SocketFlags)context.RequestData.ReadInt32();
+ int SocketFd = Context.RequestData.ReadInt32();
+ SocketFlags SocketFlags = (SocketFlags)Context.RequestData.ReadInt32();
- (long receivePosition, long receiveLength) = context.Request.GetBufferType0x22();
+ (long ReceivePosition, long ReceiveLength) = Context.Request.GetBufferType0x22();
- LinuxError errno = LinuxError.EBADF;
- BsdSocket socket = RetrieveSocket(socketFd);
- int result = -1;
+ LinuxError Errno = LinuxError.EBADF;
+ BsdSocket Socket = RetrieveSocket(SocketFd);
+ int Result = -1;
- if (socket != null)
+ if (Socket != null)
{
- if (socketFlags != SocketFlags.None && (socketFlags & SocketFlags.OutOfBand) == 0
- && (socketFlags & SocketFlags.Peek) == 0)
+ if (SocketFlags != SocketFlags.None && (SocketFlags & SocketFlags.OutOfBand) == 0
+ && (SocketFlags & SocketFlags.Peek) == 0)
{
- Logger.PrintWarning(LogClass.ServiceBsd, $"Unsupported Recv flags: {socketFlags}");
- return WriteBsdResult(context, -1, LinuxError.EOPNOTSUPP);
+ Logger.PrintWarning(LogClass.ServiceBsd, $"Unsupported Recv flags: {SocketFlags}");
+ return WriteBsdResult(Context, -1, LinuxError.EOPNOTSUPP);
}
- byte[] receivedBuffer = new byte[receiveLength];
+ byte[] ReceivedBuffer = new byte[ReceiveLength];
try
{
- result = socket.Handle.Receive(receivedBuffer, socketFlags);
- errno = SetResultErrno(socket.Handle, result);
+ Result = Socket.Handle.Receive(ReceivedBuffer, SocketFlags);
+ Errno = SetResultErrno(Socket.Handle, Result);
- context.Memory.WriteBytes(receivePosition, receivedBuffer);
+ Context.Memory.WriteBytes(ReceivePosition, ReceivedBuffer);
}
- catch (SocketException exception)
+ catch (SocketException Exception)
{
- errno = ConvertError((WsaError)exception.ErrorCode);
+ Errno = ConvertError((WSAError)Exception.ErrorCode);
}
}
- return WriteBsdResult(context, result, errno);
+ return WriteBsdResult(Context, Result, Errno);
}
// RecvFrom(u32 sock, u32 flags) -> (i32 ret, u32 bsd_errno, u32 addrlen, buffer<i8, 0x22, 0> message, buffer<nn::socket::sockaddr_in, 0x22, 0x10>)
- public long RecvFrom(ServiceCtx context)
+ public long RecvFrom(ServiceCtx Context)
{
- int socketFd = context.RequestData.ReadInt32();
- SocketFlags socketFlags = (SocketFlags)context.RequestData.ReadInt32();
+ int SocketFd = Context.RequestData.ReadInt32();
+ SocketFlags SocketFlags = (SocketFlags)Context.RequestData.ReadInt32();
- (long receivePosition, long receiveLength) = context.Request.GetBufferType0x22();
- (long sockAddrInPosition, long sockAddrInSize) = context.Request.GetBufferType0x21();
- (long sockAddrOutPosition, long sockAddrOutSize) = context.Request.GetBufferType0x22(1);
+ (long ReceivePosition, long ReceiveLength) = Context.Request.GetBufferType0x22();
+ (long SockAddrInPosition, long SockAddrInSize) = Context.Request.GetBufferType0x21();
+ (long SockAddrOutPosition, long SockAddrOutSize) = Context.Request.GetBufferType0x22(1);
- LinuxError errno = LinuxError.EBADF;
- BsdSocket socket = RetrieveSocket(socketFd);
- int result = -1;
+ LinuxError Errno = LinuxError.EBADF;
+ BsdSocket Socket = RetrieveSocket(SocketFd);
+ int Result = -1;
- if (socket != null)
+ if (Socket != null)
{
- if (socketFlags != SocketFlags.None && (socketFlags & SocketFlags.OutOfBand) == 0
- && (socketFlags & SocketFlags.Peek) == 0)
+ if (SocketFlags != SocketFlags.None && (SocketFlags & SocketFlags.OutOfBand) == 0
+ && (SocketFlags & SocketFlags.Peek) == 0)
{
- Logger.PrintWarning(LogClass.ServiceBsd, $"Unsupported Recv flags: {socketFlags}");
+ Logger.PrintWarning(LogClass.ServiceBsd, $"Unsupported Recv flags: {SocketFlags}");
- return WriteBsdResult(context, -1, LinuxError.EOPNOTSUPP);
+ return WriteBsdResult(Context, -1, LinuxError.EOPNOTSUPP);
}
- byte[] receivedBuffer = new byte[receiveLength];
- EndPoint endPoint = ParseSockAddr(context, sockAddrInPosition, sockAddrInSize);
+ byte[] ReceivedBuffer = new byte[ReceiveLength];
+ EndPoint EndPoint = ParseSockAddr(Context, SockAddrInPosition, SockAddrInSize);
try
{
- result = socket.Handle.ReceiveFrom(receivedBuffer, receivedBuffer.Length, socketFlags, ref endPoint);
- errno = SetResultErrno(socket.Handle, result);
+ Result = Socket.Handle.ReceiveFrom(ReceivedBuffer, ReceivedBuffer.Length, SocketFlags, ref EndPoint);
+ Errno = SetResultErrno(Socket.Handle, Result);
- context.Memory.WriteBytes(receivePosition, receivedBuffer);
- WriteSockAddr(context, sockAddrOutPosition, (IPEndPoint)endPoint);
+ Context.Memory.WriteBytes(ReceivePosition, ReceivedBuffer);
+ WriteSockAddr(Context, SockAddrOutPosition, (IPEndPoint)EndPoint);
}
- catch (SocketException exception)
+ catch (SocketException Exception)
{
- errno = ConvertError((WsaError)exception.ErrorCode);
+ Errno = ConvertError((WSAError)Exception.ErrorCode);
}
}
- return WriteBsdResult(context, result, errno);
+ return WriteBsdResult(Context, Result, Errno);
}
// Send(u32 socket, u32 flags, buffer<i8, 0x21, 0>) -> (i32 ret, u32 bsd_errno)
- public long Send(ServiceCtx context)
+ public long Send(ServiceCtx Context)
{
- int socketFd = context.RequestData.ReadInt32();
- SocketFlags socketFlags = (SocketFlags)context.RequestData.ReadInt32();
+ int SocketFd = Context.RequestData.ReadInt32();
+ SocketFlags SocketFlags = (SocketFlags)Context.RequestData.ReadInt32();
- (long sendPosition, long sendSize) = context.Request.GetBufferType0x21();
+ (long SendPosition, long SendSize) = Context.Request.GetBufferType0x21();
- LinuxError errno = LinuxError.EBADF;
- BsdSocket socket = RetrieveSocket(socketFd);
- int result = -1;
+ LinuxError Errno = LinuxError.EBADF;
+ BsdSocket Socket = RetrieveSocket(SocketFd);
+ int Result = -1;
- if (socket != null)
+ if (Socket != null)
{
- if (socketFlags != SocketFlags.None && socketFlags != SocketFlags.OutOfBand
- && socketFlags != SocketFlags.Peek && socketFlags != SocketFlags.DontRoute)
+ if (SocketFlags != SocketFlags.None && SocketFlags != SocketFlags.OutOfBand
+ && SocketFlags != SocketFlags.Peek && SocketFlags != SocketFlags.DontRoute)
{
- Logger.PrintWarning(LogClass.ServiceBsd, $"Unsupported Send flags: {socketFlags}");
+ Logger.PrintWarning(LogClass.ServiceBsd, $"Unsupported Send flags: {SocketFlags}");
- return WriteBsdResult(context, -1, LinuxError.EOPNOTSUPP);
+ return WriteBsdResult(Context, -1, LinuxError.EOPNOTSUPP);
}
- byte[] sendBuffer = context.Memory.ReadBytes(sendPosition, sendSize);
+ byte[] SendBuffer = Context.Memory.ReadBytes(SendPosition, SendSize);
try
{
- result = socket.Handle.Send(sendBuffer, socketFlags);
- errno = SetResultErrno(socket.Handle, result);
+ Result = Socket.Handle.Send(SendBuffer, SocketFlags);
+ Errno = SetResultErrno(Socket.Handle, Result);
}
- catch (SocketException exception)
+ catch (SocketException Exception)
{
- errno = ConvertError((WsaError)exception.ErrorCode);
+ Errno = ConvertError((WSAError)Exception.ErrorCode);
}
}
- return WriteBsdResult(context, result, errno);
+ return WriteBsdResult(Context, Result, Errno);
}
// SendTo(u32 socket, u32 flags, buffer<i8, 0x21, 0>, buffer<nn::socket::sockaddr_in, 0x21, 0x10>) -> (i32 ret, u32 bsd_errno)
- public long SendTo(ServiceCtx context)
+ public long SendTo(ServiceCtx Context)
{
- int socketFd = context.RequestData.ReadInt32();
- SocketFlags socketFlags = (SocketFlags)context.RequestData.ReadInt32();
+ int SocketFd = Context.RequestData.ReadInt32();
+ SocketFlags SocketFlags = (SocketFlags)Context.RequestData.ReadInt32();
- (long sendPosition, long sendSize) = context.Request.GetBufferType0x21();
- (long bufferPosition, long bufferSize) = context.Request.GetBufferType0x21(1);
+ (long SendPosition, long SendSize) = Context.Request.GetBufferType0x21();
+ (long BufferPosition, long BufferSize) = Context.Request.GetBufferType0x21(1);
- LinuxError errno = LinuxError.EBADF;
- BsdSocket socket = RetrieveSocket(socketFd);
- int result = -1;
+ LinuxError Errno = LinuxError.EBADF;
+ BsdSocket Socket = RetrieveSocket(SocketFd);
+ int Result = -1;
- if (socket != null)
+ if (Socket != null)
{
- if (socketFlags != SocketFlags.None && socketFlags != SocketFlags.OutOfBand
- && socketFlags != SocketFlags.Peek && socketFlags != SocketFlags.DontRoute)
+ if (SocketFlags != SocketFlags.None && SocketFlags != SocketFlags.OutOfBand
+ && SocketFlags != SocketFlags.Peek && SocketFlags != SocketFlags.DontRoute)
{
- Logger.PrintWarning(LogClass.ServiceBsd, $"Unsupported Send flags: {socketFlags}");
+ Logger.PrintWarning(LogClass.ServiceBsd, $"Unsupported Send flags: {SocketFlags}");
- return WriteBsdResult(context, -1, LinuxError.EOPNOTSUPP);
+ return WriteBsdResult(Context, -1, LinuxError.EOPNOTSUPP);
}
- byte[] sendBuffer = context.Memory.ReadBytes(sendPosition, sendSize);
- EndPoint endPoint = ParseSockAddr(context, bufferPosition, bufferSize);
+ byte[] SendBuffer = Context.Memory.ReadBytes(SendPosition, SendSize);
+ EndPoint EndPoint = ParseSockAddr(Context, BufferPosition, BufferSize);
try
{
- result = socket.Handle.SendTo(sendBuffer, sendBuffer.Length, socketFlags, endPoint);
- errno = SetResultErrno(socket.Handle, result);
+ Result = Socket.Handle.SendTo(SendBuffer, SendBuffer.Length, SocketFlags, EndPoint);
+ Errno = SetResultErrno(Socket.Handle, Result);
}
- catch (SocketException exception)
+ catch (SocketException Exception)
{
- errno = ConvertError((WsaError)exception.ErrorCode);
+ Errno = ConvertError((WSAError)Exception.ErrorCode);
}
}
- return WriteBsdResult(context, result, errno);
+ return WriteBsdResult(Context, Result, Errno);
}
// Accept(u32 socket) -> (i32 ret, u32 bsd_errno, u32 addrlen, buffer<nn::socket::sockaddr_in, 0x22, 0x10> addr)
- public long Accept(ServiceCtx context)
+ public long Accept(ServiceCtx Context)
{
- int socketFd = context.RequestData.ReadInt32();
+ int SocketFd = Context.RequestData.ReadInt32();
- (long bufferPos, long bufferSize) = context.Request.GetBufferType0x22();
+ (long BufferPos, long BufferSize) = Context.Request.GetBufferType0x22();
- LinuxError errno = LinuxError.EBADF;
- BsdSocket socket = RetrieveSocket(socketFd);
+ LinuxError Errno = LinuxError.EBADF;
+ BsdSocket Socket = RetrieveSocket(SocketFd);
- if (socket != null)
+ if (Socket != null)
{
- errno = LinuxError.SUCCESS;
+ Errno = LinuxError.SUCCESS;
- Socket newSocket = null;
+ Socket NewSocket = null;
try
{
- newSocket = socket.Handle.Accept();
+ NewSocket = Socket.Handle.Accept();
}
- catch (SocketException exception)
+ catch (SocketException Exception)
{
- errno = ConvertError((WsaError)exception.ErrorCode);
+ Errno = ConvertError((WSAError)Exception.ErrorCode);
}
- if (newSocket == null && errno == LinuxError.SUCCESS)
+ if (NewSocket == null && Errno == LinuxError.SUCCESS)
{
- errno = LinuxError.EWOULDBLOCK;
+ Errno = LinuxError.EWOULDBLOCK;
}
- else if (errno == LinuxError.SUCCESS)
+ else if (Errno == LinuxError.SUCCESS)
{
- BsdSocket newBsdSocket = new BsdSocket
+ BsdSocket NewBsdSocket = new BsdSocket
{
- Family = (int)newSocket.AddressFamily,
- Type = (int)newSocket.SocketType,
- Protocol = (int)newSocket.ProtocolType,
- Handle = newSocket
+ Family = (int)NewSocket.AddressFamily,
+ Type = (int)NewSocket.SocketType,
+ Protocol = (int)NewSocket.ProtocolType,
+ Handle = NewSocket,
};
- _sockets.Add(newBsdSocket);
+ Sockets.Add(NewBsdSocket);
- WriteSockAddr(context, bufferPos, newBsdSocket, true);
+ WriteSockAddr(Context, BufferPos, NewBsdSocket, true);
- WriteBsdResult(context, _sockets.Count - 1, errno);
+ WriteBsdResult(Context, Sockets.Count - 1, Errno);
- context.ResponseData.Write(0x10);
+ Context.ResponseData.Write(0x10);
return 0;
}
}
- return WriteBsdResult(context, -1, errno);
+ return WriteBsdResult(Context, -1, Errno);
}
// Bind(u32 socket, buffer<nn::socket::sockaddr_in, 0x21, 0x10> addr) -> (i32 ret, u32 bsd_errno)
- public long Bind(ServiceCtx context)
+ public long Bind(ServiceCtx Context)
{
- int socketFd = context.RequestData.ReadInt32();
+ int SocketFd = Context.RequestData.ReadInt32();
- (long bufferPos, long bufferSize) = context.Request.GetBufferType0x21();
+ (long BufferPos, long BufferSize) = Context.Request.GetBufferType0x21();
- LinuxError errno = LinuxError.EBADF;
- BsdSocket socket = RetrieveSocket(socketFd);
+ LinuxError Errno = LinuxError.EBADF;
+ BsdSocket Socket = RetrieveSocket(SocketFd);
- if (socket != null)
+ if (Socket != null)
{
- errno = LinuxError.SUCCESS;
+ Errno = LinuxError.SUCCESS;
try
{
- IPEndPoint endPoint = ParseSockAddr(context, bufferPos, bufferSize);
+ IPEndPoint EndPoint = ParseSockAddr(Context, BufferPos, BufferSize);
- socket.Handle.Bind(endPoint);
+ Socket.Handle.Bind(EndPoint);
}
- catch (SocketException exception)
+ catch (SocketException Exception)
{
- errno = ConvertError((WsaError)exception.ErrorCode);
+ Errno = ConvertError((WSAError)Exception.ErrorCode);
}
}
- return WriteBsdResult(context, 0, errno);
+ return WriteBsdResult(Context, 0, Errno);
}
// Connect(u32 socket, buffer<nn::socket::sockaddr_in, 0x21, 0x10>) -> (i32 ret, u32 bsd_errno)
- public long Connect(ServiceCtx context)
+ public long Connect(ServiceCtx Context)
{
- int socketFd = context.RequestData.ReadInt32();
+ int SocketFd = Context.RequestData.ReadInt32();
- (long bufferPos, long bufferSize) = context.Request.GetBufferType0x21();
+ (long BufferPos, long BufferSize) = Context.Request.GetBufferType0x21();
- LinuxError errno = LinuxError.EBADF;
- BsdSocket socket = RetrieveSocket(socketFd);
+ LinuxError Errno = LinuxError.EBADF;
+ BsdSocket Socket = RetrieveSocket(SocketFd);
- if (socket != null)
+ if (Socket != null)
{
- errno = LinuxError.SUCCESS;
+ Errno = LinuxError.SUCCESS;
try
{
- IPEndPoint endPoint = ParseSockAddr(context, bufferPos, bufferSize);
+ IPEndPoint EndPoint = ParseSockAddr(Context, BufferPos, BufferSize);
- socket.Handle.Connect(endPoint);
+ Socket.Handle.Connect(EndPoint);
}
- catch (SocketException exception)
+ catch (SocketException Exception)
{
- errno = ConvertError((WsaError)exception.ErrorCode);
+ Errno = ConvertError((WSAError)Exception.ErrorCode);
}
}
- return WriteBsdResult(context, 0, errno);
+ return WriteBsdResult(Context, 0, Errno);
}
// GetPeerName(u32 socket) -> (i32 ret, u32 bsd_errno, u32 addrlen, buffer<nn::socket::sockaddr_in, 0x22, 0x10> addr)
- public long GetPeerName(ServiceCtx context)
+ public long GetPeerName(ServiceCtx Context)
{
- int socketFd = context.RequestData.ReadInt32();
+ int SocketFd = Context.RequestData.ReadInt32();
- (long bufferPos, long bufferSize) = context.Request.GetBufferType0x22();
+ (long BufferPos, long BufferSize) = Context.Request.GetBufferType0x22();
- LinuxError errno = LinuxError.EBADF;
- BsdSocket socket = RetrieveSocket(socketFd);
+ LinuxError Errno = LinuxError.EBADF;
+ BsdSocket Socket = RetrieveSocket(SocketFd);
- if (socket != null)
+ if (Socket != null)
{
- errno = LinuxError.SUCCESS;
+ Errno = LinuxError.SUCCESS;
- WriteSockAddr(context, bufferPos, socket, true);
- WriteBsdResult(context, 0, errno);
- context.ResponseData.Write(0x10);
+ WriteSockAddr(Context, BufferPos, Socket, true);
+ WriteBsdResult(Context, 0, Errno);
+ Context.ResponseData.Write(0x10);
}
- return WriteBsdResult(context, 0, errno);
+ return WriteBsdResult(Context, 0, Errno);
}
// GetSockName(u32 socket) -> (i32 ret, u32 bsd_errno, u32 addrlen, buffer<nn::socket::sockaddr_in, 0x22, 0x10> addr)
- public long GetSockName(ServiceCtx context)
+ public long GetSockName(ServiceCtx Context)
{
- int socketFd = context.RequestData.ReadInt32();
+ int SocketFd = Context.RequestData.ReadInt32();
- (long bufferPos, long bufferSize) = context.Request.GetBufferType0x22();
+ (long BufferPos, long BufferSize) = Context.Request.GetBufferType0x22();
- LinuxError errno = LinuxError.EBADF;
- BsdSocket socket = RetrieveSocket(socketFd);
+ LinuxError Errno = LinuxError.EBADF;
+ BsdSocket Socket = RetrieveSocket(SocketFd);
- if (socket != null)
+ if (Socket != null)
{
- errno = LinuxError.SUCCESS;
+ Errno = LinuxError.SUCCESS;
- WriteSockAddr(context, bufferPos, socket, false);
- WriteBsdResult(context, 0, errno);
- context.ResponseData.Write(0x10);
+ WriteSockAddr(Context, BufferPos, Socket, false);
+ WriteBsdResult(Context, 0, Errno);
+ Context.ResponseData.Write(0x10);
}
- return WriteBsdResult(context, 0, errno);
+ return WriteBsdResult(Context, 0, Errno);
}
// GetSockOpt(u32 socket, u32 level, u32 option_name) -> (i32 ret, u32 bsd_errno, u32, buffer<unknown, 0x22, 0>)
- public long GetSockOpt(ServiceCtx context)
+ public long GetSockOpt(ServiceCtx Context)
{
- int socketFd = context.RequestData.ReadInt32();
- int level = context.RequestData.ReadInt32();
- int optionName = context.RequestData.ReadInt32();
+ int SocketFd = Context.RequestData.ReadInt32();
+ int Level = Context.RequestData.ReadInt32();
+ int OptionName = Context.RequestData.ReadInt32();
- (long bufferPosition, long bufferSize) = context.Request.GetBufferType0x22();
+ (long BufferPosition, long BufferSize) = Context.Request.GetBufferType0x22();
- LinuxError errno = LinuxError.EBADF;
- BsdSocket socket = RetrieveSocket(socketFd);
+ LinuxError Errno = LinuxError.EBADF;
+ BsdSocket Socket = RetrieveSocket(SocketFd);
- if (socket != null)
+ if (Socket != null)
{
- errno = LinuxError.ENOPROTOOPT;
+ Errno = LinuxError.ENOPROTOOPT;
- if (level == 0xFFFF)
+ if (Level == 0xFFFF)
{
- errno = HandleGetSocketOption(context, socket, (SocketOptionName)optionName, bufferPosition, bufferSize);
+ Errno = HandleGetSocketOption(Context, Socket, (SocketOptionName)OptionName, BufferPosition, BufferSize);
}
else
{
- Logger.PrintWarning(LogClass.ServiceBsd, $"Unsupported GetSockOpt Level: {(SocketOptionLevel)level}");
+ Logger.PrintWarning(LogClass.ServiceBsd, $"Unsupported GetSockOpt Level: {(SocketOptionLevel)Level}");
}
}
- return WriteBsdResult(context, 0, errno);
+ return WriteBsdResult(Context, 0, Errno);
}
// Listen(u32 socket, u32 backlog) -> (i32 ret, u32 bsd_errno)
- public long Listen(ServiceCtx context)
+ public long Listen(ServiceCtx Context)
{
- int socketFd = context.RequestData.ReadInt32();
- int backlog = context.RequestData.ReadInt32();
+ int SocketFd = Context.RequestData.ReadInt32();
+ int Backlog = Context.RequestData.ReadInt32();
- LinuxError errno = LinuxError.EBADF;
- BsdSocket socket = RetrieveSocket(socketFd);
+ LinuxError Errno = LinuxError.EBADF;
+ BsdSocket Socket = RetrieveSocket(SocketFd);
- if (socket != null)
+ if (Socket != null)
{
- errno = LinuxError.SUCCESS;
+ Errno = LinuxError.SUCCESS;
try
{
- socket.Handle.Listen(backlog);
+ Socket.Handle.Listen(Backlog);
}
- catch (SocketException exception)
+ catch (SocketException Exception)
{
- errno = ConvertError((WsaError)exception.ErrorCode);
+ Errno = ConvertError((WSAError)Exception.ErrorCode);
}
}
- return WriteBsdResult(context, 0, errno);
+ return WriteBsdResult(Context, 0, Errno);
}
// Ioctl(u32 fd, u32 request, u32 bufcount, buffer<unknown, 0x21, 0>, buffer<unknown, 0x21, 0>, buffer<unknown, 0x21, 0>, buffer<unknown, 0x21, 0>) -> (i32 ret, u32 bsd_errno, buffer<unknown, 0x22, 0>, buffer<unknown, 0x22, 0>, buffer<unknown, 0x22, 0>, buffer<unknown, 0x22, 0>)
- public long Ioctl(ServiceCtx context)
+ public long Ioctl(ServiceCtx Context)
{
- int socketFd = context.RequestData.ReadInt32();
- BsdIoctl cmd = (BsdIoctl)context.RequestData.ReadInt32();
- int bufferCount = context.RequestData.ReadInt32();
+ int SocketFd = Context.RequestData.ReadInt32();
+ BsdIoctl Cmd = (BsdIoctl)Context.RequestData.ReadInt32();
+ int BufferCount = Context.RequestData.ReadInt32();
- LinuxError errno = LinuxError.EBADF;
- BsdSocket socket = RetrieveSocket(socketFd);
+ LinuxError Errno = LinuxError.EBADF;
+ BsdSocket Socket = RetrieveSocket(SocketFd);
- if (socket != null)
+ if (Socket != null)
{
- switch (cmd)
+ switch (Cmd)
{
case BsdIoctl.AtMark:
- errno = LinuxError.SUCCESS;
+ Errno = LinuxError.SUCCESS;
- (long bufferPosition, long bufferSize) = context.Request.GetBufferType0x22();
+ (long BufferPosition, long BufferSize) = Context.Request.GetBufferType0x22();
// FIXME: OOB not implemented.
- context.Memory.WriteInt32(bufferPosition, 0);
+ Context.Memory.WriteInt32(BufferPosition, 0);
break;
default:
- errno = LinuxError.EOPNOTSUPP;
+ Errno = LinuxError.EOPNOTSUPP;
- Logger.PrintWarning(LogClass.ServiceBsd, $"Unsupported Ioctl Cmd: {cmd}");
+ Logger.PrintWarning(LogClass.ServiceBsd, $"Unsupported Ioctl Cmd: {Cmd}");
break;
}
}
- return WriteBsdResult(context, 0, errno);
+ return WriteBsdResult(Context, 0, Errno);
}
// Fcntl(u32 socket, u32 cmd, u32 arg) -> (i32 ret, u32 bsd_errno)
- public long Fcntl(ServiceCtx context)
+ public long Fcntl(ServiceCtx Context)
{
- int socketFd = context.RequestData.ReadInt32();
- int cmd = context.RequestData.ReadInt32();
- int arg = context.RequestData.ReadInt32();
+ int SocketFd = Context.RequestData.ReadInt32();
+ int Cmd = Context.RequestData.ReadInt32();
+ int Arg = Context.RequestData.ReadInt32();
- int result = 0;
- LinuxError errno = LinuxError.EBADF;
- BsdSocket socket = RetrieveSocket(socketFd);
+ int Result = 0;
+ LinuxError Errno = LinuxError.EBADF;
+ BsdSocket Socket = RetrieveSocket(SocketFd);
- if (socket != null)
+ if (Socket != null)
{
- errno = LinuxError.SUCCESS;
+ Errno = LinuxError.SUCCESS;
- if (cmd == 0x3)
+ if (Cmd == 0x3)
{
- result = !socket.Handle.Blocking ? 0x800 : 0;
+ Result = !Socket.Handle.Blocking ? 0x800 : 0;
}
- else if (cmd == 0x4 && arg == 0x800)
+ else if (Cmd == 0x4 && Arg == 0x800)
{
- socket.Handle.Blocking = false;
- result = 0;
+ Socket.Handle.Blocking = false;
+ Result = 0;
}
else
{
- errno = LinuxError.EOPNOTSUPP;
+ Errno = LinuxError.EOPNOTSUPP;
}
}
- return WriteBsdResult(context, result, errno);
+ return WriteBsdResult(Context, Result, Errno);
}
- private LinuxError HandleGetSocketOption(ServiceCtx context, BsdSocket socket, SocketOptionName optionName, long optionValuePosition, long optionValueSize)
+ private LinuxError HandleGetSocketOption(ServiceCtx Context, BsdSocket Socket, SocketOptionName OptionName, long OptionValuePosition, long OptionValueSize)
{
try
{
- byte[] optionValue = new byte[optionValueSize];
+ byte[] OptionValue = new byte[OptionValueSize];
- switch (optionName)
+ switch (OptionName)
{
case SocketOptionName.Broadcast:
case SocketOptionName.DontLinger:
@@ -927,34 +928,34 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
case SocketOptionName.SendTimeout:
case SocketOptionName.Type:
case SocketOptionName.Linger:
- socket.Handle.GetSocketOption(SocketOptionLevel.Socket, optionName, optionValue);
- context.Memory.WriteBytes(optionValuePosition, optionValue);
+ Socket.Handle.GetSocketOption(SocketOptionLevel.Socket, OptionName, OptionValue);
+ Context.Memory.WriteBytes(OptionValuePosition, OptionValue);
return LinuxError.SUCCESS;
case (SocketOptionName)0x200:
- socket.Handle.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, optionValue);
- context.Memory.WriteBytes(optionValuePosition, optionValue);
+ Socket.Handle.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, OptionValue);
+ Context.Memory.WriteBytes(OptionValuePosition, OptionValue);
return LinuxError.SUCCESS;
default:
- Logger.PrintWarning(LogClass.ServiceBsd, $"Unsupported SetSockOpt OptionName: {optionName}");
+ Logger.PrintWarning(LogClass.ServiceBsd, $"Unsupported SetSockOpt OptionName: {OptionName}");
return LinuxError.EOPNOTSUPP;
}
}
- catch (SocketException exception)
+ catch (SocketException Exception)
{
- return ConvertError((WsaError)exception.ErrorCode);
+ return ConvertError((WSAError)Exception.ErrorCode);
}
}
- private LinuxError HandleSetSocketOption(ServiceCtx context, BsdSocket socket, SocketOptionName optionName, long optionValuePosition, long optionValueSize)
+ private LinuxError HandleSetSocketOption(ServiceCtx Context, BsdSocket Socket, SocketOptionName OptionName, long OptionValuePosition, long OptionValueSize)
{
try
{
- switch (optionName)
+ switch (OptionName)
{
case SocketOptionName.Broadcast:
case SocketOptionName.DontLinger:
@@ -968,225 +969,225 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
case SocketOptionName.SendTimeout:
case SocketOptionName.Type:
case SocketOptionName.ReuseAddress:
- socket.Handle.SetSocketOption(SocketOptionLevel.Socket, optionName, context.Memory.ReadInt32(optionValuePosition));
+ Socket.Handle.SetSocketOption(SocketOptionLevel.Socket, OptionName, Context.Memory.ReadInt32(OptionValuePosition));
return LinuxError.SUCCESS;
case (SocketOptionName)0x200:
- socket.Handle.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, context.Memory.ReadInt32(optionValuePosition));
+ Socket.Handle.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, Context.Memory.ReadInt32(OptionValuePosition));
return LinuxError.SUCCESS;
case SocketOptionName.Linger:
- socket.Handle.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Linger,
- new LingerOption(context.Memory.ReadInt32(optionValuePosition) != 0, context.Memory.ReadInt32(optionValuePosition + 4)));
+ Socket.Handle.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Linger,
+ new LingerOption(Context.Memory.ReadInt32(OptionValuePosition) != 0, Context.Memory.ReadInt32(OptionValuePosition + 4)));
return LinuxError.SUCCESS;
default:
- Logger.PrintWarning(LogClass.ServiceBsd, $"Unsupported SetSockOpt OptionName: {optionName}");
+ Logger.PrintWarning(LogClass.ServiceBsd, $"Unsupported SetSockOpt OptionName: {OptionName}");
return LinuxError.EOPNOTSUPP;
}
}
- catch (SocketException exception)
+ catch (SocketException Exception)
{
- return ConvertError((WsaError)exception.ErrorCode);
+ return ConvertError((WSAError)Exception.ErrorCode);
}
}
// SetSockOpt(u32 socket, u32 level, u32 option_name, buffer<unknown, 0x21, 0> option_value) -> (i32 ret, u32 bsd_errno)
- public long SetSockOpt(ServiceCtx context)
+ public long SetSockOpt(ServiceCtx Context)
{
- int socketFd = context.RequestData.ReadInt32();
- int level = context.RequestData.ReadInt32();
- int optionName = context.RequestData.ReadInt32();
+ int SocketFd = Context.RequestData.ReadInt32();
+ int Level = Context.RequestData.ReadInt32();
+ int OptionName = Context.RequestData.ReadInt32();
- (long bufferPos, long bufferSize) = context.Request.GetBufferType0x21();
+ (long BufferPos, long BufferSize) = Context.Request.GetBufferType0x21();
- LinuxError errno = LinuxError.EBADF;
- BsdSocket socket = RetrieveSocket(socketFd);
+ LinuxError Errno = LinuxError.EBADF;
+ BsdSocket Socket = RetrieveSocket(SocketFd);
- if (socket != null)
+ if (Socket != null)
{
- errno = LinuxError.ENOPROTOOPT;
+ Errno = LinuxError.ENOPROTOOPT;
- if (level == 0xFFFF)
+ if (Level == 0xFFFF)
{
- errno = HandleSetSocketOption(context, socket, (SocketOptionName)optionName, bufferPos, bufferSize);
+ Errno = HandleSetSocketOption(Context, Socket, (SocketOptionName)OptionName, BufferPos, BufferSize);
}
else
{
- Logger.PrintWarning(LogClass.ServiceBsd, $"Unsupported SetSockOpt Level: {(SocketOptionLevel)level}");
+ Logger.PrintWarning(LogClass.ServiceBsd, $"Unsupported SetSockOpt Level: {(SocketOptionLevel)Level}");
}
}
- return WriteBsdResult(context, 0, errno);
+ return WriteBsdResult(Context, 0, Errno);
}
// Shutdown(u32 socket, u32 how) -> (i32 ret, u32 bsd_errno)
- public long Shutdown(ServiceCtx context)
+ public long Shutdown(ServiceCtx Context)
{
- int socketFd = context.RequestData.ReadInt32();
- int how = context.RequestData.ReadInt32();
+ int SocketFd = Context.RequestData.ReadInt32();
+ int How = Context.RequestData.ReadInt32();
- LinuxError errno = LinuxError.EBADF;
- BsdSocket socket = RetrieveSocket(socketFd);
+ LinuxError Errno = LinuxError.EBADF;
+ BsdSocket Socket = RetrieveSocket(SocketFd);
- if (socket != null)
+ if (Socket != null)
{
- errno = LinuxError.EINVAL;
+ Errno = LinuxError.EINVAL;
- if (how >= 0 && how <= 2)
+ if (How >= 0 && How <= 2)
{
- errno = LinuxError.SUCCESS;
+ Errno = LinuxError.SUCCESS;
try
{
- socket.Handle.Shutdown((SocketShutdown)how);
+ Socket.Handle.Shutdown((SocketShutdown)How);
}
- catch (SocketException exception)
+ catch (SocketException Exception)
{
- errno = ConvertError((WsaError)exception.ErrorCode);
+ Errno = ConvertError((WSAError)Exception.ErrorCode);
}
}
}
- return WriteBsdResult(context, 0, errno);
+ return WriteBsdResult(Context, 0, Errno);
}
// ShutdownAllSockets(u32 how) -> (i32 ret, u32 bsd_errno)
- public long ShutdownAllSockets(ServiceCtx context)
+ public long ShutdownAllSockets(ServiceCtx Context)
{
- int how = context.RequestData.ReadInt32();
+ int How = Context.RequestData.ReadInt32();
- LinuxError errno = LinuxError.EINVAL;
+ LinuxError Errno = LinuxError.EINVAL;
- if (how >= 0 && how <= 2)
+ if (How >= 0 && How <= 2)
{
- errno = LinuxError.SUCCESS;
+ Errno = LinuxError.SUCCESS;
- foreach (BsdSocket socket in _sockets)
+ foreach (BsdSocket Socket in Sockets)
{
- if (socket != null)
+ if (Socket != null)
{
try
{
- socket.Handle.Shutdown((SocketShutdown)how);
+ Socket.Handle.Shutdown((SocketShutdown)How);
}
- catch (SocketException exception)
+ catch (SocketException Exception)
{
- errno = ConvertError((WsaError)exception.ErrorCode);
+ Errno = ConvertError((WSAError)Exception.ErrorCode);
break;
}
}
}
}
- return WriteBsdResult(context, 0, errno);
+ return WriteBsdResult(Context, 0, Errno);
}
// Write(u32 socket, buffer<i8, 0x21, 0> message) -> (i32 ret, u32 bsd_errno)
- public long Write(ServiceCtx context)
+ public long Write(ServiceCtx Context)
{
- int socketFd = context.RequestData.ReadInt32();
+ int SocketFd = Context.RequestData.ReadInt32();
- (long sendPosition, long sendSize) = context.Request.GetBufferType0x21();
+ (long SendPosition, long SendSize) = Context.Request.GetBufferType0x21();
- LinuxError errno = LinuxError.EBADF;
- BsdSocket socket = RetrieveSocket(socketFd);
- int result = -1;
+ LinuxError Errno = LinuxError.EBADF;
+ BsdSocket Socket = RetrieveSocket(SocketFd);
+ int Result = -1;
- if (socket != null)
+ if (Socket != null)
{
- byte[] sendBuffer = context.Memory.ReadBytes(sendPosition, sendSize);
+ byte[] SendBuffer = Context.Memory.ReadBytes(SendPosition, SendSize);
try
{
- result = socket.Handle.Send(sendBuffer);
- errno = SetResultErrno(socket.Handle, result);
+ Result = Socket.Handle.Send(SendBuffer);
+ Errno = SetResultErrno(Socket.Handle, Result);
}
- catch (SocketException exception)
+ catch (SocketException Exception)
{
- errno = ConvertError((WsaError)exception.ErrorCode);
+ Errno = ConvertError((WSAError)Exception.ErrorCode);
}
}
- return WriteBsdResult(context, result, errno);
+ return WriteBsdResult(Context, Result, Errno);
}
// Read(u32 socket) -> (i32 ret, u32 bsd_errno, buffer<i8, 0x22, 0> message)
- public long Read(ServiceCtx context)
+ public long Read(ServiceCtx Context)
{
- int socketFd = context.RequestData.ReadInt32();
+ int SocketFd = Context.RequestData.ReadInt32();
- (long receivePosition, long receiveLength) = context.Request.GetBufferType0x22();
+ (long ReceivePosition, long ReceiveLength) = Context.Request.GetBufferType0x22();
- LinuxError errno = LinuxError.EBADF;
- BsdSocket socket = RetrieveSocket(socketFd);
- int result = -1;
+ LinuxError Errno = LinuxError.EBADF;
+ BsdSocket Socket = RetrieveSocket(SocketFd);
+ int Result = -1;
- if (socket != null)
+ if (Socket != null)
{
- byte[] receivedBuffer = new byte[receiveLength];
+ byte[] ReceivedBuffer = new byte[ReceiveLength];
try
{
- result = socket.Handle.Receive(receivedBuffer);
- errno = SetResultErrno(socket.Handle, result);
+ Result = Socket.Handle.Receive(ReceivedBuffer);
+ Errno = SetResultErrno(Socket.Handle, Result);
}
- catch (SocketException exception)
+ catch (SocketException Exception)
{
- errno = ConvertError((WsaError)exception.ErrorCode);
+ Errno = ConvertError((WSAError)Exception.ErrorCode);
}
}
- return WriteBsdResult(context, result, errno);
+ return WriteBsdResult(Context, Result, Errno);
}
// Close(u32 socket) -> (i32 ret, u32 bsd_errno)
- public long Close(ServiceCtx context)
+ public long Close(ServiceCtx Context)
{
- int socketFd = context.RequestData.ReadInt32();
+ int SocketFd = Context.RequestData.ReadInt32();
- LinuxError errno = LinuxError.EBADF;
- BsdSocket socket = RetrieveSocket(socketFd);
+ LinuxError Errno = LinuxError.EBADF;
+ BsdSocket Socket = RetrieveSocket(SocketFd);
- if (socket != null)
+ if (Socket != null)
{
- socket.Handle.Close();
+ Socket.Handle.Close();
- _sockets[socketFd] = null;
+ Sockets[SocketFd] = null;
- errno = LinuxError.SUCCESS;
+ Errno = LinuxError.SUCCESS;
}
- return WriteBsdResult(context, 0, errno);
+ return WriteBsdResult(Context, 0, Errno);
}
// DuplicateSocket(u32 socket, u64 reserved) -> (i32 ret, u32 bsd_errno)
- public long DuplicateSocket(ServiceCtx context)
+ public long DuplicateSocket(ServiceCtx Context)
{
- int socketFd = context.RequestData.ReadInt32();
- ulong reserved = context.RequestData.ReadUInt64();
+ int SocketFd = Context.RequestData.ReadInt32();
+ ulong Reserved = Context.RequestData.ReadUInt64();
- LinuxError errno = LinuxError.ENOENT;
- int newSockFd = -1;
+ LinuxError Errno = LinuxError.ENOENT;
+ int NewSockFd = -1;
- if (_isPrivileged)
+ if (IsPrivileged)
{
- errno = LinuxError.EBADF;
+ Errno = LinuxError.EBADF;
- BsdSocket oldSocket = RetrieveSocket(socketFd);
+ BsdSocket OldSocket = RetrieveSocket(SocketFd);
- if (oldSocket != null)
+ if (OldSocket != null)
{
- _sockets.Add(oldSocket);
- newSockFd = _sockets.Count - 1;
+ Sockets.Add(OldSocket);
+ NewSockFd = Sockets.Count - 1;
}
}
- return WriteBsdResult(context, newSockFd, errno);
+ return WriteBsdResult(Context, NewSockFd, Errno);
}
}
}