From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,f624720eaa41c4b X-Google-Attributes: gidfee84,public From: tom@finwds01.tu-graz.ac.at (Thomas Leitner) Subject: SOLVED: hostid under OSF/1 Date: 1995/04/06 Message-ID: <3m0s1b$hl1@fstgds15.tu-graz.ac.at>#1/1 X-Deja-AN: 100926860 references: <3lrbu0$nn1@fstgds15.tu-graz.ac.at> <3m022g$sh7@fstgds15.tu-graz.ac.at> organization: Graz University of Technology, Austria newsgroups: comp.unix.osf.osf1 Thomas Leitner (tom@finwds01.tu-graz.ac.at) wrote: : Thomas Leitner (tom@finwds01.tu-graz.ac.at) wrote: : : I found that neither in the FAQ nor in the recent postings here so: : : I need to get the hardware serial number under OSF/1. Apparently the : : hostid command can not be used for that. The sysinfo system call : : won't help either. : : Question: Can someone please post me a short code fragment how to : : get the hardware serial number under OSF/1? : Aehmm, well. Am I touching some secret here or is there really no way : to get the CPU (or system) serial number somehow? I, as well could : use the ethernet address for my purposes. How can I get out the : ethernet address of the machine from a C program (if possible : a non-priviledged)? Thanks to John Kohl . He mailed me the following routine for getting the ethernet addr. (slightly modified by me). It even works under a non-priviledged account: #include #include #include #include main() { int s; struct ifreq *ifrq, ifreqs[32]; struct ifdevea eaddr; struct ifconf ifc; long l1, l2; memset((char *)ifreqs, 0, sizeof(ifreqs)); s = socket(AF_INET, SOCK_STREAM, 0); ifc.ifc_req = ifreqs; ifc.ifc_len = sizeof(ifreqs); ioctl(s, SIOCGIFCONF, &ifc); for (ifrq = ifreqs; ifc.ifc_len > 0; ifrq++, ifc.ifc_len -= sizeof(*ifrq)) { /* for each known interface, try to get a physaddr. */ strncpy(eaddr.ifr_name, ifrq->ifr_name, IFNAMSIZ); if (ioctl(s, SIOCRPHYSADDR, &eaddr) == 0) { /* eaddr now has address. */ break; /* from for loop */ } } close(s); printf("name='%s'\n", eaddr.ifr_name); printf("def_pa='%02x:%02x:%02x:%02x:%02x:%02x'\n", eaddr.default_pa[0], eaddr.default_pa[1], eaddr.default_pa[2], eaddr.default_pa[3], eaddr.default_pa[4], eaddr.default_pa[5]); printf("cur_pa='%02x:%02x:%02x:%02x:%02x:%02x'\n", eaddr.current_pa[0], eaddr.current_pa[1], eaddr.current_pa[2], eaddr.current_pa[3], eaddr.current_pa[4], eaddr.current_pa[5]); } Thanks again -- Tom -- Tom Leitner, tom@finwds01.tu-graz.ac.at |\ _,,,---,,_ Dept. of Communications zzz. /,`.-'`' -. ;-;;,_. Graz University of Technology |,4- ) )-,_. ,\ ( `'-' Phone: +43-316-873-7455 '---''(_/--' `-'\_) Fax: +43-316-463-697 WWW home page: http://wiis.tu-graz.ac.at/people/tom.html