mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 13:57:57 -07:00
Fix code style in WII_IPC_HLE_Device_net.h/.cpp.
This commit is contained in:
parent
29873a7c55
commit
36bc494a0b
@ -113,10 +113,12 @@ bool CWII_IPC_HLE_Device_net_kd_request::IOCtl(u32 _CommandAddress)
|
||||
ReturnValue = 0;
|
||||
INFO_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_STARTUP_SOCKET - NI");
|
||||
break;
|
||||
|
||||
case IOCTL_NWC24_CLEANUP_SOCKET:
|
||||
Memory::Memset(BufferOut, 0, BufferOutSize);
|
||||
INFO_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_CLEANUP_SOCKET - NI");
|
||||
break;
|
||||
|
||||
case IOCTL_NWC24_LOCK_SOCKET: // WiiMenu
|
||||
INFO_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_LOCK_SOCKET - NI");
|
||||
break;
|
||||
@ -150,7 +152,6 @@ bool CWII_IPC_HLE_Device_net_kd_request::IOCtl(u32 _CommandAddress)
|
||||
model = gen.GetValue("MODEL");
|
||||
_GotSettings = true;
|
||||
}
|
||||
|
||||
}
|
||||
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_U32(config.CreationStage(), BufferOut + 0xC);
|
||||
break;
|
||||
|
||||
case IOCTL_NWC24_GET_SCHEDULAR_STAT:
|
||||
INFO_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_GET_SCHEDULAR_STAT - NI");
|
||||
break;
|
||||
@ -371,6 +373,7 @@ bool CWII_IPC_HLE_Device_net_ncd_manage::IOCtlV(u32 _CommandAddress)
|
||||
{
|
||||
case IOCTLV_NCD_LOCKWIRELESSDRIVER:
|
||||
break;
|
||||
|
||||
case IOCTLV_NCD_UNLOCKWIRELESSDRIVER:
|
||||
//Memory::Read_U32(CommandBuffer.InBuffer.at(0).m_Address);
|
||||
break;
|
||||
@ -402,8 +405,7 @@ bool CWII_IPC_HLE_Device_net_ncd_manage::IOCtlV(u32 _CommandAddress)
|
||||
case IOCTLV_NCD_GETLINKSTATUS:
|
||||
INFO_LOG(WII_IPC_NET, "NET_NCD_MANAGE: IOCTLV_NCD_GETLINKSTATUS");
|
||||
// Always connected
|
||||
Memory::Write_U32(netcfg_connection_t::LINK_WIRED,
|
||||
CommandBuffer.PayloadBuffer.at(0).m_Address + 4);
|
||||
Memory::Write_U32(netcfg_connection_t::LINK_WIRED, CommandBuffer.PayloadBuffer.at(0).m_Address + 4);
|
||||
break;
|
||||
|
||||
case IOCTLV_NCD_GETWIRELESSMACADDRESS:
|
||||
@ -411,9 +413,7 @@ bool CWII_IPC_HLE_Device_net_ncd_manage::IOCtlV(u32 _CommandAddress)
|
||||
|
||||
u8 address[MAC_ADDRESS_SIZE];
|
||||
GetMacAddress(address);
|
||||
Memory::WriteBigEData(address,
|
||||
CommandBuffer.PayloadBuffer.at(1).m_Address,
|
||||
sizeof(address));
|
||||
Memory::WriteBigEData(address, CommandBuffer.PayloadBuffer.at(1).m_Address, sizeof(address));
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -421,12 +421,10 @@ bool CWII_IPC_HLE_Device_net_ncd_manage::IOCtlV(u32 _CommandAddress)
|
||||
break;
|
||||
}
|
||||
|
||||
Memory::Write_U32(common_result,
|
||||
CommandBuffer.PayloadBuffer.at(common_vector).m_Address);
|
||||
Memory::Write_U32(common_result, CommandBuffer.PayloadBuffer.at(common_vector).m_Address);
|
||||
if (common_vector == 1)
|
||||
{
|
||||
Memory::Write_U32(common_result,
|
||||
CommandBuffer.PayloadBuffer.at(common_vector).m_Address + 4);
|
||||
Memory::Write_U32(common_result, CommandBuffer.PayloadBuffer.at(common_vector).m_Address + 4);
|
||||
}
|
||||
Memory::Write_U32(return_value, _CommandAddress + 4);
|
||||
return true;
|
||||
@ -477,11 +475,11 @@ bool CWII_IPC_HLE_Device_net_wd_command::IOCtlV(u32 CommandAddress)
|
||||
// XXX - unused
|
||||
// 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
|
||||
results[0] = Common::swap16(1);
|
||||
|
||||
BSSInfo *bss = (BSSInfo *)&results[1];
|
||||
BSSInfo* bss = (BSSInfo*)&results[1];
|
||||
memset(bss, 0, 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)
|
||||
bss->bssid[i] = i;
|
||||
|
||||
const char *ssid = "dolphin-emu";
|
||||
strcpy((char *)bss->ssid, ssid);
|
||||
const char* ssid = "dolphin-emu";
|
||||
strcpy((char*)bss->ssid, ssid);
|
||||
bss->ssid_length = Common::swap16((u16)strlen(ssid));
|
||||
|
||||
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:
|
||||
{
|
||||
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));
|
||||
// Probably used to disallow certain channels?
|
||||
memcpy(info->country, "US", 2);
|
||||
@ -588,7 +586,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::Close(u32 _CommandAddress, bool _bForce)
|
||||
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;
|
||||
char ch;
|
||||
@ -597,30 +595,38 @@ static int inet_pton(const char *src, unsigned char *dst)
|
||||
saw_digit = 0;
|
||||
octets = 0;
|
||||
*(tp = tmp) = 0;
|
||||
while ((ch = *src++) != '\0') {
|
||||
if (ch >= '0' && ch <= '9') {
|
||||
while ((ch = *src++) != '\0')
|
||||
{
|
||||
if (ch >= '0' && ch <= '9')
|
||||
{
|
||||
unsigned int newt = (*tp * 10) + (ch - '0');
|
||||
|
||||
if (newt > 255)
|
||||
return (0);
|
||||
return 0;
|
||||
*tp = newt;
|
||||
if (! saw_digit) {
|
||||
if (!saw_digit)
|
||||
{
|
||||
if (++octets > 4)
|
||||
return (0);
|
||||
return 0;
|
||||
saw_digit = 1;
|
||||
}
|
||||
} else if (ch == '.' && saw_digit) {
|
||||
}
|
||||
else if (ch == '.' && saw_digit)
|
||||
{
|
||||
if (octets == 4)
|
||||
return (0);
|
||||
return 0;
|
||||
*++tp = 0;
|
||||
saw_digit = 0;
|
||||
} else
|
||||
return (0);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (octets < 4)
|
||||
return (0);
|
||||
return 0;
|
||||
memcpy(dst, tmp, 4);
|
||||
return (1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// 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];
|
||||
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);
|
||||
|
||||
|
||||
Memory::Write_U32(optlen, BufferOut + 0xC);
|
||||
Memory::WriteBigEData((u8 *) optval, BufferOut + 0x10, optlen);
|
||||
Memory::WriteBigEData((u8*) optval, BufferOut + 0x10, optlen);
|
||||
|
||||
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) "
|
||||
"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",
|
||||
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
|
||||
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);
|
||||
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)
|
||||
{
|
||||
@ -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)
|
||||
{
|
||||
for (DWORD i = 0; i < ipTable->dwNumEntries; i++)
|
||||
for (DWORD i = 0; i < ipTable->dwNumEntries; ++i)
|
||||
{
|
||||
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:
|
||||
{
|
||||
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 "
|
||||
"%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;
|
||||
break;
|
||||
}
|
||||
@ -965,14 +973,14 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
|
||||
if (nfds == 0)
|
||||
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)
|
||||
{
|
||||
ReturnValue = -1;
|
||||
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
|
||||
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);
|
||||
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
|
||||
@ -1027,7 +1035,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
|
||||
|
||||
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 "
|
||||
"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 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);
|
||||
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);
|
||||
wii_addr += sizeof(u32);
|
||||
// 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);
|
||||
wii_addr += sizeof(u32);
|
||||
@ -1104,6 +1112,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
|
||||
case IOCTL_SO_ICMPCANCEL:
|
||||
ERROR_LOG(WII_IPC_NET, "IOCTL_SO_ICMPCANCEL");
|
||||
goto default_;
|
||||
|
||||
default:
|
||||
INFO_LOG(WII_IPC_NET,"0x%x "
|
||||
"BufferIn: (%08x, %i), BufferOut: (%08x, %i)",
|
||||
@ -1112,9 +1121,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
|
||||
if (BufferInSize)
|
||||
{
|
||||
ERROR_LOG(WII_IPC_NET, "in addr %x size %x", BufferIn, BufferInSize);
|
||||
ERROR_LOG(WII_IPC_NET, "\n%s",
|
||||
ArrayToString(Memory::GetPointer(BufferIn), BufferInSize, 4).c_str()
|
||||
);
|
||||
ERROR_LOG(WII_IPC_NET, "\n%s", ArrayToString(Memory::GetPointer(BufferIn), BufferInSize, 4).c_str());
|
||||
}
|
||||
|
||||
if (BufferOutSize)
|
||||
@ -1198,7 +1205,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtlV(u32 CommandAddress)
|
||||
PIP_ADAPTER_ADDRESSES AdapterAddresses = nullptr;
|
||||
ULONG OutBufferLength = 0;
|
||||
ULONG RetVal = 0, i;
|
||||
for (i = 0; i < 5; i++)
|
||||
for (i = 0; i < 5; ++i)
|
||||
{
|
||||
RetVal = GetAdaptersAddresses(
|
||||
AF_INET,
|
||||
@ -1207,16 +1214,19 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtlV(u32 CommandAddress)
|
||||
AdapterAddresses,
|
||||
&OutBufferLength);
|
||||
|
||||
if (RetVal != ERROR_BUFFER_OVERFLOW) {
|
||||
if (RetVal != ERROR_BUFFER_OVERFLOW)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (AdapterAddresses != nullptr) {
|
||||
if (AdapterAddresses != nullptr)
|
||||
{
|
||||
FREE(AdapterAddresses);
|
||||
}
|
||||
|
||||
AdapterAddresses = (PIP_ADAPTER_ADDRESSES)MALLOC(OutBufferLength);
|
||||
if (AdapterAddresses == nullptr) {
|
||||
if (AdapterAddresses == nullptr)
|
||||
{
|
||||
RetVal = GetLastError();
|
||||
break;
|
||||
}
|
||||
@ -1248,7 +1258,8 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtlV(u32 CommandAddress)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (AdapterAddresses != nullptr) {
|
||||
if (AdapterAddresses != nullptr)
|
||||
{
|
||||
FREE(AdapterAddresses);
|
||||
}
|
||||
#endif
|
||||
@ -1262,23 +1273,28 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtlV(u32 CommandAddress)
|
||||
case 0x1003: // error
|
||||
Memory::Write_U32(0, _BufferOut);
|
||||
break;
|
||||
|
||||
case 0x1004: // mac address
|
||||
u8 address[MAC_ADDRESS_SIZE];
|
||||
GetMacAddress(address);
|
||||
Memory::WriteBigEData(address, _BufferOut, sizeof(address));
|
||||
break;
|
||||
|
||||
case 0x1005: // link state
|
||||
Memory::Write_U32(1, _BufferOut);
|
||||
break;
|
||||
|
||||
case 0x4002: // ip addr number
|
||||
Memory::Write_U32(1, _BufferOut);
|
||||
break;
|
||||
|
||||
case 0x4003: // ip addr table
|
||||
Memory::Write_U32(0xC, _BufferOut2);
|
||||
Memory::Write_U32(10 << 24 | 1 << 8 | 30, _BufferOut);
|
||||
Memory::Write_U32(255 << 24 | 255 << 16 | 255 << 8 | 0, _BufferOut+4);
|
||||
Memory::Write_U32(10 << 24 | 0 << 16 | 255 << 8 | 255, _BufferOut+8);
|
||||
break;
|
||||
|
||||
default:
|
||||
ERROR_LOG(WII_IPC_NET, "Unknown param2: %08X", param2);
|
||||
break;
|
||||
@ -1304,7 +1320,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtlV(u32 CommandAddress)
|
||||
case IOCTLV_SO_GETADDRINFO:
|
||||
{
|
||||
struct addrinfo hints;
|
||||
struct addrinfo *result = nullptr;
|
||||
struct addrinfo* result = nullptr;
|
||||
|
||||
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
|
||||
// port, or by socket. Doesn't seem to matter, so we just leave
|
||||
// it 0
|
||||
((u16 *)data)[0] = Common::swap16(ip_info.icmp_id);
|
||||
((u16*)data)[0] = Common::swap16(ip_info.icmp_id);
|
||||
icmp_length = 22;
|
||||
}
|
||||
|
||||
|
@ -177,8 +177,6 @@ public:
|
||||
|
||||
void ResetConfig()
|
||||
{
|
||||
int i;
|
||||
|
||||
if (File::Exists(path))
|
||||
File::Delete(path);
|
||||
|
||||
@ -198,7 +196,7 @@ public:
|
||||
SetEnableBooting(0);
|
||||
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);
|
||||
}
|
||||
@ -226,7 +224,7 @@ public:
|
||||
{
|
||||
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();
|
||||
else
|
||||
{
|
||||
@ -245,8 +243,7 @@ public:
|
||||
{
|
||||
u32* ptr = (u32*)&config;
|
||||
u32 sum = 0;
|
||||
int i;
|
||||
for (i=0; i<0xFF; i++)
|
||||
for (int i = 0; i < 0xFF; ++i)
|
||||
{
|
||||
sum += Common::swap32(*ptr++);
|
||||
}
|
||||
@ -278,35 +275,37 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 Magic(){return Common::swap32(config.magic);}
|
||||
void SetMagic(u32 magic){config.magic = Common::swap32(magic);}
|
||||
u32 Magic() {return Common::swap32(config.magic);}
|
||||
void SetMagic(u32 magic) {config.magic = Common::swap32(magic);}
|
||||
|
||||
u32 Unk(){return Common::swap32(config._unk_04);}
|
||||
void SetUnk(u32 _unk_04){config._unk_04 = Common::swap32(_unk_04);}
|
||||
u32 Unk() {return Common::swap32(config._unk_04);}
|
||||
void SetUnk(u32 _unk_04) {config._unk_04 = Common::swap32(_unk_04);}
|
||||
|
||||
u32 IdGen(){return Common::swap32(config.id_generation);}
|
||||
void SetIdGen(u32 id_generation){config.id_generation = Common::swap32(id_generation);}
|
||||
void IncrementIdGen(){
|
||||
u32 IdGen() {return Common::swap32(config.id_generation);}
|
||||
void SetIdGen(u32 id_generation) {config.id_generation = Common::swap32(id_generation);}
|
||||
|
||||
void IncrementIdGen()
|
||||
{
|
||||
u32 id_ctr = IdGen();
|
||||
id_ctr++;
|
||||
id_ctr &= 0x1F;
|
||||
SetIdGen(id_ctr);
|
||||
}
|
||||
|
||||
u32 Checksum(){return Common::swap32(config.checksum);}
|
||||
void SetChecksum(u32 checksum){config.checksum = Common::swap32(checksum);}
|
||||
u32 Checksum() {return Common::swap32(config.checksum);}
|
||||
void SetChecksum(u32 checksum) {config.checksum = Common::swap32(checksum);}
|
||||
|
||||
u32 CreationStage(){return Common::swap32(config.creation_stage);}
|
||||
void SetCreationStage(u32 creation_stage){config.creation_stage = Common::swap32(creation_stage);}
|
||||
u32 CreationStage() {return Common::swap32(config.creation_stage);}
|
||||
void SetCreationStage(u32 creation_stage) {config.creation_stage = Common::swap32(creation_stage);}
|
||||
|
||||
u32 EnableBooting(){return Common::swap32(config.enable_booting);}
|
||||
void SetEnableBooting(u32 enable_booting){config.enable_booting = Common::swap32(enable_booting);}
|
||||
u32 EnableBooting() {return Common::swap32(config.enable_booting);}
|
||||
void SetEnableBooting(u32 enable_booting) {config.enable_booting = Common::swap32(enable_booting);}
|
||||
|
||||
u64 Id(){return Common::swap64(config.nwc24_id);}
|
||||
void SetId(u64 nwc24_id){config.nwc24_id = Common::swap64(nwc24_id);}
|
||||
u64 Id() {return Common::swap64(config.nwc24_id);}
|
||||
void SetId(u64 nwc24_id) {config.nwc24_id = Common::swap64(nwc24_id);}
|
||||
|
||||
const char * Email(){return config.email;}
|
||||
void SetEmail(const char * email)
|
||||
const char* Email() {return config.email;}
|
||||
void SetEmail(const char* email)
|
||||
{
|
||||
strncpy(config.email, email, nwc24_config_t::MAX_EMAIL_LENGTH);
|
||||
config.email[nwc24_config_t::MAX_EMAIL_LENGTH-1] = '\0';
|
||||
@ -323,7 +322,6 @@ public:
|
||||
WiiNetConfig()
|
||||
{
|
||||
path = File::GetUserPath(D_WIISYSCONF_IDX) + "net/02/config.dat";
|
||||
|
||||
ReadConfig();
|
||||
}
|
||||
|
||||
@ -348,8 +346,7 @@ public:
|
||||
{
|
||||
if (!File::Exists(path))
|
||||
{
|
||||
if (!File::CreateFullPath(
|
||||
std::string(File::GetUserPath(D_WIISYSCONF_IDX) + "net/02/")))
|
||||
if (!File::CreateFullPath(std::string(File::GetUserPath(D_WIISYSCONF_IDX) + "net/02/")))
|
||||
{
|
||||
ERROR_LOG(WII_IPC_NET, "Failed to create directory for network config file");
|
||||
}
|
||||
@ -360,19 +357,19 @@ public:
|
||||
|
||||
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)
|
||||
{
|
||||
Memory::ReadBigEData((u8 *)&config, address, sizeof(config));
|
||||
Memory::ReadBigEData((u8*)&config, address, sizeof(config));
|
||||
}
|
||||
|
||||
void ReadConfig()
|
||||
{
|
||||
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();
|
||||
}
|
||||
else
|
||||
@ -507,8 +504,7 @@ public:
|
||||
break;
|
||||
|
||||
default:
|
||||
ERROR_LOG(WII_IPC_NET, "%s - unknown IOCtl: %x\n",
|
||||
GetDeviceName().c_str(), Parameter);
|
||||
ERROR_LOG(WII_IPC_NET, "%s - unknown IOCtl: %x\n", GetDeviceName().c_str(), Parameter);
|
||||
break;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user