Skip to content

Commit

Permalink
Fix 'RemoveDefGwOnDhcpForLocalhost' function: Change to exclude unplu…
Browse files Browse the repository at this point in the history
…gged device from MAC address list.
  • Loading branch information
hiura committed Mar 31, 2024
1 parent e8c14cb commit 9720356
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Mayaqua/Microsoft.c
Original file line number Diff line number Diff line change
Expand Up @@ -2568,6 +2568,7 @@ MS_ADAPTER_LIST *MsCreateAdapterListInnerExVista(bool no_info)
UniStrCpy(a->TitleW, sizeof(a->TitleW), title);
UniToStr(a->Title, sizeof(a->Title), title);
a->Index = r->InterfaceIndex;
a->MediaConnectState = r->MediaConnectState;
a->Type = r->Type;
a->Status = ConvertMidStatusVistaToXp(r->OperStatus);
a->Mtu = r->Mtu;
Expand Down
1 change: 1 addition & 0 deletions src/Mayaqua/Microsoft.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ typedef struct MS_ADAPTER
char Title[MAX_PATH]; // Display name
wchar_t TitleW[MAX_PATH]; // Display Name (Unicode)
UINT Index; // Index
UINT MediaConnectState; // Media Connect State
UINT Type; // Type
UINT Status; // Status
UINT Mtu; // MTU
Expand Down
7 changes: 7 additions & 0 deletions src/Mayaqua/Network.c
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,13 @@ LIST *Win32GetNicList()

if (a->Type == 6 && a->AddressSize == 6)
{
// If the connection state of the interface is unknown, then exclude it.
// Unknown means that the device is not plugged into the local host.
if (a->MediaConnectState == MediaConnectStateUnknown)
{
continue;
}

NIC_ENTRY *e = ZeroMalloc(sizeof(NIC_ENTRY));

StrCpy(e->IfName, sizeof(e->IfName), a->Title);
Expand Down

0 comments on commit 9720356

Please sign in to comment.