From: YODERS@prime.wittenberg.edu
Subject: NT$LTS
Reply-To: Info-Prime@Blx-A.Prime.COM
Date: Mon, 13 Apr 1992 20:52:01 GMT

Chuck, et. al.

    On the subject of NT$LTS, the only documentation I have been able
to find is in Subr. IV, which gives you the documentation on NTS
information.  Before I discovered that IP numbers were not
accessible (with TCP/IP 2.3), I tried calling NT$LTS.  It seemed
close to what I wanted.  It returned the information that you are
getting (i.e. 32.32.32.32 port 8224).  That was when I first asked
about it on the list.  (BTW, the above test was with TCP/IP
2.3R20-ish and Primos 22.1.4.R20-ish).

    Along comes TCP/IP 2.4.  In the UPINFO for the release they
mention that NT$LTS now returns the IP number of incoming Telnet
connections, with the 1st 32 bits being the IP and the last 16 bits
the (remote) port number.  This is the MAC_ADDRESS argument.  And,
IT WORKED!  I tried using the DISPLAY_NTS_USERS supplied as an
example, but it invariably bombed off with an ACCESS VIOALTION.  The
big difference between Eric Ross' experience and mine is that I get
the correct IP before it bombs.  It looks to me like the problem is
something to do with the socket call to get the system name (the
address points at the socket.run library).

    To get the new functionality, all I had to do was install TCP/IP
2.4.  Nothing had to be done to Primos.  Looking at the TCP/IP
install, there is nothing that replaces any standard libs, so I can
only assume that the change is in how the Telnet sever functions.  I
assume that it now places the IP & port into a Primos common block
somewhere that NT$LTS looks for the LTS hardware address.  The only
real change is in how you interpret it.  This is why I am guessing
that there is something wrong with TCP/IP 2.4R4 (I have it here, but
haven't installed it yet).

    Below is a subroutine I wrote to use in an external login for
checking incoming IP addresses.  It WORKS PERFECTLY.  I am at Primos
22.1.4R35 and TCP/IP 2.4, no RRS release at all.

Kevin Yoders
Wittenberg University

/*   Title: GET_IP.PLP
/*  Author: WITT:KJY
/*    Date: 03/01/92
/* Purpose: Given a line number, return the relevant TELNET information.
/*
/* */

get_ip: proc(line_no,ip_char,telnet_port,ret_code);

/* declare subroutine arguments                                            */
dcl line_no fixed bin;       /* the Primos line number                     */
dcl ip_char (4) char(1);     /* telnet ip address as array of char(1) (C)  */
dcl telnet_port fixed bin;   /* telnet port number                         */
dcl ret_code fixed bin;      /* return code from GET_IP                    */

$Insert syscom>errd.ins.pl1

/* declare external entries                                                */
dcl nt$lts entry(fixed bin,fixed bin,char(16) var,fixed bin,
                 char(6),fixed bin);

/* declare misc. variables                                                 */
dcl media_type fixed bin;   /* used by NT$LTS. currently only 0            */
dcl lts_name char(16) var;  /* name of configured LTS (NTS only)           */
dcl lts_line fixed bin;     /* line number on LTS (NTS only)               */
dcl mac_address char(6);    /* address of LTS/remote telnet                */
dcl code fixed bin;         /* return code from nt$lts                     */
dcl ctr fixed bin;          /* general purpose counter                     */
dcl chr2bit8 (4) bit(8) based;  /* used to compare octets                  */

/* assume no errors */
ret_code = e$ok;

/* now get lan info */
call nt$lts(line_no,media_type,lts_name,lts_line,mac_address,code);

   if (code = e$ok) then do; /* no errors from nt$lts */

   /* pull out the IP address */
   do ctr = 1 to 4;
      ip_char(ctr) = substr(mac_address,ctr,1);
   end;

   /* extract the telnet port */
   telnet_port = char2_to_bin(substr(mac_address,5,2));

   /* now check to see if it is NTS or TELNET.  This test was taken   */
   /* from the sample DISPLAY_NTS_USERS.CC that comes with TCP/IP     */
   /* 2.4.  I assume it is correct.  The comments indicate that       */
   /* it will not correctly distinguish NTS from TELNET if you        */
   /* are on the 008.000.047 subnet.  These people will appear as NTS */

   if ((addr(ip_char) -> chr2bit8(1) = '08'b4) &
       (addr(ip_char) -> chr2bit8(2) = '00'b4) &
       (addr(ip_char) -> chr2bit8(3) = '2F'b4)) then do;

      /* we are NTS.  return e$rmln (336), which is                     */
      /* "illegal operation on remote line".  sort of makes sense, you  */
      /* can't get the IP if it isn't telnet. sites not using LTS boxes */
      /* can treat this code the same as e$ok.  we have extracted the   */
      /* correct information                                            */

      ret_code = e$rmln;

   end;

end; else do;

   /* an error occurred in NT$LTS. return NT$LTS's error code (already in  */
   /* code)                                                                */
   ret_code = code;
end;

return; /* done with get_ip */

/* converts a char(2) to a fixed bin */
char2_to_bin: proc(input) returns(fixed bin);

dcl input char(2);
dcl result fixed bin(15);
dcl 1 chars_based based,
       2 char1 char(1),
       2 char2 char(2);
dcl bin_based fixed bin based;

return (addr(input) -> bin_based);
end; /* char2_to_bin */

end; /* get_ip */

Newsgroups: comp.sys.prime