* SUMMARY: Getting Ethernet Address
@ 1995-04-12 16:00 Craig Knudsen
0 siblings, 0 replies; 2+ messages in thread
From: Craig Knudsen @ 1995-04-12 16:00 UTC (permalink / raw)
To: tru64-unix-managers
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 <sys/types.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
#include <stdio.h>
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 <atp@mssly1.mssl.ucl.ac.uk>
Rick Beebe <BEEBE@BIOMED.MED.YALE.EDU>
Andrew Gallatin <gallatin@isds.Duke.EDU>
Herve DEMARTHE (CEA France) <demarthe@alpha.cad.cea.fr>
Stam Nicolis <nicolis@celfi.phys.univ-tours.fr>
"Andrew Brennan, Lackey-at-large" <BRENNAN@HAL.HAHNEMANN.EDU>
Helleb\x Knut <bgk1142@bggfu2.nho.hydro.com>
Saul Tannenbaum <stannenb@emerald.tufts.edu>
"Dr. Tom Blinn, 603-881-0646" <tpb@zk3.dec.com>
Steve Osselton <so@prismtech.co.uk>
alan@nabeth.cxo.dec.com (Alan Rollow - Dr. File System's Home for Wayward Inodes.)
"nagroM W sirdI" <im@uvo.dec.com>
simon@locus.com
"Doug McPherson (617) 441-4565" <DOUGM@delphi.com>
swr@unx.dec.com (Scott Ruch)
haskins@mipps.myapc.com (Robert D. Haskins)
Dave Otto <dave@marvin.jta.edd.ca.gov>
William Flett <will@dcs.rhbnc.ac.uk>
wendling@unidad.vbo.dec.com
"Alex M. George" <george@mms.water.ci.detroit.mi.us>
Ken Cline <cline@iipo.gtegsc.com>
anthony baxter <anthony.baxter@aaii.oz.au>
Keith Lewis <keithl@mukluk.cc.monash.edu.au>
Harald Lundberg <hl@tekla.fi>
Jari Tavi <jpt@rixrax.enet.dec.com>
micha@ekpux2.physik.uni-karlsruhe.de (Michael Schneider)
Arrigo Triulzi <a.triulzi@ic.ac.uk>
Kevin J Walters <k.j.walters@lpac.ac.uk>
Robert Drawsky <rdrawsky@hulk.sfsu.edu>
tim moore <tmoore@pa.dec.com>
Benoit Maillard - Digital France- dtn: 858-1243 / ext: 33 1 69 87 12 43 <"atyisa::maillard"@atyisa.enet.dec.com>
Leonard Vaughn <vaughn@rust.zso.dec.com>
===============================================================================
Craig Knudsen cknudsen@btg.com http://www.btg.com/~cknudsen/
BTG, Inc. http://www.btg.com/
===============================================================================
^ permalink raw reply [flat|nested] 2+ messages in thread* SUMMARY: Getting Ethernet Address
@ 1995-04-12 16:51 Craig Knudsen
0 siblings, 0 replies; 2+ messages in thread
From: Craig Knudsen @ 1995-04-12 16:51 UTC (permalink / raw)
To: tru64-unix-managers
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 <sys/types.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
#include <stdio.h>
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 <atp@mssly1.mssl.ucl.ac.uk>
Rick Beebe <BEEBE@BIOMED.MED.YALE.EDU>
Andrew Gallatin <gallatin@isds.Duke.EDU>
Herve DEMARTHE (CEA France) <demarthe@alpha.cad.cea.fr>
Stam Nicolis <nicolis@celfi.phys.univ-tours.fr>
"Andrew Brennan, Lackey-at-large" <BRENNAN@HAL.HAHNEMANN.EDU>
Helleb\x Knut <bgk1142@bggfu2.nho.hydro.com>
Saul Tannenbaum <stannenb@emerald.tufts.edu>
"Dr. Tom Blinn, 603-881-0646" <tpb@zk3.dec.com>
Steve Osselton <so@prismtech.co.uk>
alan@nabeth.cxo.dec.com (Alan Rollow - Dr. File System's Home for Wayward Inodes.)
"nagroM W sirdI" <im@uvo.dec.com>
simon@locus.com
"Doug McPherson (617) 441-4565" <DOUGM@delphi.com>
swr@unx.dec.com (Scott Ruch)
haskins@mipps.myapc.com (Robert D. Haskins)
Dave Otto <dave@marvin.jta.edd.ca.gov>
William Flett <will@dcs.rhbnc.ac.uk>
wendling@unidad.vbo.dec.com
"Alex M. George" <george@mms.water.ci.detroit.mi.us>
Ken Cline <cline@iipo.gtegsc.com>
anthony baxter <anthony.baxter@aaii.oz.au>
Keith Lewis <keithl@mukluk.cc.monash.edu.au>
Harald Lundberg <hl@tekla.fi>
Jari Tavi <jpt@rixrax.enet.dec.com>
micha@ekpux2.physik.uni-karlsruhe.de (Michael Schneider)
Arrigo Triulzi <a.triulzi@ic.ac.uk>
Kevin J Walters <k.j.walters@lpac.ac.uk>
Robert Drawsky <rdrawsky@hulk.sfsu.edu>
tim moore <tmoore@pa.dec.com>
Benoit Maillard - Digital France- dtn: 858-1243 / ext: 33 1 69 87 12 43 <"atyisa::maillard"@atyisa.enet.dec.com>
Leonard Vaughn <vaughn@rust.zso.dec.com>
===============================================================================
Craig Knudsen cknudsen@btg.com http://www.btg.com/~cknudsen/
BTG, Inc. http://www.btg.com/
===============================================================================
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1995-04-12 16:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1995-04-12 16:00 SUMMARY: Getting Ethernet Address Craig Knudsen
-- strict thread matches above, loose matches on Subject: below --
1995-04-12 16:51 Craig Knudsen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox