Re: How to get MAC Address
Re: How to get MAC Address
- Subject: Re: How to get MAC Address
- From: Peter Sichel <email@hidden>
- Date: Mon, 25 Feb 2002 11:57:33 -0500
Does this work for multiple active adaptors such as:
Ethernet Built-in (en0)
PCI Ethernet Port 3, slot C (en1)
AirPort (en2)
Or just the primary interface?
What if Ethernet isn't the primary interface?
Another way might be to use the SystemConfiguration framework
to lookup the hardware address (if any) for each active configuration.
- Peter
This will do it:
void getEthernetAddress()
{
InetInterfaceInfo myInetInterfaceInfo;
int i, adaptorInterface;
NSLog(@"Ethernet addresses: ");
adaptorInterface=0;
do {
OTInetGetInterfaceInfo(&myInetInterfaceInfo, adaptorInterface);
if (myInetInterfaceInfo.fHWAddrLen > 0) {
for(i=0; i<myInetInterfaceInfo.fHWAddrLen; i++) {
printf("x ",myInetInterfaceInfo.fHWAddr[i]);
}
printf("\n");
}
adaptorInterface++;
}
while (myInetInterfaceInfo.fHWAddrLen > 0);
}
--
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.