Google
 

Trailing-Edge - PDP-10 Archives - BB-H311D-RM - monitor-sources/ntman.mac
There are 26 other files named ntman.mac in the archive. Click here to see a list.
; UPD ID= 4530, SNARK:<6.MONITOR>NTMAN.MAC.8,  14-Jul-84 09:38:15 by PURRETTA
;Update copyright notice
; UPD ID= 2521, SNARK:<6.MONITOR>NTMAN.MAC.7,  25-May-83 14:06:41 by GRANT
;TCO 6.1667 - use EP. for network management counter references
; UPD ID= 2477, SNARK:<6.MONITOR>NTMAN.MAC.6,  17-May-83 10:19:52 by GRANT
;More TCO 6.1659 - eliminate needless instruction
; UPD ID= 2476, SNARK:<6.MONITOR>NTMAN.MAC.5,  17-May-83 10:15:06 by GRANT
;TCO 6.1659 - Use the stack instead of swappable free space
; UPD ID= 1855, SNARK:<6.MONITOR>NTMAN.MAC.4,  22-Feb-83 12:09:25 by GRANT
;TCO 6.1481 - support for .NDITM, .NDOTM, .NDMAD, and .NDLML;  remove NSALNK
; UPD ID= 1741, SNARK:<6.MONITOR>NTMAN.MAC.3,   2-Feb-83 14:22:22 by GRANT
;TCO 6.1484 - add support for event logging
; UPD ID= 1682, SNARK:<6.MONITOR>NTMAN.MAC.2,  20-Jan-83 08:30:29 by GRANT
;TCO 6.1469 - implement node parameter "state"

;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY  BE  USED
;OR COPIED ONLY IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE.
;
;COPYRIGHT  (c)  DIGITAL  EQUIPMENT  CORPORATION  1976, 1984.
;ALL RIGHTS RESERVED.



	SEARCH PROLOG,NSPPAR
	TTITLE (NTMAN,,< - DNA Network Management Interface >)

;Network Management's interface to the lower layers of DECnet architecture.

;THIS MONITOR CALL ASSUMES AT ALL TIMES:
;
;Q1/ ADDRESS OF MONITOR'S COPY OF THE USER'S ARGUMENT BLOCK
;Q3/ AMOUNT OF SPACE (IN BYTES) REMAINING IN USER'S RETURN BUFFER

	SWAPCD
.NTMAN::MCENT
	STKVAR <USRARG,<MONARG,.NTARG>>
	MOVE T1,CAPENB		;GET ENABLED CAPABILITIES
	TXNN T1,SC%WHL!SC%OPR	;WHEEL OR OPERATOR ENABLED?
	ITERR (CAPX1)		;NO.  RETURN "NOT ENOUGH CAPABILITIES" ERROR
	UMOVE T2,1		;GET USER'S ARG BLOCK ADDR
	MOVEM T2,USRARG		;SAVE IT
	UMOVE T1,.NTCNT(T2)	;GET USER'S LENGTH OF ARG BLOCK
	CAIE T1,.NTARG		;CORRECT SIZE?
	ITERR (ARGX17)		;NO, ERROR RETURN
	XMOVEI T3,MONARG	;RETRIEVE MONITOR'S ARG BLOCK ADR
	CALL BLTUM1		;(T1,T2,T3) MOVE ARG BLOCK TO MONITOR
	XMOVEI Q1,MONARG	;SET UP ARG BLOCK ADDR
	LDB T1,[POINT 6,.NTBPT(Q1),11]  ;GET THE USER'S BYTE SIZE
	CAIN T1,^D8		;MUST BE 8-BIT BYTES
	IFSKP.			;NOT SO
	   CALL NMXMPE		;NETWORK MANAGEMENT PROGRAM ERROR
	   CALL NTMRET		;CLEAN UP
	   ITERR (ARGX09)	;JSYS ERROR RETURN - INVALID BYTE SIZE
	ENDIF.
	MOVE T1,.NTENT(Q1)	;GET ENTITY
	MOVE Q3,.NTBYT(Q1)	;GET USER'S BUFFER SIZE
	SETZM .NTBYT(Q1)	;INIT THE RETURN COUNT
	CAIL T1,0		;A VALID
	CAIL T1,NTENTL		; ENTITY?
	JRST [CALL NMXII	;INVALID IDENTIFICATION ERROR
	      CALL NTMRET	;CLEAN UP
	      ITERR ( )]	;ERROR RETURN
	MOVE T4,NTMENT(T1)	;YES, GET THE DISPATCH ADDRESS
	CALL (T4)		;GO DO THE WORK
	 JRST [CALL NTMRET	;GO FINISH UP
	       ITERR ( )]	;FAILURE RETURN
	MOVEI T2,NTXGUD		;SUCCESSFUL COMPLETION
	MOVEM T2,.NTERR(Q1)	;PUT STATUS IN ARG BLOCK
	CALL NTMRET		;GO FINISH UP
	MRETNG			;SUCCESS

	ENDSV.
;NTMAN% JSYS CLEAN UP ROUTINE - FILLS IN USER'S ARGUMENT BLOCK
;RETURNS:	+1
;PRESERVES T1

NTMRET:	SAVEAC <T1>
	MOVEI T1,.NTARG		;GET LENGTH OF ARGUMENT BLOCK
	MOVE T2,Q1		;GET UPDATED ARG BLOCK
	UMOVE T3,T1		;GET USER'S ADDRESS
	CALL BLTMU1		;GIVE IT BACK
	RET


;NTMAN% "ENTITY" DISPATCH TABLE

NTMENT:	EXP NTNOD		;NODE
	EXP NMXUC		;LINE
	EXP NTLOG		;LOG
	EXP NMXUC		;CIRCUIT
	EXP NMXUC		;MODULE
NTENTL==.-NTMENT
;Network Management Error Status Returns

;ROUTINE TO RETURN ERROR -1 (UNRECOGNIZED FUNCTIONS OR OPTION)

NMXUFO:	HRREI T1,NTXUFO		;GET THE ERROR CODE
	MOVEM T1,.NTERR(Q1)	;PUT IT IN THE ARG BLOCK
	RETBAD (NTMX1)		;RETURN GENERIC ERROR CODE ON JSYS FAILURE


;ROUTINE TO RETURN ERROR -5 (MANAGEMENT PROGRAM ERROR)

NMXMPE:	HRREI T1,NTXMPE		;GET THE ERROR CODE
	MOVEM T1,.NTERR(Q1)	;PUT IT IN THE ARG BLOCK
	RETBAD (NTMX1)		;RETURN GENERIC ERROR CODE ON JSYS FAILURE


;ROUTINE TO RETURN ERROR -6 (UNRECOGNIZED PARAMETER TYPE)

NMXUPT:	HRREI T1,NTXUPT		;GET THE ERROR CODE
	MOVEM T1,.NTERR(Q1)	;PUT IT IN THE ARG BLOCK
	RETBAD (NTMX1)		;RETURN GENERIC ERROR CODE ON JSYS FAILURE


;ROUTINE TO RETURN ERROR -8 (UNRECOGNIZED COMPONENT)

NMXUC:	HRREI T1,NTXUC		;GET THE ERROR CODE
	MOVEM T1,.NTERR(Q1)	;PUT IT IN THE ARG BLOCK
	RETBAD (NTMX1)		;RETURN GENERIC ERROR CODE ON JSYS FAILURE


;ROUTINE TO RETURN ERROR -9 (INVALID IDENTIFICATION)

NMXII:	HRREI T1,NTXII		;GET THE ERROR CODE
	MOVEM T1,.NTERR(Q1)	;PUT IT IN THE ARG BLOCK
	RETBAD (NTMX1)		;RETURN GENERIC ERROR CODE ON JSYS FAILURE


;ROUTINE TO RETURN ERROR -10 (LINE COMMUNICATION ERROR)

NMXLCE:	HRREI T1,NTXLCE		;GET THE ERROR CODE
	MOVEM T1,.NTERR(Q1)	;PUT IT IN THE ARG BLOCK
	RETBAD (NTMX1)		;RETURN GENERIC ERROR CODE ON JSYS FAILURE


;ROUTINE TO RETURN ERROR -11 (COMPONENT IN WRONG STATE)

NMXCWS:	HRREI T1,NTXCWS		;GET THE ERROR CODE
	MOVEM T1,.NTERR(Q1)	;PUT IT IN THE ARG BLOCK
	RETBAD (NTMX1)		;RETURN GENERIC ERROR CODE ON JSYS FAILURE


;ROUTINE TO RETURN ERROR -15 (RESOURCE ERROR)

NMXRE:	HRREI T1,NTXRE		;GET THE ERROR CODE
	MOVEM T1,.NTERR(Q1)	;PUT IT IN THE ARG BLOCK
	RETBAD (NTMX1)		;RETURN GENERIC ERROR CODE ON JSYS FAILURE


;ROUTINE TO RETURN ERROR -16 (INVALID PARAMETER VALUE)

NMXIPV:	HRREI T1,NTXIPV		;GET THE ERROR CODE
	MOVEM T1,.NTERR(Q1)	;PUT IT IN THE ARG BLOCK
	RETBAD (NTMX1)		;RETURN GENERIC ERROR CODE ON JSYS FAILURE


;ROUTINE TO RETURN ERROR -22 (PARAMETER NOT APPLICABLE)

NMXPNA:	HRREI T1,NTXPNA		;GET THE ERROR CODE
	MOVEM T1,.NTERR(Q1)	;PUT IT IN THE ARG BLOCK
	RETBAD (NTMX1)		;RETURN GENERIC ERROR CODE ON JSYS FAILURE


;ROUTINE TO RETURN ERROR -25 (OPERATION FAILURE)

NMXOF:	HRREI T1,NTXOF		;GET THE ERROR CODE
	MOVEM T1,.NTERR(Q1)	;PUT IT IN THE ARG BLOCK
	RETBAD (NTMX1)		;RETURN GENERIC ERROR CODE ON JSYS FAILURE


;ROUTINE TO RETURN ERROR -29 (PARAMETER MISSING)

NMXPM:	HRREI T1,NTXPM		;GET THE ERROR CODE
	MOVEM T1,.NTERR(Q1)	;PUT IT IN THE ARG BLOCK
	RETBAD (NTMX1)		;RETURN GENERIC ERROR CODE ON JSYS FAILURE
	SUBTTL Node Entity

;LIST OF NODE COUNTER TABLE ADDRESSES

NSNODC:	EXP NSSSLZ		;SECONDS SINCE LAST ZEROED
	EXP NSBYTR		;BYTES RECEIVED
	EXP NSBYTS		;BYTES SENT
	EXP NSMSGR		;MESSAGES RECEIVED
	EXP NSMSGS		;MESSAGES SENT
	EXP NSCONR		;CONNECTS RECEIVED
	EXP NSCONS		;CONNECTS SENT
	EXP NSTIMO		;RESPONSE TIMEOUTS
	EXP NSRCNE		;RECEIVED CONNECT RESOURCE ERRORS
NSNODL==.-NSNODC
;NODE COUNTER INFORMATION - PARALLEL TO NSNODC
;LH/ NUMBER OF BITS IN COUNTER DATA
;RH/ COUNTER NUMBER

NSNWID:	.NSW20,,.NSSSL		;SECONDS SINCE LAST ZEROED
	.NSW40,,.NSBYR		;BYTES RECEIVED
	.NSW40,,.NSBYS		;BYTES SENT
	.NSW40,,.NSMGR		;MESSAGES RECEIVED
	.NSW40,,.NSMGS		;MESSAGES SENT
	.NSW20,,.NSCNR		;CONNECTS RECEIVED
	.NSW20,,.NSCNS		;CONNECTS SENT
	.NSW20,,.NSRTO		;RESPONSE TIMEOUTS
	.NSW20,,.NSRCE		;RECEIVED CONNECT RESOURCE ERRORS
NSNWDL==.-NSNWID



;NODE PARAMETER ITEMS

NSNPAR:	.NDSTT			;NODE STATE
	.NDNID			;IDENTIFICATION
	.NDNNA			;NODE NAME
	.NDCNN			;CIRCUIT FOR NODE NAME
	.NDNNU			;NODE NUMBER
	.NDITM			;INCOMING TIMER
	.NDOTM			;OUTGOING TIMER
	.NDALK			;ACTIVE LINKS
	.NDDLY			;DELAY
	.NDVRS			;VERSION
	.NDLML			;LOCAL MAXIMUM LINKS
	.NDLDF			;LOCAL DELAY FACTOR
	.NDLDW			;LOCAL DELAY WEIGHT
	.NDIAT			;INACTIVITY TIMER
	.NDRTF			;RETRANSMIT FACTOR
	.NDTYP			;TYPE
	.NDMAD			;MAXIMUM NODE ADDRESS
NSNPRL==.-NSNPAR


;NODE IDENTIFICATION STRING (I-32)

NDIDN:	BYTE (8) ^D10,"T","O","P","S","-","2","0"," ","V","5",0
;ENTITY = NODE
;NOW GET THE FUNCTION
;RETURNS:	+1  FAILED, T1/ ERROR CODE
;		+2  SUCCESS

NTNOD:	MOVE T1,.NTFNC(Q1)	;GET FUNCTION REQUESTED
	MOVNI T2,LOWFNC		;ADJUST THE FUNCTION CODE
	HRRZS T2		;MAKE IT USEFUL
	ADD T1,T2		; FOR DISPATCHING
	CAIL T1,0		;A VALID
	CAIL T1,NTNODL		; FUNCTION?
	JRST NMXII		;NO, ERROR RETURN
	MOVE T4,NTNODF(T1)	;GET DISPATCH ADDRESS
	CALL (T4)		;GO DO THE WORK
	 RETBAD ()		;ERROR
	RETSKP			;SUCCESS

NTNODF:	EXP NMXMPE		;(-3) SET PSI CHANNEL FOR EVENT AVAILABLE
	EXP NTNMAP		;(-2) MAP NODE NUMBER TO NODE NAME
	EXP NTNREX		;(-1) RETURN EXECUTOR NODE ID
	EXP NTNSET		;(0) SET PARAMETER
	EXP NTNCLR		;(1) CLEAR PARAMETER
	EXP NTNZRO		;(2) ZERO ALL COUNTERS
	EXP NTNSHO		;(3) SHOW SELECTED ITMES
	EXP NTNSZC		;(4) SHOW AND ZERO ALL COUNTERS
	EXP NTNRET		;(5) RETURN LIST OF ITEMS
	EXP NMXMPE		;(6) PROCESS THE EVENT QUEUE
NTNODL==.-NTNODF
;ENTITY = NODE
;FUNCTION = MAP NODE NUMBER TO NODE NAME
;RETURNS:	+1 FAILED
;		+2 SUCCESS

NTNMAP:	STKVAR <BEGIN>
	MOVE T2,.NTBPT(Q1)	;GET USER'S BYTE POINTER
	MOVEM T2,BEGIN		;PRESERVE IT
	MOVEI T1,.NDALN		;GET LENGTH OF NODE NUMBER
	ADJBP T1,.NTBPT(Q1)	;SKIP THE NODE NUMBER
	XCTBU [ILDB T2,T1]	;GET THE NUMBER OF BYTES IN THE NODE NAME
	JUMPN T2,NTNMA1		;IF SOME THERE, MOVE ON
	HRREI T2,-<.NDALN+1>	;BACKUP TO
	ADJBP T2,T1		; NODE NUMBER
	MOVEM T2,.NTBPT(Q1)	;RESET THE BYTE POINTER
	MOVEI T3,.NTBPT(Q1)	;POINT TO THE NEW POINTER
	CALL GETADR		;GET THE NODE NUMBER
	 JRST NMXUC		;FAILED
	CALL FNDNAM		;LOOK UP THE NODE NAME
	CALL RETNAM		;RETURN IT TO USER
	 RETBAD ()		;FAILED
	RETSKP			;DONE

NTNMA1:	SETO T2,		;BACKUP TO
	ADJBP T2,T1		; READ THE NODE NAME
	MOVEM T2,.NTBPT(Q1)	;RESET THE BYTE POINTER
	MOVEI T3,.NTBPT(Q1)	;POINT TO THE NEW POINTER
	CALL GETNAM		;GET THE NODE NAME
	 RETBAD ()		;FAILED
	NOINT
	LOCK NMAPLK		;LOCK THE NODE NAME MAPPING TABLE
	CALL FNDADR		;FIND THE NODE NUMBER
	 JRST [	UNLOCK NMAPLK	;UNLOCK THE TABLE
		OKINT
		JRST NMXUC]	;FAILED
	UNLOCK NMAPLK		;UNLOCK THE TABLE
	OKINT
	MOVE T2,BEGIN		;RESET THE USER'S
	MOVEM T2,.NTBPT(Q1)	; BYTE POINTER
	CALL RETADR		;RETURN THE NODE NUMBER
	 RETBAD ()		;FAILED
	RETSKP

	ENDSV.
;ENTITY = NODE
;FUNCTION = RETURN EXECUTOR NODE ID
;RETURNS:	+1 FAILED
;		+2 SUCCESS

NTNREX:	MOVE T1,OURNUM		;GET OUR NODE NUMBER
	CALL RETADR		;RETURN IT
	 RETBAD ()		;FAILED
	CALL FNDNAM		;LOOK UP NODE NAME
	CALL RETNAM		;RETURN IT
	 RETBAD ()		;FAILED
	RETSKP			;DONE
;ENTITY = NODE
;FUNCTION = SET PARAMETER
;NOW FIND THE PARAMETER
;RETURNS:	+1  FAILURE
;		+2  SUCCESS


NTNSET:	MOVEI T3,.NTBPT(Q1)	;GET USER'S BYTE POINTER
	CALL GETPAR		;GET THE PARAMETER NUMBER
	CALL FNDPAR		;LOOK IT UP
	 RETBAD ( )
	MOVE T4,NTNSTP(T1)	;GET THE DISPATCH ADDRESS
	CALL (T4)		;GO DO THE WORK
	 RETBAD ()		;ERROR
	RETSKP			;SUCCESS

NTNSTP:	EXP SCNSTA		;LOCAL NODE STATE
	EXP NMXUPT		;IDENTIFICATION
	EXP SCNSET		;NODE NAME
	EXP NMXUPT		;CIRCUIT FOR NODE NAME
	EXP NMXUPT		;NODE NUMBER
	EXP NMXUPT		;INCOMING TIMER
	EXP NMXUPT		;OUTGOING TIMER
	EXP NMXUPT		;ACTIVE LINKS
	EXP NMXUPT		;DELAY
	EXP NMXUPT		;VERSION
	EXP NMXUPT		;MAXIMUM LINKS
	EXP NSNLDF		;LOCAL DELAY FACTOR
	EXP NSNLDW		;LOCAL DELAY WEIGHT
	EXP NSNIAT		;INACTIVITY TIMER
	EXP NSNTRY		;RETRANSMIT FACTOR
	EXP NMXUPT		;TYPE
NTNSTL==.-NTNSTP
;ENTITY = NODE
;FUNCTION = SET PARAMETER
;PARAMETER = STATE
;RETURNS:	+1  FAILED
;		+2  SUCCESS


SCNSTA:	MOVEI T3,.NTEID(Q1)	;POINT TO ENTITY ID BP
	CALL GETADR		;GET NODE ADDRESS 
	 JRST NMXII		;FAILED - "INVALID NODE ADDRESS"
	CAME T1,OURNUM		;MUST BE LOCAL NODE
	JRST NMXPNA		;NOT - "PARAMETER NOT APPLICABLE"
	MOVEI T1,.NTBPT(Q1)	;POINT TO PARAMETER INFO BP
	XCTBU [ILDB T3,(T1)]	;GET THE DESIRED STATE
	CAIG T3,.NDRST		;WITHIN
	CAIGE T3,.NDON		; RANGE?
	JRST NMXIPV		;NO - "INVALID PARAMETER VALUE"
	CAIN T3,.NDOFF		;TRY TO TURN US OFF?
	JRST NMXCWS		;YES, WE DON'T ALLOW THIS
	STOR T3,SCSTA		;SET NEW STATE
	RETSKP
;ENTITY = NODE
;FUNCTION = SET PARAMETER
;PARAMETER = NAME
;RETURNS:	+1  FAILED
;		+2  SUCCESS

SCNSET:	STKVAR <ADDR>
	MOVEI T3,.NTEID(Q1)	;POINT TO ENTITY ID BYTE POINTER
	CALL GETADR		;GET NODE ADDRESS FROM USER
	 JRST NMXII		;FAILED - "INVALID NODE ADDRESS"
	MOVEM T1,ADDR		;STASH THE NODE ADDRESS
	MOVEI T3,.NTBPT(Q1)	;POINT TO PARAMETER INFO BYTE POINTER
	CALL GETNAM		;GET NODE NAME FROM USER
	 RETBAD ()		;FAILED
	MOVE T2,ADDR		;GET ADDRESS IN GOOD PLACE
	NOINT
	LOCK NMAPLK		;LOCK THE MAPPING TABLE
	HRLZI T3,-<BIGNOD+1>	;MAKE AOBJN WORD
SCNSE1:	HRRZ T4,T3		;GET THE OFFSET ONLY
	ADD T4,[NODMAP]		;MOVE INTO THE TABLE
	CAMN T1,(T4)		;THIS ENTRY MATCH?
	JRST [	HRRZ T4,T3	;YES, GET ITS NUMBER
		CAMN T4,T2	;SAME AS ONE BEING SET?
		JRST SCNSE2	;YES, THAT'S OK
		UNLOCK NMAPLK	;UNLOCK THE TABLE
		OKINT
		JRST NMXCWS]	;FAIL - NAME ALREADY ASSIGNED TO ANOTHER NODE
	AOBJN T3,SCNSE1		;CHECKED THE ENTIRE TABLE?
	ADD T2,[NODMAP]		;MOVE INTO THE TABLE
	MOVEM T1,(T2)		;PUT NODE NAME INTO TABLE
SCNSE2:	UNLOCK NMAPLK		;UNLOCK THE MAPPING TABLE
	OKINT
	RETSKP			;GOOD RETURN

	ENDSV.
;ENTITY = NODE
;FUNCION = SET PARAMETER
;PARAMETER = INACTIVITY TIMER
;RETURNS:	+1 FAILURE
;		+2 SUCCESS

NSNIAT:	MOVEI T3,.NTBPT(Q1)	;GET BP TO USER'S ARG
	MOVEI T4,2		;2 BYTES IN LENGTH
	CALL GETNUM		;GET THE VALUE FROM USER
	CAIL T2,1		;A LEGAL
	CAILE T2,^D65535	; VALUE?
	JRST NMXIPV		;NO, FAIL
	IMULI T2,^D1000		;CONVERT TO MILLISECONDS
	MOVEM T2,NSINAC		;SET THE NEW VALUE
	RETSKP			;DONE


;ENTITY = NODE
;FUNCION = SET PARAMETER
;PARAMETER = LOCAL DELAY WEIGHT
;RETURNS:	+1 FAILURE
;		+2 SUCCESS

NSNLDW:	MOVEI T3,.NTBPT(Q1)	;GET BP TO USER'S ARG
	MOVEI T4,1		;1 BYTES IN LENGTH
	CALL GETNUM		;GET THE VALUE FROM USER
	CAIL T2,1		;A LEGAL
	CAILE T2,^D255		; VALUE?
	JRST NMXIPV		;NO, FAIL
	MOVEM T2,NSLDWS		;SET THE NEW VALUE
	RETSKP			;DONE


;ENTITY = NODE
;FUNCION = SET PARAMETER
;PARAMETER = LOCAL DELAY FACTOR
;RETURNS:	+1 FAILURE
;		+2 SUCCESS

NSNLDF:	MOVEI T3,.NTBPT(Q1)	;GET BP TO USER'S ARG
	MOVEI T4,1		;1 BYTES IN LENGTH
	CALL GETNUM		;GET THE VALUE FROM USER
	CAIL T2,1		;A LEGAL
	CAILE T2,^D63		; VALUE?
	JRST NMXIPV		;NO, FAIL
	MOVEM T2,NSLDFS		;SET THE NEW VALUE
	RETSKP			;DONE


;ENTITY = NODE
;FUNCION = SET PARAMETER
;PARAMETER = RETRANSMIT FACTOR
;RETURNS:	+1 FAILURE
;		+2 SUCCESS

NSNTRY:	MOVEI T3,.NTBPT(Q1)	;GET BP TO USER'S ARG
	MOVEI T4,2		;2 BYTES IN LENGTH
	CALL GETNUM		;GET THE VALUE FROM USER
	CAIL T2,1		;A LEGAL
	CAILE T2,^D20		; VALUE?
	JRST NMXIPV		;NO, FAIL
	MOVEM T2,NSTRYS		;SET THE NEW VALUE
	RETSKP			;DONE
;ENTITY = NODE
;FUNCTION = CLEAR PARAMETER
;NOW FIND THE PARAMETER
;RETURNS:	+1  FAILURE
;		+2  SUCCESS


NTNCLR:	SKIPN Q3		;BYTE COUNT = 0?
	JRST NTNCLA		;YES, THAT MEANS CLEAR ALL PARAMETERS
	MOVEI T3,.NTBPT(Q1)	;GET ADDRESS OF USER'S POINTER
	CALL GETPAR		;GET PARAMETER NUMBER
	CALL FNDPAR		;LOOK IT UP
	 RETBAD ( )
	MOVE T4,NTNCLP(T1)	;GET DISPATCH ADDRESS
	CALL (T4)		;GO DO THE WORK
	 RETBAD ()		;ERROR
	RETSKP			;SUCCESS

NTNCLP:	EXP NMXUPT		;LOCAL NODE STATE
	EXP NMXUPT		;IDENTIFICATION
	EXP SCNCLR		;NODE NAME
	EXP NMXUPT		;CIRCUIT FOR NODE NAME
	EXP NMXUPT		;NODE NUMBER
	EXP NMXUPT		;INCOMING TIMER
	EXP NMXUPT		;OUTGOING TIMER
	EXP NMXUPT		;ACTIVE LINKS
	EXP NMXUPT		;DELAY
	EXP NMXUPT		;VERSION
	EXP NMXUPT		;MAXIMUM LINKS
	EXP NMXUPT		;LOCAL DELAY FACTOR
	EXP NMXUPT		;LOCAL DELAY WEIGHT
	EXP NMXUPT		;INACTIVITY TIMER
	EXP NMXUPT		;RETRANSMIT FACTOR
	EXP NMXUPT		;TYPE
NTNCLL==.-NTNCLP


;ENTITY = NODE
;FUNCTION = CLEAR (ALL)
;RETURNS:	+1 FAILED
;		+2 SUCCESS

NTNCLA:	CALL SCNCLR		;DO SESSION CONTROL'S PART
	 RETBAD ()		;FAILED
	RETSKP			;DONE
;ENTITY = NODE
;FUNCTION = CLEAR PARAMETER
;PARAMETER = NAME
;RETURNS:	+1  FAILED
;		+2  SUCCESS


SCNCLR:	MOVEI T3,.NTEID(Q1)	;POINT TO ENTITY ID BYTE POINTER
	CALL GETADR		;GET USER'S NODE ADDRESS
	 JRST NMXII		;BAD
	NOINT
	LOCK NMAPLK		;LOCK THE MAPPING TABLE
	ADD T1,[NODMAP]		;MOVE INTO THE TABLE
	SETZM (T1)		;NULLIFY CURRENT MAPPING
	UNLOCK NMAPLK		;UNLOCK THE MAPPING TABLE
	OKINT
	RETSKP			;GOOD RETURN


;ENTITY = NODE
;FUNCTION = ZERO COUNTERS
;RETURNS:	+1 FAILED
;		+2 SUCCESS

NTNZRO:	CALL NANUEX		;GET THE NODE NUMBER
	 RETBAD ()		;FAILED
NTNZR2:	MOVEI T4,NSNODL-1	;GET NUMBER OF COUNTERS
NTNZR1:	MOVE T3,NSNODC(T4)	;GET THE TABLE
	ADD T3,T1		;GET THE OFFSET
	SETZM (T3)		;ZERO THE COUNT
	SOJGE T4,NTNZR1		;MORE TO DO?
	MOVE T4,TODCLK		;GET CURRENT UPTIME
	LSH T4,-11		;CONVERT TO SECONDS
	MOVEM T4,@[EP. NSSSLZ(T1)] ;SAVE IT
	RETSKP			;NO, DONE
;ENTITY = NODE
;FUNCTION = SHOW SELECTED ITEMS
;NOW FIND SELECTOR
;RETURNS:	+1 FAILED
;		+2 SUCCESS

NTNSHO:	MOVE T1,.NTSEL(Q1)	;GET THE SELECTOR
	CAIL T1,0		;A VALID
	CAIL T1,NTSHOL		; SELECTOR?
	JRST NMXII		;NO, FAIL
	MOVE T4,NTSHOT(T1)	;GET DISPATCH ADDRESS
	CALL (T4)		;GO DO THE WORK
	 RETBAD ()		;FAILED
	RETSKP			;SUCCESS

NTSHOT:	EXP NTNSUM		;SUMMARY
	EXP NTNSTS		;STATUS
	EXP NTNSCH		;CHARACTERISTICS
	EXP NSNSCO		;COUNTERS
	EXP NMXUFO		;EVENTS
NTSHOL==.-NTSHOT


;ENTITY = NODE
;FUNCTION = SUMMARY
;RETURNS:	+1 FAILED
;		+2 SUCCESS

NTNSUM:	STKVAR <NDNUM>
	CALL NANUEX		;GET THE NODE NUMBER
	 RETBAD ()		;FAILED
	MOVEM T1,NDNUM		;SAVE THE NODE NUMBER
	CALL DOSTA		;DO STATE PARAMETER
	 RETBAD ()		;FAILED
	MOVE T1,NDNUM		;RETRIEVE THE NODE NUMBER
	CALL RETALK		;DO ACTIVE LINK PARAMETER
	 RETBAD ()		;FAILED
	MOVE T1,NDNUM		;RETRIEVE NODE NUMBER
	CAME T1,OURNUM		;IS IT US?
	RETSKP			;NO, DONE
;	CALL RETIDN		;RETURN IDENTIFICATION PARAMETER
;	 RETBAD ()		;FAILED
	RETSKP			;DONE

	ENDSV.
;ENTITY = NODE
;FUNCTION = SHOW SELECTED ITEMS
;SELECTOR = STATUS
;RETURNS:	+1 FAILED
;		+2 SUCCESS

NTNSTS:	STKVAR <NDNUM>
	CALL NANUEX		;GET NODE NUMBER
	 RETBAD ()		;FAILED
	MOVEM T1,NDNUM		;SAVE NODE NUMBER
	CALL SCNSTS		;DO SESSION CONTROL
	 RETBAD ()		;FAILED
	MOVE T1,NDNUM		;RETRIEVE NODE NUMBER
	CALL NSNSTS		;DO NSP
	 RETBAD ()		;FAILED
	RETSKP			;DONE

	ENDSV.


;ROUTINE TO DO SESSION CONTROL'S PART OF SHOW NODE STATUS
;ACCEPTS:	T1/ NODE NUMBER
;RETURNS:	+1  FAILED
;		+2  SUCCESS

SCNSTS:	CALL DOSTA		;DO STATE PARAMETER
	 RETBAD ()		;FAILED
	RETSKP			;DONE


;ROUTINE TO DO NSP'S PART OF SHOW NODE STATUS
;ACCEPTS:	T1/ NODE NUMBER
;RETURNS:	+1 FAILED
;		+2 SUCCESS

NSNSTS:	CALL RETALK		;DO ACTIVE LINK PARAMETER
	 RETBAD ()		;FAILED
	RETSKP
;ROUTINE TO RETURN THE ACTIVE LINK PARAMETER
;ACCEPTS:	T1/ NODE NUMBER
;RETURNS:	+1 FAILED
;		+2 SUCCESS

RETALK:	SAVEAC <P3>
	STKVAR <NDNUM>
	MOVEM T1,NDNUM		;SAVE THE NODE NUMBER
	CALL GTALNK		;GO GET THE NUMBER OF ACTIVE LINKS
	MOVE T1,NDNUM		;RETRIEVE THE NODE NUMBER
	SETZ Q2,		;INIT THE ARGUMENT
	MOVEI T3,NTPAR		;PARAMETER DATA
	STOR T3,DIDDA,Q2	;PUT IT IN
	MOVEI T3,.NDALK		;PARAMETER IS ACTIVE LINK
	STOR T3,DIDNO,Q2	;PUT IT IN
	CALL NTMDID		;MAKE A DATA ID
	 RETBAD ()		;FAILED
	SETZ Q2,		;INIT THE ARGUMENT
	MOVEI T1,NTNCD		;NOT CODED
	STOR T1,DTYCD,Q2	;PUT IT IN
	MOVEI T1,NTBIN		;BINARY NUMBER
	STOR T1,DTYTY,Q2	;PUT IT IN
	MOVEI T1,2		;2 BYTES
	STOR T1,DTYLN,Q2	;PUT IT IN
	MOVEI T1,NTUDN		;UNSIGNED DECIMAL NUMBER
	STOR T1,DTYBF,Q2	;PUT IT IN
	CALL NTMDTY		;MAKE A DATA TYPE
	 RETBAD ()		;FAILED
	MOVEI T1,2		;2 BYTES
	MOVE T3,NDNUM		;GET NODE NUMBER
	MOVE P3,@[EP. NSALNK(T3)] ;GET THE CURRENT NUMBER OF ACTIVE LINKS
	LSH P3,^D20		;POSITION IT
	MOVE T2,[441000,,P3]	;MAKE A BYTE POINTER
	CALL RETNUM		;RETURN IT TO USER
	 RETBAD ()		;FAILED
	RETSKP

	ENDSV.
;GET NUMBER OF ACTIVE LINKS FOR ALL NODES
;RETURNS:	+1 WITH NSALNK TABLE FILLED IN

GTALNK:	MOVEI T1,BIGNOD		;INIT
	MOVE T2,[NSALNK]	; THE
	XMOVEI T3,1(T2)		; ACTIVE
	SETZM (T2)		; LINKS
	CALL XBLTA		; TABLE
	LLLOCK			;LOCK THE LL STRUCTURE
	MOVEI T1,GTALCO		;GET ADDRESS OF COROUTINE
	SETO T2,		;ALL LINKS
	CALL OBJSRC		;GO SEARCH THE LINK STRUCTURE
	 JFCL			;DOESN'T MATTER MUCH
	CALLRET ULOKLL		;UNLOCK THE LL STRUCTURE

GTALCO:	SAVET
	CALL BLKLOK		;LOCK THIS LL BLOCK
	 RET			;CAN'T, GO GET NEXT ONE
	LOAD T2,LLSTA,(T1)	;GET STATE OF LINK
	CAIN T2,LLSLIS		;LISTENING?
	JRST GTALCD		;YES, NOT INTERESTING
	LOAD T2,LLHSN,(T1)	;GET OTHER HOST'S NUMBER
	AOS @[EP. NSALNK(T2)]	;BUMP THE COUNT
GTALCD:	CALLRET BLKULK		;UNLOCK THIS LL BLOCK
;ROUTINE TO ASSIST IN RETURNING THE STATE OF A NODE
;ACCEPTS:	T1/ NODE NUMBER
;RETURNS:	+1/ FAILED
;		+2/ SUCCESS

DOSTA:	CAME T1,OURNUM		;IS IT US?
	JRST DOST1		;NO
	LOAD T2,SCSTA		;YES, GET LOCAL NODE STATE
	JRST DOST2		;MOVE ON
DOST1:	MOVE T3,[440200,,NODTBL]  ;MAKE BP TO REACHABLE NODES TABLE
	ADJBP T1,T3		;OFFSET TO THE NODE IN QUESTION
	LDB T2,T1		;GET ITS STATE
	SKIPE T2		;IS IT REACHABLE?
	JRST [	MOVEI T2,.NDREA  ;YES
		JRST DOST2]	;MOVE ON
	MOVEI T2,.NDUNR		;NO
DOST2:	CALL RETSTA		;RETURN THE STATE
	 RETBAD ()		;FAILED
	RETSKP
;ROUTINE TO RETURN THE STATE PARAMETER
;ACCEPTS:	T2/ STATE
;RETURNS:	+1 FAILED
;		+2 SUCCESS

RETSTA:	SAVEAC <P3>
	STKVAR <STATE>
	MOVEM T2,STATE		;SAVE THE STATE
	SETZ Q2,		;INIT THE ARGUMENT
	MOVEI T3,NTPAR		;PARAMETER DATA
	STOR T3,DIDDA,Q2	;PUT IT IN
	MOVEI T3,.NDSTT		;PARAMETER IS STATE
	STOR T3,DIDNO,Q2	;PUT IT IN
	CALL NTMDID		;MAKE A DATA ID
	 RETBAD ()		;FAILED
	SETZ Q2,		;INIT THE ARGUMENT
	MOVEI T1,NTCOD		;CODED
	STOR T1,DTYCD,Q2	;PUT IT IN
	MOVEI T1,NTSNG		;SINGLE FIELD
	STOR T1,DTYTY,Q2	;PUT IT IN
	MOVEI T1,1		;1 BYTE
	STOR T1,DTYCN,Q2	;PUT IT IN
	CALL NTMDTY		;MAKE A DATA TYPE
	 RETBAD ()		;FAILED
	MOVEI T1,1		;1 BYYTE
	MOVE P3,STATE		;GET THE STATE
	LSH P3,^D28		;POSITION IT
	MOVE T2,[441000,,P3]	;MAKE A BP TO IT
	CALL RETNUM		;RETURN IT
	 RETBAD ()		;FAILED
	RETSKP

	ENDSV.
;ENTITY = NODE
;FUNCTION = SHOW SELECTED ITEMS
;SELECTOR = CHARACTERISTICS
;RETURNS:	+1 FAILED, 1/ ERROR CODE
;		+2 SUCCESS

NTNSCH:	CALL NANUEX		;GET NODE NUMBER
	 RETBAD ()		;FAILED
	CAME T1,OURNUM		;IS IT US?
	RETSKP			;NO, NOTHING TO RETURN
	CALL SCNSCH		;DO SESSION CONTROL
	 RETBAD ()		;FAILED
	CALL NSNSCH		;DO NSP
	 RETBAD ()		;FAILED
	CALL XPNSCH		;DO TRANSPORT
	 RETBAD ()		;FAILED
	RETSKP			;DONE
;SESSION CONTROL'S PART OF SHOW CHARACTERISTICS
;RETURNS:	+1 FAILED
;		+2 SUCCESS

SCNSCH:

;DO SESSION CONTROL INCOMING TIMER

	SETZ Q2,		;INIT THE ARGUMENT
	MOVEI T3,NTPAR		;PARAMETER DATA
	STOR T3,DIDDA,Q2	;PUT IT IN
	MOVEI T3,.NDITM		;PARAMETER IS INCOMING TIMER
	STOR T3,DIDNO,Q2	;PUT IT IN
	CALL NTMDID		;MAKE A DATA ID
	 RETBAD ()		;FAILED
	SETZ Q2,		;INIT THE ARGUMENT
	MOVEI T1,NTNCD		;NOT CODED
	STOR T1,DTYCD,Q2	;PUT IT IN
	MOVEI T1,NTBIN		;BINARY NUMBER
	STOR T1,DTYTY,Q2	;PUT IT IN
	MOVEI T1,2		;2 BYTES
	STOR T1,DTYLN,Q2	;PUT IT IN
	MOVEI T1,NTUDN		;UNSIGNED DECIMAL NUMBER
	STOR T1,DTYBF,Q2	;PUT IT IN
	CALL NTMDTY		;MAKE A DATA TYPE
	 RETBAD ()		;FAILED
	MOVEI T1,2		;2 BYTES
	SETZ P3,		;NO TIMER IS USE
	MOVE T2,[441000,,P3]	;MAKE A BYTE POINTER
	CALL RETNUM		;RETURN IT TO USER
	 RETBAD ()		;FAILED

;DO SESSION CONTROL OUTGOING TIMER

	SETZ Q2,		;INIT THE ARGUMENT
	MOVEI T3,NTPAR		;PARAMETER DATA
	STOR T3,DIDDA,Q2	;PUT IT IN
	MOVEI T3,.NDOTM		;PARAMETER IS OUTGOING TIMER
	STOR T3,DIDNO,Q2	;PUT IT IN
	CALL NTMDID		;MAKE A DATA ID
	 RETBAD ()		;FAILED
	SETZ Q2,		;INIT THE ARGUMENT
	MOVEI T1,NTNCD		;NOT CODED
	STOR T1,DTYCD,Q2	;PUT IT IN
	MOVEI T1,NTBIN		;BINARY NUMBER
	STOR T1,DTYTY,Q2	;PUT IT IN
	MOVEI T1,2		;2 BYTES
	STOR T1,DTYLN,Q2	;PUT IT IN
	MOVEI T1,NTUDN		;UNSIGNED DECIMAL NUMBER
	STOR T1,DTYBF,Q2	;PUT IT IN
	CALL NTMDTY		;MAKE A DATA TYPE
	 RETBAD ()		;FAILED
	MOVEI T1,2		;2 BYTES
	SETZ P3,		;NO TIMER IN USE
	MOVE T2,[441000,,P3]	;MAKE A BYTE POINTER
	CALL RETNUM		;RETURN IT TO USER
	 RETBAD ()		;FAILED
	RETSKP
;NSP'S PART OF SHOW CHARACTERISTICS
;RETURNS:	+1 FAILED
;		+2 SUCCESS

NSNSCH:	SAVEAC <P3>

;DO NSP VERSION

	SETZ Q2,		;INIT THE ARGUMENT
	MOVEI T2,NTPAR		;PARAMETER DATA
	STOR T2,DIDDA,Q2	;PUT IT IN
	MOVEI T2,.NDVRS		;PARAMETER IS NSP VERSION
	STOR T2,DIDNO,Q2	;PUT IT IN
	CALL NTMDID		;MAKE A DATA ID
	 RETBAD ()		;FAILED
	SETZ Q2,		;INIT THE ARGUMENT
	MOVEI T2,NTCOD		;CODED
	STOR T2,DTYCD,Q2	;PUT IT IN
	MOVEI T2,NTMUL		;MULTIPLE FIELDS
	STOR T2,DTYTY,Q2	;PUT IT IN
	MOVEI T2,3		;3 FIELDS
	STOR T2,DTYCN,Q2	;PUT IT IN
	CALL NTMDTY		;MAKE A DATA TYPE
	 RETBAD ()		;FAILED
	MOVEI T1,COMVER		;GET THE VERSION OF NSP
	CALL MAKDTY		;DO THE DATA TYPE
	 RETBAD ()		;FAILED
	MOVEI T1,COMECO		;GET THE ECO LEVEL OF NSP
	CALL MAKDTY		;DO THE DATA TYPE
	 RETBAD ()		;FAILED
	MOVEI T1,COMCST		;GET THE CUSTOMER LEVEL OF NSP
	CALL MAKDTY		;DO THE DATA TYPE
	 RETBAD ()		;FAILED

;DO NSP LOCAL MAXIMUM LINKS

	SETZ Q2,		;INIT THE ARGUMENT
	MOVEI T3,NTPAR		;PARAMETER DATA
	STOR T3,DIDDA,Q2	;PUT IT IN
	MOVEI T3,.NDLML		;PARAMETER IS LOCAL MAXIMUM LINKS
	STOR T3,DIDNO,Q2	;PUT IT IN
	CALL NTMDID		;MAKE A DATA ID
	 RETBAD ()		;FAILED
	SETZ Q2,		;INIT THE ARGUMENT
	MOVEI T1,NTNCD		;NOT CODED
	STOR T1,DTYCD,Q2	;PUT IT IN
	MOVEI T1,NTBIN		;BINARY NUMBER
	STOR T1,DTYTY,Q2	;PUT IT IN
	MOVEI T1,2		;2 BYTES
	STOR T1,DTYLN,Q2	;PUT IT IN
	MOVEI T1,NTUDN		;UNSIGNED DECIMAL NUMBER
	STOR T1,DTYBF,Q2	;PUT IT IN
	CALL NTMDTY		;MAKE A DATA TYPE
	 RETBAD ()		;FAILED
	MOVEI T1,2		;2 BYTES
	MOVEI P3,MAXLNK		;GET THE VALUE
	LSH P3,^D20		;POSITION IT
	MOVE T2,[441000,,P3]	;MAKE A BYTE POINTER
	CALL RETNUM		;RETURN IT TO USER
	 RETBAD ()		;FAILED

;DO NSP LOCAL DELAY FACTOR

	SETZ Q2,		;INIT THE ARGUMENT
	MOVEI T3,NTPAR		;PARAMETER DATA
	STOR T3,DIDDA,Q2	;PUT IT IN
	MOVEI T3,.NDLDF		;PARAMETER IS LOCAL DELAY FACTOR
	STOR T3,DIDNO,Q2	;PUT IT IN
	CALL NTMDID		;MAKE A DATA ID
	 RETBAD ()		;FAILED
	SETZ Q2,		;INIT THE ARGUMENT
	MOVEI T1,NTNCD		;NOT CODED
	STOR T1,DTYCD,Q2	;PUT IT IN
	MOVEI T1,NTBIN		;BINARY NUMBER
	STOR T1,DTYTY,Q2	;PUT IT IN
	MOVEI T1,1		;1 BYTE
	STOR T1,DTYLN,Q2	;PUT IT IN
	MOVEI T1,NTUDN		;UNSIGNED DECIMAL NUMBER
	STOR T1,DTYBF,Q2	;PUT IT IN
	CALL NTMDTY		;MAKE A DATA TYPE
	 RETBAD ()		;FAILED
	MOVEI T1,1		;1 BYTE
	MOVE P3,NSLDFS		;GET THE CURRENT VALUE
	LSH P3,^D28		;POSITION IT
	MOVE T2,[441000,,P3]	;MAKE A BYTE POINTER
	CALL RETNUM		;RETURN IT TO USER
	 RETBAD ()		;FAILED

;DO NSP LOCAL DELAY WEIGHT

	SETZ Q2,		;INIT THE ARGUMENT
	MOVEI T3,NTPAR		;PARAMETER DATA
	STOR T3,DIDDA,Q2	;PUT IT IN
	MOVEI T3,.NDLDW		;PARAMETER IS LOCAL DELAY WEIGHT
	STOR T3,DIDNO,Q2	;PUT IT IN
	CALL NTMDID		;MAKE A DATA ID
	 RETBAD ()		;FAILED
	SETZ Q2,		;INIT THE ARGUMENT
	MOVEI T1,NTNCD		;NOT CODED
	STOR T1,DTYCD,Q2	;PUT IT IN
	MOVEI T1,NTBIN		;BINARY NUMBER
	STOR T1,DTYTY,Q2	;PUT IT IN
	MOVEI T1,1		;1 BYTE
	STOR T1,DTYLN,Q2	;PUT IT IN
	MOVEI T1,NTUDN		;UNSIGNED DECIMAL NUMBER
	STOR T1,DTYBF,Q2	;PUT IT IN
	CALL NTMDTY		;MAKE A DATA TYPE
	 RETBAD ()		;FAILED
	MOVEI T1,1		;1 BYTE
	MOVE P3,NSLDWS		;GET THE CURRENT VALUE
	LSH P3,^D28		;POSITION IT
	MOVE T2,[441000,,P3]	;MAKE A BYTE POINTER
	CALL RETNUM		;RETURN IT TO USER
	 RETBAD ()		;FAILED

;DO NSP INACTIVITY TIMER

	SETZ Q2,		;INIT THE ARGUMENT
	MOVEI T3,NTPAR		;PARAMETER DATA
	STOR T3,DIDDA,Q2	;PUT IT IN
	MOVEI T3,.NDIAT		;PARAMETER IS INACTIVITY TIMER
	STOR T3,DIDNO,Q2	;PUT IT IN
	CALL NTMDID		;MAKE A DATA ID
	 RETBAD ()		;FAILED
	SETZ Q2,		;INIT THE ARGUMENT
	MOVEI T1,NTNCD		;NOT CODED
	STOR T1,DTYCD,Q2	;PUT IT IN
	MOVEI T1,NTBIN		;BINARY NUMBER
	STOR T1,DTYTY,Q2	;PUT IT IN
	MOVEI T1,2		;2 BYTES
	STOR T1,DTYLN,Q2	;PUT IT IN
	MOVEI T1,NTUDN		;UNSIGNED DECIMAL NUMBER
	STOR T1,DTYBF,Q2	;PUT IT IN
	CALL NTMDTY		;MAKE A DATA TYPE
	 RETBAD ()		;FAILED
	MOVEI T1,2		;2 BYTES
	MOVE P3,NSINAC		;GET THE CURRENT VALUE
	IDIVI P3,^D1000		;CONVERT TO SECONDS
	LSH P3,^D20		;POSITION IT
	MOVE T2,[441000,,P3]	;MAKE A BYTE POINTER
	CALL RETNUM		;RETURN IT TO USER
	 RETBAD ()		;FAILED

;DO NSP RETRANSMIT FACTOR

	SETZ Q2,		;INIT THE ARGUMENT
	MOVEI T3,NTPAR		;PARAMETER DATA
	STOR T3,DIDDA,Q2	;PUT IT IN
	MOVEI T3,.NDRTF		;PARAMETER IS LOCAL DELAY WEIGHT
	STOR T3,DIDNO,Q2	;PUT IT IN
	CALL NTMDID		;MAKE A DATA ID
	 RETBAD ()		;FAILED
	SETZ Q2,		;INIT THE ARGUMENT
	MOVEI T1,NTNCD		;NOT CODED
	STOR T1,DTYCD,Q2	;PUT IT IN
	MOVEI T1,NTBIN		;BINARY NUMBER
	STOR T1,DTYTY,Q2	;PUT IT IN
	MOVEI T1,2		;2 BYTES
	STOR T1,DTYLN,Q2	;PUT IT IN
	MOVEI T1,NTUDN		;UNSIGNED DECIMAL NUMBER
	STOR T1,DTYBF,Q2	;PUT IT IN
	CALL NTMDTY		;MAKE A DATA TYPE
	 RETBAD ()		;FAILED
	MOVEI T1,2		;2 BYTES
	MOVE P3,NSTRYS		;GET THE CURRENT VALUE
	LSH P3,^D20		;POSITION IT
	MOVE T2,[441000,,P3]	;MAKE A BYTE POINTER
	CALL RETNUM		;RETURN IT TO USER
	 RETBAD ()		;FAILED
	RETSKP
;ROUTINE TO RETURN A DATA TYPE
;ACCEPTS:	1/ VALUE TO BE RETURNED
;RETURNS:	+1 FAILED
;		+2 SUCCESS

MAKDTY:	SAVEAC <P3>
	STKVAR <VALUE>
	MOVEM T1,VALUE		;SAVE THE VALUE
	MOVEI T2,NTNCD		;NOT CODED
	STOR T2,DTYCD,Q2	;PUT IT IN
	MOVEI T2,NTSNG		;SINGLE FIELD
	STOR T2,DTYTY,Q2	;PUT IT IN
	MOVEI T2,1		;1 BYTE
	STOR T2,DTYCN,Q2	;PUT IT IN
	CALL NTMDTY		;MAKE THE DATA TYPE
	 RETBAD ()		;FAILED
	MOVEI T1,1		;1 BYTE
	MOVE P3,VALUE		;RETRIEVE THE VALUE
	MOVE T2,[101000,,P3]	;MAKE A BYTE POINTER TO IT
	CALL RETNUM		;RETURN IT
	 RETBAD ()		;FAILED
	RETSKP

	ENDSV.
;TRANSPORT'S PART OF SHOW CHARACTERISTICS
;RETURNS:	+1 FAILED
;		+2 SUCCESS

XPNSCH:	SAVEAC <P3>
	SETZ Q2,		;ZERO THE ARGUMENT
	MOVEI T2,NTPAR		;PARAMETER DATA
	STOR T2,DIDDA,Q2	;PUT IT IN
	MOVEI T2,.NDTYP		;PARAMETER IS TYPE
	STOR T2,DIDNO,Q2	;PUT IT IN
	CALL NTMDID		;MAKE A DATA ID
	 RETBAD ()		;FAILED
	SETZ Q2,		;ZERO THE ARGUMENT
	MOVEI T2,NTCOD		;CODED
	STOR T2,DTYCD,Q2	;PUT IT IN
	MOVEI T2,NTSNG		;SINGLE FIELD
	STOR T2,DTYTY,Q2	;PUT IT IN
	MOVEI T2,1		;ONE BYTE LONG
	STOR T2,DTYCN,Q2	;PUT IT IN
	CALL NTMDTY		;MAKE A DATA TYPE
	 RETBAD ()		;FAILED
	MOVEI P3,PHASE2		;WE ARE PHASE II
	LSH P3,^D28		;POSITION IT
	MOVE T2,[441000,,P3]	;MAKE A BYTE POINTER
	MOVEI T1,1		;NUMBER OF BYTES
	CALL RETNUM		;RETURN IT
	 RETBAD ()		;FAILED

;DO ROUTER MAXIMUM ADDRESS

	SETZ Q2,		;INIT THE ARGUMENT
	MOVEI T3,NTPAR		;PARAMETER DATA
	STOR T3,DIDDA,Q2	;PUT IT IN
	MOVEI T3,.NDMAD		;PARAMETER IS MAXIMUM ADDRESS
	STOR T3,DIDNO,Q2	;PUT IT IN
	CALL NTMDID		;MAKE A DATA ID
	 RETBAD ()		;FAILED
	SETZ Q2,		;INIT THE ARGUMENT
	MOVEI T1,NTNCD		;NOT CODED
	STOR T1,DTYCD,Q2	;PUT IT IN
	MOVEI T1,NTBIN		;BINARY NUMBER
	STOR T1,DTYTY,Q2	;PUT IT IN
	MOVEI T1,2		;2 BYTES
	STOR T1,DTYLN,Q2	;PUT IT IN
	MOVEI T1,NTUDN		;UNSIGNED DECIMAL NUMBER
	STOR T1,DTYBF,Q2	;PUT IT IN
	CALL NTMDTY		;MAKE A DATA TYPE
	 RETBAD ()		;FAILED
	MOVEI T1,2		;2 BYTES
	MOVEI P3,BIGNOD		;GET THE VALUE
	LSH P3,^D20		;POSITION IT
	MOVE T2,[441000,,P3]	;MAKE A BYTE POINTER
	CALL RETNUM		;RETURN IT TO USER
	 RETBAD ()		;FAILED
	RETSKP
;ROUTINE TO RETURN THE NODE IDENTIFICATION
;RETURNS:	+1 FAILED
;		+2 SUCCESS

RETIDN:	SETZ Q2,		;ZERO THE ARGUMENT
	MOVEI T2,NTPAR		;PARAMETER DATA
	STOR T2,DIDDA,Q2	;PUT IT IN
	MOVEI T2,.NDNID		;PARAMETER IS "IDENTIFICATION"
	STOR T2,DIDNO,Q2	;PUT IT IN
	CALL NTMDID		;MAKE A DATA ID
	 RETBAD ()		;FAILED
	SETZ Q2,		;ZERO THE ARGUMENT
	MOVEI T2,NTNCD		;NOT CODED
	STOR T2,DTYCD,Q2	;PUT IT IN
	MOVEI T2,NTASC		;ASCII
	STOR T2,DTYTY,Q2	;PUT IT IN
	CALL NTMDTY		;MAKE A DATA TYPE
	 RETBAD ()		;FAILED
	MOVE T3,[441000,,NDIDN]  ;MAKE BYTE POINTER TO STRING
	MOVEI T2,.NTBPT(Q1)	;POINT TO USER'S SPACE
RETID1:	ILDB T1,T3		;GET A BYTE
	JUMPE T1,RSKP		;IF NULL, DONE
	CALL NTMBYT		;UPDATE COUNT
	 RETBAD ()		;FAILED
	XCTBU [IDPB T1,(T2)]	;RETURN IT
	JRST RETID1		;GO FOR MORE
;ENTITY = NODE
;FUNCTION = SHOW SELECTED ITEMS
;SELECTOR = COUNTERS
;RETURNS:	+1 FAILED, 1/ ERROR CODE
;		+2 SUCCESS, 1/ NODE ADDRESS

NSNSCO:	SAVEAC <P3>
	STKVAR <ADDR>
	CALL NANUEX		;GET NODE NUMBER
	 RETBAD ()		;FAILED
	MOVEM T1,ADDR		;SAVE THE NODE ADDRESS
	MOVSI P3,-NSNODL	;MAKE AOBJN WORD
NSNSC1:	HRRZ T4,P3		;GET THE OFFSET INTO THE COUNTER TABLES
	ADD T4,[NSNODC]		;POINT TO THIS TABLE'S ADDRESS
	MOVE T3,(T4)		;GET THE TABLE ADDRESS
	ADD T3,ADDR		;GET THE NODE'S OFFSET
	MOVE T2,(T3)		;GET THE CURRENT VALUE OF THIS COUNTER
	MOVE T3,P3		;RETRIEVE OFFSET INTO COUNTER TABLES
	ADD T3,[NSNWID]		;MOVE TO THIS COUNTER'S INFO
	HRRZ T1,(T3)		;GET THE COUNTER NUMBER
	CAIE T1,.NSSSL		;IS THIS "SECONDS SINCE LAST ZERO"
	IFSKP.
	   MOVE T3,ADDR		;YES, GET NODE NUMBER
	   MOVE T2,TODCLK	;GET UPTIME
	   LSH T2,-11		;CONVERT TO SECONDS
	   SUB T2,@[EP. NSSSLZ(T3)] ;GET TIME OF LAST ZEROING
	   ANDI T2,177777	;ONLY 16 BITS WORTH
	ENDIF.
	CALL RETCNT		;RETURN THE INFO TO THE USER
	 RETBAD ()		;FAILED
	AOBJN P3,NSNSC1		;ANY MORE TO DO?
	MOVE T1,ADDR		;GET BACK NODE ADDRESS
	RETSKP

	ENDSV.


;ENTITY = NODE
;FUNCTION = SHOW AND ZERO COUNTERS
;RETURNS:	+1 FALIED, 1/ ERROR CODE
;		+2 SUCCESS

NTNSZC:	CALL NSNSCO		;RETURN THE COUNTERS
	 RETBAD ()		;FAILED
	CALL NTNZR2		;ZERO THE COUNTERS
	 RETBAD ()		;FAIELD
	RETSKP
;ENTITY = NODE
;FUNCTION = RETURN LIST OF ITMES
;NOW FIND THE SELECTOR
;RETURNS:	+1 FAILED, 1/  ERROR CODE
;		+2 SUCCESS

NTNRET:	MOVN T1,.NTSEL(Q1)	;GET THE SELECTOR
	SOS T1			;MAKE THE ADJUSTMENT FOR DISPATCHING
	CAIL T1,0		;IS IT
	CAIL T1,NTRETL		; VALID?
	JRST NMXII		;NO, ERROR RETURN
	MOVE T4,NTRETS(T1)	;GET DISPATCH ADDRESS
	CALL (T4)		;GO DO THE WORK
	 RETBAD ()		;FAILED
	RETSKP			;SUCCESS

NTRETS:	EXP NTNRLS		;KNOWN ITEMS
	EXP NTNRAC		;ACTIVE ITEMS
	EXP NMXII		;LOOPED ITEMS
NTRETL==.-NTRETS




;ENTITY = NODE
;FUNCTION = RETURN LIST OF ITEMS
;SELECTOR = KNOWN
;RETURNS:	+1  FAILED, 1/ ERROR CODE
;		+2  SUCCESS

NTNRLS:	CALL SCNRET		;GET SESSION CONTROL INFO
	 RETBAD ()		;FAILED, ERROR RETURN
	RETSKP			;SUCCESS
;ENTITY = NODE
;FUNCTION = RETURN LIST OF ITEMS
;SELECTOR = KNOWN
;SESSION CONTROL'S PART
;RETURNS:	+1  FAILED   1/ ERROR CODE
;		+2  SUCCESS

SCNRET:	SAVEAC <P3>
	NOINT
	LOCK NMAPLK		;LOCK THE MAPPING TABLE
	HRLI P3,-BIGNOD		;MAKE AOBJN
	HRRI P3,1		; WORD
SCNRE1:	MOVE T2,[NODMAP]	;OFFSET INTO
	ADDI T2,(P3)		; THE TABLE
	MOVE T1,(T2)		;GET THE CURRENT NAME
	JUMPE T1,[	MOVE T2,[440200,,NODTBL]  ;POINT TO REACH TABLE
			HRRZ T3,P3		;GET NODE NUMBER
			ADJBP T3,T2		;OFFSET TO NODE
			LDB T2,T3		;GET REACH INFO
			JUMPE T2,SCNRE2		;IF NOT REACHABLE, MOVE ON
			JRST .+1]		;REACHABLE
	HRRZ T1,P3		;GET NODE ADDRESS
	CALL RETADR		;RETURN THE NODE ADDRESS
	 JRST SCNRE3		;FAILED
	CALL FNDNAM		;LOOK UP THE NODE NAME
	CALL RETNAM		;RETURN THE NODE NAME
	 JRST SCNRE3		;FAILED
SCNRE2:	AOBJN P3,SCNRE1		;LOOK AT THE ENTIRE TABLE
	UNLOCK NMAPLK		;UNLOCK THE MAPPING TABLE
	OKINT
	RETSKP			;GOOD RETURN

SCNRE3:	UNLOCK NMAPLK
	OKINT
	RETBAD ()
;ENTITY = NODE
;FUNCTION = RETURN LIST OF ITEMS
;SELECTOR = ACTIVE
;RETURNS:	+1  FAILED  1/ ERROR CODE
;		+2  SUCCESS

NTNRAC:	SAVEAC <P3,P6>
	NOINT
	LOCK NMAPLK
	SETZ P3,		;INIT THE NODE NUMBER
	MOVE P6,[440200,,NODTBL]  ;POINT TO REACH TABLE
NTNRA1:	ILDB T1,P6		;GET THE INFO
	AOS P3			;SET THE NODE NUMBER
	JUMPE T1,NTNRA2
	MOVE T1,P3		;GET THE NODE NUMBER IN A GOOD PLACE
	CALL RETADR		;RETURN THE NODE NUMBER TO USER
	 JRST NTNRA3		;FAILED
	CALL FNDNAM		;LOOK UP THE NODE NAME
	CALL RETNAM		;RETURN THE NODE NAME TO THE USER
	 JRST NTNRA3		;FAILED
NTNRA2:	CAIGE P3,BIGNOD		;MORE NODES TO CHECK?
	JRST NTNRA1		;YES
	UNLOCK NMAPLK
	OKINT
	RETSKP

NTNRA3:	UNLOCK NMAPLK
	OKINT
	RETBAD ()
	SUBTTL Logging Entity

;ENTITY = LOGGING
;NOW GET THE FUNCTION
;RETURNS:	+1  FAILED, T1/ ERROR CODE
;		+2  SUCCESS

NTLOG:	MOVE T1,.NTFNC(Q1)	;GET FUNCTION REQUESTED
	MOVNI T2,LOWFNC		;ADJUST THE FUNCTION CODE
	HRRZS T2		;MAKE IT USEFUL
	ADD T1,T2		; FOR DISPATCHING
	CAIL T1,0		;A VALID
	CAIL T1,NTLOGL		; FUNCTION?
	JRST NMXII		;NO, ERROR RETURN
	MOVE T4,NTLOGF(T1)	;GET DISPATCH ADDRESS
	CALL (T4)		;GO DO THE WORK
	 RETBAD ()		;ERROR
	RETSKP			;SUCCESS

NTLOGF:	EXP NTLPSI		;(-3) SET PSI CHANNEL FOR EVENT AVAILABLE
	EXP NMXUFO		;(-2) MAP NODE NUMBER TO NODE NAME
	EXP NMXUFO		;(-1) RETURN EXECUTOR NODE ID
	EXP NMXUFO		;(0) SET PARAMETER
	EXP NMXUFO		;(1) CLEAR PARAMETER
	EXP NMXUFO		;(2) ZERO ALL COUNTERS
	EXP NMXUFO		;(3) SHOW SELECTED ITMES
	EXP NMXUFO		;(4) SHOW AND ZERO ALL COUNTERS
	EXP NMXUFO		;(5) RETURN LIST OF ITEMS
	EXP NTLPEQ		;(6) PROCESS THE EVENT QUEUE
NTLOGL==.-NTLOGF
;ENTITY = LOGGING
;FUNCTION = SET PSI CHANNEL
;RETURNS:	+1 FAILED
;		+2 SUCCESS

NTLPSI:	SKIPN T1,EVRFRK		;SOMEONE ALREADY DOING THIS?
	IFSKP.
	   HRRZS T1		;YES, GET HIS ID
	   CAME T1,FORKX	;IS HE RESETTING?
	   JRST NMXMPE		;NO, ONLY ONE EVENT READER IS ALLOWED
	ENDIF.
	MOVE T1,.NTSEL(Q1)	;GET USER'S PSI CHANNEL
	CAME T1,[-1]		;DOES HE STILL WANT TO BE NOTIFIED?
	IFSKP.
	   SETZM EVRFRK		;NO, NO MORE EVENT READER
	ELSE.
	   CAIL T1,0		;YES, CHECK FOR
	   CAILE T1,^D36	; LEGAL PSI CHANNEL
	   JRST NMXMPE		;ILLEGAL
	   AOS T1		;FIX IT FOR INTERNAL USE
	   HRLM T1,EVRFRK	;SET IT UP
	   MOVE T1,FORKX	;GET USER
	   HRRM T1,EVRFRK	;SET IT UP
	ENDIF.
	RETSKP


;KILL THE EVENT READER (CALLED FROM .RESET AND KSELF)
;RETURNS:	+1

EVRKIL::HRRZ T1,EVRFRK		;GET THE EVENT LOGGER
	CAMN T1,FORKX		;IS IT US?
	SETZM EVRFRK		;YES, NO MORE EVENT READER
	RET			;NO, NOTHING TO DO
;ENTITY = LOGGING
;FUNCTION = PROCESS THE EVENT QUEUE
;RETURNS:	+1 FAILED
;		+2 SUCCESS

NTLPEQ:	HRRZ T1,EVRFRK		;GET EVENT READER FORK
	CAME T1,FORKX		;THIS THE ONE?
	JRST NMXMPE		;NO, MANAGEMENT PROGRAM ERROR
	SAVEAC <Q2>
	PIOFF			;LOCK THE EVENT QUEUE
	SKIPE NEVNTS		;ANY QUEUED EVENTS?
	IFSKP.
	   PION			;NO, UNLOCK THE EVENT QUEUE
	   JRST NMXOF		;OPREATION FAILURE (NML UNDERSTANDS THIS)
	ENDIF.
	MOVE Q2,EVENTS		;GET THE FIRST EVENT
	CALL DOEVNT		;RETURN IT TO NML
	SOS NEVNTS		;ONE LESS QUEUED EVENT
	MOVE T1,Q2		;POSITION THE EVENT'S ADDRESS
	SKIPN Q2,(Q2)		;GET THE NEXT EVENT
	SETZM EVENTS+1		;THIS IS THE LAST ONE, RESET TAIL OF QUEUE
	MOVEM Q2,EVENTS		;PUT NEXT ONE AT HEAD OF THE QUEUE
	CALL RELRES		;RELEASE THIS EVENT
	PION			;UNLOCK THE EVENT QUEUE
	RETSKP
;RETURN AN EVENT TO THE USER
;ACCEPTS:	+1/ ADDRESS OF EVENT
;RETURNS:	+1
;PRESERVES T1
;*** MUST BE CALLED PIOFF ***

DOEVNT:	RET
;QUEUE AN EVENT
;ACCEPTS:	T1/ ADDRESS OF EVENT
;RETURNS:	+1

QEVENT::SAVEAC <Q1>
	PIOFF			;LOCK THE EVENT QUEUE
	MOVE Q2,NEVNTS		;GET THE NUMBER OF QUEUED EVENTS
	CAIE Q2,MXEVNT		;IS THE QUEUE FULL?
	IFSKP.
	   CALL RELRES		;YES, TOSS THIS ONE
	   PION			;UNLOCK THE QUEUE
	   RET
	ENDIF.
	CAIE Q2,MXEVNT-1	;ROOM FOR EXACTLY 1 ONE MORE?
	IFSKP.
	   CALL RELRES		;YES, TOSS THIS EVENT
				; AND QUEUE THE "EVENT LOST" EVENT
	ENDIF.
	SKIPN Q2		;IS THE QUEUE EMPTY?
	IFSKP.
	   MOVE T2,EVENTS+1	;NO, GET THE LAST ENTRY
	   MOVEM T1,(T2)	;MAKE IT POINT TO US
	ELSE.
	   MOVEM T1,EVENTS	;YES, MAKE US BE FIRST
	ENDIF.
	MOVEM T1,EVENTS+1	;MAKE US BE LAST
	AOS NEVNTS		;1 MORE EVENT IN QUEUE
	PION			;UNLOCK THE EVENT QUEUE
	HRRZ T2,EVRFRK		;GET EVENT READER FORK
	HLRZ T1,EVRFRK		;GET PSI
	SOS T1			; CHANNEL
	CALL PSIRQ		;LET HIM KNOW
	RET
	SUBTTL NTMAN% JSYS Support Routines

;ROUTINE TO RETURN A NODE NAME TO THE USER
;ACCEPTS:	2/ ADDRESS OF SIXBIT NODE NAME
;		4/ NUMBER OF BYTES IN NODE NAME
;RETURNS:	+1 FAILED    1/ ERROR CODE
;		+2 SUCCESS

RETNAM:	STKVAR <MONPTR,COUNT>
	MOVEM T2,MONPTR		;SAVE
	MOVEM T4,COUNT		;  ARGUMENTS
	MOVE T2,T4		;GET COUNT IN PROPER AC FOR NOUT
	MOVE T1,[POINT 7,T4]	;MAKE BYTE POINTER TO BYTE COUNT
	MOVE T3,[1B17+<12>B35]	;1 BYTE, IN DECIMAL
	NOUT			;CONVERT IT TO ASCII
	 JRST NMXMPE		;INTERNAL NETWORK MANAGEMENT ERROR
	CALL NTMBYT		;UPDATE THE BYTE COUNT
	 RETBAD ()		;DON'T HAVE ROOM
	XCTBU [IDPB T2,.NTBPT(Q1)]	;FILL IN COUNT FIELD
	SKIPN T1,COUNT		;GET THE BYTE COUNT
	RETSKP			;IT'S ZERO, ALL DONE
	MOVE T3,MONPTR		;MAKE BYTE POINTER
	MOVE T2,[POINT 6,(T3)]	; TO THE NODE NAME
RETNA1:	ILDB T4,T2		;GET A BYTE
	ADDI T4,40		;CONVERT TO ASCII
	CALL NTMBYT		;UPDATE BYTE COUNT
	 RETBAD ()		;DON'T HAVE ROOM
	XCTBU [IDPB T4,.NTBPT(Q1)]	;PUT IT IN THE DESTINATION
	SOJG T1,RETNA1		;MORE TO DO?
	RETSKP			;NO

	ENDSV.
;ROUTINE TO LOOK UP A NODE NAME
;ACCEPTS:	1/ NODE ADDRESS
;RETURNS:	+1  WITH  1/ NODE ADDRESS
;			  2/ ADDRESS OF SIXBIT NODE NAME
;		          4/ NUMBER OF BYTES IN NODE NAME

FNDNAM:	SAVEAC <T1>
	STKVAR <ADDR>
	ADD T1,[NODMAP]		;OFFSET INTO TABLE
	MOVEM T1,ADDR		;SAVE IT
	MOVE T2,[POINT 6,(T1)]	;MAKE BYTE POINTER TO IT
	HRLZI T4,-6		;MAXIMUM OF SIX BYTES IN NAME
FNDNA1:	ILDB T3,T2		;GET A BYTE
	SKIPE T3		;IF NULL, ALL DONE
	AOBJN T4,FNDNA1		;MORE BYTES TO CHECK?
FNDNA2:	HRRZS T4		;GET NUMBER OF BYTES INTO PROPER AC
	MOVE T2,ADDR		;RETRIEVE THE NODE NAME ADDRESS
	RET			;ALL DONE

	ENDSV.
;ROUTINE TO GET A NODE NAME FROM THE USER AND VERIFY THAT IT IS MADE
;UP OF ALPHANUMERIC CHARACTERS, ONE OF WHICH MUST BE ALPHA.
;ACCEPTS:	3/ ADDRESS OF USER'S BYTE POINTER
;RETURNS:	+1  -  INVALID, 1/ ERROR CODE
;		+2  -  O.K.  WITH  1/ SIXBIT NODE NAME
;				   2/ NUMBER OF BYTES IN NODE NAME

GETNAM:	SAVEAC <P3,P6>
	STKVAR <COUNT>
	SETZB T1,P6		;ZERO THE DESTINATION WORD AND ALPHA FLAG
	MOVE T4,[POINT 6,T1]	;MAKE BYTE POINTER TO DESTINATION
	XCTBU [ILDB P3,(T3)]	;GET THE "COUNT" BYTE
	CAIL P3,1		;IS IT WITHIN
	CAILE P3,.NDNMX-1	; RANGE?
	JRST NMXII		;NO, INVALID BYTE COUNT FOR NODE NAME
	MOVEM P3,COUNT		;SAVE IT
GETNA1:	XCTBU [ILDB T2,(T3)]	;GET A BYTE
	CALL CHKAL		;IS IT ALPHABETIC?
	 JRST [CALL CHKNUM	;NO, IS IT NUMERIC?
	        JRST NMXII	;NO, INVALID FORMAT
	       JRST .+1]	;YES, MOVE ON
	SUBI T2,40		;MAKE IT SIXBIT
	IDPB T2,T4		;PUT IT IN DESTINATION
	SOJG P3,GETNA1		;MORE TO DO?
	SKIPN P6		;DID WE FIND AN ALPHABETIC CHARACTER?
	JRST NMXII		;NO. INVALID
	MOVE T2,COUNT		;RETRIEVE THE COUNT
	RETSKP

CHKAL:	CAIL T2,"A"
	CAILE T2,"Z"
	RET			;NOT ALPHA
	SETOM P6		;SET THE "FOUND ALPHA" FLAG
	RETSKP			;IS ALPHA

CHKNUM:	CAIL T2,"0"
	CAILE T2,"9"
	RET			;NOT NUMERIC
	RETSKP			;IS NUMERIC

	ENDSV.
;ROUTINE TO FIND A NODE NUMBER BY PARSING THE ENTITY ID FIELD
;RETURNS:	+1  ERROR     1/ ERROR CODE
;		+2  SUCCESS   1/ NODE NUMBER

NANUEX:	MOVEI T1,.NDALN		;GET LENGTH OF NODE NUMBER
	ADJBP T1,.NTEID(Q1)	;SKIP THE NODE NUMBER
	XCTBU [ILDB T2,T1]	;GET THE NUMBER OF BYTES IN THE NODE NAME
	JUMPN T2,NANUE1		;IF SOME THERE, MOVE ON
	HRREI T2,-<.NDALN+1>	;BACKUP TO
	ADJBP T2,T1		; NODE NUMBER
	MOVEM T2,.NTEID(Q1)	;RESET THE BYTE POINTER
	MOVEI T3,.NTEID(Q1)	;POINT TO THE NEW POINTER
	CALL GETADR		;GET THE NODE NUMBER
	 JRST [	SKIPE T1	;WAS IT 0?
		JRST NMXII	;NO, FAIL
		MOVE T1,OURNUM	;YES, THAT MEANS EXECUTOR
		RETSKP]		;DONE
	RETSKP			;DONE

NANUE1:	SETO T2,		;BACKUP TO
	ADJBP T2,T1		; READ THE NODE NAME
	MOVEM T2,.NTEID(Q1)	;RESET THE BYTE POINTER
NANUE2:	MOVEI T3,.NTEID(Q1)	;POINT TO THE NEW POINTER
	CALL GETNAM		;GET THE NODE NAME
	 RETBAD ()		;FAILED
	NOINT
	LOCK NMAPLK		;LOCK THE NODE NAME MAPPING TABLE
	CALL FNDADR		;FIND THE NODE NUMBER
	 JRST [	UNLOCK NMAPLK	;UNLOCK THE TABLE
		OKINT
		JRST NMXUC]	;FAILED
	UNLOCK NMAPLK		;UNLOCK THE TABLE
	OKINT
	RETSKP
;ROUTINE TO LOOK UP A NODE ADDRESS
;
;ACCEPTS:	1/ SIXBIT NODE NAME
;
;RETURNS:	+1  NOT FOUND
;		+2  WITH  1/ NODE ADDRESS

FNDADR:	HRLZI T4,-<BIGNOD+1>	;MAKE AOBJN WORD
FNDAD1:	HRRZ T3,T4		;GET OFFSET ONLY
	ADD T3,[NODMAP]		;MOVE INTO THE TABLE
	CAMN T1,(T3)		;IS THIS A MATCH?
	JRST [HRRZ T1,T4	;YES, GET NODE ADDRESS IN PROPER AC
	      RETSKP]
	AOBJN T4,FNDAD1		;ANY MORE TO CHECK?
	RET			;NO.  FAIL RETURN


;ROUTINE TO UPDATE THE "RETURNED BYTE COUNT" IN THE USER'S ARGUMENT BLOCK
;RETURNS:	+1 FAIL     1/ ERROR CODE
;		+2 SUCCESS

NTMBYT:	SOSGE Q3		;USER HAVE ANY MORE ROOM?
	JRST NMXRE		;NO, FAIL
	AOS .NTBYT(Q1)		;UPDATE THE RETURN COUNT
	RETSKP
;ROUTINE TO RETURN A NODE ADDRESS TO THE USER
;
;ACCEPTS:	1/ NODE ADDRESS
;RETURNS:	+1 FAILED     1/ ERROR CODE
;		+2 SUCCESS
;PRESERVES T1

RETADR:	SAVEAC <T1,P3>
	MOVE P3,T1		;GET ADDRESS IN GOOD PLACE
	LSH P3,4		;POSITION IT
	MOVEI T1,.NDALN		;GET NUMBER OF BYTES IN NODE ADDRESS
	MOVE T2,T1		;PRESERVE IT IN T1
	MOVNS T2		;MAKE BYTE
	MOVE T4,[041000,,P3]	; POINTER
	ADJBP T2,T4		;  TO ADDRESS
	CALL RETNUM		;RETURN NODE ADDRESS TO USER
	 RETBAD ()		;FAILED
	RETSKP


;RETURN A NUMBER TO THE USER
;ACCEPTS:	1/ NUMBER OF BYTES
;		2/ BYTE POINTER TO NUMBER
;RETURNS:	+1 FAILED     1/ ERROR CODE
;		+2 SUCCESS

RETNUM:	SOS T1			;FIX IT FOR BYTE POINTER ADJUSTING AND LOOPING
	MOVE T3,T1		;MAKE A COPY
RETNU1:	ADJBP T1,T2		;POINT TO REMAINING RIGHT-MOST BYTE
	ILDB T4,T1		;GET IT
	CALL NTMBYT		;UPDATE BYTE COUNT
	 RETBAD ()		;FAILED, USER DOESN'T HAVE ROOM
	XCTBU [IDPB T4,.NTBPT(Q1)]  ;GIVE BYTE TO USER
	SOJL T3,RSKP		;MORE TO DO?
	MOVE T1,T3		;YES, GET NEW BYTE POSITION
	JRST RETNU1		;GO BACK FOR MORE


;ROUTINE TO GET A NODE ADDRESS FROM USER
;AND VERIFY THAT IT IS A LEGITIMATE ADDRESS.
;
;ACCEPTS:	3/ ADDRESS OF USER'S BYTE POINTER
;RETURNS:	+1  ERROR 1/ NUMBER FOUND
;		+2  WITH  1/ NUMERIC NODE ADDRESS

GETADR:	MOVEI T4,.NDALN		;GET NUMBER OF BYTES IN A NODE ADDRESS
	CALL GETNUM		;GET THE NUMBER
	MOVE T1,T2		;GET NODE ADDRESS
	CAIL T1,1		;A VALID
	CAILE T1,BIGNOD		; NODE ADDRESS?
	RET
	RETSKP			;GOOD RETURN
;ROUTINE TO GET A PARAMETER NUMBER FROM THE USER
;
;ACCEPTS:	3/ ADDRESS OF USER'S BYTE POINTER
;RETURNS:	2/ PARAMETER NUMBER

GETPAR:	MOVEI T4,.NDPLN		;GET NUMBER OF BYTES IN A PARAMETER NUMBER
	CALLRET GETNUM		;GET THE NUMBER


;ROUTINE TO GET A NUMBER FROM THE USER
;
;ACCEPTS:	3/ ADDRESS OF USER'S BYTE POINTER
;		4/ NUMBER OF BYTES IN NUMBER
;RETURNS:	+1   2/ NUMBER

GETNUM:	SAVEAC <P3>
	MOVE P3,T4		;PRESERVE COUNT FOR LOOPING
	SETZ T2,		;INIT THE DESTINATION WORD
GETNU1:	XCTBU [ILDB T1,(T3)]	;GET BYTE
	IORM T1,T2		;PUT IT IN
	ROT T2,-10		;POSIITON FOR NEXT
	SOJG T4,GETNU1		;MORE TO DO?
	ROT T2,10		;UNWIND
	SOJG P3,.-1		; THE BYTE STRING
	RET			;DONE


;ROUTINE TO LOOK UP A PARAMETER NUMBER
;ACCEPTS:	2/ PARAMETER NUMBER
;RETURNS:	1/ OFFSET INTO PARAMETER TABLE

FNDPAR:	MOVEI T1,NSNPRL		;GET NUMBER OF ENTRIES IN TABLE
	SOS T1			;FIX FOR OFFSETING
FNDPA1:	XMOVEI T3,NSNPAR	;GET TABLE BASE
	ADD T3,T1		;GET OFFSET
	CAMN T2,(T3)		;THIS IT?
	RETSKP			;YES, DONE
	SOJGE T1,FNDPA1		;ANY MORE TO CHECK?
	JRST NMXUPT		;NO, BAD NUMBER
;ROUTINE TO RETURN A NODE ID TO THE USER
;ACCEPTS:	T1/ NODE NUMBER
;		T2/ PARAMETER NUMBER
;RETURNS:	+1 FAILED   1/ ERROR CODE
;		+2 SUCCESS

RETNID:	ASUBR <NDNUM,PARNUM>
	SETZM Q2		;INIT THE ARGUMENT
	MOVEI T1,NTPAR		;PARAMETER DATA
	STOR T1,DIDDA,Q2	;PUT IT IN
	STOR T2,DIDNO,Q2	;PUT IN PARAMETER NUMBER
	CALL NTMDID		;MAKE A DATA ID
	 RETBAD ()		;FAILD
	SETZM Q2		;INIT THE ARGUMENT
	MOVEI T1,NTCOD		;CODED
	STOR T1,DTYCD,Q2	;PUT IT IN
	MOVEI T1,NTMUL		;MULTIPLE FIELDS
	STOR T1,DTYTY,Q2	;PUT IT IN
	MOVEI T1,2		;NUMBER OF FIELDS IN A NODE ID
	STOR T1,DTYCN,Q2	;PUT IT IN
	CALL NTMDTY		;MAKE A DATA TYPE
	 RETBAD ()		;FAILED
	SETZM Q2		;INIT THE ARGUMENT
	MOVEI T1,NTNCD		;NOT CODED
	STOR T1,DTYCD,Q2	;PUT IT IN
	MOVEI T1,NTBIN		;BINARY NUMBER
	STOR T1,DTYTY,Q2	;PUT IT IN
	MOVEI T1,NTOCT		;OCTAL NUMBER
	STOR T1,DTYBF,Q2	;PUT IT IN
	MOVEI T1,.NDALN		;BYTES IN A NODE ADDRESS
	STOR T1,DTYLN,Q2	;PUT IT IN
	CALL NTMDTY		;MAKE A DATA TYPE
	 RETBAD ()		;FAILED
	MOVE T1,NDNUM		;GET NODE NUMBER
	CALL RETADR		;RETURN THE NODE NUMBER TO USER
	 RETBAD ()		;FAIL
	SETZM Q2		;INIT THE ARGUMENT
	MOVEI T1,NTNCD		;NOT CODED
	STOR T1,DTYCD,Q2	;PUT IT IN
	MOVEI T1,NTASC		;ASCII IMAGE
	STOR T1,DTYTY,Q2	;PUT IT IN
	CALL NTMDTY		;MAKE A DATA TYPE
	 RETBAD ()		;FAILED
	MOVE T1,NDNUM		;GET NODE NUMBER
	CALL FNDNAM		;GET THE NODE NAME
	CALL RETNAM		;RETURN THE NODE NAME TO THE USER
	 RETBAD ()		;FAILED
	RETSKP

	ENDAS.
;RETURN A COUNTER TO THE USER
;ACCEPTS:	T1/ COUNTER NUMBER
;		T2/ CURRENT VALUE OF COUNTER
;RETURNS:	+1 FAILED     1/ ERROR CODE
;		+2 SUCCESS

RETCNT:	ASUBR <NUM,VAL,WIDTH>
	SAVEAC <P3>
	SETZM Q2		;INIT THE DESTINATION WORD
	MOVEI T2,NTCOU		;COUNTER DATA
	STOR T2,DIDDA,Q2	;PUT IT IN
	STOR T1,DIDNO,Q2	;PUT IN THE COUNTER NUMBER
	CALL FNDCNT		;FIND THE COUNTER OFFSET
	ADD T2,[NSNWID]		;MOVE TO THIS COUNTER'S INFO
	HLRZ T1,(T2)		;GET THE COUNTER NUMBER
	STOR T1,DIDWD,Q2	;PUT IT IN
	MOVEM T1,WIDTH		;SAVE IT
	CALL NTMDID		;MAKE A DATA ID
	 RETBAD ()		;FAILED
	MOVE T1,WIDTH		;RETRIEVE THE WIDTH
	IDIVI T1,10		;CONVERT TO BYTES
	MOVE T2,T1		;SAVE IT IN T1
	MOVE P3,VAL		;GET THE COUNTER VALUE
	LSH P3,4		;POSITION IT
	MOVNS T2		;MAKE A
	MOVE T3,[041000,,P3]	; BYTE POINTER
	ADJBP T2,T3		;  TO THE NUMBER
	CALL RETNUM		;RETURN THE COUNTER TO USER
	 RETBAD ()		;FAILED
	RETSKP			;DONE

	ENDAS.

;GET A COUNTER'S OFFSET INTO THE COUNTER TABLES
;ACCEPTS:	T1/ COUNTER NUMBER
;RETURNS:	+1  T2/ OFFSET INTO COUNTER TABLES

FNDCNT:	MOVEI T2,NSNWDL		;GET THE NUMBER
	SOS T2			; OF TABLES
FNDCN1:	MOVE T4,T2		;SAVE T2
	ADD T4,[NSNWID]		;OFFSET INTO TABLE
	HRRZ T3,(T4)		;GET THE COUNTER NUMBER
	CAME T3,T1		;A MATCH?
	SOJGE T2,FNDCN1		;NO, MORE TO DO?
	RET			;YES, DONE
;BUILD A DATA ID
;ACCEPTS:	Q2/ DATA ID PARAMETERS
;			DEFSTR (DIDDA,0,0,1)
;			       (DIDWD,0,7,6)
;			       (DIDNO,0,17,11)
;RETURNS:	+1 FAILED    1/ ERROR CODE
;		+2 SUCCESS

NTMDID:	SAVEAC <P3>
	SETZM P3		;INIT THE DESTINATION
	LOAD T2,DIDNO,Q2	;GET THE PARAMETER OR COUNTER NUMBER
	STOR T2,NT%PNM,P3	;PUT IN NUMBER
	LOAD T2,DIDDA,Q2	;GET THE DATA TYPE
	CAIE T2,NTCOU		;COUNTER?
	JRST NTMDI1		;NO, PARAMETER
	SETONE NT%DAT,P3	;SAY COUNTER DATA TYPE
	LOAD T3,DIDWD,Q2	;GET COUNTER WIDTH
	LSH T3,-4		;CONVERT NUMBER OF BYTES
	AOS T3			; INTO PROPER CODE
	STOR T3,NT%CWD,P3	;PUT IN COUNT
NTMDI1:	HRLI T2,441000		;MAKE A BYTE POINTER
	HRRI T2,P3		; TO IT
	MOVEI T1,NTMDIL		;GET LENGTH OF DATA ID
	CALL RETNUM		;GIVE IT TO USER
	 RETBAD ()		;FAILED
	RETSKP
;BUILD A DATA TYPE
;ACCEPTS:	Q2/ DATA TYPE PARAMETERS
;			DEFSTR (DTYCD,0,0,1)
;			       (DTYTY,0,1,1)
;			       (DTYCN,0,7,6)
;			       (DTYBF,0,3,2)
;			       (DTYLN,0,7,4)
;RETURNS:	+1 FAILED    1/ ERROR CODE
;		+2 SUCCESS

NTMDTY:	SETZM T4		;INIT THE DESTINATION
	LOAD T2,DTYCD,Q2	;GET CODE INDICATOR
	CAIE T2,NTCOD		;CODED?
	JRST NTMDT1		;NO
	SETONE NT%COD,T4	;CODED, SAY SO
	LOAD T2,DTYTY,Q2	;GET TYPE
	SKIPE T2		;SINGLE FIELD?
	SETONE NT%TYP,T4	;NO, MULTIPLE FIELDS
	LOAD T2,DTYCN,Q2	;GET NUMBER OF FIELDS OR BYTES
	STOR T2,NT%CNT,T4	;PUT IT IN
	JRST NTMDT2		;MOVE ON

NTMDT1:	LOAD T2,DTYTY,Q2	;NOT CODED, GET TYPE
	SKIPE T2		;BINARY?
	SETONE NT%TYP,T4	;NO, ASCII IMAGE
	LOAD T2,DTYLN,Q2	;GET BYTE COUNT
	STOR T2,NT%LEN,T4	;PUT IT IN
	LOAD T2,DTYBF,Q2	;GET FORMAT
	STOR T2,NT%FMT,T4	;PUT IT IN
NTMDT2:	HRLI T3,441000		;MAKE BP
	HRRI T3,T4		; TO DATA TYPE
	MOVEI T2,NTMDTL		;GET NUMBER OF BYTES IN DATA TYPE
NTMDT3:	ILDB T1,T3		;GET A BYTE
	CALL NTMBYT		;UPDATE BYTE COUNT
	 RETBAD ()		;DON'T HAVE ROOM
	XCTBU [IDPB T1,.NTBPT(Q1)]  ;RETURN IT TO USER
	SOJG T2,NTMDT3		;MORE TO DO?
	RETSKP

	TNXEND

	END