Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ukma!husc6!rice!sun-spots-request From: Kemp@dockmaster.ncsc.mil Newsgroups: comp.sys.sun Subject: Finding ethernet addresses Keywords: SunOS Message-ID: <890414021852.004708@DOCKMASTER.ARPA> Date: 3 May 89 09:14:25 GMT Sender: usenet@rice.edu Organization: Sun-Spots Lines: 22 Approved: Sun-Spots@rice.edu Original-Date: Thu, 13 Apr 89 22:18 EDT X-Sun-Spots-Digest: Volume 7, Issue 263, message 2 of 9 Dan Ehrlich writes: Does anyone know how to determine the ethernet address of the second ethernet interface on a Sun? There is a program in the Sun Software Technical Bulletin (November 1988, page 2202) that does exactly that, using /dev/nit. The code is 1 1/2 pages, but the relevant lines are (omitting error checking): #include #include struct ifreq if_data; sfd = open("/dev/nit", O_RDONLY); if_data.ifr_addr.sa_family = AF_NIT; strcpy(if_data.ifr_name, argv[1]);l /* the interface name */ ioctl(sfd, NIOCBIND, &if_data); ioctl(sfd, SIOCGIFADDR, &if_data); /* Get the ethernet addr */ /* print if_data.ifr_addr.sa_data[0:5] */ I typed the program in and it works. If you don't get the STB, the above should be enough to get you pointed in the right direction. Dave Kemp