From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 13-DEC-1989 17:00
To:	MRGATE::"ARISIA::EVERHART"
Subj:	RE: How to convert node number to name

Message-Id:  <8912132123.AA27223@crdgw1.ge.com>
Received: From OLY.ACS.WASHINGTON.EDU by CRVAX.SRI.COM with TCP; Wed, 13 DEC 89 12:56:23 PDT
Received: from UWAVM.ACS.WASHINGTON.EDU by UWAVM.ACS.WASHINGTON.EDU (IBM VM SMTP R1.2) with BSMTP id 8809; Wed, 13 Dec 89 12:55:09 PST
Received: from FHCRCVAX.BITNET (JOE) by UWAVM.ACS.WASHINGTON.EDU (Mailer R2.04)
 with BSMTP id 9364; Wed, 13 Dec 89 12:55:02 PST
Date: Wed, 13 Dec 89 12:51 PST
From: Joe Meadows <JOE%FHCRCVAX.BITNET@UWAVM.ACS.WASHINGTON.EDU>
Subject: RE: How to convert node number to name
To: info-vax@sri.com
X-Vms-To: INFO-VAX

>Ahh, now that's more like it, but I need the answer quickly (ie spawning
>is out of the question).  What I'm looking for is the code to do it using
>NICE, or some other magic hook into the NML database.  Sorry, I should have
>said so in the first place.  Alternately, a pointer to the obscure
>manual where this undocumented feature is documented might be useful
>...although last time I ordered an obscure document from DEC it took
>10 months to get here - no kidding.

        I tried replying to this but it bounced. Since several people
have offered other solutions, I thought I should post the 'best' solution.
I wrote a chunk of code (as an example) to do exactly what you want.
If you send a mail message to VMSSERV@FHCRCVAX.BITNET containing a message
with the one line of "SEND DECNET.PACKAGE" you'll get a few examples (in C)
one of which is precisely what you asked for (in the file EXAMPLE.C).

        Cheers,
        Joe Meadows     joe@fhcrcvax.bitnet

Here's a copy of the relavent section of code....

/*
  Get the DECNet node name from a node number (viz. gethostbyaddress(addr)).
  Note the address is a single longword - use the formula for converting
  area number and node number into a longword.. Off the top of my head
  I believe it is ((area number * 1024) + node number), i.e. 1.1 = 1025
*/
#include <descrip.h>
#include <iodef.h>
#include <dvidef.h>

#define NFB_MAX_FIELD_ID_ENTRIES 5
#include "nfbdef.h"

struct itmlst
{
  short length;
  short code;
  long address;
  long retlen;
};

static short chan = 0;

init_netacp()
{
  static $DESCRIPTOR(Net,"Net:");

  if (chan == 0)
    return(sys$assign (&Net, &chan, 0, 0));
  else
    return(1);
}

gethostbyaddress(long add)
{
  struct nfbdef nfb = { NFB$C_FC_SHOW, NFB$M_NOCTX, NFB$C_DB_NDI, NFB$C_OP_EQL,
                 /* use NFB$C_NDI_TAD if you don't express local node as 0 */
                        NFB$C_NDI_ADD, NFB$C_WILDCARD, 0, 0, 0,
                        NFB$C_NDI_NNA, NFB$C_ENDOFLIST };
  struct dsc$descriptor nfbdesc = {sizeof(nfb), 0, 0, &nfb};
  struct {
    long int p4_count;
    long add;
  } key = {0,add};
  struct dsc$descriptor keydesc = {sizeof(key), 0, 0, &key};
  struct
  {
    short len;
    char name[6];
  } nodename;
  struct dsc$descriptor bufdesc = {sizeof(nodename), 0, 0, &nodename};
  int status, iosb[2], i, j, retlen;

  init_netacp();

  status = sys$qiow (0,chan,IO$_ACPCONTROL,iosb,0,0,
               &nfbdesc,&keydesc,&retlen,&bufdesc,0,0);
  if (ncp_error(status,iosb))
  {
    return(0);
  }
  else
  {
    printf("node %d is %.*s\n",add,nodename.len,nodename.name);
    return(1);
  }
}

