network: narrow down scope of "result" in win32 code for
GetAvailableNetworkInterfaces
This commit is contained in:
parent
04ec426201
commit
8513e59431
|
@ -22,8 +22,6 @@ namespace Network {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
std::vector<NetworkInterface> GetAvailableNetworkInterfaces() {
|
std::vector<NetworkInterface> GetAvailableNetworkInterfaces() {
|
||||||
std::vector<NetworkInterface> result;
|
|
||||||
|
|
||||||
std::vector<u8> adapter_addresses_raw;
|
std::vector<u8> adapter_addresses_raw;
|
||||||
auto adapter_addresses = reinterpret_cast<PIP_ADAPTER_ADDRESSES>(adapter_addresses_raw.data());
|
auto adapter_addresses = reinterpret_cast<PIP_ADAPTER_ADDRESSES>(adapter_addresses_raw.data());
|
||||||
DWORD ret = ERROR_BUFFER_OVERFLOW;
|
DWORD ret = ERROR_BUFFER_OVERFLOW;
|
||||||
|
@ -44,6 +42,8 @@ std::vector<NetworkInterface> GetAvailableNetworkInterfaces() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret == NO_ERROR) {
|
if (ret == NO_ERROR) {
|
||||||
|
std::vector<NetworkInterface> result;
|
||||||
|
|
||||||
for (auto current_address = adapter_addresses; current_address != nullptr;
|
for (auto current_address = adapter_addresses; current_address != nullptr;
|
||||||
current_address = current_address->Next) {
|
current_address = current_address->Next) {
|
||||||
if (current_address->FirstUnicastAddress == nullptr ||
|
if (current_address->FirstUnicastAddress == nullptr ||
|
||||||
|
@ -63,11 +63,12 @@ std::vector<NetworkInterface> GetAvailableNetworkInterfaces() {
|
||||||
.name{Common::UTF16ToUTF8(std::wstring{current_address->FriendlyName})},
|
.name{Common::UTF16ToUTF8(std::wstring{current_address->FriendlyName})},
|
||||||
.ip_address{ip_addr}});
|
.ip_address{ip_addr}});
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
LOG_ERROR(Network, "Failed to get network interfaces with GetAdaptersAddresses");
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
} else {
|
||||||
|
LOG_ERROR(Network, "Failed to get network interfaces with GetAdaptersAddresses");
|
||||||
|
return {};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Reference in New Issue