Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
* reading E-net address on DecStation 3100
@ 1992-07-27 23:56 Steven Sonnenberg
  1992-07-28 13:41 ` E.C. Loyd
  0 siblings, 1 reply; 6+ messages in thread
From: Steven Sonnenberg @ 1992-07-27 23:56 UTC (permalink / raw)


Could anyone provide a code snipet that reads the ethernet
address (hardware) on a Decstation 3100?

Thanks.

+------------------------------------------------------------------------+
| Steve Sonnenberg        (too busy to do anything fancy, sorry)         |
| Strategic Software Group, Ltd., 3402 Shelburne Rd, Baltimore, MD 21208 |
| E-mail:  steve@ssgltd.com  or  uunet!ssgltd!steve                      |
| Phone:  410-764-0454;  Fax: 410-358-2106;  Pager: 410-938-1612         |
+------------------------------------------------------------------------+


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: reading E-net address on DecStation 3100
  1992-07-27 23:56 reading E-net address on DecStation 3100 Steven Sonnenberg
@ 1992-07-28 13:41 ` E.C. Loyd
  0 siblings, 0 replies; 6+ messages in thread
From: E.C. Loyd @ 1992-07-28 13:41 UTC (permalink / raw)


In article <1992Jul27.235653.19344@socrates.umd.edu> steves@socrates.umd.edu (Steven Sonnenberg) writes:
>Could anyone provide a code snipet that reads the ethernet
>address (hardware) on a Decstation 3100?
>
>Thanks.
>
>+------------------------------------------------------------------------+
>| Steve Sonnenberg        (too busy to do anything fancy, sorry)         |
>| Strategic Software Group, Ltd., 3402 Shelburne Rd, Baltimore, MD 21208 |
>| E-mail:  steve@ssgltd.com  or  uunet!ssgltd!steve                      |
>| Phone:  410-764-0454;  Fax: 410-358-2106;  Pager: 410-938-1612         |
>+------------------------------------------------------------------------+


Well, you can always reboot the machine and watch the configuration display.
This will tell you the Ether address.  Another option is to go into NCP
and do a SHOW LINE CHAR (assuming you're running DECnet under Ultrix).

There are other ways.  These are the easiest.

-Eric

-- 
ECLDCO@RITVAX.bitnet       ECL6895@RITVAX.bitnet
ECLDCO@ultb.isc.rit.edu    ECL6895@ultb.isc.rit.edu
Eric Loyd's the name, Data Center Operations is the game.
Opinions and irrational outbursts are MY pride and joy.  Not my employer's.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: reading E-net address on DecStation 3100
  1992-07-27 21:24     ` Paul Dormitzer
@ 1992-08-05 10:28       ` Delamper Lukas
  1992-08-05 17:03         ` Gary A. Gaudet
  0 siblings, 1 reply; 6+ messages in thread
From: Delamper Lukas @ 1992-08-05 10:28 UTC (permalink / raw)



*
 *      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 demostration
 *              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.
 */

#include <strings.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <stdio.h>

static char getadrSID[] = "@(#)getadr.c 1.3 8/17/89 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; 
{
        struct ifreq ifr;
        char *interface;

        if(argc < 2)
                interface = NULL;
        else
                interface = argv[1];
        if(getadr(interface, &ifr) < 0) {
                fprintf(stderr, "getadr failed, exiting\n");
                exit(1);
        }
        printf("ifr_name = '%s'\n", ifr.ifr_name);
        printf("family = %04x\n", 0xffff & ifr.ifr_addr.sa_family);
        printf(
           "Ethernet hardware address = (%02x-%02x-%02x-%02x-%02x-%02x)\n",
                0xff & ifr.ifr_addr.sa_family,
                0xff & (ifr.ifr_addr.sa_family >> 8),
                0xff & ifr.ifr_addr.sa_data[0],
                0xff & ifr.ifr_addr.sa_data[1],
                0xff & ifr.ifr_addr.sa_data[2],
                0xff & ifr.ifr_addr.sa_data[3]);
        printf(
            "Ethernet physical address = (%02x-%02x-%02x-%02x-%02x-%02x)\n",
                0xff & ifr.ifr_addr.sa_data[4],
                0xff & ifr.ifr_addr.sa_data[5],
                0xff & ifr.ifr_addr.sa_data[6],
                0xff & ifr.ifr_addr.sa_data[7],
                0xff & ifr.ifr_addr.sa_data[8],
                0xff & ifr.ifr_addr.sa_data[9]);
    }

/*      getadr -- get primary ethernet interface address
 *              read /etc/rc.local to find primary interface and query that
 *              device.  This function does not require setuid(2) priviledges.
 *              NOTE:  Assumes standard Ultrix rc.local as set up by
 *                      netsetup(8).  Will break if rc.local was hacked...
 */

/* offsets for tokens on rc.local line */

#define IFCONFIG        0
#define INTERFACE       1
#define HOSTNAME        2
#define BROADCAST       3
#define NUMTOKENS       4
  int getadr(name, ifrp)
char *name;
struct ifreq *ifrp;
{
        int stat, i, s;
        char line[256];
        FILE *rcf;
        char *tokens[NUMTOKENS];
        char *cp;

        if((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
                perror("getadr, socket failed");
                return( -1);
        }
        if(name != NULL)
                strcpy(ifrp->ifr_name, name);
        else {
                if((rcf = fopen("/etc/rc.local", "r")) == NULL) {
                        perror("getadr, open failed on rc.local");
                        return -1;
                }
                while((cp = fgets(line, 256, rcf)) != NULL) {
                        for(i = 0; i < NUMTOKENS; i++) {
                                tokens[i] = cp;
                                while(*cp != NULL && *cp != ' ' &&
                                         *cp != '\t') cp++;
                                if(*cp == NULL)
                                        continue;
                                *cp++ = NULL;
                                while(*cp == ' ' || *cp == '\t') cp++;
                        }
                        if(strcmp(tokens[IFCONFIG], "/etc/ifconfig") == 0
                           && strcmp(tokens[HOSTNAME], "`/bin/hostname`") == 0
                           && strcmp(tokens[BROADCAST], "broadcast") == 0)
                                break;
                }
                fclose(rcf);
                strcpy(ifrp->ifr_name, tokens[INTERFACE]);
        }
        if((stat = ioctl(s, SIOCRPHYSADDR, ifrp)) == -1) {
                perror("getadr, ioctl failed");
                return -1;
        }
        return 0;
}


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: reading E-net address on DecStation 3100
  1992-08-05 10:28       ` reading E-net address on DecStation 3100 Delamper Lukas
@ 1992-08-05 17:03         ` Gary A. Gaudet
  1992-08-07 12:31           ` E.C. Loyd
  0 siblings, 1 reply; 6+ messages in thread
From: Gary A. Gaudet @ 1992-08-05 17:03 UTC (permalink / raw)


Try...

	/etc/uerf | more

Look for...

	...
	----- EVENT INFORMATION -----

	EVENT CLASS                             OPERATIONAL EVENT
	OS EVENT TYPE                  300.     SYSTEM STARTUP
	...
	                                        ln0: DEC LANCE Ethernet Interface,
	                                         _hardware address: 08:00:2b:0e:32:a8
	...


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: reading E-net address on DecStation 3100
  1992-08-05 17:03         ` Gary A. Gaudet
@ 1992-08-07 12:31           ` E.C. Loyd
  1992-08-10  5:23             ` Peter Kaiser
  0 siblings, 1 reply; 6+ messages in thread
From: E.C. Loyd @ 1992-08-07 12:31 UTC (permalink / raw)


In article <1992Aug5.170329.12460@decvax.dec.com> gaudet@decvax.dec.com (Gary A. Gaudet) writes:
>Try...
>
>	/etc/uerf | more
>
>Look for...
>
>	...
>	----- EVENT INFORMATION -----
>
>	EVENT CLASS                             OPERATIONAL EVENT
>	OS EVENT TYPE                  300.     SYSTEM STARTUP
>	...
>	                                        ln0: DEC LANCE Ethernet Interface,
>	                                         _hardware address: 08:00:2b:0e:32:a8
>	...

Yes, that works, but it's not what the person was looking for.  There is
an IOCTL that you can make to the hardware controller and get the hardware
address, and the current address (DECnet, for one, changes the hardware address
to be AA-00-xx-xx-xx-xx instead of 08-00-2B-xx-xx-xx, so it can do lookups
based on a broadcast address and the NCP database).  This is what the person
was looking for, and I sent a snippet of code to do this.  If anyone else
is interested, let me know and I'll drop you the code.

-Eric
-- 
ECLDCO@RITVAX.bitnet       ECL6895@RITVAX.bitnet
ECLDCO@ultb.isc.rit.edu    ECL6895@ultb.isc.rit.edu
Eric Loyd's the name, Data Center Operations is the game.
Opinions and irrational outbursts are MY pride and joy.  Not my employer's.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: reading E-net address on DecStation 3100
  1992-08-07 12:31           ` E.C. Loyd
@ 1992-08-10  5:23             ` Peter Kaiser
  0 siblings, 0 replies; 6+ messages in thread
From: Peter Kaiser @ 1992-08-10  5:23 UTC (permalink / raw)



--
Code to do this is also on Digital's freeware CD.

___Pete

kaiser@uniriv.vbo.dec.com
+33 92.95.62.97 (DTN 828-6297)


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1992-08-10  5:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1992-07-27 23:56 reading E-net address on DecStation 3100 Steven Sonnenberg
1992-07-28 13:41 ` E.C. Loyd
  -- strict thread matches above, loose matches on Subject: below --
1992-07-26  5:50 VAX question dwagoner
1992-07-26 21:19 ` Boyd Roberts
1992-07-26 22:39   ` VAX question (P0/P1 space) Eliot Moss
1992-07-27 21:24     ` Paul Dormitzer
1992-08-05 10:28       ` reading E-net address on DecStation 3100 Delamper Lukas
1992-08-05 17:03         ` Gary A. Gaudet
1992-08-07 12:31           ` E.C. Loyd
1992-08-10  5:23             ` Peter Kaiser

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox