getting ethernet physical address
e9525103 at stud4.tuwien.ac.at
Thu Dec 20 13:00:08 GMT 2001
On Wednesday 19 December 2001 15:49, you wrote:
> hi there,
> i would like to write a simple program to get the physical address of
> my network card. can anybody let me know how to achieve that? which class
> or function should i call? thanks in advance.
> YK (Loh Yong Khun)
> <ykloh at lkta.com.my>
Thats not as easy as getting it from proc or with ifconfig.
Principally you have to talk directly to the ethernet driver.
First you have to get access to the driver by an open command.
Then you have to call the right ioctl-function. Here are some source lines
if (ioctl(skfd, SIOCGIFHWADDR, &ifr) < 0)
memset(ife->hwaddr, 0, 32);
memcpy(ife->hwaddr, ifr.ifr_hwaddr.sa_data, 8);
For more information get the source for ifconfig. For a debian user its easy:
apt-get source net-tools
Otherwise look with the oracle: www.google.com/linux
to unsubscribe from this list send an email to kdevelop-request at kdevelop.org with the following body:
More information about the KDevelop