2018-02-02 06:31:27 -05:00
|
|
|
// Copyright 2018 yuzu emulator team
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2021-04-14 19:07:40 -04:00
|
|
|
#include "common/settings.h"
|
2018-08-28 12:30:33 -04:00
|
|
|
#include "core/core.h"
|
2018-02-02 06:31:27 -05:00
|
|
|
#include "core/hle/ipc_helpers.h"
|
2021-01-31 04:38:57 -05:00
|
|
|
#include "core/hle/kernel/k_event.h"
|
2021-01-30 01:48:06 -05:00
|
|
|
#include "core/hle/kernel/k_readable_event.h"
|
2018-11-26 18:34:07 -05:00
|
|
|
#include "core/hle/kernel/kernel.h"
|
2018-02-02 06:31:27 -05:00
|
|
|
#include "core/hle/service/nifm/nifm.h"
|
2018-07-25 17:07:32 -04:00
|
|
|
#include "core/hle/service/service.h"
|
2020-07-11 20:43:51 -04:00
|
|
|
#include "core/network/network.h"
|
2021-08-16 04:32:25 -04:00
|
|
|
#include "core/network/network_interface.h"
|
2018-02-02 06:31:27 -05:00
|
|
|
|
2018-04-19 21:41:44 -04:00
|
|
|
namespace Service::NIFM {
|
2018-02-02 06:31:27 -05:00
|
|
|
|
2019-04-28 18:44:13 -04:00
|
|
|
enum class RequestState : u32 {
|
|
|
|
NotSubmitted = 1,
|
|
|
|
Error = 1, ///< The duplicate 1 is intentional; it means both not submitted and error on HW.
|
|
|
|
Pending = 2,
|
|
|
|
Connected = 3,
|
|
|
|
};
|
|
|
|
|
2021-01-31 06:05:41 -05:00
|
|
|
struct IpAddressSetting {
|
|
|
|
bool is_automatic{};
|
|
|
|
Network::IPv4Address current_address{};
|
|
|
|
Network::IPv4Address subnet_mask{};
|
|
|
|
Network::IPv4Address gateway{};
|
|
|
|
};
|
|
|
|
static_assert(sizeof(IpAddressSetting) == 0xD, "IpAddressSetting has incorrect size.");
|
|
|
|
|
|
|
|
struct DnsSetting {
|
|
|
|
bool is_automatic{};
|
|
|
|
Network::IPv4Address primary_dns{};
|
|
|
|
Network::IPv4Address secondary_dns{};
|
|
|
|
};
|
|
|
|
static_assert(sizeof(DnsSetting) == 0x9, "DnsSetting has incorrect size.");
|
|
|
|
|
|
|
|
struct ProxySetting {
|
|
|
|
bool enabled{};
|
|
|
|
INSERT_PADDING_BYTES(1);
|
|
|
|
u16 port{};
|
|
|
|
std::array<char, 0x64> proxy_server{};
|
|
|
|
bool automatic_auth_enabled{};
|
|
|
|
std::array<char, 0x20> user{};
|
|
|
|
std::array<char, 0x20> password{};
|
|
|
|
INSERT_PADDING_BYTES(1);
|
|
|
|
};
|
|
|
|
static_assert(sizeof(ProxySetting) == 0xAA, "ProxySetting has incorrect size.");
|
|
|
|
|
|
|
|
struct IpSettingData {
|
|
|
|
IpAddressSetting ip_address_setting{};
|
|
|
|
DnsSetting dns_setting{};
|
|
|
|
ProxySetting proxy_setting{};
|
|
|
|
u16 mtu{};
|
|
|
|
};
|
|
|
|
static_assert(sizeof(IpSettingData) == 0xC2, "IpSettingData has incorrect size.");
|
|
|
|
|
|
|
|
struct SfWirelessSettingData {
|
|
|
|
u8 ssid_length{};
|
|
|
|
std::array<char, 0x20> ssid{};
|
|
|
|
u8 unknown_1{};
|
|
|
|
u8 unknown_2{};
|
|
|
|
u8 unknown_3{};
|
|
|
|
std::array<char, 0x41> passphrase{};
|
|
|
|
};
|
|
|
|
static_assert(sizeof(SfWirelessSettingData) == 0x65, "SfWirelessSettingData has incorrect size.");
|
|
|
|
|
|
|
|
struct NifmWirelessSettingData {
|
|
|
|
u8 ssid_length{};
|
|
|
|
std::array<char, 0x21> ssid{};
|
|
|
|
u8 unknown_1{};
|
|
|
|
INSERT_PADDING_BYTES(1);
|
|
|
|
u32 unknown_2{};
|
|
|
|
u32 unknown_3{};
|
|
|
|
std::array<char, 0x41> passphrase{};
|
|
|
|
INSERT_PADDING_BYTES(3);
|
|
|
|
};
|
|
|
|
static_assert(sizeof(NifmWirelessSettingData) == 0x70,
|
|
|
|
"NifmWirelessSettingData has incorrect size.");
|
|
|
|
|
|
|
|
#pragma pack(push, 1)
|
|
|
|
struct SfNetworkProfileData {
|
|
|
|
IpSettingData ip_setting_data{};
|
|
|
|
u128 uuid{};
|
|
|
|
std::array<char, 0x40> network_name{};
|
|
|
|
u8 unknown_1{};
|
|
|
|
u8 unknown_2{};
|
|
|
|
u8 unknown_3{};
|
|
|
|
u8 unknown_4{};
|
|
|
|
SfWirelessSettingData wireless_setting_data{};
|
|
|
|
INSERT_PADDING_BYTES(1);
|
|
|
|
};
|
|
|
|
static_assert(sizeof(SfNetworkProfileData) == 0x17C, "SfNetworkProfileData has incorrect size.");
|
|
|
|
|
|
|
|
struct NifmNetworkProfileData {
|
|
|
|
u128 uuid{};
|
|
|
|
std::array<char, 0x40> network_name{};
|
|
|
|
u32 unknown_1{};
|
|
|
|
u32 unknown_2{};
|
|
|
|
u8 unknown_3{};
|
|
|
|
u8 unknown_4{};
|
|
|
|
INSERT_PADDING_BYTES(2);
|
|
|
|
NifmWirelessSettingData wireless_setting_data{};
|
|
|
|
IpSettingData ip_setting_data{};
|
|
|
|
};
|
|
|
|
static_assert(sizeof(NifmNetworkProfileData) == 0x18E,
|
|
|
|
"NifmNetworkProfileData has incorrect size.");
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
2018-02-02 06:31:27 -05:00
|
|
|
class IScanRequest final : public ServiceFramework<IScanRequest> {
|
|
|
|
public:
|
2020-11-26 15:19:08 -05:00
|
|
|
explicit IScanRequest(Core::System& system_) : ServiceFramework{system_, "IScanRequest"} {
|
2019-04-10 14:48:37 -04:00
|
|
|
// clang-format off
|
2018-02-02 06:31:27 -05:00
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, nullptr, "Submit"},
|
|
|
|
{1, nullptr, "IsProcessing"},
|
|
|
|
{2, nullptr, "GetResult"},
|
|
|
|
{3, nullptr, "GetSystemEventReadableHandle"},
|
2019-04-10 14:48:37 -04:00
|
|
|
{4, nullptr, "SetChannels"},
|
2018-02-02 06:31:27 -05:00
|
|
|
};
|
2019-04-10 14:48:37 -04:00
|
|
|
// clang-format on
|
|
|
|
|
2018-02-02 06:31:27 -05:00
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class IRequest final : public ServiceFramework<IRequest> {
|
|
|
|
public:
|
2021-04-04 03:56:09 -04:00
|
|
|
explicit IRequest(Core::System& system_)
|
|
|
|
: ServiceFramework{system_, "IRequest"}, event1{system.Kernel()}, event2{system.Kernel()} {
|
2018-02-02 06:31:27 -05:00
|
|
|
static const FunctionInfo functions[] = {
|
2018-02-22 09:28:15 -05:00
|
|
|
{0, &IRequest::GetRequestState, "GetRequestState"},
|
|
|
|
{1, &IRequest::GetResult, "GetResult"},
|
|
|
|
{2, &IRequest::GetSystemEventReadableHandles, "GetSystemEventReadableHandles"},
|
2018-03-16 04:08:22 -04:00
|
|
|
{3, &IRequest::Cancel, "Cancel"},
|
2018-09-20 10:47:30 -04:00
|
|
|
{4, &IRequest::Submit, "Submit"},
|
2018-02-02 06:31:27 -05:00
|
|
|
{5, nullptr, "SetRequirement"},
|
|
|
|
{6, nullptr, "SetRequirementPreset"},
|
|
|
|
{8, nullptr, "SetPriority"},
|
|
|
|
{9, nullptr, "SetNetworkProfileId"},
|
|
|
|
{10, nullptr, "SetRejectable"},
|
2018-06-05 18:43:43 -04:00
|
|
|
{11, &IRequest::SetConnectionConfirmationOption, "SetConnectionConfirmationOption"},
|
2018-02-02 06:31:27 -05:00
|
|
|
{12, nullptr, "SetPersistent"},
|
|
|
|
{13, nullptr, "SetInstant"},
|
|
|
|
{14, nullptr, "SetSustainable"},
|
|
|
|
{15, nullptr, "SetRawPriority"},
|
|
|
|
{16, nullptr, "SetGreedy"},
|
|
|
|
{17, nullptr, "SetSharable"},
|
|
|
|
{18, nullptr, "SetRequirementByRevision"},
|
|
|
|
{19, nullptr, "GetRequirement"},
|
|
|
|
{20, nullptr, "GetRevision"},
|
2020-07-21 00:06:52 -04:00
|
|
|
{21, &IRequest::GetAppletInfo, "GetAppletInfo"},
|
2018-02-02 06:31:27 -05:00
|
|
|
{22, nullptr, "GetAdditionalInfo"},
|
|
|
|
{23, nullptr, "SetKeptInSleep"},
|
|
|
|
{24, nullptr, "RegisterSocketDescriptor"},
|
|
|
|
{25, nullptr, "UnregisterSocketDescriptor"},
|
|
|
|
};
|
|
|
|
RegisterHandlers(functions);
|
2018-02-22 09:28:15 -05:00
|
|
|
|
2021-04-09 19:56:11 -04:00
|
|
|
Kernel::KAutoObject::Create(std::addressof(event1));
|
|
|
|
Kernel::KAutoObject::Create(std::addressof(event2));
|
|
|
|
|
2021-04-04 03:56:09 -04:00
|
|
|
event1.Initialize("IRequest:Event1");
|
|
|
|
event2.Initialize("IRequest:Event2");
|
2018-02-22 09:28:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2018-09-20 10:47:30 -04:00
|
|
|
void Submit(Kernel::HLERequestContext& ctx) {
|
|
|
|
LOG_WARNING(Service_NIFM, "(STUBBED) called");
|
2018-11-26 01:06:13 -05:00
|
|
|
|
2018-09-20 10:51:13 -04:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2021-05-21 01:05:04 -04:00
|
|
|
rb.Push(ResultSuccess);
|
2018-09-20 10:47:30 -04:00
|
|
|
}
|
|
|
|
|
2018-02-22 09:28:15 -05:00
|
|
|
void GetRequestState(Kernel::HLERequestContext& ctx) {
|
2018-07-02 12:13:26 -04:00
|
|
|
LOG_WARNING(Service_NIFM, "(STUBBED) called");
|
2018-11-26 01:06:13 -05:00
|
|
|
|
2018-02-22 09:28:15 -05:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
2021-05-21 01:05:04 -04:00
|
|
|
rb.Push(ResultSuccess);
|
2019-10-05 20:00:54 -04:00
|
|
|
|
2021-08-12 15:32:53 -04:00
|
|
|
if (Network::GetHostIPv4Address().has_value()) {
|
2019-10-05 20:00:54 -04:00
|
|
|
rb.PushEnum(RequestState::Connected);
|
2021-08-12 15:32:53 -04:00
|
|
|
} else {
|
|
|
|
rb.PushEnum(RequestState::NotSubmitted);
|
2019-10-05 20:00:54 -04:00
|
|
|
}
|
2018-02-02 06:31:27 -05:00
|
|
|
}
|
2018-06-05 18:43:43 -04:00
|
|
|
|
2018-02-22 09:28:15 -05:00
|
|
|
void GetResult(Kernel::HLERequestContext& ctx) {
|
2018-07-02 12:13:26 -04:00
|
|
|
LOG_WARNING(Service_NIFM, "(STUBBED) called");
|
2018-11-26 01:06:13 -05:00
|
|
|
|
2018-04-02 23:30:27 -04:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2021-05-21 01:05:04 -04:00
|
|
|
rb.Push(ResultSuccess);
|
2018-02-22 09:28:15 -05:00
|
|
|
}
|
2018-06-05 18:43:43 -04:00
|
|
|
|
2018-02-22 09:28:15 -05:00
|
|
|
void GetSystemEventReadableHandles(Kernel::HLERequestContext& ctx) {
|
2018-07-02 12:13:26 -04:00
|
|
|
LOG_WARNING(Service_NIFM, "(STUBBED) called");
|
2018-11-26 01:06:13 -05:00
|
|
|
|
2018-02-22 09:28:15 -05:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 2};
|
2021-05-21 01:05:04 -04:00
|
|
|
rb.Push(ResultSuccess);
|
2021-04-04 03:56:09 -04:00
|
|
|
rb.PushCopyObjects(event1.GetReadableEvent(), event2.GetReadableEvent());
|
2018-02-22 09:28:15 -05:00
|
|
|
}
|
2018-06-05 18:43:43 -04:00
|
|
|
|
2018-03-16 04:08:22 -04:00
|
|
|
void Cancel(Kernel::HLERequestContext& ctx) {
|
2018-07-02 12:13:26 -04:00
|
|
|
LOG_WARNING(Service_NIFM, "(STUBBED) called");
|
2018-11-26 01:06:13 -05:00
|
|
|
|
2018-03-16 04:08:22 -04:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2021-05-21 01:05:04 -04:00
|
|
|
rb.Push(ResultSuccess);
|
2018-03-16 04:08:22 -04:00
|
|
|
}
|
2018-02-22 09:28:15 -05:00
|
|
|
|
2018-06-05 18:43:43 -04:00
|
|
|
void SetConnectionConfirmationOption(Kernel::HLERequestContext& ctx) {
|
2018-07-02 12:13:26 -04:00
|
|
|
LOG_WARNING(Service_NIFM, "(STUBBED) called");
|
2018-11-26 01:06:13 -05:00
|
|
|
|
2018-06-05 18:43:43 -04:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2021-05-21 01:05:04 -04:00
|
|
|
rb.Push(ResultSuccess);
|
2018-06-05 18:43:43 -04:00
|
|
|
}
|
|
|
|
|
2020-07-21 00:06:52 -04:00
|
|
|
void GetAppletInfo(Kernel::HLERequestContext& ctx) {
|
|
|
|
LOG_WARNING(Service_NIFM, "(STUBBED) called");
|
|
|
|
|
2021-01-31 02:19:36 -05:00
|
|
|
std::vector<u8> out_buffer(ctx.GetWriteBufferSize());
|
|
|
|
|
|
|
|
ctx.WriteBuffer(out_buffer);
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 5};
|
2021-05-21 01:05:04 -04:00
|
|
|
rb.Push(ResultSuccess);
|
2020-10-20 01:45:01 -04:00
|
|
|
rb.Push<u32>(0);
|
|
|
|
rb.Push<u32>(0);
|
|
|
|
rb.Push<u32>(0);
|
2020-07-21 00:06:52 -04:00
|
|
|
}
|
|
|
|
|
2021-04-04 03:56:09 -04:00
|
|
|
Kernel::KEvent event1, event2;
|
2018-02-02 06:31:27 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
class INetworkProfile final : public ServiceFramework<INetworkProfile> {
|
|
|
|
public:
|
2020-11-26 15:19:08 -05:00
|
|
|
explicit INetworkProfile(Core::System& system_) : ServiceFramework{system_, "INetworkProfile"} {
|
2018-02-02 06:31:27 -05:00
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, nullptr, "Update"},
|
|
|
|
{1, nullptr, "PersistOld"},
|
|
|
|
{2, nullptr, "Persist"},
|
|
|
|
};
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-03-16 04:00:29 -04:00
|
|
|
class IGeneralService final : public ServiceFramework<IGeneralService> {
|
|
|
|
public:
|
2020-11-26 15:19:08 -05:00
|
|
|
explicit IGeneralService(Core::System& system_);
|
2018-03-16 04:00:29 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
void GetClientId(Kernel::HLERequestContext& ctx) {
|
2018-09-19 11:59:01 -04:00
|
|
|
static constexpr u32 client_id = 1;
|
2018-07-02 12:13:26 -04:00
|
|
|
LOG_WARNING(Service_NIFM, "(STUBBED) called");
|
2018-11-26 01:06:13 -05:00
|
|
|
|
2018-03-16 04:00:29 -04:00
|
|
|
IPC::ResponseBuilder rb{ctx, 4};
|
2021-05-21 01:05:04 -04:00
|
|
|
rb.Push(ResultSuccess);
|
2018-09-19 11:59:01 -04:00
|
|
|
rb.Push<u64>(client_id); // Client ID needs to be non zero otherwise it's considered invalid
|
2018-03-16 04:00:29 -04:00
|
|
|
}
|
|
|
|
void CreateScanRequest(Kernel::HLERequestContext& ctx) {
|
2018-11-26 01:06:13 -05:00
|
|
|
LOG_DEBUG(Service_NIFM, "called");
|
|
|
|
|
2018-03-16 04:00:29 -04:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
|
|
|
|
2021-05-21 01:05:04 -04:00
|
|
|
rb.Push(ResultSuccess);
|
2020-11-26 15:19:08 -05:00
|
|
|
rb.PushIpcInterface<IScanRequest>(system);
|
2018-03-16 04:00:29 -04:00
|
|
|
}
|
|
|
|
void CreateRequest(Kernel::HLERequestContext& ctx) {
|
2018-11-26 01:06:13 -05:00
|
|
|
LOG_DEBUG(Service_NIFM, "called");
|
|
|
|
|
2018-03-16 04:00:29 -04:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
|
|
|
|
2021-05-21 01:05:04 -04:00
|
|
|
rb.Push(ResultSuccess);
|
2019-09-21 05:07:13 -04:00
|
|
|
rb.PushIpcInterface<IRequest>(system);
|
2018-03-16 04:00:29 -04:00
|
|
|
}
|
2021-01-31 06:37:10 -05:00
|
|
|
void GetCurrentNetworkProfile(Kernel::HLERequestContext& ctx) {
|
|
|
|
LOG_WARNING(Service_NIFM, "(STUBBED) called");
|
|
|
|
|
|
|
|
const SfNetworkProfileData network_profile_data{
|
|
|
|
.ip_setting_data{
|
|
|
|
.ip_address_setting{
|
|
|
|
.is_automatic{true},
|
|
|
|
.current_address{192, 168, 1, 100},
|
|
|
|
.subnet_mask{255, 255, 255, 0},
|
|
|
|
.gateway{192, 168, 1, 1},
|
|
|
|
},
|
|
|
|
.dns_setting{
|
|
|
|
.is_automatic{true},
|
|
|
|
.primary_dns{1, 1, 1, 1},
|
|
|
|
.secondary_dns{1, 0, 0, 1},
|
|
|
|
},
|
|
|
|
.proxy_setting{
|
|
|
|
.enabled{false},
|
|
|
|
.port{},
|
|
|
|
.proxy_server{},
|
|
|
|
.automatic_auth_enabled{},
|
|
|
|
.user{},
|
|
|
|
.password{},
|
|
|
|
},
|
|
|
|
.mtu{1500},
|
|
|
|
},
|
|
|
|
.uuid{0xdeadbeef, 0xdeadbeef},
|
|
|
|
.network_name{"yuzu Network"},
|
|
|
|
.wireless_setting_data{
|
|
|
|
.ssid_length{12},
|
|
|
|
.ssid{"yuzu Network"},
|
|
|
|
.passphrase{"yuzupassword"},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
ctx.WriteBuffer(network_profile_data);
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2021-05-21 01:05:04 -04:00
|
|
|
rb.Push(ResultSuccess);
|
2021-01-31 06:37:10 -05:00
|
|
|
}
|
2018-03-16 04:00:29 -04:00
|
|
|
void RemoveNetworkProfile(Kernel::HLERequestContext& ctx) {
|
2018-07-02 12:13:26 -04:00
|
|
|
LOG_WARNING(Service_NIFM, "(STUBBED) called");
|
2018-11-26 01:06:13 -05:00
|
|
|
|
2018-03-16 04:00:29 -04:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2021-05-21 01:05:04 -04:00
|
|
|
rb.Push(ResultSuccess);
|
2018-03-16 04:00:29 -04:00
|
|
|
}
|
2020-07-11 20:43:51 -04:00
|
|
|
void GetCurrentIpAddress(Kernel::HLERequestContext& ctx) {
|
|
|
|
LOG_WARNING(Service_NIFM, "(STUBBED) called");
|
|
|
|
|
2021-08-12 15:32:53 -04:00
|
|
|
auto ipv4 = Network::GetHostIPv4Address();
|
|
|
|
if (!ipv4) {
|
2021-08-12 18:21:54 -04:00
|
|
|
LOG_ERROR(Service_NIFM, "Couldn't get host IPv4 address, defaulting to 0.0.0.0");
|
2021-08-12 15:32:53 -04:00
|
|
|
ipv4.emplace(Network::IPv4Address{0, 0, 0, 0});
|
|
|
|
}
|
2020-07-11 20:43:51 -04:00
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
2021-05-21 01:05:04 -04:00
|
|
|
rb.Push(ResultSuccess);
|
2021-08-12 18:24:33 -04:00
|
|
|
rb.PushRaw(*ipv4);
|
2020-07-11 20:43:51 -04:00
|
|
|
}
|
2018-03-16 04:00:29 -04:00
|
|
|
void CreateTemporaryNetworkProfile(Kernel::HLERequestContext& ctx) {
|
2018-11-26 01:06:13 -05:00
|
|
|
LOG_DEBUG(Service_NIFM, "called");
|
|
|
|
|
2020-05-21 04:43:55 -04:00
|
|
|
ASSERT_MSG(ctx.GetReadBufferSize() == 0x17c,
|
|
|
|
"SfNetworkProfileData is not the correct size");
|
2018-09-19 11:59:01 -04:00
|
|
|
u128 uuid{};
|
|
|
|
auto buffer = ctx.ReadBuffer();
|
|
|
|
std::memcpy(&uuid, buffer.data() + 8, sizeof(u128));
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 6, 0, 1};
|
2018-03-16 04:00:29 -04:00
|
|
|
|
2021-05-21 01:05:04 -04:00
|
|
|
rb.Push(ResultSuccess);
|
2020-11-26 15:19:08 -05:00
|
|
|
rb.PushIpcInterface<INetworkProfile>(system);
|
2018-09-19 11:59:01 -04:00
|
|
|
rb.PushRaw<u128>(uuid);
|
2018-03-16 04:00:29 -04:00
|
|
|
}
|
2021-01-31 06:47:49 -05:00
|
|
|
void GetCurrentIpConfigInfo(Kernel::HLERequestContext& ctx) {
|
|
|
|
LOG_WARNING(Service_NIFM, "(STUBBED) called");
|
|
|
|
|
|
|
|
struct IpConfigInfo {
|
2021-08-21 11:07:01 -04:00
|
|
|
IpAddressSetting ip_address_setting{};
|
|
|
|
DnsSetting dns_setting{};
|
2021-01-31 06:47:49 -05:00
|
|
|
};
|
|
|
|
static_assert(sizeof(IpConfigInfo) == sizeof(IpAddressSetting) + sizeof(DnsSetting),
|
|
|
|
"IpConfigInfo has incorrect size.");
|
|
|
|
|
2021-08-21 11:07:01 -04:00
|
|
|
const auto net_iface = Network::GetSelectedNetworkInterface();
|
2021-01-31 06:47:49 -05:00
|
|
|
|
2021-08-21 11:07:01 -04:00
|
|
|
const IpConfigInfo ip_config_info = [&net_iface] {
|
|
|
|
if (!net_iface) {
|
|
|
|
return IpConfigInfo{};
|
|
|
|
}
|
2021-08-16 04:32:25 -04:00
|
|
|
|
2021-08-21 11:07:01 -04:00
|
|
|
return IpConfigInfo{
|
|
|
|
.ip_address_setting{
|
|
|
|
.is_automatic{true},
|
|
|
|
.current_address{Network::TranslateIPv4(net_iface->ip_address)},
|
|
|
|
.subnet_mask{Network::TranslateIPv4(net_iface->subnet_mask)},
|
|
|
|
.gateway{Network::TranslateIPv4(net_iface->gateway)},
|
|
|
|
},
|
|
|
|
.dns_setting{
|
|
|
|
.is_automatic{true},
|
|
|
|
.primary_dns{1, 1, 1, 1},
|
|
|
|
.secondary_dns{1, 0, 0, 1},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}();
|
2021-08-16 04:32:25 -04:00
|
|
|
|
2021-05-13 09:00:46 -04:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2 + (sizeof(IpConfigInfo) + 3) / sizeof(u32)};
|
2021-05-21 01:05:04 -04:00
|
|
|
rb.Push(ResultSuccess);
|
2021-01-31 06:47:49 -05:00
|
|
|
rb.PushRaw<IpConfigInfo>(ip_config_info);
|
|
|
|
}
|
2018-07-12 02:40:17 -04:00
|
|
|
void IsWirelessCommunicationEnabled(Kernel::HLERequestContext& ctx) {
|
|
|
|
LOG_WARNING(Service_NIFM, "(STUBBED) called");
|
2018-11-26 01:06:13 -05:00
|
|
|
|
2018-07-12 02:40:17 -04:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
2021-05-21 01:05:04 -04:00
|
|
|
rb.Push(ResultSuccess);
|
2018-07-12 02:40:17 -04:00
|
|
|
rb.Push<u8>(0);
|
|
|
|
}
|
|
|
|
void IsEthernetCommunicationEnabled(Kernel::HLERequestContext& ctx) {
|
|
|
|
LOG_WARNING(Service_NIFM, "(STUBBED) called");
|
2018-11-26 01:06:13 -05:00
|
|
|
|
2018-07-12 02:40:17 -04:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
2021-05-21 01:05:04 -04:00
|
|
|
rb.Push(ResultSuccess);
|
2021-08-12 15:32:53 -04:00
|
|
|
if (Network::GetHostIPv4Address().has_value()) {
|
2019-10-05 20:00:54 -04:00
|
|
|
rb.Push<u8>(1);
|
2021-08-12 15:32:53 -04:00
|
|
|
} else {
|
|
|
|
rb.Push<u8>(0);
|
2019-10-05 20:00:54 -04:00
|
|
|
}
|
2018-07-12 02:40:17 -04:00
|
|
|
}
|
|
|
|
void IsAnyInternetRequestAccepted(Kernel::HLERequestContext& ctx) {
|
|
|
|
LOG_WARNING(Service_NIFM, "(STUBBED) called");
|
2018-11-26 01:06:13 -05:00
|
|
|
|
2018-07-12 02:40:17 -04:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
2021-05-21 01:05:04 -04:00
|
|
|
rb.Push(ResultSuccess);
|
2021-08-12 15:32:53 -04:00
|
|
|
if (Network::GetHostIPv4Address().has_value()) {
|
2019-10-05 20:00:54 -04:00
|
|
|
rb.Push<u8>(1);
|
2021-08-12 15:32:53 -04:00
|
|
|
} else {
|
|
|
|
rb.Push<u8>(0);
|
2019-10-05 20:00:54 -04:00
|
|
|
}
|
2018-07-12 02:40:17 -04:00
|
|
|
}
|
2018-03-16 04:00:29 -04:00
|
|
|
};
|
|
|
|
|
2020-11-26 15:19:08 -05:00
|
|
|
IGeneralService::IGeneralService(Core::System& system_)
|
|
|
|
: ServiceFramework{system_, "IGeneralService"} {
|
2019-11-12 08:54:58 -05:00
|
|
|
// clang-format off
|
2018-02-02 06:31:27 -05:00
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{1, &IGeneralService::GetClientId, "GetClientId"},
|
|
|
|
{2, &IGeneralService::CreateScanRequest, "CreateScanRequest"},
|
|
|
|
{4, &IGeneralService::CreateRequest, "CreateRequest"},
|
2021-01-31 06:37:10 -05:00
|
|
|
{5, &IGeneralService::GetCurrentNetworkProfile, "GetCurrentNetworkProfile"},
|
2018-03-16 09:34:12 -04:00
|
|
|
{6, nullptr, "EnumerateNetworkInterfaces"},
|
|
|
|
{7, nullptr, "EnumerateNetworkProfiles"},
|
2018-02-02 06:31:27 -05:00
|
|
|
{8, nullptr, "GetNetworkProfile"},
|
|
|
|
{9, nullptr, "SetNetworkProfile"},
|
|
|
|
{10, &IGeneralService::RemoveNetworkProfile, "RemoveNetworkProfile"},
|
|
|
|
{11, nullptr, "GetScanDataOld"},
|
2020-07-11 20:43:51 -04:00
|
|
|
{12, &IGeneralService::GetCurrentIpAddress, "GetCurrentIpAddress"},
|
2018-02-02 06:31:27 -05:00
|
|
|
{13, nullptr, "GetCurrentAccessPointOld"},
|
|
|
|
{14, &IGeneralService::CreateTemporaryNetworkProfile, "CreateTemporaryNetworkProfile"},
|
2021-01-31 06:47:49 -05:00
|
|
|
{15, &IGeneralService::GetCurrentIpConfigInfo, "GetCurrentIpConfigInfo"},
|
2018-02-02 06:31:27 -05:00
|
|
|
{16, nullptr, "SetWirelessCommunicationEnabled"},
|
2018-07-12 02:40:17 -04:00
|
|
|
{17, &IGeneralService::IsWirelessCommunicationEnabled, "IsWirelessCommunicationEnabled"},
|
2018-02-02 06:31:27 -05:00
|
|
|
{18, nullptr, "GetInternetConnectionStatus"},
|
|
|
|
{19, nullptr, "SetEthernetCommunicationEnabled"},
|
2018-07-12 02:40:17 -04:00
|
|
|
{20, &IGeneralService::IsEthernetCommunicationEnabled, "IsEthernetCommunicationEnabled"},
|
|
|
|
{21, &IGeneralService::IsAnyInternetRequestAccepted, "IsAnyInternetRequestAccepted"},
|
2018-02-02 06:31:27 -05:00
|
|
|
{22, nullptr, "IsAnyForegroundRequestAccepted"},
|
|
|
|
{23, nullptr, "PutToSleep"},
|
|
|
|
{24, nullptr, "WakeUp"},
|
|
|
|
{25, nullptr, "GetSsidListVersion"},
|
|
|
|
{26, nullptr, "SetExclusiveClient"},
|
|
|
|
{27, nullptr, "GetDefaultIpSetting"},
|
|
|
|
{28, nullptr, "SetDefaultIpSetting"},
|
|
|
|
{29, nullptr, "SetWirelessCommunicationEnabledForTest"},
|
|
|
|
{30, nullptr, "SetEthernetCommunicationEnabledForTest"},
|
|
|
|
{31, nullptr, "GetTelemetorySystemEventReadableHandle"},
|
|
|
|
{32, nullptr, "GetTelemetryInfo"},
|
|
|
|
{33, nullptr, "ConfirmSystemAvailability"},
|
|
|
|
{34, nullptr, "SetBackgroundRequestEnabled"},
|
|
|
|
{35, nullptr, "GetScanData"},
|
|
|
|
{36, nullptr, "GetCurrentAccessPoint"},
|
|
|
|
{37, nullptr, "Shutdown"},
|
2018-10-19 04:00:39 -04:00
|
|
|
{38, nullptr, "GetAllowedChannels"},
|
2019-11-12 08:54:58 -05:00
|
|
|
{39, nullptr, "NotifyApplicationSuspended"},
|
|
|
|
{40, nullptr, "SetAcceptableNetworkTypeFlag"},
|
|
|
|
{41, nullptr, "GetAcceptableNetworkTypeFlag"},
|
|
|
|
{42, nullptr, "NotifyConnectionStateChanged"},
|
|
|
|
{43, nullptr, "SetWowlDelayedWakeTime"},
|
2018-02-02 06:31:27 -05:00
|
|
|
};
|
2019-11-12 08:54:58 -05:00
|
|
|
// clang-format on
|
|
|
|
|
2018-02-02 06:31:27 -05:00
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
2018-07-25 17:07:32 -04:00
|
|
|
class NetworkInterface final : public ServiceFramework<NetworkInterface> {
|
|
|
|
public:
|
2020-11-26 15:19:08 -05:00
|
|
|
explicit NetworkInterface(const char* name, Core::System& system_)
|
|
|
|
: ServiceFramework{system_, name} {
|
2018-07-25 17:07:32 -04:00
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{4, &NetworkInterface::CreateGeneralServiceOld, "CreateGeneralServiceOld"},
|
|
|
|
{5, &NetworkInterface::CreateGeneralService, "CreateGeneralService"},
|
|
|
|
};
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
2018-02-02 06:31:27 -05:00
|
|
|
|
2020-11-26 15:19:08 -05:00
|
|
|
private:
|
2018-07-25 17:07:32 -04:00
|
|
|
void CreateGeneralServiceOld(Kernel::HLERequestContext& ctx) {
|
2018-11-26 01:06:13 -05:00
|
|
|
LOG_DEBUG(Service_NIFM, "called");
|
|
|
|
|
2018-07-25 17:07:32 -04:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
2021-05-21 01:05:04 -04:00
|
|
|
rb.Push(ResultSuccess);
|
2019-09-21 05:07:13 -04:00
|
|
|
rb.PushIpcInterface<IGeneralService>(system);
|
2018-07-25 17:07:32 -04:00
|
|
|
}
|
2018-02-02 06:31:27 -05:00
|
|
|
|
2018-07-25 17:07:32 -04:00
|
|
|
void CreateGeneralService(Kernel::HLERequestContext& ctx) {
|
2018-11-26 01:06:13 -05:00
|
|
|
LOG_DEBUG(Service_NIFM, "called");
|
|
|
|
|
2018-07-25 17:07:32 -04:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
2021-05-21 01:05:04 -04:00
|
|
|
rb.Push(ResultSuccess);
|
2019-09-21 05:07:13 -04:00
|
|
|
rb.PushIpcInterface<IGeneralService>(system);
|
2018-07-25 17:07:32 -04:00
|
|
|
}
|
|
|
|
};
|
2018-02-02 06:31:27 -05:00
|
|
|
|
2019-09-21 05:07:13 -04:00
|
|
|
void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) {
|
|
|
|
std::make_shared<NetworkInterface>("nifm:a", system)->InstallAsService(service_manager);
|
|
|
|
std::make_shared<NetworkInterface>("nifm:s", system)->InstallAsService(service_manager);
|
|
|
|
std::make_shared<NetworkInterface>("nifm:u", system)->InstallAsService(service_manager);
|
2018-02-02 06:31:27 -05:00
|
|
|
}
|
|
|
|
|
2018-04-19 21:41:44 -04:00
|
|
|
} // namespace Service::NIFM
|