1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 18:53:28 +01:00

sys_net full rewrite

Implement sys_net syscalls
Clean libnet functions
Use libnet.sprx
Use libhttp.sprx
Use libssl.sprx
Use librudp.sprx
Implement sys_ss_random_number_generator
This commit is contained in:
Nekotekina 2017-09-25 18:52:34 +03:00
parent 6335fa8df1
commit e5f756205c
21 changed files with 3061 additions and 1662 deletions

View File

@ -156,6 +156,10 @@ error_code cellNetCtlGetInfo(s32 code, vm::ptr<CellNetCtlInfo> info)
{
strcpy_trunc(info->netmask, "255.255.255.255");
}
else if (code == CELL_NET_CTL_INFO_HTTP_PROXY_CONFIG)
{
info->http_proxy_config = 0;
}
return CELL_OK;
}

View File

@ -1,7 +1,5 @@
#pragma once
#include "sys_net.h"
namespace vm { using namespace ps3; }
// Return Codes
@ -79,7 +77,9 @@ enum
CELL_RUDP_POLL_EV_ERROR = 0x0008,
};
using CellRudpEventHandler = s32(s32 event_id, s32 soc, vm::cptr<u8> data, u32 datalen, vm::cptr<sys_net::sockaddr> addr, u32 addrlen, vm::ptr<void> arg);
struct sys_net_sockaddr;
using CellRudpEventHandler = s32(s32 event_id, s32 soc, vm::cptr<u8> data, u32 datalen, vm::cptr<sys_net_sockaddr> addr, u32 addrlen, vm::ptr<void> arg);
using CellRudpAllocatorFuncAlloc = vm::ptr<void>(u32 size);
using CellRudpAllocatorFuncFree = void(vm::ptr<void> ptr);

View File

@ -5,6 +5,7 @@
#include "Emu/Cell/lv2/sys_mutex.h"
#include "Emu/Cell/lv2/sys_interrupt.h"
#include "Emu/Cell/lv2/sys_process.h"
#include "Emu/Cell/lv2/sys_ss.h"
#include "sysPrxForUser.h"
logs::channel sysPrxForUser("sysPrxForUser");
@ -71,7 +72,7 @@ s32 sys_process_get_paramsfo(vm::ptr<char> buffer)
return _sys_process_get_paramsfo(buffer);
}
s32 sys_get_random_number(vm::ptr<u8> addr, u64 size)
s32 sys_get_random_number(vm::ptr<void> addr, u64 size)
{
sysPrxForUser.warning("sys_get_random_number(addr=*0x%x, size=%d)", addr, size);
@ -80,9 +81,12 @@ s32 sys_get_random_number(vm::ptr<u8> addr, u64 size)
return CELL_EINVAL;
}
for (u32 i = 0; i < (u32)size; i++)
switch (u32 rs = sys_ss_random_number_generator(2, addr, size))
{
addr[i] = rand() & 0xff;
case 0x80010501: return CELL_ENOMEM;
case 0x80010503: return CELL_EAGAIN;
case 0x80010509: return CELL_EINVAL;
default: if (rs) return CELL_EABORT;
}
return CELL_OK;

File diff suppressed because it is too large Load Diff

View File

@ -1,245 +0,0 @@
#if defined(__FreeBSD__)
#include <sys/select.h>
#undef fds_bits
#endif
#pragma once
namespace vm { using namespace ps3; }
namespace sys_net
{
// It turns out SOL_SOCKET is equal to 1 on Linux, but 0xffff on Windows, and it appears the PS3 uses 0xffff, like Windows
#define PS3_SOL_SOCKET 0xffff
// Error codes
enum
{
SYS_NET_ENOENT = 2,
SYS_NET_EINTR = 4,
SYS_NET_EBADF = 9,
SYS_NET_ENOMEM = 12,
SYS_NET_EACCES = 13,
SYS_NET_EFAULT = 14,
SYS_NET_EBUSY = 16,
SYS_NET_EINVAL = 22,
SYS_NET_EMFILE = 24,
SYS_NET_ENOSPC = 28,
SYS_NET_EPIPE = 32,
SYS_NET_EAGAIN = 35,
SYS_NET_EWOULDBLOCK = SYS_NET_EAGAIN,
SYS_NET_EINPROGRESS = 36,
SYS_NET_EALREADY = 37,
SYS_NET_EDESTADDRREQ = 39,
SYS_NET_EMSGSIZE = 40,
SYS_NET_EPROTOTYPE = 41,
SYS_NET_ENOPROTOOPT = 42,
SYS_NET_EPROTONOSUPPORT = 43,
SYS_NET_EOPNOTSUPP = 45,
SYS_NET_EPFNOSUPPORT = 46,
SYS_NET_EAFNOSUPPORT = 47,
SYS_NET_EADDRINUSE = 48,
SYS_NET_EADDRNOTAVAIL = 49,
SYS_NET_ENETDOWN = 50,
SYS_NET_ENETUNREACH = 51,
SYS_NET_ECONNABORTED = 53,
SYS_NET_ECONNRESET = 54,
SYS_NET_ENOBUFS = 55,
SYS_NET_EISCONN = 56,
SYS_NET_ENOTCONN = 57,
SYS_NET_ESHUTDOWN = 58,
SYS_NET_ETOOMANYREFS = 59,
SYS_NET_ETIMEDOUT = 60,
SYS_NET_ECONNREFUSED = 61,
SYS_NET_EHOSTDOWN = 64,
SYS_NET_EHOSTUNREACH = 65,
};
// Socket types
enum
{
SOCK_STREAM = 1,
SOCK_DGRAM = 2,
SOCK_RAW = 3,
SOCK_DGRAM_P2P = 6,
SOCK_STREAM_P2P = 10,
};
// Socket options
// Note: All options are prefixed with "OP_" to prevent name conflicts.
enum
{
OP_SO_SNDBUF = 0x1001,
OP_SO_RCVBUF = 0x1002,
OP_SO_SNDLOWAT = 0x1003,
OP_SO_RCVLOWAT = 0x1004,
OP_SO_SNDTIMEO = 0x1005,
OP_SO_RCVTIMEO = 0x1006,
OP_SO_ERROR = 0x1007,
OP_SO_TYPE = 0x1008,
OP_SO_NBIO = 0x1100, // Non-blocking IO
OP_SO_TPPOLICY = 0x1101,
OP_SO_REUSEADDR = 0x0004,
OP_SO_KEEPALIVE = 0x0008,
OP_SO_BROADCAST = 0x0020,
OP_SO_LINGER = 0x0080,
OP_SO_OOBINLINE = 0x0100,
OP_SO_REUSEPORT = 0x0200,
OP_SO_ONESBCAST = 0x0800,
OP_SO_USECRYPTO = 0x1000,
OP_SO_USESIGNATURE = 0x2000,
};
// TCP options
enum
{
OP_TCP_NODELAY = 1,
OP_TCP_MAXSEG = 2,
OP_TCP_MSS_TO_ADVERTISE = 3,
};
// IP protocols
// Note: Proctols are prefixed with "PROTO_" to prevent name conflicts
enum
{
PROTO_IPPROTO_IP = 0,
PROTO_IPPROTO_ICMP = 1,
PROTO_IPPROTO_IGMP = 2,
PROTO_IPPROTO_TCP = 6,
PROTO_IPPROTO_UDP = 17,
PROTO_IPPROTO_ICMPV6 = 58,
};
// only for reference, no need to use it
using in_addr_t = u32;
using in_port_t = u16;
using sa_family_t = u8;
using socklen_t = u32;
struct fd_set
{
be_t<u32> fds_bits[32];
};
struct hostent
{
vm::bptr<char> h_name;
vm::bpptr<char> h_aliases;
be_t<s32> h_addrtype;
be_t<s32> h_length;
vm::bpptr<char> h_addr_list;
};
struct in_addr
{
be_t<u32> s_addr;
};
struct iovec
{
be_t<s32> zero1;
vm::bptr<void> iov_base;
be_t<s32> zero2;
be_t<u32> iov_len;
};
struct ip_mreq
{
be_t<u32> imr_multiaddr;
be_t<u32> imr_interface;
};
struct msghdr
{
be_t<s32> zero1;
vm::bptr<void> msg_name;
be_t<u32> msg_namelen;
be_t<s32> pad1;
be_t<s32> zero2;
vm::bptr<iovec> msg_iov;
be_t<s32> msg_iovlen;
be_t<s32> pad2;
be_t<s32> zero3;
vm::bptr<void> msg_control;
be_t<u32> msg_controllen;
be_t<s32> msg_flags;
};
struct pollfd
{
be_t<s32> fd;
be_t<s16> events;
be_t<s16> revents;
};
struct sockaddr
{
u8 sa_len;
u8 sa_family;
char sa_data[14];
};
struct sockaddr_dl
{
u8 sdl_len;
u8 sdl_family;
be_t<u16> sdl_index;
u8 sdl_type;
u8 sdl_nlen;
u8 sdl_alen;
u8 sdl_slen;
char sdl_data[12];
};
struct sockaddr_in
{
u8 sin_len;
u8 sin_family;
be_t<u16> sin_port;
be_t<u32> sin_addr;
char sin_zero[8];
};
struct sockaddr_in_p2p
{
u8 sin_len;
u8 sin_family;
be_t<u16> sin_port;
be_t<u32> sin_addr;
be_t<u16> sin_vport;
char sin_zero[6];
};
struct timeval
{
be_t<s64> tv_sec;
be_t<s64> tv_usec;
};
struct sys_net_sockinfo_t
{
be_t<s32> s;
be_t<s32> proto;
be_t<s32> recv_queue_length;
be_t<s32> send_queue_length;
in_addr local_adr;
be_t<s32> local_port;
in_addr remote_adr;
be_t<s32> remote_port;
be_t<s32> state;
};
}
struct sys_net_initialize_parameter_t
{
vm::bptr<void> memory;
be_t<s32> memory_size;
be_t<s32> flags;
};
// PS3 libnet socket struct
struct net_socket_t
{
std::intptr_t native_handle;
};

View File

@ -0,0 +1,737 @@
#include "stdafx.h"
#include "Emu/Cell/PPUModule.h"
#include "Emu/IdManager.h"
#include "sys_net_.h"
namespace vm { using namespace ps3; }
logs::channel libnet("libnet");
struct sys_net_tls_data
{
be_t<s32> _errno;
be_t<s32> _h_errno;
char addr[16];
};
// TODO
thread_local vm::ptr<sys_net_tls_data> g_tls_net_data{};
static NEVER_INLINE vm::ptr<sys_net_tls_data> get_tls()
{
// Allocate if not initialized
if (!g_tls_net_data)
{
g_tls_net_data.set(vm::alloc(sizeof(decltype(g_tls_net_data)::type), vm::main));
// Initial values
g_tls_net_data->_errno = SYS_NET_EBUSY;
thread_ctrl::atexit([addr = g_tls_net_data.addr()]
{
vm::dealloc_verbose_nothrow(addr, vm::main);
});
}
return g_tls_net_data;
}
s32 sys_net_accept(s32 s, vm::ptr<sys_net_sockaddr> addr, vm::ptr<u32> paddrlen)
{
libnet.todo("accept(s=%d, addr=*0x%x, paddrlen=*0x%x)", s, addr, paddrlen);
return 0;
}
s32 sys_net_bind(s32 s, vm::cptr<sys_net_sockaddr> addr, u32 addrlen)
{
libnet.todo("bind(s=%d, addr=*0x%x, addrlen=%u)", s, addr, addrlen);
return 0;
}
s32 sys_net_connect(s32 s, vm::ptr<sys_net_sockaddr> addr, u32 addrlen)
{
libnet.todo("connect(s=%d, addr=*0x%x, addrlen=%u)", s, addr, addrlen);
return 0;
}
s32 sys_net_gethostbyaddr()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 sys_net_gethostbyname()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 sys_net_getpeername(s32 s, vm::ptr<sys_net_sockaddr> addr, vm::ptr<u32> paddrlen)
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 sys_net_getsockname(s32 s, vm::ptr<sys_net_sockaddr> addr, vm::ptr<u32> paddrlen)
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 sys_net_getsockopt(s32 s, s32 level, s32 optname, vm::ptr<void> optval, vm::ptr<u32> optlen)
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
u32 sys_net_inet_addr(vm::cptr<char> cp)
{
libnet.todo("inet_addr(cp=%s)", cp);
return 0xffffffff;
}
s32 sys_net_inet_aton()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 sys_net_inet_lnaof()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 sys_net_inet_makeaddr()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 sys_net_inet_netof()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 sys_net_inet_network()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
vm::ptr<char> sys_net_inet_ntoa(u32 in)
{
libnet.todo("inet_ntoa(in=0x%x)", in);
return vm::null;
}
vm::cptr<char> sys_net_inet_ntop(s32 af, vm::ptr<void> src, vm::ptr<char> dst, u32 size)
{
libnet.todo("inet_ntop(af=%d, src=%s, dst=*0x%x, size=%d)", af, src, dst, size);
return vm::null;
}
s32 sys_net_inet_pton(s32 af, vm::cptr<char> src, vm::ptr<char> dst)
{
libnet.todo("inet_pton(af=%d, src=%s, dst=*0x%x)", af, src, dst);
return 0;
}
s32 sys_net_listen(s32 s, s32 backlog)
{
libnet.todo("listen(s=%d, backlog=%d)", s, backlog);
return 0;
}
s32 sys_net_recv(s32 s, vm::ptr<void> buf, u32 len, s32 flags)
{
libnet.todo("recv(s=%d, buf=*0x%x, len=%d, flags=0x%x)", s, buf, len, flags);
return 0;
}
s32 sys_net_recvfrom(s32 s, vm::ptr<void> buf, u32 len, s32 flags, vm::ptr<sys_net_sockaddr> addr, vm::ptr<u32> paddrlen)
{
libnet.todo("recvfrom(s=%d, buf=*0x%x, len=%d, flags=0x%x, addr=*0x%x, paddrlen=*0x%x)", s, buf, len, flags, addr, paddrlen);
return 0;
}
s32 sys_net_recvmsg(s32 s, vm::ptr<sys_net_msghdr> msg, s32 flags)
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 sys_net_send(s32 s, vm::cptr<void> buf, u32 len, s32 flags)
{
libnet.todo("send(s=%d, buf=*0x%x, len=%d, flags=0x%x)", s, buf, len, flags);
return 0;
}
s32 sys_net_sendmsg(s32 s, vm::cptr<sys_net_msghdr> msg, s32 flags)
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 sys_net_sendto(s32 s, vm::cptr<void> buf, u32 len, s32 flags, vm::cptr<sys_net_sockaddr> addr, u32 addrlen)
{
libnet.todo("sendto(s=%d, buf=*0x%x, len=%d, flags=0x%x, addr=*0x%x, addrlen=%d)", s, buf, len, flags, addr, addrlen);
return 0;
}
s32 sys_net_setsockopt(s32 s, s32 level, s32 optname, vm::cptr<void> optval, u32 optlen)
{
libnet.todo("setsockopt(s=%d, level=%d, optname=%d, optval=*0x%x, optlen=%d)", s, level, optname, optval, optlen);
return 0;
}
s32 sys_net_shutdown(s32 s, s32 how)
{
libnet.todo("shutdown(s=%d, how=%d)", s, how);
return 0;
}
s32 sys_net_socket(s32 family, s32 type, s32 protocol)
{
libnet.todo("socket(family=%d, type=%d, protocol=%d)", family, type, protocol);
return 0;
}
s32 sys_net_socketclose(s32 s)
{
libnet.warning("socketclose(s=%d)", s);
return 0;
}
s32 sys_net_socketpoll(vm::ptr<sys_net_pollfd> fds, s32 nfds, s32 ms)
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 sys_net_socketselect(s32 nfds, vm::ptr<sys_net_fd_set> readfds, vm::ptr<sys_net_fd_set> writefds, vm::ptr<sys_net_fd_set> exceptfds, vm::ptr<sys_net_timeval> timeout)
{
libnet.todo("socketselect(nfds=%d, readfds=*0x%x, writefds=*0x%x, exceptfds=*0x%x, timeout=*0x%x)", nfds, readfds, writefds, exceptfds, timeout);
return 0;
}
s32 sys_net_initialize_network_ex(vm::ptr<sys_net_initialize_parameter_t> param)
{
libnet.todo("sys_net_initialize_network_ex(param=*0x%x)", param);
return CELL_OK;
}
s32 sys_net_get_udpp2p_test_param()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 sys_net_set_udpp2p_test_param()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 sys_net_get_lib_name_server()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 sys_net_if_ctl()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 sys_net_get_if_list()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 sys_net_get_name_server()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 sys_net_get_netemu_test_param()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 sys_net_get_routing_table_af()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 sys_net_get_sockinfo(s32 s, vm::ptr<sys_net_sockinfo_t> p, s32 n)
{
libnet.todo("sys_net_get_sockinfo(s=%d, p=*0x%x, n=%d)", s, p, n);
return CELL_OK;
}
s32 sys_net_close_dump(s32 id, vm::ptr<s32> pflags)
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 sys_net_set_test_param()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 sys_net_show_nameserver()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
vm::ptr<s32> _sys_net_errno_loc()
{
libnet.warning("_sys_net_errno_loc()");
return get_tls().ptr(&sys_net_tls_data::_errno);
}
s32 sys_net_set_resolver_configurations()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 sys_net_show_route()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 sys_net_read_dump(s32 id, vm::ptr<void> buf, s32 len, vm::ptr<s32> pflags)
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 sys_net_abort_resolver()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 sys_net_abort_socket()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 sys_net_set_lib_name_server()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 sys_net_get_test_param()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 sys_net_get_sockinfo_ex()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 sys_net_open_dump(s32 len, s32 flags)
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 sys_net_show_ifconfig()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 sys_net_finalize_network()
{
libnet.todo("sys_net_finalize_network()");
return CELL_OK;
}
vm::ptr<s32> _sys_net_h_errno_loc()
{
libnet.warning("_sys_net_h_errno_loc()");
return get_tls().ptr(&sys_net_tls_data::_h_errno);
}
s32 sys_net_set_netemu_test_param()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 sys_net_free_thread_context(u64 tid, s32 flags)
{
libnet.todo("sys_net_free_thread_context(tid=0x%x, flags=%d)", tid, flags);
return CELL_OK;
}
s32 _sys_net_lib_abort()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 _sys_net_lib_bnet_control()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 __sys_net_lib_calloc()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 _sys_net_lib_free()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 _sys_net_lib_get_system_time()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 _sys_net_lib_if_nametoindex()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 _sys_net_lib_ioctl()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 __sys_net_lib_malloc()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 _sys_net_lib_rand()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 __sys_net_lib_realloc()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 _sys_net_lib_reset_libnetctl_queue()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 _sys_net_lib_set_libnetctl_queue()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 _sys_net_lib_thread_create()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 _sys_net_lib_thread_exit()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 _sys_net_lib_thread_join()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 _sys_net_lib_sync_clear()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 _sys_net_lib_sync_create()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 _sys_net_lib_sync_destroy()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 _sys_net_lib_sync_signal()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 _sys_net_lib_sync_wait()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 _sys_net_lib_sysctl()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 _sys_net_lib_usleep()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 sys_netset_abort()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 sys_netset_close()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 sys_netset_get_if_id()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 sys_netset_get_status()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 sys_netset_if_down()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 sys_netset_get_key_value()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 sys_netset_if_up()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 sys_netset_open()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 _sce_net_get_name_server()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 _sce_net_add_name_server()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 _sce_net_add_name_server_with_char()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 _sce_net_flush_route()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 _sce_net_set_default_gateway()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 _sce_net_set_ip_and_mask()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
s32 _sce_net_set_name_server()
{
UNIMPLEMENTED_FUNC(libnet);
return CELL_OK;
}
DECLARE(ppu_module_manager::sys_net)("sys_net", []()
{
REG_FNID(sys_net, "accept", sys_net_accept);
REG_FNID(sys_net, "bind", sys_net_bind);
REG_FNID(sys_net, "connect", sys_net_connect);
REG_FNID(sys_net, "gethostbyaddr", sys_net_gethostbyaddr);
REG_FNID(sys_net, "gethostbyname", sys_net_gethostbyname);
REG_FNID(sys_net, "getpeername", sys_net_getpeername);
REG_FNID(sys_net, "getsockname", sys_net_getsockname);
REG_FNID(sys_net, "getsockopt", sys_net_getsockopt);
REG_FNID(sys_net, "inet_addr", sys_net_inet_addr);
REG_FNID(sys_net, "inet_aton", sys_net_inet_aton);
REG_FNID(sys_net, "inet_lnaof", sys_net_inet_lnaof);
REG_FNID(sys_net, "inet_makeaddr", sys_net_inet_makeaddr);
REG_FNID(sys_net, "inet_netof", sys_net_inet_netof);
REG_FNID(sys_net, "inet_network", sys_net_inet_network);
REG_FNID(sys_net, "inet_ntoa", sys_net_inet_ntoa);
REG_FNID(sys_net, "inet_ntop", sys_net_inet_ntop);
REG_FNID(sys_net, "inet_pton", sys_net_inet_pton);
REG_FNID(sys_net, "listen", sys_net_listen);
REG_FNID(sys_net, "recv", sys_net_recv);
REG_FNID(sys_net, "recvfrom", sys_net_recvfrom);
REG_FNID(sys_net, "recvmsg", sys_net_recvmsg);
REG_FNID(sys_net, "send", sys_net_send);
REG_FNID(sys_net, "sendmsg", sys_net_sendmsg);
REG_FNID(sys_net, "sendto", sys_net_sendto);
REG_FNID(sys_net, "setsockopt", sys_net_setsockopt);
REG_FNID(sys_net, "shutdown", sys_net_shutdown);
REG_FNID(sys_net, "socket", sys_net_socket);
REG_FNID(sys_net, "socketclose", sys_net_socketclose);
REG_FNID(sys_net, "socketpoll", sys_net_socketpoll);
REG_FNID(sys_net, "socketselect", sys_net_socketselect);
REG_FUNC(sys_net, sys_net_initialize_network_ex);
REG_FUNC(sys_net, sys_net_get_udpp2p_test_param);
REG_FUNC(sys_net, sys_net_set_udpp2p_test_param);
REG_FUNC(sys_net, sys_net_get_lib_name_server);
REG_FUNC(sys_net, sys_net_if_ctl);
REG_FUNC(sys_net, sys_net_get_if_list);
REG_FUNC(sys_net, sys_net_get_name_server);
REG_FUNC(sys_net, sys_net_get_netemu_test_param);
REG_FUNC(sys_net, sys_net_get_routing_table_af);
REG_FUNC(sys_net, sys_net_get_sockinfo);
REG_FUNC(sys_net, sys_net_close_dump);
REG_FUNC(sys_net, sys_net_set_test_param);
REG_FUNC(sys_net, sys_net_show_nameserver);
REG_FUNC(sys_net, _sys_net_errno_loc);
REG_FUNC(sys_net, sys_net_set_resolver_configurations);
REG_FUNC(sys_net, sys_net_show_route);
REG_FUNC(sys_net, sys_net_read_dump);
REG_FUNC(sys_net, sys_net_abort_resolver);
REG_FUNC(sys_net, sys_net_abort_socket);
REG_FUNC(sys_net, sys_net_set_lib_name_server);
REG_FUNC(sys_net, sys_net_get_test_param);
REG_FUNC(sys_net, sys_net_get_sockinfo_ex);
REG_FUNC(sys_net, sys_net_open_dump);
REG_FUNC(sys_net, sys_net_show_ifconfig);
REG_FUNC(sys_net, sys_net_finalize_network);
REG_FUNC(sys_net, _sys_net_h_errno_loc);
REG_FUNC(sys_net, sys_net_set_netemu_test_param);
REG_FUNC(sys_net, sys_net_free_thread_context);
REG_FUNC(sys_net, _sys_net_lib_abort);
REG_FUNC(sys_net, _sys_net_lib_bnet_control);
REG_FUNC(sys_net, __sys_net_lib_calloc);
REG_FUNC(sys_net, _sys_net_lib_free);
REG_FUNC(sys_net, _sys_net_lib_get_system_time);
REG_FUNC(sys_net, _sys_net_lib_if_nametoindex);
REG_FUNC(sys_net, _sys_net_lib_ioctl);
REG_FUNC(sys_net, __sys_net_lib_malloc);
REG_FUNC(sys_net, _sys_net_lib_rand);
REG_FUNC(sys_net, __sys_net_lib_realloc);
REG_FUNC(sys_net, _sys_net_lib_reset_libnetctl_queue);
REG_FUNC(sys_net, _sys_net_lib_set_libnetctl_queue);
REG_FUNC(sys_net, _sys_net_lib_thread_create);
REG_FUNC(sys_net, _sys_net_lib_thread_exit);
REG_FUNC(sys_net, _sys_net_lib_thread_join);
REG_FUNC(sys_net, _sys_net_lib_sync_clear);
REG_FUNC(sys_net, _sys_net_lib_sync_create);
REG_FUNC(sys_net, _sys_net_lib_sync_destroy);
REG_FUNC(sys_net, _sys_net_lib_sync_signal);
REG_FUNC(sys_net, _sys_net_lib_sync_wait);
REG_FUNC(sys_net, _sys_net_lib_sysctl);
REG_FUNC(sys_net, _sys_net_lib_usleep);
REG_FUNC(sys_net, sys_netset_abort);
REG_FUNC(sys_net, sys_netset_close);
REG_FUNC(sys_net, sys_netset_get_if_id);
REG_FUNC(sys_net, sys_netset_get_key_value);
REG_FUNC(sys_net, sys_netset_get_status);
REG_FUNC(sys_net, sys_netset_if_down);
REG_FUNC(sys_net, sys_netset_if_up);
REG_FUNC(sys_net, sys_netset_open);
REG_FUNC(sys_net, _sce_net_add_name_server);
REG_FUNC(sys_net, _sce_net_add_name_server_with_char);
REG_FUNC(sys_net, _sce_net_flush_route);
REG_FUNC(sys_net, _sce_net_get_name_server);
REG_FUNC(sys_net, _sce_net_set_default_gateway);
REG_FUNC(sys_net, _sce_net_set_ip_and_mask);
REG_FUNC(sys_net, _sce_net_set_name_server);
});

View File

@ -0,0 +1,41 @@
#pragma once
#include "Emu/Cell/lv2/sys_net.h"
#include "Emu/Memory/vm.h"
struct sys_net_sockinfo_t
{
be_t<s32> s;
be_t<s32> proto;
be_t<s32> recv_queue_length;
be_t<s32> send_queue_length;
sys_net_in_addr local_adr;
be_t<s32> local_port;
sys_net_in_addr remote_adr;
be_t<s32> remote_port;
be_t<s32> state;
};
struct sys_net_sockinfo_ex_t
{
be_t<s32> s;
be_t<s32> proto;
be_t<s32> recv_queue_length;
be_t<s32> send_queue_length;
sys_net_in_addr local_adr;
be_t<s32> local_port;
sys_net_in_addr remote_adr;
be_t<s32> remote_port;
be_t<s32> state;
be_t<s32> socket_type;
be_t<s32> local_vport;
be_t<s32> remote_vport;
be_t<s32> reserved[8];
};
struct sys_net_initialize_parameter_t
{
vm::ps3::bptr<void> memory;
be_t<s32> memory_size;
be_t<s32> flags;
};

View File

@ -413,16 +413,16 @@ extern std::string ppu_get_syscall_name(u64 code)
case 708: return "sys_net_bnet_recvmsg";
case 709: return "sys_net_bnet_sendmsg";
case 710: return "sys_net_bnet_sendto";
case 711: return "sys_net_bnet_setsockop";
case 711: return "sys_net_bnet_setsockopt";
case 712: return "sys_net_bnet_shutdown";
case 713: return "sys_net_bnet_socket";
case 714: return "sys_net_bnet_close";
case 715: return "sys_net_bnet_poll";
case 716: return "sys_net_bnet_select";
case 717: return "sys_net_open_dump";
case 718: return "sys_net_read_dump";
case 719: return "sys_net_close_dump";
case 720: return "sys_net_write_dump";
case 717: return "_sys_net_open_dump";
case 718: return "_sys_net_read_dump";
case 719: return "_sys_net_close_dump";
case 720: return "_sys_net_write_dump";
case 721: return "sys_net_abort";
case 722: return "sys_net_infoctl";
case 723: return "sys_net_control";

View File

@ -248,7 +248,7 @@ static void ppu_initialize_modules(const std::shared_ptr<ppu_linkage_info>& link
&ppu_module_manager::sceNpTus,
&ppu_module_manager::sceNpUtil,
&ppu_module_manager::sys_io,
&ppu_module_manager::libnet,
&ppu_module_manager::sys_net,
&ppu_module_manager::sysPrxForUser,
&ppu_module_manager::sys_libc,
&ppu_module_manager::sys_lv2dbg,

View File

@ -243,7 +243,7 @@ public:
static const ppu_static_module sceNpTus;
static const ppu_static_module sceNpUtil;
static const ppu_static_module sys_io;
static const ppu_static_module libnet;
static const ppu_static_module sys_net;
static const ppu_static_module sysPrxForUser;
static const ppu_static_module sys_libc;
static const ppu_static_module sys_lv2dbg;

View File

@ -1164,9 +1164,9 @@ extern void ppu_initialize(const ppu_module& info)
sha1_update(&ctx, vm::ps3::_ptr<const u8>(func.addr), func.size);
}
if (info.name == "liblv2.sprx")
if (info.name == "liblv2.sprx" || info.name == "libsysmodule.sprx" || info.name == "libnet.sprx")
{
const be_t<u64> forced_upd = 2;
const be_t<u64> forced_upd = 3;
sha1_update(&ctx, reinterpret_cast<const u8*>(&forced_upd), sizeof(forced_upd));
}

View File

@ -14,6 +14,7 @@
#include "sys_interrupt.h"
#include "sys_memory.h"
#include "sys_mmapper.h"
#include "sys_net.h"
#include "sys_ppu_thread.h"
#include "sys_process.h"
#include "sys_prx.h"
@ -663,33 +664,33 @@ const std::array<ppu_function_t, 1024> s_ppu_syscall_table
null_func,//BIND_FUNC(sys_...) //697 (0x2B9) UNS
null_func,//BIND_FUNC(sys_...) //698 (0x2BA) UNS
null_func,//BIND_FUNC(sys_bdemu_send_command) //699 (0x2BB)
null_func,//BIND_FUNC(sys_net_bnet_accept) //700 (0x2BC)
null_func,//BIND_FUNC(sys_net_bnet_bind) //701 (0x2BD)
null_func,//BIND_FUNC(sys_net_bnet_connect) //702 (0x2BE)
null_func,//BIND_FUNC(sys_net_bnet_getpeername) //703 (0x2BF)
null_func,//BIND_FUNC(sys_net_bnet_getsockname) //704 (0x2C0)
null_func,//BIND_FUNC(sys_net_bnet_getsockopt) //705 (0x2C1)
null_func,//BIND_FUNC(sys_net_bnet_listen) //706 (0x2C2)
null_func,//BIND_FUNC(sys_net_bnet_recvfrom) //707 (0x2C3)
null_func,//BIND_FUNC(sys_net_bnet_recvmsg) //708 (0x2C4)
null_func,//BIND_FUNC(sys_net_bnet_sendmsg) //709 (0x2C5)
null_func,//BIND_FUNC(sys_net_bnet_sendto) //710 (0x2C6)
null_func,//BIND_FUNC(sys_net_bnet_setsockop) //711 (0x2C7)
null_func,//BIND_FUNC(sys_net_bnet_shutdown) //712 (0x2C8)
null_func,//BIND_FUNC(sys_net_bnet_socket) //713 (0x2C9)
null_func,//BIND_FUNC(sys_net_bnet_close) //714 (0x2CA)
null_func,//BIND_FUNC(sys_net_bnet_poll) //715 (0x2CB)
null_func,//BIND_FUNC(sys_net_bnet_select) //716 (0x2CC)
null_func,//BIND_FUNC(sys_net_open_dump) //717 (0x2CD)
null_func,//BIND_FUNC(sys_net_read_dump) //718 (0x2CE)
null_func,//BIND_FUNC(sys_net_close_dump) //719 (0x2CF)
null_func,//BIND_FUNC(sys_net_write_dump) //720 (0x2D0)
null_func,//BIND_FUNC(sys_net_abort) //721 (0x2D1)
null_func,//BIND_FUNC(sys_net_infoctl) //722 (0x2D2)
null_func,//BIND_FUNC(sys_net_control) //723 (0x2D3)
null_func,//BIND_FUNC(sys_net_bnet_ioctl) //724 (0x2D4)
null_func,//BIND_FUNC(sys_net_bnet_sysctl) //725 (0x2D5)
null_func,//BIND_FUNC(sys_net_eurus_post_command) //726 (0x2D6)
BIND_FUNC(sys_net_bnet_accept), //700 (0x2BC)
BIND_FUNC(sys_net_bnet_bind), //701 (0x2BD)
BIND_FUNC(sys_net_bnet_connect), //702 (0x2BE)
BIND_FUNC(sys_net_bnet_getpeername), //703 (0x2BF)
BIND_FUNC(sys_net_bnet_getsockname), //704 (0x2C0)
BIND_FUNC(sys_net_bnet_getsockopt), //705 (0x2C1)
BIND_FUNC(sys_net_bnet_listen), //706 (0x2C2)
BIND_FUNC(sys_net_bnet_recvfrom), //707 (0x2C3)
BIND_FUNC(sys_net_bnet_recvmsg), //708 (0x2C4)
BIND_FUNC(sys_net_bnet_sendmsg), //709 (0x2C5)
BIND_FUNC(sys_net_bnet_sendto), //710 (0x2C6)
BIND_FUNC(sys_net_bnet_setsockopt), //711 (0x2C7)
BIND_FUNC(sys_net_bnet_shutdown), //712 (0x2C8)
BIND_FUNC(sys_net_bnet_socket), //713 (0x2C9)
BIND_FUNC(sys_net_bnet_close), //714 (0x2CA)
BIND_FUNC(sys_net_bnet_poll), //715 (0x2CB)
BIND_FUNC(sys_net_bnet_select), //716 (0x2CC)
BIND_FUNC(_sys_net_open_dump), //717 (0x2CD)
BIND_FUNC(_sys_net_read_dump), //718 (0x2CE)
BIND_FUNC(_sys_net_close_dump), //719 (0x2CF)
BIND_FUNC(_sys_net_write_dump), //720 (0x2D0)
BIND_FUNC(sys_net_abort), //721 (0x2D1)
BIND_FUNC(sys_net_infoctl), //722 (0x2D2)
BIND_FUNC(sys_net_control), //723 (0x2D3)
BIND_FUNC(sys_net_bnet_ioctl), //724 (0x2D4)
BIND_FUNC(sys_net_bnet_sysctl), //725 (0x2D5)
BIND_FUNC(sys_net_eurus_post_command), //726 (0x2D6)
null_func, null_func, null_func, //729 UNS
null_func, null_func, null_func, null_func, null_func, //734 UNS
@ -765,7 +766,7 @@ const std::array<ppu_function_t, 1024> s_ppu_syscall_table
null_func,//BIND_FUNC(syscall_...) //862 ROOT
null_func,//BIND_FUNC(syscall_...) //863 ROOT
null_func,//BIND_FUNC(syscall_...) //864 DBG
null_func,//BIND_FUNC(sys_ss_random_number_generator), //865 (0x361) ROOT AUTHID
BIND_FUNC(sys_ss_random_number_generator), //865 (0x361)
null_func,//BIND_FUNC(sys_...) //866 ROOT
null_func,//BIND_FUNC(sys_...) //867 ROOT
null_func,//BIND_FUNC(sys_...) //868 ROOT / DBG AUTHID

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,383 @@
#pragma once
#include "Utilities/bit_set.h"
#include "Utilities/sema.h"
#include <vector>
#include <utility>
#include <functional>
// Error codes
enum
{
SYS_NET_ENOENT = 2,
SYS_NET_EINTR = 4,
SYS_NET_EBADF = 9,
SYS_NET_ENOMEM = 12,
SYS_NET_EACCES = 13,
SYS_NET_EFAULT = 14,
SYS_NET_EBUSY = 16,
SYS_NET_EINVAL = 22,
SYS_NET_EMFILE = 24,
SYS_NET_ENOSPC = 28,
SYS_NET_EPIPE = 32,
SYS_NET_EAGAIN = 35,
SYS_NET_EWOULDBLOCK = SYS_NET_EAGAIN,
SYS_NET_EINPROGRESS = 36,
SYS_NET_EALREADY = 37,
SYS_NET_EDESTADDRREQ = 39,
SYS_NET_EMSGSIZE = 40,
SYS_NET_EPROTOTYPE = 41,
SYS_NET_ENOPROTOOPT = 42,
SYS_NET_EPROTONOSUPPORT = 43,
SYS_NET_EOPNOTSUPP = 45,
SYS_NET_EPFNOSUPPORT = 46,
SYS_NET_EAFNOSUPPORT = 47,
SYS_NET_EADDRINUSE = 48,
SYS_NET_EADDRNOTAVAIL = 49,
SYS_NET_ENETDOWN = 50,
SYS_NET_ENETUNREACH = 51,
SYS_NET_ECONNABORTED = 53,
SYS_NET_ECONNRESET = 54,
SYS_NET_ENOBUFS = 55,
SYS_NET_EISCONN = 56,
SYS_NET_ENOTCONN = 57,
SYS_NET_ESHUTDOWN = 58,
SYS_NET_ETOOMANYREFS = 59,
SYS_NET_ETIMEDOUT = 60,
SYS_NET_ECONNREFUSED = 61,
SYS_NET_EHOSTDOWN = 64,
SYS_NET_EHOSTUNREACH = 65,
};
// Socket types (prefixed with SYS_NET_)
enum
{
SYS_NET_SOCK_STREAM = 1,
SYS_NET_SOCK_DGRAM = 2,
SYS_NET_SOCK_RAW = 3,
SYS_NET_SOCK_DGRAM_P2P = 6,
SYS_NET_SOCK_STREAM_P2P = 10,
};
// Socket options (prefixed with SYS_NET_)
enum
{
SYS_NET_SO_SNDBUF = 0x1001,
SYS_NET_SO_RCVBUF = 0x1002,
SYS_NET_SO_SNDLOWAT = 0x1003,
SYS_NET_SO_RCVLOWAT = 0x1004,
SYS_NET_SO_SNDTIMEO = 0x1005,
SYS_NET_SO_RCVTIMEO = 0x1006,
SYS_NET_SO_ERROR = 0x1007,
SYS_NET_SO_TYPE = 0x1008,
SYS_NET_SO_NBIO = 0x1100, // Non-blocking IO
SYS_NET_SO_TPPOLICY = 0x1101,
SYS_NET_SO_REUSEADDR = 0x0004,
SYS_NET_SO_KEEPALIVE = 0x0008,
SYS_NET_SO_BROADCAST = 0x0020,
SYS_NET_SO_LINGER = 0x0080,
SYS_NET_SO_OOBINLINE = 0x0100,
SYS_NET_SO_REUSEPORT = 0x0200,
SYS_NET_SO_ONESBCAST = 0x0800,
SYS_NET_SO_USECRYPTO = 0x1000,
SYS_NET_SO_USESIGNATURE = 0x2000,
SYS_NET_SOL_SOCKET = 0xffff,
};
// Family (prefixed with SYS_NET_)
enum
{
SYS_NET_AF_UNSPEC = 0,
SYS_NET_AF_LOCAL = 1,
SYS_NET_AF_UNIX = SYS_NET_AF_LOCAL,
SYS_NET_AF_INET = 2,
SYS_NET_AF_INET6 = 24,
};
// Flags (prefixed with SYS_NET_)
enum
{
SYS_NET_MSG_OOB = 0x1,
SYS_NET_MSG_PEEK = 0x2,
SYS_NET_MSG_DONTROUTE = 0x4,
SYS_NET_MSG_EOR = 0x8,
SYS_NET_MSG_TRUNC = 0x10,
SYS_NET_MSG_CTRUNC = 0x20,
SYS_NET_MSG_WAITALL = 0x40,
SYS_NET_MSG_DONTWAIT = 0x80,
SYS_NET_MSG_BCAST = 0x100,
SYS_NET_MSG_MCAST = 0x200,
SYS_NET_MSG_USECRYPTO = 0x400,
SYS_NET_MSG_USESIGNATURE= 0x800,
};
// Shutdown types (prefixed with SYS_NET_)
enum
{
SYS_NET_SHUT_RD = 0,
SYS_NET_SHUT_WR = 1,
SYS_NET_SHUT_RDWR = 2,
};
// TCP options (prefixed with SYS_NET_)
enum
{
SYS_NET_TCP_NODELAY = 1,
SYS_NET_TCP_MAXSEG = 2,
SYS_NET_TCP_MSS_TO_ADVERTISE = 3,
};
// IP protocols (prefixed with SYS_NET_)
enum
{
SYS_NET_IPPROTO_IP = 0,
SYS_NET_IPPROTO_ICMP = 1,
SYS_NET_IPPROTO_IGMP = 2,
SYS_NET_IPPROTO_TCP = 6,
SYS_NET_IPPROTO_UDP = 17,
SYS_NET_IPPROTO_ICMPV6 = 58,
};
// Poll events (prefixed with SYS_NET_)
enum
{
SYS_NET_POLLIN = 0x0001,
SYS_NET_POLLPRI = 0x0002,
SYS_NET_POLLOUT = 0x0004,
SYS_NET_POLLERR = 0x0008, /* revent only */
SYS_NET_POLLHUP = 0x0010, /* revent only */
SYS_NET_POLLNVAL = 0x0020, /* revent only */
SYS_NET_POLLRDNORM = 0x0040,
SYS_NET_POLLWRNORM = SYS_NET_POLLOUT,
SYS_NET_POLLRDBAND = 0x0080,
SYS_NET_POLLWRBAND = 0x0100,
};
// in_addr_t type prefixed with sys_net_
using sys_net_in_addr_t = u32;
// in_port_t type prefixed with sys_net_
using sys_net_in_port_t = u16;
// sa_family_t type prefixed with sys_net_
using sys_net_sa_family_t = u8;
// socklen_t type prefixed with sys_net_
using sys_net_socklen_t = u32;
// fd_set prefixed with sys_net_
struct sys_net_fd_set
{
be_t<u32> fds_bits[32];
u32 bit(s32 s)
{
return (fds_bits[(s >> 5) & 31] >> (s & 31)) & 1u;
}
void set(s32 s)
{
fds_bits[(s >> 5) & 31] |= (1u << (s & 31));
}
};
// hostent prefixed with sys_net_
struct sys_net_hostent
{
vm::ps3::bptr<char> h_name;
vm::ps3::bpptr<char> h_aliases;
be_t<s32> h_addrtype;
be_t<s32> h_length;
vm::ps3::bpptr<char> h_addr_list;
};
// in_addr prefixed with sys_net_
struct sys_net_in_addr
{
be_t<u32> _s_addr;
};
// iovec prefixed with sys_net_
struct sys_net_iovec
{
be_t<s32> zero1;
vm::ps3::bptr<void> iov_base;
be_t<s32> zero2;
be_t<u32> iov_len;
};
// ip_mreq prefixed with sys_net_
struct sys_net_ip_mreq
{
be_t<u32> imr_multiaddr;
be_t<u32> imr_interface;
};
// msghdr prefixed with sys_net_
struct sys_net_msghdr
{
be_t<s32> zero1;
vm::ps3::bptr<void> msg_name;
be_t<u32> msg_namelen;
be_t<s32> pad1;
be_t<s32> zero2;
vm::ps3::bptr<sys_net_iovec> msg_iov;
be_t<s32> msg_iovlen;
be_t<s32> pad2;
be_t<s32> zero3;
vm::ps3::bptr<void> msg_control;
be_t<u32> msg_controllen;
be_t<s32> msg_flags;
};
// pollfd prefixed with sys_net_
struct sys_net_pollfd
{
be_t<s32> fd;
be_t<s16> events;
be_t<s16> revents;
};
// sockaddr prefixed with sys_net_
struct sys_net_sockaddr
{
u8 sa_len;
u8 sa_family;
char sa_data[14];
};
// sockaddr_dl prefixed with sys_net_
struct sys_net_sockaddr_dl
{
u8 sdl_len;
u8 sdl_family;
be_t<u16> sdl_index;
u8 sdl_type;
u8 sdl_nlen;
u8 sdl_alen;
u8 sdl_slen;
char sdl_data[12];
};
// sockaddr_in prefixed with sys_net_
struct sys_net_sockaddr_in
{
u8 sin_len;
u8 sin_family;
be_t<u16> sin_port;
be_t<u32> sin_addr;
be_t<u64> sin_zero;
};
// sockaddr_in_p2p prefixed with sys_net_
struct sys_net_sockaddr_in_p2p
{
u8 sin_len;
u8 sin_family;
be_t<u16> sin_port;
be_t<u32> sin_addr;
be_t<u16> sin_vport;
char sin_zero[6];
};
// timeval prefixed with sys_net_
struct sys_net_timeval
{
be_t<s64> tv_sec;
be_t<s64> tv_usec;
};
// linger prefixed with sys_net_
struct sys_net_linger
{
be_t<s32> l_onoff;
be_t<s32> l_linger;
};
// Custom structure for sockets
// We map host sockets to sequential IDs to return as descriptors because syscalls expect socket IDs to be under 1024.
struct lv2_socket final
{
#ifdef _WIN32
using socket_type = std::uintptr_t;
#else
using socket_type = int;
#endif
static const u32 id_base = 0;
static const u32 id_step = 1;
static const u32 id_count = 1024;
// Poll events
enum class poll
{
read,
write,
error,
__bitset_enum_max
};
lv2_socket(socket_type s);
~lv2_socket();
semaphore<> mutex;
#ifdef _WIN32
// Remember events (WSAEnumNetworkEvents)
u32 ev_set = 0;
#endif
// Native socket (must be non-blocking)
socket_type socket;
// Events selected for polling
atomic_t<bs_t<poll>> events{};
// Non-blocking IO option
s32 so_nbio = 0;
// Connection result
s32 so_error = 0;
// Unsupported option
s32 so_tcp_maxseg = 1500;
// Event processing workload (pair of thread id and the processing function)
std::vector<std::pair<u32, std::function<bool(bs_t<lv2_socket::poll>)>>> queue;
};
class ppu_thread;
// Syscalls
s32 sys_net_bnet_accept(ppu_thread&, s32 s, vm::ps3::ptr<sys_net_sockaddr> addr, vm::ps3::ptr<u32> paddrlen);
s32 sys_net_bnet_bind(ppu_thread&, s32 s, vm::ps3::cptr<sys_net_sockaddr> addr, u32 addrlen);
s32 sys_net_bnet_connect(ppu_thread&, s32 s, vm::ps3::ptr<sys_net_sockaddr> addr, u32 addrlen);
s32 sys_net_bnet_getpeername(ppu_thread&, s32 s, vm::ps3::ptr<sys_net_sockaddr> addr, vm::ps3::ptr<u32> paddrlen);
s32 sys_net_bnet_getsockname(ppu_thread&, s32 s, vm::ps3::ptr<sys_net_sockaddr> addr, vm::ps3::ptr<u32> paddrlen);
s32 sys_net_bnet_getsockopt(ppu_thread&, s32 s, s32 level, s32 optname, vm::ps3::ptr<void> optval, vm::ps3::ptr<u32> optlen);
s32 sys_net_bnet_listen(ppu_thread&, s32 s, s32 backlog);
s32 sys_net_bnet_recvfrom(ppu_thread&, s32 s, vm::ps3::ptr<void> buf, u32 len, s32 flags, vm::ps3::ptr<sys_net_sockaddr> addr, vm::ps3::ptr<u32> paddrlen);
s32 sys_net_bnet_recvmsg(ppu_thread&, s32 s, vm::ps3::ptr<sys_net_msghdr> msg, s32 flags);
s32 sys_net_bnet_sendmsg(ppu_thread&, s32 s, vm::ps3::cptr<sys_net_msghdr> msg, s32 flags);
s32 sys_net_bnet_sendto(ppu_thread&, s32 s, vm::ps3::cptr<void> buf, u32 len, s32 flags, vm::ps3::cptr<sys_net_sockaddr> addr, u32 addrlen);
s32 sys_net_bnet_setsockopt(ppu_thread&, s32 s, s32 level, s32 optname, vm::ps3::cptr<void> optval, u32 optlen);
s32 sys_net_bnet_shutdown(ppu_thread&, s32 s, s32 how);
s32 sys_net_bnet_socket(ppu_thread&, s32 family, s32 type, s32 protocol);
s32 sys_net_bnet_close(ppu_thread&, s32 s);
s32 sys_net_bnet_poll(ppu_thread&, vm::ps3::ptr<sys_net_pollfd> fds, s32 nfds, s32 ms);
s32 sys_net_bnet_select(ppu_thread&, s32 nfds, vm::ps3::ptr<sys_net_fd_set> readfds, vm::ps3::ptr<sys_net_fd_set> writefds, vm::ps3::ptr<sys_net_fd_set> exceptfds, vm::ps3::ptr<sys_net_timeval> timeout);
s32 _sys_net_open_dump(ppu_thread&, s32 len, s32 flags);
s32 _sys_net_read_dump(ppu_thread&, s32 id, vm::ps3::ptr<void> buf, s32 len, vm::ps3::ptr<s32> pflags);
s32 _sys_net_close_dump(ppu_thread&, s32 id, vm::ps3::ptr<s32> pflags);
s32 _sys_net_write_dump(ppu_thread&, s32 id, vm::ps3::cptr<void> buf, s32 len, u32 unknown);
s32 sys_net_abort(ppu_thread&, s32 type, u64 arg, s32 flags);
s32 sys_net_infoctl(ppu_thread&, s32 cmd, vm::ps3::ptr<void> arg);
s32 sys_net_control(ppu_thread&, u32 arg1, s32 arg2, vm::ps3::ptr<void> arg3, s32 arg4);
s32 sys_net_bnet_ioctl(ppu_thread&, s32 arg1, u32 arg2, u32 arg3);
s32 sys_net_bnet_sysctl(ppu_thread&, u32 arg1, u32 arg2, u32 arg3, vm::ps3::ptr<void> arg4, u32 arg5, u32 arg6);
s32 sys_net_eurus_post_command(ppu_thread&, s32 arg1, u32 arg2, u32 arg3);

View File

@ -23,14 +23,10 @@ static const std::unordered_map<std::string, int> s_prx_ignore
{ "/dev_flash/sys/external/libbeisobmf.sprx", 0 },
{ "/dev_flash/sys/external/libcamera.sprx", 0 },
{ "/dev_flash/sys/external/libgem.sprx", 0 },
{ "/dev_flash/sys/external/libhttp.sprx", 0 },
{ "/dev_flash/sys/external/libio.sprx", 0 },
{ "/dev_flash/sys/external/libmedi.sprx", 0 },
{ "/dev_flash/sys/external/libmic.sprx", 0 },
{ "/dev_flash/sys/external/libnet.sprx", 0 },
{ "/dev_flash/sys/external/libnetctl.sprx", 0 },
{ "/dev_flash/sys/external/librudp.sprx", 0 },
{ "/dev_flash/sys/external/libssl.sprx", 0 },
{ "/dev_flash/sys/external/libsysutil.sprx", 0 },
{ "/dev_flash/sys/external/libsysutil_ap.sprx", 0 },
{ "/dev_flash/sys/external/libsysutil_authdialog.sprx", 0 },

View File

@ -3,10 +3,66 @@
#include "sys_ss.h"
#ifdef _WIN32
#include <Windows.h>
#include <wincrypt.h>
const HCRYPTPROV s_crypto_provider = []() -> HCRYPTPROV
{
HCRYPTPROV result;
if (!CryptAcquireContextW(&result, nullptr, nullptr, PROV_RSA_FULL, 0))
{
return 0;
}
::atexit([]()
{
if (s_crypto_provider)
{
CryptReleaseContext(s_crypto_provider, 0);
}
});
return result;
}();
#endif
namespace vm { using namespace ps3; }
logs::channel sys_ss("sys_ss");
error_code sys_ss_random_number_generator(u32 arg1, vm::ptr<void> buf, u64 size)
{
sys_ss.warning("sys_ss_random_number_generator(arg1=%u, buf=*0x%x, size=0x%x)", arg1, buf, size);
if (arg1 != 2)
{
return 0x80010509;
}
if (size > 0x10000000)
{
return 0x80010501;
}
#ifdef _WIN32
if (!s_crypto_provider || !CryptGenRandom(s_crypto_provider, size, (BYTE*)buf.get_ptr()))
{
return CELL_EABORT;
}
#else
fs::file rnd{"/dev/random/"};
if (!rnd || rnd.read(buf.get_ptr(), size) != size)
{
return CELL_EABORT;
}
#endif
return CELL_OK;
}
s32 sys_ss_get_console_id(vm::ps3::ptr<u8> buf)
{
sys_ss.todo("sys_ss_get_console_id(buf=*0x%x)", buf);

View File

@ -9,5 +9,6 @@ struct CellSsOpenPSID
be_t<u64> low;
};
error_code sys_ss_random_number_generator(u32 arg1, vm::ps3::ptr<void> buf, u64 size);
s32 sys_ss_get_console_id(vm::ps3::ptr<u8> buf);
s32 sys_ss_get_open_psid(vm::ps3::ptr<CellSsOpenPSID> ptr);

View File

@ -43,6 +43,8 @@ extern void spu_load_exec(const spu_exec_object&);
extern void arm_load_exec(const arm_exec_object&);
extern std::shared_ptr<struct lv2_prx> ppu_load_prx(const ppu_prx_object&, const std::string&);
extern void network_thread_init();
fs::file g_tty;
template <>
@ -548,6 +550,7 @@ void Emulator::Load(bool add_only)
ppu_load_exec(ppu_exec);
fxm::import<GSRender>(Emu.GetCallbacks().get_gs_render); // TODO: must be created in appropriate sys_rsx syscall
network_thread_init();
}
else if (ppu_prx.open(elf_file) == elf_error::ok)
{

View File

@ -115,6 +115,7 @@
<ClCompile Include="..\Utilities\Thread.cpp" />
<ClCompile Include="..\Utilities\version.cpp" />
<ClCompile Include="..\Utilities\VirtualMemory.cpp" />
<ClCompile Include="Emu\Cell\lv2\sys_net.cpp" />
<ClCompile Include="Emu\Cell\PPUAnalyser.cpp" />
<ClCompile Include="Emu\Cell\PPUTranslator.cpp">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
@ -262,7 +263,7 @@
<ClCompile Include="Emu\Cell\Modules\sys_lwmutex_.cpp" />
<ClCompile Include="Emu\Cell\Modules\sys_mempool.cpp" />
<ClCompile Include="Emu\Cell\Modules\sys_mmapper_.cpp" />
<ClCompile Include="Emu\Cell\Modules\sys_net.cpp" />
<ClCompile Include="Emu\Cell\Modules\sys_net_.cpp" />
<ClCompile Include="Emu\Cell\Modules\sys_ppu_thread_.cpp" />
<ClCompile Include="Emu\Cell\Modules\sys_prx_.cpp" />
<ClCompile Include="Emu\Cell\Modules\sys_rsxaudio_.cpp" />
@ -454,6 +455,7 @@
<ClInclude Include="Crypto\unself.h" />
<ClInclude Include="Crypto\utils.h" />
<ClInclude Include="define_new_memleakdetect.h" />
<ClInclude Include="Emu\Cell\lv2\sys_net.h" />
<ClInclude Include="Emu\Cell\Modules\cellOskDialog.h" />
<ClInclude Include="Emu\Cell\PPUAnalyser.h" />
<ClInclude Include="Emu\Cell\PPUTranslator.h" />
@ -626,7 +628,7 @@
<ClInclude Include="Emu\Cell\Modules\sceNpUtil.h" />
<ClInclude Include="Emu\Cell\Modules\sysPrxForUser.h" />
<ClInclude Include="Emu\Cell\Modules\sys_lv2dbg.h" />
<ClInclude Include="Emu\Cell\Modules\sys_net.h" />
<ClInclude Include="Emu\Cell\Modules\sys_net_.h" />
<ClInclude Include="Emu\Cell\PPCDisAsm.h" />
<ClInclude Include="Emu\Cell\PPUCallback.h" />
<ClInclude Include="Emu\Cell\PPUDisAsm.h" />

View File

@ -626,9 +626,6 @@
<ClCompile Include="Emu\Cell\Modules\sys_mmapper_.cpp">
<Filter>Emu\Cell\Modules</Filter>
</ClCompile>
<ClCompile Include="Emu\Cell\Modules\sys_net.cpp">
<Filter>Emu\Cell\Modules</Filter>
</ClCompile>
<ClCompile Include="Emu\Cell\Modules\sys_ppu_thread_.cpp">
<Filter>Emu\Cell\Modules</Filter>
</ClCompile>
@ -932,6 +929,12 @@
<ClCompile Include="..\Utilities\LUrlParser.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Emu\Cell\Modules\sys_net_.cpp">
<Filter>Emu\Cell\Modules</Filter>
</ClCompile>
<ClCompile Include="Emu\Cell\lv2\sys_net.cpp">
<Filter>Emu\Cell\lv2</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Crypto\aes.h">
@ -1447,9 +1450,6 @@
<ClInclude Include="Emu\Cell\Modules\sys_lv2dbg.h">
<Filter>Emu\Cell\Modules</Filter>
</ClInclude>
<ClInclude Include="Emu\Cell\Modules\sys_net.h">
<Filter>Emu\Cell\Modules</Filter>
</ClInclude>
<ClInclude Include="Emu\Cell\Modules\sysPrxForUser.h">
<Filter>Emu\Cell\Modules</Filter>
</ClInclude>
@ -1801,5 +1801,11 @@
<ClInclude Include="Emu\RSX\Common\texture_cache.h">
<Filter>Emu\GPU\RSX\Common</Filter>
</ClInclude>
<ClInclude Include="Emu\Cell\Modules\sys_net_.h">
<Filter>Emu\Cell\Modules</Filter>
</ClInclude>
<ClInclude Include="Emu\Cell\lv2\sys_net.h">
<Filter>Emu\Cell\lv2</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -29,14 +29,11 @@ int main(int argc, char** argv)
//QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
SetProcessDPIAware();
WSADATA wsa_data;
WSAStartup(MAKEWORD(2, 2), &wsa_data);
timeBeginPeriod(1);
atexit([]
{
timeEndPeriod(1);
WSACleanup();
});
#else
qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "1");