How to get MAC address using C program
Dennis George
easyeinfo at yahoo.com
Wed Nov 10 02:00:35 PST 2004
Hi,
Can anybody help me out to retrieve MAC address of my machine... using a C program.... I gave it a try using ioctl but not getting the correct result...... Following is my code......
int main()
{
......
struct ifr_req ifr ;
strcpy(ifr.ifr_name, "rl0");
if( ioctl(s, SIOCGIFADDR, &ifr) < 0 ) {
cout << "Error" << endl ;
return 0 ;
}
printf("ADDR(%s) = ") ;
for(int i = 0; i < 6; i++) {
printf("%x :", ifr.ifr_addr.sa_data[i] ) ;
}
its not printing the correct result....
Thanks in advance
Dennis
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the freebsd-questions
mailing list