From:	CSBVAX::MRGATE!MIKE%LOYVAX.BITNET@CUNYVM.CUNY.EDU@SMTP 14-APR-1988 06:46
To:	ARISIA::EVERHART
Subj:	Getting node names on a DECnet.


Received: from CUNYVM.CUNY.EDU by KL.SRI.COM with TCP; Tue 12 Apr 88 14:20:35-PDT
Received: from LOYVAX.BITNET by CUNYVM.CUNY.EDU (IBM VM SMTP R1.1) with BSMTP id 5011; Tue, 12 Apr 88 17:20:29 EDT
Date:     Tue, 12 Apr 88 17:18 EST
From:     <MIKE%LOYVAX.BITNET@CUNYVM.CUNY.EDU>
Subject:  Getting node names on a DECnet.
To:       info-vax@kl.sri.com
X-Original-To:  info-vax@kl.sri.com, MIKE

There has been some talk of late about getting the names of the nodes on a
network from a high level language. "Show network" works well, but that's
only from DCL. The following program will print out the names of all the nodes
in a cluster. We're on a VAXcluster here, so I haven't been able to test it
for all times and places. It shouldn't have any adverse effects when it is run,
because all it does is call a system service.

If you want to use the program to actually do something with the name, the
name is contained in the buffer (item.bufadd^) after the system call. You
can replace the writeln with a procedure of some kind or anything else.

If anyone is on a DECnet that has nodes NOT organized into a cluster and can
tell me if it works for that situation as well, I would appreciate it.

Any comments/questions are welcome. Please send mail to my bitnet address:
Mike@Loyvax.Bitnet

Thanks,
Mike Polek.

(****************************************************************************)

[inherit ('sys$library:starlet')]
program nodenames (input,output);

(* It's basically undocumented, but if you understand system calls, there's not
   much to it. If you don't documentation problably wouldn't help much. Just
   compile and run it and it should work ok....
 *)

const
     len = 16;

type
     string = packed array [1..len] of char;
     byte = [byte] 0..255;
     word = [word] 0..65535;
     quadword = [quad] record
                         x:unsigned;
                         y:unsigned
                       end;
     itemtype = record
                  buflen : word;
                  code   : word;
                  bufadd : ^string;
                  retlen : ^integer;
                  term   : quadword
                end;

var
   status,id : integer;
   item: itemtype;

[external (sys$getsyi)]
function getsyi (%ref efn:integer := %immed 0;
                 %ref csid:integer := %immed 0;
                 %descr nodename:packed array[a..b:integer] of char := %immed 0;
                 %ref itmlst:itemtype;
                 %ref iosb:quadword := %immed 0;
                 %immed [unbound,asynchronous] procedure astadr := %immed 0;
                 %immed astprm:integer := %immed 0):integer;external;

begin
  new (item.bufadd);
  new (item.retlen);
  item.buflen := len;
  item.term.x := 0;
  item.term.y := 0;
  id := -1;   (* wildcard operation to get all nodes *)
  item.code := syi$_nodename;  (* defined in starlet *)
  status := getsyi (csid := id, itmlst := item);
  while status <> ss$_nomorenode do begin
    writeln (item.bufadd^);
    status := getsyi (csid := id, itmlst := item)
  end;
end.

(**************************************************************************)
