On Feb 20, 2007, at 2:33 PM, nocturnal wrote:
[ ...looking up one's MAC address... ]
I am buying a MacBook for personal use though so it would be nice
to run it on osx. I wouldn't like to start using another library
just to get the hardware address of an interface though, that seems
kinda overkill for what should be a simple task. The program is
already using libpcap but that is included in FreeBSD by default so
you don't have to install it.
I don't think PCAP offers an easy way to get the MAC address of a
given interface, short of capturing a packet sent from the host via
that particular interface, and then figuring out the right offset to
the source/sender MAC based on the datalink type header, which
presumably will be DLT_EN10MB (14 bytes in size, IIRC).
Do you have any idea of why i'm getting this error from ioctl when
i'm doing what the manual says i should do? I am of course running
it as root to because the libpcap operations require it.
Nope, sorry. I remember trying to make this go myself a while back,
and decided that using the libnet call was much easier than figuring
out why the SIOCGIFMAC ioctl wasn't working as expected...
What might help me is to take a look at the source of that
libnet_get_hwaddr function in libnet. I'll try that, thank you very
much for the tip.
So far i've been trying to look at the source for ifconfig to
figure out how it gets the hardware address. Of course it uses
SIOCGIFMAC but i can't find the socket it opens because i can't
find where it uses the maclabel_status function.
Well, you could always invoke and parse the output of ifconfig (or
arp), but I can understand wanting to get the information directly
without frobbing external programs. :-)
--
-Chuck
_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"