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