在 2011-9-12 下午10:00,"MARMONIER Cédric" <[email protected]>写道: > > 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 ? > >
One solution is to compare the 'AdapterName' field in IP_ADAPTER_ADDRESSES struct with the field in pcap_if_t struct (i don't remember the name). You may first get the whole pcap_if_t struct list then select the one you need. Regards. Wentao > Is there a method which can operate with Windows Xp (and Windows 7 if possible) and Linux ? > > > > > > > > -----Message d'origine----- > De : [email protected] [mailto: [email protected]] De la part de Wentao Shang > Envoyé : lundi 12 septembre 2011 11:27 > À : [email protected] > Objet : Re: [Winpcap-users] How to get local MAC address ? > > 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) <[email protected]>: > > 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) > > [email protected] > > > > > > > > > > _______________________________________________ > > Winpcap-users mailing list > > [email protected] > > https://www.winpcap.org/mailman/listinfo/winpcap-users > > > > > > -- > Wentao Shang > > Master Candidate and Research Assistant at CERNET Center & EE > Department, Tsinghua University, > > Email: [email protected], [email protected], > > Mobile: +86-13466605118, +86-18952150939, > _______________________________________________ > Winpcap-users mailing list > [email protected] > https://www.winpcap.org/mailman/listinfo/winpcap-users > > _______________________________________________ > Winpcap-users mailing list > [email protected] > https://www.winpcap.org/mailman/listinfo/winpcap-users
_______________________________________________ Winpcap-users mailing list [email protected] https://www.winpcap.org/mailman/listinfo/winpcap-users
