From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96075319106469.tru64-unix-managers.marc@archive.invalid> From: Craig Knudsen Date: Wed, 12 Apr 1995 16:00:22 +0000 To: tru64-unix-managers Subject: SUMMARY: Getting Ethernet Address X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96075319106469 My original posting: I am writing some license management software. It needs to be node- locked. I would prefer not to use the hostid or the IP address since both of those can be changed under OSF/1 and Ultrix. Is there a C system call that will give me the ethernet address? I would prefer to use the ethernet address (That can't be changed, right?). Many people were quick to point out that the ethernet address can be changed either by replacing the ethernet card or by setting in software. Many were also quick to complain that node-locking a license to an ethernet address is a bad idea. I received quit a few sets of code to get the ethernet address. Note that there are two addresses (default hardware address and current physical address). Here is one: #include #include #include #include #include main(argc,argv) char **argv; { struct ifdevea ifr; int s; if (argc != 2) { fprintf(stderr,"Usage: %s devname\n",argv[0]); fprintf(stderr,"Example: %s qe0\n",argv[0]); exit(1);} /* Create a socket */ if ((s = socket(AF_INET,SOCK_DGRAM,0)) < 0) perror("socket"); strcpy(ifr.ifr_name, argv[1]); /* Get the ethernet address */ if ( ioctl(s,SIOCRPHYSADDR,&ifr) < 0 ) perror("Error in ioctl"); printf("%2x:%2x:%2x:%2x:%2x:%2x, name=%s\n", (u_char)ifr.current_pa[0], (u_char)ifr.current_pa[1],(u_char)ifr.current_pa[2], (u_char)ifr.current_pa[3],(u_char)ifr.current_pa[4], (u_char)ifr.current_pa[5], ifr.ifr_name); printf("%2x:%2x:%2x:%2x:%2x:%2x, name=%s\n", (u_char)ifr.default_pa[0], (u_char)ifr.default_pa[1],(u_char)ifr.default_pa[2], (u_char)ifr.default_pa[3],(u_char)ifr.default_pa[4], (u_char)ifr.default_pa[5], ifr.ifr_name); } Thanks to those who replied: Andy Phillips Rick Beebe Andrew Gallatin Herve DEMARTHE (CEA France) Stam Nicolis "Andrew Brennan, Lackey-at-large" Helleb\x Knut Saul Tannenbaum "Dr. Tom Blinn, 603-881-0646" Steve Osselton alan@nabeth.cxo.dec.com (Alan Rollow - Dr. File System's Home for Wayward Inodes.) "nagroM W sirdI" simon@locus.com "Doug McPherson (617) 441-4565" swr@unx.dec.com (Scott Ruch) haskins@mipps.myapc.com (Robert D. Haskins) Dave Otto William Flett wendling@unidad.vbo.dec.com "Alex M. George" Ken Cline anthony baxter Keith Lewis Harald Lundberg Jari Tavi micha@ekpux2.physik.uni-karlsruhe.de (Michael Schneider) Arrigo Triulzi Kevin J Walters Robert Drawsky tim moore Benoit Maillard - Digital France- dtn: 858-1243 / ext: 33 1 69 87 12 43 <"atyisa::maillard"@atyisa.enet.dec.com> Leonard Vaughn =============================================================================== Craig Knudsen cknudsen@btg.com http://www.btg.com/~cknudsen/ BTG, Inc. http://www.btg.com/ ===============================================================================