This commit is contained in:
Zion Nimchuk 2017-06-22 12:08:17 -07:00 committed by Ivan
parent 173cc13d01
commit 54a38aa927
2 changed files with 36 additions and 10 deletions

View File

@ -16,7 +16,6 @@
#include <arpa/inet.h>
#include <unistd.h>
#endif
#include <fcntl.h>
logs::channel libnet("libnet");
@ -567,7 +566,7 @@ namespace sys_net
return -1;
}
if (level != SOL_SOCKET && level != IPPROTO_TCP)
if (level != PS3_SOL_SOCKET && level != IPPROTO_TCP)
{
fmt::throw_exception("Invalid socket option level!" HERE);
}
@ -575,7 +574,7 @@ namespace sys_net
s32 ret;
#ifdef _WIN32
if (level == SOL_SOCKET)
if (level == PS3_SOL_SOCKET)
{
switch (optname)
{
@ -623,12 +622,14 @@ namespace sys_net
}
case OP_SO_USECRYPTO:
{
libnet.warning("Socket option OP_SO_USECRYPTO is unimplemented");
libnet.todo("Socket option OP_SO_USECRYPTO is unimplemented");
ret = CELL_OK;
break;
}
case OP_SO_USESIGNATURE:
{
libnet.warning("Socket option OP_SO_USESIGNATURE is unimplemented");
libnet.todo("Socket option OP_SO_USESIGNATURE is unimplemented");
ret = CELL_OK;
break;
}
case OP_SO_BROADCAST:
@ -669,7 +670,7 @@ namespace sys_net
}
}
#else
if (level == SOL_SOCKET)
if (level == PS3_SOL_SOCKET)
{
switch (optname)
{
@ -690,6 +691,24 @@ namespace sys_net
ret = fcntl(sock->s, F_SETFL, flags);
break;
}
case OP_SO_RCVBUF:
{
u32 recvbuff = *(u32*)optval.get_ptr();
ret = ::setsockopt(sock->s, SOL_SOCKET, SO_RCVBUF, (const char*)&recvbuff, sizeof(recvbuff));
break;
}
case OP_SO_USECRYPTO:
{
libnet.warning("Socket option OP_SO_USECRYPTO is unimplemented");
ret = CELL_OK;
break;
}
case OP_SO_USESIGNATURE:
{
libnet.warning("Socket option OP_SO_USESIGNATURE is unimplemented");
ret = CELL_OK;
break;
}
default:
libnet.error("Unknown socket option for Unix: 0x%x", optname);
@ -821,8 +840,8 @@ namespace sys_net
s32 socketselect(s32 nfds, vm::ptr<fd_set> readfds, vm::ptr<fd_set> writefds, vm::ptr<fd_set> exceptfds, vm::ptr<timeval> timeout)
{
libnet.warning("socketselect(nfds=%d, readfds=*0x%x, writefds=*0x%x, exceptfds=*0x%x, timeout=*0x%x)", nfds, readfds, writefds, exceptfds, timeout);
libnet.warning("socketselect(nfds=%d, readfds=*0x%x, writefds=*0x%x, exceptfds=*0x%x, timeout.tv_sec=%d, timeout.tv_usec=%d)",
nfds, readfds, writefds, exceptfds, timeout->tv_sec, timeout->tv_usec);
::timeval _timeout;
if (timeout)
@ -830,8 +849,12 @@ namespace sys_net
_timeout.tv_sec = timeout->tv_sec;
_timeout.tv_usec = timeout->tv_usec;
}
//libnet.error("timeval: %d . %d", _timeout.tv_sec, _timeout.tv_usec);
if (_timeout.tv_usec >= 1000000)
{
_timeout.tv_sec = _timeout.tv_sec ? _timeout.tv_sec - 1 : _timeout.tv_sec + 1;
_timeout.tv_usec = 0;
}
::fd_set _readfds;
::fd_set _writefds;

View File

@ -9,6 +9,9 @@ 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
{