mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2025-06-14 00:08:39 -05:00
Sources: Run clang-format on everything.
This commit is contained in:
@ -19,40 +19,40 @@
|
||||
#include "core/memory.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
|
||||
// MinGW does not define several errno constants
|
||||
#ifndef _MSC_VER
|
||||
#define EBADMSG 104
|
||||
#define ENODATA 120
|
||||
#define ENOMSG 122
|
||||
#define ENOSR 124
|
||||
#define ENOSTR 125
|
||||
#define ETIME 137
|
||||
#define EIDRM 2001
|
||||
#define ENOLINK 2002
|
||||
#endif // _MSC_VER
|
||||
// MinGW does not define several errno constants
|
||||
#ifndef _MSC_VER
|
||||
#define EBADMSG 104
|
||||
#define ENODATA 120
|
||||
#define ENOMSG 122
|
||||
#define ENOSR 124
|
||||
#define ENOSTR 125
|
||||
#define ETIME 137
|
||||
#define EIDRM 2001
|
||||
#define ENOLINK 2002
|
||||
#endif // _MSC_VER
|
||||
#else
|
||||
#include <cerrno>
|
||||
#include <fcntl.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#include <poll.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
#include <cerrno>
|
||||
#include <fcntl.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#include <poll.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
# define WSAEAGAIN WSAEWOULDBLOCK
|
||||
# define WSAEMULTIHOP -1 // Invalid dummy value
|
||||
# define ERRNO(x) WSA##x
|
||||
# define GET_ERRNO WSAGetLastError()
|
||||
# define poll(x, y, z) WSAPoll(x, y, z);
|
||||
#define WSAEAGAIN WSAEWOULDBLOCK
|
||||
#define WSAEMULTIHOP -1 // Invalid dummy value
|
||||
#define ERRNO(x) WSA##x
|
||||
#define GET_ERRNO WSAGetLastError()
|
||||
#define poll(x, y, z) WSAPoll(x, y, z);
|
||||
#else
|
||||
# define ERRNO(x) x
|
||||
# define GET_ERRNO errno
|
||||
# define closesocket(x) close(x)
|
||||
#define ERRNO(x) x
|
||||
#define GET_ERRNO errno
|
||||
#define closesocket(x) close(x)
|
||||
#endif
|
||||
|
||||
static const s32 SOCKET_ERROR_VALUE = -1;
|
||||
@ -63,84 +63,82 @@ static const s32 SOCKET_ERROR_VALUE = -1;
|
||||
namespace SOC_U {
|
||||
|
||||
/// Holds the translation from system network errors to 3DS network errors
|
||||
static const std::unordered_map<int, int> error_map = { {
|
||||
{ E2BIG, 1 },
|
||||
{ ERRNO(EACCES), 2 },
|
||||
{ ERRNO(EADDRINUSE), 3 },
|
||||
{ ERRNO(EADDRNOTAVAIL), 4 },
|
||||
{ ERRNO(EAFNOSUPPORT), 5 },
|
||||
{ ERRNO(EAGAIN), 6 },
|
||||
{ ERRNO(EALREADY), 7 },
|
||||
{ ERRNO(EBADF), 8 },
|
||||
{ EBADMSG, 9 },
|
||||
{ EBUSY, 10 },
|
||||
{ ECANCELED, 11 },
|
||||
{ ECHILD, 12 },
|
||||
{ ERRNO(ECONNABORTED), 13 },
|
||||
{ ERRNO(ECONNREFUSED), 14 },
|
||||
{ ERRNO(ECONNRESET), 15 },
|
||||
{ EDEADLK, 16 },
|
||||
{ ERRNO(EDESTADDRREQ), 17 },
|
||||
{ EDOM, 18 },
|
||||
{ ERRNO(EDQUOT), 19 },
|
||||
{ EEXIST, 20 },
|
||||
{ ERRNO(EFAULT), 21 },
|
||||
{ EFBIG, 22 },
|
||||
{ ERRNO(EHOSTUNREACH), 23 },
|
||||
{ EIDRM, 24 },
|
||||
{ EILSEQ, 25 },
|
||||
{ ERRNO(EINPROGRESS), 26 },
|
||||
{ ERRNO(EINTR), 27 },
|
||||
{ ERRNO(EINVAL), 28 },
|
||||
{ EIO, 29 },
|
||||
{ ERRNO(EISCONN), 30 },
|
||||
{ EISDIR, 31 },
|
||||
{ ERRNO(ELOOP), 32 },
|
||||
{ ERRNO(EMFILE), 33 },
|
||||
{ EMLINK, 34 },
|
||||
{ ERRNO(EMSGSIZE), 35 },
|
||||
{ ERRNO(EMULTIHOP), 36 },
|
||||
{ ERRNO(ENAMETOOLONG), 37 },
|
||||
{ ERRNO(ENETDOWN), 38 },
|
||||
{ ERRNO(ENETRESET), 39 },
|
||||
{ ERRNO(ENETUNREACH), 40 },
|
||||
{ ENFILE, 41 },
|
||||
{ ERRNO(ENOBUFS), 42 },
|
||||
{ ENODATA, 43 },
|
||||
{ ENODEV, 44 },
|
||||
{ ENOENT, 45 },
|
||||
{ ENOEXEC, 46 },
|
||||
{ ENOLCK, 47 },
|
||||
{ ENOLINK, 48 },
|
||||
{ ENOMEM, 49 },
|
||||
{ ENOMSG, 50 },
|
||||
{ ERRNO(ENOPROTOOPT), 51 },
|
||||
{ ENOSPC, 52 },
|
||||
{ ENOSR, 53 },
|
||||
{ ENOSTR, 54 },
|
||||
{ ENOSYS, 55 },
|
||||
{ ERRNO(ENOTCONN), 56 },
|
||||
{ ENOTDIR, 57 },
|
||||
{ ERRNO(ENOTEMPTY), 58 },
|
||||
{ ERRNO(ENOTSOCK), 59 },
|
||||
{ ENOTSUP, 60 },
|
||||
{ ENOTTY, 61 },
|
||||
{ ENXIO, 62 },
|
||||
{ ERRNO(EOPNOTSUPP), 63 },
|
||||
{ EOVERFLOW, 64 },
|
||||
{ EPERM, 65 },
|
||||
{ EPIPE, 66 },
|
||||
{ EPROTO, 67 },
|
||||
{ ERRNO(EPROTONOSUPPORT), 68 },
|
||||
{ ERRNO(EPROTOTYPE), 69 },
|
||||
{ ERANGE, 70 },
|
||||
{ EROFS, 71 },
|
||||
{ ESPIPE, 72 },
|
||||
{ ESRCH, 73 },
|
||||
{ ERRNO(ESTALE), 74 },
|
||||
{ ETIME, 75 },
|
||||
{ ERRNO(ETIMEDOUT), 76 }
|
||||
}};
|
||||
static const std::unordered_map<int, int> error_map = {{{E2BIG, 1},
|
||||
{ERRNO(EACCES), 2},
|
||||
{ERRNO(EADDRINUSE), 3},
|
||||
{ERRNO(EADDRNOTAVAIL), 4},
|
||||
{ERRNO(EAFNOSUPPORT), 5},
|
||||
{ERRNO(EAGAIN), 6},
|
||||
{ERRNO(EALREADY), 7},
|
||||
{ERRNO(EBADF), 8},
|
||||
{EBADMSG, 9},
|
||||
{EBUSY, 10},
|
||||
{ECANCELED, 11},
|
||||
{ECHILD, 12},
|
||||
{ERRNO(ECONNABORTED), 13},
|
||||
{ERRNO(ECONNREFUSED), 14},
|
||||
{ERRNO(ECONNRESET), 15},
|
||||
{EDEADLK, 16},
|
||||
{ERRNO(EDESTADDRREQ), 17},
|
||||
{EDOM, 18},
|
||||
{ERRNO(EDQUOT), 19},
|
||||
{EEXIST, 20},
|
||||
{ERRNO(EFAULT), 21},
|
||||
{EFBIG, 22},
|
||||
{ERRNO(EHOSTUNREACH), 23},
|
||||
{EIDRM, 24},
|
||||
{EILSEQ, 25},
|
||||
{ERRNO(EINPROGRESS), 26},
|
||||
{ERRNO(EINTR), 27},
|
||||
{ERRNO(EINVAL), 28},
|
||||
{EIO, 29},
|
||||
{ERRNO(EISCONN), 30},
|
||||
{EISDIR, 31},
|
||||
{ERRNO(ELOOP), 32},
|
||||
{ERRNO(EMFILE), 33},
|
||||
{EMLINK, 34},
|
||||
{ERRNO(EMSGSIZE), 35},
|
||||
{ERRNO(EMULTIHOP), 36},
|
||||
{ERRNO(ENAMETOOLONG), 37},
|
||||
{ERRNO(ENETDOWN), 38},
|
||||
{ERRNO(ENETRESET), 39},
|
||||
{ERRNO(ENETUNREACH), 40},
|
||||
{ENFILE, 41},
|
||||
{ERRNO(ENOBUFS), 42},
|
||||
{ENODATA, 43},
|
||||
{ENODEV, 44},
|
||||
{ENOENT, 45},
|
||||
{ENOEXEC, 46},
|
||||
{ENOLCK, 47},
|
||||
{ENOLINK, 48},
|
||||
{ENOMEM, 49},
|
||||
{ENOMSG, 50},
|
||||
{ERRNO(ENOPROTOOPT), 51},
|
||||
{ENOSPC, 52},
|
||||
{ENOSR, 53},
|
||||
{ENOSTR, 54},
|
||||
{ENOSYS, 55},
|
||||
{ERRNO(ENOTCONN), 56},
|
||||
{ENOTDIR, 57},
|
||||
{ERRNO(ENOTEMPTY), 58},
|
||||
{ERRNO(ENOTSOCK), 59},
|
||||
{ENOTSUP, 60},
|
||||
{ENOTTY, 61},
|
||||
{ENXIO, 62},
|
||||
{ERRNO(EOPNOTSUPP), 63},
|
||||
{EOVERFLOW, 64},
|
||||
{EPERM, 65},
|
||||
{EPIPE, 66},
|
||||
{EPROTO, 67},
|
||||
{ERRNO(EPROTONOSUPPORT), 68},
|
||||
{ERRNO(EPROTOTYPE), 69},
|
||||
{ERANGE, 70},
|
||||
{EROFS, 71},
|
||||
{ESPIPE, 72},
|
||||
{ESRCH, 73},
|
||||
{ERRNO(ESTALE), 74},
|
||||
{ETIME, 75},
|
||||
{ERRNO(ETIMEDOUT), 76}}};
|
||||
|
||||
/// Converts a network error from platform-specific to 3ds-specific
|
||||
static int TranslateError(int error) {
|
||||
@ -153,21 +151,21 @@ static int TranslateError(int error) {
|
||||
|
||||
/// Holds the translation from system network socket options to 3DS network socket options
|
||||
/// Note: -1 = No effect/unavailable
|
||||
static const std::unordered_map<int, int> sockopt_map = { {
|
||||
{ 0x0004, SO_REUSEADDR },
|
||||
{ 0x0080, -1 },
|
||||
{ 0x0100, -1 },
|
||||
{ 0x1001, SO_SNDBUF },
|
||||
{ 0x1002, SO_RCVBUF },
|
||||
{ 0x1003, -1 },
|
||||
static const std::unordered_map<int, int> sockopt_map = {{
|
||||
{0x0004, SO_REUSEADDR},
|
||||
{0x0080, -1},
|
||||
{0x0100, -1},
|
||||
{0x1001, SO_SNDBUF},
|
||||
{0x1002, SO_RCVBUF},
|
||||
{0x1003, -1},
|
||||
#ifdef _WIN32
|
||||
/// Unsupported in WinSock2
|
||||
{ 0x1004, -1 },
|
||||
{0x1004, -1},
|
||||
#else
|
||||
{ 0x1004, SO_RCVLOWAT },
|
||||
{0x1004, SO_RCVLOWAT},
|
||||
#endif
|
||||
{ 0x1008, SO_TYPE },
|
||||
{ 0x1009, SO_ERROR },
|
||||
{0x1008, SO_TYPE},
|
||||
{0x1009, SO_ERROR},
|
||||
}};
|
||||
|
||||
/// Converts a socket option from 3ds-specific to platform-specific
|
||||
@ -203,7 +201,8 @@ struct CTRPollFD {
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Translates the resulting events of a Poll operation from platform-specific to 3ds specific
|
||||
/// Translates the resulting events of a Poll operation from platform-specific to 3ds
|
||||
/// specific
|
||||
static Events TranslateTo3DS(u32 input_event) {
|
||||
Events ev = {};
|
||||
if (input_event & POLLIN)
|
||||
@ -221,7 +220,8 @@ struct CTRPollFD {
|
||||
return ev;
|
||||
}
|
||||
|
||||
/// Translates the resulting events of a Poll operation from 3ds specific to platform specific
|
||||
/// Translates the resulting events of a Poll operation from 3ds specific to platform
|
||||
/// specific
|
||||
static u32 TranslateToPlatform(Events input_event) {
|
||||
u32 ret = 0;
|
||||
if (input_event.pollin)
|
||||
@ -239,7 +239,7 @@ struct CTRPollFD {
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
Events events; ///< Events to poll for (input)
|
||||
Events events; ///< Events to poll for (input)
|
||||
Events revents; ///< Events received (output)
|
||||
|
||||
/// Converts a platform-specific pollfd to a 3ds specific structure
|
||||
@ -265,17 +265,17 @@ struct CTRPollFD {
|
||||
union CTRSockAddr {
|
||||
/// Structure to represent a raw sockaddr
|
||||
struct {
|
||||
u8 len; ///< The length of the entire structure, only the set fields count
|
||||
u8 sa_family; ///< The address family of the sockaddr
|
||||
u8 len; ///< The length of the entire structure, only the set fields count
|
||||
u8 sa_family; ///< The address family of the sockaddr
|
||||
u8 sa_data[0x1A]; ///< The extra data, this varies, depending on the address family
|
||||
} raw;
|
||||
|
||||
/// Structure to represent the 3ds' sockaddr_in structure
|
||||
struct CTRSockAddrIn {
|
||||
u8 len; ///< The length of the entire structure
|
||||
u8 len; ///< The length of the entire structure
|
||||
u8 sin_family; ///< The address family of the sockaddr_in
|
||||
u16 sin_port; ///< The port associated with this sockaddr_in
|
||||
u32 sin_addr; ///< The actual address of the sockaddr_in
|
||||
u16 sin_port; ///< The port associated with this sockaddr_in
|
||||
u32 sin_addr; ///< The actual address of the sockaddr_in
|
||||
} in;
|
||||
|
||||
/// Convert a 3DS CTRSockAddr to a platform-specific sockaddr
|
||||
@ -286,8 +286,7 @@ union CTRSockAddr {
|
||||
|
||||
// We can not guarantee ABI compatibility between platforms so we copy the fields manually
|
||||
switch (result.sa_family) {
|
||||
case AF_INET:
|
||||
{
|
||||
case AF_INET: {
|
||||
sockaddr_in* result_in = reinterpret_cast<sockaddr_in*>(&result);
|
||||
result_in->sin_port = ctr_addr.in.sin_port;
|
||||
result_in->sin_addr.s_addr = ctr_addr.in.sin_addr;
|
||||
@ -307,8 +306,7 @@ union CTRSockAddr {
|
||||
result.raw.sa_family = static_cast<u8>(addr.sa_family);
|
||||
// We can not guarantee ABI compatibility between platforms so we copy the fields manually
|
||||
switch (result.raw.sa_family) {
|
||||
case AF_INET:
|
||||
{
|
||||
case AF_INET: {
|
||||
sockaddr_in const* addr_in = reinterpret_cast<sockaddr_in const*>(&addr);
|
||||
result.raw.len = sizeof(CTRSockAddrIn);
|
||||
result.in.sin_port = addr_in->sin_port;
|
||||
@ -341,24 +339,27 @@ static void Socket(Service::Interface* self) {
|
||||
|
||||
// Only 0 is allowed according to 3dbrew, using 0 will let the OS decide which protocol to use
|
||||
if (protocol != 0) {
|
||||
cmd_buffer[1] = UnimplementedFunction(ErrorModule::SOC).raw; // TODO(Subv): Correct error code
|
||||
cmd_buffer[1] =
|
||||
UnimplementedFunction(ErrorModule::SOC).raw; // TODO(Subv): Correct error code
|
||||
return;
|
||||
}
|
||||
|
||||
if (domain != AF_INET) {
|
||||
cmd_buffer[1] = UnimplementedFunction(ErrorModule::SOC).raw; // TODO(Subv): Correct error code
|
||||
cmd_buffer[1] =
|
||||
UnimplementedFunction(ErrorModule::SOC).raw; // TODO(Subv): Correct error code
|
||||
return;
|
||||
}
|
||||
|
||||
if (type != SOCK_DGRAM && type != SOCK_STREAM) {
|
||||
cmd_buffer[1] = UnimplementedFunction(ErrorModule::SOC).raw; // TODO(Subv): Correct error code
|
||||
cmd_buffer[1] =
|
||||
UnimplementedFunction(ErrorModule::SOC).raw; // TODO(Subv): Correct error code
|
||||
return;
|
||||
}
|
||||
|
||||
u32 socket_handle = static_cast<u32>(::socket(domain, type, protocol));
|
||||
|
||||
if ((s32)socket_handle != SOCKET_ERROR_VALUE)
|
||||
open_sockets[socket_handle] = { socket_handle, true };
|
||||
open_sockets[socket_handle] = {socket_handle, true};
|
||||
|
||||
int result = 0;
|
||||
if ((s32)socket_handle == SOCKET_ERROR_VALUE)
|
||||
@ -406,8 +407,8 @@ static void Fcntl(Service::Interface* self) {
|
||||
int result = 0;
|
||||
u32 posix_ret = 0; // TODO: Check what hardware returns for F_SETFL (unspecified by POSIX)
|
||||
SCOPE_EXIT({
|
||||
cmd_buffer[1] = result;
|
||||
cmd_buffer[2] = posix_ret;
|
||||
cmd_buffer[1] = result;
|
||||
cmd_buffer[2] = posix_ret;
|
||||
});
|
||||
|
||||
if (ctr_cmd == 3) { // F_GETFL
|
||||
@ -493,7 +494,7 @@ static void Accept(Service::Interface* self) {
|
||||
u32 ret = static_cast<u32>(::accept(socket_handle, &addr, &addr_len));
|
||||
|
||||
if ((s32)ret != SOCKET_ERROR_VALUE)
|
||||
open_sockets[ret] = { ret, true };
|
||||
open_sockets[ret] = {ret, true};
|
||||
|
||||
int result = 0;
|
||||
if ((s32)ret == SOCKET_ERROR_VALUE) {
|
||||
@ -573,9 +574,11 @@ static void SendTo(Service::Interface* self) {
|
||||
int ret = -1;
|
||||
if (addr_len > 0) {
|
||||
sockaddr dest_addr = CTRSockAddr::ToPlatform(ctr_dest_addr);
|
||||
ret = ::sendto(socket_handle, reinterpret_cast<const char*>(input_buff.data()), len, flags, &dest_addr, sizeof(dest_addr));
|
||||
ret = ::sendto(socket_handle, reinterpret_cast<const char*>(input_buff.data()), len, flags,
|
||||
&dest_addr, sizeof(dest_addr));
|
||||
} else {
|
||||
ret = ::sendto(socket_handle, reinterpret_cast<const char*>(input_buff.data()), len, flags, nullptr, 0);
|
||||
ret = ::sendto(socket_handle, reinterpret_cast<const char*>(input_buff.data()), len, flags,
|
||||
nullptr, 0);
|
||||
}
|
||||
|
||||
int result = 0;
|
||||
@ -596,8 +599,7 @@ static void RecvFrom(Service::Interface* self) {
|
||||
u32 flags = cmd_buffer[3];
|
||||
socklen_t addr_len = static_cast<socklen_t>(cmd_buffer[4]);
|
||||
|
||||
struct
|
||||
{
|
||||
struct {
|
||||
u32 output_buffer_descriptor;
|
||||
u32 output_buffer_addr;
|
||||
u32 address_buffer_descriptor;
|
||||
@ -619,11 +621,13 @@ static void RecvFrom(Service::Interface* self) {
|
||||
std::vector<u8> output_buff(len);
|
||||
sockaddr src_addr;
|
||||
socklen_t src_addr_len = sizeof(src_addr);
|
||||
int ret = ::recvfrom(socket_handle, reinterpret_cast<char*>(output_buff.data()), len, flags, &src_addr, &src_addr_len);
|
||||
int ret = ::recvfrom(socket_handle, reinterpret_cast<char*>(output_buff.data()), len, flags,
|
||||
&src_addr, &src_addr_len);
|
||||
|
||||
if (ret >= 0 && buffer_parameters.output_src_address_buffer != 0 && src_addr_len > 0) {
|
||||
CTRSockAddr ctr_src_addr = CTRSockAddr::FromPlatform(src_addr);
|
||||
Memory::WriteBlock(buffer_parameters.output_src_address_buffer, &ctr_src_addr, sizeof(ctr_src_addr));
|
||||
Memory::WriteBlock(buffer_parameters.output_src_address_buffer, &ctr_src_addr,
|
||||
sizeof(ctr_src_addr));
|
||||
}
|
||||
|
||||
int result = 0;
|
||||
@ -633,7 +637,8 @@ static void RecvFrom(Service::Interface* self) {
|
||||
total_received = 0;
|
||||
} else {
|
||||
// Write only the data we received to avoid overwriting parts of the buffer with zeros
|
||||
Memory::WriteBlock(buffer_parameters.output_buffer_addr, output_buff.data(), total_received);
|
||||
Memory::WriteBlock(buffer_parameters.output_buffer_addr, output_buff.data(),
|
||||
total_received);
|
||||
}
|
||||
|
||||
cmd_buffer[1] = result;
|
||||
@ -648,7 +653,8 @@ static void Poll(Service::Interface* self) {
|
||||
|
||||
VAddr input_fds_addr = cmd_buffer[6];
|
||||
VAddr output_fds_addr = cmd_buffer[0x104 >> 2];
|
||||
if (!Memory::IsValidVirtualAddress(input_fds_addr) || !Memory::IsValidVirtualAddress(output_fds_addr)) {
|
||||
if (!Memory::IsValidVirtualAddress(input_fds_addr) ||
|
||||
!Memory::IsValidVirtualAddress(output_fds_addr)) {
|
||||
cmd_buffer[1] = -1; // TODO(Subv): Find correct error code.
|
||||
return;
|
||||
}
|
||||
@ -656,7 +662,8 @@ static void Poll(Service::Interface* self) {
|
||||
std::vector<CTRPollFD> ctr_fds(nfds);
|
||||
Memory::ReadBlock(input_fds_addr, ctr_fds.data(), nfds * sizeof(CTRPollFD));
|
||||
|
||||
// The 3ds_pollfd and the pollfd structures may be different (Windows/Linux have different sizes)
|
||||
// The 3ds_pollfd and the pollfd structures may be different (Windows/Linux have different
|
||||
// sizes)
|
||||
// so we have to copy the data
|
||||
std::vector<pollfd> platform_pollfd(nfds);
|
||||
std::transform(ctr_fds.begin(), ctr_fds.end(), platform_pollfd.begin(), CTRPollFD::ToPlatform);
|
||||
@ -664,7 +671,8 @@ static void Poll(Service::Interface* self) {
|
||||
const int ret = ::poll(platform_pollfd.data(), nfds, timeout);
|
||||
|
||||
// Now update the output pollfd structure
|
||||
std::transform(platform_pollfd.begin(), platform_pollfd.end(), ctr_fds.begin(), CTRPollFD::FromPlatform);
|
||||
std::transform(platform_pollfd.begin(), platform_pollfd.end(), ctr_fds.begin(),
|
||||
CTRPollFD::FromPlatform);
|
||||
|
||||
Memory::WriteBlock(output_fds_addr, ctr_fds.data(), nfds * sizeof(CTRPollFD));
|
||||
|
||||
@ -775,7 +783,7 @@ static void Connect(Service::Interface* self) {
|
||||
}
|
||||
|
||||
static void InitializeSockets(Service::Interface* self) {
|
||||
// TODO(Subv): Implement
|
||||
// TODO(Subv): Implement
|
||||
#ifdef _WIN32
|
||||
WSADATA data;
|
||||
WSAStartup(MAKEWORD(2, 2), &data);
|
||||
@ -808,7 +816,7 @@ static void GetSockOpt(Service::Interface* self) {
|
||||
int ret = -1;
|
||||
int err = 0;
|
||||
|
||||
if(optname < 0) {
|
||||
if (optname < 0) {
|
||||
#ifdef _WIN32
|
||||
err = WSAEINVAL;
|
||||
#else
|
||||
@ -818,7 +826,7 @@ static void GetSockOpt(Service::Interface* self) {
|
||||
// 0x100 = static buffer offset (bytes)
|
||||
// + 0x4 = 2nd pointer (u32) position
|
||||
// >> 2 = convert to u32 offset instead of byte offset (cmd_buffer = u32*)
|
||||
char* optval = reinterpret_cast<char *>(Memory::GetPointer(cmd_buffer[0x104 >> 2]));
|
||||
char* optval = reinterpret_cast<char*>(Memory::GetPointer(cmd_buffer[0x104 >> 2]));
|
||||
|
||||
ret = ::getsockopt(socket_handle, level, optname, optval, &optlen);
|
||||
err = 0;
|
||||
@ -842,7 +850,7 @@ static void SetSockOpt(Service::Interface* self) {
|
||||
int ret = -1;
|
||||
int err = 0;
|
||||
|
||||
if(optname < 0) {
|
||||
if (optname < 0) {
|
||||
#ifdef _WIN32
|
||||
err = WSAEINVAL;
|
||||
#else
|
||||
@ -850,7 +858,7 @@ static void SetSockOpt(Service::Interface* self) {
|
||||
#endif
|
||||
} else {
|
||||
socklen_t optlen = static_cast<socklen_t>(cmd_buffer[4]);
|
||||
const char* optval = reinterpret_cast<const char *>(Memory::GetPointer(cmd_buffer[8]));
|
||||
const char* optval = reinterpret_cast<const char*>(Memory::GetPointer(cmd_buffer[8]));
|
||||
|
||||
ret = static_cast<u32>(::setsockopt(socket_handle, level, optname, optval, optlen));
|
||||
err = 0;
|
||||
@ -865,39 +873,39 @@ static void SetSockOpt(Service::Interface* self) {
|
||||
}
|
||||
|
||||
const Interface::FunctionInfo FunctionTable[] = {
|
||||
{0x00010044, InitializeSockets, "InitializeSockets"},
|
||||
{0x000200C2, Socket, "Socket"},
|
||||
{0x00030082, Listen, "Listen"},
|
||||
{0x00040082, Accept, "Accept"},
|
||||
{0x00050084, Bind, "Bind"},
|
||||
{0x00060084, Connect, "Connect"},
|
||||
{0x00070104, nullptr, "recvfrom_other"},
|
||||
{0x00080102, RecvFrom, "RecvFrom"},
|
||||
{0x00090106, nullptr, "sendto_other"},
|
||||
{0x000A0106, SendTo, "SendTo"},
|
||||
{0x000B0042, Close, "Close"},
|
||||
{0x000C0082, Shutdown, "Shutdown"},
|
||||
{0x000D0082, nullptr, "GetHostByName"},
|
||||
{0x000E00C2, nullptr, "GetHostByAddr"},
|
||||
{0x000F0106, nullptr, "GetAddrInfo"},
|
||||
{0x00100102, nullptr, "GetNameInfo"},
|
||||
{0x00110102, GetSockOpt, "GetSockOpt"},
|
||||
{0x00120104, SetSockOpt, "SetSockOpt"},
|
||||
{0x001300C2, Fcntl, "Fcntl"},
|
||||
{0x00140084, Poll, "Poll"},
|
||||
{0x00150042, nullptr, "SockAtMark"},
|
||||
{0x00160000, GetHostId, "GetHostId"},
|
||||
{0x00170082, GetSockName, "GetSockName"},
|
||||
{0x00180082, GetPeerName, "GetPeerName"},
|
||||
{0x00190000, ShutdownSockets, "ShutdownSockets"},
|
||||
{0x001A00C0, nullptr, "GetNetworkOpt"},
|
||||
{0x001B0040, nullptr, "ICMPSocket"},
|
||||
{0x001C0104, nullptr, "ICMPPing"},
|
||||
{0x001D0040, nullptr, "ICMPCancel"},
|
||||
{0x001E0040, nullptr, "ICMPClose"},
|
||||
{0x001F0040, nullptr, "GetResolverInfo"},
|
||||
{0x00210002, nullptr, "CloseSockets"},
|
||||
{0x00230040, nullptr, "AddGlobalSocket"},
|
||||
{0x00010044, InitializeSockets, "InitializeSockets"},
|
||||
{0x000200C2, Socket, "Socket"},
|
||||
{0x00030082, Listen, "Listen"},
|
||||
{0x00040082, Accept, "Accept"},
|
||||
{0x00050084, Bind, "Bind"},
|
||||
{0x00060084, Connect, "Connect"},
|
||||
{0x00070104, nullptr, "recvfrom_other"},
|
||||
{0x00080102, RecvFrom, "RecvFrom"},
|
||||
{0x00090106, nullptr, "sendto_other"},
|
||||
{0x000A0106, SendTo, "SendTo"},
|
||||
{0x000B0042, Close, "Close"},
|
||||
{0x000C0082, Shutdown, "Shutdown"},
|
||||
{0x000D0082, nullptr, "GetHostByName"},
|
||||
{0x000E00C2, nullptr, "GetHostByAddr"},
|
||||
{0x000F0106, nullptr, "GetAddrInfo"},
|
||||
{0x00100102, nullptr, "GetNameInfo"},
|
||||
{0x00110102, GetSockOpt, "GetSockOpt"},
|
||||
{0x00120104, SetSockOpt, "SetSockOpt"},
|
||||
{0x001300C2, Fcntl, "Fcntl"},
|
||||
{0x00140084, Poll, "Poll"},
|
||||
{0x00150042, nullptr, "SockAtMark"},
|
||||
{0x00160000, GetHostId, "GetHostId"},
|
||||
{0x00170082, GetSockName, "GetSockName"},
|
||||
{0x00180082, GetPeerName, "GetPeerName"},
|
||||
{0x00190000, ShutdownSockets, "ShutdownSockets"},
|
||||
{0x001A00C0, nullptr, "GetNetworkOpt"},
|
||||
{0x001B0040, nullptr, "ICMPSocket"},
|
||||
{0x001C0104, nullptr, "ICMPPing"},
|
||||
{0x001D0040, nullptr, "ICMPCancel"},
|
||||
{0x001E0040, nullptr, "ICMPClose"},
|
||||
{0x001F0040, nullptr, "GetResolverInfo"},
|
||||
{0x00210002, nullptr, "CloseSockets"},
|
||||
{0x00230040, nullptr, "AddGlobalSocket"},
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
Reference in New Issue
Block a user