Trailing-Edge
-
PDP-10 Archives
-
BB-J710A-BM
-
tools/nrt20/nrt20.mac
There are no other files named nrt20.mac in the archive.
TITLE NRT20 - Program to permit logins to remote network host
;COPYRIGHT (C) 1979 BY
;DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
;
;
;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND COPIED
;ONLY IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE AND WITH THE
;INCLUSION OF THE ABOVE COPYRIGHT NOTICE. THIS SOFTWARE OR ANY OTHER
;COPIES THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY
;OTHER PERSON. NO TITLE TO AND OWNERSHIP OF THE SOFTWARE IS HEREBY
;TRANSFERRED.
;
;
;THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE
;AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT
;CORPORATION.
;
;DIGITAL ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY OF ITS
;SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DIGITAL.
SALL ; Keep listing uncluttered, no macro expansion
SEARCH MONSYM,MACSYM,CMD ; Universals to search
.REQUIRE SYS:MACREL,SYS:CMD ; Make LINK load these automatically
;
; This program will allow a user to login in to a remote system in a
; DECnet network from a TOPS-20 host system. It demonstrates use of the
; TOPS-20 DECnet functionality in a program which performs a real function.
; The remote system must provide a program which acts as a server to
; this program. The NRTSRV program is an example of a program written for
; TOPS-20 which will perform that function on that system. Programs for
; other systems must perform functionally similar to NRTSRV.
;
SUBTTL DECLARED SYMBOLS
T1==1 ; AC definitions
T2==2
T3==3
T4==4
CX==16
P==17
NPDL==20 ; Size of pushdown list
INSIZ==50 ; Terminal input buffer size, in words
MAXINP==INSIZ*5 ; Maximum number of terminal input characters
DBUFFR==100000 ; Data buffer on page 100
SUBTTL IMPURE STORAGE
STIMSK: BLOCK 1 ; Terminal interrupt word mask for STIW
LOCAL: BLOCK 2 ; Local node name
DCNJFN: BLOCK 1 ; JFN of logical link to NRTSRV server
INSTR: BLOCK INSIZ ; Terminal input stream buffer
SAVACE: BLOCK 4 ; Register save area for AC's 1 - 4
NAME: BLOCK 10 ; File spec name of logical link to NRTSRV
FORK: BLOCK 1 ; Handle of inferior process to read from TTY
VIRGIN: EXP -1 ; Flag to indicate fresh start, initially -1
PC: BLOCK 3 ; Storage for PC on interrupts
LEVTAB: PC ; Software interrupt level table
PC+1
PC+2
CHNTAB: 0 ; Software interrupt channel table
1,,ESC ; Panic character (default ^Y)
0
PDL: BLOCK NPDL ; Pushdown list (STACK)
CMDSTG ; Command parser storage (from CMDS)
SUBTTL START - Start of NRT20 program
START: RESET ; Intialize ourself
MOVE P,[IOWD NPDL,PDL] ; and set up pushdown list
AOS VIRGIN ; Bump count of times we come through here
CALL CMDINI ; Initialize command parser
MOVX T1,CR%MAP ; Create process to read from TTY
SETZM T2
CFORK ; Make the process, same address map
JRST [ JSHLT ; on error... halt and allow continue
JRST START]
MOVEM T1,FORK ; Save the process handle obtained
MOVEI T1,.FHSLF ; Our process handle
RPCAP ; Get our capabilities
TXO T3,SC%CTC ; allow ^C trapping for job
EPCAP ; Enable new set of capabilities
MOVE T2,[LEVTAB,,CHNTAB] ; Address of software interrupt system tables
SIR ; Give them to monitor
MOVX T2,1B1 ; Channel number
AIC ; Activate software interrupt channels
EIR ; Enable software interrupt system
CALL ALLON ; Turn on all TTY interrupts
CALL PRESCN ; Prescan EXEC line for host name...
JRST PREHST ; Got it - skip the prompting
JRST ESCHAR ; Otherwise get it now
SUBTTL ESCHAR - Obtain the escape character user wants to use
ESCHAR: PROMPT <Escape character(^Y):> ; Put out prompt to users terminal
MOVEI T1,[FLDDB. (.CMTXT,CM%SDH,,<Character for interrupting connection>,<>)]
CALL CFIELD ; Read the escape character
LDB T1,[POINT 7,ATMBUF,6] ; Get character itself
CAILE T1,.TICCZ ; Is it a valid character? (^A to ^Z)
JRST [ HRROI T1,[ASCIZ /Invalid character/] ; No, tell user
ESOUT
JRST ESCHAR] ; and try again
MOVNI T2,0(T1) ; Save the character
HRLS T1 ; Character value is terminal code
HRRI T1,1 ; Channel number
ATI ; Assign terminal code to software interrupt channel
MOVX T1,1B0 ; Get a bit
LSH T1,0(T2) ; Make terminal interrupt word mask for character
TXO T1,1B<.TICTI> ; Allow typein
MOVEM T1,STIMSK ; Save for use later
JRST HSTNAM ; Get the host name
SUBTTL HSTNAM - Get the host name user wants to login on
HSTNAM: PROMPT <Host name: > ; Put out prompt to users terminal
PREHST: MOVEI T1,[FLDDB. (.CMTXT,CM%SDH,,<Name of system to connect to>)]
CALL CFIELD ; Read host name
HRROI T1,INSTR ; Pointer to destination buffer
HRROI T2,ATMBUF ; Pointer to source buffer
MOVEI T3,0 ; An ASCIZ string
SOUT ; Copy the host name
MOVX T1,177B6 ; See if real host name given
TDNN T1,INSTR ; Was one?
JRST [ HRROI T1,[ASCIZ /
[CONNECTING TO LOCAL HOST- /] ; No, tell user what's happening
PSOUT
MOVEI T1,.NDGLN ; Function code to get local node name
MOVEI T2,T3
HRROI T3,INSTR
NODE ; Obtain local node name
HRROI T1,INSTR
PSOUT ; Output to user's TTY
HRROI T1,[ASCIZ /]
/]
PSOUT ; Finish the message nicely
JRST .+1]
JRST SETTMD ; Have name. Now set TTY modes
SUBTTL SETTMD - Set TTY modes
SETTMD: MOVEI T1,.PRIIN ; Primary input
RFMOD ; Get current JFN mode word
TXO T2,TT%WAK ; Wake on all
TXZ T2,TT%ECO!TT%DAM ; Echoes off and binary data mode
SFMOD ; Set new JFN mode word
MOVX T1,.FHJOB ; Set terminal interrupt word for entire job
MOVE T2,STIMSK ; Get terminal interrupt word saved earlier
STIW ; Set it to allow only panic interrupts
HRROI T1,NAME ; Build network file spec to NRTSRV
HRROI T2,[ASCIZ /DCN:/] ; The DECnet device for making connection
SETZM T3
SOUT
HRROI T2,INSTR ; The node name to connect to
SOUT
HRROI T2,[ASCIZ /-200/] ; NRTSRV's object type
SOUT
MOVX T1,GJ%SHT ; Do a short form GTJFN
HRROI T2,NAME ; Using the spec just built
GTJFN ; Get DCN connection
JRST [ JSERR ; If error, tell user
CALL ALLON ; Reset TTY to normal mode
JRST HSTNAM] ; And go back to get host name
MOVEM T1,DCNJFN ; Save JFN for the connection
MOVEI T1,.PRIOU ; Check if parity OK on this TTY
GDSTS ; Get device status
ERJMP [SETZM T2 ; If error, set all status off
JRST .+1] ; And continue along
MOVE T1,DCNJFN ; Restore the JFN for network connection
TXNE T2,GD%PAR ; Does terminal allow parity?
SKIPA T2,[FLD(^D8,OF%BSZ)!OF%RD!OF%WR] ; Yes, 8 bit bytes and read/write access
MOVE T2,[FLD(^D7,OF%BSZ)!OF%RD!OF%WR] ; No, then 7 bit bytes and read/write access
OPENF ; Open the network connection
ERJMP [JSERR ; If failed, tell user
MOVE T1,DCNJFN ; And release the JFN
RLJFN
JFCL
CALL ALLON ; Reset TTY to normal mode
JRST HSTNAM] ; And go back to get host name
MOVE T1,FORK ; Restore the process handle obtained
MOVEI T2,DOINP0 ; The start address
SFORK ; Start the process to read input from TTY
ERJMP [RESET ; If failed, reset ourself
JSHLT ; Tell user and halt
JRST START] ; Go back to beginning if continued
JRST GOTDA1 ; Connection now opened. Wait for input
SUBTTL GOTDA1 - Read data from network connection
GOTDA1: MOVE T1,DCNJFN ; Get the network connection JFN
MOVE T2,[POINT ^D8,DBUFFR] ; Pointer to buffer
MOVNI T3,1 ; One byte only
SIN ; Read from logical link
ERJMP BADCON ; If error, connection broken
MOVE T3,T2 ; Save byte pointer
SIBE ; Any more data to read now ?
SKIPA ; Yes, read the rest
JRST [ SETZM T4 ; No, then go type what there is to user
JRST GOTDAX]
EXCH T2,T3 ; Restore byte pointer
MOVE T4,T3 ; Save count
MOVNS T3 ; Read the exact number available
SIN ; Read remaining bytes
ERJMP BADCON ; If error, connection broken
GOTDAX: MOVEI T1,.PRIOU ; Output to users terminal
MOVE T2,[POINT ^D8,DBUFFR] ; Pointer to data from remote host
MOVNI T3,1(T4) ; Output count
SOUT ; Type data on users terminal
JRST GOTDA1 ; And continue
SUBTTL ALLON - Restore echoing and interrupts on terminal
ALLON: MOVX T1,.FHJOB ; Set terminal interrupt word for entire job
SETOM T2 ; Terminal interrupt word mask for all codes
STIW ; Set terminal interrupt word
MOVEI T1,.PRIIN ; Primary input
RFMOD ; Read JFN mode word
TXO T2,TT%ECO!TT%DAM ; Echo on, ASCII data mode, output translation disabled
SFMOD ; Set new JFN mode word
RET ; Done, return to caller
SUBTTL PRESCN - Prescan EXEC command for host name
PRESCN: SKIPE VIRGIN ; Starting out fresh?
RETSKP ; No..., so return +2 to force prompt
MOVEI T1,.RSINI ; Make rescan buffer available
RSCAN ; as command line to process reading from CTTY
ERJMP PRESC1
MOVX T1,.RSCNT ; Get count of characters
RSCAN ; in rescan buffer
ERJMP PRESC1
JUMPE T1,[RETSKP] ; None there, so must prompt
MOVEI T1,.PRIIN ; Primary input
BIN ; Read a character
CAIE T2,"R" ; RUN or R (program name can't start with "R")
CAIN T2,"r" ; Check lowercase also
JRST PRESC0 ; Yes, no prescanning, go eat rest of line
PRES1: CAIE T2," " ; Have we hit a space yet?
CAIN T2," " ; Also accept a tab
JRST PRES2 ; Yes, read the node name
CAIN T2,.CHLFD ; Have we hit EOL yet?
RETSKP ; Yes, no node name, skip return to prompt
BIN ; Read the next character
JRST PRES1 ; And loop to test
PRES2: MOVSI T1,.TICCY ; Default to ^Y for interrupt character
HRRI T1,1 ; And use channel one
ATI ; Assign terminal code to interrupt channel
MOVX T1,1B0 ; Get a hi order bit
LSH T1,-.TICCY ; Shift bit by value of ^Y code
TXO T1,1B<.TICTI> ; Allow typein
MOVEM T1,STIMSK ; Save for use later
TMSG <[Type ^Y to return to node > ; Tell user how to get back
MOVX T1,.NDGLN
MOVX T2,T3
MOVE T3,[POINT 7,LOCAL]
NODE ; And name of local node
JFCL
HRROI T1,LOCAL
PSOUT
TMSG <]
> ; Finish off nicely
PROMPT <> ; Null prompt
RET ; Done, return no skip to not prompt
;HERE TO FLUSH REST OF EXEC COMMAND LINE
PRESC0: BIN ; Get next byte
CAIE T2,.CHLFD ; The end of line?
JRST PRESC0 ; No, Try again
RETSKP ; Yes, return +2 to prompt for node
;Here if rescan attempt does not succeed
PRESC1: HRROI T1,[ASCIZ/Unexpected error in scanning command line/] ; If error,
ESOUT ; tell user
HALTF ; and halt
JRST START ; Start over if continued...
SUBTTL BADCON - Handle a broken network connection
BADCON: CIS ; Prevent further interruption
CALL ALLON ; Restore TTY modes
MOVE T1,FORK ; Restore the process handle
KFORK ; Kill the terminal input process
HRROI T1,[ASCIZ /
?Connection broken. Reason: /] ; Tell user bad news
PSOUT
MOVE T1,DCNJFN ; Restore network connection JFN
MOVEI T2,.MORLS ; Get current link status
MTOPR
HRRZ T2,T3 ; Get DECnet error reason code
MOVEI T1,.PRIOU ; Output to users terminal
MOVEI T3,12 ; In decimal
NOUT ; Type it
JFCL
CAIG T2,MAXMSG ; Know about this error?
SKIPN T1,MSGTBL(T2) ; Yes, have one to type?
SKIPA ; No
PSOUT ; Yes, type it then
HRROI T1,[ASCIZ /
/]
PSOUT ; Pretty it
MOVE T1,DCNJFN ; Get the JFN for the link
TXO T1,CZ%ABT ; Abort any operations
CLOSF ; Close it
ERJMP [JSERR ;If fails tell why
JRST .+1]
HALTF ; Halt here
JRST START ; And start at beginning if continued
SUBTTL ESC - Handle input of panic escape character from terminal
;
; Note: This routine runs at software interrupt level when the user
; types the specifed escape character. It resets the terminal
; to its normal mode and halts, thus causing the EXEC to regain
; control. If the EXEC CONTINUE command is issued data will be
; again directed to the remote host.
;
ESC: DMOVEM T1,SAVACE ; Save AC's we're going to use
DMOVEM T3,SAVACE+2
MOVE T1,FORK ; Restore process handle
FFORK ; Freeze the terminal input process
MOVEI T1,.PRIOU ; Users terminal
RFMOD ; Get current TTY modes
PUSH P,T2 ; Save them
TXO T2,TT%DAM ; ASCII data mode, output translation disabled
SFMOD ; Set new JFN mode word
CFOBF ; Flush any pending terminal output
MOVEI T1,.PRIIN ; Users terminal
CFIBF ; Flush terminal type ahead
HRROI T1,[ASCIZ /
[Connection broken, back at node /] ; Tell user he's now talking to us
PSOUT
MOVX T1,.NDGLN
MOVX T2,T3
MOVE T3,[POINT 7,LOCAL]
NODE ; Get our node name
JFCL
HRROI T1,LOCAL
PSOUT ; Type node name to user
HRROI T1,[ASCIZ/,
Type CONTINUE to resume connection]
/] ; Let him know how to restart
PSOUT
HALTF ; Halt here until continued
HRROI T1,[ASCIZ/%Reconnecting to remote node...
/] ; Let user know we are restarting
PSOUT
MOVEI T1,.PRIOU ; Users terminal
POP P,T2 ; Desired TTY modes
SFMOD ; Set new JFN mode word
MOVE T1,FORK ; Restore process handle
RFORK ; Resume the terminal input process
DMOVE T1,SAVACE ; Restore the AC's
DMOVE T3,SAVACE+2
DEBRK ; And finish interrupt processing
SUBTTL DOINP0 - Read terminal input and send to remote host
;
; Note: This routine runs as a separate process to read characters
; from the users terminal and send them to the NRTSRV server
; which is running on the remote host system
;
DOINP0: MOVEI T4,MAXINP ; Maximum input characters
MOVE T3,[POINT 7,INSTR] ; Where they are going
MOVEI T1,.PRIIN ; Primary input
BIN ; Wait for a byte
JRST DOIN0 ; Got one, go handle it...
DOINP: SIBE ; Any bytes?
SKIPA ; Yes
JRST EMPTY ; No
BIN ; Get another byte
DOIN0: IDPB T2,T3 ; Stash it in input stream buffer
SOJG T4,DOINP ; Do it all
EMPTY: MOVNI T3,MAXINP ; Maximum characters
ADD T3,T4 ; Compute number to send
JUMPE T3,DOINP0 ; If none, go wait
MOVE T1,DCNJFN ; The network JFN
HRROI T2,INSTR ; Pointer to input stream buffer
SOUTR ; Send this buffer to remote NRTSRV
JRST DOINP0 ; And continue
SUBTTL MSGTBL - Table of DECnet disconnect/abort reason text
;
; This table is used by the BADCON routine to provide an english
; text translation for the DECnet error codes which indicate why
; the network logical link connection was broken
;
;MACRO TO MAKE ENTRIES IN NSP ERROR TABLE
MAXMSG==^D50 ; Maximum number of NSP error messages
DEFINE NSPERR (CODE,TEXT,BASE<MSGTBL>),<
.ORG BASE+CODE
POINT 7,[ASCIZ\: TEXT\]
.ORG
>
MSGTBL: ;DECNET ERROR TEXT TABLE
REPEAT MAXMSG,<POINT 7,[ASCIZ\: Undefined NSP error\]> ;MAKE TABLE SPACE
; & UNDEFINED ENTRIES
NSPERR (.DCX0,<No special error>)
NSPERR (.DCX1,<Resource allocation failure>)
NSPERR (.DCX2,<Destination node does not exist>)
NSPERR (.DCX3,<Node shutting down>)
NSPERR (.DCX4,<Destination NRT process does not exist>)
NSPERR (.DCX5,<Invalid name field>)
NSPERR (.DCX9,<NRT server aborted link>)
NSPERR (.DCX11,<Undefined error>)
NSPERR (.DCX21,<CI with illegal destination address>)
NSPERR (.DCX24,<Flow control violation>)
NSPERR (.DCX32,<Too many connections to node>)
NSPERR (.DCX33,<Too many connections to destination NRT process>)
NSPERR (.DCX34,<Access not permitted>)
NSPERR (.DCX35,<Logical link services mismatch>)
NSPERR (.DCX36,<Invalid account>)
NSPERR (.DCX37,<Segment size too small>)
NSPERR (.DCX38,<Process aborted>)
NSPERR (.DCX39,<No path to destination node>)
NSPERR (.DCX40,<Link aborted due to data loss>)
NSPERR (.DCX41,<Destination logical link address does not exist>)
NSPERR (.DCX42,<Confirmation of disconnect initiate>)
NSPERR (.DCX43,<Image data field too long>)
END START