Date: Wed, 10 Nov 2004 02:00:33 -0800 (PST) From: Dennis George <easyeinfo@yahoo.com> To: freeBSD Questions <freebsd-questions@freebsd.org> Subject: How to get MAC address using C program Message-ID: <20041110100034.10805.qmail@web53908.mail.yahoo.com> In-Reply-To: <20041104013702.GA8777@teddy.fas.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20041110100034.10805.qmail>