Skip to content

Commit

Permalink
Fixes accept.
Browse files Browse the repository at this point in the history
Tested with network demo from devKitPPC :)
  • Loading branch information
Parlane committed Aug 31, 2013
1 parent 11cffdd commit 676d78e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
6 changes: 3 additions & 3 deletions Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.cpp
Expand Up @@ -709,14 +709,14 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
}
case IOCTL_SO_LISTEN:
{
INFO_LOG(WII_IPC_NET, "IOCTL_SO_LISTEN "
"BufferIn: (%08x, %i), BufferOut: (%08x, %i)",
BufferIn, BufferInSize, BufferOut, BufferOutSize);

u32 fd = Memory::Read_U32(BufferIn);
u32 BACKLOG = Memory::Read_U32(BufferIn + 0x04);
u32 ret = listen(fd, BACKLOG);
ReturnValue = WiiSockMan::getNetErrorCode(ret, "SO_LISTEN", false);
INFO_LOG(WII_IPC_NET, "IOCTL_SO_LISTEN = %d "
"BufferIn: (%08x, %i), BufferOut: (%08x, %i)",
ReturnValue, BufferIn, BufferInSize, BufferOut, BufferOutSize);
break;
}
case IOCTL_SO_GETSOCKOPT:
Expand Down
23 changes: 15 additions & 8 deletions Source/Core/Core/Src/IPC_HLE/WII_Socket.cpp
Expand Up @@ -224,7 +224,7 @@ void WiiSocket::update(bool read, bool write, bool except)
WiiSockAddrIn* wii_name = (WiiSockAddrIn*)Memory::GetPointer(BufferOut);
WiiSockMan::Convert(*wii_name, local_name);

socklen_t addrlen = wii_name->len;
socklen_t addrlen = sizeof(sockaddr_in);
int ret = (s32)accept(fd, (sockaddr*)&local_name, &addrlen);
ReturnValue = WiiSockMan::getNetErrorCode(ret, "SO_ACCEPT", false);

Expand All @@ -235,7 +235,9 @@ void WiiSocket::update(bool read, bool write, bool except)
int ret = (s32)accept(fd, NULL, 0);
ReturnValue = WiiSockMan::getNetErrorCode(ret, "SO_ACCEPT", false);
}


WiiSockMan::getInstance().addSocket(ReturnValue);

INFO_LOG(WII_IPC_NET, "IOCTL_SO_ACCEPT "
"BufferIn: (%08x, %i), BufferOut: (%08x, %i)",
BufferIn, BufferInSize, BufferOut, BufferOutSize);
Expand Down Expand Up @@ -506,7 +508,7 @@ void WiiSocket::update(bool read, bool write, bool except)
|| (!it->is_ssl && ReturnValue != -SO_EAGAIN && ReturnValue != -SO_EINPROGRESS && ReturnValue != -SO_EALREADY)
|| (it->is_ssl && ReturnValue != SSL_ERR_WAGAIN && ReturnValue != SSL_ERR_RAGAIN))
{
DEBUG_LOG(WII_IPC_NET, "IOCTL(V) Sock: %d ioctl/v: %d returned: %d nonBlock: %d forceNonBlock: %d",
DEBUG_LOG(WII_IPC_NET, "IOCTL(V) Sock: %08x ioctl/v: %d returned: %d nonBlock: %d forceNonBlock: %d",
fd, it->is_ssl ? it->ssl_type : it->net_type, ReturnValue, nonBlock, forceNonBlock);
WiiSockMan::EnqueueReply(it->_CommandAddress, ReturnValue);
it = pending_sockops.erase(it);
Expand All @@ -532,6 +534,15 @@ void WiiSocket::doSock(u32 _CommandAddress, SSL_IOCTL type)
pending_sockops.push_back(so);
}

void WiiSockMan::addSocket(s32 fd)
{
if (fd >= 0)
{
WiiSocket& sock = WiiSockets[fd];
sock.setFd(fd);
}
}

s32 WiiSockMan::newSocket(s32 af, s32 type, s32 protocol)
{
if (NetPlay::IsNetPlayRunning()
Expand All @@ -543,11 +554,7 @@ s32 WiiSockMan::newSocket(s32 af, s32 type, s32 protocol)

s32 fd = (s32)socket(af, type, protocol);
s32 ret = getNetErrorCode(fd, "newSocket", false);
if (ret >= 0)
{
WiiSocket& sock = WiiSockets[ret];
sock.setFd(ret);
}
addSocket(ret);
return ret;
}

Expand Down
1 change: 1 addition & 0 deletions Source/Core/Core/Src/IPC_HLE/WII_Socket.h
Expand Up @@ -210,6 +210,7 @@ class WiiSockMan
static void Convert(sockaddr_in const & from, WiiSockAddrIn& to, s32 addrlen=-1);
// NON-BLOCKING FUNCTIONS
s32 newSocket(s32 af, s32 type, s32 protocol);
void addSocket(s32 fd);
s32 delSocket(s32 s);

void clean()
Expand Down

0 comments on commit 676d78e

Please sign in to comment.