From 1e98e738283ccb81303d29305188ac825ecfcba9 Mon Sep 17 00:00:00 2001 From: spholz <44805808+spholz@users.noreply.github.com> Date: Thu, 12 Aug 2021 21:32:53 +0200 Subject: configuration: add option to select network interface This commit renames the "Services" tab to "Network" and adds a combobox that allows the user to select the network interface that yuzu should use. This new setting is now used to get the local IP address in Network::GetHostIPv4Address. This prevents yuzu from selecting the wrong network interface and thus using the wrong IP address. The return type of Network::GetHostIPv4Adress has also been changed. --- src/core/network/network.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/core/network/network.h') diff --git a/src/core/network/network.h b/src/core/network/network.h index bd30f1899..cfa68d478 100644 --- a/src/core/network/network.h +++ b/src/core/network/network.h @@ -5,6 +5,7 @@ #pragma once #include +#include #include #include "common/common_funcs.h" @@ -93,7 +94,7 @@ public: }; /// @brief Returns host's IPv4 address -/// @return Pair of an array of human ordered IPv4 address (e.g. 192.168.0.1) and an error code -std::pair GetHostIPv4Address(); +/// @return human ordered IPv4 address (e.g. 192.168.0.1) as an array +std::optional GetHostIPv4Address(); } // namespace Network -- cgit v1.2.3 From 70419f7a17880fd1e7834e7fe6e1aad14b0565bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Holz?= Date: Mon, 16 Aug 2021 10:32:25 +0200 Subject: network: retrieve subnet mask and gateway info --- src/core/network/network.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/core/network/network.h') diff --git a/src/core/network/network.h b/src/core/network/network.h index cfa68d478..fdd3e4655 100644 --- a/src/core/network/network.h +++ b/src/core/network/network.h @@ -11,6 +11,12 @@ #include "common/common_funcs.h" #include "common/common_types.h" +#ifdef _WIN32 +#include +#elif YUZU_UNIX +#include +#endif + namespace Network { class Socket; @@ -93,6 +99,19 @@ public: ~NetworkInstance(); }; +#ifdef _WIN32 +constexpr IPv4Address TranslateIPv4(in_addr addr) { + auto& bytes = addr.S_un.S_un_b; + return IPv4Address{bytes.s_b1, bytes.s_b2, bytes.s_b3, bytes.s_b4}; +} +#elif YUZU_UNIX +constexpr IPv4Address TranslateIPv4(in_addr addr) { + const u32 bytes = addr.s_addr; + return IPv4Address{static_cast(bytes), static_cast(bytes >> 8), + static_cast(bytes >> 16), static_cast(bytes >> 24)}; +} +#endif + /// @brief Returns host's IPv4 address /// @return human ordered IPv4 address (e.g. 192.168.0.1) as an array std::optional GetHostIPv4Address(); -- cgit v1.2.3