From 676d78ec41455457dae0f0d45344f7b946352d63 Mon Sep 17 00:00:00 2001 From: Matthew Parlane Date: Sat, 31 Aug 2013 18:46:46 +1200 Subject: [PATCH] Fixes accept. Tested with network demo from devKitPPC :) --- .../Src/IPC_HLE/WII_IPC_HLE_Device_net.cpp | 6 ++--- Source/Core/Core/Src/IPC_HLE/WII_Socket.cpp | 23 ++++++++++++------- Source/Core/Core/Src/IPC_HLE/WII_Socket.h | 1 + 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.cpp index be0e1a1358..cbb5b63d83 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.cpp @@ -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: diff --git a/Source/Core/Core/Src/IPC_HLE/WII_Socket.cpp b/Source/Core/Core/Src/IPC_HLE/WII_Socket.cpp index 4939499b1e..e8c7a5a1bd 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_Socket.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_Socket.cpp @@ -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); @@ -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); @@ -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); @@ -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() @@ -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; } diff --git a/Source/Core/Core/Src/IPC_HLE/WII_Socket.h b/Source/Core/Core/Src/IPC_HLE/WII_Socket.h index 3c2ce3bb30..717724f313 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_Socket.h +++ b/Source/Core/Core/Src/IPC_HLE/WII_Socket.h @@ -210,6 +210,7 @@ public: 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()