From 56285ec0d47191f61f7b551747203b6e8f933a36 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Mon, 6 Jul 2015 17:58:04 -0700 Subject: [PATCH] Another attempt at a fix for all the Windows driver coma issues. --- osdep/WindowsEthernetTap.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/osdep/WindowsEthernetTap.cpp b/osdep/WindowsEthernetTap.cpp index d477f2e3d..b2d3ed8b8 100644 --- a/osdep/WindowsEthernetTap.cpp +++ b/osdep/WindowsEthernetTap.cpp @@ -692,17 +692,20 @@ void WindowsEthernetTap::threadMain() ULONGLONG tc = GetTickCount64(); if ((tc - timeOfLastBorkCheck) >= 2500) { timeOfLastBorkCheck = tc; - MIB_IF_TABLE2 *ift = NULL; - if ((GetIfTable2(&ift) == NO_ERROR)&&(ift)) { + char aabuf[16384]; + ULONG aalen = sizeof(aabuf); + if (GetAdaptersAddresses(AF_UNSPEC,GAA_FLAG_SKIP_UNICAST|GAA_FLAG_SKIP_ANYCAST|GAA_FLAG_SKIP_MULTICAST|GAA_FLAG_SKIP_DNS_SERVER|GAA_FLAG_SKIP_FRIENDLY_NAME,(void *)0,reinterpret_cast(aabuf),&aalen) == NO_ERROR) { bool isBorked = false; - for(ULONG r=0;rNumEntries;++r) { - if (ift->Table[r].InterfaceLuid.Value == _deviceLuid.Value) { - if ((ift->Table[r].InterfaceAndOperStatusFlags.NotMediaConnected)||(ift->Table[r].MediaConnectState == MediaConnectStateDisconnected)) - isBorked = true; + + PIP_ADAPTER_ADDRESSES aa = reinterpret_cast(aabuf); + while (aa) { + if (_deviceLuid.Value == aa->Luid.Value) { + isBorked = (aa->OperStatus != IfOperStatusUp); break; } + aa = aa->Next; } - FreeMibTable(ift); + if (isBorked) { // Close and reopen tap device if there's an issue (outer loop) break;