Xref: utzoo comp.unix.ultrix:5579 comp.unix.programmer:675 Path: utzoo!attcan!uunet!mcsun!hp4nl!utrcu1!emmerik From: emmerik@utrcu1.UUCP (Emmerik P.J.L. van) Newsgroups: comp.unix.ultrix,comp.unix.programmer Subject: WANTED: ethernet address or other unique ID for DEC-station Keywords: ethernet-address unique-ID DECstation Message-ID: <750@utrcu1.UUCP> Date: 12 Dec 90 07:47:24 GMT Organization: UTWENTE, Enschede Lines: 64 Repost: Sorry, in the original posting i asked only for a solution for a SUN workstation, where i realy wanted a solution for both SUN and DEC (RISK) workstations. I have already received a solution for SUN, use gethostid(2). Wanted: a way of obtaining a unique identifier for a DEC workstation from a program. On some systems we use the ethernet address of a workstation as a unique identifier, but on some, like SUN Sparcstations and DEC-stations running Ultrix this does not seem to work. The method we use works as follows: #include #include #include #include int sock, st; struct sock_addr_in sin, *parp_pa; struct arpreq arpreq; struct hostent *hp; char chxx[200]; /* Create a socket */ sock = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP ); /* Set the Internet address for the request */ parp_pa = (struct sockaddr_in *)&arpreq.arp_pa; parp_pa->sin_family = AF_INET; parp_pa->sin_port = 0; gethostname( chxx, 199 ); hp = gethostbyname( chxx ); parp_pa->sin_addr.s_addr = *(u_long *)hp->hp_addr; /* Set the type of the requested address */ arpreq.arp_ha.sa_family = AF_UNSPEC; /* Get the ethernet address */ st = ioctl( sock, SIOCGARP, (caddr_t)&arpreq ) if ( st< 0 ) { perror( "ioctl" ); } close( sock ); } I have left some details, like error handling out. This program will result in a message from perror: ioctl: No such device or address i.e. ERRNO = 6 Two questions: - am i doing something wrong, if so what should i do? - is there maybe another way of obtaining a uniqiue identifier, e.g. a SUN specific routine to get a CPU-id? Pleace send responces to emmerik@utwente.nl -- Pieter van Emmerik | Phone: +31-74-483059 Hollandse Signaalapparaten b.v. | FAX: +31-74-425936 P.O.box 42 | E-mail: emmerik@utwente.nl 7550 GD Hengelo, The Netherlands | hp4nl!utrcu1!emmerik