[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference hydra::axp-developer

Title:Alpha Developer Support
Notice:[email protected], 800-332-4786
Moderator:HYDRA::SYSTEM
Created:Mon Jun 06 1994
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:3722
Total number of notes:11359

3289.0. " ProSTEP GmbH - Point 21970" by RDGENG::ASAP () Fri Mar 07 1997 10:57

    Company Name :   ProSTEP GmbH - Point 21970
    Contact Name :  Michael Gudel
    Phone        :  +49-6151-928730
    Fax          :  +49-6151-928726
    Email        :  [email protected]
    Date/Time in :   7-MAR-1997 15:57:10
    Entered by   :  Ian Chamberlin
    SPE center   :  REO

    Category     :  unix
    OS Version   :  
    System H/W   :  


    Brief Description of Problem:
    -----------------------------

From:	ESSB::ESSB::MRGATE::"ILO::ESSC::rallen"  7-MAR-1997 08:32:53.38
To:	RDGENG::ASAP
CC:	
Subj:	ESCALATION: POINT No.21970, Company ProSTEP GmbH TO ASAP READING:    

From:	NAME: ESCTECH@ILO          
	TEL: (822-)6704          
	ADDR: ILO                  <rallen@ESSC@ILO>
To:	ASAP@RDGENG@MRGATE

Hello - 

POINT Log Number	21970

Company Name 	ProSTEP GmbH   

Engineers name	Michael Gudel 

Telephone Number 	+49-6151-928730

Fax Number		+49-6151-928726

E-mail Address	[email protected]	

Operating System, Version	OSF/1 Version 3.0

Platform			

Problem Statement		

Dear Sirs,
we try to port a licence tool, that we use on various Unix platforms
for our software packages, to OSF/1 (Version 3.0). This licence tool
needs a host-identification, which will be determined either by the
function "gethostid" or "uname". Neither of these functions are available
on OSF/1.
Is there any function available, that returns a unique system-id ?
(CPU based or network-based )

Regards,

Richard
Richard Allen
Pre-Sales Technical Support                      DTN fax 822.44.45  
European Software Center                        DTN phone 822.43.52  
Digital Equipment International B.V.    [email protected] 
        ~ FREEPHONE NUMBERS ARE AVAILABLE ON REQUEST ~
T.RTitleUserPersonal
Name
DateLines
3289.1KZIN::HUDSONThat&#039;s what I thinkWed Mar 12 1997 10:49262
From:	DEC:.REO.REOVTX::HUDSON       "[email protected] - UK Software
Partner Engineering 830-4121" 12-MAR-1997 15:48:38.43
To:	nm%vbormc::"[email protected]"
CC:	HUDSON
Subj:	RE: point 21970, unique address

Hello Michael Gudel,

Thank-you for your ASAP question Unix (OSF/1) host identification.

Firstly, my apologies for not responding to this mail earlier.  I missed your
question in my mail folder and only recovered it today (12-Mar).

>we try to port a licence tool, that we use on various Unix platforms
>for our software packages, to OSF/1 (Version 3.0). This licence tool
>needs a host-identification, which will be determined either by the
>function "gethostid" or "uname". Neither of these functions are available
>on OSF/1.
>Is there any function available, that returns a unique system-id ?
>(CPU based or network-based )


This is a question we see quite often, and I enclose at the bottom of this mail
a program which shows how you can obtain the system ethernet address, which
is typically used in this type of situation.

If you have WWW access, you can find this program on the ASAP web pages:

	http://www.partner.digital.com/www-swdev/

	- on that page follow the link to "technical support"
	- follow the link to "Frequently Asked Questions (FAQs)"
	- follow the link to "DIGITAL UNIX"
	- follow the link to "Ethernet Address"

Incidentally, "uname" and "gethostid" are both available on Digital Unix:

% man -k uname
uname (1)               - Displays information about the operating system
uname (2)               - Gets the name of the current system
uuname (1)              - Displays names of accessible systems
%man -k gethostid
gethostid (2)           - Gets the unique identifier of the current host


Regards

Nick Hudson
Digital Software Partner Engineering




/*
 *      getadr.c -- program to acquire ethernet controller addresses
 *              (c) Digital Equipment Corporation, 1989
 *              Author: Jim Lieb, Digital Equipment Corp. suntan::lieb
 *              This program is distributed free as a demonstration
 *              of network access methods.  No warrantee is expressed or
 *              implied.
 *
 *      Application: Use the getadr function to get the hardware address
 *              for the system in applications where the license key is
 *              verified by checking something unique like a system serial
 *              number (not always present on DEC cpus).
 *
 *      NOTE:   There is a difference between the hardware address and the
 *              physical address of Digital manufactured Ethernet controller.
 *              The hardware address is a unique number, typically of the
 *              form:  08-00-2B-xx-xx-xx, as assigned by IEEE authority. The
 *              xx-xx-xx number is fixed in ROM and is unique for each
 *              controller.  This address is guaranteed fixed and unique.
 *              The physical address is programmable and is MODIFIED by the
 *              DECnet routing layer to encode the 16 bit Phase IV DECnet
 *              address in the least significant 2 octets (byte swapped)
 *              of the source address of packets. This address, typically
 *              of the form aa-00-04-00-yy-yy where yy-yy is the DECnet
 *              address, becomes the address used by the controller for
 *              packet receive and transmit.
 *
 *              March 3, 1990 - Jim Lieb, changed to use internal tables
 *                              and clean up struct usage.  Please note!
 *              May 21, 1990 -  John Dustin OSG, use status bits rather than
 *                              string compares to get right interface.
 *                              also test for interface turned on and use
 *                              best guess of none on...
 *              September 28, 1993 - Doug Olson, updated to match change in
 *                              /usr/include/net/if.h (IFF_MULTICAST).
 *              3 November 1994 Chuck Newman.  getadr was changed to return the
 *                              addresses of all ethernet devices.  The
 *                              interface was completely changed.
 */

#include <strings.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <errno.h>              /* error numbers */
#include <stdio.h>

static char getadrSID[] = "@(#)getadr.c 1.5 6/22/90 demo";
extern int errno;

int getadr();

/* main -- Shell to demonstrate the call to the getadr function.  This
 *      also prints the address contents to stdout.
 */

main(argc, argv, envp)

    int             argc;
    char            **argv, **envp;

    {
    char            *interface;
#define INTERFACE_COUNT 32
	unsigned char hardware[INTERFACE_COUNT][6];
	int temp_int, count;

    if(argc < 2)
        interface = NULL;
    else
        interface = argv[1];

    if ((count = getadr(hardware, INTERFACE_COUNT)) == 0)
        {
        fprintf(stderr, "couldn't get network interface\n");
        exit(1);
        }

    for (temp_int = 0; temp_int < abs(count); temp_int++)
      {
        printf("Ethernet hardware address =
(%02.2X-%02.2X-%02.2X-%02.2X-%02.2X-%02.2X)\n",
            hardware[temp_int][0], hardware[temp_int][1],
            hardware[temp_int][2], hardware[temp_int][3],
            hardware[temp_int][4], hardware[temp_int][5]);
      }
    if (count < 0) printf("There are more devices than those listed\nCall getadr
with a larger buffer\n");
    }

/*      getadr -- get primary ethernet interface address
 *              read list of net devices via ioctl to ifreqs.  Pass over
 *              loopback device and any serial line interfaces.  Return
 *              all devices.
 * 
 *              This function does not require setuid(2) priviledges.
 */

#if 0

This routine accepts two parameters, and returns the count of addresses found
    Input 1:  Area to receive ethernet addresses
    Input 2:  Number of addresses that can fit into the area specified
              by Input 1.  Each address takes 6 bytes.
   Return
      Value:  Positive -- number of addresses returned
              Negative -- absolute value is number of addresses returned,
                          but there are more addresses
              Zero     -- no addresses, or failure

#endif

#define IFREQCNT 64     /* need enough room for total number of possible
                         * interfaces, including aliases for LAT and DECnet
                         */
int getadr(unsigned char hardware[], int count)

    {
    int             s;
    struct ifreq    ifreqs[IFREQCNT];
    struct ifconf   ifc;
    struct ifdevea  ifrp;
    int    index    = 0;
    int    ndx, ifr;

    bzero(&ifrp, sizeof(struct ifdevea));
    if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
        {
        perror("socket");
        return(0);
        }

        ifc.ifc_req = ifreqs;
        ifc.ifc_len = sizeof(ifreqs);
        if (ioctl(s, SIOCGIFCONF, &ifc) < 0)
            {
            perror("ioctl: SIOCGIFCONF");
            return(0);
            }

        for (ifr = 0; ((ifr < IFREQCNT)&&(strlen(ifreqs[ifr].ifr_name) != 0));
ifr++)
            {
                if ((ioctl(s, SIOCGIFFLAGS, &ifreqs[ifr]) < 0)&&(index == 0))
                    {
                    perror("ioctl: SIOCGIFFLAGS");
                    return(0);
                    }

                if ((ifreqs[ifr].ifr_flags & (IFF_POINTOPOINT))
                        == (IFF_POINTOPOINT))
                    {
                    continue;   /* skip point to point */
                    }

                if ((ifreqs[ifr].ifr_flags & (IFF_MULTICAST|IFF_BROADCAST))
                        != (IFF_MULTICAST|IFF_BROADCAST))
                    {
                    continue;   /* skip CI, etc. */
                    }

                strcpy(ifrp.ifr_name, ifreqs[ifr].ifr_name);
                if (ioctl(s, SIOCRPHYSADDR, &ifrp) >= 0)
                 {
                  if (index==0)
                    {
                      if (index == count) return -index;
                      hardware[0+index*6] = ifrp.default_pa[0];
                      hardware[1+index*6] = ifrp.default_pa[1];
                      hardware[2+index*6] = ifrp.default_pa[2];
                      hardware[3+index*6] = ifrp.default_pa[3];
                      hardware[4+index*6] = ifrp.default_pa[4];
                      hardware[5+index*6] = ifrp.default_pa[5];
                      index+=1;
                    }
                  else
                    {
                      for (ndx=0; ; ndx++)
                        {
                          if (ndx == count) return -index;
                          if (ndx == index)
                            {
                              hardware[0+index*6] = ifrp.default_pa[0];
                              hardware[1+index*6] = ifrp.default_pa[1];
                              hardware[2+index*6] = ifrp.default_pa[2];
                              hardware[3+index*6] = ifrp.default_pa[3];
                              hardware[4+index*6] = ifrp.default_pa[4];
                              hardware[5+index*6] = ifrp.default_pa[5];
                              index+=1;
                              break;
                            }
                          if ((ifrp.default_pa[5]==hardware[ndx*6+5])&&
                              (ifrp.default_pa[4]==hardware[ndx*6+4])&&
                              (ifrp.default_pa[3]==hardware[ndx*6+3])&&
                              (ifrp.default_pa[2]==hardware[ndx*6+2])&&
                              (ifrp.default_pa[1]==hardware[ndx*6+1])&&
                              (ifrp.default_pa[0]==hardware[ndx*6+0]))
                            {
                              break;
                            }
                        }
                    }
                 }

            }

    return index;
    }