weskoerber / mac_address

A cross-platform library to retrieve the MAC address from your network interfaces without libc.
https://weskoerber.github.io/mac_address/
MIT License
2 stars 1 forks source link

chore: exclude devices that don't support ARP #13

Open weskoerber opened 2 months ago

weskoerber commented 2 months ago

Closes #9 closes #12

TODOs:

weskoerber commented 2 months ago

Windows has IfType in the IP_ADAPTER_ADDRESSES_LH structure; one of these values might indicate a layer 3+ device

The full IfType specification can be found in ipifcons.h (permalink).

The IfType value of my Tailscale device on my Windows 11 machine reports a value of 53:

#define IF_TYPE_PROP_VIRTUAL            53  // Proprietary virtual/internal
weskoerber commented 2 months ago

It seems that we'll have to get the ARP table and iterate each entry in the table, comparing it against the interface. Rough steps to make this work:

In one (confusing) sentence: Filter addresses returned from GetAdaptersAddresses having IfIndex that matches dwIndex in table returned from GetIpNetTable.