From:	CSBVAX::MRGATE!info-vax-RELAY@KL.SRI.COM@SMTP  9-FEB-1988 04:39
To:	ARISIA::EVERHART
Subj:	How to find out if a DECnet node is 'known'


Received: from ucbvax.Berkeley.EDU by KL.SRI.COM with TCP; Fri 29 Jan 88 10:40:51-PST
Received: by ucbvax.Berkeley.EDU (5.58/1.26)
	id AA23596; Fri, 29 Jan 88 09:45:49 PST
Received: from USENET by ucbvax.Berkeley.EDU with netnews
	for info-vax@kl.sri.com (info-vax@kl.sri.com)
	(contact usenet@ucbvax.Berkeley.EDU if you have questions)
Date: 27 Jan 88 12:55:34 GMT
From: mcvax!ukc!stc!stl!dww@uunet.uu.net  (David Wright)
Subject: How to find out if a DECnet node is 'known'
Message-Id: <616@acer.stl.stc.co.uk>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com

I recently needed to know whether a DECnet node was 'known'.  This was within
a DCL procedure we run nightly on all our DECnet nodes to update the DECnet
tables from a central master list.    If you try to remove a node that isn't
there you get lots of error messages! 

There does not appear to be a DCL lexical function to reveal if a node is
known, so I had to find an alternative; look up the node in the appropriate
DECnet file.  In this case I needed to check the address, not the name, so I
had to convert the form area.node into the internal binary format. 

The method I worked out may be useful to others, so I'm posting it to the net 
as a small stand-alone .COM procedure - as it's small I'm not VMS_SHAR'ing it.
There is a note in the code on how to lookup by name too.

This procedure has been tested with VMS 4.4/5/6.  The DECnet file format
was changed in VMS 4.4 when the files were reorganised, to simplify cluster
operation I think.  We haven't seen 4.7 yet.   I would expect the format to
change again eventually (VMS 5?), as DECnet's present address range is
inadequate for very large networks. 

$! ----------------------------- Cut Here ------------------------------------
$! Check whether a DECnet node address is 'known' by converting to 16-bit 
$! binary form and looking it up in the DECnet tables.
$!
$! The address should be in standard DECnet area.node form, e.g. 1.3
$! This is converted as follows:
$!   area in first 6 bits range 1-63, node in remaining 10 bits range 1-1023
$! The actual lookup treats the binary number as a 2-char string, because 
$! DCL read/key only accepts string type keys.
$!
$! The first two fields of netnote_remote.dat under VMS V4.4+ are
$!	address as a 16-bit binary number
$!	name    as a 6-byte fixed string
$! This file format was different under VMS V4.2 and may change again in V5
$!
$! Author: David Wright - dww@stl.stc.co.uk - December 1987
$!
$ address = p1
$ if p1 .eqs. "" then inquire address
$!
$ if f$element(0,".",address) .lt. 1 .or. f$element(1,".",address) .lt. 1 -
	then goto NO_CANCEL	! neither field can be 0
$!
$!!!TEST $ bin_address = -
$!!!TEST 	f$element(0,".",address) * 1024 + f$element(1,".",address)
$!!!TEST $ show symbol bin_address
$ str_address[0,16] = -
	f$element(0,".",address) * 1024 + f$element(1,".",address) 
$ open/read/share netnode sys$system:netnode_remote.dat
$ read /index=0 /key="''str_address'" /match=eq /error=NO_CANCEL netnode line
$! If you want to search on name instead, use ... index=1 /key="''name'" ...
$ close netnode
$!
$ write sys$output address, " is known, name ", f$extract(2,6,line)
$ exit

$NO_CANCEL:
$ write sys$output address, " not found"
$ exit

-- 
Regards,
        David Wright           STL, London Road, Harlow, Essex  CM17 9NA, UK
dww@stl.stc.co.uk <or> ...uunet!mcvax!ukc!stl!dww <or> PSI%234237100122::DWW

-------

