Fix code style in WII_IPC_HLE_Device_net.h/.cpp.

This commit is contained in:
Rachel Bryk 2014-07-09 05:15:07 -04:00
parent 29873a7c55
commit 36bc494a0b
2 changed files with 94 additions and 82 deletions

View File

@ -113,10 +113,12 @@ bool CWII_IPC_HLE_Device_net_kd_request::IOCtl(u32 _CommandAddress)
ReturnValue = 0; ReturnValue = 0;
INFO_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_STARTUP_SOCKET - NI"); INFO_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_STARTUP_SOCKET - NI");
break; break;
case IOCTL_NWC24_CLEANUP_SOCKET: case IOCTL_NWC24_CLEANUP_SOCKET:
Memory::Memset(BufferOut, 0, BufferOutSize); Memory::Memset(BufferOut, 0, BufferOutSize);
INFO_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_CLEANUP_SOCKET - NI"); INFO_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_CLEANUP_SOCKET - NI");
break; break;
case IOCTL_NWC24_LOCK_SOCKET: // WiiMenu case IOCTL_NWC24_LOCK_SOCKET: // WiiMenu
INFO_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_LOCK_SOCKET - NI"); INFO_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_LOCK_SOCKET - NI");
break; break;
@ -150,7 +152,6 @@ bool CWII_IPC_HLE_Device_net_kd_request::IOCtl(u32 _CommandAddress)
model = gen.GetValue("MODEL"); model = gen.GetValue("MODEL");
_GotSettings = true; _GotSettings = true;
} }
} }
if (_GotSettings) if (_GotSettings)
{ {
@ -187,6 +188,7 @@ bool CWII_IPC_HLE_Device_net_kd_request::IOCtl(u32 _CommandAddress)
Memory::Write_U64(config.Id(), BufferOut + 4); Memory::Write_U64(config.Id(), BufferOut + 4);
Memory::Write_U32(config.CreationStage(), BufferOut + 0xC); Memory::Write_U32(config.CreationStage(), BufferOut + 0xC);
break; break;
case IOCTL_NWC24_GET_SCHEDULAR_STAT: case IOCTL_NWC24_GET_SCHEDULAR_STAT:
INFO_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_GET_SCHEDULAR_STAT - NI"); INFO_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_GET_SCHEDULAR_STAT - NI");
break; break;
@ -371,6 +373,7 @@ bool CWII_IPC_HLE_Device_net_ncd_manage::IOCtlV(u32 _CommandAddress)
{ {
case IOCTLV_NCD_LOCKWIRELESSDRIVER: case IOCTLV_NCD_LOCKWIRELESSDRIVER:
break; break;
case IOCTLV_NCD_UNLOCKWIRELESSDRIVER: case IOCTLV_NCD_UNLOCKWIRELESSDRIVER:
//Memory::Read_U32(CommandBuffer.InBuffer.at(0).m_Address); //Memory::Read_U32(CommandBuffer.InBuffer.at(0).m_Address);
break; break;
@ -402,8 +405,7 @@ bool CWII_IPC_HLE_Device_net_ncd_manage::IOCtlV(u32 _CommandAddress)
case IOCTLV_NCD_GETLINKSTATUS: case IOCTLV_NCD_GETLINKSTATUS:
INFO_LOG(WII_IPC_NET, "NET_NCD_MANAGE: IOCTLV_NCD_GETLINKSTATUS"); INFO_LOG(WII_IPC_NET, "NET_NCD_MANAGE: IOCTLV_NCD_GETLINKSTATUS");
// Always connected // Always connected
Memory::Write_U32(netcfg_connection_t::LINK_WIRED, Memory::Write_U32(netcfg_connection_t::LINK_WIRED, CommandBuffer.PayloadBuffer.at(0).m_Address + 4);
CommandBuffer.PayloadBuffer.at(0).m_Address + 4);
break; break;
case IOCTLV_NCD_GETWIRELESSMACADDRESS: case IOCTLV_NCD_GETWIRELESSMACADDRESS:
@ -411,9 +413,7 @@ bool CWII_IPC_HLE_Device_net_ncd_manage::IOCtlV(u32 _CommandAddress)
u8 address[MAC_ADDRESS_SIZE]; u8 address[MAC_ADDRESS_SIZE];
GetMacAddress(address); GetMacAddress(address);
Memory::WriteBigEData(address, Memory::WriteBigEData(address, CommandBuffer.PayloadBuffer.at(1).m_Address, sizeof(address));
CommandBuffer.PayloadBuffer.at(1).m_Address,
sizeof(address));
break; break;
default: default:
@ -421,12 +421,10 @@ bool CWII_IPC_HLE_Device_net_ncd_manage::IOCtlV(u32 _CommandAddress)
break; break;
} }
Memory::Write_U32(common_result, Memory::Write_U32(common_result, CommandBuffer.PayloadBuffer.at(common_vector).m_Address);
CommandBuffer.PayloadBuffer.at(common_vector).m_Address);
if (common_vector == 1) if (common_vector == 1)
{ {
Memory::Write_U32(common_result, Memory::Write_U32(common_result, CommandBuffer.PayloadBuffer.at(common_vector).m_Address + 4);
CommandBuffer.PayloadBuffer.at(common_vector).m_Address + 4);
} }
Memory::Write_U32(return_value, _CommandAddress + 4); Memory::Write_U32(return_value, _CommandAddress + 4);
return true; return true;
@ -597,30 +595,38 @@ static int inet_pton(const char *src, unsigned char *dst)
saw_digit = 0; saw_digit = 0;
octets = 0; octets = 0;
*(tp = tmp) = 0; *(tp = tmp) = 0;
while ((ch = *src++) != '\0') { while ((ch = *src++) != '\0')
if (ch >= '0' && ch <= '9') { {
if (ch >= '0' && ch <= '9')
{
unsigned int newt = (*tp * 10) + (ch - '0'); unsigned int newt = (*tp * 10) + (ch - '0');
if (newt > 255) if (newt > 255)
return (0); return 0;
*tp = newt; *tp = newt;
if (! saw_digit) { if (!saw_digit)
{
if (++octets > 4) if (++octets > 4)
return (0); return 0;
saw_digit = 1; saw_digit = 1;
} }
} else if (ch == '.' && saw_digit) { }
else if (ch == '.' && saw_digit)
{
if (octets == 4) if (octets == 4)
return (0); return 0;
*++tp = 0; *++tp = 0;
saw_digit = 0; saw_digit = 0;
} else }
return (0); else
{
return 0;
}
} }
if (octets < 4) if (octets < 4)
return (0); return 0;
memcpy(dst, tmp, 4); memcpy(dst, tmp, 4);
return (1); return 1;
} }
// Maps SOCKOPT level from native to Wii // Maps SOCKOPT level from native to Wii
@ -778,7 +784,9 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
INFO_LOG(WII_IPC_NET, "IOCTL_SO_SETSOCKOPT(%08x, %08x, %08x, %08x) " INFO_LOG(WII_IPC_NET, "IOCTL_SO_SETSOCKOPT(%08x, %08x, %08x, %08x) "
"BufferIn: (%08x, %i), BufferOut: (%08x, %i)" "BufferIn: (%08x, %i), BufferOut: (%08x, %i)"
"%02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx", "%02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx",
fd, level, optname, optlen, BufferIn, BufferInSize, BufferOut, BufferOutSize, optval[0], optval[1], optval[2], optval[3], optval[4], optval[5], optval[6], optval[7], optval[8], optval[9], optval[10], optval[11], optval[12], optval[13], optval[14], optval[15], optval[16], optval[17], optval[18], optval[19]); fd, level, optname, optlen, BufferIn, BufferInSize, BufferOut, BufferOutSize, optval[0], optval[1], optval[2], optval[3],
optval[4], optval[5],optval[6], optval[7], optval[8], optval[9], optval[10], optval[11], optval[12], optval[13], optval[14],
optval[15], optval[16], optval[17], optval[18], optval[19]);
//TODO: bug booto about this, 0x2005 most likely timeout related, default value on wii is , 0x2001 is most likely tcpnodelay //TODO: bug booto about this, 0x2005 most likely timeout related, default value on wii is , 0x2001 is most likely tcpnodelay
if (level == 6 && (optname == 0x2005 || optname == 0x2001)){ if (level == 6 && (optname == 0x2005 || optname == 0x2001)){
@ -877,7 +885,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
result = GetIpForwardTable(forwardTable.get(), &forwardTableSize, FALSE); result = GetIpForwardTable(forwardTable.get(), &forwardTableSize, FALSE);
while (result == NO_ERROR || result == ERROR_MORE_DATA) // can return ERROR_MORE_DATA on XP even after the first call while (result == NO_ERROR || result == ERROR_MORE_DATA) // can return ERROR_MORE_DATA on XP even after the first call
{ {
for (DWORD i = 0; i < forwardTable->dwNumEntries; i++) for (DWORD i = 0; i < forwardTable->dwNumEntries; ++i)
{ {
if (forwardTable->table[i].dwForwardDest == 0) if (forwardTable->table[i].dwForwardDest == 0)
{ {
@ -894,7 +902,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
if (ifIndex != -1 && GetIpAddrTable(ipTable.get(), &ipTableSize, FALSE) == NO_ERROR) if (ifIndex != -1 && GetIpAddrTable(ipTable.get(), &ipTableSize, FALSE) == NO_ERROR)
{ {
for (DWORD i = 0; i < ipTable->dwNumEntries; i++) for (DWORD i = 0; i < ipTable->dwNumEntries; ++i)
{ {
if (ipTable->table[i].dwIndex == ifIndex) if (ipTable->table[i].dwIndex == ifIndex)
{ {
@ -972,7 +980,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
break; break;
} }
for (int i = 0; i < nfds; i++) for (int i = 0; i < nfds; ++i)
{ {
ufds[i].fd = Memory::Read_U32(BufferOut + 0xc*i); //fd ufds[i].fd = Memory::Read_U32(BufferOut + 0xc*i); //fd
int events = Memory::Read_U32(BufferOut + 0xc*i + 4); //events int events = Memory::Read_U32(BufferOut + 0xc*i + 4); //events
@ -1001,7 +1009,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)
{ {
// Translate native to Wii events // Translate native to Wii events
@ -1083,7 +1091,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
Memory::Write_U32(0, wii_addr); Memory::Write_U32(0, wii_addr);
wii_addr += sizeof(u32); wii_addr += sizeof(u32);
// The actual IPs // The actual IPs
for (int i = 0; remoteHost->h_addr_list[i]; i++) for (int i = 0; remoteHost->h_addr_list[i]; ++i)
{ {
Memory::Write_U32_Swap(*(u32*)(remoteHost->h_addr_list[i]), wii_addr); Memory::Write_U32_Swap(*(u32*)(remoteHost->h_addr_list[i]), wii_addr);
wii_addr += sizeof(u32); wii_addr += sizeof(u32);
@ -1104,6 +1112,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
case IOCTL_SO_ICMPCANCEL: case IOCTL_SO_ICMPCANCEL:
ERROR_LOG(WII_IPC_NET, "IOCTL_SO_ICMPCANCEL"); ERROR_LOG(WII_IPC_NET, "IOCTL_SO_ICMPCANCEL");
goto default_; goto default_;
default: default:
INFO_LOG(WII_IPC_NET,"0x%x " INFO_LOG(WII_IPC_NET,"0x%x "
"BufferIn: (%08x, %i), BufferOut: (%08x, %i)", "BufferIn: (%08x, %i), BufferOut: (%08x, %i)",
@ -1112,9 +1121,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
if (BufferInSize) if (BufferInSize)
{ {
ERROR_LOG(WII_IPC_NET, "in addr %x size %x", BufferIn, BufferInSize); ERROR_LOG(WII_IPC_NET, "in addr %x size %x", BufferIn, BufferInSize);
ERROR_LOG(WII_IPC_NET, "\n%s", ERROR_LOG(WII_IPC_NET, "\n%s", ArrayToString(Memory::GetPointer(BufferIn), BufferInSize, 4).c_str());
ArrayToString(Memory::GetPointer(BufferIn), BufferInSize, 4).c_str()
);
} }
if (BufferOutSize) if (BufferOutSize)
@ -1198,7 +1205,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtlV(u32 CommandAddress)
PIP_ADAPTER_ADDRESSES AdapterAddresses = nullptr; PIP_ADAPTER_ADDRESSES AdapterAddresses = nullptr;
ULONG OutBufferLength = 0; ULONG OutBufferLength = 0;
ULONG RetVal = 0, i; ULONG RetVal = 0, i;
for (i = 0; i < 5; i++) for (i = 0; i < 5; ++i)
{ {
RetVal = GetAdaptersAddresses( RetVal = GetAdaptersAddresses(
AF_INET, AF_INET,
@ -1207,16 +1214,19 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtlV(u32 CommandAddress)
AdapterAddresses, AdapterAddresses,
&OutBufferLength); &OutBufferLength);
if (RetVal != ERROR_BUFFER_OVERFLOW) { if (RetVal != ERROR_BUFFER_OVERFLOW)
{
break; break;
} }
if (AdapterAddresses != nullptr) { if (AdapterAddresses != nullptr)
{
FREE(AdapterAddresses); FREE(AdapterAddresses);
} }
AdapterAddresses = (PIP_ADAPTER_ADDRESSES)MALLOC(OutBufferLength); AdapterAddresses = (PIP_ADAPTER_ADDRESSES)MALLOC(OutBufferLength);
if (AdapterAddresses == nullptr) { if (AdapterAddresses == nullptr)
{
RetVal = GetLastError(); RetVal = GetLastError();
break; break;
} }
@ -1248,7 +1258,8 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtlV(u32 CommandAddress)
} }
} }
} }
if (AdapterAddresses != nullptr) { if (AdapterAddresses != nullptr)
{
FREE(AdapterAddresses); FREE(AdapterAddresses);
} }
#endif #endif
@ -1262,23 +1273,28 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtlV(u32 CommandAddress)
case 0x1003: // error case 0x1003: // error
Memory::Write_U32(0, _BufferOut); Memory::Write_U32(0, _BufferOut);
break; break;
case 0x1004: // mac address case 0x1004: // mac address
u8 address[MAC_ADDRESS_SIZE]; u8 address[MAC_ADDRESS_SIZE];
GetMacAddress(address); GetMacAddress(address);
Memory::WriteBigEData(address, _BufferOut, sizeof(address)); Memory::WriteBigEData(address, _BufferOut, sizeof(address));
break; break;
case 0x1005: // link state case 0x1005: // link state
Memory::Write_U32(1, _BufferOut); Memory::Write_U32(1, _BufferOut);
break; break;
case 0x4002: // ip addr number case 0x4002: // ip addr number
Memory::Write_U32(1, _BufferOut); Memory::Write_U32(1, _BufferOut);
break; break;
case 0x4003: // ip addr table case 0x4003: // ip addr table
Memory::Write_U32(0xC, _BufferOut2); Memory::Write_U32(0xC, _BufferOut2);
Memory::Write_U32(10 << 24 | 1 << 8 | 30, _BufferOut); Memory::Write_U32(10 << 24 | 1 << 8 | 30, _BufferOut);
Memory::Write_U32(255 << 24 | 255 << 16 | 255 << 8 | 0, _BufferOut+4); Memory::Write_U32(255 << 24 | 255 << 16 | 255 << 8 | 0, _BufferOut+4);
Memory::Write_U32(10 << 24 | 0 << 16 | 255 << 8 | 255, _BufferOut+8); Memory::Write_U32(10 << 24 | 0 << 16 | 255 << 8 | 255, _BufferOut+8);
break; break;
default: default:
ERROR_LOG(WII_IPC_NET, "Unknown param2: %08X", param2); ERROR_LOG(WII_IPC_NET, "Unknown param2: %08X", param2);
break; break;

View File

@ -177,8 +177,6 @@ public:
void ResetConfig() void ResetConfig()
{ {
int i;
if (File::Exists(path)) if (File::Exists(path))
File::Delete(path); File::Delete(path);
@ -198,7 +196,7 @@ public:
SetEnableBooting(0); SetEnableBooting(0);
SetEmail("@wii.com"); SetEmail("@wii.com");
for (i=0; i<nwc24_config_t::URL_COUNT; i++) for (int i = 0; i < nwc24_config_t::URL_COUNT; ++i)
{ {
strncpy(config.http_urls[i], urls[i], nwc24_config_t::MAX_URL_LENGTH); strncpy(config.http_urls[i], urls[i], nwc24_config_t::MAX_URL_LENGTH);
} }
@ -245,8 +243,7 @@ public:
{ {
u32* ptr = (u32*)&config; u32* ptr = (u32*)&config;
u32 sum = 0; u32 sum = 0;
int i; for (int i = 0; i < 0xFF; ++i)
for (i=0; i<0xFF; i++)
{ {
sum += Common::swap32(*ptr++); sum += Common::swap32(*ptr++);
} }
@ -286,7 +283,9 @@ public:
u32 IdGen() {return Common::swap32(config.id_generation);} u32 IdGen() {return Common::swap32(config.id_generation);}
void SetIdGen(u32 id_generation) {config.id_generation = Common::swap32(id_generation);} void SetIdGen(u32 id_generation) {config.id_generation = Common::swap32(id_generation);}
void IncrementIdGen(){
void IncrementIdGen()
{
u32 id_ctr = IdGen(); u32 id_ctr = IdGen();
id_ctr++; id_ctr++;
id_ctr &= 0x1F; id_ctr &= 0x1F;
@ -323,7 +322,6 @@ public:
WiiNetConfig() WiiNetConfig()
{ {
path = File::GetUserPath(D_WIISYSCONF_IDX) + "net/02/config.dat"; path = File::GetUserPath(D_WIISYSCONF_IDX) + "net/02/config.dat";
ReadConfig(); ReadConfig();
} }
@ -348,8 +346,7 @@ public:
{ {
if (!File::Exists(path)) if (!File::Exists(path))
{ {
if (!File::CreateFullPath( if (!File::CreateFullPath(std::string(File::GetUserPath(D_WIISYSCONF_IDX) + "net/02/")))
std::string(File::GetUserPath(D_WIISYSCONF_IDX) + "net/02/")))
{ {
ERROR_LOG(WII_IPC_NET, "Failed to create directory for network config file"); ERROR_LOG(WII_IPC_NET, "Failed to create directory for network config file");
} }
@ -507,8 +504,7 @@ public:
break; break;
default: default:
ERROR_LOG(WII_IPC_NET, "%s - unknown IOCtl: %x\n", ERROR_LOG(WII_IPC_NET, "%s - unknown IOCtl: %x\n", GetDeviceName().c_str(), Parameter);
GetDeviceName().c_str(), Parameter);
break; break;
} }