IP/Top: Add Android network interface

This commit is contained in:
Sepalani committed 2020-11-27 19:10:28 +04:00
1 parent 26302c2257
commit 20ebed51bb
7 files changed
+204 -2

No files matched your search

+13 -2
View File
@@ -50,6 +50,10 @@
#include <unistd.h>
#endif
#ifdef __ANDROID__
#include "jni/AndroidCommon/AndroidCommon.h"
#endif
namespace IOS::HLE::Device
{
enum SOResultCode : s32
@@ -217,7 +221,14 @@ static std::optional<DefaultInterface> GetSystemDefaultInterface()
return DefaultInterface{entry.dwAddr, entry.dwMask, entry.dwBCastAddr};
}
}
#elif !defined(__ANDROID__)
#elif defined(__ANDROID__)
const u32 addr = GetNetworkIpAddress();
const u32 prefix_length = GetNetworkPrefixLength();
const u32 netmask = (1 << prefix_length) - 1;
const u32 gateway = GetNetworkGateway();
if (addr || netmask || gateway)
return DefaultInterface{addr, netmask, gateway};
#else
// Assume that the address that is used to access the Internet corresponds
// to the default interface.
auto get_default_address = []() -> std::optional<in_addr> {
@@ -261,7 +272,7 @@ static std::optional<DefaultInterface> GetSystemDefaultInterface()
}
}
#endif
return {};
return std::nullopt;
}
static DefaultInterface GetSystemDefaultInterfaceOrFallback()