From:	CSBVAX::CSBVAX::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 29-MAR-1989 17:34
To:	MRGATE::"ARISIA::EVERHART"
Subj:	DECnet_Enet.Com - converts DECnet address to Ethernet address


Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Wed, 29 MAR 89 14:02:11 PDT
Received: from hqhsd.brooks.af.mil by KL.SRI.COM with TCP; Wed, 29 Mar 89 13:43:06 PST
Date: 29 Mar 89 15:24:00 CST
From: "HSDP1::WILSONJL" <wilsonjl%hsdp1.decnet@hqhsd.brooks.af.mil>
Subject: DECnet_Enet.Com - converts DECnet address to Ethernet address
To: "info-vax" <info-vax@kl.sri.com>


Here's the companion hack to the ENET_DECNET.COM procedure I posted a few days
ago. Sure enough, I had the need for the reverse operation. Here it is for your
benefit (?)


Jonathan L Wilson 
TRW Defense Systems Group 
MILNET: WILSONJL@HQHSD.BROOKS.AF.MIL 
Phone:  (512) 536 2236   
Standard disclaimer applies.


--------------------------------------


$!
$! DECnet_Enet.COM converts a DECnet node's address to its Ethernet
$! address.
$!
$! Jonathan L Wilson/TRW 28-Mar-1989
$!
$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
$!
$GET_P1:
$	if (p1 .eqs. "") then inquire/nopunct p1 "DECnet address: "
$	if (p1 .eqs. "") then goto GET_P1
$	p1 = f$edit(p1,"TRIM,UPCASE,COLLAPSE")
$!
$!Check address - std addresses have a period 
$!
$	if (f$locate(".",p1).eqs.f$length(P1)) 
$	  then
$	    write sys$output "''p1' is not a standard DECnet address"
$	    EXIT
$	endif
$!
$!Separate address into area and node and check
$!
$	area = f$integer(f$element(0,".",p1))
$	node = f$integer(f$element(1,".",p1))
$	if ((node .eq. 0) .or. (area .eq. 0))  
$	  then
$	    write sys$output "''p1' is not a standard DECnet address"
$	    EXIT
$	endif
$!
$!Convert into integer
$!
$	result = (area * 1024) + node
$	assign sys$scratch:DECNET_ENET.TMP sys$output
$	sho symb result
$	deassign sys$output
$	open/read temp sys$scratch:decnet_enet.tmp
$	read temp line
$	close temp
$	delete/noconf/nolog sys$scratch:decnet_enet.tmp;
$!
$!Process input line
$!
$	line = f$edit(line,"TRIM,COMPRESS")
$	hexaddress = f$element(5," ",line)
$	hexaddress = f$extract(4,4,hexaddress)
$!
$!Swap bytes
$!
$	least = f$extract(0,2,hexaddress)
$	most = f$extract(2,2,hexaddress)
$	addr = "AA-00-04-00-''most'-''least'"
$!
$!Display results
$!
$	write sys$output ""
$	write sys$output "For DECnet address ''p1':"
$	write sys$output "Ethernet address = ''addr'"
$	write sys$output ""
$!
$	EXIT


