From owner-freebsd-questions@FreeBSD.ORG Wed Nov 10 10:00:35 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 44A2916A4E4 for ; Wed, 10 Nov 2004 10:00:35 +0000 (GMT) Received: from web53908.mail.yahoo.com (web53908.mail.yahoo.com [206.190.36.218]) by mx1.FreeBSD.org (Postfix) with SMTP id D2D4343D1F for ; Wed, 10 Nov 2004 10:00:34 +0000 (GMT) (envelope-from easyeinfo@yahoo.com) Received: (qmail 10807 invoked by uid 60001); 10 Nov 2004 10:00:34 -0000 Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; b=PMV7AQXiJqUrih9o6alJDcdrsO5LgjxDMyWslM9n1trBxzotVkPbnnlDa8WuC2cS9dynNK2/9TdfjEijIFuijY3ID8rim1zw7J2Vg4+65KmbkXbNG1fS6CVxPMXMJJSEUG+1AIVv1Ix2gNgJKaKeYZ3IQoP308O+A41gv88ispo= ; Message-ID: <20041110100034.10805.qmail@web53908.mail.yahoo.com> Received: from [202.168.70.130] by web53908.mail.yahoo.com via HTTP; Wed, 10 Nov 2004 02:00:33 PST Date: Wed, 10 Nov 2004 02:00:33 -0800 (PST) From: Dennis George To: freeBSD Questions In-Reply-To: <20041104013702.GA8777@teddy.fas.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Content-Filtered-By: Mailman/MimeDel 2.1.1 Subject: How to get MAC address using C program X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Nov 2004 10:00:35 -0000 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