[Winpcap-users] How to get local MAC address ?

Wentao Shang wentaoshang at gmail.com
Mon Sep 12 02:27:18 PDT 2011


David is correct.

GetAdaptersInfo is obsolete since Windows XP and people should use
GetAdaptersAddresses now.

The field 'PhysicalAddress' and 'PhysicalAddressLength' in the
'IP_ADAPTER_ADDRESSES' struct correspond to the MAC address of the
device. The 'PhysicalAddressLength' value should equal to 6 for
Ethernet adapters.

See http://msdn.microsoft.com/en-us/library/aa366058(v=VS.85).aspx for
more info.:)

Regards.

Wentao

2011/9/12 "Fish" (David B. Trout) <fish at infidels.org>:
> Mark Pizzolato wrote:
>> Fish wrote:
>> >
>> > http://msdn.microsoft.com/en-us/library/aa365915(v=vs.85).aspx
>> >
>>
>> That reference shows how to determine IP addresses not MAC addresses.
>
> Incorrect.
>
> It shows how to retrieve a linked list of 'IP_ADAPTER_ADDRESSES' structures,
> one field of which happens to be the hardware address.  It most certainly is
> not ONLY for determining protocol addresses.
>
> The old "GetAdaptersInfo" API is what you previously had to use, which
> returned 'IP_ADAPTER_INFO' structures. But it only returned information for
> adapters which has an IPv4 IP address associated with them, and not any with
> IPv6 addresses assigned.:
>
>  http://msdn.microsoft.com/en-us/library/aa365917(VS.85).aspx
>  http://msdn.microsoft.com/en-us/library/aa366062(v=VS.85).aspx
>
>
> The "GetAdaptersAddresses" API was designed to replace the "GetAdaptersInfo"
> API. It returns MUCH MORE information than GetAdaptersInfo ever did, and it
> does so for ALL adapters, *regardless* of whether or not an IPv4 and/or IPv6
> protocol address is assigned to it.
>
> You're wrong.
>
> The "GetAdaptersAddresses" API most certainly *is* the correct API to use
> and is the correct answer.
>
> --
> "Fish" (David B. Trout)
>  fish at softdevlabs.com
>
>
>
>
> _______________________________________________
> Winpcap-users mailing list
> Winpcap-users at winpcap.org
> https://www.winpcap.org/mailman/listinfo/winpcap-users
>



-- 
Wentao Shang

Master Candidate and Research Assistant at CERNET Center & EE
Department, Tsinghua University,

Email: wentaoshang at gmail.com, mundou at qq.com,

Mobile: +86-13466605118, +86-18952150939,


More information about the Winpcap-users mailing list