mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2025-07-20 08:15:46 +00:00
[nifm, bsd] add airplane mode functionality to a new nifm call and fix local files (#225)
There is a cmd `IsAnyInternetRequestAccepted` which is called by games like DOOM to check if internet access is available. Adds the newly added airplane mode there. Also, moved down the airplane mode check on bsd to also check if it's a local file request, if it is, let it connect. (SMO guide web applet for example) + adds a check in IRequest if airplane mode is active, which then results in an not succeeding requests. Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/225 Co-authored-by: Maufeat <sahyno1996@gmail.com> Co-committed-by: Maufeat <sahyno1996@gmail.com>
This commit is contained in:
parent
c88d0b3967
commit
726e1e756d
4 changed files with 21 additions and 18 deletions
|
@ -428,7 +428,8 @@ private:
|
||||||
LOG_WARNING(Service_NIFM, "(STUBBED) called");
|
LOG_WARNING(Service_NIFM, "(STUBBED) called");
|
||||||
|
|
||||||
const auto result = [this] {
|
const auto result = [this] {
|
||||||
const auto has_connection = Network::GetHostIPv4Address().has_value();
|
const auto has_connection = Network::GetHostIPv4Address().has_value() &&
|
||||||
|
!Settings::values.airplane_mode.GetValue();
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case RequestState::NotSubmitted:
|
case RequestState::NotSubmitted:
|
||||||
return has_connection ? ResultSuccess : ResultNetworkCommunicationDisabled;
|
return has_connection ? ResultSuccess : ResultNetworkCommunicationDisabled;
|
||||||
|
@ -947,7 +948,7 @@ void IGeneralService::IsEthernetCommunicationEnabled(HLERequestContext& ctx) {
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
if (Network::GetHostIPv4Address().has_value()) {
|
if (Network::GetHostIPv4Address().has_value() && !Settings::values.airplane_mode.GetValue()) {
|
||||||
rb.Push<u8>(1);
|
rb.Push<u8>(1);
|
||||||
} else {
|
} else {
|
||||||
rb.Push<u8>(0);
|
rb.Push<u8>(0);
|
||||||
|
@ -959,7 +960,7 @@ void IGeneralService::IsAnyInternetRequestAccepted(HLERequestContext& ctx) {
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
if (Network::GetHostIPv4Address().has_value()) {
|
if (Network::GetHostIPv4Address().has_value() && !Settings::values.airplane_mode.GetValue()) {
|
||||||
rb.Push<u8>(1);
|
rb.Push<u8>(1);
|
||||||
} else {
|
} else {
|
||||||
rb.Push<u8>(0);
|
rb.Push<u8>(0);
|
||||||
|
|
|
@ -491,11 +491,6 @@ void BSD::ExecuteWork(HLERequestContext& ctx, Work work) {
|
||||||
|
|
||||||
std::pair<s32, Errno> BSD::SocketImpl(Domain domain, Type type, Protocol protocol) {
|
std::pair<s32, Errno> BSD::SocketImpl(Domain domain, Type type, Protocol protocol) {
|
||||||
|
|
||||||
if (Settings::values.airplane_mode.GetValue()) {
|
|
||||||
LOG_ERROR(Service, "Airplane mode is enabled, cannot create socket");
|
|
||||||
return {-1, Errno::NOTCONN};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type == Type::SEQPACKET) {
|
if (type == Type::SEQPACKET) {
|
||||||
UNIMPLEMENTED_MSG("SOCK_SEQPACKET errno management");
|
UNIMPLEMENTED_MSG("SOCK_SEQPACKET errno management");
|
||||||
} else if (type == Type::RAW && (domain != Domain::INET || protocol != Protocol::ICMP)) {
|
} else if (type == Type::RAW && (domain != Domain::INET || protocol != Protocol::ICMP)) {
|
||||||
|
@ -528,6 +523,11 @@ std::pair<s32, Errno> BSD::SocketImpl(Domain domain, Type type, Protocol protoco
|
||||||
descriptor.socket->Initialize(Translate(domain), Translate(type), Translate(protocol));
|
descriptor.socket->Initialize(Translate(domain), Translate(type), Translate(protocol));
|
||||||
descriptor.is_connection_based = IsConnectionBased(type);
|
descriptor.is_connection_based = IsConnectionBased(type);
|
||||||
|
|
||||||
|
if (Settings::values.airplane_mode.GetValue() && descriptor.is_connection_based) {
|
||||||
|
LOG_ERROR(Service, "Airplane mode is enabled, cannot create socket");
|
||||||
|
return {-1, Errno::NOTCONN};
|
||||||
|
}
|
||||||
|
|
||||||
return {fd, Errno::SUCCESS};
|
return {fd, Errno::SUCCESS};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,20 +11,22 @@
|
||||||
|
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
namespace Network {
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define NOMINMAX
|
#define NOMINMAX
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <wlanapi.h>
|
#include <wlanapi.h>
|
||||||
#pragma comment(lib, "wlanapi.lib")
|
#pragma comment(lib, "wlanapi.lib")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace Network {
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
static u8 QualityToPercent(DWORD q) {
|
static u8 QualityToPercent(DWORD q) {
|
||||||
return static_cast<u8>(q);
|
return static_cast<u8>(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::vector<ScanData> ScanWifiWin(std::chrono::milliseconds deadline) {
|
static std::vector<Network::ScanData> ScanWifiWin(std::chrono::milliseconds deadline) {
|
||||||
std::vector<ScanData> out;
|
std::vector<Network::ScanData> out;
|
||||||
|
|
||||||
HANDLE hClient{};
|
HANDLE hClient{};
|
||||||
DWORD ver{};
|
DWORD ver{};
|
||||||
|
@ -57,7 +59,7 @@ static std::vector<ScanData> ScanWifiWin(std::chrono::milliseconds deadline) {
|
||||||
|
|
||||||
for (DWORD n = 0; n < list->dwNumberOfItems; ++n) {
|
for (DWORD n = 0; n < list->dwNumberOfItems; ++n) {
|
||||||
const auto& nw = list->Network[n];
|
const auto& nw = list->Network[n];
|
||||||
ScanData sd{};
|
Network::ScanData sd{};
|
||||||
sd.ssid_len = static_cast<u8>(nw.dot11Ssid.uSSIDLength);
|
sd.ssid_len = static_cast<u8>(nw.dot11Ssid.uSSIDLength);
|
||||||
std::memcpy(sd.ssid, nw.dot11Ssid.ucSSID, sd.ssid_len);
|
std::memcpy(sd.ssid, nw.dot11Ssid.ucSSID, sd.ssid_len);
|
||||||
sd.quality = QualityToPercent(nw.wlanSignalQuality);
|
sd.quality = QualityToPercent(nw.wlanSignalQuality);
|
||||||
|
@ -112,8 +114,8 @@ static int wifi_callback(int skfd, char* ifname, char* args[], int count)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(crueter, Maufeat): Check if driver supports wireless extensions, fallback to nl80211 if not
|
// TODO(crueter, Maufeat): Check if driver supports wireless extensions, fallback to nl80211 if not
|
||||||
static std::vector<ScanData> ScanWifiLinux(std::chrono::milliseconds deadline) {
|
static std::vector<Network::ScanData> ScanWifiLinux(std::chrono::milliseconds deadline) {
|
||||||
std::vector<ScanData> out;
|
std::vector<Network::ScanData> out;
|
||||||
int sock = iw_sockets_open();
|
int sock = iw_sockets_open();
|
||||||
if (sock < 0) {
|
if (sock < 0) {
|
||||||
LOG_ERROR(Network, "iw_sockets_open() failed");
|
LOG_ERROR(Network, "iw_sockets_open() failed");
|
||||||
|
@ -152,7 +154,7 @@ static std::vector<ScanData> ScanWifiLinux(std::chrono::milliseconds deadline) {
|
||||||
if (!ws->b.has_essid)
|
if (!ws->b.has_essid)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ScanData sd{};
|
Network::ScanData sd{};
|
||||||
sd.ssid_len = static_cast<u8>(std::min<int>(ws->b.essid_len, 0x20));
|
sd.ssid_len = static_cast<u8>(std::min<int>(ws->b.essid_len, 0x20));
|
||||||
std::memcpy(sd.ssid, ws->b.essid, sd.ssid_len);
|
std::memcpy(sd.ssid, ws->b.essid, sd.ssid_len);
|
||||||
sd.quality = QualityToPercent(range, ws);
|
sd.quality = QualityToPercent(range, ws);
|
||||||
|
@ -172,7 +174,7 @@ static std::vector<ScanData> ScanWifiLinux(std::chrono::milliseconds deadline) {
|
||||||
}
|
}
|
||||||
#endif /* linux */
|
#endif /* linux */
|
||||||
|
|
||||||
std::vector<ScanData> ScanWifiNetworks(std::chrono::milliseconds deadline) {
|
std::vector<Network::ScanData> ScanWifiNetworks(std::chrono::milliseconds deadline) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
return ScanWifiWin(deadline);
|
return ScanWifiWin(deadline);
|
||||||
#elif defined(__linux__) && !defined(ANDROID)
|
#elif defined(__linux__) && !defined(ANDROID)
|
||||||
|
|
|
@ -18,5 +18,5 @@ struct ScanData {
|
||||||
};
|
};
|
||||||
static_assert(sizeof(ScanData) <= 0x2C, "ScanData layout changed – update conversions!");
|
static_assert(sizeof(ScanData) <= 0x2C, "ScanData layout changed – update conversions!");
|
||||||
|
|
||||||
std::vector<ScanData> ScanWifiNetworks(std::chrono::milliseconds deadline);
|
std::vector<Network::ScanData> ScanWifiNetworks(std::chrono::milliseconds deadline);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue