net: net_if_list should return only active interfaces on win32
GetAdaptersAddresses lists all interfaces with any status. For example, unconnected
Interfaces return link local IPv4/IPv6 addresses. Since we are only interested
in "up" interfaces this commit checks for "IfOperStatusUp".
Refs:
*/
#include <winsock2.h>
#include <iphlpapi.h>
+#include <ifdef.h>
+
#include <re_types.h>
#include <re_fmt.h>
#include <re_net.h>
@@ -56,6 +58,9 @@ static int if_list_gaa(net_ifaddr_h *ifh, void *arg)
for (cur = addrv; cur && !stop; cur = cur->Next) {
PIP_ADAPTER_UNICAST_ADDRESS ip;
+ if (cur->OperStatus != IfOperStatusUp)
+ continue;
+
/* an interface can have many IP-addresses */
for (ip = cur->FirstUnicastAddress; ip; ip = ip->Next) {
struct sa sa;
