What is my Ethernet address?
gregt
gregt at sdl.monet.scs.com
Sat Aug 4 06:04:20 AEST 1990
In article <545 at siswat.UUCP> buck at siswat.UUCP (A. Lester Buck) writes:
In article <432 at minya.UUCP>, jc at 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 at sdl.scs.com)
--
A. Lester Buck buck at 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 at sdl.scs.com // Gregory Tusar // Silicon Compiler Sys. // Warren, NJ
More information about the Comp.unix.wizards
mailing list