core: implement GetGaiStringErrorRequest, IContextRegistrar
This commit is contained in:
parent
3e4029b238
commit
3e3294e1c2
10 changed files with 115 additions and 5 deletions
|
@ -496,8 +496,9 @@ public:
|
||||||
void LoadIdTokenCache(HLERequestContext& ctx) {
|
void LoadIdTokenCache(HLERequestContext& ctx) {
|
||||||
LOG_WARNING(Service_ACC, "(STUBBED) called");
|
LOG_WARNING(Service_ACC, "(STUBBED) called");
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
|
rb.Push(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -2,13 +2,48 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include "core/hle/service/glue/ectx.h"
|
#include "core/hle/service/glue/ectx.h"
|
||||||
|
#include "core/hle/service/ipc_helpers.h"
|
||||||
|
|
||||||
namespace Service::Glue {
|
namespace Service::Glue {
|
||||||
|
|
||||||
|
// This is nn::err::context::IContextRegistrar
|
||||||
|
class IContextRegistrar : public ServiceFramework<IContextRegistrar> {
|
||||||
|
public:
|
||||||
|
IContextRegistrar(Core::System& system_) : ServiceFramework{system_, "IContextRegistrar"} {
|
||||||
|
// clang-format off
|
||||||
|
static const FunctionInfo functions[] = {
|
||||||
|
{0, &IContextRegistrar::Complete, "Complete"},
|
||||||
|
};
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
|
RegisterHandlers(functions);
|
||||||
|
}
|
||||||
|
|
||||||
|
~IContextRegistrar() override = default;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void Complete(HLERequestContext& ctx) {
|
||||||
|
struct InputParameters {
|
||||||
|
u32 unk;
|
||||||
|
};
|
||||||
|
struct OutputParameters {
|
||||||
|
u32 unk;
|
||||||
|
};
|
||||||
|
|
||||||
|
IPC::RequestParser rp{ctx};
|
||||||
|
[[maybe_unused]] auto input = rp.PopRaw<InputParameters>();
|
||||||
|
[[maybe_unused]] auto value = ctx.ReadBuffer();
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
|
rb.Push(ResultSuccess);
|
||||||
|
rb.Push(0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
ECTX_AW::ECTX_AW(Core::System& system_) : ServiceFramework{system_, "ectx:aw"} {
|
ECTX_AW::ECTX_AW(Core::System& system_) : ServiceFramework{system_, "ectx:aw"} {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{0, nullptr, "CreateContextRegistrar"},
|
{0, &ECTX_AW::CreateContextRegistrar, "CreateContextRegistrar"},
|
||||||
{1, nullptr, "CommitContext"},
|
{1, nullptr, "CommitContext"},
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
@ -18,4 +53,10 @@ ECTX_AW::ECTX_AW(Core::System& system_) : ServiceFramework{system_, "ectx:aw"} {
|
||||||
|
|
||||||
ECTX_AW::~ECTX_AW() = default;
|
ECTX_AW::~ECTX_AW() = default;
|
||||||
|
|
||||||
|
void ECTX_AW::CreateContextRegistrar(HLERequestContext& ctx) {
|
||||||
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||||
|
rb.Push(ResultSuccess);
|
||||||
|
rb.PushIpcInterface<IContextRegistrar>(std::make_shared<IContextRegistrar>(system));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Service::Glue
|
} // namespace Service::Glue
|
||||||
|
|
|
@ -15,6 +15,9 @@ class ECTX_AW final : public ServiceFramework<ECTX_AW> {
|
||||||
public:
|
public:
|
||||||
explicit ECTX_AW(Core::System& system_);
|
explicit ECTX_AW(Core::System& system_);
|
||||||
~ECTX_AW() override;
|
~ECTX_AW() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void CreateContextRegistrar(HLERequestContext& ctx);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Service::Glue
|
} // namespace Service::Glue
|
||||||
|
|
|
@ -559,7 +559,7 @@ std::pair<s32, Errno> BSD::PollImpl(std::vector<u8>& write_buffer, std::span<con
|
||||||
|
|
||||||
const std::optional<FileDescriptor>& descriptor = file_descriptors[pollfd.fd];
|
const std::optional<FileDescriptor>& descriptor = file_descriptors[pollfd.fd];
|
||||||
if (!descriptor) {
|
if (!descriptor) {
|
||||||
LOG_ERROR(Service, "File descriptor handle={} is not allocated", pollfd.fd);
|
LOG_TRACE(Service, "File descriptor handle={} is not allocated", pollfd.fd);
|
||||||
pollfd.revents = PollEvents::Nval;
|
pollfd.revents = PollEvents::Nval;
|
||||||
return {0, Errno::SUCCESS};
|
return {0, Errno::SUCCESS};
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ NSD::NSD(Core::System& system_, const char* name) : ServiceFramework{system_, na
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{5, nullptr, "GetSettingUrl"},
|
{5, nullptr, "GetSettingUrl"},
|
||||||
{10, nullptr, "GetSettingName"},
|
{10, nullptr, "GetSettingName"},
|
||||||
{11, nullptr, "GetEnvironmentIdentifier"},
|
{11, &NSD::GetEnvironmentIdentifier, "GetEnvironmentIdentifier"},
|
||||||
{12, nullptr, "GetDeviceId"},
|
{12, nullptr, "GetDeviceId"},
|
||||||
{13, nullptr, "DeleteSettings"},
|
{13, nullptr, "DeleteSettings"},
|
||||||
{14, nullptr, "ImportSettings"},
|
{14, nullptr, "ImportSettings"},
|
||||||
|
@ -103,6 +103,14 @@ void NSD::ResolveEx(HLERequestContext& ctx) {
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NSD::GetEnvironmentIdentifier(HLERequestContext& ctx) {
|
||||||
|
const std::string environment_identifier = "lp1";
|
||||||
|
ctx.WriteBuffer(environment_identifier);
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
|
rb.Push(ResultSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
void NSD::GetApplicationServerEnvironmentType(HLERequestContext& ctx) {
|
void NSD::GetApplicationServerEnvironmentType(HLERequestContext& ctx) {
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
|
|
|
@ -19,6 +19,7 @@ public:
|
||||||
private:
|
private:
|
||||||
void Resolve(HLERequestContext& ctx);
|
void Resolve(HLERequestContext& ctx);
|
||||||
void ResolveEx(HLERequestContext& ctx);
|
void ResolveEx(HLERequestContext& ctx);
|
||||||
|
void GetEnvironmentIdentifier(HLERequestContext& ctx);
|
||||||
void GetApplicationServerEnvironmentType(HLERequestContext& ctx);
|
void GetApplicationServerEnvironmentType(HLERequestContext& ctx);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ SFDNSRES::SFDNSRES(Core::System& system_) : ServiceFramework{system_, "sfdnsres"
|
||||||
{2, &SFDNSRES::GetHostByNameRequest, "GetHostByNameRequest"},
|
{2, &SFDNSRES::GetHostByNameRequest, "GetHostByNameRequest"},
|
||||||
{3, nullptr, "GetHostByAddrRequest"},
|
{3, nullptr, "GetHostByAddrRequest"},
|
||||||
{4, nullptr, "GetHostStringErrorRequest"},
|
{4, nullptr, "GetHostStringErrorRequest"},
|
||||||
{5, nullptr, "GetGaiStringErrorRequest"},
|
{5, &SFDNSRES::GetGaiStringErrorRequest, "GetGaiStringErrorRequest"},
|
||||||
{6, &SFDNSRES::GetAddrInfoRequest, "GetAddrInfoRequest"},
|
{6, &SFDNSRES::GetAddrInfoRequest, "GetAddrInfoRequest"},
|
||||||
{7, nullptr, "GetNameInfoRequest"},
|
{7, nullptr, "GetNameInfoRequest"},
|
||||||
{8, nullptr, "RequestCancelHandleRequest"},
|
{8, nullptr, "RequestCancelHandleRequest"},
|
||||||
|
@ -300,6 +300,20 @@ void SFDNSRES::GetAddrInfoRequest(HLERequestContext& ctx) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SFDNSRES::GetGaiStringErrorRequest(HLERequestContext& ctx) {
|
||||||
|
struct InputParameters {
|
||||||
|
GetAddrInfoError gai_errno;
|
||||||
|
};
|
||||||
|
IPC::RequestParser rp{ctx};
|
||||||
|
auto input = rp.PopRaw<InputParameters>();
|
||||||
|
|
||||||
|
const std::string result = Translate(input.gai_errno);
|
||||||
|
ctx.WriteBuffer(result);
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
|
rb.Push(ResultSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
void SFDNSRES::GetAddrInfoRequestWithOptions(HLERequestContext& ctx) {
|
void SFDNSRES::GetAddrInfoRequestWithOptions(HLERequestContext& ctx) {
|
||||||
// Additional options are ignored
|
// Additional options are ignored
|
||||||
auto [data_size, emu_gai_err] = GetAddrInfoRequestImpl(ctx);
|
auto [data_size, emu_gai_err] = GetAddrInfoRequestImpl(ctx);
|
||||||
|
|
|
@ -18,6 +18,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void GetHostByNameRequest(HLERequestContext& ctx);
|
void GetHostByNameRequest(HLERequestContext& ctx);
|
||||||
|
void GetGaiStringErrorRequest(HLERequestContext& ctx);
|
||||||
void GetHostByNameRequestWithOptions(HLERequestContext& ctx);
|
void GetHostByNameRequestWithOptions(HLERequestContext& ctx);
|
||||||
void GetAddrInfoRequest(HLERequestContext& ctx);
|
void GetAddrInfoRequest(HLERequestContext& ctx);
|
||||||
void GetAddrInfoRequestWithOptions(HLERequestContext& ctx);
|
void GetAddrInfoRequestWithOptions(HLERequestContext& ctx);
|
||||||
|
|
|
@ -81,6 +81,44 @@ GetAddrInfoError Translate(Network::GetAddrInfoError error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* Translate(GetAddrInfoError error) {
|
||||||
|
// https://android.googlesource.com/platform/bionic/+/085543106/libc/dns/net/getaddrinfo.c#254
|
||||||
|
switch (error) {
|
||||||
|
case GetAddrInfoError::SUCCESS:
|
||||||
|
return "Success";
|
||||||
|
case GetAddrInfoError::ADDRFAMILY:
|
||||||
|
return "Address family for hostname not supported";
|
||||||
|
case GetAddrInfoError::AGAIN:
|
||||||
|
return "Temporary failure in name resolution";
|
||||||
|
case GetAddrInfoError::BADFLAGS:
|
||||||
|
return "Invalid value for ai_flags";
|
||||||
|
case GetAddrInfoError::FAIL:
|
||||||
|
return "Non-recoverable failure in name resolution";
|
||||||
|
case GetAddrInfoError::FAMILY:
|
||||||
|
return "ai_family not supported";
|
||||||
|
case GetAddrInfoError::MEMORY:
|
||||||
|
return "Memory allocation failure";
|
||||||
|
case GetAddrInfoError::NODATA:
|
||||||
|
return "No address associated with hostname";
|
||||||
|
case GetAddrInfoError::NONAME:
|
||||||
|
return "hostname nor servname provided, or not known";
|
||||||
|
case GetAddrInfoError::SERVICE:
|
||||||
|
return "servname not supported for ai_socktype";
|
||||||
|
case GetAddrInfoError::SOCKTYPE:
|
||||||
|
return "ai_socktype not supported";
|
||||||
|
case GetAddrInfoError::SYSTEM:
|
||||||
|
return "System error returned in errno";
|
||||||
|
case GetAddrInfoError::BADHINTS:
|
||||||
|
return "Invalid value for hints";
|
||||||
|
case GetAddrInfoError::PROTOCOL:
|
||||||
|
return "Resolved protocol is unknown";
|
||||||
|
case GetAddrInfoError::OVERFLOW_:
|
||||||
|
return "Argument buffer overflow";
|
||||||
|
default:
|
||||||
|
return "Unknown error";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Network::Domain Translate(Domain domain) {
|
Network::Domain Translate(Domain domain) {
|
||||||
switch (domain) {
|
switch (domain) {
|
||||||
case Domain::Unspecified:
|
case Domain::Unspecified:
|
||||||
|
|
|
@ -20,6 +20,9 @@ std::pair<s32, Errno> Translate(std::pair<s32, Network::Errno> value);
|
||||||
/// Translate abstract getaddrinfo error to guest getaddrinfo error
|
/// Translate abstract getaddrinfo error to guest getaddrinfo error
|
||||||
GetAddrInfoError Translate(Network::GetAddrInfoError value);
|
GetAddrInfoError Translate(Network::GetAddrInfoError value);
|
||||||
|
|
||||||
|
/// Translate guest error to string
|
||||||
|
const char* Translate(GetAddrInfoError value);
|
||||||
|
|
||||||
/// Translate guest domain to abstract domain
|
/// Translate guest domain to abstract domain
|
||||||
Network::Domain Translate(Domain domain);
|
Network::Domain Translate(Domain domain);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue