aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs')
-rw-r--r--Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs96
1 files changed, 48 insertions, 48 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs
index 1246c31b..63f639cb 100644
--- a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs
+++ b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs
@@ -197,28 +197,28 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
return WriteBsdResult(context, _sockets.Count - 1);
}
- private IPEndPoint ParseSockAddr(ServiceCtx context, long bufferPosition, long bufferSize)
+ private IPEndPoint ParseSockAddr(ServiceCtx context, ulong bufferPosition, ulong bufferSize)
{
- int size = context.Memory.Read<byte>((ulong)bufferPosition);
- int family = context.Memory.Read<byte>((ulong)bufferPosition + 1);
- int port = BinaryPrimitives.ReverseEndianness(context.Memory.Read<ushort>((ulong)bufferPosition + 2));
+ int size = context.Memory.Read<byte>(bufferPosition);
+ int family = context.Memory.Read<byte>(bufferPosition + 1);
+ int port = BinaryPrimitives.ReverseEndianness(context.Memory.Read<ushort>(bufferPosition + 2));
byte[] rawIp = new byte[4];
- context.Memory.Read((ulong)bufferPosition + 4, rawIp);
+ context.Memory.Read(bufferPosition + 4, rawIp);
return new IPEndPoint(new IPAddress(rawIp), port);
}
- private void WriteSockAddr(ServiceCtx context, long bufferPosition, IPEndPoint endPoint)
+ private void WriteSockAddr(ServiceCtx context, ulong bufferPosition, IPEndPoint endPoint)
{
- context.Memory.Write((ulong)bufferPosition, (byte)0);
- context.Memory.Write((ulong)bufferPosition + 1, (byte)endPoint.AddressFamily);
- context.Memory.Write((ulong)bufferPosition + 2, BinaryPrimitives.ReverseEndianness((ushort)endPoint.Port));
- context.Memory.Write((ulong)bufferPosition + 4, endPoint.Address.GetAddressBytes());
+ context.Memory.Write(bufferPosition, (byte)0);
+ context.Memory.Write(bufferPosition + 1, (byte)endPoint.AddressFamily);
+ context.Memory.Write(bufferPosition + 2, BinaryPrimitives.ReverseEndianness((ushort)endPoint.Port));
+ context.Memory.Write(bufferPosition + 4, endPoint.Address.GetAddressBytes());
}
- private void WriteSockAddr(ServiceCtx context, long bufferPosition, BsdSocket socket, bool isRemote)
+ private void WriteSockAddr(ServiceCtx context, ulong bufferPosition, BsdSocket socket, bool isRemote)
{
IPEndPoint endPoint = (isRemote ? socket.Handle.RemoteEndPoint : socket.Handle.LocalEndPoint) as IPEndPoint;
@@ -282,13 +282,13 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
// Open(u32 flags, array<unknown, 0x21> path) -> (i32 ret, u32 bsd_errno)
public ResultCode Open(ServiceCtx context)
{
- (long bufferPosition, long bufferSize) = context.Request.GetBufferType0x21();
+ (ulong bufferPosition, ulong bufferSize) = context.Request.GetBufferType0x21();
int flags = context.RequestData.ReadInt32();
byte[] rawPath = new byte[bufferSize];
- context.Memory.Read((ulong)bufferPosition, rawPath);
+ context.Memory.Read(bufferPosition, rawPath);
string path = Encoding.ASCII.GetString(rawPath);
@@ -317,10 +317,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
int fdsCount = context.RequestData.ReadInt32();
int timeout = context.RequestData.ReadInt32();
- (long bufferPosition, long bufferSize) = context.Request.GetBufferType0x21();
+ (ulong bufferPosition, ulong bufferSize) = context.Request.GetBufferType0x21();
- if (timeout < -1 || fdsCount < 0 || (fdsCount * 8) > bufferSize)
+ if (timeout < -1 || fdsCount < 0 || (ulong)(fdsCount * 8) > bufferSize)
{
return WriteBsdResult(context, -1, LinuxError.EINVAL);
}
@@ -329,7 +329,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
for (int i = 0; i < fdsCount; i++)
{
- int socketFd = context.Memory.Read<int>((ulong)(bufferPosition + i * 8));
+ int socketFd = context.Memory.Read<int>(bufferPosition + (ulong)i * 8);
BsdSocket socket = RetrieveSocket(socketFd);
@@ -337,8 +337,8 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
{
return WriteBsdResult(context, -1, LinuxError.EBADF);}
- PollEvent.EventTypeMask inputEvents = (PollEvent.EventTypeMask)context.Memory.Read<short>((ulong)(bufferPosition + i * 8 + 4));
- PollEvent.EventTypeMask outputEvents = (PollEvent.EventTypeMask)context.Memory.Read<short>((ulong)(bufferPosition + i * 8 + 6));
+ PollEvent.EventTypeMask inputEvents = (PollEvent.EventTypeMask)context.Memory.Read<short>(bufferPosition + (ulong)i * 8 + 4);
+ PollEvent.EventTypeMask outputEvents = (PollEvent.EventTypeMask)context.Memory.Read<short>(bufferPosition + (ulong)i * 8 + 6);
events[i] = new PollEvent(socketFd, socket, inputEvents, outputEvents);
}
@@ -413,8 +413,8 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
for (int i = 0; i < fdsCount; i++)
{
PollEvent Event = events[i];
- context.Memory.Write((ulong)(bufferPosition + i * 8), Event.SocketFd);
- context.Memory.Write((ulong)(bufferPosition + i * 8 + 4), (short)Event.InputEvents);
+ context.Memory.Write(bufferPosition + (ulong)i * 8, Event.SocketFd);
+ context.Memory.Write(bufferPosition + (ulong)i * 8 + 4, (short)Event.InputEvents);
PollEvent.EventTypeMask outputEvents = 0;
@@ -443,7 +443,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
outputEvents |= PollEvent.EventTypeMask.Output;
}
- context.Memory.Write((ulong)(bufferPosition + i * 8 + 6), (short)outputEvents);
+ context.Memory.Write(bufferPosition + (ulong)i * 8 + 6, (short)outputEvents);
}
return WriteBsdResult(context, readEvents.Count + writeEvents.Count + errorEvents.Count, LinuxError.SUCCESS);
@@ -467,7 +467,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
int socketFd = context.RequestData.ReadInt32();
SocketFlags socketFlags = (SocketFlags)context.RequestData.ReadInt32();
- (long receivePosition, long receiveLength) = context.Request.GetBufferType0x22();
+ (ulong receivePosition, ulong receiveLength) = context.Request.GetBufferType0x22();
LinuxError errno = LinuxError.EBADF;
BsdSocket socket = RetrieveSocket(socketFd);
@@ -489,7 +489,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
result = socket.Handle.Receive(receivedBuffer, socketFlags);
errno = SetResultErrno(socket.Handle, result);
- context.Memory.Write((ulong)receivePosition, receivedBuffer);
+ context.Memory.Write(receivePosition, receivedBuffer);
}
catch (SocketException exception)
{
@@ -507,8 +507,8 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
int socketFd = context.RequestData.ReadInt32();
SocketFlags socketFlags = (SocketFlags)context.RequestData.ReadInt32();
- (long receivePosition, long receiveLength) = context.Request.GetBufferType0x22();
- (long sockAddrOutPosition, long sockAddrOutSize) = context.Request.GetBufferType0x22(1);
+ (ulong receivePosition, ulong receiveLength) = context.Request.GetBufferType0x22();
+ (ulong sockAddrOutPosition, ulong sockAddrOutSize) = context.Request.GetBufferType0x22(1);
LinuxError errno = LinuxError.EBADF;
BsdSocket socket = RetrieveSocket(socketFd);
@@ -532,7 +532,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
result = socket.Handle.ReceiveFrom(receivedBuffer, receivedBuffer.Length, socketFlags, ref endPoint);
errno = SetResultErrno(socket.Handle, result);
- context.Memory.Write((ulong)receivePosition, receivedBuffer);
+ context.Memory.Write(receivePosition, receivedBuffer);
WriteSockAddr(context, sockAddrOutPosition, (IPEndPoint)endPoint);
}
catch (SocketException exception)
@@ -551,7 +551,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
int socketFd = context.RequestData.ReadInt32();
SocketFlags socketFlags = (SocketFlags)context.RequestData.ReadInt32();
- (long sendPosition, long sendSize) = context.Request.GetBufferType0x21();
+ (ulong sendPosition, ulong sendSize) = context.Request.GetBufferType0x21();
LinuxError errno = LinuxError.EBADF;
BsdSocket socket = RetrieveSocket(socketFd);
@@ -569,7 +569,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
byte[] sendBuffer = new byte[sendSize];
- context.Memory.Read((ulong)sendPosition, sendBuffer);
+ context.Memory.Read(sendPosition, sendBuffer);
try
{
@@ -593,8 +593,8 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
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);
+ (ulong sendPosition, ulong sendSize) = context.Request.GetBufferType0x21();
+ (ulong bufferPosition, ulong bufferSize) = context.Request.GetBufferType0x21(1);
LinuxError errno = LinuxError.EBADF;
BsdSocket socket = RetrieveSocket(socketFd);
@@ -612,7 +612,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
byte[] sendBuffer = new byte[sendSize];
- context.Memory.Read((ulong)sendPosition, sendBuffer);
+ context.Memory.Read(sendPosition, sendBuffer);
EndPoint endPoint = ParseSockAddr(context, bufferPosition, bufferSize);
@@ -637,7 +637,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
{
int socketFd = context.RequestData.ReadInt32();
- (long bufferPos, long bufferSize) = context.Request.GetBufferType0x22();
+ (ulong bufferPos, ulong bufferSize) = context.Request.GetBufferType0x22();
LinuxError errno = LinuxError.EBADF;
BsdSocket socket = RetrieveSocket(socketFd);
@@ -692,7 +692,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
{
int socketFd = context.RequestData.ReadInt32();
- (long bufferPos, long bufferSize) = context.Request.GetBufferType0x21();
+ (ulong bufferPos, ulong bufferSize) = context.Request.GetBufferType0x21();
LinuxError errno = LinuxError.EBADF;
BsdSocket socket = RetrieveSocket(socketFd);
@@ -722,7 +722,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
{
int socketFd = context.RequestData.ReadInt32();
- (long bufferPos, long bufferSize) = context.Request.GetBufferType0x21();
+ (ulong bufferPos, ulong bufferSize) = context.Request.GetBufferType0x21();
LinuxError errno = LinuxError.EBADF;
BsdSocket socket = RetrieveSocket(socketFd);
@@ -751,7 +751,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
{
int socketFd = context.RequestData.ReadInt32();
- (long bufferPos, long bufferSize) = context.Request.GetBufferType0x22();
+ (ulong bufferPos, ulong bufferSize) = context.Request.GetBufferType0x22();
LinuxError errno = LinuxError.EBADF;
BsdSocket socket = RetrieveSocket(socketFd);
@@ -774,7 +774,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
{
int socketFd = context.RequestData.ReadInt32();
- (long bufferPos, long bufferSize) = context.Request.GetBufferType0x22();
+ (ulong bufferPos, ulong bufferSize) = context.Request.GetBufferType0x22();
LinuxError errno = LinuxError.EBADF;
BsdSocket socket = RetrieveSocket(socketFd);
@@ -799,7 +799,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
int level = context.RequestData.ReadInt32();
int optionName = context.RequestData.ReadInt32();
- (long bufferPosition, long bufferSize) = context.Request.GetBufferType0x22();
+ (ulong bufferPosition, ulong bufferSize) = context.Request.GetBufferType0x22();
LinuxError errno = LinuxError.EBADF;
BsdSocket socket = RetrieveSocket(socketFd);
@@ -866,10 +866,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
case BsdIoctl.AtMark:
errno = LinuxError.SUCCESS;
- (long bufferPosition, long bufferSize) = context.Request.GetBufferType0x22();
+ (ulong bufferPosition, ulong bufferSize) = context.Request.GetBufferType0x22();
// FIXME: OOB not implemented.
- context.Memory.Write((ulong)bufferPosition, 0);
+ context.Memory.Write(bufferPosition, 0);
break;
default:
@@ -917,7 +917,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
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, ulong optionValuePosition, ulong optionValueSize)
{
try
{
@@ -938,13 +938,13 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
case SocketOptionName.Type:
case SocketOptionName.Linger:
socket.Handle.GetSocketOption(SocketOptionLevel.Socket, optionName, optionValue);
- context.Memory.Write((ulong)optionValuePosition, optionValue);
+ context.Memory.Write(optionValuePosition, optionValue);
return LinuxError.SUCCESS;
case (SocketOptionName)0x200:
socket.Handle.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, optionValue);
- context.Memory.Write((ulong)optionValuePosition, optionValue);
+ context.Memory.Write(optionValuePosition, optionValue);
return LinuxError.SUCCESS;
@@ -960,7 +960,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
}
}
- private LinuxError HandleSetSocketOption(ServiceCtx context, BsdSocket socket, SocketOptionName optionName, long optionValuePosition, long optionValueSize)
+ private LinuxError HandleSetSocketOption(ServiceCtx context, BsdSocket socket, SocketOptionName optionName, ulong optionValuePosition, ulong optionValueSize)
{
try
{
@@ -1013,7 +1013,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
int level = context.RequestData.ReadInt32();
int optionName = context.RequestData.ReadInt32();
- (long bufferPos, long bufferSize) = context.Request.GetBufferType0x21();
+ (ulong bufferPos, ulong bufferSize) = context.Request.GetBufferType0x21();
LinuxError errno = LinuxError.EBADF;
BsdSocket socket = RetrieveSocket(socketFd);
@@ -1105,7 +1105,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
{
int socketFd = context.RequestData.ReadInt32();
- (long sendPosition, long sendSize) = context.Request.GetBufferType0x21();
+ (ulong sendPosition, ulong sendSize) = context.Request.GetBufferType0x21();
LinuxError errno = LinuxError.EBADF;
BsdSocket socket = RetrieveSocket(socketFd);
@@ -1115,7 +1115,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
{
byte[] sendBuffer = new byte[sendSize];
- context.Memory.Read((ulong)sendPosition, sendBuffer);
+ context.Memory.Read(sendPosition, sendBuffer);
try
{
@@ -1137,7 +1137,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
{
int socketFd = context.RequestData.ReadInt32();
- (long receivePosition, long receiveLength) = context.Request.GetBufferType0x22();
+ (ulong receivePosition, ulong receiveLength) = context.Request.GetBufferType0x22();
LinuxError errno = LinuxError.EBADF;
BsdSocket socket = RetrieveSocket(socketFd);
@@ -1151,7 +1151,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
{
result = socket.Handle.Receive(receivedBuffer);
errno = SetResultErrno(socket.Handle, result);
- context.Memory.Write((ulong)receivePosition, receivedBuffer);
+ context.Memory.Write(receivePosition, receivedBuffer);
}
catch (SocketException exception)
{