Return to BSD News archive
Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!news.ecn.uoknor.edu!feed1.news.erols.com!cpk-news-hub1.bbnplanet.com!news.bbnplanet.com!EU.net!sun4nl!fido.news.demon.net!demon!newsgate.unisource.nl!surfnet.nl!news.tue.nl!usenet
From: Gert van der Plas <gert@inferno.phys.tue.nl>
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: etting ethernet address of networkadaptor.
Date: Fri, 16 May 1997 11:12:31 +0200
Organization: Eindhoven University of Technology
Message-ID: <337C24FF.167E@inferno.phys.tue.nl>
NNTP-Posting-Host: inferno.phys.tue.nl
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 3.01Gold (X11; I; OSF1 V3.2 alpha)
Lines: 53
Xref: euryale.cc.adfa.oz.au comp.unix.bsd.freebsd.misc:41015
I would like to obtain the physical address of the network-adapter.
Does anyone have some code to do this? I had some code for the DEC-Alpha
but that did not work and I could not manage to patch it since I do not
know enough about FreeBSD 2.2.1 to do this. Can some one please help?
Whishes,
Gert
P.S. The code for the DEC Alpha looks like this.
#include <stdio.h> /* standard I/O */
#include <errno.h> /* error numbers */
#include <sys/socket.h> /* socket definitions */
#include <sys/ioctl.h> /* ioctls */
#include <net/if.h> /* generic interface structures
*/
main()
{
int s,i;
static struct ifdevea devea;
/* Get a socket */
s = socket(AF_INET,SOCK_DGRAM,0);
if (s < 0) {
perror("socket");
exit(1);
}
strcpy(devea.ifr_name,"ln0");
if (ioctl(s,SIOCRPHYSADDR,&devea) < 0) {
perror(&devea.ifr_name[0]);
exit(1);
}
printf(Address is ");
for (i = 0, i < 6, i++)
printf("%X ", devea.default_pa[1] & 0xff);
printf("0);
close(s);
}
--
-------------------------------------------------------------------------------
G.A.J. van der Plas |
e-mail:gert@inferno.phys.tue.nl
Eindhoven University of Technology |
http://tnj.phys.tue.nl/users/gert
-------------------------------------------------------------------------------
'The ultimate good is not to be afraid.' Nietze *!* finger for
PGP-key *!*
-------------------------------------------------------------------------------