[Winpcap-users] How to get local MAC address ?
Mark Pizzolato - WinPCap-Users
winpcap-users-20040408 at subscriptions.pizzolato.net
Mon Sep 12 07:24:25 PDT 2011
On Sunday, September 11, 2011 at 11:42 PM, "Fish" (David B. Trout) wrote:
>
> 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.
I stand corrected.
However, the reference I pointed at was ALSO a way to acquire the MAC address of an interface.
Additionally since the question was asked in the context of WinPcap, it might be relevant to someone using WinPcap's API's.
Meanwhile:
On Monday, September 12, 2011 at 7:00 AM, MARMONIER Cédric wrote:
>
> Thanks but there is a probleme.
> GetAdaptersAddresses() don't give me the same adapter list that
> pcap_findalldevs()
>
> If I have :
> IP_ADAPTER_INFO *adapter_Iphlpapi = NULL;
> pcap_if_t *adapter_WinPCAP = NULL;
> adapter_Iphlpapi = getMyAdapter(); // use the GetAdaptersAddresses
> function to select an adapter
>
> => How can I do to set the good adapter in the adapter_WinPCAP variable ?
>
>
> Is there a method which can operate with Windows Xp (and Windows 7 if
> possible) and Linux ?
Linux returns MAC address info in the results returned with pcap_findalldevs().
There once was some discussion about adding this functionality to WinPcap's implementation of pcap_findalldevs(). It never came to anything since it fell off the radar of the developers, and it wasn't a significantly pressing requirement.
For now you can either use the API David points at, or you can use something derived from Gianluca's developer pack example.
Good Luck.
- Mark Pizzolato
More information about the Winpcap-users
mailing list