home *** CD-ROM | disk | FTP | other *** search
- #ifndef lint
- static char rcsid[] =
- "@(#) $Header: rmtinfo.c,v 1.3 87/04/09 20:20:51 leres Exp $ (LBL)";
- #endif
- /*
- * The privilege NETMBX is required for use.
- *
- * Warning: This routine is chalked full of undocumented MAGIC.
- */
- #include <ctype.h>
- #include <strings.h>
-
- #include "vms/nfbdef.h"
- #include "vms/ssdef.h"
- #include "vms/iodef.h"
-
- /*
- * Use nfb block to help define what we need.
- */
- static struct XNFB {
- struct NFB x;
- #define xnfb$b_fct x.nfb$b_fct
- #define xnfb$b_flags x.nfb$b_flags
- #define xnfb$b_database x.nfb$b_database
- #define xnfb$b_oper x.nfb$b_oper
- #define xnfb$l_srch_key x.nfb$l_srch_key
- #define xnfb$l_srch2_key x.nfb$l_srch2_key
- #define xnfb$l_x_lli_pna x.nfb$l_fldid
- unsigned long xnfb$l_x_lli_pnn;
- unsigned long xnfb$l_x_endoflist;
- } nfb;
-
- static struct acpbuf {
- long a_node; /* decnet node number */
- short a_length; /* length of the decnet host name */
- char a_name[6]; /* decnet host name */
- } abuf;
-
- static struct dsc {
- long d_length;
- char *d_address;
- };
-
- rmtinfo(link, node, name)
- long link;
- long *node;
- char *name;
- {
- register int i, status;
- int sys$assign(), sys$qiow();
- short iosb[4];
- struct dsc netdsc, nfbdsc, keydsc, bufdsc;
- long key[2];
- static int chan = 0;
-
- /*
- * If necessary, assign a channel to NET
- */
- if (!chan) {
- netdsc.d_address = "NET:";
- netdsc.d_length = strlen(netdsc.d_address);
- if ((status = sys$assign(&netdsc, &chan, 0, 0)) != SS$_NORMAL)
- return(status);
- }
- /*
- * Set up the nfb request buffer
- */
- bzero(&nfb, sizeof(nfb));
- nfb.xnfb$b_fct = NFB$C_FC_SHOW;
- nfb.xnfb$b_flags = NFB$M_NOCTX; /* don't update the database */
- nfb.xnfb$b_database = NFB$C_DB_LLI; /* logical link info database */
- nfb.xnfb$b_oper = NFB$C_OP_EQL; /* match the key exactly */
- nfb.xnfb$l_srch_key = NFB$C_LLI_LLN; /* key is logical link number */
- nfb.xnfb$l_srch2_key = NFB$C_WILDCARD; /* search the whole database */
- nfb.xnfb$l_x_lli_pna = NFB$C_LLI_PNA; /* partner's node address */
- nfb.xnfb$l_x_lli_pnn = NFB$C_LLI_PNN; /* partner's node name */
- nfb.xnfb$l_x_endoflist = NFB$C_ENDOFLIST;
- /*
- * Construct the nfb descriptor
- */
- nfbdsc.d_address = (char *) &nfb;
- nfbdsc.d_length = sizeof(nfb);
- /*
- * Construct the key descriptor
- */
- keydsc.d_address = (char *) &key[0];
- keydsc.d_length = sizeof(key);
- /*
- * Construct the logical link key descriptor
- */
- key[0] = 0;
- key[1] = link;
- /*
- * Construct the return buffer descriptor
- */
- bufdsc.d_address = (char *) &abuf;
- bufdsc.d_length = sizeof(abuf);
- /*
- * Ask NET about this port
- */
- status = sys$qiow(0, chan, IO$_ACPCONTROL, iosb, 0, 0,
- &nfbdsc, &keydsc, 0, &bufdsc, 0, 0);
- if (status != SS$_NORMAL)
- return(status);
- status = iosb[0];
- if (status != SS$_NORMAL)
- return(status);
- /*
- * Return the node number
- */
- *node = abuf.a_node;
- /*
- * Return the node name
- */
- if ((i = abuf.a_length) > sizeof(abuf.a_name))
- i = sizeof(abuf.a_name);
- name[i] = '\0';
- for (--i; i >= 0; i--)
- if (isupper(name[i] = abuf.a_name[i]))
- name[i] = tolower(name[i]);
- return(SS$_NORMAL);
- }
-