2016-03-21 20:43:03 +01:00
|
|
|
#include "Emu/Cell/PPUModule.h"
|
2019-10-17 23:01:28 +02:00
|
|
|
#include "Emu/IdManager.h"
|
2025-04-08 18:46:57 +02:00
|
|
|
#include "Emu/system_config.h"
|
|
|
|
|
#include "stdafx.h"
|
2016-03-21 20:43:03 +01:00
|
|
|
|
2017-05-15 13:30:14 +02:00
|
|
|
#include "cellGame.h"
|
2016-03-21 20:43:03 +01:00
|
|
|
#include "cellNetCtl.h"
|
2025-04-08 18:46:57 +02:00
|
|
|
#include "cellSysutil.h"
|
2016-03-21 20:43:03 +01:00
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
#include "util/StrUtil.h"
|
2020-03-04 14:55:35 +01:00
|
|
|
|
|
|
|
|
#include "Emu/NP/np_handler.h"
|
2021-11-06 21:18:31 +01:00
|
|
|
#include "Emu/NP/np_helpers.h"
|
2020-03-04 14:55:35 +01:00
|
|
|
|
2018-08-25 14:39:00 +02:00
|
|
|
LOG_CHANNEL(cellNetCtl);
|
2016-03-21 20:43:03 +01:00
|
|
|
|
2017-05-20 13:45:02 +02:00
|
|
|
template <>
|
2017-05-15 13:30:14 +02:00
|
|
|
void fmt_class_string<CellNetCtlError>::format(std::string& out, u64 arg)
|
|
|
|
|
{
|
|
|
|
|
format_enum(out, arg, [](auto error)
|
|
|
|
|
{
|
2025-04-05 21:50:45 +02:00
|
|
|
switch (error)
|
|
|
|
|
{
|
|
|
|
|
STR_CASE(CELL_NET_CTL_ERROR_NOT_INITIALIZED);
|
|
|
|
|
STR_CASE(CELL_NET_CTL_ERROR_NOT_TERMINATED);
|
|
|
|
|
STR_CASE(CELL_NET_CTL_ERROR_HANDLER_MAX);
|
|
|
|
|
STR_CASE(CELL_NET_CTL_ERROR_ID_NOT_FOUND);
|
|
|
|
|
STR_CASE(CELL_NET_CTL_ERROR_INVALID_ID);
|
|
|
|
|
STR_CASE(CELL_NET_CTL_ERROR_INVALID_CODE);
|
|
|
|
|
STR_CASE(CELL_NET_CTL_ERROR_INVALID_ADDR);
|
|
|
|
|
STR_CASE(CELL_NET_CTL_ERROR_NOT_CONNECTED);
|
|
|
|
|
STR_CASE(CELL_NET_CTL_ERROR_NOT_AVAIL);
|
|
|
|
|
STR_CASE(CELL_NET_CTL_ERROR_INVALID_TYPE);
|
|
|
|
|
STR_CASE(CELL_NET_CTL_ERROR_INVALID_SIZE);
|
|
|
|
|
STR_CASE(CELL_NET_CTL_ERROR_NET_DISABLED);
|
|
|
|
|
STR_CASE(CELL_NET_CTL_ERROR_NET_NOT_CONNECTED);
|
|
|
|
|
STR_CASE(CELL_NET_CTL_ERROR_NP_NO_ACCOUNT);
|
|
|
|
|
STR_CASE(CELL_NET_CTL_ERROR_NP_RESERVED1);
|
|
|
|
|
STR_CASE(CELL_NET_CTL_ERROR_NP_RESERVED2);
|
|
|
|
|
STR_CASE(CELL_NET_CTL_ERROR_NET_CABLE_NOT_CONNECTED);
|
|
|
|
|
STR_CASE(CELL_NET_CTL_ERROR_DIALOG_CANCELED);
|
|
|
|
|
STR_CASE(CELL_NET_CTL_ERROR_DIALOG_ABORTED);
|
|
|
|
|
|
|
|
|
|
STR_CASE(CELL_NET_CTL_ERROR_WLAN_DEAUTHED);
|
|
|
|
|
STR_CASE(CELL_NET_CTL_ERROR_WLAN_KEYINFO_EXCHNAGE_TIMEOUT);
|
|
|
|
|
STR_CASE(CELL_NET_CTL_ERROR_WLAN_ASSOC_FAILED);
|
|
|
|
|
STR_CASE(CELL_NET_CTL_ERROR_WLAN_AP_DISAPPEARED);
|
|
|
|
|
STR_CASE(CELL_NET_CTL_ERROR_PPPOE_SESSION_INIT);
|
|
|
|
|
STR_CASE(CELL_NET_CTL_ERROR_PPPOE_SESSION_NO_PADO);
|
|
|
|
|
STR_CASE(CELL_NET_CTL_ERROR_PPPOE_SESSION_NO_PADS);
|
|
|
|
|
STR_CASE(CELL_NET_CTL_ERROR_PPPOE_SESSION_GET_PADT);
|
|
|
|
|
STR_CASE(CELL_NET_CTL_ERROR_PPPOE_SESSION_SERVICE_NAME);
|
|
|
|
|
STR_CASE(CELL_NET_CTL_ERROR_PPPOE_SESSION_AC_SYSTEM);
|
|
|
|
|
STR_CASE(CELL_NET_CTL_ERROR_PPPOE_SESSION_GENERIC);
|
|
|
|
|
STR_CASE(CELL_NET_CTL_ERROR_PPPOE_STATUS_AUTH);
|
|
|
|
|
STR_CASE(CELL_NET_CTL_ERROR_PPPOE_STATUS_NETWORK);
|
|
|
|
|
STR_CASE(CELL_NET_CTL_ERROR_PPPOE_STATUS_TERMINATE);
|
|
|
|
|
STR_CASE(CELL_NET_CTL_ERROR_DHCP_LEASE_TIME);
|
|
|
|
|
|
|
|
|
|
STR_CASE(CELL_GAMEUPDATE_ERROR_NOT_INITIALIZED);
|
|
|
|
|
STR_CASE(CELL_GAMEUPDATE_ERROR_ALREADY_INITIALIZED);
|
|
|
|
|
STR_CASE(CELL_GAMEUPDATE_ERROR_INVALID_ADDR);
|
|
|
|
|
STR_CASE(CELL_GAMEUPDATE_ERROR_INVALID_SIZE);
|
|
|
|
|
STR_CASE(CELL_GAMEUPDATE_ERROR_INVALID_MEMORY_CONTAINER);
|
|
|
|
|
STR_CASE(CELL_GAMEUPDATE_ERROR_INSUFFICIENT_MEMORY_CONTAINER);
|
|
|
|
|
STR_CASE(CELL_GAMEUPDATE_ERROR_BUSY);
|
|
|
|
|
STR_CASE(CELL_GAMEUPDATE_ERROR_NOT_START);
|
|
|
|
|
STR_CASE(CELL_GAMEUPDATE_ERROR_LOAD_FAILED);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return unknown;
|
|
|
|
|
});
|
2017-05-15 13:30:14 +02:00
|
|
|
}
|
|
|
|
|
|
2017-05-20 13:45:02 +02:00
|
|
|
template <>
|
|
|
|
|
void fmt_class_string<CellNetCtlState>::format(std::string& out, u64 arg)
|
2016-03-21 20:43:03 +01:00
|
|
|
{
|
2017-05-20 13:45:02 +02:00
|
|
|
format_enum(out, arg, [](CellNetCtlState value)
|
|
|
|
|
{
|
2025-04-05 21:50:45 +02:00
|
|
|
switch (value)
|
|
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
case CELL_NET_CTL_STATE_Disconnected:
|
|
|
|
|
return "Disconnected";
|
|
|
|
|
case CELL_NET_CTL_STATE_Connecting:
|
|
|
|
|
return "Connecting";
|
|
|
|
|
case CELL_NET_CTL_STATE_IPObtaining:
|
|
|
|
|
return "Obtaining IP";
|
|
|
|
|
case CELL_NET_CTL_STATE_IPObtained:
|
|
|
|
|
return "IP Obtained";
|
2025-04-05 21:50:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return unknown;
|
|
|
|
|
});
|
2017-05-20 13:45:02 +02:00
|
|
|
}
|
2016-03-21 20:43:03 +01:00
|
|
|
|
2023-01-15 10:46:49 +01:00
|
|
|
struct CellGameUpdateResult
|
|
|
|
|
{
|
|
|
|
|
be_t<s32> status; // CellGameUpdateResultStatus
|
|
|
|
|
be_t<s32> error_code;
|
|
|
|
|
char app_ver[CELL_GAME_SYSP_APP_VER_SIZE];
|
|
|
|
|
char padding[2];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct CellGameUpdateParam
|
|
|
|
|
{
|
|
|
|
|
be_t<u32> size;
|
|
|
|
|
be_t<u32> cid;
|
|
|
|
|
};
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
using CellGameUpdateCallback = void(s32 status, s32 error_code,
|
|
|
|
|
vm::ptr<void> userdata);
|
|
|
|
|
using CellGameUpdateCallbackEx = void(vm::ptr<CellGameUpdateResult> result,
|
|
|
|
|
vm::ptr<void> userdata);
|
2023-01-15 10:46:49 +01:00
|
|
|
|
2017-05-15 13:30:14 +02:00
|
|
|
error_code cellNetCtlInit()
|
2016-03-21 20:43:03 +01:00
|
|
|
{
|
|
|
|
|
cellNetCtl.warning("cellNetCtlInit()");
|
|
|
|
|
|
2021-10-28 06:36:57 +02:00
|
|
|
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
2019-10-17 23:01:28 +02:00
|
|
|
|
2021-03-02 12:59:19 +01:00
|
|
|
if (nph.is_netctl_init)
|
2019-10-17 23:01:28 +02:00
|
|
|
{
|
|
|
|
|
return CELL_NET_CTL_ERROR_NOT_TERMINATED;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-02 12:59:19 +01:00
|
|
|
nph.is_netctl_init = true;
|
2019-10-17 23:01:28 +02:00
|
|
|
|
2016-03-21 20:43:03 +01:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-17 23:01:28 +02:00
|
|
|
void cellNetCtlTerm()
|
2016-03-21 20:43:03 +01:00
|
|
|
{
|
|
|
|
|
cellNetCtl.warning("cellNetCtlTerm()");
|
|
|
|
|
|
2021-10-28 06:36:57 +02:00
|
|
|
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
2021-03-02 12:59:19 +01:00
|
|
|
|
|
|
|
|
nph.is_netctl_init = false;
|
2016-03-21 20:43:03 +01:00
|
|
|
}
|
|
|
|
|
|
2019-10-17 23:01:28 +02:00
|
|
|
error_code cellNetCtlGetState(vm::ptr<s32> state)
|
2016-03-21 20:43:03 +01:00
|
|
|
{
|
|
|
|
|
cellNetCtl.trace("cellNetCtlGetState(state=*0x%x)", state);
|
|
|
|
|
|
2021-10-28 06:36:57 +02:00
|
|
|
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
2020-03-04 14:55:35 +01:00
|
|
|
|
2021-03-02 12:59:19 +01:00
|
|
|
if (!nph.is_netctl_init)
|
2019-10-17 23:01:28 +02:00
|
|
|
{
|
|
|
|
|
return CELL_NET_CTL_ERROR_NOT_INITIALIZED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!state)
|
|
|
|
|
{
|
|
|
|
|
return CELL_NET_CTL_ERROR_INVALID_ADDR;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-02 12:59:19 +01:00
|
|
|
*state = nph.get_net_status();
|
2020-03-04 14:55:35 +01:00
|
|
|
|
2016-03-21 20:43:03 +01:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code cellNetCtlAddHandler(vm::ptr<cellNetCtlHandler> handler,
|
|
|
|
|
vm::ptr<void> arg, vm::ptr<s32> hid)
|
2016-03-21 20:43:03 +01:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellNetCtl.todo("cellNetCtlAddHandler(handler=*0x%x, arg=*0x%x, hid=*0x%x)",
|
|
|
|
|
handler, arg, hid);
|
2016-03-21 20:43:03 +01:00
|
|
|
|
2021-10-28 06:36:57 +02:00
|
|
|
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
2020-03-04 14:55:35 +01:00
|
|
|
|
2021-03-02 12:59:19 +01:00
|
|
|
if (!nph.is_netctl_init)
|
2019-10-17 23:01:28 +02:00
|
|
|
{
|
|
|
|
|
return CELL_NET_CTL_ERROR_NOT_INITIALIZED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!hid)
|
|
|
|
|
{
|
|
|
|
|
return CELL_NET_CTL_ERROR_INVALID_ADDR;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-21 20:43:03 +01:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-15 13:30:14 +02:00
|
|
|
error_code cellNetCtlDelHandler(s32 hid)
|
2016-03-21 20:43:03 +01:00
|
|
|
{
|
|
|
|
|
cellNetCtl.todo("cellNetCtlDelHandler(hid=0x%x)", hid);
|
|
|
|
|
|
2021-10-28 06:36:57 +02:00
|
|
|
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
2020-03-04 14:55:35 +01:00
|
|
|
|
2021-03-02 12:59:19 +01:00
|
|
|
if (!nph.is_netctl_init)
|
2019-10-17 23:01:28 +02:00
|
|
|
{
|
|
|
|
|
return CELL_NET_CTL_ERROR_NOT_INITIALIZED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (hid > 3)
|
|
|
|
|
{
|
|
|
|
|
return CELL_NET_CTL_ERROR_INVALID_ID;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-21 20:43:03 +01:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-15 13:30:14 +02:00
|
|
|
error_code cellNetCtlGetInfo(s32 code, vm::ptr<CellNetCtlInfo> info)
|
2016-03-21 20:43:03 +01:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellNetCtl.warning("cellNetCtlGetInfo(code=0x%x (%s), info=*0x%x)", code,
|
|
|
|
|
InfoCodeToName(code), info);
|
2016-03-21 20:43:03 +01:00
|
|
|
|
2021-10-28 06:36:57 +02:00
|
|
|
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
2020-03-04 14:55:35 +01:00
|
|
|
|
2021-03-02 12:59:19 +01:00
|
|
|
if (!nph.is_netctl_init)
|
2019-10-17 23:01:28 +02:00
|
|
|
{
|
|
|
|
|
return CELL_NET_CTL_ERROR_NOT_INITIALIZED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!info)
|
|
|
|
|
{
|
|
|
|
|
return CELL_NET_CTL_ERROR_INVALID_ADDR;
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-04 22:43:22 +01:00
|
|
|
if (code == CELL_NET_CTL_INFO_ETHER_ADDR)
|
|
|
|
|
{
|
2021-03-02 12:59:19 +01:00
|
|
|
memcpy(info->ether_addr.data, nph.get_ether_addr().data(), 6);
|
2018-02-04 22:43:22 +01:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-02 12:59:19 +01:00
|
|
|
if (nph.get_net_status() == CELL_NET_CTL_STATE_Disconnected)
|
2018-02-04 22:43:22 +01:00
|
|
|
{
|
|
|
|
|
return CELL_NET_CTL_ERROR_NOT_CONNECTED;
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-07 23:50:17 +02:00
|
|
|
switch (code)
|
|
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
case CELL_NET_CTL_INFO_DEVICE:
|
|
|
|
|
info->device = CELL_NET_CTL_DEVICE_WIRED;
|
|
|
|
|
break;
|
|
|
|
|
case CELL_NET_CTL_INFO_MTU:
|
|
|
|
|
info->mtu = 1500;
|
|
|
|
|
break;
|
|
|
|
|
case CELL_NET_CTL_INFO_LINK:
|
|
|
|
|
info->link = CELL_NET_CTL_LINK_CONNECTED;
|
|
|
|
|
break;
|
|
|
|
|
case CELL_NET_CTL_INFO_LINK_TYPE:
|
|
|
|
|
info->link_type = CELL_NET_CTL_LINK_TYPE_100BASE_FULL;
|
|
|
|
|
break;
|
2024-09-27 15:26:48 +02:00
|
|
|
// case CELL_NET_CTL_INFO_BSSID: break;
|
|
|
|
|
// case CELL_NET_CTL_INFO_SSID: break;
|
|
|
|
|
// case CELL_NET_CTL_INFO_WLAN_SECURITY: break;
|
|
|
|
|
// case CELL_NET_CTL_INFO_8021X_TYPE: break;
|
|
|
|
|
// case CELL_NET_CTL_INFO_8021X_AUTH_NAME: break;
|
2025-04-08 18:46:57 +02:00
|
|
|
case CELL_NET_CTL_INFO_RSSI:
|
|
|
|
|
info->rssi = 100;
|
|
|
|
|
break; // wireless: value ranges from 0-100 indicating wireless connection
|
|
|
|
|
// strength
|
|
|
|
|
case CELL_NET_CTL_INFO_CHANNEL:
|
|
|
|
|
info->channel = 1;
|
|
|
|
|
break; // wireless: channel used to connect to the AP?
|
|
|
|
|
case CELL_NET_CTL_INFO_IP_CONFIG:
|
|
|
|
|
info->ip_config = CELL_NET_CTL_IP_STATIC;
|
|
|
|
|
break;
|
|
|
|
|
case CELL_NET_CTL_INFO_DHCP_HOSTNAME:
|
|
|
|
|
strcpy_trunc(info->dhcp_hostname, nph.get_hostname());
|
|
|
|
|
break;
|
2024-09-27 15:26:48 +02:00
|
|
|
// case CELL_NET_CTL_INFO_PPPOE_AUTH_NAME: break;
|
2025-04-08 18:46:57 +02:00
|
|
|
case CELL_NET_CTL_INFO_IP_ADDRESS:
|
|
|
|
|
strcpy_trunc(info->ip_address, np::ip_to_string(nph.get_local_ip_addr()));
|
|
|
|
|
break; // verified on HW
|
|
|
|
|
case CELL_NET_CTL_INFO_NETMASK:
|
|
|
|
|
strcpy_trunc(info->netmask, "255.255.255.0");
|
|
|
|
|
break;
|
|
|
|
|
case CELL_NET_CTL_INFO_DEFAULT_ROUTE:
|
|
|
|
|
strcpy_trunc(info->default_route, "192.168.1.1");
|
|
|
|
|
break;
|
|
|
|
|
case CELL_NET_CTL_INFO_PRIMARY_DNS:
|
|
|
|
|
strcpy_trunc(info->primary_dns, np::ip_to_string(nph.get_dns_ip()));
|
|
|
|
|
break;
|
|
|
|
|
case CELL_NET_CTL_INFO_SECONDARY_DNS:
|
|
|
|
|
strcpy_trunc(info->secondary_dns, np::ip_to_string(nph.get_dns_ip()));
|
|
|
|
|
break;
|
|
|
|
|
case CELL_NET_CTL_INFO_HTTP_PROXY_CONFIG:
|
|
|
|
|
info->http_proxy_config = 0;
|
|
|
|
|
break;
|
2024-09-27 15:26:48 +02:00
|
|
|
// case CELL_NET_CTL_INFO_HTTP_PROXY_SERVER: break;
|
|
|
|
|
// case CELL_NET_CTL_INFO_HTTP_PROXY_PORT: break;
|
2025-04-08 18:46:57 +02:00
|
|
|
case CELL_NET_CTL_INFO_UPNP_CONFIG:
|
|
|
|
|
info->upnp_config =
|
|
|
|
|
(nph.get_upnp_status() == SCE_NP_SIGNALING_NETINFO_UPNP_STATUS_VALID) ? CELL_NET_CTL_UPNP_ON : CELL_NET_CTL_UPNP_OFF;
|
|
|
|
|
break;
|
2024-09-27 15:26:48 +02:00
|
|
|
// case CELL_NET_CTL_INFO_RESERVED1: break;
|
|
|
|
|
// case CELL_NET_CTL_INFO_RESERVED2: break;
|
2025-04-08 18:46:57 +02:00
|
|
|
default:
|
|
|
|
|
cellNetCtl.error("Unsupported request: %s", InfoCodeToName(code));
|
|
|
|
|
break;
|
2017-09-25 17:52:34 +02:00
|
|
|
}
|
2016-03-21 20:43:03 +01:00
|
|
|
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-28 15:25:53 +01:00
|
|
|
struct netstart_hack
|
|
|
|
|
{
|
|
|
|
|
static constexpr std::string_view thread_name = "NetStart Hack";
|
|
|
|
|
|
2021-04-09 21:12:47 +02:00
|
|
|
void operator()(int) const
|
2021-02-28 15:25:53 +01:00
|
|
|
{
|
|
|
|
|
thread_ctrl::wait_for(500'000);
|
|
|
|
|
|
|
|
|
|
sysutil_send_system_cmd(CELL_SYSUTIL_NET_CTL_NETSTART_LOADED, 0);
|
|
|
|
|
sysutil_send_system_cmd(CELL_SYSUTIL_NET_CTL_NETSTART_FINISHED, 0);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code cellNetCtlNetStartDialogLoadAsync(
|
|
|
|
|
vm::cptr<CellNetCtlNetStartDialogParam> param)
|
2016-03-21 20:43:03 +01:00
|
|
|
{
|
2022-05-18 17:44:21 +02:00
|
|
|
cellNetCtl.warning("cellNetCtlNetStartDialogLoadAsync(param=*0x%x)", param);
|
2016-03-21 20:43:03 +01:00
|
|
|
|
2021-10-28 06:36:57 +02:00
|
|
|
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
2020-03-04 14:55:35 +01:00
|
|
|
|
2021-03-02 12:59:19 +01:00
|
|
|
if (!nph.is_netctl_init)
|
2019-10-17 23:01:28 +02:00
|
|
|
{
|
|
|
|
|
return CELL_NET_CTL_ERROR_NOT_INITIALIZED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!param)
|
|
|
|
|
{
|
|
|
|
|
return CELL_NET_CTL_ERROR_INVALID_ADDR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (param->type >= CELL_NET_CTL_NETSTART_TYPE_MAX)
|
|
|
|
|
{
|
|
|
|
|
return CELL_NET_CTL_ERROR_INVALID_TYPE;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-19 16:26:41 +01:00
|
|
|
if (param->size != 12u)
|
2019-10-17 23:01:28 +02:00
|
|
|
{
|
|
|
|
|
return CELL_NET_CTL_ERROR_INVALID_SIZE;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
// This is a hack for Diva F 2nd that registers the sysutil callback after
|
|
|
|
|
// calling this function.
|
2021-03-02 12:59:19 +01:00
|
|
|
g_fxo->get<named_thread<netstart_hack>>()(0);
|
2016-03-21 20:43:03 +01:00
|
|
|
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-15 13:30:14 +02:00
|
|
|
error_code cellNetCtlNetStartDialogAbortAsync()
|
2016-03-21 20:43:03 +01:00
|
|
|
{
|
|
|
|
|
cellNetCtl.error("cellNetCtlNetStartDialogAbortAsync()");
|
|
|
|
|
|
2021-10-28 06:36:57 +02:00
|
|
|
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
2020-03-04 14:55:35 +01:00
|
|
|
|
2021-03-02 12:59:19 +01:00
|
|
|
if (!nph.is_netctl_init)
|
2019-10-17 23:01:28 +02:00
|
|
|
{
|
|
|
|
|
return CELL_NET_CTL_ERROR_NOT_INITIALIZED;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-21 20:43:03 +01:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code cellNetCtlNetStartDialogUnloadAsync(
|
|
|
|
|
vm::ptr<CellNetCtlNetStartDialogResult> result)
|
2016-03-21 20:43:03 +01:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellNetCtl.warning("cellNetCtlNetStartDialogUnloadAsync(result=*0x%x)",
|
|
|
|
|
result);
|
2016-03-21 20:43:03 +01:00
|
|
|
|
2021-10-28 06:36:57 +02:00
|
|
|
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
2020-03-04 14:55:35 +01:00
|
|
|
|
2021-03-02 12:59:19 +01:00
|
|
|
if (!nph.is_netctl_init)
|
2019-10-17 23:01:28 +02:00
|
|
|
{
|
|
|
|
|
return CELL_NET_CTL_ERROR_NOT_INITIALIZED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!result)
|
|
|
|
|
{
|
|
|
|
|
return CELL_NET_CTL_ERROR_INVALID_ADDR;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-19 16:26:41 +01:00
|
|
|
if (result->size != 8u)
|
2019-10-17 23:01:28 +02:00
|
|
|
{
|
|
|
|
|
return CELL_NET_CTL_ERROR_INVALID_SIZE;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-02 12:59:19 +01:00
|
|
|
result->result = nph.get_net_status() == CELL_NET_CTL_STATE_IPObtained ? 0 : CELL_NET_CTL_ERROR_DIALOG_CANCELED;
|
2019-12-04 20:55:40 +01:00
|
|
|
|
2016-07-27 23:43:22 +02:00
|
|
|
sysutil_send_system_cmd(CELL_SYSUTIL_NET_CTL_NETSTART_UNLOADED, 0);
|
2016-03-21 20:43:03 +01:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-15 13:30:14 +02:00
|
|
|
error_code cellNetCtlGetNatInfo(vm::ptr<CellNetCtlNatInfo> natInfo)
|
2016-03-21 20:43:03 +01:00
|
|
|
{
|
2019-12-20 08:17:22 +01:00
|
|
|
cellNetCtl.warning("cellNetCtlGetNatInfo(natInfo=*0x%x)", natInfo);
|
2016-03-21 20:43:03 +01:00
|
|
|
|
2021-10-28 06:36:57 +02:00
|
|
|
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
2020-03-04 14:55:35 +01:00
|
|
|
|
2021-03-02 12:59:19 +01:00
|
|
|
if (!nph.is_netctl_init)
|
2019-10-17 23:01:28 +02:00
|
|
|
{
|
|
|
|
|
return CELL_NET_CTL_ERROR_NOT_INITIALIZED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!natInfo)
|
|
|
|
|
{
|
|
|
|
|
return CELL_NET_CTL_ERROR_INVALID_ADDR;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-19 16:26:41 +01:00
|
|
|
if (natInfo->size != 16u && natInfo->size != 20u)
|
2016-03-21 20:43:03 +01:00
|
|
|
{
|
|
|
|
|
return CELL_NET_CTL_ERROR_INVALID_SIZE;
|
|
|
|
|
}
|
2017-12-16 01:03:49 +01:00
|
|
|
|
2020-08-27 21:47:04 +02:00
|
|
|
natInfo->nat_type = CELL_NET_CTL_NATINFO_NAT_TYPE_2;
|
|
|
|
|
natInfo->stun_status = CELL_NET_CTL_NATINFO_STUN_OK;
|
2023-01-12 04:05:05 +01:00
|
|
|
natInfo->upnp_status = nph.get_upnp_status();
|
2020-08-27 21:47:04 +02:00
|
|
|
|
2016-03-21 20:43:03 +01:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-13 09:42:24 +02:00
|
|
|
error_code cellNetCtlAddHandlerGameInt()
|
|
|
|
|
{
|
|
|
|
|
cellNetCtl.todo("cellNetCtlAddHandlerGameInt()");
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
error_code cellNetCtlConnectGameInt()
|
|
|
|
|
{
|
|
|
|
|
cellNetCtl.todo("cellNetCtlConnectGameInt()");
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
error_code cellNetCtlDelHandlerGameInt()
|
|
|
|
|
{
|
|
|
|
|
cellNetCtl.todo("cellNetCtlDelHandlerGameInt()");
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
error_code cellNetCtlDisconnectGameInt()
|
|
|
|
|
{
|
|
|
|
|
cellNetCtl.todo("cellNetCtlDisconnectGameInt()");
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
error_code cellNetCtlGetInfoGameInt()
|
|
|
|
|
{
|
|
|
|
|
cellNetCtl.todo("cellNetCtlGetInfoGameInt()");
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
error_code cellNetCtlGetScanInfoGameInt()
|
|
|
|
|
{
|
|
|
|
|
cellNetCtl.todo("cellNetCtlGetScanInfoGameInt()");
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
error_code cellNetCtlGetStateGameInt()
|
|
|
|
|
{
|
|
|
|
|
cellNetCtl.todo("cellNetCtlGetStateGameInt()");
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
error_code cellNetCtlScanGameInt()
|
|
|
|
|
{
|
|
|
|
|
cellNetCtl.todo("cellNetCtlScanGameInt()");
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-15 13:30:14 +02:00
|
|
|
error_code cellGameUpdateInit()
|
2016-03-21 20:43:03 +01:00
|
|
|
{
|
2017-05-15 13:30:14 +02:00
|
|
|
cellNetCtl.todo("cellGameUpdateInit()");
|
|
|
|
|
return CELL_OK;
|
2016-03-21 20:43:03 +01:00
|
|
|
}
|
|
|
|
|
|
2017-05-15 13:30:14 +02:00
|
|
|
error_code cellGameUpdateTerm()
|
2016-03-21 20:43:03 +01:00
|
|
|
{
|
2017-05-15 13:30:14 +02:00
|
|
|
cellNetCtl.todo("cellGameUpdateTerm()");
|
|
|
|
|
return CELL_OK;
|
2016-03-21 20:43:03 +01:00
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code
|
|
|
|
|
cellGameUpdateCheckStartAsync(vm::cptr<CellGameUpdateParam> param,
|
|
|
|
|
vm::ptr<CellGameUpdateCallback> cb_func,
|
|
|
|
|
vm::ptr<void> userdata)
|
2016-03-21 20:43:03 +01:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellNetCtl.todo("cellGameUpdateCheckStartAsync(param=*0x%x, cb_func=*0x%x, "
|
|
|
|
|
"userdata=*0x%x)",
|
|
|
|
|
param, cb_func, userdata);
|
2017-12-16 01:03:49 +01:00
|
|
|
sysutil_register_cb([=](ppu_thread& ppu) -> s32
|
2025-04-05 21:50:45 +02:00
|
|
|
{
|
|
|
|
|
cb_func(ppu, CELL_GAMEUPDATE_RESULT_STATUS_NO_UPDATE, CELL_OK, userdata);
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
});
|
2017-05-15 13:30:14 +02:00
|
|
|
return CELL_OK;
|
2016-03-21 20:43:03 +01:00
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code
|
|
|
|
|
cellGameUpdateCheckFinishAsync(vm::ptr<CellGameUpdateCallback> cb_func,
|
|
|
|
|
vm::ptr<void> userdata)
|
2016-03-21 20:43:03 +01:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellNetCtl.todo(
|
|
|
|
|
"cellGameUpdateCheckFinishAsync(cb_func=*0x%x, userdata=*0x%x)", cb_func,
|
|
|
|
|
userdata);
|
2017-12-16 01:03:49 +01:00
|
|
|
sysutil_register_cb([=](ppu_thread& ppu) -> s32
|
2025-04-05 21:50:45 +02:00
|
|
|
{
|
|
|
|
|
cb_func(ppu, CELL_GAMEUPDATE_RESULT_STATUS_FINISHED, CELL_OK, userdata);
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
});
|
2017-05-15 13:30:14 +02:00
|
|
|
return CELL_OK;
|
2016-03-21 20:43:03 +01:00
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code cellGameUpdateCheckStartWithoutDialogAsync(
|
|
|
|
|
vm::ptr<CellGameUpdateCallback> cb_func, vm::ptr<void> userdata)
|
2016-03-21 20:43:03 +01:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellNetCtl.todo("cellGameUpdateCheckStartWithoutDialogAsync(cb_func=*0x%x, "
|
|
|
|
|
"userdata=*0x%x)",
|
|
|
|
|
cb_func, userdata);
|
2018-01-08 21:37:40 +01:00
|
|
|
sysutil_register_cb([=](ppu_thread& ppu) -> s32
|
2025-04-05 21:50:45 +02:00
|
|
|
{
|
|
|
|
|
cb_func(ppu, CELL_GAMEUPDATE_RESULT_STATUS_NO_UPDATE, CELL_OK, userdata);
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
});
|
2017-05-15 13:30:14 +02:00
|
|
|
return CELL_OK;
|
2016-03-21 20:43:03 +01:00
|
|
|
}
|
|
|
|
|
|
2017-05-15 13:30:14 +02:00
|
|
|
error_code cellGameUpdateCheckAbort()
|
2016-03-21 20:43:03 +01:00
|
|
|
{
|
2017-05-15 13:30:14 +02:00
|
|
|
cellNetCtl.todo("cellGameUpdateCheckAbort()");
|
|
|
|
|
return CELL_OK;
|
2016-03-21 20:43:03 +01:00
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code
|
|
|
|
|
cellGameUpdateCheckStartAsyncEx(vm::cptr<CellGameUpdateParam> param,
|
|
|
|
|
vm::ptr<CellGameUpdateCallbackEx> cb_func,
|
|
|
|
|
vm::ptr<void> userdata)
|
2016-03-21 20:43:03 +01:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellNetCtl.todo("cellGameUpdateCheckStartAsyncEx(param=*0x%x, cb_func=*0x%x, "
|
|
|
|
|
"userdata=*0x%x)",
|
|
|
|
|
param, cb_func, userdata);
|
2018-01-08 06:59:15 +01:00
|
|
|
sysutil_register_cb([=](ppu_thread& ppu) -> s32
|
2025-04-05 21:50:45 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cb_func(ppu,
|
|
|
|
|
vm::make_var(CellGameUpdateResult{
|
|
|
|
|
CELL_GAMEUPDATE_RESULT_STATUS_NO_UPDATE, CELL_OK}),
|
|
|
|
|
userdata);
|
2025-04-05 21:50:45 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
});
|
2017-05-15 13:30:14 +02:00
|
|
|
return CELL_OK;
|
2016-03-21 20:43:03 +01:00
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code
|
|
|
|
|
cellGameUpdateCheckFinishAsyncEx(vm::ptr<CellGameUpdateCallbackEx> cb_func,
|
|
|
|
|
vm::ptr<void> userdata)
|
2016-03-21 20:43:03 +01:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellNetCtl.todo(
|
|
|
|
|
"cellGameUpdateCheckFinishAsyncEx(cb_func=*0x%x, userdata=*0x%x)",
|
|
|
|
|
cb_func, userdata);
|
2018-01-08 06:59:15 +01:00
|
|
|
sysutil_register_cb([=](ppu_thread& ppu) -> s32
|
2025-04-05 21:50:45 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cb_func(ppu,
|
|
|
|
|
vm::make_var(CellGameUpdateResult{
|
|
|
|
|
CELL_GAMEUPDATE_RESULT_STATUS_FINISHED, CELL_OK}),
|
|
|
|
|
userdata);
|
2025-04-05 21:50:45 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
});
|
2017-05-15 13:30:14 +02:00
|
|
|
return CELL_OK;
|
2016-03-21 20:43:03 +01:00
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code cellGameUpdateCheckStartWithoutDialogAsyncEx(
|
|
|
|
|
vm::ptr<CellGameUpdateCallbackEx> cb_func, vm::ptr<void> userdata)
|
2016-03-21 20:43:03 +01:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellNetCtl.todo("cellGameUpdateCheckStartWithoutDialogAsyncEx(cb_func=*0x%x, "
|
|
|
|
|
"userdata=*0x%x)",
|
|
|
|
|
cb_func, userdata);
|
2018-01-08 21:37:40 +01:00
|
|
|
sysutil_register_cb([=](ppu_thread& ppu) -> s32
|
2025-04-05 21:50:45 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cb_func(ppu,
|
|
|
|
|
vm::make_var(CellGameUpdateResult{
|
|
|
|
|
CELL_GAMEUPDATE_RESULT_STATUS_NO_UPDATE, CELL_OK}),
|
|
|
|
|
userdata);
|
2025-04-05 21:50:45 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
});
|
2017-05-15 13:30:14 +02:00
|
|
|
return CELL_OK;
|
2016-03-21 20:43:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DECLARE(ppu_module_manager::cellNetCtl)("cellNetCtl", []()
|
2025-04-05 21:50:45 +02:00
|
|
|
{
|
|
|
|
|
REG_FUNC(cellNetCtl, cellNetCtlInit);
|
|
|
|
|
REG_FUNC(cellNetCtl, cellNetCtlTerm);
|
|
|
|
|
|
|
|
|
|
REG_FUNC(cellNetCtl, cellNetCtlGetState);
|
|
|
|
|
REG_FUNC(cellNetCtl, cellNetCtlAddHandler);
|
|
|
|
|
REG_FUNC(cellNetCtl, cellNetCtlDelHandler);
|
|
|
|
|
|
|
|
|
|
REG_FUNC(cellNetCtl, cellNetCtlGetInfo);
|
|
|
|
|
|
|
|
|
|
REG_FUNC(cellNetCtl, cellNetCtlNetStartDialogLoadAsync);
|
|
|
|
|
REG_FUNC(cellNetCtl, cellNetCtlNetStartDialogAbortAsync);
|
|
|
|
|
REG_FUNC(cellNetCtl, cellNetCtlNetStartDialogUnloadAsync);
|
|
|
|
|
|
|
|
|
|
REG_FUNC(cellNetCtl, cellNetCtlGetNatInfo);
|
|
|
|
|
|
|
|
|
|
REG_FUNC(cellNetCtl, cellNetCtlAddHandlerGameInt);
|
|
|
|
|
REG_FUNC(cellNetCtl, cellNetCtlConnectGameInt);
|
|
|
|
|
REG_FUNC(cellNetCtl, cellNetCtlDelHandlerGameInt);
|
|
|
|
|
REG_FUNC(cellNetCtl, cellNetCtlDisconnectGameInt);
|
|
|
|
|
REG_FUNC(cellNetCtl, cellNetCtlGetInfoGameInt);
|
|
|
|
|
REG_FUNC(cellNetCtl, cellNetCtlGetScanInfoGameInt);
|
|
|
|
|
REG_FUNC(cellNetCtl, cellNetCtlGetStateGameInt);
|
|
|
|
|
REG_FUNC(cellNetCtl, cellNetCtlScanGameInt);
|
|
|
|
|
|
|
|
|
|
REG_FUNC(cellNetCtl, cellGameUpdateInit);
|
|
|
|
|
REG_FUNC(cellNetCtl, cellGameUpdateTerm);
|
|
|
|
|
|
|
|
|
|
REG_FUNC(cellNetCtl, cellGameUpdateCheckStartAsync);
|
|
|
|
|
REG_FUNC(cellNetCtl, cellGameUpdateCheckFinishAsync);
|
|
|
|
|
REG_FUNC(cellNetCtl, cellGameUpdateCheckStartWithoutDialogAsync);
|
|
|
|
|
REG_FUNC(cellNetCtl, cellGameUpdateCheckAbort);
|
|
|
|
|
REG_FUNC(cellNetCtl, cellGameUpdateCheckStartAsyncEx);
|
|
|
|
|
REG_FUNC(cellNetCtl, cellGameUpdateCheckFinishAsyncEx);
|
|
|
|
|
REG_FUNC(cellNetCtl, cellGameUpdateCheckStartWithoutDialogAsyncEx);
|
|
|
|
|
});
|