Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!samsung!uunet!sdl!gregt From: gregt@sdl.monet.scs.com (gregt) Newsgroups: comp.unix.wizards Subject: Re: What is my Ethernet address? Message-ID: Date: 3 Aug 90 20:04:20 GMT References: <432@minya.UUCP> <545@siswat.UUCP> Sender: gregt@sdl.scs.com Organization: Silicon Compiler Systems, Warren NJ Lines: 53 In-reply-to: buck@siswat.UUCP's message of 2 Aug 90 06:12:50 GMT In article <545@siswat.UUCP> buck@siswat.UUCP (A. Lester Buck) writes: In article <432@minya.UUCP>, jc@minya.UUCP (John Chambers) writes: > The only correct answer is one that gives the Ethernet address that is > on the card at this very instant, not one that "should" be there according > to some file or server which should (but may not) be correct. I'm trying > to determine whether those files and servers are correct; I can't very well > ask them whether they're lying to me. (Well, maybe I can; what does the > request packet look like? :-) ... register. I am not really familiar with the Sun, but I thought I read at one time that Suns could load whatever Ethernet address they wanted from /etc/ethers onto the adapter. ... I not sure about that, but the way you read the address is by opening /dev/nit, and hitting it with a SIOCGIFADDR ioctl - ala int f; struct ifreq if; if ((f = open("/dev/nit", 0)) < 0) { perror("open()"); exit(1); } bzero(&if, sizeof(struct ifreq)); if.ifr_addr.sa_family = AF_NIT; strcpy(if.ifr_name, "ie0"); /* insert interface name here */ if (ioctl(f, NIOCBIND, &if) < 0) { perror("ioctl()"); exit(2); } if (ioctl(f, SIOCGIFADDR, &if) < 0) { perror("ioctl()"); exit(3); } The address is filled in if.ifr_addr.sa_data cheers, greg tusar (gregt@sdl.scs.com) -- A. Lester Buck buck@siswat.lonestar.org ...!texbell!moray!siswat!buck -- "Of all kinds of painting, figure painting is the most difficult; then comes landscape painting, and next dogs and horses." - Ku K'ai-Chih : gregt@sdl.scs.com // Gregory Tusar // Silicon Compiler Sys. // Warren, NJ