mirror of
https://github.com/skyline-emu/skyline.git
synced 2025-01-07 08:48:13 +01:00
Stub correctly some nifm calls
This commit is contained in:
parent
37a68b41f1
commit
635f06bf50
@ -3,6 +3,7 @@
|
||||
|
||||
#include <kernel/types/KProcess.h>
|
||||
#include "IRequest.h"
|
||||
#include <common/settings.h>
|
||||
|
||||
namespace skyline::service::nifm {
|
||||
namespace result {
|
||||
@ -15,8 +16,10 @@ namespace skyline::service::nifm {
|
||||
BaseService(state, manager) {}
|
||||
|
||||
Result IRequest::GetRequestState(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||
constexpr u32 Unsubmitted{1}; //!< The request has not been submitted
|
||||
response.Push<u32>(Unsubmitted);
|
||||
if (*state.settings->isInternetEnabled)
|
||||
response.Push(RequestState::Accepted);
|
||||
else
|
||||
response.Push(RequestState::Invalid);
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -36,6 +39,10 @@ namespace skyline::service::nifm {
|
||||
return {};
|
||||
}
|
||||
|
||||
Result IRequest::Cancel(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||
return {};
|
||||
}
|
||||
|
||||
Result IRequest::Submit(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||
return {};
|
||||
}
|
||||
|
@ -7,6 +7,17 @@
|
||||
#include <services/serviceman.h>
|
||||
|
||||
namespace skyline::service::nifm {
|
||||
/**
|
||||
* @url https://switchbrew.org/wiki/Network_Interface_services#RequestState
|
||||
*/
|
||||
enum class RequestState : u32 {
|
||||
Invalid = 0,
|
||||
Free = 1,
|
||||
OnHold = 2,
|
||||
Accepted = 3,
|
||||
Blocking = 4,
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief IRequest is used by applications to bring up a network
|
||||
* @url https://switchbrew.org/wiki/Network_Interface_services#IRequest
|
||||
@ -37,6 +48,11 @@ namespace skyline::service::nifm {
|
||||
*/
|
||||
Result GetSystemEventReadableHandles(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
|
||||
|
||||
/**
|
||||
* @url https://switchbrew.org/wiki/Network_Interface_services#Cancel
|
||||
*/
|
||||
Result Cancel(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
|
||||
|
||||
/**
|
||||
* @brief Submits a request to bring up a network
|
||||
* @url https://switchbrew.org/wiki/Network_Interface_services#Submit
|
||||
@ -57,9 +73,10 @@ namespace skyline::service::nifm {
|
||||
SFUNC(0x0, IRequest, GetRequestState),
|
||||
SFUNC(0x1, IRequest, GetResult),
|
||||
SFUNC(0x2, IRequest, GetSystemEventReadableHandles),
|
||||
SFUNC(0x3, IRequest, Cancel),
|
||||
SFUNC(0x4, IRequest, Submit),
|
||||
SFUNC(0xB, IRequest, SetConnectionConfirmationOption),
|
||||
SFUNC(0x15, IRequest, GetAppletInfo)
|
||||
)
|
||||
)
|
||||
};
|
||||
}
|
||||
|
@ -6,6 +6,19 @@
|
||||
#include <common/settings.h>
|
||||
|
||||
namespace skyline::service::socket {
|
||||
static NetDbError AddrInfoErrorToNetDbError(i32 result) {
|
||||
switch (result) {
|
||||
case 0:
|
||||
return NetDbError::Success;
|
||||
case EAI_AGAIN:
|
||||
return NetDbError::TryAgain;
|
||||
case EAI_NODATA:
|
||||
return NetDbError::NoData;
|
||||
default:
|
||||
return NetDbError::HostNotFound;
|
||||
}
|
||||
}
|
||||
|
||||
IResolver::IResolver(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager) {}
|
||||
|
||||
Result IResolver::GetAddrInfoRequest(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||
@ -42,12 +55,12 @@ namespace skyline::service::socket {
|
||||
return {0, -1};
|
||||
}
|
||||
|
||||
addrinfo* result;
|
||||
addrinfo *result;
|
||||
i32 resultCode = getaddrinfo(hostname.data(), service.data(), nullptr, &result);
|
||||
|
||||
u32 dataSize{0};
|
||||
if (resultCode == 0 && result != nullptr) {
|
||||
const std::vector<u8>& data = SerializeAddrInfo(result, resultCode, hostname);
|
||||
const std::vector<u8> data = SerializeAddrInfo(result, resultCode, hostname);
|
||||
dataSize = static_cast<u32>(data.size());
|
||||
request.outputBuf.at(0).copy_from(data);
|
||||
freeaddrinfo(result);
|
||||
@ -161,17 +174,4 @@ namespace skyline::service::socket {
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
NetDbError IResolver::AddrInfoErrorToNetDbError(i32 result) {
|
||||
switch (result) {
|
||||
case 0:
|
||||
return NetDbError::Success;
|
||||
case EAI_AGAIN:
|
||||
return NetDbError::TryAgain;
|
||||
case EAI_NODATA:
|
||||
return NetDbError::NoData;
|
||||
default:
|
||||
return NetDbError::HostNotFound;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,8 +38,6 @@ namespace skyline::service::socket {
|
||||
|
||||
std::vector<u8> SerializeAddrInfo(const addrinfo* addrinfo, i32 result_code, std::string_view host);
|
||||
|
||||
NetDbError AddrInfoErrorToNetDbError(i32 result);
|
||||
|
||||
SERVICE_DECL(
|
||||
SFUNC(0x6, IResolver, GetAddrInfoRequest),
|
||||
SFUNC(0xA, IResolver, GetHostByNameRequestWithOptions),
|
||||
|
Loading…
Reference in New Issue
Block a user