Opera v1024 uses connect() error code to work out if a socket connected successfully. Added correct return code for windows equivalent error code.

This commit is contained in:
Matthew Parlane 2012-01-19 19:31:35 +13:00
parent 1df04e11a4
commit 1cafa52c32
1 changed files with 28 additions and 32 deletions

View File

@ -195,7 +195,7 @@ CWII_IPC_HLE_Device_net_ncd_manage::CWII_IPC_HLE_Device_net_ncd_manage(u32 _Devi
{ {
// store network configuration // store network configuration
const std::string filename(File::GetUserPath(D_WIIUSER_IDX) + "shared2/sys/net/02/config.dat"); const std::string filename(File::GetUserPath(D_WIIUSER_IDX) + "shared2/sys/net/02/config.dat");
File::IOFile file(filename, "rb"); File::IOFile file(filename, "rb");
if (!file.ReadBytes(&m_Ifconfig, 1)) if (!file.ReadBytes(&m_Ifconfig, 1))
{ {
@ -481,6 +481,8 @@ static int getNetErrorCode(int ret, std::string caller)
return -1; return -1;
case 10054: case 10054:
return -15; return -15;
case 10056:
return -30;
case 10035: case 10035:
return -26; return -26;
case 6: case 6:
@ -545,8 +547,8 @@ static int inet_pton(const char *src, unsigned char *dst)
u32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommand(u32 _Command, u32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommand(u32 _Command,
u32 _BufferIn, u32 BufferInSize, u32 _BufferIn, u32 BufferInSize,
u32 _BufferOut, u32 BufferOutSize) u32 _BufferOut, u32 BufferOutSize)
{ {
switch (_Command) switch (_Command)
{ {
@ -605,13 +607,13 @@ u32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommand(u32 _Command,
u32 sock = Memory::Read_U32(_BufferIn); u32 sock = Memory::Read_U32(_BufferIn);
INFO_LOG(WII_IPC_NET, "/dev/net/ip/top::IOCtl request IOCTL_SO_CLOSE (%08x)", sock); INFO_LOG(WII_IPC_NET, "/dev/net/ip/top::IOCtl request IOCTL_SO_CLOSE (%08x)", sock);
#ifdef _WIN32 #ifdef _WIN32
u32 ret = closesocket(sock); u32 ret = closesocket(sock);
return getNetErrorCode(ret, "IOCTL_SO_CLOSE"); return getNetErrorCode(ret, "IOCTL_SO_CLOSE");
#else #else
return close(sock); return close(sock);
#endif #endif
break; break;
} }
@ -682,7 +684,7 @@ u32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommand(u32 _Command,
u32 optname = Memory::Read_U32(_BufferOut + 8); u32 optname = Memory::Read_U32(_BufferOut + 8);
INFO_LOG(WII_IPC_NET,"/dev/net/ip/top::IOCtl request IOCTL_SO_GETSOCKOPT(%08x, %08x, %08x)" INFO_LOG(WII_IPC_NET,"/dev/net/ip/top::IOCtl request IOCTL_SO_GETSOCKOPT(%08x, %08x, %08x)"
"BufferIn: (%08x, %i), BufferOut: (%08x, %i)", "BufferIn: (%08x, %i), BufferOut: (%08x, %i)",
sock, level, optname, sock, level, optname,
@ -696,7 +698,7 @@ u32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommand(u32 _Command,
//for(int i=0; i<BufferOutSize; i++) INFO_LOG(WII_IPC_NET,"%02x ", Memory::Read_U8(_BufferOut + i)); //for(int i=0; i<BufferOutSize; i++) INFO_LOG(WII_IPC_NET,"%02x ", Memory::Read_U8(_BufferOut + i));
int ret = getsockopt (sock, level, optname, (char *) &optval, (socklen_t*)&optlen); int ret = getsockopt (sock, level, optname, (char *) &optval, (socklen_t*)&optlen);
ret = getNetErrorCode(ret, "SO_GETSOCKOPT"); ret = getNetErrorCode(ret, "SO_GETSOCKOPT");
@ -745,10 +747,10 @@ u32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommand(u32 _Command,
"Socket: %08x, BufferIn: (%08x, %i), BufferOut: (%08x, %i)", "Socket: %08x, BufferIn: (%08x, %i), BufferOut: (%08x, %i)",
cmd, arg, cmd, arg,
sock, _BufferIn, BufferInSize, _BufferOut, BufferOutSize); sock, _BufferIn, BufferInSize, _BufferOut, BufferOutSize);
#ifdef _WIN32 #ifdef _WIN32
#define F_GETFL 3 #define F_GETFL 3
#define F_SETFL 4 #define F_SETFL 4
#define F_NONBLOCK 4 #define F_NONBLOCK 4
if (cmd == F_GETFL) if (cmd == F_GETFL)
{ {
INFO_LOG(WII_IPC_NET, "F_GETFL WTF?"); INFO_LOG(WII_IPC_NET, "F_GETFL WTF?");
@ -766,9 +768,9 @@ u32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommand(u32 _Command,
INFO_LOG(WII_IPC_NET, "UNKNOWN WTF?"); INFO_LOG(WII_IPC_NET, "UNKNOWN WTF?");
} }
return 0; return 0;
#else #else
return fcntl(sock, cmd, arg); return fcntl(sock, cmd, arg);
#endif #endif
} }
case IOCTL_SO_GETSOCKNAME: case IOCTL_SO_GETSOCKNAME:
@ -785,7 +787,7 @@ u32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommand(u32 _Command,
int ret = getsockname(sock, &sa, &sa_len); int ret = getsockname(sock, &sa, &sa_len);
Memory::Write_U8(BufferOutSize, _BufferOut); Memory::Write_U8(BufferOutSize, _BufferOut);
Memory::Write_U8(sa.sa_family, _BufferOut+1); Memory::Write_U8(sa.sa_family & 0xFF, _BufferOut+1);
Memory::WriteBigEData((u8*)&sa.sa_data, _BufferOut+2, BufferOutSize-2); Memory::WriteBigEData((u8*)&sa.sa_data, _BufferOut+2, BufferOutSize-2);
return ret; return ret;
} }
@ -794,7 +796,7 @@ u32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommand(u32 _Command,
INFO_LOG(WII_IPC_NET, "/dev/net/ip/top::IOCtl request IOCTL_SO_GETHOSTID " INFO_LOG(WII_IPC_NET, "/dev/net/ip/top::IOCtl request IOCTL_SO_GETHOSTID "
"(BufferIn: (%08x, %i), BufferOut: (%08x, %i)", "(BufferIn: (%08x, %i), BufferOut: (%08x, %i)",
_BufferIn, BufferInSize, _BufferOut, BufferOutSize); _BufferIn, BufferInSize, _BufferOut, BufferOutSize);
return 10 << 24 | 1 << 8 | 30; return 192 << 24 | 168 << 16 | 1 << 8 | 150;
case IOCTL_SO_INETATON: case IOCTL_SO_INETATON:
{ {
@ -814,7 +816,7 @@ u32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommand(u32 _Command,
case IOCTL_SO_POLL: case IOCTL_SO_POLL:
{ {
#ifdef _WIN32 #ifdef _WIN32
u32 unknown = Memory::Read_U32(_BufferIn); u32 unknown = Memory::Read_U32(_BufferIn);
u32 timeout = Memory::Read_U32(_BufferIn + 4); u32 timeout = Memory::Read_U32(_BufferIn + 4);
@ -836,7 +838,7 @@ u32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommand(u32 _Command,
_BufferIn, BufferInSize, _BufferOut, BufferOutSize); _BufferIn, BufferInSize, _BufferOut, BufferOutSize);
} }
int ret = poll(ufds, nfds, timeout); int ret = poll(ufds, nfds, timeout);
ret = getNetErrorCode(ret, "SO_SETSOCKOPT"); ret = getNetErrorCode(ret, "SO_SETSOCKOPT");
for (int i = 0; i<nfds; i++) for (int i = 0; i<nfds; i++)
@ -847,9 +849,9 @@ u32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommand(u32 _Command,
} }
free(ufds); free(ufds);
return ret; return ret;
#else #else
#pragma warning /dev/net/ip/top::IOCtl IOCTL_SO_POLL unimplemented #pragma warning /dev/net/ip/top::IOCtl IOCTL_SO_POLL unimplemented
#endif #endif
break; break;
} }
@ -951,11 +953,11 @@ u32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommandV(u32 _Parameter, SIOCtlVBuffe
//struct ifreq ifr; struct sockaddr_in saddr; //struct ifreq ifr; struct sockaddr_in saddr;
//int fd; //int fd;
#ifdef _WIN32 #ifdef _WIN32
PIP_ADAPTER_ADDRESSES AdapterAddresses = NULL; PIP_ADAPTER_ADDRESSES AdapterAddresses = NULL;
ULONG OutBufferLength = 0; ULONG OutBufferLength = 0;
ULONG RetVal = 0, i; ULONG RetVal = 0, i;
#endif #endif
u32 param = 0, param2 = 0, param3, param4, param5 = 0; u32 param = 0, param2 = 0, param3, param4, param5 = 0;
@ -988,7 +990,7 @@ u32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommandV(u32 _Parameter, SIOCtlVBuffe
ioctl(fd,SIOCGIFADDR,&ifr); ioctl(fd,SIOCGIFADDR,&ifr);
saddr=*((struct sockaddr_in *)(&(ifr.ifr_addr))); saddr=*((struct sockaddr_in *)(&(ifr.ifr_addr)));
*/ */
#ifdef _WIN32 #ifdef _WIN32
for (i = 0; i < 5; i++) for (i = 0; i < 5; i++)
{ {
RetVal = GetAdaptersAddresses( RetVal = GetAdaptersAddresses(
@ -1042,7 +1044,7 @@ u32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommandV(u32 _Parameter, SIOCtlVBuffe
if (AdapterAddresses != NULL) { if (AdapterAddresses != NULL) {
FREE(AdapterAddresses); FREE(AdapterAddresses);
} }
#endif #endif
if (address == 0) if (address == 0)
address = 0x08080808; address = 0x08080808;
@ -1148,13 +1150,8 @@ u32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommandV(u32 _Parameter, SIOCtlVBuffe
return totallen; return totallen;
}else }else
#endif #endif
if (fromlen){
ret = recvfrom(sock, buf, len, flags, ret = recvfrom(sock, buf, len, flags,
fromlen ? (struct sockaddr*) &addr : NULL, fromlen ? &fromlen : 0); fromlen ? (struct sockaddr*) &addr : NULL, fromlen ? &fromlen : 0);
}else{
ret = recv(sock, buf, len, flags);
}
if (BufferOutSize2 != 0) if (BufferOutSize2 != 0)
{ {
//something not quite right below, need to verify //something not quite right below, need to verify
@ -1242,7 +1239,6 @@ u32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommandV(u32 _Parameter, SIOCtlVBuffe
INFO_LOG(WII_IPC_NET,"/dev/net/ip/top::IOCtlV request 0x%x (BufferIn: (%08x, %i), BufferIn2: (%08x, %i)", INFO_LOG(WII_IPC_NET,"/dev/net/ip/top::IOCtlV request 0x%x (BufferIn: (%08x, %i), BufferIn2: (%08x, %i)",
_Parameter, _BufferIn, BufferInSize, _BufferIn2, BufferInSize2); _Parameter, _BufferIn, BufferInSize, _BufferIn2, BufferInSize2);
break; break;
} }
return 0; return 0;
} }