tcpdump mailing list archives
Re: Obtaining interface IP address and MAC address
From: roy hills <royhills () hotmail com>
Date: Tue, 25 Jan 2011 10:46:38 +0000
The interfaces used to do both of the above are almost universal now: SIOCGIFADDR and SIOCGIFHWADDR.
I don't think SIOCGIFHWADDR is supported on MacOS or Windows. For MacOS and other BSD operating systems, I use sysctl with the MIB { CTL_NET, PF_ROUTE, 0, AF_LINK, NET_RT_IFLIST, 0 } and loop through the interfaces in the list until I find the one that I am using. This works fine, but I'd rather not have to maintain my own system-specific link functions together with the autoconf logic to select the correct one for the target OS. - This is the tcpdump-workers list. Visit https://cod.sandelman.ca/ to unsubscribe.
Current thread:
- Obtaining interface IP address and MAC address with libpcap roy hills (Jan 24)
- Re: Obtaining interface IP address and MAC address with libpcap Guy Harris (Jan 24)
- Re: Obtaining interface IP address and MAC address Darren Reed (Jan 24)
- Re: Obtaining interface IP address and MAC address Guy Harris (Jan 24)
- Re: Obtaining interface IP address and MAC address roy hills (Jan 25)