IOS HLE: Deduplicate request code in net/net_ssl
This commit is contained in:
parent
84c8d0b66d
commit
a04902086a
File diff suppressed because it is too large
Load Diff
|
@ -30,7 +30,7 @@ public:
|
||||||
|
|
||||||
virtual ~CWII_IPC_HLE_Device_net_kd_request();
|
virtual ~CWII_IPC_HLE_Device_net_kd_request();
|
||||||
|
|
||||||
IPCCommandResult IOCtl(u32 _CommandAddress) override;
|
IPCCommandResult IOCtl(const IOSIOCtlRequest& request) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum
|
enum
|
||||||
|
@ -86,35 +86,31 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~CWII_IPC_HLE_Device_net_kd_time() {}
|
virtual ~CWII_IPC_HLE_Device_net_kd_time() {}
|
||||||
IPCCommandResult IOCtl(u32 _CommandAddress) override
|
IPCCommandResult IOCtl(const IOSIOCtlRequest& request) override
|
||||||
{
|
{
|
||||||
u32 Parameter = Memory::Read_U32(_CommandAddress + 0x0C);
|
s32 result = 0;
|
||||||
u32 BufferIn = Memory::Read_U32(_CommandAddress + 0x10);
|
|
||||||
u32 BufferOut = Memory::Read_U32(_CommandAddress + 0x18);
|
|
||||||
|
|
||||||
u32 result = 0;
|
|
||||||
u32 common_result = 0;
|
u32 common_result = 0;
|
||||||
// TODO Writes stuff to /shared2/nwc24/misc.bin
|
// TODO Writes stuff to /shared2/nwc24/misc.bin
|
||||||
// u32 update_misc = 0;
|
// u32 update_misc = 0;
|
||||||
|
|
||||||
switch (Parameter)
|
switch (request.request)
|
||||||
{
|
{
|
||||||
case IOCTL_NW24_GET_UNIVERSAL_TIME:
|
case IOCTL_NW24_GET_UNIVERSAL_TIME:
|
||||||
Memory::Write_U64(GetAdjustedUTC(), BufferOut + 4);
|
Memory::Write_U64(GetAdjustedUTC(), request.buffer_out + 4);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTL_NW24_SET_UNIVERSAL_TIME:
|
case IOCTL_NW24_SET_UNIVERSAL_TIME:
|
||||||
SetAdjustedUTC(Memory::Read_U64(BufferIn));
|
SetAdjustedUTC(Memory::Read_U64(request.buffer_in));
|
||||||
// update_misc = Memory::Read_U32(BufferIn + 8);
|
// update_misc = Memory::Read_U32(request.buffer_in + 8);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTL_NW24_SET_RTC_COUNTER:
|
case IOCTL_NW24_SET_RTC_COUNTER:
|
||||||
rtc = Memory::Read_U32(BufferIn);
|
rtc = Memory::Read_U32(request.buffer_in);
|
||||||
// update_misc = Memory::Read_U32(BufferIn + 4);
|
// update_misc = Memory::Read_U32(request.buffer_in + 4);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTL_NW24_GET_TIME_DIFF:
|
case IOCTL_NW24_GET_TIME_DIFF:
|
||||||
Memory::Write_U64(GetAdjustedUTC() - rtc, BufferOut + 4);
|
Memory::Write_U64(GetAdjustedUTC() - rtc, request.buffer_out + 4);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTL_NW24_UNIMPLEMENTED:
|
case IOCTL_NW24_UNIMPLEMENTED:
|
||||||
|
@ -122,13 +118,13 @@ public:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ERROR_LOG(WII_IPC_NET, "%s - unknown IOCtl: %x", GetDeviceName().c_str(), Parameter);
|
ERROR_LOG(WII_IPC_NET, "%s - unknown IOCtl: %x", GetDeviceName().c_str(), request.request);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// write return values
|
// write return values
|
||||||
Memory::Write_U32(common_result, BufferOut);
|
Memory::Write_U32(common_result, request.buffer_out);
|
||||||
Memory::Write_U32(result, _CommandAddress + 4);
|
request.SetReturnValue(result);
|
||||||
return GetDefaultReply();
|
return GetDefaultReply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,8 +203,8 @@ public:
|
||||||
|
|
||||||
virtual ~CWII_IPC_HLE_Device_net_ip_top();
|
virtual ~CWII_IPC_HLE_Device_net_ip_top();
|
||||||
|
|
||||||
IPCCommandResult IOCtl(u32 _CommandAddress) override;
|
IPCCommandResult IOCtl(const IOSIOCtlRequest& request) override;
|
||||||
IPCCommandResult IOCtlV(u32 _CommandAddress) override;
|
IPCCommandResult IOCtlV(const IOSIOCtlVRequest& request) override;
|
||||||
|
|
||||||
void Update() override;
|
void Update() override;
|
||||||
|
|
||||||
|
@ -227,7 +223,7 @@ public:
|
||||||
|
|
||||||
virtual ~CWII_IPC_HLE_Device_net_ncd_manage();
|
virtual ~CWII_IPC_HLE_Device_net_ncd_manage();
|
||||||
|
|
||||||
IPCCommandResult IOCtlV(u32 _CommandAddress) override;
|
IPCCommandResult IOCtlV(const IOSIOCtlVRequest& request) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum
|
enum
|
||||||
|
@ -253,7 +249,7 @@ public:
|
||||||
|
|
||||||
virtual ~CWII_IPC_HLE_Device_net_wd_command();
|
virtual ~CWII_IPC_HLE_Device_net_wd_command();
|
||||||
|
|
||||||
IPCCommandResult IOCtlV(u32 CommandAddress) override;
|
IPCCommandResult IOCtlV(const IOSIOCtlVRequest& request) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum
|
enum
|
||||||
|
|
|
@ -75,72 +75,62 @@ int CWII_IPC_HLE_Device_net_ssl::GetSSLFreeID() const
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtl(u32 _CommandAddress)
|
IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtl(const IOSIOCtlRequest& request)
|
||||||
{
|
{
|
||||||
u32 BufferIn = Memory::Read_U32(_CommandAddress + 0x10);
|
request.Log(GetDeviceName(), LogTypes::WII_IPC_SSL, LogTypes::LINFO);
|
||||||
u32 BufferInSize = Memory::Read_U32(_CommandAddress + 0x14);
|
request.SetReturnValue(IPC_SUCCESS);
|
||||||
u32 BufferOut = Memory::Read_U32(_CommandAddress + 0x18);
|
|
||||||
u32 BufferOutSize = Memory::Read_U32(_CommandAddress + 0x1C);
|
|
||||||
u32 Command = Memory::Read_U32(_CommandAddress + 0x0C);
|
|
||||||
|
|
||||||
INFO_LOG(WII_IPC_SSL, "%s unknown %i "
|
|
||||||
"(BufferIn: (%08x, %i), BufferOut: (%08x, %i)",
|
|
||||||
GetDeviceName().c_str(), Command, BufferIn, BufferInSize, BufferOut, BufferOutSize);
|
|
||||||
Memory::Write_U32(0, _CommandAddress + 0x4);
|
|
||||||
return GetDefaultReply();
|
return GetDefaultReply();
|
||||||
}
|
}
|
||||||
|
|
||||||
IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtlV(u32 _CommandAddress)
|
IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtlV(const IOSIOCtlVRequest& request)
|
||||||
{
|
{
|
||||||
SIOCtlVBuffer CommandBuffer(_CommandAddress);
|
u32 BufferIn = 0, BufferIn2 = 0, BufferIn3 = 0;
|
||||||
|
|
||||||
u32 _BufferIn = 0, _BufferIn2 = 0, _BufferIn3 = 0;
|
|
||||||
u32 BufferInSize = 0, BufferInSize2 = 0, BufferInSize3 = 0;
|
u32 BufferInSize = 0, BufferInSize2 = 0, BufferInSize3 = 0;
|
||||||
|
|
||||||
u32 BufferOut = 0, BufferOut2 = 0, BufferOut3 = 0;
|
u32 BufferOut = 0, BufferOut2 = 0, BufferOut3 = 0;
|
||||||
u32 BufferOutSize = 0, BufferOutSize2 = 0, BufferOutSize3 = 0;
|
u32 BufferOutSize = 0, BufferOutSize2 = 0, BufferOutSize3 = 0;
|
||||||
|
|
||||||
if (CommandBuffer.InBuffer.size() > 0)
|
if (request.in_vectors.size() > 0)
|
||||||
{
|
{
|
||||||
_BufferIn = CommandBuffer.InBuffer.at(0).m_Address;
|
BufferIn = request.in_vectors.at(0).address;
|
||||||
BufferInSize = CommandBuffer.InBuffer.at(0).m_Size;
|
BufferInSize = request.in_vectors.at(0).size;
|
||||||
}
|
}
|
||||||
if (CommandBuffer.InBuffer.size() > 1)
|
if (request.in_vectors.size() > 1)
|
||||||
{
|
{
|
||||||
_BufferIn2 = CommandBuffer.InBuffer.at(1).m_Address;
|
BufferIn2 = request.in_vectors.at(1).address;
|
||||||
BufferInSize2 = CommandBuffer.InBuffer.at(1).m_Size;
|
BufferInSize2 = request.in_vectors.at(1).size;
|
||||||
}
|
}
|
||||||
if (CommandBuffer.InBuffer.size() > 2)
|
if (request.in_vectors.size() > 2)
|
||||||
{
|
{
|
||||||
_BufferIn3 = CommandBuffer.InBuffer.at(2).m_Address;
|
BufferIn3 = request.in_vectors.at(2).address;
|
||||||
BufferInSize3 = CommandBuffer.InBuffer.at(2).m_Size;
|
BufferInSize3 = request.in_vectors.at(2).size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CommandBuffer.PayloadBuffer.size() > 0)
|
if (request.io_vectors.size() > 0)
|
||||||
{
|
{
|
||||||
BufferOut = CommandBuffer.PayloadBuffer.at(0).m_Address;
|
BufferOut = request.io_vectors.at(0).address;
|
||||||
BufferOutSize = CommandBuffer.PayloadBuffer.at(0).m_Size;
|
BufferOutSize = request.io_vectors.at(0).size;
|
||||||
}
|
}
|
||||||
if (CommandBuffer.PayloadBuffer.size() > 1)
|
if (request.io_vectors.size() > 1)
|
||||||
{
|
{
|
||||||
BufferOut2 = CommandBuffer.PayloadBuffer.at(1).m_Address;
|
BufferOut2 = request.io_vectors.at(1).address;
|
||||||
BufferOutSize2 = CommandBuffer.PayloadBuffer.at(1).m_Size;
|
BufferOutSize2 = request.io_vectors.at(1).size;
|
||||||
}
|
}
|
||||||
if (CommandBuffer.PayloadBuffer.size() > 2)
|
if (request.io_vectors.size() > 2)
|
||||||
{
|
{
|
||||||
BufferOut3 = CommandBuffer.PayloadBuffer.at(2).m_Address;
|
BufferOut3 = request.io_vectors.at(2).address;
|
||||||
BufferOutSize3 = CommandBuffer.PayloadBuffer.at(2).m_Size;
|
BufferOutSize3 = request.io_vectors.at(2).size;
|
||||||
}
|
}
|
||||||
|
|
||||||
// I don't trust SSL to be deterministic, and this is never going to sync
|
// I don't trust SSL to be deterministic, and this is never going to sync
|
||||||
// as such (as opposed to forwarding IPC results or whatever), so -
|
// as such (as opposed to forwarding IPC results or whatever), so -
|
||||||
if (Core::g_want_determinism)
|
if (Core::g_want_determinism)
|
||||||
{
|
{
|
||||||
Memory::Write_U32(-1, _CommandAddress + 0x4);
|
request.SetReturnValue(-1);
|
||||||
return GetDefaultReply();
|
return GetDefaultReply();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (CommandBuffer.Parameter)
|
switch (request.request)
|
||||||
{
|
{
|
||||||
case IOCTLV_NET_SSL_NEW:
|
case IOCTLV_NET_SSL_NEW:
|
||||||
{
|
{
|
||||||
|
@ -187,20 +177,20 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtlV(u32 _CommandAddress)
|
||||||
mbedtls_ssl_set_hostname(&ssl->ctx, ssl->hostname.c_str());
|
mbedtls_ssl_set_hostname(&ssl->ctx, ssl->hostname.c_str());
|
||||||
|
|
||||||
ssl->active = true;
|
ssl->active = true;
|
||||||
Memory::Write_U32(freeSSL, _BufferIn);
|
Memory::Write_U32(freeSSL, BufferIn);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_SSL_NEW_ERROR:
|
_SSL_NEW_ERROR:
|
||||||
Memory::Write_U32(SSL_ERR_FAILED, _BufferIn);
|
Memory::Write_U32(SSL_ERR_FAILED, BufferIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_NEW (%d, %s) "
|
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_NEW (%d, %s) "
|
||||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
||||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
||||||
verifyOption, hostname.c_str(), _BufferIn, BufferInSize, _BufferIn2, BufferInSize2,
|
verifyOption, hostname.c_str(), BufferIn, BufferInSize, BufferIn2, BufferInSize2,
|
||||||
_BufferIn3, BufferInSize3, BufferOut, BufferOutSize, BufferOut2, BufferOutSize2,
|
BufferIn3, BufferInSize3, BufferOut, BufferOutSize, BufferOut2, BufferOutSize2,
|
||||||
BufferOut3, BufferOutSize3);
|
BufferOut3, BufferOutSize3);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -226,18 +216,18 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtlV(u32 _CommandAddress)
|
||||||
|
|
||||||
ssl->active = false;
|
ssl->active = false;
|
||||||
|
|
||||||
Memory::Write_U32(SSL_OK, _BufferIn);
|
Memory::Write_U32(SSL_OK, BufferIn);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Memory::Write_U32(SSL_ERR_ID, _BufferIn);
|
Memory::Write_U32(SSL_ERR_ID, BufferIn);
|
||||||
}
|
}
|
||||||
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SHUTDOWN "
|
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SHUTDOWN "
|
||||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
||||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
||||||
_BufferIn, BufferInSize, _BufferIn2, BufferInSize2, _BufferIn3, BufferInSize3,
|
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
|
||||||
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IOCTLV_NET_SSL_SETROOTCA:
|
case IOCTLV_NET_SSL_SETROOTCA:
|
||||||
|
@ -246,8 +236,8 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtlV(u32 _CommandAddress)
|
||||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
||||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
||||||
_BufferIn, BufferInSize, _BufferIn2, BufferInSize2, _BufferIn3, BufferInSize3,
|
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
|
||||||
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||||
|
|
||||||
int sslID = Memory::Read_U32(BufferOut) - 1;
|
int sslID = Memory::Read_U32(BufferOut) - 1;
|
||||||
if (SSLID_VALID(sslID))
|
if (SSLID_VALID(sslID))
|
||||||
|
@ -264,19 +254,19 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtlV(u32 _CommandAddress)
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
Memory::Write_U32(SSL_ERR_FAILED, _BufferIn);
|
Memory::Write_U32(SSL_ERR_FAILED, BufferIn);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mbedtls_ssl_conf_ca_chain(&ssl->config, &ssl->cacert, nullptr);
|
mbedtls_ssl_conf_ca_chain(&ssl->config, &ssl->cacert, nullptr);
|
||||||
Memory::Write_U32(SSL_OK, _BufferIn);
|
Memory::Write_U32(SSL_OK, BufferIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETROOTCA = %d", ret);
|
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETROOTCA = %d", ret);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Memory::Write_U32(SSL_ERR_ID, _BufferIn);
|
Memory::Write_U32(SSL_ERR_ID, BufferIn);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -286,8 +276,8 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtlV(u32 _CommandAddress)
|
||||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
||||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
||||||
_BufferIn, BufferInSize, _BufferIn2, BufferInSize2, _BufferIn3, BufferInSize3,
|
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
|
||||||
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||||
|
|
||||||
int sslID = Memory::Read_U32(BufferOut) - 1;
|
int sslID = Memory::Read_U32(BufferOut) - 1;
|
||||||
if (SSLID_VALID(sslID))
|
if (SSLID_VALID(sslID))
|
||||||
|
@ -302,19 +292,19 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtlV(u32 _CommandAddress)
|
||||||
{
|
{
|
||||||
mbedtls_x509_crt_free(&ssl->clicert);
|
mbedtls_x509_crt_free(&ssl->clicert);
|
||||||
mbedtls_pk_free(&ssl->pk);
|
mbedtls_pk_free(&ssl->pk);
|
||||||
Memory::Write_U32(SSL_ERR_FAILED, _BufferIn);
|
Memory::Write_U32(SSL_ERR_FAILED, BufferIn);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mbedtls_ssl_conf_own_cert(&ssl->config, &ssl->clicert, &ssl->pk);
|
mbedtls_ssl_conf_own_cert(&ssl->config, &ssl->clicert, &ssl->pk);
|
||||||
Memory::Write_U32(SSL_OK, _BufferIn);
|
Memory::Write_U32(SSL_OK, BufferIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT = (%d, %d)", ret, pk_ret);
|
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT = (%d, %d)", ret, pk_ret);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Memory::Write_U32(SSL_ERR_ID, _BufferIn);
|
Memory::Write_U32(SSL_ERR_ID, BufferIn);
|
||||||
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT invalid sslID = %d", sslID);
|
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT invalid sslID = %d", sslID);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -325,8 +315,8 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtlV(u32 _CommandAddress)
|
||||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
||||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
||||||
_BufferIn, BufferInSize, _BufferIn2, BufferInSize2, _BufferIn3, BufferInSize3,
|
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
|
||||||
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||||
|
|
||||||
int sslID = Memory::Read_U32(BufferOut) - 1;
|
int sslID = Memory::Read_U32(BufferOut) - 1;
|
||||||
if (SSLID_VALID(sslID))
|
if (SSLID_VALID(sslID))
|
||||||
|
@ -336,11 +326,11 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtlV(u32 _CommandAddress)
|
||||||
mbedtls_pk_free(&ssl->pk);
|
mbedtls_pk_free(&ssl->pk);
|
||||||
|
|
||||||
mbedtls_ssl_conf_own_cert(&ssl->config, nullptr, nullptr);
|
mbedtls_ssl_conf_own_cert(&ssl->config, nullptr, nullptr);
|
||||||
Memory::Write_U32(SSL_OK, _BufferIn);
|
Memory::Write_U32(SSL_OK, BufferIn);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Memory::Write_U32(SSL_ERR_ID, _BufferIn);
|
Memory::Write_U32(SSL_ERR_ID, BufferIn);
|
||||||
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT invalid sslID = %d", sslID);
|
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT invalid sslID = %d", sslID);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -357,25 +347,25 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtlV(u32 _CommandAddress)
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
mbedtls_x509_crt_free(&ssl->clicert);
|
mbedtls_x509_crt_free(&ssl->clicert);
|
||||||
Memory::Write_U32(SSL_ERR_FAILED, _BufferIn);
|
Memory::Write_U32(SSL_ERR_FAILED, BufferIn);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mbedtls_ssl_conf_ca_chain(&ssl->config, &ssl->cacert, nullptr);
|
mbedtls_ssl_conf_ca_chain(&ssl->config, &ssl->cacert, nullptr);
|
||||||
Memory::Write_U32(SSL_OK, _BufferIn);
|
Memory::Write_U32(SSL_OK, BufferIn);
|
||||||
}
|
}
|
||||||
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETBUILTINROOTCA = %d", ret);
|
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETBUILTINROOTCA = %d", ret);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Memory::Write_U32(SSL_ERR_ID, _BufferIn);
|
Memory::Write_U32(SSL_ERR_ID, BufferIn);
|
||||||
}
|
}
|
||||||
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETBUILTINROOTCA "
|
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETBUILTINROOTCA "
|
||||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
||||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
||||||
_BufferIn, BufferInSize, _BufferIn2, BufferInSize2, _BufferIn3, BufferInSize3,
|
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
|
||||||
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IOCTLV_NET_SSL_CONNECT:
|
case IOCTLV_NET_SSL_CONNECT:
|
||||||
|
@ -388,18 +378,18 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtlV(u32 _CommandAddress)
|
||||||
ssl->sockfd = Memory::Read_U32(BufferOut2);
|
ssl->sockfd = Memory::Read_U32(BufferOut2);
|
||||||
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_CONNECT socket = %d", ssl->sockfd);
|
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_CONNECT socket = %d", ssl->sockfd);
|
||||||
mbedtls_ssl_set_bio(&ssl->ctx, &ssl->sockfd, mbedtls_net_send, mbedtls_net_recv, nullptr);
|
mbedtls_ssl_set_bio(&ssl->ctx, &ssl->sockfd, mbedtls_net_send, mbedtls_net_recv, nullptr);
|
||||||
Memory::Write_U32(SSL_OK, _BufferIn);
|
Memory::Write_U32(SSL_OK, BufferIn);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Memory::Write_U32(SSL_ERR_ID, _BufferIn);
|
Memory::Write_U32(SSL_ERR_ID, BufferIn);
|
||||||
}
|
}
|
||||||
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_CONNECT "
|
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_CONNECT "
|
||||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
||||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
||||||
_BufferIn, BufferInSize, _BufferIn2, BufferInSize2, _BufferIn3, BufferInSize3,
|
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
|
||||||
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IOCTLV_NET_SSL_DOHANDSHAKE:
|
case IOCTLV_NET_SSL_DOHANDSHAKE:
|
||||||
|
@ -408,12 +398,12 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtlV(u32 _CommandAddress)
|
||||||
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, request, IOCTLV_NET_SSL_DOHANDSHAKE);
|
||||||
return GetNoReply();
|
return GetNoReply();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Memory::Write_U32(SSL_ERR_ID, _BufferIn);
|
Memory::Write_U32(SSL_ERR_ID, BufferIn);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -423,19 +413,19 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtlV(u32 _CommandAddress)
|
||||||
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, request, IOCTLV_NET_SSL_WRITE);
|
||||||
return GetNoReply();
|
return GetNoReply();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Memory::Write_U32(SSL_ERR_ID, _BufferIn);
|
Memory::Write_U32(SSL_ERR_ID, BufferIn);
|
||||||
}
|
}
|
||||||
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_WRITE "
|
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_WRITE "
|
||||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
||||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
||||||
_BufferIn, BufferInSize, _BufferIn2, BufferInSize2, _BufferIn3, BufferInSize3,
|
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
|
||||||
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||||
INFO_LOG(WII_IPC_SSL, "%s", Memory::GetString(BufferOut2).c_str());
|
INFO_LOG(WII_IPC_SSL, "%s", Memory::GetString(BufferOut2).c_str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -446,19 +436,19 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtlV(u32 _CommandAddress)
|
||||||
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, request, IOCTLV_NET_SSL_READ);
|
||||||
return GetNoReply();
|
return GetNoReply();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Memory::Write_U32(SSL_ERR_ID, _BufferIn);
|
Memory::Write_U32(SSL_ERR_ID, BufferIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_READ(%d)"
|
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_READ(%d)"
|
||||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
||||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
||||||
ret, _BufferIn, BufferInSize, _BufferIn2, BufferInSize2, _BufferIn3, BufferInSize3,
|
ret, BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3,
|
||||||
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -467,18 +457,18 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtlV(u32 _CommandAddress)
|
||||||
int sslID = Memory::Read_U32(BufferOut) - 1;
|
int sslID = Memory::Read_U32(BufferOut) - 1;
|
||||||
if (SSLID_VALID(sslID))
|
if (SSLID_VALID(sslID))
|
||||||
{
|
{
|
||||||
Memory::Write_U32(SSL_OK, _BufferIn);
|
Memory::Write_U32(SSL_OK, BufferIn);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Memory::Write_U32(SSL_ERR_ID, _BufferIn);
|
Memory::Write_U32(SSL_ERR_ID, BufferIn);
|
||||||
}
|
}
|
||||||
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETROOTCADEFAULT "
|
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETROOTCADEFAULT "
|
||||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
||||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
||||||
_BufferIn, BufferInSize, _BufferIn2, BufferInSize2, _BufferIn3, BufferInSize3,
|
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
|
||||||
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IOCTLV_NET_SSL_SETCLIENTCERTDEFAULT:
|
case IOCTLV_NET_SSL_SETCLIENTCERTDEFAULT:
|
||||||
|
@ -487,33 +477,25 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtlV(u32 _CommandAddress)
|
||||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
||||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
||||||
_BufferIn, BufferInSize, _BufferIn2, BufferInSize2, _BufferIn3, BufferInSize3,
|
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
|
||||||
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||||
|
|
||||||
int sslID = Memory::Read_U32(BufferOut) - 1;
|
int sslID = Memory::Read_U32(BufferOut) - 1;
|
||||||
if (SSLID_VALID(sslID))
|
if (SSLID_VALID(sslID))
|
||||||
{
|
{
|
||||||
Memory::Write_U32(SSL_OK, _BufferIn);
|
Memory::Write_U32(SSL_OK, BufferIn);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Memory::Write_U32(SSL_ERR_ID, _BufferIn);
|
Memory::Write_U32(SSL_ERR_ID, BufferIn);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
ERROR_LOG(WII_IPC_SSL, "%i "
|
request.DumpUnknown(GetDeviceName(), LogTypes::WII_IPC_SSL);
|
||||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
|
||||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
|
||||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
|
||||||
CommandBuffer.Parameter, _BufferIn, BufferInSize, _BufferIn2, BufferInSize2,
|
|
||||||
_BufferIn3, BufferInSize3, BufferOut, BufferOutSize, BufferOut2, BufferOutSize2,
|
|
||||||
BufferOut3, BufferOutSize3);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SSL return codes are written to BufferIn
|
// SSL return codes are written to BufferIn
|
||||||
Memory::Write_U32(0, _CommandAddress + 4);
|
request.SetReturnValue(IPC_SUCCESS);
|
||||||
|
|
||||||
return GetDefaultReply();
|
return GetDefaultReply();
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,8 +87,8 @@ public:
|
||||||
|
|
||||||
virtual ~CWII_IPC_HLE_Device_net_ssl();
|
virtual ~CWII_IPC_HLE_Device_net_ssl();
|
||||||
|
|
||||||
IPCCommandResult IOCtl(u32 _CommandAddress) override;
|
IPCCommandResult IOCtl(const IOSIOCtlRequest& request) override;
|
||||||
IPCCommandResult IOCtlV(u32 _CommandAddress) override;
|
IPCCommandResult IOCtlV(const IOSIOCtlVRequest& request) override;
|
||||||
|
|
||||||
int GetSSLFreeID() const;
|
int GetSSLFreeID() const;
|
||||||
|
|
||||||
|
|
|
@ -187,28 +187,23 @@ void WiiSocket::Update(bool read, bool write, bool except)
|
||||||
{
|
{
|
||||||
s32 ReturnValue = 0;
|
s32 ReturnValue = 0;
|
||||||
bool forceNonBlock = false;
|
bool forceNonBlock = false;
|
||||||
IPCCommandType ct = static_cast<IPCCommandType>(Memory::Read_U32(it->_CommandAddress));
|
IPCCommandType ct = it->request.command;
|
||||||
if (!it->is_ssl && ct == IPC_CMD_IOCTL)
|
if (!it->is_ssl && ct == IPC_CMD_IOCTL)
|
||||||
{
|
{
|
||||||
u32 BufferIn = Memory::Read_U32(it->_CommandAddress + 0x10);
|
IOSIOCtlRequest ioctl{it->request.address};
|
||||||
u32 BufferInSize = Memory::Read_U32(it->_CommandAddress + 0x14);
|
|
||||||
u32 BufferOut = Memory::Read_U32(it->_CommandAddress + 0x18);
|
|
||||||
u32 BufferOutSize = Memory::Read_U32(it->_CommandAddress + 0x1C);
|
|
||||||
|
|
||||||
switch (it->net_type)
|
switch (it->net_type)
|
||||||
{
|
{
|
||||||
case IOCTL_SO_FCNTL:
|
case IOCTL_SO_FCNTL:
|
||||||
{
|
{
|
||||||
u32 cmd = Memory::Read_U32(BufferIn + 4);
|
u32 cmd = Memory::Read_U32(ioctl.buffer_in + 4);
|
||||||
u32 arg = Memory::Read_U32(BufferIn + 8);
|
u32 arg = Memory::Read_U32(ioctl.buffer_in + 8);
|
||||||
ReturnValue = FCntl(cmd, arg);
|
ReturnValue = FCntl(cmd, arg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IOCTL_SO_BIND:
|
case IOCTL_SO_BIND:
|
||||||
{
|
{
|
||||||
// u32 has_addr = Memory::Read_U32(BufferIn + 0x04);
|
|
||||||
sockaddr_in local_name;
|
sockaddr_in local_name;
|
||||||
WiiSockAddrIn* wii_name = (WiiSockAddrIn*)Memory::GetPointer(BufferIn + 0x08);
|
WiiSockAddrIn* wii_name = (WiiSockAddrIn*)Memory::GetPointer(ioctl.buffer_in + 8);
|
||||||
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));
|
||||||
|
@ -220,9 +215,8 @@ void WiiSocket::Update(bool read, bool write, bool except)
|
||||||
}
|
}
|
||||||
case IOCTL_SO_CONNECT:
|
case IOCTL_SO_CONNECT:
|
||||||
{
|
{
|
||||||
// u32 has_addr = Memory::Read_U32(BufferIn + 0x04);
|
|
||||||
sockaddr_in local_name;
|
sockaddr_in local_name;
|
||||||
WiiSockAddrIn* wii_name = (WiiSockAddrIn*)Memory::GetPointer(BufferIn + 0x08);
|
WiiSockAddrIn* wii_name = (WiiSockAddrIn*)Memory::GetPointer(ioctl.buffer_in + 8);
|
||||||
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));
|
||||||
|
@ -234,10 +228,10 @@ void WiiSocket::Update(bool read, bool write, bool except)
|
||||||
}
|
}
|
||||||
case IOCTL_SO_ACCEPT:
|
case IOCTL_SO_ACCEPT:
|
||||||
{
|
{
|
||||||
if (BufferOutSize > 0)
|
if (ioctl.buffer_out_size > 0)
|
||||||
{
|
{
|
||||||
sockaddr_in local_name;
|
sockaddr_in local_name;
|
||||||
WiiSockAddrIn* wii_name = (WiiSockAddrIn*)Memory::GetPointer(BufferOut);
|
WiiSockAddrIn* wii_name = (WiiSockAddrIn*)Memory::GetPointer(ioctl.buffer_out);
|
||||||
WiiSockMan::Convert(*wii_name, local_name);
|
WiiSockMan::Convert(*wii_name, local_name);
|
||||||
|
|
||||||
socklen_t addrlen = sizeof(sockaddr_in);
|
socklen_t addrlen = sizeof(sockaddr_in);
|
||||||
|
@ -254,10 +248,7 @@ void WiiSocket::Update(bool read, bool write, bool except)
|
||||||
|
|
||||||
WiiSockMan::GetInstance().AddSocket(ReturnValue);
|
WiiSockMan::GetInstance().AddSocket(ReturnValue);
|
||||||
|
|
||||||
INFO_LOG(WII_IPC_NET, "IOCTL_SO_ACCEPT "
|
ioctl.Log("IOCTL_SO_ACCEPT", LogTypes::WII_IPC_NET);
|
||||||
"BufferIn: (%08x, %i), BufferOut: (%08x, %i)",
|
|
||||||
BufferIn, BufferInSize, BufferOut, BufferOutSize);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -275,34 +266,34 @@ void WiiSocket::Update(bool read, bool write, bool except)
|
||||||
}
|
}
|
||||||
else if (ct == IPC_CMD_IOCTLV)
|
else if (ct == IPC_CMD_IOCTLV)
|
||||||
{
|
{
|
||||||
SIOCtlVBuffer CommandBuffer(it->_CommandAddress);
|
IOSIOCtlVRequest ioctlv{it->request.address};
|
||||||
u32 BufferIn = 0, BufferIn2 = 0;
|
u32 BufferIn = 0, BufferIn2 = 0;
|
||||||
u32 BufferInSize = 0, BufferInSize2 = 0;
|
u32 BufferInSize = 0, BufferInSize2 = 0;
|
||||||
u32 BufferOut = 0, BufferOut2 = 0;
|
u32 BufferOut = 0, BufferOut2 = 0;
|
||||||
u32 BufferOutSize = 0, BufferOutSize2 = 0;
|
u32 BufferOutSize = 0, BufferOutSize2 = 0;
|
||||||
|
|
||||||
if (CommandBuffer.InBuffer.size() > 0)
|
if (ioctlv.in_vectors.size() > 0)
|
||||||
{
|
{
|
||||||
BufferIn = CommandBuffer.InBuffer.at(0).m_Address;
|
BufferIn = ioctlv.in_vectors.at(0).address;
|
||||||
BufferInSize = CommandBuffer.InBuffer.at(0).m_Size;
|
BufferInSize = ioctlv.in_vectors.at(0).size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CommandBuffer.PayloadBuffer.size() > 0)
|
if (ioctlv.io_vectors.size() > 0)
|
||||||
{
|
{
|
||||||
BufferOut = CommandBuffer.PayloadBuffer.at(0).m_Address;
|
BufferOut = ioctlv.io_vectors.at(0).address;
|
||||||
BufferOutSize = CommandBuffer.PayloadBuffer.at(0).m_Size;
|
BufferOutSize = ioctlv.io_vectors.at(0).size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CommandBuffer.PayloadBuffer.size() > 1)
|
if (ioctlv.io_vectors.size() > 1)
|
||||||
{
|
{
|
||||||
BufferOut2 = CommandBuffer.PayloadBuffer.at(1).m_Address;
|
BufferOut2 = ioctlv.io_vectors.at(1).address;
|
||||||
BufferOutSize2 = CommandBuffer.PayloadBuffer.at(1).m_Size;
|
BufferOutSize2 = ioctlv.io_vectors.at(1).size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CommandBuffer.InBuffer.size() > 1)
|
if (ioctlv.in_vectors.size() > 1)
|
||||||
{
|
{
|
||||||
BufferIn2 = CommandBuffer.InBuffer.at(1).m_Address;
|
BufferIn2 = ioctlv.in_vectors.at(1).address;
|
||||||
BufferInSize2 = CommandBuffer.InBuffer.at(1).m_Size;
|
BufferInSize2 = ioctlv.in_vectors.at(1).size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (it->is_ssl)
|
if (it->is_ssl)
|
||||||
|
@ -576,8 +567,8 @@ void WiiSocket::Update(bool read, bool write, bool except)
|
||||||
"IOCTL(V) Sock: %08x ioctl/v: %d returned: %d nonBlock: %d forceNonBlock: %d", fd,
|
"IOCTL(V) Sock: %08x ioctl/v: %d returned: %d nonBlock: %d forceNonBlock: %d", fd,
|
||||||
it->is_ssl ? (int)it->ssl_type : (int)it->net_type, ReturnValue, nonBlock,
|
it->is_ssl ? (int)it->ssl_type : (int)it->net_type, ReturnValue, nonBlock,
|
||||||
forceNonBlock);
|
forceNonBlock);
|
||||||
Memory::Write_U32(ReturnValue, it->_CommandAddress + 4);
|
it->request.SetReturnValue(ReturnValue);
|
||||||
WII_IPC_HLE_Interface::EnqueueReply(it->_CommandAddress);
|
WII_IPC_HLE_Interface::EnqueueReply(it->request);
|
||||||
it = pending_sockops.erase(it);
|
it = pending_sockops.erase(it);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -587,16 +578,16 @@ void WiiSocket::Update(bool read, bool write, bool except)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WiiSocket::DoSock(u32 _CommandAddress, NET_IOCTL type)
|
void WiiSocket::DoSock(IOSRequest request, NET_IOCTL type)
|
||||||
{
|
{
|
||||||
sockop so = {_CommandAddress, false};
|
sockop so = {request, 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(IOSRequest request, SSL_IOCTL type)
|
||||||
{
|
{
|
||||||
sockop so = {_CommandAddress, true};
|
sockop so = {request, true};
|
||||||
so.ssl_type = type;
|
so.ssl_type = type;
|
||||||
pending_sockops.push_back(so);
|
pending_sockops.push_back(so);
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,7 +172,7 @@ class WiiSocket
|
||||||
{
|
{
|
||||||
struct sockop
|
struct sockop
|
||||||
{
|
{
|
||||||
u32 _CommandAddress;
|
IOSRequest request;
|
||||||
bool is_ssl;
|
bool is_ssl;
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
|
@ -191,8 +191,8 @@ private:
|
||||||
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(IOSRequest request, NET_IOCTL type);
|
||||||
void DoSock(u32 _CommandAddress, SSL_IOCTL type);
|
void DoSock(IOSRequest request, SSL_IOCTL type);
|
||||||
void Update(bool read, bool write, bool except);
|
void Update(bool read, bool write, bool except);
|
||||||
bool IsValid() const { return fd >= 0; }
|
bool IsValid() const { return fd >= 0; }
|
||||||
public:
|
public:
|
||||||
|
@ -223,19 +223,19 @@ public:
|
||||||
void SetLastNetError(s32 error) { errno_last = error; }
|
void SetLastNetError(s32 error) { errno_last = error; }
|
||||||
void Clean() { WiiSockets.clear(); }
|
void Clean() { WiiSockets.clear(); }
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void DoSock(s32 sock, u32 CommandAddress, T type)
|
void DoSock(s32 sock, const IOSRequest& request, T type)
|
||||||
{
|
{
|
||||||
auto socket_entry = WiiSockets.find(sock);
|
auto socket_entry = WiiSockets.find(sock);
|
||||||
if (socket_entry == WiiSockets.end())
|
if (socket_entry == WiiSockets.end())
|
||||||
{
|
{
|
||||||
ERROR_LOG(WII_IPC_NET, "DoSock: Error, fd not found (%08x, %08X, %08X)", sock, CommandAddress,
|
ERROR_LOG(WII_IPC_NET, "DoSock: Error, fd not found (%08x, %08X, %08X)", sock,
|
||||||
type);
|
request.address, type);
|
||||||
Memory::Write_U32(-SO_EBADF, CommandAddress + 4);
|
request.SetReturnValue(-SO_EBADF);
|
||||||
WII_IPC_HLE_Interface::EnqueueReply(CommandAddress);
|
WII_IPC_HLE_Interface::EnqueueReply(request);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
socket_entry->second.DoSock(CommandAddress, type);
|
socket_entry->second.DoSock(request, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue