Make WiiSocket function names conform to the coding style.

This commit is contained in:
Lioncash 2014-03-10 19:06:08 -04:00
parent 8d679e76d2
commit 3b27a2d22e
4 changed files with 80 additions and 80 deletions

View File

@ -61,7 +61,7 @@ CWII_IPC_HLE_Device_net_kd_request::CWII_IPC_HLE_Device_net_kd_request(u32 _Devi
CWII_IPC_HLE_Device_net_kd_request::~CWII_IPC_HLE_Device_net_kd_request() CWII_IPC_HLE_Device_net_kd_request::~CWII_IPC_HLE_Device_net_kd_request()
{ {
WiiSockMan::getInstance().clean(); WiiSockMan::GetInstance().Clean();
} }
bool CWII_IPC_HLE_Device_net_kd_request::Open(u32 _CommandAddress, u32 _Mode) bool CWII_IPC_HLE_Device_net_kd_request::Open(u32 _CommandAddress, u32 _Mode)
@ -660,8 +660,8 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
u32 type = Memory::Read_U32(BufferIn + 0x04); u32 type = Memory::Read_U32(BufferIn + 0x04);
u32 prot = Memory::Read_U32(BufferIn + 0x08); u32 prot = Memory::Read_U32(BufferIn + 0x08);
WiiSockMan &sm = WiiSockMan::getInstance(); WiiSockMan &sm = WiiSockMan::GetInstance();
ReturnValue = sm.newSocket(af, type, prot); ReturnValue = sm.NewSocket(af, type, prot);
INFO_LOG(WII_IPC_NET, "IOCTL_SO_SOCKET " INFO_LOG(WII_IPC_NET, "IOCTL_SO_SOCKET "
"Socket: %08x (%d,%d,%d), BufferIn: (%08x, %i), BufferOut: (%08x, %i)", "Socket: %08x (%d,%d,%d), BufferIn: (%08x, %i), BufferOut: (%08x, %i)",
ReturnValue, af, type, prot, BufferIn, BufferInSize, BufferOut, BufferOutSize); ReturnValue, af, type, prot, BufferIn, BufferInSize, BufferOut, BufferOutSize);
@ -671,8 +671,8 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
{ {
u32 pf = Memory::Read_U32(BufferIn); u32 pf = Memory::Read_U32(BufferIn);
WiiSockMan &sm = WiiSockMan::getInstance(); WiiSockMan &sm = WiiSockMan::GetInstance();
ReturnValue = sm.newSocket(pf, SOCK_RAW, IPPROTO_ICMP); ReturnValue = sm.NewSocket(pf, SOCK_RAW, IPPROTO_ICMP);
INFO_LOG(WII_IPC_NET, "IOCTL_SO_ICMPSOCKET(%x) %d", pf, ReturnValue); INFO_LOG(WII_IPC_NET, "IOCTL_SO_ICMPSOCKET(%x) %d", pf, ReturnValue);
break; break;
} }
@ -680,8 +680,8 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
case IOCTL_SO_ICMPCLOSE: case IOCTL_SO_ICMPCLOSE:
{ {
u32 fd = Memory::Read_U32(BufferIn); u32 fd = Memory::Read_U32(BufferIn);
WiiSockMan &sm = WiiSockMan::getInstance(); WiiSockMan &sm = WiiSockMan::GetInstance();
ReturnValue = sm.delSocket(fd); ReturnValue = sm.DeleteSocket(fd);
DEBUG_LOG(WII_IPC_NET, "%s(%x) %x", DEBUG_LOG(WII_IPC_NET, "%s(%x) %x",
Command == IOCTL_SO_ICMPCLOSE ? "IOCTL_SO_ICMPCLOSE" : "IOCTL_SO_CLOSE", Command == IOCTL_SO_ICMPCLOSE ? "IOCTL_SO_ICMPCLOSE" : "IOCTL_SO_CLOSE",
fd, ReturnValue); fd, ReturnValue);
@ -693,8 +693,8 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
case IOCTL_SO_FCNTL: case IOCTL_SO_FCNTL:
{ {
u32 fd = Memory::Read_U32(BufferIn); u32 fd = Memory::Read_U32(BufferIn);
WiiSockMan &sm = WiiSockMan::getInstance(); WiiSockMan &sm = WiiSockMan::GetInstance();
sm.doSock(fd, _CommandAddress, (NET_IOCTL)Command); sm.DoSock(fd, _CommandAddress, (NET_IOCTL)Command);
return false; return false;
} }
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
@ -709,7 +709,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
u32 fd = Memory::Read_U32(BufferIn); u32 fd = Memory::Read_U32(BufferIn);
u32 how = Memory::Read_U32(BufferIn+4); u32 how = Memory::Read_U32(BufferIn+4);
int ret = shutdown(fd, how); int ret = shutdown(fd, how);
ReturnValue = WiiSockMan::getNetErrorCode(ret, "SO_SHUTDOWN", false); ReturnValue = WiiSockMan::GetNetErrorCode(ret, "SO_SHUTDOWN", false);
break; break;
} }
case IOCTL_SO_LISTEN: case IOCTL_SO_LISTEN:
@ -718,7 +718,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
u32 fd = Memory::Read_U32(BufferIn); u32 fd = Memory::Read_U32(BufferIn);
u32 BACKLOG = Memory::Read_U32(BufferIn + 0x04); u32 BACKLOG = Memory::Read_U32(BufferIn + 0x04);
u32 ret = listen(fd, BACKLOG); u32 ret = listen(fd, BACKLOG);
ReturnValue = WiiSockMan::getNetErrorCode(ret, "SO_LISTEN", false); ReturnValue = WiiSockMan::GetNetErrorCode(ret, "SO_LISTEN", false);
INFO_LOG(WII_IPC_NET, "IOCTL_SO_LISTEN = %d " INFO_LOG(WII_IPC_NET, "IOCTL_SO_LISTEN = %d "
"BufferIn: (%08x, %i), BufferOut: (%08x, %i)", "BufferIn: (%08x, %i), BufferOut: (%08x, %i)",
ReturnValue, BufferIn, BufferInSize, BufferOut, BufferOutSize); ReturnValue, BufferIn, BufferInSize, BufferOut, BufferOutSize);
@ -750,7 +750,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
u32 optlen = 4; u32 optlen = 4;
int ret = getsockopt (fd, nat_level, nat_optname, (char *) &optval, (socklen_t*)&optlen); int ret = getsockopt (fd, nat_level, nat_optname, (char *) &optval, (socklen_t*)&optlen);
ReturnValue = WiiSockMan::getNetErrorCode(ret, "SO_GETSOCKOPT", false); ReturnValue = WiiSockMan::GetNetErrorCode(ret, "SO_GETSOCKOPT", false);
Memory::Write_U32(optlen, BufferOut + 0xC); Memory::Write_U32(optlen, BufferOut + 0xC);
@ -758,7 +758,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
if (optname == SO_ERROR) if (optname == SO_ERROR)
{ {
s32 last_error = WiiSockMan::getInstance().getLastNetError(); s32 last_error = WiiSockMan::GetInstance().GetLastNetError();
Memory::Write_U32(sizeof(s32), BufferOut + 0xC); Memory::Write_U32(sizeof(s32), BufferOut + 0xC);
Memory::Write_U32(last_error, BufferOut + 0x10); Memory::Write_U32(last_error, BufferOut + 0x10);
@ -807,7 +807,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
} }
int ret = setsockopt(fd, nat_level, nat_optname, (char*)optval, optlen); int ret = setsockopt(fd, nat_level, nat_optname, (char*)optval, optlen);
ReturnValue = WiiSockMan::getNetErrorCode(ret, "SO_SETSOCKOPT", false); ReturnValue = WiiSockMan::GetNetErrorCode(ret, "SO_SETSOCKOPT", false);
break; break;
} }
case IOCTL_SO_GETSOCKNAME: case IOCTL_SO_GETSOCKNAME:
@ -946,7 +946,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
} }
int ret = poll(ufds, nfds, timeout); int ret = poll(ufds, nfds, timeout);
ret = WiiSockMan::getNetErrorCode(ret, "SO_POLL", false); ret = WiiSockMan::GetNetErrorCode(ret, "SO_POLL", false);
for (int i = 0; i<nfds; i++) for (int i = 0; i<nfds; i++)
{ {
@ -1237,16 +1237,16 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtlV(u32 CommandAddress)
case IOCTLV_SO_SENDTO: case IOCTLV_SO_SENDTO:
{ {
u32 fd = Memory::Read_U32(_BufferIn2); u32 fd = Memory::Read_U32(_BufferIn2);
WiiSockMan &sm = WiiSockMan::getInstance(); WiiSockMan &sm = WiiSockMan::GetInstance();
sm.doSock(fd, CommandAddress, IOCTLV_SO_SENDTO); sm.DoSock(fd, CommandAddress, IOCTLV_SO_SENDTO);
return false; return false;
break; break;
} }
case IOCTLV_SO_RECVFROM: case IOCTLV_SO_RECVFROM:
{ {
u32 fd = Memory::Read_U32(_BufferIn); u32 fd = Memory::Read_U32(_BufferIn);
WiiSockMan &sm = WiiSockMan::getInstance(); WiiSockMan &sm = WiiSockMan::GetInstance();
sm.doSock(fd, CommandAddress, IOCTLV_SO_RECVFROM); sm.DoSock(fd, CommandAddress, IOCTLV_SO_RECVFROM);
return false; return false;
break; break;
} }
@ -1417,6 +1417,6 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtlV(u32 CommandAddress)
} }
u32 CWII_IPC_HLE_Device_net_ip_top::Update() u32 CWII_IPC_HLE_Device_net_ip_top::Update()
{ {
WiiSockMan::getInstance().Update(); WiiSockMan::GetInstance().Update();
return 0; return 0;
} }

View File

@ -404,8 +404,8 @@ _SSL_NEW_ERROR:
int sslID = Memory::Read_U32(BufferOut) - 1; int sslID = Memory::Read_U32(BufferOut) - 1;
if (SSLID_VALID(sslID)) if (SSLID_VALID(sslID))
{ {
WiiSockMan &sm = WiiSockMan::getInstance(); WiiSockMan &sm = WiiSockMan::GetInstance();
sm.doSock(_SSL[sslID].sockfd, _CommandAddress, IOCTLV_NET_SSL_DOHANDSHAKE); sm.DoSock(_SSL[sslID].sockfd, _CommandAddress, IOCTLV_NET_SSL_DOHANDSHAKE);
return false; return false;
} }
else else
@ -419,8 +419,8 @@ _SSL_NEW_ERROR:
int sslID = Memory::Read_U32(BufferOut) - 1; int sslID = Memory::Read_U32(BufferOut) - 1;
if (SSLID_VALID(sslID)) if (SSLID_VALID(sslID))
{ {
WiiSockMan &sm = WiiSockMan::getInstance(); WiiSockMan &sm = WiiSockMan::GetInstance();
sm.doSock(_SSL[sslID].sockfd, _CommandAddress, IOCTLV_NET_SSL_WRITE); sm.DoSock(_SSL[sslID].sockfd, _CommandAddress, IOCTLV_NET_SSL_WRITE);
return false; return false;
} }
else else
@ -444,8 +444,8 @@ _SSL_NEW_ERROR:
int sslID = Memory::Read_U32(BufferOut) - 1; int sslID = Memory::Read_U32(BufferOut) - 1;
if (SSLID_VALID(sslID)) if (SSLID_VALID(sslID))
{ {
WiiSockMan &sm = WiiSockMan::getInstance(); WiiSockMan &sm = WiiSockMan::GetInstance();
sm.doSock(_SSL[sslID].sockfd, _CommandAddress, IOCTLV_NET_SSL_READ); sm.DoSock(_SSL[sslID].sockfd, _CommandAddress, IOCTLV_NET_SSL_READ);
return false; return false;
} }
else else

View File

@ -37,7 +37,7 @@ char* WiiSockMan::DecodeError(s32 ErrorCode)
#endif #endif
} }
s32 translateErrorCode(s32 native_error, bool isRW) s32 TranslateErrorCode(s32 native_error, bool isRW)
{ {
switch (native_error) switch (native_error)
{ {
@ -77,7 +77,7 @@ s32 translateErrorCode(s32 native_error, bool isRW)
} }
} }
s32 WiiSockMan::getNetErrorCode(s32 ret, std::string caller, bool isRW) s32 WiiSockMan::GetNetErrorCode(s32 ret, std::string caller, bool isRW)
{ {
#ifdef _WIN32 #ifdef _WIN32
s32 errorCode = WSAGetLastError(); s32 errorCode = WSAGetLastError();
@ -87,15 +87,15 @@ s32 WiiSockMan::getNetErrorCode(s32 ret, std::string caller, bool isRW)
if (ret >= 0) if (ret >= 0)
{ {
WiiSockMan::getInstance().setLastNetError(ret); WiiSockMan::GetInstance().SetLastNetError(ret);
return ret; return ret;
} }
INFO_LOG(WII_IPC_NET, "%s failed with error %d: %s, ret= %d", INFO_LOG(WII_IPC_NET, "%s failed with error %d: %s, ret= %d",
caller.c_str(), errorCode, DecodeError(errorCode), ret); caller.c_str(), errorCode, DecodeError(errorCode), ret);
s32 ReturnValue = translateErrorCode(errorCode, isRW); s32 ReturnValue = TranslateErrorCode(errorCode, isRW);
WiiSockMan::getInstance().setLastNetError(ReturnValue); WiiSockMan::GetInstance().SetLastNetError(ReturnValue);
return ReturnValue; return ReturnValue;
} }
@ -104,14 +104,14 @@ WiiSocket::~WiiSocket()
{ {
if (fd >= 0) if (fd >= 0)
{ {
(void)closeFd(); (void)CloseFd();
} }
} }
void WiiSocket::setFd(s32 s) void WiiSocket::SetFd(s32 s)
{ {
if (fd >= 0) if (fd >= 0)
(void)closeFd(); (void)CloseFd();
nonBlock = false; nonBlock = false;
fd = s; fd = s;
@ -128,7 +128,7 @@ void WiiSocket::setFd(s32 s)
#endif #endif
} }
s32 WiiSocket::closeFd() s32 WiiSocket::CloseFd()
{ {
s32 ReturnValue = 0; s32 ReturnValue = 0;
if (fd >= 0) if (fd >= 0)
@ -138,17 +138,17 @@ s32 WiiSocket::closeFd()
#else #else
s32 ret = close(fd); s32 ret = close(fd);
#endif #endif
ReturnValue = WiiSockMan::getNetErrorCode(ret, "delSocket", false); ReturnValue = WiiSockMan::GetNetErrorCode(ret, "CloseFd", false);
} }
else else
{ {
ReturnValue = WiiSockMan::getNetErrorCode(EITHER(WSAENOTSOCK, EBADF), "delSocket", false); ReturnValue = WiiSockMan::GetNetErrorCode(EITHER(WSAENOTSOCK, EBADF), "CloseFd", false);
} }
fd = -1; fd = -1;
return ReturnValue; return ReturnValue;
} }
s32 WiiSocket::_fcntl(u32 cmd, u32 arg) s32 WiiSocket::FCntl(u32 cmd, u32 arg)
{ {
#define F_GETFL 3 #define F_GETFL 3
#define F_SETFL 4 #define F_SETFL 4
@ -173,7 +173,7 @@ s32 WiiSocket::_fcntl(u32 cmd, u32 arg)
return ret; return ret;
} }
void WiiSocket::update(bool read, bool write, bool except) void WiiSocket::Update(bool read, bool write, bool except)
{ {
auto it = pending_sockops.begin(); auto it = pending_sockops.begin();
while (it != pending_sockops.end()) while (it != pending_sockops.end())
@ -194,7 +194,7 @@ void WiiSocket::update(bool read, bool write, bool except)
{ {
u32 cmd = Memory::Read_U32(BufferIn + 4); u32 cmd = Memory::Read_U32(BufferIn + 4);
u32 arg = Memory::Read_U32(BufferIn + 8); u32 arg = Memory::Read_U32(BufferIn + 8);
ReturnValue = _fcntl(cmd, arg); ReturnValue = FCntl(cmd, arg);
break; break;
} }
case IOCTL_SO_BIND: case IOCTL_SO_BIND:
@ -205,7 +205,7 @@ void WiiSocket::update(bool read, bool write, bool except)
WiiSockMan::Convert(*wii_name, local_name); WiiSockMan::Convert(*wii_name, local_name);
int ret = bind(fd, (sockaddr*)&local_name, sizeof(local_name)); int ret = bind(fd, (sockaddr*)&local_name, sizeof(local_name));
ReturnValue = WiiSockMan::getNetErrorCode(ret, "SO_BIND", false); ReturnValue = WiiSockMan::GetNetErrorCode(ret, "SO_BIND", false);
INFO_LOG(WII_IPC_NET, "IOCTL_SO_BIND (%08X %s:%d) = %d ", fd, INFO_LOG(WII_IPC_NET, "IOCTL_SO_BIND (%08X %s:%d) = %d ", fd,
inet_ntoa(local_name.sin_addr), Common::swap16(local_name.sin_port), ret); inet_ntoa(local_name.sin_addr), Common::swap16(local_name.sin_port), ret);
@ -219,7 +219,7 @@ void WiiSocket::update(bool read, bool write, bool except)
WiiSockMan::Convert(*wii_name, local_name); WiiSockMan::Convert(*wii_name, local_name);
int ret = connect(fd, (sockaddr*)&local_name, sizeof(local_name)); int ret = connect(fd, (sockaddr*)&local_name, sizeof(local_name));
ReturnValue = WiiSockMan::getNetErrorCode(ret, "SO_CONNECT", false); ReturnValue = WiiSockMan::GetNetErrorCode(ret, "SO_CONNECT", false);
INFO_LOG(WII_IPC_NET,"IOCTL_SO_CONNECT (%08x, %s:%d)", INFO_LOG(WII_IPC_NET,"IOCTL_SO_CONNECT (%08x, %s:%d)",
fd, inet_ntoa(local_name.sin_addr), Common::swap16(local_name.sin_port)); fd, inet_ntoa(local_name.sin_addr), Common::swap16(local_name.sin_port));
@ -227,7 +227,6 @@ void WiiSocket::update(bool read, bool write, bool except)
} }
case IOCTL_SO_ACCEPT: case IOCTL_SO_ACCEPT:
{ {
if (BufferOutSize > 0) if (BufferOutSize > 0)
{ {
sockaddr_in local_name; sockaddr_in local_name;
@ -236,17 +235,17 @@ void WiiSocket::update(bool read, bool write, bool except)
socklen_t addrlen = sizeof(sockaddr_in); socklen_t addrlen = sizeof(sockaddr_in);
int ret = (s32)accept(fd, (sockaddr*)&local_name, &addrlen); int ret = (s32)accept(fd, (sockaddr*)&local_name, &addrlen);
ReturnValue = WiiSockMan::getNetErrorCode(ret, "SO_ACCEPT", true); ReturnValue = WiiSockMan::GetNetErrorCode(ret, "SO_ACCEPT", true);
WiiSockMan::Convert(local_name, *wii_name, addrlen); WiiSockMan::Convert(local_name, *wii_name, addrlen);
} }
else else
{ {
int ret = (s32)accept(fd, nullptr, 0); int ret = (s32)accept(fd, nullptr, 0);
ReturnValue = WiiSockMan::getNetErrorCode(ret, "SO_ACCEPT", true); ReturnValue = WiiSockMan::GetNetErrorCode(ret, "SO_ACCEPT", true);
} }
WiiSockMan::getInstance().addSocket(ReturnValue); WiiSockMan::GetInstance().AddSocket(ReturnValue);
INFO_LOG(WII_IPC_NET, "IOCTL_SO_ACCEPT " INFO_LOG(WII_IPC_NET, "IOCTL_SO_ACCEPT "
"BufferIn: (%08x, %i), BufferOut: (%08x, %i)", "BufferIn: (%08x, %i), BufferOut: (%08x, %i)",
@ -442,7 +441,7 @@ void WiiSocket::update(bool read, bool write, bool except)
int ret = sendto(fd, data, BufferInSize, flags, int ret = sendto(fd, data, BufferInSize, flags,
has_destaddr ? (struct sockaddr*)&local_name : nullptr, has_destaddr ? (struct sockaddr*)&local_name : nullptr,
has_destaddr ? sizeof(sockaddr) : 0); has_destaddr ? sizeof(sockaddr) : 0);
ReturnValue = WiiSockMan::getNetErrorCode(ret, "SO_SENDTO", true); ReturnValue = WiiSockMan::GetNetErrorCode(ret, "SO_SENDTO", true);
INFO_LOG(WII_IPC_NET, INFO_LOG(WII_IPC_NET,
"%s = %d Socket: %08x, BufferIn: (%08x, %i), BufferIn2: (%08x, %i), %u.%u.%u.%u", "%s = %d Socket: %08x, BufferIn: (%08x, %i), BufferIn2: (%08x, %i), %u.%u.%u.%u",
@ -488,7 +487,7 @@ void WiiSocket::update(bool read, bool write, bool except)
int ret = recvfrom(fd, data, data_len, flags, int ret = recvfrom(fd, data, data_len, flags,
BufferOutSize2 ? (struct sockaddr*) &local_name : nullptr, BufferOutSize2 ? (struct sockaddr*) &local_name : nullptr,
BufferOutSize2 ? &addrlen : nullptr); BufferOutSize2 ? &addrlen : nullptr);
ReturnValue = WiiSockMan::getNetErrorCode(ret, BufferOutSize2 ? "SO_RECVFROM" : "SO_RECV", true); ReturnValue = WiiSockMan::GetNetErrorCode(ret, BufferOutSize2 ? "SO_RECVFROM" : "SO_RECV", true);
INFO_LOG(WII_IPC_NET, "%s(%d, %p) Socket: %08X, Flags: %08X, " INFO_LOG(WII_IPC_NET, "%s(%d, %p) Socket: %08X, Flags: %08X, "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), " "BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
@ -534,30 +533,30 @@ void WiiSocket::update(bool read, bool write, bool except)
} }
} }
void WiiSocket::doSock(u32 _CommandAddress, NET_IOCTL type) void WiiSocket::DoSock(u32 _CommandAddress, NET_IOCTL type)
{ {
sockop so = {_CommandAddress, false}; sockop so = {_CommandAddress, false};
so.net_type = type; so.net_type = type;
pending_sockops.push_back(so); pending_sockops.push_back(so);
} }
void WiiSocket::doSock(u32 _CommandAddress, SSL_IOCTL type) void WiiSocket::DoSock(u32 _CommandAddress, SSL_IOCTL type)
{ {
sockop so = {_CommandAddress, true}; sockop so = {_CommandAddress, true};
so.ssl_type = type; so.ssl_type = type;
pending_sockops.push_back(so); pending_sockops.push_back(so);
} }
void WiiSockMan::addSocket(s32 fd) void WiiSockMan::AddSocket(s32 fd)
{ {
if (fd >= 0) if (fd >= 0)
{ {
WiiSocket& sock = WiiSockets[fd]; WiiSocket& sock = WiiSockets[fd];
sock.setFd(fd); sock.SetFd(fd);
} }
} }
s32 WiiSockMan::newSocket(s32 af, s32 type, s32 protocol) s32 WiiSockMan::NewSocket(s32 af, s32 type, s32 protocol)
{ {
if (NetPlay::IsNetPlayRunning() || if (NetPlay::IsNetPlayRunning() ||
Movie::IsRecordingInput() || Movie::IsRecordingInput() ||
@ -567,14 +566,14 @@ s32 WiiSockMan::newSocket(s32 af, s32 type, s32 protocol)
} }
s32 fd = (s32)socket(af, type, protocol); s32 fd = (s32)socket(af, type, protocol);
s32 ret = getNetErrorCode(fd, "newSocket", false); s32 ret = GetNetErrorCode(fd, "NewSocket", false);
addSocket(ret); AddSocket(ret);
return ret; return ret;
} }
s32 WiiSockMan::delSocket(s32 s) s32 WiiSockMan::DeleteSocket(s32 s)
{ {
s32 ReturnValue = WiiSockets[s].closeFd(); s32 ReturnValue = WiiSockets[s].CloseFd();
WiiSockets.erase(s); WiiSockets.erase(s);
return ReturnValue; return ReturnValue;
} }
@ -590,7 +589,7 @@ void WiiSockMan::Update()
for (auto& entry : WiiSockets) for (auto& entry : WiiSockets)
{ {
WiiSocket& sock = entry.second; WiiSocket& sock = entry.second;
if (sock.valid()) if (sock.IsValid())
{ {
FD_SET(sock.fd, &read_fds); FD_SET(sock.fd, &read_fds);
FD_SET(sock.fd, &write_fds); FD_SET(sock.fd, &write_fds);
@ -610,7 +609,7 @@ void WiiSockMan::Update()
for (auto& pair : WiiSockets) for (auto& pair : WiiSockets)
{ {
WiiSocket& sock = pair.second; WiiSocket& sock = pair.second;
sock.update( sock.Update(
FD_ISSET(sock.fd, &read_fds) != 0, FD_ISSET(sock.fd, &read_fds) != 0,
FD_ISSET(sock.fd, &write_fds) != 0, FD_ISSET(sock.fd, &write_fds) != 0,
FD_ISSET(sock.fd, &except_fds) != 0 FD_ISSET(sock.fd, &except_fds) != 0
@ -621,7 +620,7 @@ void WiiSockMan::Update()
{ {
for (auto& elem : WiiSockets) for (auto& elem : WiiSockets)
{ {
elem.second.update(false, false, false); elem.second.Update(false, false, false);
} }
} }
} }

View File

@ -161,7 +161,8 @@ struct WiiSockAddrIn
class WiiSocket class WiiSocket
{ {
struct sockop{ struct sockop
{
u32 _CommandAddress; u32 _CommandAddress;
bool is_ssl; bool is_ssl;
union union
@ -176,14 +177,14 @@ private:
std::list<sockop> pending_sockops; std::list<sockop> pending_sockops;
friend class WiiSockMan; friend class WiiSockMan;
void setFd(s32 s); void SetFd(s32 s);
s32 closeFd(); s32 CloseFd();
s32 _fcntl(u32 cmd, u32 arg); s32 FCntl(u32 cmd, u32 arg);
void doSock(u32 _CommandAddress, NET_IOCTL type); void DoSock(u32 _CommandAddress, NET_IOCTL type);
void doSock(u32 _CommandAddress, SSL_IOCTL type); void DoSock(u32 _CommandAddress, SSL_IOCTL type);
void update(bool read, bool write, bool except); void Update(bool read, bool write, bool except);
bool valid() {return fd >= 0;} bool IsValid() {return fd >= 0;}
public: public:
WiiSocket() : fd(-1), nonBlock(false) {} WiiSocket() : fd(-1), nonBlock(false) {}
~WiiSocket(); ~WiiSocket();
@ -194,10 +195,10 @@ public:
class WiiSockMan class WiiSockMan
{ {
public: public:
static s32 getNetErrorCode(s32 ret, std::string caller, bool isRW); static s32 GetNetErrorCode(s32 ret, std::string caller, bool isRW);
static char* DecodeError(s32 ErrorCode); static char* DecodeError(s32 ErrorCode);
static WiiSockMan& getInstance() static WiiSockMan& GetInstance()
{ {
static WiiSockMan instance; // Guaranteed to be destroyed. static WiiSockMan instance; // Guaranteed to be destroyed.
return instance; // Instantiated on first use. return instance; // Instantiated on first use.
@ -207,30 +208,30 @@ public:
static void Convert(WiiSockAddrIn const & from, sockaddr_in& to); static void Convert(WiiSockAddrIn const & from, sockaddr_in& to);
static void Convert(sockaddr_in const & from, WiiSockAddrIn& to, s32 addrlen=-1); static void Convert(sockaddr_in const & from, WiiSockAddrIn& to, s32 addrlen=-1);
// NON-BLOCKING FUNCTIONS // NON-BLOCKING FUNCTIONS
s32 newSocket(s32 af, s32 type, s32 protocol); s32 NewSocket(s32 af, s32 type, s32 protocol);
void addSocket(s32 fd); void AddSocket(s32 fd);
s32 delSocket(s32 s); s32 DeleteSocket(s32 s);
s32 getLastNetError() {return errono_last;} s32 GetLastNetError() { return errno_last; }
void setLastNetError(s32 error) {errono_last = error;} void SetLastNetError(s32 error) { errno_last = error; }
void clean() void Clean()
{ {
WiiSockets.clear(); WiiSockets.clear();
} }
template <typename T> template <typename T>
void doSock(s32 sock, u32 CommandAddress, T type) void DoSock(s32 sock, u32 CommandAddress, T type)
{ {
if (WiiSockets.find(sock) == WiiSockets.end()) if (WiiSockets.find(sock) == WiiSockets.end())
{ {
ERROR_LOG(WII_IPC_NET, ERROR_LOG(WII_IPC_NET,
"doSock: Error, fd not found (%08x, %08X, %08X)", "DoSock: Error, fd not found (%08x, %08X, %08X)",
sock, CommandAddress, type); sock, CommandAddress, type);
EnqueueReply(CommandAddress, -SO_EBADF); EnqueueReply(CommandAddress, -SO_EBADF);
} }
else else
{ {
WiiSockets[sock].doSock(CommandAddress, type); WiiSockets[sock].DoSock(CommandAddress, type);
} }
} }
@ -240,5 +241,5 @@ private:
void operator=(WiiSockMan const&); // Don't implement void operator=(WiiSockMan const&); // Don't implement
std::unordered_map<s32, WiiSocket> WiiSockets; std::unordered_map<s32, WiiSocket> WiiSockets;
s32 errono_last; s32 errno_last;
}; };