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;
@ -477,11 +475,11 @@ bool CWII_IPC_HLE_Device_net_wd_command::IOCtlV(u32 CommandAddress)
// XXX - unused // XXX - unused
// ScanInfo *scan = (ScanInfo *)Memory::GetPointer(CommandBuffer.InBuffer.at(0).m_Address); // ScanInfo *scan = (ScanInfo *)Memory::GetPointer(CommandBuffer.InBuffer.at(0).m_Address);
u16 *results = (u16 *)Memory::GetPointer(CommandBuffer.PayloadBuffer.at(0).m_Address); u16* results = (u16*)Memory::GetPointer(CommandBuffer.PayloadBuffer.at(0).m_Address);
// first u16 indicates number of BSSInfo following // first u16 indicates number of BSSInfo following
results[0] = Common::swap16(1); results[0] = Common::swap16(1);
BSSInfo *bss = (BSSInfo *)&results[1]; BSSInfo* bss = (BSSInfo*)&results[1];
memset(bss, 0, sizeof(BSSInfo)); memset(bss, 0, sizeof(BSSInfo));
bss->length = Common::swap16(sizeof(BSSInfo)); bss->length = Common::swap16(sizeof(BSSInfo));
@ -490,8 +488,8 @@ bool CWII_IPC_HLE_Device_net_wd_command::IOCtlV(u32 CommandAddress)
for (int i = 0; i < BSSID_SIZE; ++i) for (int i = 0; i < BSSID_SIZE; ++i)
bss->bssid[i] = i; bss->bssid[i] = i;
const char *ssid = "dolphin-emu"; const char* ssid = "dolphin-emu";
strcpy((char *)bss->ssid, ssid); strcpy((char*)bss->ssid, ssid);
bss->ssid_length = Common::swap16((u16)strlen(ssid)); bss->ssid_length = Common::swap16((u16)strlen(ssid));
bss->channel = Common::swap16(2); bss->channel = Common::swap16(2);
@ -500,7 +498,7 @@ bool CWII_IPC_HLE_Device_net_wd_command::IOCtlV(u32 CommandAddress)
case IOCTLV_WD_GET_INFO: case IOCTLV_WD_GET_INFO:
{ {
Info *info = (Info *)Memory::GetPointer(CommandBuffer.PayloadBuffer.at(0).m_Address); Info* info = (Info*)Memory::GetPointer(CommandBuffer.PayloadBuffer.at(0).m_Address);
memset(info, 0, sizeof(Info)); memset(info, 0, sizeof(Info));
// Probably used to disallow certain channels? // Probably used to disallow certain channels?
memcpy(info->country, "US", 2); memcpy(info->country, "US", 2);
@ -588,7 +586,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::Close(u32 _CommandAddress, bool _bForce)
return true; return true;
} }
static int inet_pton(const char *src, unsigned char *dst) static int inet_pton(const char* src, unsigned char* dst)
{ {
int saw_digit, octets; int saw_digit, octets;
char ch; char ch;
@ -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
@ -749,12 +755,12 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
u8 optval[20]; u8 optval[20];
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);
Memory::WriteBigEData((u8 *) optval, BufferOut + 0x10, optlen); Memory::WriteBigEData((u8*) optval, BufferOut + 0x10, optlen);
if (optname == SO_ERROR) if (optname == SO_ERROR)
{ {
@ -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)
{ {
@ -913,12 +921,12 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
case IOCTL_SO_INETATON: case IOCTL_SO_INETATON:
{ {
struct hostent *remoteHost = gethostbyname((char*)Memory::GetPointer(BufferIn)); struct hostent* remoteHost = gethostbyname((char*)Memory::GetPointer(BufferIn));
Memory::Write_U32(Common::swap32(*(u32 *)remoteHost->h_addr_list[0]), BufferOut); Memory::Write_U32(Common::swap32(*(u32*)remoteHost->h_addr_list[0]), BufferOut);
INFO_LOG(WII_IPC_NET, "IOCTL_SO_INETATON = %d " INFO_LOG(WII_IPC_NET, "IOCTL_SO_INETATON = %d "
"%s, BufferIn: (%08x, %i), BufferOut: (%08x, %i), IP Found: %08X",remoteHost->h_addr_list[0] == nullptr ? -1 : 0, "%s, BufferIn: (%08x, %i), BufferOut: (%08x, %i), IP Found: %08X",remoteHost->h_addr_list[0] == nullptr ? -1 : 0,
(char*)Memory::GetPointer(BufferIn), BufferIn, BufferInSize, BufferOut, BufferOutSize, Common::swap32(*(u32 *)remoteHost->h_addr_list[0])); (char*)Memory::GetPointer(BufferIn), BufferIn, BufferInSize, BufferOut, BufferOutSize, Common::swap32(*(u32*)remoteHost->h_addr_list[0]));
ReturnValue = remoteHost->h_addr_list[0] == nullptr ? 0 : 1; ReturnValue = remoteHost->h_addr_list[0] == nullptr ? 0 : 1;
break; break;
} }
@ -965,14 +973,14 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
if (nfds == 0) if (nfds == 0)
ERROR_LOG(WII_IPC_NET, "Hidden POLL"); ERROR_LOG(WII_IPC_NET, "Hidden POLL");
pollfd_t* ufds = (pollfd_t *)malloc(sizeof(pollfd_t) * nfds); pollfd_t* ufds = (pollfd_t*)malloc(sizeof(pollfd_t) * nfds);
if (ufds == nullptr) if (ufds == nullptr)
{ {
ReturnValue = -1; ReturnValue = -1;
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
@ -1027,7 +1035,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
case IOCTL_SO_GETHOSTBYNAME: case IOCTL_SO_GETHOSTBYNAME:
{ {
hostent *remoteHost = gethostbyname((char*)Memory::GetPointer(BufferIn)); hostent* remoteHost = gethostbyname((char*)Memory::GetPointer(BufferIn));
INFO_LOG(WII_IPC_NET, "IOCTL_SO_GETHOSTBYNAME " INFO_LOG(WII_IPC_NET, "IOCTL_SO_GETHOSTBYNAME "
"Address: %s, BufferIn: (%08x, %i), BufferOut: (%08x, %i)", "Address: %s, BufferIn: (%08x, %i), BufferOut: (%08x, %i)",
@ -1051,7 +1059,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
u32 wii_addr = BufferOut + 4 * 3 + 2 * 2; u32 wii_addr = BufferOut + 4 * 3 + 2 * 2;
u32 name_length = (u32)strlen(remoteHost->h_name) + 1; u32 name_length = (u32)strlen(remoteHost->h_name) + 1;
Memory::WriteBigEData((const u8 *)remoteHost->h_name, wii_addr, name_length); Memory::WriteBigEData((const u8*)remoteHost->h_name, wii_addr, name_length);
Memory::Write_U32(wii_addr, BufferOut); Memory::Write_U32(wii_addr, BufferOut);
wii_addr += (name_length + 4) & ~3; wii_addr += (name_length + 4) & ~3;
@ -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;
@ -1304,7 +1320,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtlV(u32 CommandAddress)
case IOCTLV_SO_GETADDRINFO: case IOCTLV_SO_GETADDRINFO:
{ {
struct addrinfo hints; struct addrinfo hints;
struct addrinfo *result = nullptr; struct addrinfo* result = nullptr;
if (BufferInSize3) if (BufferInSize3)
{ {
@ -1428,7 +1444,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtlV(u32 CommandAddress)
// TODO sequence number is incremented either statically, by // TODO sequence number is incremented either statically, by
// port, or by socket. Doesn't seem to matter, so we just leave // port, or by socket. Doesn't seem to matter, so we just leave
// it 0 // it 0
((u16 *)data)[0] = Common::swap16(ip_info.icmp_id); ((u16*)data)[0] = Common::swap16(ip_info.icmp_id);
icmp_length = 22; icmp_length = 22;
} }

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);
} }
@ -226,7 +224,7 @@ public:
{ {
if (File::Exists(path)) if (File::Exists(path))
{ {
if (!File::IOFile(path, "rb").ReadBytes((void *)&config, sizeof(config))) if (!File::IOFile(path, "rb").ReadBytes((void*)&config, sizeof(config)))
ResetConfig(); ResetConfig();
else else
{ {
@ -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++);
} }
@ -278,35 +275,37 @@ public:
return 0; return 0;
} }
u32 Magic(){return Common::swap32(config.magic);} u32 Magic() {return Common::swap32(config.magic);}
void SetMagic(u32 magic){config.magic = Common::swap32(magic);} void SetMagic(u32 magic) {config.magic = Common::swap32(magic);}
u32 Unk(){return Common::swap32(config._unk_04);} u32 Unk() {return Common::swap32(config._unk_04);}
void SetUnk(u32 _unk_04){config._unk_04 = Common::swap32(_unk_04);} void SetUnk(u32 _unk_04) {config._unk_04 = Common::swap32(_unk_04);}
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;
SetIdGen(id_ctr); SetIdGen(id_ctr);
} }
u32 Checksum(){return Common::swap32(config.checksum);} u32 Checksum() {return Common::swap32(config.checksum);}
void SetChecksum(u32 checksum){config.checksum = Common::swap32(checksum);} void SetChecksum(u32 checksum) {config.checksum = Common::swap32(checksum);}
u32 CreationStage(){return Common::swap32(config.creation_stage);} u32 CreationStage() {return Common::swap32(config.creation_stage);}
void SetCreationStage(u32 creation_stage){config.creation_stage = Common::swap32(creation_stage);} void SetCreationStage(u32 creation_stage) {config.creation_stage = Common::swap32(creation_stage);}
u32 EnableBooting(){return Common::swap32(config.enable_booting);} u32 EnableBooting() {return Common::swap32(config.enable_booting);}
void SetEnableBooting(u32 enable_booting){config.enable_booting = Common::swap32(enable_booting);} void SetEnableBooting(u32 enable_booting) {config.enable_booting = Common::swap32(enable_booting);}
u64 Id(){return Common::swap64(config.nwc24_id);} u64 Id() {return Common::swap64(config.nwc24_id);}
void SetId(u64 nwc24_id){config.nwc24_id = Common::swap64(nwc24_id);} void SetId(u64 nwc24_id) {config.nwc24_id = Common::swap64(nwc24_id);}
const char * Email(){return config.email;} const char* Email() {return config.email;}
void SetEmail(const char * email) void SetEmail(const char* email)
{ {
strncpy(config.email, email, nwc24_config_t::MAX_EMAIL_LENGTH); strncpy(config.email, email, nwc24_config_t::MAX_EMAIL_LENGTH);
config.email[nwc24_config_t::MAX_EMAIL_LENGTH-1] = '\0'; config.email[nwc24_config_t::MAX_EMAIL_LENGTH-1] = '\0';
@ -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");
} }
@ -360,19 +357,19 @@ public:
void WriteToMem(const u32 address) void WriteToMem(const u32 address)
{ {
Memory::WriteBigEData((const u8 *)&config, address, sizeof(config)); Memory::WriteBigEData((const u8*)&config, address, sizeof(config));
} }
void ReadFromMem(const u32 address) void ReadFromMem(const u32 address)
{ {
Memory::ReadBigEData((u8 *)&config, address, sizeof(config)); Memory::ReadBigEData((u8*)&config, address, sizeof(config));
} }
void ReadConfig() void ReadConfig()
{ {
if (File::Exists(path)) if (File::Exists(path))
{ {
if (!File::IOFile(path, "rb").ReadBytes((void *)&config, sizeof(config))) if (!File::IOFile(path, "rb").ReadBytes((void*)&config, sizeof(config)))
ResetConfig(); ResetConfig();
} }
else else
@ -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;
} }