[Winpcap-users] Retireving MAC Address

Alessandro Baldisserri bujia at libero.it
Sat Jan 7 09:31:21 GMT 2006


Hi!

Problem solved! Buffer was little... Now I enlarge it to 2048 and it works... Thanks!

There is a way to obtain MAC Address with PCAP API other than Packet API ? 

Another question:

- Is there a method to recognize only ethernet card from device list? I want to exlude bluetooth, wireless 802.11 and so on... I want only ethernet.

Thanks in advance!

Alessandro









---------- Initial Header -----------

>From      : winpcap-users-bounces at winpcap.org
To          : winpcap-users at winpcap.org
Cc          : 
Date      : Thu, 5 Jan 2006 09:09:43 -0800
Subject : Re: [Winpcap-users] Retireving MAC Address







> Hi Alessandro.
> 
> Maybe PacketGetAdapterNames is failing because the buffer is not big enough. 
> Have you looked at the value returned into nameSize?
> 
> Out of curiosity, why are you still using WinPcap 3.0, and the Packet API 
> (which we suggest *not* to use, because subject to change between different 
> versions), instead of the pcap one?
> 
> Have a nice day
> GV
> 
> ----- Original Message ----- 
> From: "Alessandro Baldisserri" <bujia at libero.it>
> To: "WinPCap MailingList" <winpcap-users at winpcap.org>
> Sent: Tuesday, January 03, 2006 6:36 AM
> Subject: [Winpcap-users] Retireving MAC Address
> 
> 
> Hi!
> 
> I'm using winpcap version 3.0.0.18
> I want to retrieve MAC Address from my net adapter. I use this code:
> 
>     PPACKET_OID_DATA pOidData;
>     LPADAPTER lpAdapter=NULL;
>     CHAR *pStr;
>     CHAR *adName = new CHAR[1024];
>     PTSTR adNameptstr = (PTSTR)adName;
>     ULONG nameSize = 1024;
>     BOOLEAN res;
>     pStr = new CHAR[sizeof(PACKET_OID_DATA)+128];
>     ZeroMemory(pStr, sizeof(PACKET_OID_DATA)+128);
>     pOidData = (PPACKET_OID_DATA) pStr;
>     pOidData->Oid = OID_802_3_CURRENT_ADDRESS;
>     pOidData->Length = 6;
> res = PacketGetAdapterNames(adNameptstr,&nameSize);
> if (res==0) {
> // -----------------> MY ERROR IS THIS!!!!
> printf("ERROR in PacketGetAdapterNames\n");
> goto ip;
> }
> lpAdapter = PacketOpenAdapter(adNameptstr);
> if (lpAdapter==NULL) {
> printf("ERROR in PacketOpenAdapter\n");
> goto ip;
> }
>     res = PacketRequest(lpAdapter, FALSE, pOidData);
> if (res==0) {
> printf("ERROR in PacketRequest\n");
> goto ip;
> }
> // In pOidData->Data[0...5] è contenuto il MAC ADDRESS
> sprintf(host_mac_address,"%02X:%02X:%02X:%02X:%02X:%02X",
> pOidData->Data[0],
> pOidData->Data[1],
> pOidData->Data[2],
> pOidData->Data[3],
> pOidData->Data[4],
> pOidData->Data[5]);
> 
> 
> With this code I have an error in PacketGetAdapterName.
> Is this code wrong?
> Anyone can help me?
> Thanks in advance!
> Alex
> 
> 
> _______________________________________________
> Winpcap-users mailing list
> Winpcap-users at winpcap.org
> https://www.winpcap.org/mailman/listinfo/winpcap-users
> 
> _______________________________________________
> Winpcap-users mailing list
> Winpcap-users at winpcap.org
> https://www.winpcap.org/mailman/listinfo/winpcap-users
> 




More information about the Winpcap-users mailing list