Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!samsung!uakari.primate.wisc.edu!uflorida!haven!decuac!e2big.dec.com!shlump.nac.dec.com!mipsbx.nac.dec.com!thomas From: thomas@mipsbx.nac.dec.com (Matt Thomas) Newsgroups: comp.sys.dec Subject: Re: Getting ETHERNET address of VAX adapter Message-ID: <10272@shlump.nac.dec.com> Date: 13 Apr 90 17:31:06 GMT References: <10847@cbmvax.commodore.com> <3431.26246304@fps.mcw.edu> Sender: news@shlump.nac.dec.com Reply-To: thomas@wrl.dec.com Organization: Digital Equipment Corporation Lines: 78 > This is ALMOST a really stupid question.... > How does one go about finding out the ethernet address of the > ethernet adapter of a VAX? (via software, that is...) > > With NCP, etc., I can easily see the addresses of the SERVERS, > but stuff like SHOW EXEC CHAR doesn't tell me what I need to know. Try this program. It will list any interface that has an physical address (which may not be limited to just Ethernet adapters). #include /* standard I/O */ #include /* error numbers */ #include /* time definitions */ #include /* system types */ #include /* socket stuff */ #include /* ioctls */ #include /* generic interface structs */ extern char *optarg; extern int optind; extern char *sys_errlist[]; main( argc, argv ) int argc; char *argv[]; { struct ifdevea devea; struct ifreq *ifr, ifreqs[32]; struct ifconf ifc; int s, i; bzero(&devea, sizeof(devea)); /* we need a socket -- any old socket will do. */ s = socket(AF_UNIX, SOCK_DGRAM, 0); if (s < 0) { perror("socket"); exit(1); } ifc.ifc_req = ifreqs; ifc.ifc_len = sizeof(ifreqs); if (ioctl(s, SIOCGIFCONF, &ifc) < 0) { perror("siocgifconf"); exit(1); } for (ifr = ifreqs; ifc.ifc_len > 0; ifr++, ifc.ifc_len -= sizeof(*ifr)) { if (strcmp(devea.ifr_name, ifr->ifr_name)) { (void) strcpy(devea.ifr_name, ifr->ifr_name); /* read the address of the interface */ if (ioctl(s, SIOCRPHYSADDR, &devea) < 0) { /* error? */ if (errno != EOPNOTSUPP && errno |= EINVAL) { /* unexpected error */ perror(devea.ifr_name); } continue; } printf("%s: ", devea.ifr_name); printf("current = %02x-%02x-%02x-%02x-%02x-%02x, ", devea.current_pa[0], devea.current_pa[1], devea.current_pa[2], devea.current_pa[3], devea.current_pa[4], devea.current_pa[5] ); printf("default = %02x-%02x-%02x-%02x-%02x-%02x\n", devea.default_pa[0], devea.default_pa[1], devea.default_pa[2], devea.default_pa[3], devea.default_pa[4], devea.default_pa[5] ); } } } -- Matt Thomas Internet: thomas@wrl.dec.com DECnet-ULTRIX Development UUCP: ...!decwrl!thomas Digital Equipment Corporation Disclaimer: This message reflects my own Littleton, MA warped views, etc.