Google
 

Trailing-Edge - PDP-10 Archives - BB-H348C-RM_1982 - swskit-v21/debugging-tools/dynets/dymods.mac
There is 1 other file named dymods.mac in the archive. Click here to see a list.
;<GUNN.DTR>DYMODS.MAC.2, 20-Dec-79 13:33:38, Edit by GUNN
;CHANGE TO ACCEPT ONLY SEGMENT:8 AS DTR FLOW CONTROL REQUEST
;<GUNN.DYNETS>DYMODS.MAC.215,  4-May-78 15:18:34, Edit by GUNN
;ADD RANGE CHECK FOR MESSAGE LENGTHS IN DATA TEST
;<GUNN.DYNETS>DYMODS.MAC.212,  3-May-78 13:49:14, Edit by GUNN
;ADD CODE TO KEEP TRACK OF SEND & RECEIVE BYTE COUNTS IN LCB
;<GUNN.DYNETS>DYMODS.MAC.210,  3-May-78 12:10:01, Edit by GUNN
;ADD CODE TO PRINT MESSAGE COUNTS AND DATA RATE FOR DTR
;ADD CODE TO PRINT NSP ERROR TEXT
;<GUNN.DYNETS>DYMODS.MAC.204, 11-Apr-78 16:45:36, Edit by GUNN
;<GUNN.DYNETS>DYMODS.MAC.203, 11-Apr-78 15:01:08, Edit by GUNN
;<GUNN.DYNETS>DYMODS.MAC.202, 11-Apr-78 11:54:40, Edit by GUNN
;<GUNN.DYNETS>DYMODS.MAC.200, 10-Apr-78 11:27:57, Edit by GUNN
;<GUNN.DYNETS>DYMODS.MAC.194, 26-Jan-78 16:11:02, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.193, 26-Jan-78 16:00:47, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.191, 16-Jan-78 11:02:57, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.190,  5-Jan-78 17:15:11, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.189, 15-Dec-77 12:08:17, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.188, 15-Dec-77 08:28:05, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.187, 14-Dec-77 15:54:49, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.186, 14-Dec-77 15:19:02, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.185, 14-Dec-77 14:11:48, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.184, 12-Dec-77 17:08:55, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.183, 12-Dec-77 16:37:25, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.182, 12-Dec-77 15:57:08, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.181, 12-Dec-77 14:57:30, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.180,  9-Dec-77 11:45:27, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.179,  8-Dec-77 17:02:24, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.178,  8-Dec-77 12:00:45, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.177,  8-Dec-77 11:16:16, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.176,  7-Dec-77 17:05:19, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.175,  6-Dec-77 16:48:20, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.174,  6-Dec-77 16:43:12, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.173,  6-Dec-77 16:06:45, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.172,  6-Dec-77 14:09:49, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.171,  6-Dec-77 10:04:52, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.170,  5-Dec-77 14:46:42, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.169,  5-Dec-77 12:51:44, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.168,  2-Dec-77 17:08:15, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.167,  2-Dec-77 12:14:00, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.166,  2-Dec-77 10:39:30, EDIT BY GUNN
;<GUNN>DYMODS.MAC.1, 30-Nov-77 09:09:51, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.164, 29-Nov-77 14:55:17, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.163, 29-Nov-77 14:23:28, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.162, 29-Nov-77 12:54:55, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.161, 28-Nov-77 21:26:47, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.160, 28-Nov-77 20:02:07, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.159, 28-Nov-77 19:54:33, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.158, 28-Nov-77 19:34:26, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.157, 28-Nov-77 19:08:10, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.156, 28-Nov-77 18:48:30, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.155, 28-Nov-77 14:59:24, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.154, 10-Nov-77 11:36:13, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.153, 10-Nov-77 10:57:31, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.152,  9-Nov-77 17:06:50, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.151,  9-Nov-77 16:40:46, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.150,  9-Nov-77 14:43:14, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.149,  9-Nov-77 11:09:58, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.148,  8-Nov-77 17:08:12, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.147,  8-Nov-77 11:25:27, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.146,  1-Nov-77 09:43:46, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.145, 26-Oct-77 16:05:32, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.144, 25-Oct-77 10:06:00, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.143, 25-Oct-77 09:12:29, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.142, 24-Oct-77 16:08:39, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.141, 14-Oct-77 12:10:10, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.140, 11-Oct-77 11:30:22, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.139, 11-Oct-77 10:53:25, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.138, 11-Oct-77 09:49:24, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.137, 11-Oct-77 09:15:37, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.136,  6-Oct-77 12:33:11, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.135,  6-Oct-77 11:58:52, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.134,  4-Oct-77 09:37:33, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.132, 26-Sep-77 11:40:21, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.131, 26-Sep-77 11:05:51, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.130, 21-Sep-77 12:41:29, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.129, 21-Sep-77 11:40:48, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.128, 20-Sep-77 12:32:13, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.127, 19-Sep-77 11:55:11, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.126, 16-Sep-77 11:34:53, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.125, 16-Sep-77 10:35:12, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.124, 16-Sep-77 09:53:26, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.123, 15-Sep-77 11:39:52, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.122, 15-Sep-77 10:19:47, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.121, 15-Sep-77 08:59:19, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.120, 14-Sep-77 17:08:28, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.119, 14-Sep-77 15:14:12, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.118, 12-Sep-77 13:09:54, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.117, 12-Sep-77 11:39:34, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.116, 12-Sep-77 11:26:45, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.115, 12-Sep-77 11:16:50, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.114, 12-Sep-77 10:45:26, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.113,  9-Sep-77 13:46:32, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.112,  9-Sep-77 13:25:00, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.111,  9-Sep-77 10:23:17, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.110,  9-Sep-77 10:07:03, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.109,  8-Sep-77 12:24:24, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.108,  7-Sep-77 17:05:40, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.107,  7-Sep-77 13:37:21, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.106,  2-Sep-77 09:32:59, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.105,  1-Sep-77 17:05:16, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.104,  1-Sep-77 16:43:08, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.103,  1-Sep-77 16:37:03, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.102,  1-Sep-77 12:45:05, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.101, 31-Aug-77 17:08:20, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.100, 23-Aug-77 15:51:20, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.99, 19-Aug-77 16:30:55, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.98, 19-Aug-77 14:51:03, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.97, 17-Aug-77 10:07:14, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.96, 16-Aug-77 00:46:28, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.95, 14-Aug-77 21:58:24, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.94, 11-Aug-77 00:17:21, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.93, 11-Aug-77 00:10:54, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.92, 10-Aug-77 10:43:18, EDIT BY GUNN
;<GUNN.DYNETS>DYMODS.MAC.91, 10-Aug-77 10:01:40, EDIT BY GUNN
;<GUNN>DYMODS.MAC.90,  8-Aug-77 23:26:16, EDIT BY GUNN
;<GUNN>DYMODS.MAC.89,  8-Aug-77 16:40:45, EDIT BY GUNN
;<GUNN>DYMODS.MAC.88,  8-Aug-77 15:04:46, EDIT BY GUNN
;<GUNN>DYMODS.MAC.87,  8-Aug-77 14:46:00, EDIT BY GUNN
;<GUNN>DYMODS.MAC.86,  8-Aug-77 09:57:45, EDIT BY GUNN
;<GUNN>DYMODS.MAC.85,  6-Aug-77 19:56:40, EDIT BY GUNN
;<GUNN>DYMODS.MAC.84,  6-Aug-77 19:34:56, EDIT BY GUNN
;<GUNN>DYMODS.MAC.83,  6-Aug-77 18:41:21, EDIT BY GUNN
;<GUNN>DYMODS.MAC.82,  6-Aug-77 18:33:29, EDIT BY GUNN
;<GUNN>DYMODS.MAC.81,  6-Aug-77 18:31:37, EDIT BY GUNN
;<GUNN>DYMODS.MAC.80,  6-Aug-77 18:15:00, EDIT BY GUNN
;<GUNN>DYMODS.MAC.79,  5-Aug-77 16:23:24, EDIT BY GUNN
;<GUNN>DYMODS.MAC.78,  5-Aug-77 13:59:48, EDIT BY GUNN
;<GUNN>DYMODS.MAC.77,  5-Aug-77 10:29:39, EDIT BY GUNN
;<GUNN>DYMODS.MAC.76,  3-Aug-77 14:06:45, EDIT BY GUNN
;<GUNN>DYMODS.MAC.75,  3-Aug-77 09:11:31, EDIT BY GUNN
;<GUNN>DYMODS.MAC.74,  2-Aug-77 17:01:34, EDIT BY GUNN
;<GUNN>DYMODS.MAC.73,  2-Aug-77 15:41:37, EDIT BY GUNN
;<GUNN>DYMODS.MAC.72,  2-Aug-77 11:41:32, EDIT BY GUNN
;<GUNN>DYMODS.MAC.71,  1-Aug-77 16:53:44, EDIT BY GUNN
;<GUNN>DYMODS.MAC.70,  1-Aug-77 12:37:16, EDIT BY GUNN
;<GUNN>DYMODS.MAC.69,  1-Aug-77 11:35:45, EDIT BY GUNN
;<GUNN>DYMODS.MAC.68,  1-Aug-77 11:30:38, EDIT BY GUNN
;<GUNN>DYMODS.MAC.67, 29-Jul-77 12:43:15, EDIT BY GUNN
;<GUNN>DYMODS.MAC.66, 29-Jul-77 11:57:49, EDIT BY GUNN
;<GUNN>DYMODS.MAC.65, 29-Jul-77 10:14:59, EDIT BY GUNN
;<GUNN>DYMODS.MAC.64, 29-Jul-77 09:28:40, EDIT BY GUNN
;<GUNN>DYMODS.MAC.63, 26-Jul-77 15:18:00, EDIT BY GUNN
;<GUNN>DYMODS.MAC.62, 26-Jul-77 12:15:47, EDIT BY GUNN
;<GUNN>DYMODS.MAC.61, 26-Jul-77 10:40:04, EDIT BY GUNN
;<GUNN>DYMODS.MAC.60, 25-Jul-77 14:42:26, EDIT BY GUNN
;<GUNN>DYMODS.MAC.59, 25-Jul-77 12:31:25, EDIT BY GUNN
;<GUNN>DYMODS.MAC.58, 25-Jul-77 11:30:33, EDIT BY GUNN
;<GUNN>DYMODS.MAC.57, 25-Jul-77 11:02:53, EDIT BY GUNN
;<GUNN>DYMODS.MAC.56, 22-Jul-77 16:40:59, EDIT BY GUNN
;<GUNN>DYMODS.MAC.55, 22-Jul-77 15:07:16, EDIT BY GUNN
;<GUNN>DYMODS.MAC.54, 22-Jul-77 14:39:30, EDIT BY GUNN
;<GUNN>DYMODS.MAC.53, 21-Jul-77 16:53:50, EDIT BY GUNN
;<GUNN>DYMODS.MAC.52, 21-Jul-77 14:44:20, EDIT BY GUNN
;<GUNN>DYMODS.MAC.50, 20-Jul-77 23:19:02, EDIT BY GUNN
;<GUNN>DYMODS.MAC.48, 20-Jul-77 16:42:59, EDIT BY GUNN
;<GUNN>DYMODS.MAC.46, 19-Jul-77 14:50:04, EDIT BY GUNN
;<GUNN>DYMODS.MAC.45, 18-Jul-77 12:17:43, EDIT BY GUNN
;<GUNN>DYMODS.MAC.44, 18-Jul-77 11:58:25, EDIT BY GUNN
;<GUNN>DYMODS.MAC.43, 13-Jul-77 17:02:38, EDIT BY GUNN
;<GUNN>DYMODS.MAC.42, 13-Jul-77 09:04:19, EDIT BY GUNN
;<GUNN>DYMODS.MAC.41, 12-Jul-77 15:33:35, EDIT BY GUNN
;<GUNN>DYMODS.MAC.40, 12-Jul-77 15:29:36, EDIT BY GUNN
;<GUNN>DYMODS.MAC.39, 11-Jul-77 10:07:08, EDIT BY GUNN
;<GUNN>DYMODS.MAC.38, 11-Jul-77 09:59:11, EDIT BY GUNN
;<GUNN>DYMODS.MAC.37,  8-Jul-77 13:16:46, EDIT BY GUNN
;<GUNN>DYMODS.MAC.36,  7-Jul-77 16:07:57, EDIT BY GUNN
;<GUNN>DYMODS.MAC.35,  7-Jul-77 15:39:07, EDIT BY GUNN
;<GUNN>DYMODS.MAC.33,  6-Jul-77 15:07:59, EDIT BY GUNN
;<GUNN>DYMODS.MAC.31,  6-Jul-77 09:18:45, EDIT BY GUNN
;<GUNN>DYMODS.MAC.30, 28-Jun-77 14:42:55, EDIT BY GUNN
;<GUNN>DYMODS.MAC.29, 28-Jun-77 14:32:41, EDIT BY GUNN
;<GUNN>DYMODS.MAC.26, 24-Jun-77 16:24:31, EDIT BY GUNN
;<GUNN>DYMODS.MAC.25, 24-Jun-77 12:40:58, EDIT BY GUNN
;<GUNN>DYMODS.MAC.22, 23-Jun-77 15:30:57, EDIT BY GUNN
;<GUNN>DYMODS.MAC.21, 22-Jun-77 09:38:17, EDIT BY GUNN
;<GUNN>DYMODS.MAC.20, 22-Jun-77 09:29:30, EDIT BY GUNN
;<GUNN>DYMODS.MAC.19, 22-Jun-77 09:15:12, EDIT BY GUNN
;<GUNN>DYMODS.MAC.18, 21-Jun-77 15:55:29, EDIT BY GUNN
;<GUNN>DYMODS.MAC.17, 21-Jun-77 15:11:43, EDIT BY GUNN
;<GUNN>DYMODS.MAC.16, 21-Jun-77 12:34:18, EDIT BY GUNN
;<GUNN>DYMODS.MAC.15, 21-Jun-77 10:48:09, EDIT BY GUNN
;<GUNN>DYMODS.MAC.14, 21-Jun-77 08:44:38, EDIT BY GUNN
;<GUNN>DYMODS.MAC.13, 20-Jun-77 15:35:00, EDIT BY GUNN
;<GUNN>DYMODS.MAC.12, 17-Jun-77 16:48:10, EDIT BY GUNN
;<GUNN>DYMODS.MAC.10, 16-Jun-77 10:45:12, EDIT BY GUNN
;<GUNN>DYMODS.MAC.9, 15-Jun-77 14:33:15, EDIT BY GUNN
;<GUNN>DYMODS.MAC.6,  9-Jun-77 20:50:33, EDIT BY GUNN
;<GUNN>DYMODS.MAC.5,  9-Jun-77 20:42:51, EDIT BY GUNN



;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY ONLY BE USED
;  OR COPIED IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE.
;
;COPYRIGHT (C) 1977 BY DIGITAL EQUIPMENT CORPORATION
;
	TITLE DYMODS - DYNAMIC NETWORK EXERCISER MODULES
	SEARCH DYNUNV,MACSYM,MONSYM
	.REQUIRE SYS:MACREL


;******************************************************************************
;********************  ASSEMBLY CONDITIONAL SWITCH FOR DTR ********************
;******************************************************************************

	IFNDEF DTRSW,<DTRSW==0>	; DO NOT INCLUDE CODE FOR DTR

;******************************************************************************
	PAGE
	SUBTTL NETDCL - PERFORM THE DECLARE COMMAND
;
;NETDCL - ROUTINE TO PERFORM DECLARE COMMAND.
; BUILDS NETWORK SERVER CONTROL BLOCK,
; DOES AN OPENF ON THE PROVIDED JFN, ASSIGNS THE OBTAINED LINK TO INTERRUPT
; CHANNEL TO AWAIT A CONNECTION, WHEN INTERRUPT OCCURS, LINK DATA IS READ
; AND STORED IN LCB. IF THE OPTIONAL DATA SUPPLIED IS "A" THE CONNECTION IS
; ACCEPTED, IF "R" THE CONNECTION IS REJECTED. THE LCB IS THEN PLACED ON THE 
;RECEIVE LIST AND ENABLED FOR DATA AVAILABLE INTERRUPTS.
;
;ACCEPTS: T1/ POINTER TO ARGUMENT BLOCK
;
;		ARGUMENT BLOCK FORMAT:
;
;		.DEJFN/ SERVER NAME JFN
;		.DETGT/ POINTER TO SERVER-NAME STRING
;		.DEBYT/ BYTE SIZE
;		.DEREC/ MESSAGE SIZE FOR LINK
;		.DEDEL/ DELAY TO PROVIDE ON ECHO
;
;	CALL NETDCL
;
;RETURNS+1: FAILURE
;	+2: SUCCESS
;
NETDCL::			;ENTRY POINT TO NETDCL
	STKVAR <ARGPTR>		;CREATE VARIABLES
	MOVEM  T1,ARGPTR	;SAVE ARGUMENT POINTER
	MOVE   T1,(T1)		;GET THE JFN FROM ARG LIST
	CALL   MAKSCB		;MAKE A SCB
	JFCL
	MOVEI  SCBPTR,(T2)	;GET POINTER TO THE SCB OBTAINED
	CALL   BLDLCB		;GO BUILD AN LCB
	STOR   SCBPTR,LCBOBJ	;STORE BACK CHAIN POINTER TO SCB
	MOVE   T1,ARGPTR	;GET ARGUMENT BLOCK POINTER
	MOVE   T2,.DEJFN(T1)	;GET THE JFN FROM ARG BLOCK
	STOR   T2,LCBJFN	;STORE IT IN LCB
	SETONE LCBSVR		;TURN ON SERVER BIT
	MOVE   T2,.DEBYT(T1)	;GET BYTE SIZE
	STOR   T2,LCBBSZ	;STOR IT IN LCB
	MOVE   T2,.DEREC(T1)	;GET RECORD SIZE
	STOR   T2,LCBMSZ	;STORE IT IN LCB
	MOVE   T2,.DEDEL(T1)	;GET DELAY VALUE
	STOR   T2,LCBWAT	;STORE AS WAIT VALUE IN LCB
	CALL   OPNLNK		;GO OPEN THE LINK
	JRST   [CALL   ERXLNK		;PRINT ERROR MESSAGE
		RETBAD FRELCB]		;FAILED, RELEASE THE LCB ,RETURN BAD
	LOAD   T1,SCBLCB	;OPENED OK, GET POINTER TO LCB'S THIS SERVER
	STOR   T1,LCBNLP	;MAKE THIS NEW HEAD OF LIST
	STOR   LCBPTR,SCBLCB	;STORE HEAD OF LCB LIST IN SCB
	CALL   PIOFF		;DON'T ALLOW INT'S WHILE TOUCHING CONNECT LIST
	MOVE   T1,CONLST	;GET POINTER TO HEAD OF LIST
	STOR   T1,LCBCHN	;PUT AT HEAD OF LIST
	MOVEM  LCBPTR,CONLST	;POINT TO NEW HEAD OF LIST
	CALL   PION		;TURN INTERRUPT SYSTEM BACK ON
	CALL   STCICS		;SET FOR CONNECT INTERRUPT
	RETBAD ERXLNK		;RETURN BAD
	RETSKP			;DONE, RETURN TO CALLER
	PAGE
	SUBTTL NETEST - ESTABLISH COMMAND EXECUTOR
;
;NETEST - ROUTINE TO DO WORK FOR ESTABLISH COMMAND
;	BUILDS NETWORK TARGET CONTROL BLOCK, IF ONE DOES NOT YET EXIST FOR THIS
;	TARGET.  BUILDS AN LCB FOR THIS LINK.  CHAINS THE LCB OFF THE TCB.
;	OPENS THE LOGICAL LINK.  
;
;ACCEPTS: T1/ POINTER TO ARGUMENT BLOCK
;
;		ARGUMENT BLOCK FORMAT:
;
;		.ESJFN/ TARGET NAME JFN
;		.ESTGT/ POINTER TO TARGET-NAME STRING
;		.ESLKN/ POINTER TO LINK NAME STRING
;		.ESWAT/ WAIT SWITCH VALUE
;		.ESBYT/ BYTE SIZE FOR LINK
;		.ESREC/ MESSAGE LENGTH FOR LINK
;
;	CALL NETEST
;
;RETURNS+1: ALWAYS
;
NETEST::			;ENTRY
	STKVAR <ARGPTR>	;CREATE VARIABLES
	MOVEM  T1,ARGPTR	;SAVE ARGUMENT POINTER
	MOVE   T1,.ESJFN(T1)	;GET THE JFN FROM ARG LIST
	CALL   MAKTCB		;MAKE A TCB
	JFCL			;DO SAME WHETHER NEW OR NOT
	MOVEI  TCBPTR,(T2)	;GET POINTER TO THE TCB OBTAINED
	CALL   BLDLCB		;GO BUILD AN LCB
	SETZRO LCBSVR		;TURN OFF SERVER BIT
	STOR   TCBPTR,LCBOBJ	;STORE BACK CHAIN POINTER TO TCB
	MOVE   T1,ARGPTR	;GET ARGUMENT BLOCK POINTER
	MOVE   T2,.ESJFN(T1)	;GET THE JFN FROM ARG BLOCK
	STOR   T2,LCBJFN	;STORE IT IN LCB
	MOVE   T2,.ESLKN(T1)	;GET POINTER TO LINK NAME STRING
	DMOVE  T2,(T2)		;GET THE LINK NAME
	OPSTRM <DMOVEM T2,>,LCBNAM ;STORE LINK NAME IN LCB
	MOVE   T2,.ESBYT(T1)	;GET THE BYTE SIZE FROM ARG LIST
	STOR   T2,LCBBSZ	;STORE IT IN LCB
	MOVE   T2,.ESREC(T1)	;GET THE RECORD LENGTH
	STOR   T2,LCBMSZ	;STORE IT IN LCB
	SETONE DTRPRT		;MAKE IT PRINT MESSAGES
	MOVE   T1,CONLTT	;GET HEAD OF CONNECT LIST
	MOVEM  LCBPTR,CONLTT	;MAKE THIS THE NEW HEAD
	STOR   T1,LCBCHN	;REST OF LIST BEHIND IT
	CALL   OPNLNK		;GO OPEN THE LINK
	JRST   [LOAD  T1,LCBCHN		;GET NEXT IN CHAIN
		MOVEM  T1,CONLTT	;RESTORE ORIGINAL HEAD OF CHAIN
		CALL   ERXLNK		;GO PRINT ERROR MSG
		RETBAD FRELCB]		;FREE LCB AND RETURN BAD
	CALL   STCICT		;PUT IT ON CONNECT CHAN
	JRST   [LOAD  T1,LCBCHN		;GET NEXT IN CHAIN
		MOVEM  T1,CONLTT	;RESTORE ORIGINAL HEAD OF CHAIN
		CALL   ERXLNK		;GO PRINT ERROR MSG
		RETBAD FRELCB]		;FREE LCB AND RETURN BAD
	MOVE   T1,ARGPTR	;GET ARGUMENT BLOCK POINTER
	MOVE   T1,.ESWAT(T1)	;SLEEP FOR THE WAIT TIME SPECIFIED
	CALL   SLEEP		;GO WAIT FOR CONNECTION TO COMPLETE
;
;HERE WE WOKE UP, BUT MUST CHECK TO SEE IF WE REALLY GOT CONNECTED
; OR IF WE WOKE UP DUE TO SOMTHING ELSE, I.E., TIME EXPIRED ??
;
	CALL   RLSLNK		;GO READ CURRENT LINK STATUS
	JRST   [LOAD  T1,LCBCHN		;GET NEXT IN CHAIN
		MOVEM  T1,CONLTT	;RESTORE ORIGINAL HEAD OF CHAIN
		CALL   ERXLNK		;GO PRINT ERROR MSG
		RETBAD FRELCB]		;FREE LCB AND RETURN BAD
	LOAD   T1,LCBSTS	;GET THE STATUS
	TXNN   T1,MO%CON	;DID WE GET CONNECTED ??
	JRST   [LOAD  T1,LCBCHN		;NO, GET NEXT IN CHAIN
		MOVEM  T1,CONLTT	;RESTORE ORIGINAL HEAD OF CHAIN
		CALL   FRELCB		;GO RELEASE THE LCB
		SKIPE  TIMOUT		;TIME EXPIRED ??
		PRTERR (<NOT CONNECTED, WAIT TIME EXPIRED>,<RET>) ;YES, PRINT MESSAGE
		PRTERR (<NOT CONNECTED, LINK REJECTED>)
		RET]			;RETURN BAD
	LOAD   T1,TCBLCB	;GET POINTER TO LCB'S FOR THIS TARGET
	STOR   T1,LCBNLP	;MAKE THIS NEW HEAD OF LIST
	STOR   LCBPTR,TCBLCB	;STORE POINTER TO LCB IN TCB
	RETSKP			;DONE, RETURN TO CALLER
	PAGE
	SUBTTL NETRCV - RECEIVE COMMAND EXECUTOR
;
;NETRCV - ROUTINE TO PERFORM RECEIVE COMMAND.
; BUILDS NETWORK TARGET CONTROL BLOCK, IF A MESSAGE FILE WAS SPECIFIED,
; THE FILE IS OPENED FOR WRITE ACCESS. DOES AN OPENF ON THE PROVIDED 
; LINK JFN, ASSIGNS THE OBTAINED LINK TO THE
; DATA AVAILABLE AND INTERRUPT MESSAGE INTERRUPT CHANNEL TO AWAIT A
; MESSAGE, WHEN INTERRUPT OCCURS, DATA IS READ AND STORED IN BUFFER.
; IF A MESSAGE LOG WAS SPECIFIED, THE RECEIVED DATA IS WRITTEN TO THE
; MESSAGE LOG FILE.
;
;ACCEPTS: T1/ POINTER TO ARGUMENT BLOCK
;
;		ARGUMENT BLOCK FORMAT:
;
;		.REJFN/ TARGET NAME JFN
;		.RETGT/ POINTER TO TARGET-NAME STRING
;		.RELKN/ POINTER TO LINK NAME BUFFER
;		.REMLN/ MESSAGE LOG JFN
;		.RETOU/ TIMEOUT VALUE
;		.REREC/ MESSAGE LENGTH FOR LINK
;		.REBYT/ BYTE SIZE
;
;	NOTE: IF WORD AT .REJFN IS ZERO A RECEIVE IS DONE FOR ALL CURRENTLY
;		ESTABLISHED LINKS
;	      IF BYTE SIZE IS ZERO, THE BYTE SIZE IN THE LCB IS USED
;	      IF MESSAGE LOG JFN IS ZERO, A LOG OF THE FORM 
;		DSK:HOST-OBJECT-DESCRIPTOR.LOG  IS USED
;
;	CALL NETRCV
;
;RETURNS+1: FAILURE
;	+2: SUCCESS
;
NETRCV::			;ENTRY POINT TO NETRCV
	TRVAR  <ARGPTR>		;CREATE VARIABLE
	MOVEM  T1,ARGPTR	;SAVE ARGUMENT POINTER
	MOVE   T1,.REJFN(T1)	;GET THE LINK JFN FROM ARG LIST
	JUMPE  T1,NETRC2	;IF NO LINK JFN, DO FOR ALL ESTABLISHED LINKS
	CALL   FNDTCB		;GO FIND THE TARGET, MUST EXIST
	PRTERR (<LINK NOT PREVIOUSLY ESTABLISHED>,RET) ;ERROR
	RLJFN			;RELEASE IT, DON'T NEED
	 JSRET (<RLJFN FAILED>)
NETRC1:				;HERE WHEN PREVIOUS ESTABLISH COMMAND GIVEN
	MOVEI  TCBPTR,(T2)	;GET POINTER TO THE TCB OBTAINED
	LOAD   LCBPTR,TCBLCB	;POINT TO FIRST LCB THIS TARGET
	SKIPN  LCBPTR		;ANY LINKS ESTABLISHED ?
	PRTERR (<NO LINKS ESTABLISHED>,<RET>) ;MUST BE AT LEAST ONE
	LOAD   T3,LCBBSZ	;GET BYTE SIZE OF FIRST LCB
	MOVE   T1,ARGPTR	;POINT TO ARGUMENT BLOCK
	MOVEM  T3,.REBYT(T1)	;MAKE IT BYTE SIZE FOR THIS COMMAND
NETR11:				;HERE FOR NEXT LCB
	CALL   NETRC4		;GO DO COMMON STUFF
	LOAD   LCBPTR,LCBNLP	;POINT TO NEXT LCB THIS TARGET
	JUMPN  LCBPTR,NETR11	;IF NOT END OF LIST, GO DO FOR NEXT LCB
	RETSKP			;ELSE, DONE, RETURN


	PAGE


NETRC2:				;HERE TO DO RECEIVE FOR ALL ESTABLISHED LINKS
	MOVE   TCBPTR,TCBLST	;POINT TO FIRST TCB
NETR21:				;HERE TO DO FOR NEXT TCB
	CALL   NETRC1		;DO FOR ALL LINKS TO THIS TARGET
	HALTF			;ALWAYS RETURNS +2
	LOAD   TCBPTR,TCBCHN	;POINT TO NEXT TCB
	JUMPN  TCBPTR,NETR21	;IF NOT END OF LIST, GO DO FOR NEXT TCB
	RETSKP			;DONE, RETURN






NETRC3:				;HERE IF NO PREVIOUS ESTABLISH FOR THIS TARGET
	MOVEI  TCBPTR,(T2)	;GET POINTER TO THE TCB OBTAINED
	CALL   BLDLCB		;GO BUILD AN LCB
	LOAD   T1,TCBLCB	;GET POINTER TO LCB'S THIS TARGET
	STOR   T1,LCBNLP	;MAKE THIS NEW HEAD OF LIST
	STOR   LCBPTR,TCBLCB	;STORE HEAD OF LCB LIST IN TCB
	MOVE   T1,ARGPTR	;GET ARGUMENT BLOCK POINTER
	MOVE   T2,.REJFN(T1)	;GET THE JFN FROM ARG BLOCK
	STOR   T2,LCBJFN	;STORE IT IN LCB
	STOR   TCBPTR,LCBOBJ	;STORE BACK CHAIN POINTER TO TCB
	LOAD   T2,LCBBSZ	;GET BYTE SIZE IN LCB
	SKIPE  .REBYT(T1)	;BYTE SIZE GIVEN IN COMMAND ?
	MOVE   T2,.REBYT(T1)	;YES, GET BYTE SIZE
	STOR   T2,LCBBSZ	;STORE IT IN LCB
	MOVE   T2,.RELKN(T1)	;GET POINTER TO LINK NAME STRING
	DMOVE  T2,(T2)		;GET THE LINK NAME
	OPSTRM <DMOVEM T2,>,LCBNAM ;STORE LINK NAME IN LCB
	CALL   OPNLNK		;GO OPEN THE LINK
	RETBAD ERXLNK		;FAILED, PRINT LINK ERROR, RETURN BAD
	CALL   NETRC4		;DO COMMON STUFF
	RETSKP			;DONE, RETURN


	PAGE


NETRC4:				;HERE TO DO STUFF COMMON TO EACH LINK
	MOVE   T2,ARGPTR	;GET ARGUMENT BLOCK POINTER
	LOAD   T1,LCBBSZ	;GET THE BYTE SIZE FROM LCB
	SETZRO LCBNER		;CLEAR NEXT EXPECTED RECEIVE COUNT
	SETZRO LCBRCV		;CLEAR RECEIVE MESSAGE COUNT
	SETZRO LCBIRC		;CLEAR INTERRUPT RECEIVE COUNT
	SETZRO LCBRMQ		;CLEAR POINTER TO RECEIVE BUFFER
	MOVE   T1,.REMLN(T2)	;GET JFN FOR MESSAGE LOG FILE
	TLNN   T1,.RHALF	;IS IT STRING POINTER ?
	JSP    P5,NETRC5	;NO, POSSIBLY JFN, GO CHECK
	TRNN   T1,.RHALF	;IS IT GOOD POINTER OR JFN ?
	PRTERR (<BAD MESSAGE LOG JFN>,<RET>) ;NO, TELL USER
	STOR   T1,LCBMLN	;STORE MESSAGE LOG JFN/POINTER IN LCB
	CALL   PIOFF		;DON'T ALLOW INT'S WHILE TOUCHING RECEIVE LIST
	MOVE   T1,RCVLTT	;GET POINTER TO HEAD OF LIST
	STOR   T1,LCBCHN	;PUT AT HEAD OF LIST
	MOVEM  LCBPTR,RCVLTT	;POINT TO NEW HEAD OF LIST
	CALL   PION		;TURN INTERRUPT SYSTEM BACK ON
	CALL   STDACT		;SET FOR DATA AVAILABLE INTERRUPT
	RETBAD ERXLNK		;FAILED, PRINT LINK ERROR, RETURN BAD
	CALL   STIMCT		;SET FOR INTERRUPT MESSAGE INTERRUPT
	RETBAD ERXLNK		;FAILED, PRINT LINK ERROR, RETURN BAD
	RET			;DONE, RETURN TO CALLER


	PAGE


NETRC5:				;HERE TO CHECK FOR MESSAGE LOG JFN,
				; GET ONE IF NEEDED, AND OPEN FILE,
				;T1 HAS JFN AT ENTRY
	TRNN   T1,.RHALF	;IS IT GOOD JFN ?
	JRST   [MOVEI  T1,GJFBLK	;NO, GO GET ONE
		CALL   CLRGJF		;CLEAR GTJFN ARG BLOCK
		MOVEI  T1,GJFBLK	;GET ADDRESS OF GTJFN BLOCK
		MOVX   T2,GJ%FOU	;NEW FILE
		MOVEM  T2,.GJGEN(T1)	;PUT IN GTJFN ARG BLOCK
		MOVE   T2,[.NULIO,,.NULIO] ;NO I/O
		MOVEM  T2,.GJSRC(T1)
		HRROI  T2,[ASCIZ/LOG/]	;LOG FILE TYPE
		MOVEM  T2,.GJEXT(T1)
		HRROI  T2,2(TCBPTR)	;POINT TO HOST-OBJECT-DESCRIPTOR
		GTJFN			;GET JFN FOR LOG
		 JSRET (<GTJFN FOR LOG FILE FAILED>)
		MOVE   T2,ARGPTR	;POINT TO ARG BLOCK
		JRST   .+1]		;RETURN
	MOVE   T2,ARGPTR	;POINT TO ARGUMENT BLOCK
	MOVE   T2,.REBYT(T2)	;GET BYTE SIZE
	LSH    T2,<^D35-POS(OF%BSZ)> ;PUT IN OF%BSZ FIELD
	TXO    T2,OF%WR		;WRITE ACCESS
	OPENF			;OPEN THE FILE
	 JSRET (<OPENF FOR LOG FAILED>)
	HRLI   T1,(FLD(.FBBYV,CF%DSP)) ;CHANGE THE RETENTION COUNT
	MOVX   T2,FB%RET	;FIELD TO CHANGE
	MOVX   T3,^D63		;MAKE IT MAXIMUM
	CHFDB
	HRLI   T1,0		;CLEAR OPENF FLAGS IN LEFT HALF
	TXO    T1,CO%NRJ	;INDICATE KEEP JFN
	CLOSF			;CLOSE TO MAKE FILE EXIST
	 JSRET (<CLOSF FOR LOG FILE FAILED>)
	HRLI   T1,0		;CLEAR CLOSF FLAGS IN LEFT HALF
	MOVE   T2,ARGPTR	;POINT TO ARGUMENT BLOCK
	MOVE   T2,.REBYT(T2)	;GET BYTE SIZE
	LSH    T2,<^D35-POS(OF%BSZ)> ;PUT IN OF%BSZ
	TXO    T2,OF%WR		;WRITE ACCESS
	OPENF			;OPEN IT AGAIN
	 JSRET (<OPENF FOR LOG FILE FAILED>)
	JRST   (P5)		;DONE, RETURN
	PAGE
	SUBTTL NETLIS - LISTEN COMMAND EXECUTOR
;
;NETLIS - ROUTINE TO PERFORM THE LISTEN COMMAND
;
;	NOT CURRENTLY IMPLEMENTED
;
NETLIS::			;ENTRY
	
	HRROI  T1,[ASCIZ/% DYNETS: FUNCTION NOT CURRENTLY IMPLEMENTED/]
	CALL   SNDMSG
	RET			;DONE, RETURN
	PAGE
	SUBTTL NETSND - EXECUTES THE SEND COMMAND
;
;	CALLED BY COMMAND MAINLINE TO DO THE WORK FOR SEND COMMAND
;
;ACCEPTS: T1/ POINTER TO ARGUMENT BLOCK
;
;	ARGUMENT BLOCK CONTAINS ALL INFO OBTAINED DURING PARSE OF THE
;	SEND COMMAND. ITS FORMAT IS :
;
;	.SEJFN/ TARGET-NAME JFN
;	.SETGT/ POINTER TO TARGET-NAME STRING
;	.SELKN/ POINTER TO LINK NAME STRING
;	.SEMFN/ JFN OF MESSAGE FILE OR STRING POINTER TO MESSAGE
;	.SETIM/ TIMES SWITCH VALUE
;	.SEDEL/ DELAY SWITCH VALUE
;	.SEBYT/ BYTE SIZE FOR LINK
;	.SEREC/ MESSAGE LENGTH FOR LINK
;	.SEINT/ INTERRUPT MESSAGE FREQUENCY
;
;
NETSND::			;ENTRY POINT OF NETSND
	TRVAR  <ARGPTR,BUFPTR,BUFSIZ,BUFBYT,FILDON,INTCNT> ;VARIABLES
	MOVEM  T1,ARGPTR	;STORE ARG PTR
	SETZM  FILDON		;CLEAR FILE DONE FLAG
	MOVE   T2,.SEINT(T1)	;GET THE INTERRUPT COUNT VALUE
	MOVEM  T2,INTCNT	;STORE IT IN COUNTER VARIABLE
	MOVE   T1,.SEJFN(T1)	;GET THE TARGET-NAME JFN
	JUMPE  T1,NETSN2	;IF TARGET-NAME NOT SPECIFIED SEND TO ALL
	CALL   FNDTCB		;GO FIND THE TARGET, MUST EXIST
	PRTERR (<LINK NOT PREVIOUSLY ESTABLISHED>,RET) ;ERROR
	RLJFN			;RELEASE IT, DON'T NEED
	 JSRET (<RLJFN FAILED>)
NETSN1:				;HERE WHEN PREVIOUS ESTABLISH COMMAND GIVEN
	MOVEI  TCBPTR,(T2)	;GET POINTER TO TCB
	LOAD   LCBPTR,TCBLCB	;POINT TO FIRST LCB FOR THIS TCB
	SKIPN  LCBPTR		;ANY LINKS ESTABLISHED ?
	PRTERR (<NO LINKS ESTABLISHED>,<RET>) ;NO, TELL USER & RETURN
	MOVE   T1,ARGPTR	;POINT TO ARGUMENT BLOCK
	LOAD   T2,LCBBSZ	;GET BYTE SIZE OF FIRST LCB
	MOVEM  T2,.SEBYT(T1)	;STORE AS BYTE SIZE FOR THIS COMMAND
	LOAD   T2,LCBMSZ	;GET MESSAGE SIZE FROM LCB
	MOVEM  T2,.SEREC(T1)	;STORE AS RECORD SIZE
NETS01:				;LOOP FOR EACH LCB THIS TCB
	MOVE   T2,.SETIM(T1)	;GET TIMES SWITCH VALUE FROM ARG BLOCK
	STOR   T2,LCBNMS	;STORE NUMBER MESSAGES TO SEND IN LCB
	MOVE   T2,.SEDEL(T1)	;GET DELAY SWITCH VALUE FROM ARG BLOCK
	STOR   T2,LCBWAT	;STORE IN LCB
	LOAD   LCBPTR,LCBNLP	;POINT TO NEXT LCB THIS TARGET
	JUMPN  LCBPTR,NETS01	;IF NOT END OF CHAIN, GO DO FOR NEXT LCB
	LOAD   LCBPTR,TCBLCB	;POINT TO FIRST LCB FOR THIS TCB
	CALL   NETSN5		;GO SET UP SEND BUFFER
	RET			;MAKE BAD RETURN
NETS11:				;HERE TO DO FOR REST OF LINKS THIS TARGET
	CALL   NETSN4		;GO DO COMMON STUFF TO SEND ON LINK
	RET			;FAILED, MAKE BAD RETURN
	LOAD   LCBPTR,LCBNLP	;POINT TO NEXT LCB THIS TARGET
	JUMPN  LCBPTR,NETS11	;IF NOT END OF CHAIN, GO DO FOR NEXT LCB
	SKIPE  FILDON		;GOT ALL FROM FILE ?
	RETBAD NETS21		;YES, WAIT FOR RECEIVES TO COMPLETE AND RETURN
	JSP    P5,NETSN7	;NO, GO GET MORE INPUT
	LOAD   LCBPTR,TCBLCB	;POINT TO FIRST LCB FOR THIS TCB
	JRST   NETS11		;SEND IT ALL LINKS THIS TARGET


NETS21:				;HERE TO WAIT FOR RECEIVES TO COMPLETE
	SETOI  T1,-1		;WAIT FOREVER
	CALL   SLEEP		;GO TO SLEEP
	LOAD   LCBPTR,TCBLCB	;POINT TO FIRST LCB
NETS31:				;HERE TO CHECK NEXT LCB
	LOAD   T2,LCBRCV	;GET RECEIVE COUNT
	LOAD   T3,LCBSND	;GET SEND COUNT
	CAME   T2,T3		;EQUAL ??
	JRST   NETS21		;NO, GO WAIT SOME MORE
	LOAD   LCBPTR,LCBNLP	;YES, POINT TO NEXT LCB THIS TARGET
	JUMPN  LCBPTR,NETS31	;IF NOT END OF CHAIN, GO CHECK THIS LCB
	RETSKP			;END OF CHAIN, DONE

	PAGE


NETSN2:				;HERE TO SEND ON ALL LINKS TO ALL TARGETS
	MOVE   TCBPTR,TCBLST	;POINT TO FIRST TCB IN CHAIN
	LOAD   LCBPTR,TCBLCB	;POINT TO FIRST LCB FOR THIS TCB
	MOVE   T1,ARGPTR	;POINT TO ARGUMENT BLOCK
	LOAD   T2,LCBBSZ	;GET BYTE SIZE OF FIRST LCB
	MOVEM  T2,.SEBYT(T1)	;STORE AS BYTE SIZE FOR THIS COMMAND
	LOAD   T2,LCBMSZ	;GET MESSAGE SIZE FROM LCB
	MOVEM  T2,.SEREC(T1)	;STORE AS RECORD SIZE
NETS02:				;HERE FOR NEXT TCB IN CHAIN
	LOAD   LCBPTR,TCBLCB	;POINT TO FIRST LCB FOR THIS TCB
NETS12:				;LOOP FOR EACH LCB THIS TCB
	MOVE   T2,.SETIM(T1)	;GET TIMES SWITCH VALUE FROM ARG BLOCK
	STOR   T2,LCBNMS	;STORE NUMBER MESSAGES TO SEND IN LCB
	MOVE   T2,.SEDEL(T1)	;GET DELAY SWITCH VALUE FROM ARG BLOCK
	STOR   T2,LCBWAT	;STORE IN LCB
	LOAD   LCBPTR,LCBNLP	;POINT TO NEXT LCB THIS TARGET
	JUMPN  LCBPTR,NETS12	;IF NOT END OF CHAIN, GO DO FOR NEXT LCB
	LOAD   TCBPTR,TCBCHN	;POINT TO NEXT TCB IN CHAIN
	JUMPN  TCBPTR,NETS02	;IF NOT END OF CHAIN, DO FOR NEXT TCB
	MOVE   TCBPTR,TCBLST	;POINT TO FIRST TCB IN CHAIN
	CALL   NETSN5		;GO DO COMMON STUFF TO SET UP SEND BUFFER
	RET			;FAILED, MAKE BAD RETURN
NETS22:				;HERE TO DO REST OF TCB'S IN CHAIN
	LOAD   LCBPTR,TCBLCB	;POINT TO FIRST LCB IN CHAIN
NETS32:				;HERE TO DO FOR REST OF LCB THIS TCB
	CALL   NETSN4		;GO DO COMMON STUFF TO SEND
	RET			;FAILED, MAKE BAD RETURN
	LOAD   LCBPTR,LCBNLP	;POINT TO NEXT LCB THIS TARGET
	JUMPN  LCBPTR,NETS32	;IF NOT END OF CHAIN, GO DO FOR NEXT LCB
	LOAD   TCBPTR,TCBCHN	;POINT TO NEXT TCB IN CHAIN
	JUMPN  TCBPTR,NETS22	;IF NOT END OF CHAIN, DO FOR NEXT TCB
	SKIPE  FILDON		;GOT ALL FROM FILE ?
	RETSKP			;YES, RETURN
	JSP    P5,NETSN7	;GO GET MORE INPUT FROM MESSAGE FILE
	JRST   NETSN2		;AND SEND IT TO ALL LINKS


	PAGE


NETSN3:				;HERE IF TCB WAS A NEW ENTRY
	MOVEI  TCBPTR,(T2)	;GET POINTER TO TCB
	CALL   BLDLCB		;CAN'T BE ANY LCB SO BUILD ONE
	STOR   LCBPTR,TCBLCB	;STORE POINTER TO LCB IN TCB
	MOVE   T1,ARGPTR	;GET ARGUMENT BLOCK POINTER
	MOVE   T2,.SEJFN(T1)	;GET THE JFN FROM ARG BLOCK
	STOR   T2,LCBJFN	;AND STORE IN LCB
	MOVE   T2,.SELKN(T1)	;GET POINTER TO LINK NAME STRING
	DMOVE  T2,(T2)		;GET THE LINK NAME
	OPSTRM <DMOVEM T2,>,LCBNAM ;STORE LINK NAME IN LCB
	MOVE   T2,.SETIM(T1)	;GET TIMES SWITCH VALUE FROM ARG BLOCK
	STOR   T2,LCBNMS	;STORE NUMBER MESSAGES TO SEND IN LCB
	MOVE   T2,.SEDEL(T1)	;GET DELAY SWITCH VALUE FROM ARG BLOCK
	STOR   T2,LCBWAT	;STORE IN LCB
	MOVE   T2,.SEBYT(T1)	;GET BYTE SIZE FROM ARG BLOCK
	STOR   T2,LCBBSZ	;STORE IN LCB
	STOR   (TCBPTR,LCBOBJ)	;STORE BACK POINTER TO TCB
	CALL   OPNLNK		;GO OPEN THE LINK AND FILL IN MORE OF LCB
	RETBAD ERXLNK		;FAILED, PRINT LINK ERROR, RETURN BAD
	CALL   NETSN5		;GO INIT MESSAGE SEND FILE
	RET			;FAILED, MAKE BAD RETURN
NETS13:				;HERE TO SEND NEXT BUFFER
	CALL   NETSN4		;GO DO COMMON STUFF FOR SEND
	RET			;FAILED, MAKE BAD RETURN
	SKIPE  FILDON		;GOT ALL FROM FILE ?
	RETSKP			;YES, RETURN
	JSP    P5,NETSN7	;GO GET MORE FROM MESSAGE FILE
	JRST   NETS13		;AND GO SEND IT ON LINK


	PAGE


NETSN4:				;HERE TO DO COMMON STUFF TO SEND EACH LINK
	MOVE   T1,ARGPTR	;POINT TO ARG BLOCK
	MOVE   T1,.SEDEL(T1)	;GET NUMBER OF SECONDS TO DELAY
	IMULI  T1,^D1000	;MAKE IT MILLISECONDS
	SKIPE  T1		;A DELAY SPECIFIED ?
	DISMS			;YES, DISMISS FOR SPECIFIED TIME
	CALL   RLSLNK		;GET CURRENT LINK STATUS
	RETBAD ERXLNK		;FAILED, PRINT LINK ERROR, RETURN BAD
	LOAD   T2,LCBSTS	;GET THE CURRENT STATUS
	TXNN   T2,MO%CON	;STILL CONNECTED ?
;
;**** WE WANT TO DO SOME FANCIER THING HERE IF THE LINK
; GETS DISCONNECTED ON US WHEN WE DON'T EXPECT IT
;
	PRTERR (<ESTABLISHED LINK NOT NOW CONNECTED>,<RET>) ;NO, TELL USER
	MOVE   T4,BUFPTR	;YES, GET BUFFER POINTER
	STOR   T4,LCBSMQ	;STORE IT IN LCB
	MOVE   T4,BUFBYT	;GET NUMBER OF BYTES TO SEND
	STOR   T4,LCBCSZ	;STORE AS CURRENT MESSAGE SIZE IN LCB
	LOAD   T2,LCBFLG	;GET FLAGS
	MOVE   T1,ARGPTR	;POINT TO ARG BLK
	SKIPE  .SEREC(T1)	;RECORD SIZE ??
	TXO    T2,LCB%LM	;YES, SEND A LOGICAL MESSAGE
	STOR   T2,LCBFLG
	CALL   SNDLNK		;GO SEND THE MESSAGE ON LINK
	RETBAD ERXLNK		;FAILED, PRINT LINK ERROR, RETURN BAD
	LOAD   T1,LCBFLG	;GET LCB FLAG WORD
	TDO    T1,FILDON	;SET FILE DONE FLAG TO CURRENT VALUE
	STOR   T1,LCBFLG	;STORE IT BACK
	SOSE   INTCNT		;TIME TO SEND INTERRUPT MSG ??
	RETSKP			;NO, DONE, RETURN
				;YES, GO SEND IT
	MOVE   T1,STDINT	;GET POINTER TO STANDARD INTERRUPT MSG
	STOR   T1,LCBPIM	;STORE IT IN LCB
	MOVEI  T1,NBIMSG	;GET SIZE OF STANDARD INTERRUPT MSG
	STOR   T1,LCBSZI	;STORE IT IN LCB
	CALL   SIMLNK		;GO SEND ONE
	RETBAD ERXLNK		;FAILED, PRINT LINK ERROR, RETURN BAD
	SETZRO LCBSZI		;CLEAR SIZE 
	SETZRO LCBPIM		;AND POINTER IN LCB
	MOVE   T1,ARGPTR	;ADDRESS THE ARGUMENT BLOCK
	MOVE   T1,.SEINT(T1)	;GET THE INTERRUPT FREQ
	MOVEM  T1,INTCNT	;REFRESH THE COUNTER
	HRRZI  T1,-1		;MINUS ONE TO SLEEP FOREVER
	OPSTRM <SKIPE 0,>,LCBIOC ;IS INTERRUPT MESSAGE OUTSTANDING ?
	CALL   SLEEP		;YES, WAIT FOR ITS ARRIVAL
	RETSKP			;DONE, RETURN


	PAGE


NETSN5:				;HERE TO DO COMMON STUFF TO SET UP SEND BUFFER
				;DO WE HAVE A JFN OR STRING PTR FOR MESSAGE ?
	MOVE   T4,ARGPTR	;GET POINTER TO ARG BLOCK
	MOVE   T1,.SEMFN(T4)	;GET JFN/STRING POINTER
	TLNN   T1,.RHALF	;IS IT JFN OR STRING POINTER ?
	JSP    P5,NETSN6	;IF JFN, GO INITIALIZE FILE
	RET			;BAD RETURN FROM FILE INIT
	TRNN   T1,.RHALF	;IS IT GOOD POINTER OR JFN ?
	PRTERR (<BAD JFN OR POINTER>,<RET>) ;NO, TELL USER/]
	MOVEM  T1,BUFPTR	;STORE POINTER/JFN
	RETSKP			;DONE, RETURN
NETSN6:				;HERE TO OPEN MESSAGE FILE
	MOVE   T1,.SEMFN(T4)	;GET JFN FOR MESSAGE FILE
	MOVE   T2,.SEBYT(T4)	;GET BYTE SIZE
	LSH    T2,<^D35-POS(OF%BSZ)> ;PUT IN OF%BSZ FIELD
	TXO    T2,OF%RD		;READ ACCESS
	OPENF			;OPEN THE MESSAGE FILE
	 JSRET (<OPENF FOR MESSAGE FILE FAILED>)
	CALL   M%ACQP##		;GET A PAGE FOR MESSAGE
	LSH    T1,^D9		;CONVERT PAGE NUMBER TO ADDRESS
	MOVEI  T2,1000		;GET SIZE OF A PAGE
	MOVEM  T2,(T1)		;STORE AS FIRST WORD OF BUFFER
	HRLZ   T2,.SEBYT(T4)	;GET BYTE SIZE
	HLRZ   T3,T2		;SAVE BYTE SIZE IN T3
	LSH    T2,^D6		;MAKE STRING POINTER
	HRRI   T2,(T1)		;STRING POINTER IN T2
	MOVEM  T2,BUFPTR	;SAVE BUFFER STRING POINTER
	MOVEI  T1,^D36		;NUMBER OF BITS IN A WORD
	IDIVM  T1,T3		;FIND NUMBER OF BYTES PER WORD
	MOVEI  T1,1000-1	;NUMBER OF WORDS IN BUFFER FOR DATA
	IMULI  T3,(T1)		;FIND NUMBER OF BYTES IN BUFFER
	SKIPE  .SEREC(T4)	;RECORD SIZE SPECIFIED ??
	MOVE   T3,.SEREC(T4)	;YES, GET IT TO USE INSTEAD
	MOVEM  T3,BUFSIZ	;SAVE NUMBER OF BYTES IN BUFFER
	MOVNI  T3,(T3)		;MAKE NEGATIVE
	MOVE   T1,.SEMFN(T4)	;GET JFN OF MESSAGE FILE
	SETZI  T4,0
	SIN			;GET STRING FROM MESSAGE FILE
	ERJMP  [GTSTS			;CHECK FILE STATUS
		 JSHLT (<GTSTS FAILED>)
		TXNE   T2,GS%EOF	;AT END OF FILE ?
		JRST   [CALL   NETSN8		;YES, GO CLOSE MESSAGE FILE
			MOVX   T1,LCB%DN	;GET DONE FLAG
			MOVEM  T1,FILDON	;SET IN FILE DONE FLAG WORD
			JRST   .+1]		;CONTINUE IN-LINE
		CALL   PRERRJ			;GO PRINT JSYS ERROR MESSAGE
		SKIPA  0,[ASCIZ/COULDN'T READ FROM MESSAGE FILE/]
		RET]
	ADD    T3,BUFSIZ	;COMPUTE NUMBER OF BYTES READ
	MOVEM  T3,BUFBYT	;SAVE BYTES GOTTEN
	MOVE   T1,BUFPTR	;MAKE SURE T1 HAS STRING POINTER
	JRST   1(P5)		;DONE, RETURN +1


	PAGE


NETSN7:				;HERE TO GET MORE INPUT FROM MESSAGE FILE
	MOVE   T4,ARGPTR	;GET POINTER TO ARG BLOCK
	MOVE   T1,.SEMFN(T4)	;GET MESSAGE FILE JFN
	TLNE   T1,.RHALF	;IS IT JFN OR STRING POINTER ?
	RETSKP			;IF NOT JFN RETURN NOW
	MOVE   T2,BUFPTR	;GET POINTER TO SEND BUFFER
	MOVN   T3,BUFSIZ	;GET NEGATIVE OF # BYTES TO GET
	SIN			;FILL THE BUFFER
	 ERJMP [GTSTS			;CHECK FILE STATUS
		 JSHLT (<GTSTS FAILED>)
		TXNE   T2,GS%EOF	;AT END OF FILE ?
		JRST   [CALL   NETSN8		;YES, GO CLOSE MESSAGE FILE
			MOVX   T1,LCB%DN	;GET DONE FLAG
			MOVEM  T1,FILDON	;SET IN FILE DONE FLAG WORD
			JRST   .+1]		;CONTINUE IN-LINE
		CALL   PRERRJ			;GO PRINT JSYS ERROR MESSAGE
		SKIPA  0,[ASCIZ/COULDN'T READ FROM MESSAGE FILE/]
		RET]			;RETURN TO COMMAND LEVEL
	ADD    T3,BUFSIZ	;COMPUTE NUMBER OF BYTES READ
	MOVEM  T3,BUFBYT	;SAVE BYTES GOTTEN
	JRST   (P5)		;RETURN
NETSN8:				;HERE WHEN AT END OF MESSAGE FILE
	CLOSF			;CLOSE THE FILE
	 JSRET (<CLOSF FOR MESSAGE FILE FAILED>)
	RET			;RETURN
	PAGE
	SUBTTL NETINT - NETWORK INTERRUPT MESSAGE ROUTINE
;
;NETINT - PERFORM WORK FOR INTERRUPT COMMAND
;
NETINT::			;ENTRY
	
	HRROI  T1,[ASCIZ/% DYNETS: FUNCTION NOT CURRENTLY IMPLEMENTED/]
	CALL   SNDMSG
	RET			;DONE, RETURN
	PAGE
	SUBTTL NETPUR - PURGE COMMAND EXECUTOR
;
;NETPUR - ROUTINE TO PERFORM THE PURGE COMMAND
;
NETPUR::			;ENTRY
	
	HRROI  T1,[ASCIZ/% DYNETS: FUNCTION NOT CURRENTLY IMPLEMENTED/]
	CALL   SNDMSG
	RET			;DONE, RETURN
	PAGE
	SUBTTL NETDIS - DISESTABLISH COMMAND EXECUTOR
;
;NETDIS - ROUTINE TO PERFORM THE DISESTABLISH COMMAND
;
;ACCEPTS: T1/ POINTER TO ARGUMENT BLOCK
;
;	CALL NETDIS
;
;RETURNS+1: FAILURE
;	+2: SUCCESS
;
NETDIS::			;ENTRY
	TRVAR  <ARGPTR>		;CREATE VARIABLE
	MOVEM  T1,ARGPTR	;SAVE ARGUMENT POINTER
	MOVE   T1,.DIJFN(T1)	;GET THE LINK JFN FROM ARG LIST
	JUMPE  T1,NETDI2	;IF NO LINK JFN, DO FOR ALL ESTABLISHED LINKS
	CALL   FNDTCB		;GO FIND THE TARGET, MUST EXIST
	PRTERR (<LINK NOT PREVIOUSLY ESTABLISHED>,RET) ;ERROR
	RLJFN			;RELEASE IT, DON'T NEED
	 JSRET (<RLJFN FAILED>)
NETDI1:				;HERE WHEN PREVIOUS ESTABLISH COMMAND GIVEN
	MOVEI  TCBPTR,(T2)	;GET POINTER TO THE TCB OBTAINED
	LOAD   LCBPTR,TCBLCB	;POINT TO FIRST LCB THIS TARGET
	SKIPN  LCBPTR		;ANY LINKS ESTABLISHED ?
	PRTERR (<NO LINKS ESTABLISHED>,<RET>) ;MUST BE AT LEAST ONE
NETD11:				;HERE FOR NEXT LCB
	LOAD   T1,LCBNLP	;GET POINTER TO NEXT LCB FOR TARGET
	STOR   T1,TCBLCB	;MAKE HEAD OF CHAIN
	CALL   NETDI4		;GO DO COMMON STUFF
	JUMPN  LCBPTR,NETD11	;IF NOT END OF LIST, GO DO FOR NEXT LCB
	RETSKP			;ELSE, DONE, RETURN


NETDI2:	PRTERR (<NOT CURRENTLY IMPLEMENTED>,<HALTF>)
	JRST .-1		;CAN'T CONTINUE


	PAGE

NETDI4:				;HERE TO DISESTABLISH EACH LINK
	SETONE LCBRJF		;SET FLAG TO KEEP JFN
	CALL   CLZLNK
	RETBAD ERXLNK		;FAILED
	SETZRO LCBRJF		;CLEAR FLAG
	LOAD   T1,LCBNLP	;GET NEXT LINK THIS OBJECT
	PUSH   P,T1		;SAVE IT
	CALL   PIOFF		;DON'T ALLOW INTERRUPTS
	MOVEI  T1,RCVLTT	;GET ADDRESS OF RECEIVE LIST
	CALL   DELLST		;GO DELETE IT
	MOVEI  T1,CONLTT	;DELETE FROM CONNECT LIST
	CALL   DELLST
	CALL   PION		;TURN ON INTERRUPT SYSTEM
	CALL   FRELCB		;GO FREE THE STORAGE
	POP    P,LCBPTR		;RESTORE NEXT LINK LCB
	RET

	PAGE
	SUBTTL NETSET - SET COMMAND EXECUTOR
;
;NETSET - ROUTINE TO PERFORM THE SET COMMAND
;
NETSET::			;ENTRY
	
	HRROI  T1,[ASCIZ/% DYNETS: FUNCTION NOT CURRENTLY IMPLEMENTED/]
	CALL   SNDMSG
	RET			;DONE, RETURN
	PAGE
	SUBTTL NETCLZ - NETWORK CLOSE SUBROUTINE
;
;NETCLZ - DOES A SYNCHRONOUS DISCONNECT ON A SPECIFIED LOGICAL LINK
;
NETCLZ::			;ENTRY POINT OF NETCLZ
	
	HRROI  T1,[ASCIZ/% DYNETS: FUNCTION NOT CURRENTLY IMPLEMENTED/]
	CALL   SNDMSG
	RET			;DONE, RETURN TO CALLER
	PAGE
	SUBTTL COINSH - CONNECT INTERRUPT HANDLER FOR SERVER LINKS
;
;COINSH - ROUTINE TO HANDLE SOFTWARE INTERRUPTS WHEN CONNECTION IS ATTEMPTED
; TO THE DECLARED SERVER OBJECT
;
COINSH:				;ENTRY
	PUSH   P,T1		;SAVE T1
	PUSH   P,T2		;SAVE T2
	PUSH   P,T3		;SAVE T3
	PUSH   P,T4		;SAVE T4
	PUSH   P,LCBPTR		;SAVE LCBPTR
	PUSH   P,P1		;SAVE A WORK REG
	SKIPN  LCBPTR,CONLST	;POINT TO HEAD OF CONNECT LIST, EMPTY ??
	JRST   COINSE		;YES, TERMINATE INTERRUPT
COINS0:				;NO, CHECK NEXT LCB
	CALL   RLSLNK		;READ THE LINK STATUS
	JRST   [CALL   ERXLNK		;FAILED, PRINT LINK ERROR
		HALTF]			;HALT FOR NOW
	LOAD   T1,LCBSTS	;GET THE LINK STATUS
	TXNE   T1,MO%WCC	;SKIP IF NOT WAITING TO BE CONFIRMED
	CALL   COINS1		;GO ACCEPT OR REJECT
	LOAD   LCBPTR,LCBCHN	;GET NEXT LCB IN CHAIN
	JUMPN  LCBPTR,COINS0	;DONE, AT END OF CHAIN
COINSE:				;HERE TO DISMISS INTERRUPT
	POP    P,P1		;RESTORE WORK REG
	POP    P,LCBPTR		;RESTORE LCBPTR
	POP    P,T4		;RESTORE T4
	POP    P,T3		;RESTORE T3
	POP    P,T2		;RESTORE T2
	POP    P,T1		;RESTORE T1
	DEBRK			;DISMISS, DONE 
	PAGE



COINS1:				;HERE TO CHECK WHETHER TO ACCEPT OR REJECT
	CALL   RLDLNK		;GO GET THE LINK DATA
	RETBAD ERXLNK		;FAILED, PRINT LINK ERROR, RETURN BAD
	LOAD   T1,LCBOPT	;GET POINTER TO OPTIONAL DATA
	ILDB   P1,T1		;GET FIRST BYTE OF OPT DATA


;*******************************************************************************
;*******************************************************************************

IFN DTRSW,<			;CONDITIONAL CODE FOR DTR
	SKIPE  DTRFLG		;IN DTR MODE ?
	JRST   DTR		>;YES, GO DO IT

;*******************************************************************************
;*******************************************************************************


	CAIN   P1,"R"		;REJECT CODE ?
	CALLRET COINS4		;YES, GO REJECT
	CAIN   P1,"A"		;ACCEPT CODE ?
	CALLRET COINS3		;YES, GO ACCEPT IT
	PRTWRN (<NO CODE FOUND IN OPTIONAL DATA>);NEITHER CODE FOUND, SAY SO
	;...	FALL INTO ACCEPT ROUTINE
	PAGE
	;...	CONTINUING
COINS3:				;HERE TO ACCEPT A CONNECTION
	LOAD   T1,LCBOPT	;GET POINTER TO OPT DATA WE GOT
	STOR   T1,LCBOSP	;MAKE IT ECHO
	LOAD   T1,LCBROC	;GET RECV COUNT
	STOR   T1,LCBSOC	;SEND SAME NUMBER
	PRTWRN (<ACCEPTING CONNECTION FROM - >) ;LET THE USER KNOW
	CALL   PRTOBJ		;GO OUTPUT THE HOST-OBJ-DESCR NAME
	PRTWRN (< >)		;HEADER FOR ACCESS CONTROL INFO
	CALL   PRTACC		;OUTPUT THE ACCESS CONTROL INFO


;*******************************************************************************
;*******************************************************************************


IFN DTRSW,<			;DTR CONDITIONAL CODE
DTRACP:				;HERE FOR DTR TO ACCEPT CONNECTION
				>;END DTR COND


;*******************************************************************************
;*******************************************************************************


	CALL   CLCICS		;CLEAR FROM CONNECT INTERRUPT CHANNEL
	RETBAD ERXLNK		;FAILED, PRINT LINK ERROR, RETURN BAD
	CALL   ACPLNK		;ACCEPT THE LINK
	RETBAD ERXLNK		;FAILED, PRINT LINK ERROR, RETURN BAD
	SETZRO LCBSOC		;CLEAR SEND OPT DATA POINTER
	SETZRO LCBOSP		;AND SEND BYTE COUNT
	CALL   STDACS		;SET UP LINK ON DATA PI CHANNEL
	RETBAD ERXLNK		;FAILED, PRINT LINK ERROR, RETURN BAD
	CALL   STIMCS		;SET UP LINK ON INT MSG PI CHANNEL
	RETBAD ERXLNK		;FAILED, PRINT LINK ERROR, RETURN BAD
	SETZRO LCBMAX		;CLEAR ALL THE MESSAGE COUNTERS
	SETZRO LCBCUR
	SETZRO LCBNER
	SETZRO LCBSND
	SETZRO LCBRCV
	SETZRO LCBIRC
	SETZRO LCBISC
	SETZRO LCBIOC
	SETZRO LCBSBC
	SETZRO LCBRBC
	SETZRO DTRSTI
	SETZRO DTRFTI
	LOAD   T1,LCBCHN	;GET POINTER TO NEXT IN CONNECT LIST
	PUSH   P,T1		;SAVE IT FOR LATER
	MOVEI  T1,CONLST	;GET ADDRESS OF CONNECT LIST ANCHOR
	CALL   DELLST		;REMOVE LCB FROM CONNECT LIST
	MOVE   T2,RCVLST	;GET FIRST ON RECEIVE LIST
	MOVEM  LCBPTR,RCVLST	;MAKE THIS ONE FIRST
	STOR   T2,LCBCHN	;AND REST CHAINED BEHIND
	POP    P,LCBPTR		;RESTORE POINTER TO NEXT IN CONNECT LIST
	RETSKP			;RETURN, SKIPPING LOAD CHAIN FIELD
	
	PAGE

COINS4:				;HERE TO REJECT A LINK
				;LET THE WORLD KNOW WHAT'S HAPPENING
	PRTWRN (<REJECTING CONNECTION FROM - >)
	CALL   PRTOBJ		;GO PRINT THE HOST-OBJ-DESCR NAME


;*******************************************************************************
;*******************************************************************************

IFN DTRSW,<			;DTR CONDITIONAL CODE
DTRREJ:				;HERE FOR DTR TO REJECT CONNECTION
				>;END OF DTR CONDITIONAL CODE

;*******************************************************************************
;*******************************************************************************


	CALL   REJLNK		;GO REJECT THE LINK
	RETBAD ERXLNK		;FAILED, PRINT LINK ERROR, RETURN BAD
	SETZRO LCBSOC		;CLEAR SEND OPT DATA POINTER
	SETZRO LCBOSP		;AND SEND BYTE COUNT
	RET			;DONE, RETURN



	PAGE
	SUBTTL DTR - DECNET TRANSMIT/RECEIVE ROUTINE


;*******************************************************************************
;*******************************************************************************
;
; THIS CODE IMPLEMENTS THE DTR FUNCTION 
;
;*******************************************************************************


IFN DTRSW,<			;BEGIN CONDITIONAL ASSEMBLY OF DTR CODE
				;ADD CODE HERE FOR DTR
DTR:				;ENTRY TO DTR ROUTINE
	LOAD   T2,LCBROC	;GET COUNT OF OPT DATA BYTES RECEIVED
	CAIGE  T2,2		;TWO OR MORE ?
	PRTWRN (<LESS THAN 2 BYTES OPT DATA>,<CALLRET COINS4>) ;NO, ERROR
	LOAD   T2,LCBFLG	;GET LCB FLAG FIELD
	TXZ    T2,DTR%PR	;CLEAR PRINT FLAG
	TRZE   P1,200		;CHECK PRINT OPTION  & CLEAR IT
	TXO    T2,DTR%PR	;SET PRINT FLAG
	TXZ    T2,<DTR%SK+DTR%SQ+DTR%PA+DTR%EK> ;CLEAR DATA TEST FLAGS
	STOR   T2,LCBFLG	;STORE BACK FLAG FIELD
	CAIL   P1,0		;CHECK FOR VALID TEST TYPE
	CAILE  P1,4		;TEST TYPE 0 TO 4 INCLUSIVE ?
	PRTWRN (<INVALID DTR TEST TYPE>,<CALLRET COINS4>) ;NO, LET USER KNOW
	JRST   @DTRDSP(P1)	;DISPATCH TO DTR TEST TYPE ROUTINE



DTRDSP:				;DTR DISPATCH TABLE
	DTRCON			;DTR CONNECT TEST ROUTINE
	DTRDAT			;DTR DATA TEST ROUTINE
	DTRDIS			;DTR DISCONNECT TEST
	DTRINT			;DTR INTERRUPT TEST

	PAGE
	SUBTTL DTRCON - DTR CONNECT TEST


DTRCON:				;ENTRY FOR CONNECT TEST
	ILDB   P1,T1		;GET SECOND BYTE OF OPTIONAL DATA
	CAIL   P1,0		;CHECK FOR VALID CONNECT TYPE
	CAILE  P1,5		;TYPES 0 TO 5 VALID
	PRTWRN (<INVALID CONNECT TEST TYPE>,<CALLRET COINS4>) ;NO, TELL USER
	JRST   @DTRCDP(P1)	;DISPATCH TO CONNECT TYPE ROUTINE

DTRCDP:				;DTR CONNECT TYPE DISPATCH TABLE
	CONREJ			;CONNECT REJECT W/O USER DATA
	CONACC			;CONNECT ACCEPT W/O USER DATA
	CONRST			;CONNECT REJECT W/ STD DATA
	CONAST			;CONNECT ACCEPT W/ STD DATA
	CONRRD			;CONNECT REJECT W/ RECEIVED DATA
	CONARD			;CONNECT ACCEPT W/ RECEIVED DATA


CONACC:				;ENTRY FOR ACCEPT
	PRTWRN (<DTR CONNECT ACCEPT TEST, NO OPTIONAL DATA>)
	CALLRET DTRACP		;JUST ACCEPT 



CONREJ:				;ENTRY FOR REJECT
	PRTWRN (<DTR CONNECT REJECT TEST, NO OPTIONAL DATA>)
	CALLRET COINS4		;JUST REJECT



CONRST:				;ENTRY FOR REJECT W/ STD DATA
	PRTWRN (<DTR CONNECT REJECT TEST, STANDARD OPTIONAL DATA>)
	MOVEI  T1,^D16		;16 BYTES OF STANDARD DATA
	STOR   T1,LCBSOC	;PUT SEND OPT DATA COUNT IN LCB
	MOVE   T1,STDINT	;GET POINTER TO STD DATA
	STOR   T1,LCBOSP	;PUT IN LCB
	CALLRET COINS4		;GO REJECT IT



CONAST:				;ENTRY FOR ACCEPT W/ STD DATA
	PRTWRN (<DTR CONNECT ACCEPT TEST, STANDARD OPTIONAL DATA>)
	MOVEI  T1,^D16		;16 BYTES OF STANDARD DATA
	STOR   T1,LCBSOC	;PUT SEND OPT DATA COUNT IN LCB
	MOVE   T1,STDINT	;GET POINTER TO STD DATA
	STOR   T1,LCBOSP	;PUT IN LCB
	CALLRET DTRACP		;GO ACCEPT IT



CONRRD:				;ENTRY FOR REJECT W/ RCV DATA
	PRTWRN (<DTR CONNECT REJECT TEST, USER OPTIONAL DATA>)
	LOAD   T1,LCBOPT	;GET POINTER TO OPT DATA REVEIVED
	STOR   T1,LCBOSP	;MAKE POINTER TO SEND
	LOAD   T1,LCBROC	;GET RECEIVED COUNT
	STOR   T1,LCBSOC	;SEND SAME COUNT
	CALLRET COINS4		;GO REJECT W/ RCV OPT DATA ECHOED



CONARD:				;ENTRY FOR ACCEPT W/ RCV DATA
	PRTWRN (<DTR CONNECT ACCEPT TEST, USER OPTIONAL DATA>)
	LOAD   T1,LCBOPT	;GET POINTER TO OPT DATA REVEIVED
	STOR   T1,LCBOSP	;MAKE POINTER TO SEND
	LOAD   T1,LCBROC	;GET RECEIVED COUNT
	STOR   T1,LCBSOC	;SEND SAME COUNT
	CALLRET DTRACP		;GO ACCEPT IT

	PAGE
	SUBTTL DTRDAT - DTR DATA TEST


DTRDAT:				;ENTRY FOR DTR DATA TEST
	LOAD   T2,LCBROC	;GET COUNT OF OPT DATA BYTE RECEIVED
	CAIE   T2,8		;IS IT 8 BYTES ?
	PRTWRN (<INVALID DATA TEST REQUEST SIZE>,<CALLRET COINS4>) ;NO, ERROR
	ILDB   P1,T1		;GET SECOND BYTE OF OPTIONAL DATA
	CAIL   P1,0		;CHECK FOR VALID DATA TEST TYPE
	CAILE  P1,3		;TYPES 0 TO 3 VALID
	PRTWRN (<INVALID DATA TEST TYPE>,<CALLRET COINS4>) ;NO, TELL USER
;
; WARNING!: This code has been changed to accept only Segment:8 as a valid
;		flow control option request. This is the value that the
;		TOPS-20 Monitor for Rel 3A & 4 implements. If future monitors
;		implement different flow control options or provide a way
;		for user programs to set or read the flow control option,
;		this code should be changed accordingly.
;
	ILDB   P2,T1		;GET THIRD BYTE (FCOPT)
	CAIE   P2,1		;IS IT SEGMENT FLOW CONTROL?, (FCOPT=1)
	PRTWRN (<UNSUPPORTED FLOW CONTROL OPTION>,<CALLRET COINS4>)
	ILDB   P2,T1		;YES, GET FCVAL
	CAIE   P2,^D8		;IS IT EIGHT?
	PRTWRN (<UNSUPPORTED FLOW CONTROL VALUE, MUST BE 8>,<CALLRET COINS4>)
	ILDB   P2,T1		;GET NAKVAL
	SKIPE  P2
	PRTWRN (<UNSUPPORTED NAK OPTION>,<CALLRET COINS4>)
	ILDB   P2,T1		;GET BPVAL
	SKIPE  P2
	PRTWRN  (<UNSUPPORTED BACK PRESSURE OPTION>,<CALLRET COINS4>)
	ILDB   P2,T1		;GET LOW ORDER 8 BITS OF MSGLEN
	ILDB   P3,T1		;GET HI ORDER
	LSH    P3,^D8		;SHIFT TO HI ORDER POSITION
	ADDI   P2,(P3)		;ADD IN THE LO ORDER BITS
	CAILE  P2,777*4		;MSGLEN TOO LARGE ? 2044 BYTES MAX
	PRTWRN (<UNSUPPORTED MESSAGE LENGTH, TOO LARGE>,<CALLRET COINS4>)
	STOR P2,LCBMSZ		;MAXIMUM SIZE TO READ
	SETONE LCBULM		;ALWAYS READ WHOLE MESSAGE
	SETZRO DTRSTI		;CLEAR START AND FINISH TIMES
	SETZRO DTRFTI
	SETZRO DTRSNK		;CLEAR THE DATA TEST TYPE FLAGS
	SETZRO DTREKO
	SETZRO DTRPAT
	SETZRO DTRSEQ
	SETONE DTRIDS		;IGNORE ANY INTERRUPT MESSAGES
	JRST   @DTRDDP(P1)	;DISPATCH TO DATA TEST TYPE ROUTINE

	PAGE


DTRDDP:				;DTR DATA TEST DISPATCH TABLE
	DATSNK			;DATA SINK
	DATSEQ			;SEQUENCE CHECK
	DATPAT			;PATTERN & SEQUENCE CHECK
	DATEKO			;ECHO



DATSNK:				;ENTRY FOR IDEAL DATA SINK
	CAIGE P2,1		;RANGE CHECK MESSAGE LENGTH, .GT. 1
	PRTWRN (<INVALID MESSAGE LENGTH>,<CALLRET COINS4>)
	PRTWRN (<DTR DATA SINK TEST>)
	SETONE DTRSNK		;SET DTR DATA SINK FLAG
	CALLRET DTRACP		;GO ACCEPT THE CONNECTION
DATSEQ:				;ENTRY FOR SEQUENCE CHECK TEST
	CAIGE P2,4		;RANGE CHECK MESSAGE LENGTH, .GT. 4
	PRTWRN (<INVALID MESSAGE LENGTH>,<CALLRET COINS4>)
	PRTWRN (<DTR DATA SEQUENCE TEST>)
	SETONE DTRSEQ		;SET DTR SEQUENCE CHECK FLAG
	SETONE DTRSNK		;ALSO MUST DO SINK
	CALLRET DTRACP		;GO ACCEPT THE CONNECTION
DATPAT:				;ENTRY FOR PATTERN TEST
	CAIGE P2,5		;RANGE CHECK MESSAGE LENGTH, .GT. 5
	PRTWRN (<INVALID MESSAGE LENGTH>,<CALLRET COINS4>)
	PRTWRN (<DTR DATA PATTERN TEST>)
	SETONE DTRSEQ		;SET DTR SEQUENCE CHECK FLAG
	SETONE DTRPAT		;SET DTR PATTERN CHECK FLAG
	SETONE DTRSNK		;ALSO MUST DO SINK
	CALLRET DTRACP		;GO ACCEPT THE CONNECTION
DATEKO:				;ENTRY FOR ECHO TEST
	CAIGE P2,1		;RANGE CHECK MESSAGE LENGTH, .GT. 1
	PRTWRN (<INVALID MESSAGE LENGTH>,<CALLRET COINS4>)
	PRTWRN (<DTR DATA ECHO TEST>)
	SETONE DTREKO		;SET DTR ECHO FLAG
	CALLRET DTRACP		;ACCEPT THE CONNECTION

	PAGE
	SUBTTL DTRDIS - DTR DISCONNECT TEST


DTRDIS:				;ENTRY FOR DTR DISCONNECT TEST
	ILDB   P1,T1		;GET DISCONNECT TEST TYPE
	CAIL   P1,0		;CHECK FOR VALID DISCONNECT TEST TYPE
	CAILE  P1,5		;0 TO 5 VALID
	PRTWRN (<INVALID DISCONNECT TEST TYPE>,<CALLRET COINS4>) ;NO, TELL USER
	CALL   ACPLNK		;GO ACCEPT THE LINK
	RETBAD ERXLNK		;FAILED, RETURN BAD
	JRST   @DTRSDP(P1)	;DISPATCH TO DISCONNECT TEST TYPE ROUTINE


DTRSDP:				;DTR DISCONNECT TEST DISPATCH TABLE
	DISCLZ			;DISCONNECT WITH CLOSF
	DISABT			;ABORT WITH CLOSF
	DISDST			;DISCONNECT W/ STD DATA USING MTOPR
	DISAST			;ABORT W/ STD DATA USING MTOPR
	DISDUS			;DISCONNECT W/ USER DATA
	DISAUS			;ABORT W/ USER DATA


DISCLZ:				;ENTRY FOR DISCONNECT W/ NO OPT DATA
	PRTWRN (<DTR DISCONNECT TEST, NO OPTIONAL DATA>)
	SETONE LCBRJF		;WANT TO KEEP THE JFN
	SETZRO LCBABT		;MAKE SURE NOT ABORT
	CALL   CLZLNK		;DO CLOSF ON LINK
	JRST   [PRTWRN (<DISCONNECT FAILED, ABORTING>) ;FAILED
		SETONE LCBABT		;SET ABORT FLAG
		CALL   CLZLNK		;GO ABORT IT
		RETBAD ERXLNK		;FAILED, RETURN BAD
		JRST   .+2]		;CONTINUE...
	PRTWRN (<CLOSED SERVER LINK, REOPENING>)
	SETZRO LCBRJF		;CLEAR KEEP JFN FLAG
	CALL   OPNLNK		;GO MAKE LINK LISTEN AGAIN
	RETBAD ERXLNK		;FAILED, RETURN BAD
	CALL   STCICS		;PUT BACK ON CONNECT INTERRUPT CHANNEL
	RETBAD ERXLNK		;FAILED, RETURN BAD
	RET			;DONE,RETURN



DISABT:				;ENTRY FOR ABORT W/ NO OPT DATA
	PRTWRN (<DTR ABORT TEST, NO OPTIONAL DATA>)
	SETONE LCBRJF		;WANT TO KEEP THE JFN
	SETONE LCBABT		;WANT TO ABORT
	CALL   CLZLNK		;DO CLOSF ON LINK
	RETBAD ERXLNK		;FAILED, RETURN BAD
	PRTWRN (<CLOSED SERVER LINK WITH ABORT, REOPENING>)
	SETZRO LCBRJF		;CLEAR KEEP JFN FLAG
	CALL   OPNLNK		;GO MAKE LINK LISTEN AGAIN
	RETBAD ERXLNK		;FAILED, RETURN BAD
	CALL   STCICS		;PUT BACK ON CONNECT INTERRUPT CHANNEL
	RETBAD ERXLNK		;FAILED, RETURN BAD
	RET			;DONE,RETURN



DISDST:				;ENTRY FOR DISCONNECT W/ STD DATA
	PRTWRN (<DTR DISCONNECT TEST, STANDARD OPTIONAL DATA>)
	MOVEI  T1,^D16		;16 BYTES OF STD DATA
	STOR   T1,LCBSOC	;PUT IN LCB
	MOVE   T1,STDINT	;GET POINTER TO STD DATA
	STOR   T1,LCBOSP	;STORE IN LCB
	SETZRO LCBABT		;MAKE SURE NOT ABORT
	CALL   REJLNK		;GO DO DISCONNECT
	RETBAD ERXLNK		;FAILED, RETURN BAD
	SETZRO LCBOSP		;CLEAR POINTER & COUNT
	SETZRO LCBSOC
	SETONE LCBRJF		;WANT TO KEEP THE JFN
	SETONE LCBABT		;WANT TO ABORT
	CALL   CLZLNK		;DO CLOSF ON LINK
	RETBAD ERXLNK		;FAILED, RETURN BAD
	PRTWRN (<DISCONNECTED SERVER LINK, REOPENING>)
	SETZRO LCBRJF		;CLEAR KEEP JFN FLAG
	CALL   OPNLNK		;GO MAKE LINK LISTEN AGAIN
	RETBAD ERXLNK		;FAILED, RETURN BAD
	CALL   STCICS		;PUT BACK ON CONNECT INTERRUPT CHANNEL
	RETBAD ERXLNK		;FAILED, RETURN BAD
	RET			;DONE, RETURN



DISAST:				;ENTRY FOR ABORT W/ STD DATA
	PRTWRN (<DTR ABORT TEST, STANDARD OPTIONAL DATA>)
	MOVEI  T1,^D16		;16 BYTES OF STD DATA
	STOR   T1,LCBSOC	;PUT IN LCB
	MOVE   T1,STDINT	;GET POINTER TO STD DATA
	STOR   T1,LCBOSP	;STORE IN LCB
	SETONE LCBABT		;MAKE IT DO ABORT

;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;
;THE DTR SPECIFICATION SAYS TO ABORT THE LINK WITH REASON CODE = 0
; HOWEVER, WE HAVE NO WAY TO DO THIS AND STILL SEND OPTIONAL DATA
; SO, WE WILL USE REASON CODE 9

	MOVX   T1,.DCX9		;GET NSP USER ABORT CODE
	STOR   T1,LCBRSN	;STORE IN LCB
	CALL   REJLNK		;GO DO ABORT
	RETBAD ERXLNK		;FAILED, RETURN BAD
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

	PRTWRN (<ABORTED SERVER LINK, REOPENING>)
	SETONE LCBRJF		;WANT TO KEEP THE JFN
	CALL   CLZLNK		;DO CLOSF ON LINK
	RETBAD ERXLNK		;FAILED, RETURN BAD
	SETZRO LCBOSP		;CLEAR POINTER & COUNT
	SETZRO LCBSOC
	SETZRO LCBRSN		;AND ABORT REASON CODE
	SETONE LCBABT		;WANT TO ABORT
	SETZRO LCBRJF		;CLEAR KEEP JFN FLAG
	CALL   OPNLNK		;GO MAKE LINK LISTEN AGAIN
	RETBAD ERXLNK		;FAILED, RETURN BAD
	CALL   STCICS		;PUT BACK ON CONNECT INTERRUPT CHANNEL
	RETBAD ERXLNK		;FAILED, RETURN BAD
	RET			;DONE, RETURN



DISDUS:				;ENTRY FOR DISCONNECT W/ USER DATA
	PRTWRN (<DTR DISCONNECT TEST, USER OPTIONAL DATA>)
	LOAD   T1,LCBROC	;GET RECEIVED OPT DATA BYTE COUNT
	STOR   T1,LCBSOC	;PUT IN LCB
	LOAD   T1,LCBOPT	;GET POINTER TO OPT DATA RECEIVED
	STOR   T1,LCBOSP	;STORE IN LCB
	SETZRO LCBABT		;MAKE SURE NOT ABORT
	CALL   REJLNK		;GO DO DISCONNECT
	RETBAD ERXLNK		;FAILED, RETURN BAD
	SETZRO LCBOSP		;CLEAR POINT & COUNT
	SETZRO LCBSOC
	SETONE LCBRJF		;WANT TO KEEP THE JFN
	SETONE LCBABT		;WANT TO ABORT
	CALL   CLZLNK		;DO CLOSF ON LINK
	RETBAD ERXLNK		;FAILED, RETURN BAD
	SETZRO LCBRJF		;CLEAR KEEP JFN FLAG
	CALL   OPNLNK		;GO MAKE LINK LISTEN AGAIN
	RETBAD ERXLNK		;FAILED, RETURN BAD
	CALL   STCICS		;PUT BACK ON CONNECT INTERRUPT CHANNEL
	RETBAD ERXLNK		;FAILED, RETURN BAD
	RET			;DONE, RETURN



DISAUS:				;ENTRY FOR ABORT W/ USER DATA
	PRTWRN (<DTR ABORT TEST, USER OPTIONAL DATA>)
	LOAD   T1,LCBROC	;GET RECEIVED COUNT
	STOR   T1,LCBSOC	;PUT IN LCB
	LOAD   T1,LCBOPT	;GET POINTER TO RECEIVED DATA
	STOR   T1,LCBOSP	;STORE IN LCB
	SETONE LCBABT		;MAKE IT DO ABORT
	MOVX   T1,.DCX9	;GET NSP USER ABORT CODE
	STOR   T1,LCBRSN	;STORE IN LCB
	CALL   REJLNK		;GO DO ABORT
	RETBAD ERXLNK		;FAILED, RETURN BAD
	SETZRO LCBOSP		;CLEAR POINTER & COUNT
	SETZRO LCBSOC
	SETZRO LCBRSN		;AND ABORT REASON CODE
	SETONE LCBRJF		;WANT TO KEEP THE JFN
	SETONE LCBABT		;WANT TO ABORT
	CALL   CLZLNK		;DO CLOSF ON LINK
	RETBAD ERXLNK		;FAILED, RETURN BAD
	SETZRO LCBRJF		;CLEAR KEEP JFN FLAG
	CALL   OPNLNK		;GO MAKE LINK LISTEN AGAIN
	RETBAD ERXLNK		;FAILED, RETURN BAD
	CALL   STCICS		;PUT BACK ON CONNECT INTERRUPT CHANNEL
	RETBAD ERXLNK		;FAILED, RETURN BAD
	RET			;DONE, RETURN



	PAGE
	SUBTTL DTRINT - DTR INTERRUPT TEST


DTRINT:				;ENTRY FOR DTR INTERRUPT TEST
	LOAD   T2,LCBROC	;GET COUNT OF OPT DATA BYTE RECEIVED
	CAIE   T2,3		;IS IT 3 BYTES ?
	PRTWRN (<INVALID INTERRUPT TEST REQUEST SIZE>,<CALLRET COINS4>) ;NO, ERROR
	ILDB   P1,T1		;GET SECOND BYTE OF OPTIONAL DATA
	CAIL   P1,0		;CHECK FOR VALID INTERRUPT TEST TYPE
	CAILE  P1,3		;TYPES 0 TO 3 VALID
	PRTWRN (<INVALID INTERRUPT TEST TYPE>,<CALLRET COINS4>) ;NO, TELL USER
	ILDB   P2,T1		;GET THIRD BYTE (INTFC)
	CAIE   P2,1		;INTERRUPT FLOW CONTROL = 1 ?
	PRTWRN (<INVALID FLOW CONTROL OPTION>,<CALLRET COINS4>) ;NO, ERROR
	SETZRO DTRIDS		;CLEAR THE INTERRUPT TEST TYPE FLAGS
	SETZRO DTRIEK
	SETZRO DTRIPA
	SETZRO DTRISE
	JRST   @DTRIDP(P1)	;DISPATCH TO INTERRUPT TEST TYPE ROUTINE

	PAGE


DTRIDP:				;DTR INTERRUPT TEST DISPATCH TABLE
	INTSNK			;INTERRUPT SINK
	INTSEQ			;SEQUENCE CHECK
	INTPAT			;PATTERN & SEQUENCE CHECK
	INTEKO			;ECHO



INTSNK:				;ENTRY FOR IDEAL INTERRUPT SINK
	PRTWRN (<DTR INTERRUPT SINK TEST>)
	SETONE DTRIDS		;SET DTR INTERRUPT SINK FLAG
	CALLRET DTRACP		;GO ACCEPT THE CONNECTION
INTSEQ:				;ENTRY FOR SEQUENCE CHECK TEST
	PRTWRN (<DTR INTERRUPT SEQUENCE TEST>)
	SETONE DTRISE		;SET DTR SEQUENCE CHECK FLAG
	SETONE DTRIDS		;ALSO MUST DO SINK
	CALLRET DTRACP		;GO ACCEPT THE CONNECTION
INTPAT:				;ENTRY FOR PATTERN TEST
	PRTWRN (<DTR INTERRUPT PATTERN TEST>)
	SETONE DTRISE		;SET DTR SEQUENCE CHECK FLAG
	SETONE DTRIPA		;SET DTR PATTERN CHECK FLAG
	SETONE DTRIDS		;ALSO MUST DO SINK
	CALLRET DTRACP		;GO ACCEPT THE CONNECTION
INTEKO:				;ENTRY FOR ECHO TEST
	PRTWRN (<DTR INTERRUPT ECHO TEST>)
	SETONE DTRIEK		;SET DTR ECHO FLAG
	CALLRET DTRACP		;ACCEPT THE CONNECTION

				>;END OF DTR CONDITIONAL CODE

;*******************************************************************************
;*******************************************************************************



	PAGE
	SUBTTL COINTH - CONNECT INTERRUPT HANDLER FOR TARGET LINKS
;
;COINTH - ROUTINE TO HANDLE SOFTWARE INTERRUPTS WHEN CONNECTION IS COMPLETED
; TO THE TARGET OBJECT
;
COINTH:				;ENTRY
	PUSH   P,T1		;SAVE T1
	PUSH   P,T2		;SAVE T2
	PUSH   P,T3		;SAVE T3
	PUSH   P,T4		;SAVE T4
	PUSH   P,LCBPTR		;SAVE LCBPTR
	PUSH   P,P1		;SAVE A WORK REG
	SKIPN  LCBPTR,CONLTT	;POINT TO HEAD OF CONNECT LIST, EMPTY ??
	JRST   COINTE		;YES, TERMINATE INTERRUPT
COINT0:				;NO, CHECK NEXT LCB
	CALL   RLSLNK		;READ THE LINK STATUS
; THIS FAILS IF LINK WAS CLOSED WHEN WE GET HERE
	CALL   ERXLNK		;FAILED, PRINT LINK ERROR, RETURN BAD
	LOAD   T1,LCBSTS	;GET THE LINK STATUS
	TXNN   T1,MO%WFC	;STILL WAITING FOR CONNECT ??
	CALL   COINT1		;NO, GO SEE WHAT HAPPENED
	LOAD   LCBPTR,LCBCHN	;GET NEXT LCB IN CHAIN
	JUMPN  LCBPTR,COINT0	;DONE, AT END OF CHAIN
COINTE:				;HERE TO DISMISS INTERRUPT
	POP    P,P1		;RESTORE WORK REG
	POP    P,LCBPTR		;RESTORE LCBPTR
	POP    P,T4		;RESTORE T4
	POP    P,T3		;RESTORE T3
	POP    P,T2		;RESTORE T2
	POP    P,T1		;RESTORE T1
	DEBRK			;DISMISS, DONE 



COINT1:				;HERE TO DO STUFF FOR CONNECTION COMPLETE
	TXNE   T1,MO%CON	;CONNECTED ??
	CALLRET COINT2		;YES, GO GET LINK INFO & WAKE UP
	TXNE   T1,MO%ABT	;ABORTED ??
	CALLRET COINT3		;YES, GO FIND WHY
	TXNE   T1,MO%SYN	;SYNCH DISCONNECT ??
	CALLRET COINT4		;YES, GO CLEAN UP
	PRTWRN (<NOT CONNECTED, ABORTED, DISCONNECTED>) ;SHOULD NOT GET HERE
	RET			;NEITHER OF THESE, CHECK REST


COINT2:			;HERE TO HANDLE CONNECT CONFIRMS
;
;WANT TO READ TASK NAME, OPTIONAL DATA,  HOST NAME?, SEGMENT SIZE
;
	CALL   RLDLNK		;GO GET THE LINK DATA
	RETBAD ERXLNK		;FAILED, PRINT LINK ERROR, RETURN BAD
	CALL   RSSLNK		;READ THE LINKS SEGMENT SIZE
	RETBAD ERXLNK		;FAILED, PRINT LINK ERROR, RETURN BAD
	PRTWRN (<SEGMENT SIZE - >) ;BANNER
	CALL   PRTSGS		;GO PRINT SEGMENT SIZE FOR THIS LINK
COINT5:				;HERE TO DO CLEAN UP
	PRTWRN (<OPT DATA - >)	;PRINT BANNER
	CALL   PRTOPT		;OUTPUT THE OPT DATA STRING
	CALL   CLCICT		;CLEAR FROM CONNECT INTERRUPT CHANNEL
	RETBAD ERXLNK		;FAILED, PRINT LINK ERROR, RETURN BAD
	LOAD   T1,LCBCHN	;GET POINTER TO NEXT IN CONNECT LIST
	PUSH   P,T1		;SAVE IT FOR LATER
	MOVEI  T1,CONLTT	;GET ADDRESS OF CONNECT LIST ANCHOR
	CALL   DELLST		;REMOVE LCB FROM CONNECT LIST
	POP    P,LCBPTR		;RESTORE POINTER TO NEXT IN CONNECT LIST
				;WAKE UP THE PROCESS IF WAITING
	MOVEI  T1,COINTL	;OUR LEVEL
	CALL   WAKEUP		;GO WAKE UP BACKGROUND IF SLEEPING
	RETSKP			;RETURN, SKIPPING LOAD CHAIN FIELD

COINT3:				;HERE ON ASYNCHRONOUS DISCONNECT
	
	PRTWRN (<TARGET LINK ABORTED - REASON CODE=>)
	CALL   PRTRSN		;GO PRINT ERROR REASON CODE
	CALL   ILKDTA		;INITIALIZE LCB'S LINK DATA AREA
	JRST   COINT5		;FAILED, CAN'T DO ANYTHING ELSE
	CALL   RDALNK		;READ OPTIONAL DATA
	JRST   COINT5		;FAILED
	JRST   COINT5		;GO DO CLEANUP & PRINT OPT DATA



COINT4:				;HERE ON SYNCHRONOUS DISCONNECT
	
	PRTWRN (<TARGET LINK DISCONNECTED>)
	CALL   ILKDTA		;INITIALIZE LCB'S LINK DATA AREA
	JRST   COINT5		;FAILED, CAN'T DO ANYTHING ELSE
	CALL   RDALNK		;READ OPTIONAL DATA
	JRST   COINT5		;FAILED
	JRST   COINT5		;GO DO CLEANUP & PRINT OPT DATA

	

	PAGE
	SUBTTL DAINSH - DATA AVAILABLE INTERRUPT HANDLER FOR SERVER
;
;DAINSH - INTERRUPT ROUTINE TO HANDLE DATA AVAILABLE ON SERVER LINKS
;
DAINSH:				;ENTRY TO DATA AVAILABLE INTERRUPT HANDLER
	PUSH   P,T1		;SAVE T1
	PUSH   P,T2		;SAVE T2
	PUSH   P,T3		;SAVE T3
	PUSH   P,T4		;SAVE T4
	PUSH   P,LCBPTR		;SAVE LCBPTR
	SKIPN  LCBPTR,RCVLST	;POINT TO HEAD OF RECEIVE LIST, EMPTY ??
	JRST   DAINSE		;YES, TERMINATE INTERRUPT
DAINS0:				;NO, CHECK NEXT LCB
	MOVX   (T1,<ASCIZ/LCB/>) ;MAKE CONSISTENCY CHECK FOR GOOD LCB
	OPSTRM (<CAME T1,>,LCBID) ;SKIP ON GOOD COMPARE
	PRTERR (<BAD LCB FOUND IN DA INT HANDLER>,<HALTF>) ;FATAL ERROR
	LOAD   (T1,LCBJFN)	;GET JFN FOR THIS LINK
	SIBE			;TEST FOR ANY DATA RECEIVED
	 JRST  [CALL   DAINS3		;IF BUFFER NOT EMPTY, GO READ
		JRST   DAINS0]		;GO SEE IF ANYMORE HAS ARRIVED
	CALL   RLSLNK		;GO READ LINK STATUS
	JRST   [CALL   ERXLNK		;PRINT ERROR
		HALTF]			;SHOULD NEVER HALT
	LOAD   T2,LCBSTS	;GET STATUS
	TXNN   T2,MO%CON	;CONNECTED ??
	JRST   [CALL DAINS1		;NO, GO CLOSE LINK
		JUMPN LCBPTR,DAINS0	;IF NOT LAST IN LIST GO DO NEXT LINK
		JRST DAINSE]		;END INTERRUPT IF AT END OF LIST
	GTSTS			;CHECK STATUS OF LINK
	 JSCONT (<GTSTS FAILED>) ;JSYS FAILURE, CONTINUE
	TXNE   T2,GS%EOF	;END OF FILE ?
	JRST   [CALL DAINS1		;YES, GO CLOSE LINK
		JUMPN LCBPTR,DAINS0	;IF NOT LAST IN LIST GO DO NEXT LINK
		JRST DAINSE]		;END INTERRUPT IF AT END OF LIST
DAINS2:				;HERE TO CHECK NEXT LCB IN CHAIN
	LOAD   (LCBPTR,LCBCHN)	;GET NEXT LCB ON CHAIN
	JUMPN  LCBPTR,DAINS0	;IF NOT END OF CHAIN, GO CHECK NEXT
DAINSE:				;HERE TO DISMISS INTERRUPT
	POP    P,LCBPTR		;RESTORE LCBPTR
	POP    P,T4		;RESTORE T4
	POP    P,T3		;RESTORE T3
	POP    P,T2		;RESTORE T2
	POP    P,T1		;RESTORE T1
	DEBRK			;DISMISS THE INTERRUPT WHEN DONE


	PAGE


;
;HERE TO READ ANY DATA RECEIVED ON A LINK
;
DAINS3:				;ENTRY WHEN DATA IN BUFFER FOR A LINK
	STOR   (T2,LCBCSZ)	;STORE NUMBER OF BYTES AVAILABLE
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;	LOAD T1,LCBMSZ
;	CAIE T1,(T2)		;WHOLE MESSAGE AVAILABLE NOW ?
;	PRTWRN (<DATA INTERRUPT WITH PARTIAL MESSAGE>)
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	MOVEI  T1,44		;NUMBER OF BITS PER WORD
	LOAD   T2,LCBBSZ	;GET BYTE SIZE FOR THIS LINK
	IDIVI  T1,(T2)		;FIND NUMBER OF BYTES PER WORD
	LOAD   T2,LCBMSZ	;GET NUMBER OF BYTES TO READ
	ADDI   T2,1		;ADD ONE BYTE FOR NULL
	IDIVM  T2,T1		;FIND NUMBER OF WORDS REQUIRED
	ADDI   T1,2		;ADD TWO WORDS TO BE SAFE
	JN     (LCBRMQ,,DAINS4)	;IF BUFFER ALREADY GOTTEN, GO SEE IF SUFFICIENT
DAINS6:				;BACK HERE TO GET ANOTHER BUFFER
	CALL   M%GMEM		;NO, GET BLOCK THAT SIZE FOR RECEIVE BUFFER
	SKIPN  F,0		;SUCCESS ?, YES SKIP
	PRTERR (<CAN'T GET BUFFER FOR RECEIVE>,<HALTF>)
	MOVEM  T1,(T2)		;STORE SIZE AS FIRST WORD OF BUFFER
	LOAD   T3,LCBBSZ	;GET BYTE SIZE
	LSH    T3,6		;MAKE A BYTE POINTER
	HRLI   T2,(T3)		;BYTE POINTER
	STOR   T2,LCBRMQ	;STORE BYTE POINTER FOR RECEIVE BUFFER IN LCB
DAINS7:				;BACK HERE IF CURRENT BUFFER BIG ENOUGH
	CALL   RLSLNK		;GET CURRENT STATUS
	RETBAD ERXLNK		;FAILED, PRINT LINK ERROR, RETURN BAD

	PAGE

;*******************************************************************************
;*******************************************************************************
IFN DTRSW,<			;BEGIN CONDITIONAL ASSEMBLY OF DTR CODE

	SKIPN  DTRFLG		;IN DTR MODE ?
	JRST   DTRDAX		;NO, BRANCH AROUND DTR CODE
	TIME			;GET CURRENT ELAPSED TIME
	 JFCL			;SHOULD NEVER FAIL
	JN DTRSTI,,DTRSQ1	;STORE START TIME FIRST MESSAGE RECEIVED ONLY
	STOR T1,DTRSTI		;STORE START TIME
DTRSQ1:				;HERE ON SUBSEQUENT RECEIVES 
	STOR T1,DTRFTI		;STORE CURRENT ELAPSED TIME EACH MESSAGE
	SETONE LCBULM		;ALWAYS READ LOGICAL MESSAGE
	LOAD T1,LCBMSZ		;GET MAX MSG SIZE
	STOR T1,LCBCSZ		;READ THE WHOLE MESSAGE
	CALL RCVLNK
	RETBAD ERXLNK

DTRSQN:				;ENTRY TO DTR SEQUENCE CHECK ROUTINE
	JE     DTRSEQ,,DTRPTN	;DO A SEQUENCE CHECK ? NO, GO CHECK PATTERN FLAG
	LOAD   T1,LCBRMQ	;GET POINTER TO RECEIVED MESSAGE
	MOVEI  T2,4		;GET A 4 BYTE -11 INTEGER
	CALL   LOAD11		;GO GET IT
	LOAD   T3,LCBRCV	;GET CURRENT RECEIVE COUNT
	CAMN   T2,T3		;DO THEY AGREE ??
	JRST   DTRPTN		;YES, GO CHECK PATTERN FLAG
	PRTWRN (<SEQUENCE ERROR ENCOUNTERED>) ;NO, TELL USER
	JRST   DTRABT		;NO, GO ABORT LINK
DTRPTN:				;ENTRY TO DTR PATTERN CHECK ROUTINE
	JE     DTRPAT,,DTRECH	;DO A PATTERN CHECK ? NO, GO CHECK ECHO FLAG
				;.... T1 HAS POINTER TO MESSAGE
	STKVAR <PATCNT>		;VARIABLE TO HOLD COUNT OF BYTES TO CHECK
	LOAD   T3,LCBMSZ	;GET LENGTH OF MESSAGE WE GOT
	SUBI   T3,4		;LESS THE LENGTH OF THE SEQ NUMBER
DTRPT1:				;HERE TO CHECK EACH PATTERN OCCURENCE
	MOVE   T2,STDPAT	;GET POINTER TO STANDARD PATTERN
	MOVEM  T3,PATCNT	;SAVE THE COUNT
	CAILE  T3,^D36		;MORE THAN THE STANDARD PATTERN ?
	MOVEI  T3,^D36		;YES, COMPARE FOR LENGTH OF STANDARD PATTERN
	CALL   STRCMP		;GO COMPARE THE STRINGS
	PRTWRN (<PATTERN ERROR ENCOUNTERED>,<JRST DTRABT>) ;UNEQUAL, GO ABORT
	MOVE   T3,PATCNT	;EQUAL COMPARE, RESTORE THE COUNT
	SUBI   T3,^D36		;DECREMENT BY LENGTH OF STANDARD PATTERN
	JUMPG  T3,DTRPT1	;IF MORE TO COMPARE GO DO IT
	JRST   DTRSIN		;ELSE, LOOKS GOOD, DONE
DTRABT:				;HERE TO ABORT LINK
	SETONE LCBABT		;SET THE ABORT FLAG IN LCB
	CALL   REJLNK		;GO ABORT THE LINK
	JRST   [CALL ERXLNK	;SHOULDN'T FAIL
		RET]		;DID SO GIVE UP THE SHIP
	RET			;RETURN
DTRSIN:				;ENTRY TO SINK CHECK ROUTINE
	JN     DTRSNK,,R	;DO A SINK TEST ? YES, JUST A RETURN
	PRTERR (<UNEXPECTED DATA RECEIVED ON LINK>,<RET>) ;NO, NETWORK ERROR
	JRST .-1
DTRECH:				;ENTRY TO ECHO CHECK ROUTINE
	JE     DTREKO,,DTRSIN	;DO AN ECHO ? NO, GO CHECK SINK FLAG
				;FALL INTO ECHO CODE
				;HERE TO DO DTR ECHO TEST
	JRST DAINS9

DTRDAX:				;HERE TO BRANCH AROUND DTR CODE

				>;END OF DTR CONDITIONAL CODE
;*******************************************************************************
;*******************************************************************************

	PAGE


	SETZRO LCBULM		;CLEAR LOGICAL MESSAGE FLAG
	LOAD   T2,LCBSTS
	LOAD   T1,LCBFLG	;GET LCB FLAGS
	TXNE   T2,MO%EOM	;GOT A COMPLETE MESSAGE ??
	TXO    T1,LCB%LM	;YES, SET LOGICAL MSG FLAG
	STOR   T1,LCBFLG	;STORE BACK THE UPDATED FLAGS
	CALL   RCVLNK		;RECEIVE FROM LINK
	RETBAD ERXLNK		;FAILED, PRINT LINK ERROR, RETURN BAD
;
;??? IT IS POSSIBLE TO GET A GOOD RECEIVE WITH THE LINK DISCONNECTED
; THEN, THE FOLLOWING SEND WILL FAIL
; OUGHT TO CHECK LINK STATUS HERE, AND DO SOMETHING RATIONAL
; IF THE LINK IS NOT CONNECTED
;
DAINS9:
	LOAD   T2,LCBRMQ	;RESTORE POINTER FOR RECEIVE BUFFER
	STOR   T2,LCBSMQ	;MAKE IT SEND FROM RECEIVE BUFFER
	CALL   SNDLNK		;GO SEND ON LINK
	RETBAD ERXLNK		;FAILED, PRINT LINK ERROR, RETURN BAD
	SETZRO LCBULM		;TURN OFF LOGICAL MESSAGE FLAG
	RET			;DONE, RETURN


	PAGE

;REMOVE LINK FROM RECEIVE STATE, CLOSE/REOPEN THE JFN, AND
; PUT IT BACK IN WAITING FOR CONNECT STATE


DAINS1:				;HERE ON END OF FILE ON LINK
	SETONE LCBRJF		;INDICATE KEEP JFN
	LOAD   T2,LCBSTS	;GET LINK STATUS
	TXNE   T2,MO%ABT	;ABORTED ??
	JRST   [PRTWRN (<SERVER LINK ABORTED - REASON CODE=>) ;YES, TELL USER
		CALL   PRTRSN		;GO PRINT ERROR REASON CODE
		JRST   .+1]		;RETURN
	TXNE   T2,MO%SYN	;SYNCH DISC ??
	PRTWRN (<SERVER LINK DISCONNECTED, REOPENING>) ;YES, TELL USER
;*******************************************************************************
IFN DTRSW,<			;CONDITIONAL CODE FOR DTR
	SKIPE  DTRFLG		;IN DTR MODE ?
	JRST   [LOAD T1,LCBFLG		;YES, GET LCB FLAGS
		TXNE T1,<DTR%SK+DTR%SQ+DTR%PA+DTR%EK> ;DOING ANY DATA TEST ?
		CALL PRTEFF]		>;YES, GO PRINT COUNTS + DATA RATE
;*******************************************************************************
	CALL  CLDACS		;REMOVE FROM DATA AVAILABLE CHANNEL
	RETBAD ERXLNK		;FAILED, PRINT LINK ERROR, RETURN BAD
	CALL   CLZLNK		;GO CLOSE LINK
	JRST   [SETONE LCBABT		;FAILED, SET ABORT FLAG
		CALL   CLZLNK		;TRY TO ABORT IT
		JRST   [CALL ERXLNK		;FAILED
			HALTF]			;SHOULD NEVER HALT HERE
		JRST   .+1]		;RETURN
	SETZRO LCBRJF		;TURN OFF RELEASE JFN FLAG
	SETZRO LCBABT		;TURN OFF ABORT FLAG
	LOAD   T1,LCBCHN	;GET ADDRESS OF NEXT IN RECEIVE LIST
	PUSH   P,T1		;SAVE IT FOR LATER
	MOVEI  T1,RCVLST	;GET ADDRESS OF CHAIN ANCHOR OF RECEIVE LIST
	CALL   DELLST		;GO REMOVE FROM RECEIVE LIST
	MOVEI  T1,NWLKDA	;GET SIZE OF LINK DATA AREA
	LOAD   T2,LCBHST	;AND POINTER TO IT
	HRRZI  T2,(T2)		;MAKE SURE IT'S ADDRESS ONLY
	CALL   M%RMEM		;RELEASE THE STORAGE
	SKIPN  F		;CHECK RETURN FLAG
	PRTERR (<COULDN'T FREE LINK DATA AREA>,<HALTF>)
	SETZRO LCBHST		;CLEAR LINK DATA POINTERS
	SETZRO LCBODS
	SETZRO LCBTSK
	SETZRO LCBGPU
	SETZRO LCBUSE
	SETZRO LCBPAS
	SETZRO LCBACT
	SETZRO LCBOPT
	SETZRO LCBCON
	SETZRO LCBLLA
	;...	MORE
	PAGE
	;...	CONTINUING
	LOAD   T2,LCBRMQ	;GET POINTER TO RECEIVE BUFFER
	JUMPE  T2,DAINS8	;DON'T TRY TO FREE IF WE NEVER GOT A BUFFER
	HRRZI  T2,(T2)		;MAKE SURE IT'S ADDRESS ONLY
	MOVE   T1,(T2)		;AND ITS SIZE 
	CALL   M%RMEM		;RELEASE THE STORAGE
	SKIPN  F		;CHECK RETURN FLAG
	PRTERR (<COULDN'T FREE RECEIVE BUFFER>,<HALTF>)
	SETZRO LCBRMQ		;CLEAR RECEIVE BUFFER POINTER



DAINS8:				;HERE IF WE DIDN'T FIND BUFFER TO FREE
	CALL   OPNLNK		;OPEN IT AGAIN
	JRST   [CALL   ERXLNK
		HALTF]			;DISASTER, HALT FOR NOW !!
	CALL   STCICS		;SET FOR CONNECT INTERRUPT
	JRST   [CALL   ERXLNK
		HALTF]			;DISASTER, HALT FOR NOW !!
	MOVE   T1,CONLST	;GET POINTER TO HEAD OF CONNECT LIST
	STOR   T1,LCBCHN	;PUT AT HEAD OF CONNECT LIST
	MOVEM  LCBPTR,CONLST	;POINT TO NEW HEAD OF CONNECT LIST
	POP    P,LCBPTR		;RESTORE POINTER TO NEXT IN RECEIVE LIST
	RET			;DONE, RETURN


	PAGE


;
;HERE ON SUBSEQUENT INTERRUPTS TO CHECK INPUT BUFFER SIZE
;
DAINS4:				;ENTRY
	LOAD   T2,LCBRMQ	;GET BUFFER POINTER
	CAMG   T1,(T2)		;BUFFER LARGE ENOUGH FOR THIS READ ?
	JRST   DAINS7		;YES, GO DO READ 
	PUSH   P,T1		;SAVE NUMBER OF BYTES TO READ
	HRRZI  T2,(T2)		;MAKE SURE IT'S ADDRESS ONLY
	MOVE   T1,(T2)		;GET SIZE OF BUFFER
	CALL   M%RMEM		;RELEASE THE BUFFER
	SKIPN F			;CHECK FOR GOOD RETURN
	PRTERR (<COULDN'T FREE RECEIVE BUFFER>,<HALTF>) ;FAILED
	POP    P,T1		;RESTORE NUMBER OF BYTES TO READ
	JRST   DAINS6		;GO GET ANOTHER BUFFER
	PAGE
	SUBTTL DAINTH - DATA AVAILABLE INTERRUPT HANDLER FOR TARGET LINKS
;
;DAINTH - INTERRUPT ROUTINE TO HANDLE DATA AVAILABLE ON LOGICAL LINKS TO
;	TARGET TASKS
;
DAINTH:				;ENTRY TO DATA AVAILABLE INTERRUPT HANDLER
	PUSH   P,T1		;SAVE T1
	PUSH   P,T2		;SAVE T2
	PUSH   P,T3		;SAVE T3
	PUSH   P,T4		;SAVE T4
	PUSH   P,LCBPTR		;SAVE LCBPTR
	SKIPN  LCBPTR,RCVLTT	;POINT TO HEAD OF RECEIVE LIST, EMPTY ??
	JRST   DAINTE		;YES, TERMINATE INTERRUPT
DAINT0:				;NO, CHECK NEXT LCB
	MOVX   (T1,<ASCIZ/LCB/>) ;MAKE CONSISTENCY CHECK FOR GOOD LCB
	OPSTRM (<CAME T1,>,LCBID) ;SKIP ON GOOD COMPARE
	PRTERR (<BAD LCB FOUND IN DA INT HANDLER>,<HALTF>) ;FATAL ERROR
	LOAD   (T1,LCBJFN)	;GET JFN FOR THIS LINK
	SIBE			;ANY DATA RECEIVED ?
	JRST   [CALL   DAINT3		;YES, BUFFER NOT EMPTY, GO READ
		JRST   DAINT0]		;SEE IF ANYMORE ARRIVED
	CALL   DAINT5		;NO, GO CHECK STATUS
DAINT2:				;HERE CHECK NEXT LCB IN RECEIVE CHAIN
	LOAD   (LCBPTR,LCBCHN)	;GET NEXT LCB ON CHAIN
	JUMPN  LCBPTR,DAINT0	;IF NOT END OF CHAIN, GO CHECK NEXT LCB
DAINTE:				;AT END OF RECEIVE CHAIN, DISMISS INTERRUPT
	MOVEI  T1,DAINTL	;OUR LEVEL
	CALL   WAKEUP		;GO WAKEUP BACKGROUND
	POP    P,LCBPTR		;RESTORE LCBPTR
	POP    P,T4		;RESTORE T4
	POP    P,T3		;RESTORE T3
	POP    P,T2		;RESTORE T2
	POP    P,T1		;RESTORE T1
	DEBRK			;DISMISS THE INTERRUPT WHEN DONE


	PAGE
;
;HERE TO READ ANY DATA RECEIVED ON A LINK
;
DAINT3:				;ENTRY WHEN DATA IN BUFFER FOR A LINK
	STOR   (T2,LCBCSZ)	;STORE NUMBER OF BYTES AVAILABLE
	MOVEI  T1,^D36		;NUMBER OF BITS PER WORD
	LOAD   T2,LCBBSZ	;GET BYTE SIZE FOR THIS LINK
	IDIVI  T1,(T2)		;FIND NUMBER OF BYTES PER WORD
	LOAD   T2,LCBMSZ	;GET NUMBER OF BYTES TO READ
	ADDI   T2,1		;ADD ONE BYTE FOR NULL
	IDIVM  T2,T1		;FIND NUMBER OF WORDS REQUIRED
	ADDI   T1,2		;ADD TWO WORDS TO BE SAFE
	JN     (LCBRMQ,,DAINT4)	;IF BUFFER ALREADY GOTTEN, GO SEE IF SUFFICIENT
DAINT6:				;BACK HERE TO GET ANOTHER BUFFER
	CALL   M%GMEM		;NO, GET BLOCK THAT SIZE FOR RECEIVE BUFFER
	SKIPN  F,0		;SUCCESS ?, YES SKIP
	PRTERR (<CAN'T GET BUFFER FOR RECEIVE>,<RET>)
	MOVEM  T1,(T2)		;STORE SIZE AS FIRST WORD OF BUFFER
	LOAD   T3,LCBBSZ	;GET BYTE SIZE
	LSH    T3,6		;MAKE A BYTE POINTER
	HRLI   T2,(T3)		;BYTE POINTER
	STOR   T2,LCBRMQ	;STORE BYTE POINTER FOR RECEIVE BUFFER IN LCB
DAINT7:				;BACK HERE IF CURRENT BUFFER BIG ENOUGH
	CALL   RCVLNK		;GO RECEIVE ON LINK
	RETBAD ERXLNK		;FAILED, PRINT LINK ERROR, RETURN BAD
				;NOW WRITE TO MESSAGE LOG FILE
	LOAD   T1,LCBMLN	;GET JFN/POINTER TO MESSAGE LOG
	LOAD   T2,LCBRMQ	;RESTORE POINTER FOR RECEIVE BUFFER
	LOAD   T3,LCBCSZ	;GET NUMBER OF BYTES READ FROM LINK
	MOVNI  T3,(T3)		;MAKE NEGATIVE
	SOUT			;WRITE TO MESSAGE LOG
	 JSCONT (<COULDN'T WRITE TO MESSAGE LOG>) ;JSYS FAILED, CONTINUE
	LOAD   T1,LCBJFN	;GET LINK JFN
	GTSTS			;CHECK STATUS OF LINK
	 JSRET (<GTSTS FAILED ON LINK>) ;JSYS FAILED, RETURN
	TXNN   T2,GS%EOF	;END OF FILE ?
	RET			;NO, GO CHECK REST OF LIST
	CALL   DAINT5		;YES, GO CLOSE LINK
	RET			;AND RETURN
	PAGE
DAINT5:			;HERE TO CHECK STATUS AFTER DATA READ OR
				; ON INTERRUPT WITH NO DATA
	CALL   RLSLNK		;NO,  READ LINK STATUS
	JRST   [CALL   ERXLNK		;FAILED
		CALLRET DAINT1]		;GO CLOSE LINK
	LOAD   T2,LCBSTS	;GET STATUS
	TXNN   T2,MO%CON	;STILL CONNECTED ?
	CALLRET DAINT1		;NO, GO CLOSE LINK
	LOAD   T2,LCBFLG	;GET LCB FLAGS
	TXNN   T2,LCB%DN	;DONE FLAG ON ?
	RET			;NO, KEEP GOING
	LOAD   T2,LCBRCV	;YES, GET RECEIVE COUNT
	LOAD   T3,LCBSND	;GET SEND COUNT
	CAIN   T2,(T3)		;GOT ALL WE SENT ?
	CALLRET DAINT1		;YES, WE'RE DONE, GO CLOSE LINK
	RET			;NO, KEEP WAITING


	PAGE
;
;HERE ON END OF FILE OR LINK DISCONNECT
;
DAINT1:
	SETZRO LCBRJF		;TURN OFF RELEASE JFN FLAG
	SETZRO LCBABT		;TURN OFF ABORT FLAG
	LOAD   T2,LCBSTS	;GET CURRENT LINK STATUS
	TXNE   T2,MO%ABT	;ABORTED ??
	JRST   [PRTWRN (<TARGET LINK ABORTED - REASON CODE=>) ;YES, TELL USER
		CALL   PRTRSN		;GO PRINT ERROR REASON CODE
		JRST   .+1]	;RETURN
	TXNE   T2,MO%SYN	;SYNCH DISCONNECT ??
	PRTWRN (<TARGET LINK DISCONNECTED>) ;YES, TELL USER
	CALL   CLDACT		;REMOVE FROM DATA AVAILABLE CHANNEL
	CALL   ERXLNK		;FAILED, PRINT LINK ERROR
	CALL   CLZLNK		;GO CLOSE LINK
	JRST   [SETONE LCBABT		;FAILED, SET ABORT FLAG
		CALL   CLZLNK		;TRY TO ABORT IT
		JRST   [CALL   ERXLNK
			HALTF]			;DISASTER, HALT FOR NOW !!
		JRST   .+1]			;RETURN BAD
	LOAD   T1,LCBCHN	;GET POINTER TO NEXT IN RECEIVE LIST
	PUSH   P,T1		;SAVE IT FOR LATER
	MOVEI  T1,RCVLTT	;GET ADDRESS OF CHAIN ANCHOR OF RECEIVE LIST
	CALL   DELLST		;GO REMOVE FROM RECEIVE LIST
	MOVEI  T1,NWLKDA	;GET SIZE OF LINK DATA AREA
	LOAD   T2,LCBHST	;AND POINTER TO IT
	SKIPN  T2
	PRTERR (<NO LINK DATA AREA TO FREE>,<JRST DAINT8>) ;NO POINTER
	HRRZI  T2,(T2)		;MAKE SURE IT'S ADDRESS ONLY
	CALL   M%RMEM		;RELEASE THE STORAGE
	SKIPN  F		;CHECK RETURN FLAG
	PRTERR (<COULDN'T FREE LINK DATA AREA>,<RET>) ;BAD RETURN
	;...	MORE
	PAGE
	;...	CONTINUING
DAINT8:				;HERE WHEN NO LINK DATA AREA FREED
	SETZRO LCBHST		;CLEAR LINK DATA POINTERS
	SETZRO LCBODS
	SETZRO LCBTSK
	SETZRO LCBGPU
	SETZRO LCBUSE
	SETZRO LCBPAS
	SETZRO LCBACT
	SETZRO LCBOPT
	SETZRO LCBCON
	SETZRO LCBLLA
	LOAD   T2,LCBRMQ	;GET POINTER TO RECEIVE BUFFER
	JUMPE  T2,DAINT9	;DON'T FREE IF NEVER GOTTEN
	HRRZI  T2,(T2)		;MAKE SURE IT'S ADDRESS ONLY
	MOVE   T1,(T2)		;AND ITS SIZE 
	CALL   M%RMEM		;RELEASE THE STORAGE
	SKIPN  F		;CHECK RETURN FLAG
	PRTERR (<COULDN'T FREE RECEIVE BUFFER>,<RET>) ;NONE THERE
DAINT9:				;HERE TO BRANCH AROUND FREE
	SETZRO LCBRMQ		;CLEAR RECEIVE BUFFER POINTER
	POP    P,LCBPTR		;RESTORE POINTER TO NEXT IN RECEIVE LIST
	RETSKP			;GO CHECK REST OF RECEIVE LIST


	PAGE


;
;HERE ON SUBSEQUENT INTERRUPTS TO CHECK INPUT BUFFER SIZE
;
DAINT4:				;ENTRY
	LOAD   T2,LCBRMQ	;GET BUFFER POINTER
	CAMG   T1,(T2)		;BUFFER LARGE ENOUGH FOR THIS READ ?
	JRST   DAINT7		;YES, GO DO READ 
	PUSH   P,T1		;SAVE NUMBER OF BYTES TO READ
	HRRZI  T2,(T2)		;MAKE SURE IT'S ADDRESS ONLY
	MOVE   T1,(T2)		;GET SIZE OF BUFFER
	CALL   M%RMEM		;RELEASE THE BUFFER
	SKIPN F			;CHECK FOR GOOD RETURN
	JRST   [
		HRROI  T1,[ASCIZ/? DYNETS: COULDN'T FREE RECEIVE BUFFER/]
		CALL   SNDMSG
		RET]
	POP    P,T1		;RESTORE NUMBER OF BYTES TO READ
	JRST   DAINT6		;GO GET ANOTHER BUFFER
	PAGE
	SUBTTL IMINSH - INTERRUPT MESSAGE RECEIPT INTERRUPT HANDLER FOR SERVER
;
;IMINSH - ROUTINE TO HANDLE RECEIPT OF INTERRUPT MESSAGE ON SERVER LINKS
;
IMINSH:				;ENTRY
	PUSH   P,T1		;SAVE T1
	PUSH   P,T2		;SAVE T2
	PUSH   P,T3		;SAVE T3
	PUSH   P,T4		;SAVE T4
	PUSH   P,LCBPTR		;SAVE LCBPTR
	MOVE   LCBPTR,RCVLST	;GET POINTER TO FIRST LCB IN RECEIVE LIST
IMINS0:				;LOOP BACK TO HERE FOR EACH LCB
	MOVX   (T1,<ASCIZ/LCB/>) ;MAKE CONSISTENCY CHECK FOR GOOD LCB
	OPSTRM (<CAME T1,>,LCBID) ;SKIP ON GOOD COMPARE
	PRTERR (<BAD LCB FOUND IN IM INT HANDLER>,<HALTF>)
	CALL   RLSLNK		;GO READ LINK STATUS
	JRST   [CALL   ERXLNK
		HALTF]			;DISASTER, HALT FOR NOW !!
	LOAD   T2,LCBSTS	;GET STATUS
	TXNN   T2,MO%CON	;STILL CONNECTED ??
	JRST   [CALL DAINS1		;NO, GO CLOSE AND RESET 
		JUMPN LCBPTR,IMINS0	;IF NOT LAST IN LIST GO DO NEXT LINK
		JRST IMINSE]		;END INTERRUPT IF AT END OF LIST
	TXNE   T2,MO%INT	;INTERRUPT MSG AVAILABLE ??
	CALL   IMINS3		;YES, GO READ IT
IMINS2:				;HERE TO CHECK NEXT LCB IN CHAIN
	LOAD   (LCBPTR,LCBCHN)	;GET NEXT LCB ON CHAIN
	JUMPN  LCBPTR,IMINS0	;IF NOT END OF CHAIN, GO CHECK NEXT
IMINSE:				;HERE TO DISMISS INTERRUPT
	POP    P,LCBPTR		;RESTORE LCBPTR
	POP    P,T4		;RESTORE T4
	POP    P,T3		;RESTORE T3
	POP    P,T2		;RESTORE T2
	POP    P,T1		;RESTORE T1
	DEBRK			;DISMISS THE INTERRUPT WHEN DONE
IMINS3:				;HERE TO READ INTERRUPT MESSAGE AND ECHO
	CALL   RIMLNK		;GO READ THE INTERRUPT MESSAGE
	RETBAD ERXLNK		;FAILED, PRINT LINK ERROR, RETURN BAD
	PAGE

;*******************************************************************************
;*******************************************************************************
IFN DTRSW,<			;BEGIN CONDITIONAL ASSEMBLY OF DTR CODE

DTRISQ:				;ENTRY TO DTR INTERRUPT SEQUENCE CHECK ROUTINE
	JE     DTRISE,,DTRIPT	;DO A SEQUENCE CHECK ? NO, GO CHECK PATTERN FLAG
	LOAD   T1,LCBPIM	;GET POINTER TO RECEIVED MESSAGE
	MOVEI  T2,4		;GET A 4 BYTE -11 INTEGER
	CALL   LOAD11		;GO GET IT
	LOAD   T3,LCBIRC	;GET CURRENT RECEIVE COUNT
	CAMN   T2,T3		;DO THEY AGREE ??
	JRST   DTRIPT		;YES, GO CHECK PATTERN FLAG
	PRTWRN (<SEQUENCE ERROR ENCOUNTERED>) ;NO, TELL USER
	JRST   DTRIAB		;NO, GO ABORT LINK
DTRIPT:				;ENTRY TO DTR INTERRUPT PATTERN CHECK ROUTINE
	JE     DTRIPA,,DTRIEC	;DO A PATTERN CHECK ? NO, GO CHECK ECHO FLAG
				;.... T1 HAS POINTER TO MESSAGE
	MOVE   T2,STDINT	;GET POINTER TO STANDARD PATTERN
	LOAD   T3,LCBSZI	;GET LENGTH OF INTERRUPT MESSAGE WE GOT
	SUBI   T3,4		;LESS THE LENGTH OF THE SEQ NUMBER
	CALL   STRCMP		;GO COMPARE THE STRINGS
	PRTWRN (<PATTERN ERROR ENCOUNTERED>,<JRST DTRIAB>) ;UNEQUAL, GO ABORT
	JRST   DTRISI		;LOOKS GOOD
DTRIAB:				;HERE TO ABORT LINK
	SETONE LCBABT		;SET THE ABORT FLAG IN LCB
	CALL   REJLNK		;GO ABORT THE LINK
	JRST   [CALL ERXLNK	;SHOULDN'T FAIL
		HALTF]		;DID SO GIVE UP THE SHIP
	CALL DAINS1		;GO CLOSE AND RESET TO WAIT FOR CONNECT
	RETSKP			;RETURN +2 TO AVOID RELOAD OF LCBPTR
DTRISI:				;ENTRY TO SINK CHECK ROUTINE
	JN     DTRIDS,,R	;DO AN INTERRUPT SINK TEST ? YES, JUST A RETURN
	PRTERR (<INVALID DTR INTERRUPT TEST FLAGS>,<HALTF>) ;NO, INTERNAL ERROR
	JRST .-1
DTRIEC:				;ENTRY TO ECHO CHECK ROUTINE
	JE     DTRIEK,,DTRISI	;DO AN INTERRUPT ECHO ? NO, GO CHECK SINK FLAG
				;FALL INTO ECHO CODE
				;HERE TO DO DTR ECHO TEST

				>;END OF DTR CONDITIONAL CODE
;*******************************************************************************
;*******************************************************************************

	CALL   SIMLNK		;AND ECHO IT
	RETBAD ERXLNK		;FAILED, PRINT LINK ERROR, RETURN BAD
	RET			;DONE RETURN
	PAGE
	SUBTTL IMINTH - INTERUPT MESSAGE RECEIPT INTERRUPT HANDLER FOR TARGET
;
;IMINTH - HANDLE RECEIPT OF INTERRUPT MESSAGE ON LINKS TO TARGETS
;
IMINTH:				;ENTRY
	PUSH   P,T1		;SAVE T1
	PUSH   P,T2		;SAVE T2
	PUSH   P,T3		;SAVE T3
	PUSH   P,T4		;SAVE T4
	PUSH   P,LCBPTR		;SAVE LCBPTR
	MOVE   LCBPTR,RCVLTT	;GET POINTER TO FIRST LCB IN RECEIVE LIST
IMINT0:				;LOOP BACK TO HERE FOR EACH LCB
	MOVX   (T1,<ASCIZ/LCB/>) ;MAKE CONSISTENCY CHECK FOR GOOD LCB
	OPSTRM (<CAME T1,>,LCBID) ;SKIP ON GOOD COMPARE
	JRST   [CALL TSTCOL
		HRROI  T1,[ASCIZ/BAD LCB FOUND IN IM INT HANDLER/]
		CALL   SNDMSG
		JRST   IMINTE]
	CALL   RLSLNK		;GO READ LINK STATUS
	JRST   [CALL   ERXLNK
		HALTF]			;DISASTER, HALT FOR NOW !!
	LOAD   T2,LCBSTS	;GET STATUS
	TXNN   T2,MO%CON	;STILL CONNECTED ??
	JRST   IMINT2		;NO, DON'T DO ANYTHING
	TXNE   T2,MO%INT	;INTERRUPT MSG AVAILABLE ??
	CALL   IMINT3		;YES, GO READ IT
IMINT2:				;HERE TO CHECK NEXT LCB IN CHAIN
	LOAD   (LCBPTR,LCBCHN)	;GET NEXT LCB ON CHAIN
	JUMPN  LCBPTR,IMINT0	;IF NOT END OF CHAIN, GO CHECK NEXT
IMINTE:				;HERE TO DISMISS INTERRUPT
	MOVEI  T1,IMINTL	;OUR LEVEL
	CALL   WAKEUP		;WAKE UP BACKGROUND
	POP    P,LCBPTR		;RESTORE LCBPTR
	POP    P,T4		;RESTORE T4
	POP    P,T3		;RESTORE T3
	POP    P,T2		;RESTORE T2
	POP    P,T1		;RESTORE T1
	DEBRK			;DISMISS THE INTERRUPT WHEN DONE
IMINT3:				;HERE TO READ INTERRUPT MESSAGE AND ECHO
	CALL   RIMLNK		;GO READ THE INTERRUPT MESSAGE
	RETBAD ERXLNK		;FAILED, PRINT LINK ERROR, RETURN BAD
	MOVE   T1,STDINT	;POINT TO THE STANDARD WE SENT
	LOAD   T2,LCBPIM	;POINT TO THE INT MSG WE RECEIVED
	MOVEI  T3,NBIMSG	;NUMBER OF BYTES TO COMPARE
	CALL   STRCMP		;COMPARE THEM
	JRST   [HRROI  T1,[ASCIZ/? DYNETS: INTERRUPT MESSAGE NOT WHAT SENT/]
		CALL   SNDMSG
		RET]
	LOAD   T1,LCBPIM	;POINTER TO INT MSG
	HRRZI  T2,(T1)		;MAKE IT ADDRESS ONLY
	MOVX   T1,<NBIMSG/4>
	CALL   M%RMEM		;FREE STORAGE FOR INT MSG
	RET			;DONE RETURN
	PAGE
	SUBTTL MAKTCB - MAKE AN ENTRY IN THE TCB LIST IF ONE DOES NOT YET EXIST
;
;ACCEPTS: T1/ JFN OF THE TARGET/OBJECT/DESCRIPTOR
;
;	CALL MAKTCB
;
;RETURNS+1: IF TCB WAS NOT IN TABLE T2/POINTER TO THE NEW TCB
;	+2: IF TCB WAS ALREADY IN TABLE T2/POINTER TO TCB
;
MAKTCB:				;ENTRY
	STKVAR <SAVJFN,TCBADR>	;VARIABLE FOR ARGUMENT AND TCB ADDRESS
	MOVEM  T1,SAVJFN	;SAVE ARGUMENT
	MOVEI  T1,TCBSIZ	;GET STORAGE FOR A TCB
	CALL   M%GMEM		;EVEN IF DON'T NEED LATER
	MOVEM  T2,TCBADR	;SAVE TCB ADDRESS
	HRROI  T1,2(T2)		;GET ADDRESS OF WHERE TO PUT STRING
	MOVE   T2,SAVJFN	;GET JFN FOR THIS TARGET/OBJ/DESCR
	MOVX   (T3,<FLD(.JSAOF,JS%NAME)>) ;OUTPUT ONLY FILE NAME 
	JFNS			;GET HOST-OBJECT-DESCRIPTION
	 JSHLT (<JFNS FAILED>)
	MOVEI  T1,TCBLKT	;GET ADDRESS OF TCB LOOKUP TABLE
	MOVE   T2,TCBADR	;ADDRESS OF TCB
	HRROI  T2,2(T2)		;STRING POINTER TO HOST-OBJ-DESCR
	TBLUK			;SEE IF IN TABLE ALREADY
	 JSHLT (<TBLUK FAILED>)
	TXNE   (T2,TL%NOM)	;SKIP IF FOUND IN TABLE
	JRST   ADDTCB		;GO BUILD A NEW TARGET CONTROL BLOCK
	MOVE   T2,TCBADR	;ADRRESS OF STORAGE GOTTEN FOR TCB
	MOVEM  T1,TCBADR	;SAVE RETURNED ENTRY ADDRESS
	MOVEI  T1,TCBSIZ	;SIZE OF TCB BEING RETURNED
	CALL   M%RMEM		;RETURN STORAGE, DON'T NEED
	MOVE   T1,SAVJFN	;GET THE JFN
	MOVE   T2,TCBADR	;GET ADDRESS OF ENTRY FOUND BY TBLUK
	HRRZ   T2,(T2)		;GET ADDRESS OF THE TCB FROM LOOKUP TABLE
	RETSKP			;DONE, RETURN +2
ADDTCB:				;HERE TO PUT TCB ON LIST
	MOVEI  T1,TCBLKT	;GET ADDRESS OF TCB LOOKUP TABLE
	MOVE   T2,TCBADR	;ADDRESS OF THE NEW TCB
	HRLI   T2,2(T2)		;ADDRESS OF THE HOST/OBJ/DESCR STRING
	TBADD			;ADD ENTRY TO TCB LOOKUP TABLE
	 JSHLT (<TBADD FAILED>)
	MOVE   T1,TCBLST	;GET START OF TCB LIST
	MOVE   T2,TCBADR	;GET ADDRESS OF NEW TCB TO ADD
	MOVEM  T1,(T2)		;POINT TO PREVIOUS FIRST ENTRY
	MOVEM  T2,TCBLST	;MAKE NEW HEAD OF LIST
	RET			;DONE, RETURN
	PAGE
	SUBTTL MAKSCB - MAKE AN ENTRY IN THE SCB LIST IF ONE DOES NOT YET EXIST
;
;ACCEPTS: T1/ JFN OF THE SERVER OBJECT-DESCRIPTOR
;
;	CALL MAKSCB
;
;RETURNS+1: IF SCB WAS NOT IN TABLE T2/POINTER TO THE NEW SCB
;	+2: IF SCB WAS ALREADY IN TABLE T2/POINTER TO SCB
;
MAKSCB:				;ENTRY
	STKVAR <SAVJFN,SCBADR>	;VARIABLE FOR ARGUMENT AND SCB ADDRESS
	MOVEM  T1,SAVJFN	;SAVE ARGUMENT
	MOVEI  T1,SCBSIZ	;GET STORAGE FOR A SCB
	CALL   M%GMEM		;EVEN IF DON'T NEED LATER
	MOVEM  T2,SCBADR	;SAVE SCB ADDRESS
	HRROI  T1,2(T2)		;GET ADDRESS OF WHERE TO PUT STRING
	MOVE   T2,SAVJFN	;GET JFN FOR THIS TARGET/OBJ/DESCR
	MOVX   (T3,<FLD(.JSAOF,JS%NAME)>) ;OUTPUT ONLY FILE NAME 
	JFNS			;GET HOST-OBJECT-DESCRIPTION
	 JSHLT (<JFNS FAILED>)
	MOVEI  T1,SCBLKT	;GET ADDRESS OF SCB LOOKUP TABLE
	MOVE   T2,SCBADR	;ADDRESS OF SCB
	HRROI  T2,2(T2)		;STRING POINTER TO HOST-OBJ-DESCR
	TBLUK			;SEE IF IN TABLE ALREADY
	 JSHLT (<TBLUK FAILED>)
	TXNE   (T2,TL%NOM)	;SKIP IF FOUND IN TABLE
	JRST   MAKSC1		;GO BUILD A NEW TARGET CONTROL BLOCK
	MOVE   T2,SCBADR	;ADRRESS OF STORAGE GOTTEN FOR SCB
	MOVEM  T1,SCBADR	;SAVE RETURNED ENTRY ADDRESS
	MOVEI  T1,SCBSIZ	;SIZE OF SCB BEING RETURNED
	CALL   M%RMEM		;RETURN STORAGE, DON'T NEED
	MOVE   T1,SAVJFN	;GET THE JFN
	MOVE   T2,SCBADR	;GET ADDRESS OF ENTRY FOUND BY TBLUK
	HRRZ   T2,(T2)		;GET ADDRESS OF THE SCB FROM LOOKUP TABLE
	RETSKP			;DONE, RETURN +2
MAKSC1:				;HERE TO PUT SCB ON LIST
	MOVEI  T1,SCBLKT	;GET ADDRESS OF SCB LOOKUP TABLE
	MOVE   T2,SCBADR	;ADDRESS OF THE NEW SCB
	HRLI   T2,2(T2)		;ADDRESS OF THE HOST/OBJ/DESCR STRING
	TBADD			;ADD ENTRY TO SCB LOOKUP TABLE
	 JSHLT (<TBADD FAILED>)
	MOVE   T1,SCBLST	;GET START OF SCB LIST
	MOVE   T2,SCBADR	;GET ADDRESS OF NEW SCB TO ADD
	MOVEM  T1,(T2)		;POINT TO PREVIOUS FIRST ENTRY
	MOVEM  T2,SCBLST	;MAKE NEW HEAD OF LIST
	RET			;DONE, RETURN
	PAGE
	SUBTTL DELLST - DELETE AN LCB FROM LINKED LIST
;
;DELLST - ROUTINE TO TAKE LCB OFF OF A LINKED LIST
;
;ACCEPTS T1/ ADDRESS OF LIST ANCHOR
;	LCBPTR/ POINTER TO LCB TO REMOVE
;
;RETURNS+1: ALWAYS, T1/ POINTER TO PREVIOUS IN LIST OR ZERO
;
DELLST:				;ENTRY
	CAMN   LCBPTR,(T1)	;IS IT FIRST IN LIST ?
	JRST   [LOAD   T2,LCBCHN 	;YES, REMOVE IT
		MOVEM  T2,(T1)		;MAKE NEW FIRST IN LIST
		SETZRO LCBCHN		;CLEAR CHAIN FIELD
		SETZI  T1,0		;ZERO TO INDICATE FIRST IN LIST
		RET]			;AND RETURN
	MOVE   T2,LCBPTR	;SAVE POINTER TO ONE TO REMOVE
	SKIPN  (T1)		;LIST EMPTY ?
	RET			;YES, JUST RETURN
	MOVE   LCBPTR,(T1)	;POINT TO FIRST IN LIST
DEL1:	MOVE   T3,LCBPTR	;SAVE POINTER TO ENTRY WE'RE LOOKING AT
	LOAD   LCBPTR,LCBCHN	;GET POINTER TO NEXT ENTRY IN LIST
	SKIPN  LCBPTR		;AT END OF LIST ?
	JRST   [MOVE   LCBPTR,T2	;YES, RESTORE POINTER TO LCB REMOVED
		RET]			;RETURN
	CAME   T2,LCBPTR	;IS THIS ONE WE'RE LOOKING FOR ?
	JRST   DEL1		;NO, GO BUMP TO NEXT ENTRY IN LIST
	LOAD   T4,LCBCHN	;YES, GET POINTER TO NEXT
	MOVE   LCBPTR,T3	;POINT TO PREVIOUS
	STOR   T4,LCBCHN	;PREVIOUS POINTS TO ENTRY FOLLOWING DELETED
	MOVE   T1,LCBPTR	;GET POINTER TO PREVIOUS IN LIST
	MOVE   LCBPTR,T2	;POINT TO ENTRY BEING REMOVED
	SETZRO LCBCHN		;CLEAR ITS CHAIN FIELD
	RET			;AND RETURN
	PAGE
	SUBTTL DELLCB - DELETE AN LCB FROM TCB LIST
;
;DELLCB - ROUTINE TO TAKE LCB OFF OF TCB'S LINKED LIST
;
;ACCEPTS LCBPTR/ POINTER TO LCB TO REMOVE
;	TCBPTR/ POINTER TO TCB
;
;RETURNS+1: ALWAYS, T1/ POINTER TO PREVIOUS IN LIST OR ZERO IF NO PREVIOUS
;		    T2/ POINTER TO NEXT
;		    LCBPTR/ UNCHANGED
;
DELLCB:				;ENTRY
	CAMN   LCBPTR,TCBLCB	;IS IT FIRST IN LIST ?
	JRST   [LOAD   T2,LCBNLP 	;YES, REMOVE IT
		MOVEM  T2,TCBLCB	;MAKE NEW FIRST IN LIST
		SETZRO LCBNLP		;CLEAR CHAIN FIELD
		SETZI  T1,0		;ZERO TO INDICATE FIRST IN LIST
		RET]			;AND RETURN
	MOVE   T2,LCBPTR	;SAVE POINTER TO ONE TO REMOVE
	MOVE   LCBPTR,TCBLCB	;POINT TO FIRST IN LIST
	SKIPN  LCBPTR		;EMPTY ?
	RET			;YES, JUST RETURN
DELLC1:	MOVE   T3,LCBPTR	;SAVE POINTER TO ENTRY WE'RE LOOKING AT
	LOAD   LCBPTR,LCBNLP	;GET POINTER TO NEXT ENTRY IN LIST
	SKIPN  LCBPTR		;AT END OF LIST ?
	RET			;YES, RETURN
	CAME   T2,LCBPTR	;IS THIS ONE WE'RE LOOKING FOR ?
	JRST   DELLC1		;NO, GO BUMP TO NEXT ENTRY IN LIST
	LOAD   T4,LCBNLP	;YES, GET POINTER TO NEXT
	MOVE   LCBPTR,T3	;POINT TO PREVIOUS
	STOR   T4,LCBNLP	;PREVIOUS POINTS TO ENTRY FOLLOWING DELETED
	MOVE   T1,LCBPTR	;GET POINTER TO PREVIOUS IN LIST
	MOVE   LCBPTR,T2	;POINT TO ENTRY BEING REMOVED
	SETZRO LCBNLP		;CLEAR ITS CHAIN FIELD
	RET			;AND RETURN
	PAGE
	SUBTTL BUILD SKELETON LCB ROUTINE
;
;SET UP A SKELETON LINK CONTROL BLOCK
;
BLDLCB:				;ENTRY TO BUILD LCB ROUTINE
	MOVX   T1,LCBSIZ	;GET SIZE OF AN LCB
	CALL   M%GMEM		;GET A BLOCK OF MEMORY FOR LCB
	MOVEI  LCBPTR,(T2)	;SET LCB POINTER TO ADDRESS OF BLOCK
	MOVX   T1,<ASCIZ/LCB/>	;GET THE ASCII ID STRING
	STOR   T1,LCBID		;STORE IN ID FIELD
	MOVX   T1,LCB.EC	;DEFAULT IS ECHO MODE
	STOR   T1,LCBMOD	;STORE DEFAULT MODE
	MOVX   T1,LCB.BS	;GET DEFAULT BYTE SIZE
	STOR   T1,LCBBSZ	;STORE IT
	MOVX   T1,LCB.MX	;GET MAXIMUM OUTSTANDING COUNT
	STOR   T1,LCBMAX	;STORE IT
	MOVX   T1,LCB.MS	;GET MAXIMUM MESSAGE SIZE
	STOR   T1,LCBMSZ	;STORE IT
	RET			;DONE, RETURN
	PAGE
	SUBTTL FRELCB - FREE THE LINK CONTROL BLOCK STORAGE
;
;FRELCB - ROUTINE TO RELEASE STORAGE ASSOCIATED WITH AN LCB
;
;ACCEPTS LCBPTR/ POINTER TO LCB TO FREE
;
;	CALL FRELCB
;
;RETURNS+1: ALWAYS
;
FRELCB:				;ENTRY
	LOAD   T1,LCBJFN	;RELEASE THE JFN
	GTSTS			;CHECK LINK STATUS
	TXNN   T2,GS%OPN	;OPEN ??
	JRST   FRELC1		;NO, DON'T NEED TO CLOSE IT
	SETZRO LCBABT		;TURN OFF ABORT FLAG
	CALL   CLZLNK		;GO CLOSE LINK
	JRST   [SETONE LCBABT		;FAILED
		CALL   CLZLNK		;TRY TO ABORT IT
		JRST   [CALL   ERXLNK		;COULDN'T EVEN DO THAT
			HALTF]			;DISASTER, HALT FOR NOW !!
		JRST   .+1]
FRELC1:				;HERE IF DON'T NEED TO CLOSE
	LOAD   T1,LCBJFN	;GET JFN
	RLJFN
	 JSHLT (<RLJFN FAILED>)
	MOVEI  T1,NWLKDA	;GET SIZE OF LINK DATA AREA
	LOAD   T2,LCBHST	;BEGGINING OF LINK DATA AREA
	HRRZI  T2,(T2)		;MAKE SURE IT IS ADDRESS ONLY
	SKIPE  T2		;AREA EXISTS ?
	CALL   M%RMEM		;YES, RELEASE IT
	MOVEI  T1,16		;SIZE OF OPTIONAL DATA
	LOAD   T2,LCBODS	;OPT DATA SEND AREA
	HRRZI  T2,(T2)		;MAKE SURE IT IS ADDRESS ONLY
	SKIPE  T2		;AREA EXISTS ?
	CALL   M%RMEM		;YES, RELEASE IT
	LOAD   T2,LCBSMQ	;GET SEND MESSAGE BUFFER ADDRESS
	MOVE   T1,(T2)		;AND ITS SIZE
	HRRZI  T2,(T2)		;MAKE SURE IT IS ADDRESS ONLY
	SKIPE  T2		;AREA EXISTS ?
	CALL   M%RMEM		;YES, RELEASE IT
	LOAD   T2,LCBRMQ	;GET RECEIVE MESSAGE BUFFER ADDRESS
	MOVE   T1,(T2)		;AND ITS SIZE
	HRRZI  T2,(T2)		;MAKE SURE IT IS ADDRESS ONLY
	SKIPE  T2		;AREA EXISTS ?
	CALL   M%RMEM		;YES, RELEASE IT
	MOVEI  T1,NBIMSG	;GET SIZE OF INTERRUPT MESSAGE AREA
	LOAD   T2,LCBPIM	;GET ADDRESS OF INT MSG AREA
	HRRZI  T2,(T2)		;MAKE SURE IT IS ADDRESS ONLY
	SKIPE  T2		;AREA EXISTS ?
	CALL   M%RMEM		;YES, RELEASE IT
	MOVEI  T1,LCBSIZ	;GET SIZE OF LCB
	MOVEI  T2,(LCBPTR)	;GET ADDRESS OF LCB
	CALL   M%RMEM		;RELEASE IT
	CALL   DELLCB		;DELETE LCB FROM TCB LIST
	RET			;DONE, RETURN
	PAGE
	SUBTTL FNDTCB - FIND TCB IN LOOKUP TABLE
;
;FNDTCB - ROUTINE TO LOOKUP A TCB IN THE LOOKUP TABLE
;
;ACCEPTS T1/ JFN OF NETWORK FILE SPEC
;
;	CALL FNDTCB
;
;RETURNS+1: NOT FOUND
;	+2: FOUND
;
FNDTCB:				;ENTRY
	SAVEAC <T1>		;SAVE T1
	MOVE   T2,T1		;GET JFN FOR THIS TARGET/OBJ/DESCR
	HRROI  T1,TCBSTR	;GET ADDRESS OF WHERE TO PUT STRING
	MOVX   (T3,<FLD(.JSAOF,JS%NAME)>) ;OUTPUT ONLY FILE NAME 
	JFNS			;GET HOST-OBJECT-DESCRIPTION
	 JSHLT (<JFNS FAILED>)
	MOVEI  T1,TCBLKT	;GET ADDRESS OF TCB LOOKUP TABLE
	HRROI  T2,TCBSTR	;STRING POINTER TO HOST-OBJ-DESCR
	TBLUK			;SEE IF IN TABLE ALREADY
	 JSHLT (<TBLUK FAILED>)
	EXCH   T1,T2		;SWAP T1,T2
	HRRZ   T2,(T2)		;GET ADDRESS
	TXNE   (T1,TL%NOM)	;FOUND IN TABLE ??
	RET			;NO, TAKE +1 RETURN
	RETSKP			;YES, TAKE SKIP RETURN 
	PAGE
	SUBTTL OPNLNK - OPEN A NETWORK CONNECTION LOGICAL LINK
;
;OPNLNK - ROUTINE TO DO AN OPENF FOR LOGICAL LINK
;
;ACCEPTS LCBPTR: POINTER TO LCB
;
;	CALL OPNLNK
;
;RETURNS+1:FAILURE, ERROR CODES STORED IN LCB
;	+2:SUCCESS
;
OPNLNK:				;ENTRY
	SKIPN  LCBPTR		;SKIP IF GOOD LCB POINTER
	PRTERR (<INVALID LCB POINTER>,<HALTF>)
	LOAD   (T1,LCBJFN)	;GET THE JFN FOR THIS LCB
	LOAD   (T2,LCBBSZ)	;GET THE BYTE SIZE
	LSH    T2,<^D36-POS(OF%BSZ)-1> ;PUT IT IN OF%BSZ
	TXO    (T2,<OF%RD+OF%WR>) ;SET READ, WRITE FLAGS
	OPENF			;DO THE OPEN JSYS
	 ERJMP OPNERR			;FAILED
	SETONE LCBOFG		;TURN ON THE OPEN FLAG IN LCB
	RETSKP			;DONE, MAKE GOOD RETURN



OPNERR:				;HERE TO HANDLE JSYS ERROR
	MOVX   T2,.OPNER	;GET DYNETS ERROR CODE
	RETBAD ER1LNK		;STORE IT IN LCB



	PAGE
	SUBTTL RLSLNK - READ LINK STATUS FOR LINK
;
;RLSLNK - ROUTINE TO DO A READ LINK STATUS OPERATION FOR A LINK
;
;ACCEPTS Q1(LCBPTR)/ POINTER TO LCB
;
;	CALL RLSLNK
;
;RETURNS+1: FAILURE
;	+2: SUCCESS
;
RLSLNK:				;ENTRY
	LOAD   T1,LCBJFN	;GET THE JFN FOR THIS LINK
	MOVX   T2,.MORLS	;READ LINK STATUS FUNCTION CODE
	MTOPR			;READ LINK STATUS MTOPR
	 ERJMP RLSERR		;JSYS ERROR
	STOR   T3,LCBSTS	;STORE LINK STATUS BITS AND ABORT REASON
	RETSKP			;GOOD RETURN



RLSERR:				;HERE TO HANDLE JSYS ERROR
	MOVX   T2,.RLSER	;GET DYNETS ERROR CODE
	RETBAD ERRLNK		;STORE IT IN LCB



	PAGE
	SUBTTL RLDLNK - READ LINK DATA FOR LINK
;
;RLDLNK - ROUTINE TO READ LINK DATA ASSOCIATED WITH LCB'S LINK
;
;ACCEPTS Q1(LCBPTR)/ POINTER TO LCB
;
;	CALL RLDLNK
;
;RETURNS+1: FAILURE
;	+2: SUCCESS
;
RLDLNK:				;ENTRY
	SKIPN  LCBPTR		;SHOULDN'T BE HERE WITH NO LCB'S
	PRTERR (<INVALID LCB POINTER>,<HALTF>)
	MOVX   T1,<ASCIZ/LCB/>	;GET THE VALID LCB ID
	OPSTRM (<CAME T1,>,LCBID) ;SKIP IF GOOD LCB
	PRTERR (<INVALID LCB FOUND>,<HALTF>)
	CALL   ILKDTA		;INITIALIZE THE LINK DATA AREA
	PRTERR (<INIT LINK DATA AREA FAILED>,<RET>) ;COULDN'T INIT BAD RETURN
	CALL   RHNLNK		;READ HOST NAME
	HALTF
	CALL   RODLNK		;READ OBJECT DESCRIPTOR & GROUP/USER
	HALTF
	CALL   RTNLNK		;READ TASK NAME
	HALTF
	CALL   RUSLNK		;READ USER ID
	HALTF
	CALL   RPWLNK		;READ PASSWORD
	HALTF
	CALL   RACLNK		;READ ACCOUNT
	HALTF
	CALL   RDALNK		;READ OPTIONAL DATA
	HALTF
	CALL   RCNLNK		;READ CONNECT OBJECT NUMBER
	HALTF
	RETSKP			;DONE, RETURN
	PAGE
	SUBTTL RHNLNK - READ HOST NAME FOR LINK
;
;RHNLNK - ROUTINE TO READ HOST NAME ASSOCIATED WITH LCB'S LINK
;
;ACCEPTS Q1(LCBPTR)/ POINTER TO LCB
;
;	CALL RHNLNK
;
;RETURNS+1: FAILURE
;	+2: SUCCESS
;
RHNLNK:				;ENTRY
	LOAD   T1,LCBJFN	;GET JFN FOR THIS LINK
	MOVX   T2,.MORHN	;FUNCTION CODE FOR READ HOST NAME
	LOAD   T3,LCBHST	;STRING POINTER FOR HOST NAME
	MTOPR			;READ THE LINK DATA MTOPR
	 ERJMP RHNERR		;ERROR ON JSYS
	RETSKP			;DONE, RETURN



RHNERR:				;HERE TO HANDLE JSYS ERROR
	MOVX   T2,.RHNER	;GET DYNETS ERROR CODE
	RETBAD ERRLNK		;STORE IT IN LCB



	PAGE
	SUBTTL RODLNK - READ OBJECT-DESCRIPTOR FOR LINK
;
;RODLNK - ROUTINE TO READ OBJECT-DESCRIPTOR ASSOCIATED WITH LCB'S LINK
;
;ACCEPTS Q1(LCBPTR)/ POINTER TO LCB
;
;	CALL RODLNK
;
;RETURNS+1: FAILURE
;	+2: SUCCESS
;
RODLNK:				;ENTRY
	LOAD   T1,LCBJFN	;GET JFN FOR THIS LINK
	MOVX   T2,.MOROD	;FUNCTION CODE FOR READ OBJECT-DESCRIPTOR
	LOAD   T3,LCBODS	;STRING POINTER FOR OBJECT-DESCRIPTOR
	LOAD   T4,LCBSVR	;GET SERVER FLAG
	SKIPE  T4		;FUNCTION VALID ONLY FOR SERVER
	MTOPR			;MTOPR TO READ OBJ-DESCR
	 ERJMP RODERR		;ERROR ON JSYS
	STOR   T4,LCBGPU	;STORE GROUP/USER CODE
	RETSKP			;DONE, RETURN



RODERR:				;HERE TO HANDLE JSYS ERROR
	MOVX   T2,.RODER	;GET DYNETS ERROR CODE
	RETBAD ERRLNK		;STORE IT IN LCB



	PAGE
	SUBTTL RTNLNK - READ TASK NAME FOR LINK
;
;RTNLNK - ROUTINE TO READ TASK NAME ASSOCIATED WITH LCB'S LINK
;
;ACCEPTS Q1(LCBPTR)/ POINTER TO LCB
;
;	CALL RTNLNK
;
;RETURNS+1: FAILURE
;	+2: SUCCESS
;
RTNLNK:				;ENTRY
	LOAD   T1,LCBJFN	;GET JFN FOR THIS LINK
	MOVX   T2,.MORTN	;FUNCTION CODE FOR READ TASK NAME
	LOAD   T3,LCBTSK	;STRING POINTER FOR TASK NAME
	MTOPR			;READ THE LINK DATA MTOPR
	 ERJMP RTNERR		;ERROR ON JSYS
	RETSKP			;DONE, RETURN



RTNERR:				;HERE TO HANDLE JSYS ERROR
	MOVX   T2,.RTNER	;GET DYNETS ERROR CODE
	RETBAD ERRLNK		;STORE IT IN LCB



	PAGE
	SUBTTL RUSLNK - READ USER ID FOR LINK
;
;RUSLNK - ROUTINE TO READ USER ID ASSOCIATED WITH LCB'S LINK
;
;ACCEPTS Q1(LCBPTR)/ POINTER TO LCB
;
;	CALL RUSLNK
;
;RETURNS+1: FAILURE
;	+2: SUCCESS
;
RUSLNK:				;ENTRY
	LOAD   T1,LCBJFN	;GET JFN FOR THIS LINK
	MOVX   T2,.MORUS	;FUNCTION CODE FOR READ USER ID
	LOAD   T3,LCBUSE	;STRING POINTER FOR USER ID
	LOAD   T4,LCBSVR	;GET SERVER FLAG
	SKIPE  T4		;FUNCTION VALID ONLY FOR SERVER
	MTOPR			;READ THE LINK DATA MTOPR
	 ERJMP RUSERR		;ERROR ON JSYS
	RETSKP			;DONE, RETURN



RUSERR:				;HERE TO HANDLE JSYS ERROR
	MOVX   T2,.RUSER	;GET DYNETS ERROR CODE
	RETBAD ERRLNK		;STORE IT IN LCB



	PAGE
	SUBTTL RPWLNK - READ PASSWORD FOR LINK
;
;RPWLNK - ROUTINE TO READ PASSWORD ASSOCIATED WITH LCB'S LINK
;
;ACCEPTS Q1(LCBPTR)/ POINTER TO LCB
;
;	CALL RPWLNK
;
;RETURNS+1: FAILURE
;	+2: SUCCESS
;
RPWLNK:				;ENTRY
	LOAD   T1,LCBJFN	;GET JFN FOR THIS LINK
	MOVX   T2,.MORPW	;FUNCTION CODE FOR READ PASSWORD
	LOAD   T3,LCBPAS	;STRING POINTER FOR PASSWORD
	LOAD   T4,LCBSVR	;GET SERVER FLAG
	SKIPE  T4		;FUNCTION VALID ONLY FOR SERVER
	MTOPR			;READ THE LINK DATA MTOPR
	 ERJMP RPWERR		;ERROR ON JSYS
	STOR   T4,LCBPWC	;STORE PASSWORD BYTE COUNT
	RETSKP			;DONE, RETURN



RPWERR:				;HERE TO HANDLE JSYS ERROR
	MOVX   T2,.RPWER	;GET DYNETS ERROR CODE
	RETBAD ERRLNK		;STORE IT IN LCB



	PAGE
	SUBTTL RACLNK - READ ACCOUNT FOR LINK
;
;RACLNK - ROUTINE TO READ ACCOUNT ASSOCIATED WITH LCB'S LINK
;
;ACCEPTS Q1(LCBPTR)/ POINTER TO LCB
;
;	CALL RACLNK
;
;RETURNS+1: FAILURE
;	+2: SUCCESS
;
RACLNK:				;ENTRY
	LOAD   T1,LCBJFN	;GET JFN FOR THIS LINK
	MOVX   T2,.MORAC	;FUNCTION CODE FOR READ ACCOUNT STRING
	LOAD   T3,LCBACT	;STRING POINTER FOR ACCOUNT STRING
	LOAD   T4,LCBSVR	;GET SERVER FLAG
	SKIPE  T4		;FUNCTION VALID ONLY FOR SERVER
	MTOPR			;READ THE LINK DATA MTOPR
	 ERJMP RACERR		;ERROR ON JSYS
	RETSKP			;DONE, RETURN



RACERR:				;HERE TO HANDLE JSYS ERROR
	MOVX   T2,.RACER	;GET DYNETS ERROR CODE
	RETBAD ERRLNK		;STORE IT IN LCB



	PAGE
	SUBTTL RDALNK - READ OPTIONAL DATA FOR LINK
;
;RDALNK - ROUTINE TO READ THE OPTIONAL DATA FOR A LINK
;
;ACCEPTS Q1(LCBPTR)/ POINTER TO LCB
;
;	CALL RDALNK
;
;RETURNS+1: FAILURE
;	+2: SUCCESS
;
RDALNK:				;ENTRY
	LOAD   T1,LCBJFN	;GET JFN FOR THIS LINK
	MOVX   T2,.MORDA	;FUNCTION CODE FOR READ OPTIONAL DATA
	LOAD   T3,LCBOPT	;STRING POINTER FOR OPTIONAL DATA
	MTOPR			;READ THE LINK DATA MTOPR
	 ERJMP RDAERR		;ERROR ON JSYS
	STOR   T4,LCBROC	;STORE RECEIVED OPTIONAL DATA BYTE COUNT
	RETSKP			;DONE, RETURN



RDAERR:				;HERE TO HANDLE JSYS ERROR
	MOVX   T2,.RDAER	;GET DYNETS ERROR CODE
	RETBAD ERRLNK		;STORE IT IN LCB



	PAGE
	SUBTTL RCNLNK - READ CONNECT OBJECT NUMBER FOR LINK
;
;RCNLNK - ROUTINE TO READ CONNECT OBJECT NUMBER ASSOCIATED WITH LCB'S LINK
;
;ACCEPTS Q1(LCBPTR)/ POINTER TO LCB
;
;	CALL RCNLNK
;
;RETURNS+1: FAILURE
;	+2: SUCCESS
;
RCNLNK:				;ENTRY
	LOAD   T1,LCBJFN	;GET JFN FOR THIS LINK
	MOVX   T2,.MORCN	;FUNCTION CODE FOR READ CONNECT OBJECT NUMBER
	LOAD   T3,LCBSVR	;GET SERVER FLAG
	SKIPE  T3		;FUNCTION VALID ONLY FOR SERVER
	MTOPR			;READ THE LINK DATA MTOPR
	 ERJMP RCNERR		;ERROR ON JSYS
	STOR   T3,LCBCON	;STORE OBJECT NUMBER IN LCB
	RETSKP			;DONE, RETURN



RCNERR:				;HERE TO HANDLE JSYS ERROR
	MOVX   T2,.RCNER	;GET DYNETS ERROR CODE
	RETBAD ERRLNK		;STORE IT IN LCB



	PAGE
	SUBTTL RSSLNK - READ SEGMENT SIZE FOR LINK
;
;RSSLNK - ROUTINE TO READ SEGMENT SIZE FOR A LINK
;
;ACCEPTS Q1(LCBPTR)/ POINTER TO LCB
;
;	CALL RSSLNK
;
;RETURNS+1: FAILURE
;	+2: SUCCESS
;
RSSLNK:				;ENTRY
	LOAD   T1,LCBJFN	;GET THE JFN FOR THIS LINK
	MOVX   T2,.MORSS	;READ SEGMENT SIZE FUNCTION CODE
	MTOPR			;READ LINK STATUS MTOPR
	 ERJMP RSSERR		;JSYS ERROR
	STOR   T3,LCBSGS	;STORE SEGMENT SIZE IN LCB
	RETSKP			;GOOD RETURN



RSSERR:				;HERE TO HANDLE JSYS ERROR
	MOVX   T2,.RSSER	;GET DYNETS ERROR CODE
	RETBAD ERRLNK		;STORE IT IN LCB



	PAGE
	SUBTTL ACPLNK - ACCEPT A LOGICAL LINK CONNECTION
;
;ACPLNK - ROUTINE TO ACCEPT A LOGICAL LINK CONNECTION
;
;ACCEPTS Q1(LCBPTR)/POINTER TO LCB 
;
;	CALL ACPLNK
;
;RETURNS+1: FAILURE
;	+2: SUCCESS
;
ACPLNK:				;ENTRY
	SKIPN  LCBPTR		;SHOULDN'T BE HERE WITH NO LCB'S
	PRTERR (<INVALID LCB POINTER>,<HALTF>)
	MOVX   (T1,<ASCIZ/LCB/>) ;GET THE VALID LCB ID
	OPSTRM (<CAME T1,>,LCBID) ;SKIP IF GOOD LCB
	PRTERR (<INVALID LCB FOUND>,<HALTF>)
	LOAD   (T1,LCBJFN)	;GET JFN FOR THIS LINK
	MOVX   (T2,.MOCC)	;ACCEPT CONNECT FUNCTION CODE
	LOAD   (T3,LCBOSP)	;POINTER TO OPTIONAL DATA TO SEND
	SETZI  T4,0		;CLEAR TO ZERO
	SKIPE  T3		;SKIP IF NO ACCEPT DATA
	LOAD   T4,LCBSOC	;GET SEND OPTIONAL DATA BYTE COUNT 
	MTOPR			;DO THE MTOPR TO ACCEPT CONNECTION
	 ERJMP ACPERR		;ERROR ON JSYS
	RETSKP			;DONE, RETURN



ACPERR:				;HERE TO HANDLE JSYS ERROR
	MOVX   T2,.ACPER	;GET DYNETS ERROR CODE
	RETBAD ERRLNK		;STORE IT IN LCB



	PAGE
	SUBTTL SNDLNK - SEND OUTPUT FOR AN LCB
;
;SNDLNK - SENDS OUTPUT MESSAGES ON THE SEND MESSAGE QUEUE FOR A PARTICULAR
; LINK CONTROL BLOCK
;
;ACCEPTS IN (LCBPTR): POINTER TO LCB FOR WHICH ACTION IS REQUESTED
;
;	CALL SNDLNK
;
;RETURNS+1: FAILURE
;	+2: SUCCESS
;
SNDLNK:				;ENTRY
	LOAD   (T1,LCBJFN)	;GET JFN FOR THIS LINK
	LOAD   (T2,LCBSMQ)	;GET POINTER TO NEXT MESSAGE IN QUEUE
	OPSTR  (<MOVN T3,>,LCBCSZ) ;GET MESSAGE SIZE
	SETZI  T4,0
	JE     (LCBULM,,SNDLN1)	;DO LOGICAL MSG ??
	SOUTR			;YES, SEND THE MESSAGE OUT
	 ERJMP SNDERR		;ERROR ON JSYS
	INCR   LCBSND		;BUMP TOTAL SEND COUNT
	OPSTR <ADD T3,>,LCBCSZ	;GET BYTES SENT
	OPSTRM <ADDM T3,>,LCBSBC ;ADD TO SEND BYTE COUNT ON LINK
	INCR   LCBCUR		;BUMP CURRENT OUTSTANDING COUNT
;	AOS    TMSGCT		;BUMP GLOBAL MESSAGE COUNT
;	MOVE   T1,TMSGCT	;GET THE NEW COUNT
;	IDIVI  T1,ITMSCT	;GET MULTIPLE OF ITMSCT
;	CAIN  T2,0		;READY TO PRINT MESSAGE ?
;	CALL   PRTCNT		;YES, GO PRINT TOTAL MESSAGES COUNT
	RETSKP			;RETURN TO CALLER
SNDLN1:				;HERE SEND JUST STRING
	SOUT			;SEND THE STRING
	 ERJMP SNDERR
	OPSTR <ADD T3,>,LCBCSZ	;GET BYTES SENT
	OPSTRM <ADDM T3,>,LCBSBC ;ADD TO SEND BYTE COUNT ON LINK
	RETSKP			;RETURN, WITHOUT BUMPING COUNTS



SNDERR:				;HERE TO HANDLE JSYS ERROR
	MOVX   T2,.SNDER	;GET DYNETS ERROR CODE
	RETBAD ERRLNK		;STORE IT IN LCB



	PAGE
	SUBTTL RCVLNK - RECEIVE MESSAGE ON LOGICAL LINK CONNECTION
;
;RCVLNK - ROUTINE TO RECEIVE ON A LOGICAL LINK CONNECTION
;
;ACCEPTS IN (LCBPTR): POINTER TO LCB FOR WHICH ACTION IS REQUESTED
;
;	CALL RCVLNK
;
;RETURNS+1: FAILURE
;	+2: SUCCESS
;
RCVLNK:				;ENTRY
	LOAD   (T1,LCBJFN)	;GET THIS LINKS JFN
	LOAD   T2,LCBRMQ	;GET POINTER TO RECEIVE BUFFER
	OPSTR  <MOVN T3,>,LCBCSZ ;GET NEGATIVE OF NUMBER OF BYTES TO READ
	JE     (LCBULM,,RCVLN1)	;DO LOGICAL MSG ??
	SINR			;YES, READ MESSAGE
	 ERJMP RCVERR
	INCR   LCBRCV		;BUMP RECEIVE MESSAGE COUNT
	OPSTR <ADD T3,>,LCBCSZ	;GET BYTES RECEIVED
	OPSTRM <ADDM T3,>,LCBRBC ;ADD TO RECEIVE BYTE COUNT ON LINK
	DECR   LCBCUR		;DECREMENT CURRENT OUTSTANDING COUNT
	RETSKP			;DONE, RETURN GOOD
RCVLN1:				;HERE TO JUST SEND STRING
	SIN			;READ A STRING
	 ERJMP RCVERR		;GO TO ERROR ROUTINE ON JSYS FAILURE
	OPSTR <ADD T3,>,LCBCSZ	;GET BYTES RECEIVED
	OPSTRM <ADDM T3,>,LCBRBC ;ADD TO RECEIVE BYTE COUNT ON LINK
	RETSKP			;DONE, RETURN GOOD



RCVERR:				;HERE TO HANDLE JSYS ERROR
	MOVX   T2,.RCVER	;GET DYNETS ERROR CODE
	RETBAD ERRLNK		;STORE IT IN LCB



	PAGE
	SUBTTL CLZLNK - CLOSE A LOGICAL LINK CONNECTION
;
;CLZLNK - ROUTINE TO DO AN IMPLICIT REJECT OR SYNCHRONOUS DISCONNECT
;	   ON A LOGICAL LINK
;
;ACCEPTS Q1(LCBPTR): POINTER TO LCB
;
;	CALL CLZLNK
;
;RETURNS+1: FAILURE
;	+2: SUCCESS
;
CLZLNK:				;ENTRY
	SKIPN  LCBPTR		;SHOULDN'T BE HERE WITH NO LCB'S
	PRTERR (<INVALID LCB POINTER>,<HALTF>)
	MOVX   (T1,<ASCIZ/LCB/>) ;GET THE VALID LCB ID
	OPSTRM (<CAME T1,>,LCBID) ;SKIP IF GOOD LCB
	PRTERR (<INVALID LCB FOUND>,<HALTF>)
	LOAD   (T1,LCBJFN)	;GET JFN FOR THIS LINK
	LOAD   (T2,LCBFLG)	;GET LCB FLAG WORD
	TXNE   T2,LCB%RJ	;SKIP IF RELEASE JFN FLAG NOT ON
	TXO    T1,CO%NRJ	;SET DO NOT RELEASE JFN 
	TXNE   T2,LCB%AB	;SKIP IF ABORT FLAG NOT ON
	TXO    T1,CZ%ABT	;SET ABORT FLAG
	CLOSF			;DO THE CLOSE
	 ERJMP  CLZERR		;ERROR ON JSYS
	RETSKP			;DONE, RETURN



CLZERR:				;HERE TO HANDLE JSYS ERROR
	MOVX   T2,.CLZER	;GET DYNETS ERROR CODE
	RETBAD ER1LNK		;STORE IT IN LCB



	PAGE
	SUBTTL REJLNK - REJECT OR EXPLICIT CLOSE FOR LINK
;
;REJLNK - ROUTINE TO DO AN EXPLICIT CLOSE OR REJECT FOR A LOGICAL LINK
;
;ACCEPTS Q1(LCBPTR): POINTER TO LCB
;
;	CALL REJLNK
;
;RETURNS+1: FAILURE
;	+2: SUCCESS
;
REJLNK:				;ENTRY
	SKIPN  LCBPTR		;SHOULDN'T BE HERE WITH NO LCB'S
	PRTERR (<INVALID LCB POINTER>,<HALTF>)
	MOVX   (T1,<ASCIZ/LCB/>) ;GET THE VALID LCB ID
	OPSTRM (<CAME T1,>,LCBID) ;SKIP IF GOOD LCB
	PRTERR (<INVALID LCB FOUND>,<HALTF>)
	LOAD   (T1,LCBJFN)	;GET JFN FOR THIS LINK
	MOVX   (T2,.MOCLZ)	;SET ABORT FUNCTION CODE
	LOAD   (T3,LCBRSN)	;GET ABORT REASON CODE
	LOAD   (T4,LCBFLG)	;GET LCB FLAG WORD
	TXNE   (T4,LCB%AB)	;ABORT ??
	HRLI   T2,(T3)		;YES, PUT REASON CODE IN LH T2
	LOAD   (T3,LCBOSP)	;POINTER TO OPTIONAL DATA TO SEND
	SETZI  T4,0		;CLEAR TO ZERO
	SKIPE  T3		;SKIP IF NO ACCEPT DATA
	LOAD   T4,LCBSOC	;GET SEND OPTIONAL DATA BYTE COUNT 
	MTOPR			;DO MTOPR TO DO CLOSE/REJECT
	 ERJMP REJERR		;ERROR ON JSYS
	RETSKP			;DONE, RETURN



REJERR:				;HERE TO HANDLE JSYS ERROR
	MOVX   T2,.REJER	;GET DYNETS ERROR CODE
	RETBAD ERRLNK		;STORE IT IN LCB



	PAGE
	SUBTTL SIMLNK - SEND INTERRUPT MESSAGE ON LINK
;
;SIMLNK - ROUTINE TO SEND AN INTERRUPT MESSAGE ON A LOGICAL LINK
;
;ACCEPTS Q1(LCBPTR): POINTER TO LCB
;
;	CALL SIMLNK
;
;RETURNS+1: FAILURE
;	+2: SUCCESS
;
SIMLNK:				;ENTRY
	SKIPN  LCBPTR		;SHOULDN'T BE HERE WITH NO LCB'S
	PRTERR (<INVALID LCB POINTER>,<HALTF>)
	MOVX   (T1,<ASCIZ/LCB/>) ;GET THE VALID LCB ID
	OPSTRM (<CAME T1,>,LCBID) ;SKIP IF GOOD LCB
	PRTERR (<INVALID LCB FOUND>,<HALTF>)

SIMLN1:				;HERE TO RETRY
	LOAD   (T1,LCBJFN)	;GET JFN FOR THIS LINK
	MOVX   T2,.MOSIM	;SET SEND INTERRUPT MESSAGE FUNCTION CODE
	LOAD   (T3,LCBPIM)	;GET POINTER TO INTERRUPT MESSAGE
	LOAD   (T4,LCBSZI)	;GET SIZE OF INTERRUPT MESSAGE
	MTOPR			;DO MTOPR TO SEND INTERRUPT MESSAGE
	 ERJMP SIMERR		;ERROR ON JSYS
	INCR   LCBISC		;BUMP THE INTERRUPT MESSAGE SEND COUNT
	INCR   LCBIOC		;BUMP THE OUTSTANDING COUNT
	RETSKP			;DONE, RETURN



SIMERR:				;HERE TO HANDLE JSYS ERROR
	MOVX   T2,.SIMER	;GET DYNETS ERROR CODE
	CALL ERRLNK		;STORE MONITOR & DYNETS ERROR CODE IN LCB
	LOAD T1,LCBLER		;GET MONITOR ERROR
	CAIE T1,DCNX14		;IS PREV INT MSG STILL UNREAD ?
	RET			;NO, REAL ERROR
	JRST SIMLN1		;YES, JUST TRY AGAIN



	PAGE
	SUBTTL RIMLNK - RECEIVE INTERRUPT MESSAGE ON LINK
;
;RIMLNK - ROUTINE TO RECEIVE AN INTERRUPT MESSAGE ON A LOGICAL LINK
;
;ACCEPTS Q1(LCBPTR): POINTER TO LCB
;
;	CALL RIMLNK
;
;RETURNS+1: FAILURE
;	+2: SUCCESS
;
RIMLNK:				;ENTRY
	SKIPN  LCBPTR		;SHOULDN'T BE HERE WITH NO LCB'S
	PRTERR (<INVALID LCB POINTER>,<HALTF>)
	MOVX   (T1,<ASCIZ/LCB/>) ;GET THE VALID LCB ID
	OPSTRM (<CAME T1,>,LCBID) ;SKIP IF GOOD LCB
	PRTERR (<INVALID LCB FOUND>,<HALTF>)
	MOVX   (T1,NBIMSG)	;GET NUMBER OF BYTES PER INTERRUPT MESSAGE
	IDIVI  T1,4		;NUMBER OF WORDS FOR 8 BIT BYTES
	CALL   M%GMEM		;GET STORAGE FOR INTERRUPT MESSAGE
	HRLI   T2,(POINT 8,0)	;MAKE RETURNED ADDRESS 8 BIT BYTE POINTER
	STOR   (T2,LCBPIM)	;STORE POINTER TO INTERRUPT MESSAGE
	LOAD   (T1,LCBJFN)	;GET JFN FOR THIS LINK
	MOVX   (T2,.MORIM)	;SET READ INTERRUPT MESSAGE FUNCTION CODE
	LOAD   (T3,LCBPIM)	;GET POINTER TO INTERRUPT MESSAGE
	MTOPR			;DO MTOPR TO RECEIVE INTERRUPT MESSAGE
	 ERJMP RIMERR		;ERROR ON JSYS
	STOR   T4,LCBSZI	;STORE SIZE OF INTERRUPT MSG OBTAINED
	INCR   LCBIRC		;BUMP THE INTERRUPT MESSAGE RECEIVE COUNT
	DECR   LCBIOC		;DECREMENT THE OUTSTANDING COUNT
	RETSKP			;DONE, RETURN



RIMERR:				;HERE TO HANDLE JSYS ERROR
	MOVX   T2,.RIMER	;GET DYNETS ERROR CODE
	RETBAD ERRLNK		;STORE IT IN LCB



	PAGE
	SUBTTL STXXXX/CLXXXX - SET AND CLEAR INTERRUPT CHANNELS
;
;STXXXX/CLXXXX - ROUTINES TO SET AND CLEAR THE INTERRUPT CHANNELS FOR LOGICAL LINKS
;STCICS - SET CONNECTION EVENT FOR SERVER
;STCICT - SET CONNECTION EVENT FOR TARGET
;STDACS - SET DATA EVENT FOR SERVER
;STDACT - SET DATA EVENT FOR TARGET
;STIMCS - SET INTERRUPT MESSAGE EVENT FOR SERVER
;STIMCT - SET INTERRUPT MESSAGE EVENT FOR TARGET
;CLCICS - CLEAR CONNECTION EVENT FOR SERVER
;CLCICT - CLEAR CONNECTION EVENT FOR TARGET
;CLDACS - CLEAR DATA EVENT FOR SERVER
;CLDACT - CLEAR DATA EVENT FOR TARGET
;CLIMCS - CLEAR INTERRUPT MESSAGE EVENT FOR SERVER
;CLIMCT - CLEAR INTERRUPT MESSAGE EVENT FOR TARGET
;
;	NOTE: THESE SYMBOLS SPECIFY THE INTERRUPT CHANNELS USED
;
;		COCHNS - CONNECTION EVENT INTERRUPT FOR SERVER LINKS
;		COCHNT - CONNECTION EVENT INTERRUPT FOR TARGET LINKS
;		DACHNS - DATA EVENT INTERRUPT FOR SERVER LINKS
;		DACHNT - DATA EVENT INTERRUPT FOR TARGET LINKS
;		IMCHNS - INTERRUPT MESSAGE EVENT INTERRUPT FOR SERVER LINKS
;		IMCHNT - INTERRUPT MESSAGE EVENT INTERRUPT FOR TARGET LINKS
;
;ACCEPTS LCBPTR: POINTER TO LCB
;
;	CALL STXXXX
;	CALL CLXXXX
;
;RETURNS+1:FAILURE
;	+2:SUCCESS
;



	PAGE
STCICS:				;ENTRY TO SET CONNECT REQUEST INTERRUPT CHAN
	MOVX   T3,<FLD(COCHNS,MO%CDN)+FLD(.MONCI,MO%INA)+FLD(.MONCI,MO%DAV)>
	JRST   SETCLR		;SKIP OTHER ENTRIES
STCICT:				;ENTRY TO SET CONNECTION EVENT CHANNEL
	MOVX   T3,<FLD(COCHNT,MO%CDN)+FLD(.MONCI,MO%INA)+FLD(.MONCI,MO%DAV)>
	JRST   SETCLR		;SKIP OTHER ENTRIES
STDACS:				;ENTRY TO SET DATA AVAILABLE CHAN
	MOVX   T3,<FLD(.MONCI,MO%CDN)+FLD(.MONCI,MO%INA)+FLD(DACHNS,MO%DAV)>
	JRST   SETCLR		;SKIP OTHER ENTRIES
STDACT:				;ENTRY TO SET DATA AVAILABLE CHAN
	MOVX   T3,<FLD(.MONCI,MO%CDN)+FLD(.MONCI,MO%INA)+FLD(DACHNT,MO%DAV)>
	JRST   SETCLR		;SKIP OTHER ENTRIES
STIMCS:				;ENTRY TO SET INTERRUPT MESSAGE CHAN
	MOVX   T3,<FLD(.MONCI,MO%CDN)+FLD(IMCHNS,MO%INA)+FLD(.MONCI,MO%DAV)>
	JRST   SETCLR		;SKIP OTHER ENTRIES
STIMCT:				;ENTRY TO SET INTERRUPT MESSAGE CHAN
	MOVX   T3,<FLD(.MONCI,MO%CDN)+FLD(IMCHNT,MO%INA)+FLD(.MONCI,MO%DAV)>
	JRST   SETCLR		;SKIP OTHER ENTRIES
CLCICS:				;ENTRY TO CLEAR CONNECT REQUEST CHAN
CLCICT:
	MOVX   T3,<FLD(.MOCIA,MO%CDN)+FLD(.MONCI,MO%INA)+FLD(.MONCI,MO%DAV)>
	JRST   SETCLR		;SKIP OTHER ENTRIES
CLDACS:				;ENTRY TO CLEAR DATA AVAILABLE CHAN
CLDACT:
	MOVX   T3,<FLD(.MONCI,MO%CDN)+FLD(.MONCI,MO%INA)+FLD(.MOCIA,MO%DAV)>
	JFCL			;SKIP OTHER ENTRIES
CLIMCS:				;ENTRY TO CLEAR INTERRUPT MESSAGE CHAN
CLIMCT:
	MOVX   T3,<FLD(.MONCI,MO%CDN)+FLD(.MOCIA,MO%INA)+FLD(.MONCI,MO%DAV)>
	PAGE
SETCLR:				;COMMON ENTRY
	SKIPN  LCBPTR		;SKIP IF GOOD LCB POINTER
	PRTERR (<INVALID LCB POINTER>,<HALTF>)
	SAVEAC <T1,T2,T3>	;SAVE AC'S
	MOVX   T1,<ASCIZ/LCB/>	;GET THE ID FOR AN LCB
	OPSTRM (<CAME T1,>,LCBID) ;SKIP IF IT MATCHES
	PRTERR (<INVALID LCB FOUND>,<HALTF>)
	LOAD   (T1,LCBJFN)	;GET THE JFN FOR THIS LCB
	MOVX   (T2,.MOACN)	;GET THE CODE FOR ASSIGN INTERRUPT CHAN
	MTOPR			;DO THE JSYS
	 ERJMP SETERR		;ERROR ON FAILURE
	RETSKP			;DONE, RETURN GOOD



SETERR:				;HERE TO HANDLE JSYS ERROR
	MOVX   T2,.SETER	;GET DYNETS ERROR CODE
	RETBAD ERRLNK		;STORE IT IN LCB



	PAGE
	SUBTTL DCXERR - DECNET ERROR MESSAGE ROUTINE

;ACCEPTS: T1/ DESTINATION POINTER
;	  T2/ DECNET ERROR NUMBER
;
;	CALL DCXERR
;
;RETURNS+1: ALWAYS

	DXTBSZ==^D50		;SIZE OF ERROR TABLE

DCXERR:				;ENTRY POINT
	HRRZI T3,(T2)		;ISOLATE REASON CODE
	CAIL T3,0		;RANGE CHECK ERROR NUMBER
	CAIL T3,DXTBSZ		;BETWEEN 0 AND DEFINED TABLE SIZE
	SKIPA T2,[POINT 7,[ASCIZ\ERROR OUT OF RANGE\]] ;IF NOT !
	MOVE T2,DCXTBL(T3)	;GET POINTER TO ERROR TEXT
	SETZI T3,0		;STOP ON NULL
	SETZI T4,0
	SOUT
	RET

;MACRO TO MAKE ENTRIES IN DCX ERROR TABLE

DEFINE DCXER (CODE,TEXT,BASE<DCXTBL>),<
	.ORG BASE+CODE
	POINT 7,[ASCIZ\TEXT\]
	.ORG
>
DCXTBL:				;DECNET ERROR TEXT TABLE

REPEAT DXTBSZ,<			;MAKE TABLE SPACE & UNDEFINED ENTRIES
	POINT 7,[ASCIZ\UNDEFINED NSP ERROR\]>

	DCXER (.DCX0,<NO SPECIAL ERROR>)
	DCXER (.DCX1,<RESOURCE ALLOCATION FAILURE>)
	DCXER (.DCX2,<DESTINATION NODE DOES NOT EXIST>)
	DCXER (.DCX3,<NODE SHUTTING DOWN>)
	DCXER (.DCX4,<DESTINATION PROCESS DOES NOT EXIST>)
	DCXER (.DCX5,<INVALID NAME FIELD>)
	DCXER (.DCX9,<USER ABORT>)
	DCXER (.DCX11,<UNDEFINED ERROR>)
	DCXER (.DCX21,<CI WITH ILLEGAL DESTINATION ADDRESS>)
	DCXER (.DCX22,<CC WITH ILLEGAL DESTINATION ADDRESS>)
	DCXER (.DCX23,<CI OR CC WITH ZERO SOURCE ADDRESS>)
	DCXER (.DCX32,<TOO MANY CONNECTIONS TO NODE>)
	DCXER (.DCX33,<TOO MANY CONNECTIONS TO DESTINATION PROCESS>)
	DCXER (.DCX34,<ACCESS NOT PERMITTED>)
	DCXER (.DCX35,<LOGICAL LINK SERVICES MISMATCH>)
	DCXER (.DCX36,<INVALID ACCOUNT>)
	DCXER (.DCX37,<SEGSIZE TOO SMALL>)
	DCXER (.DCX38,<PROCESS ABORTED>)
	DCXER (.DCX39,<NO PATH TO DESTINATION NODE>)
	DCXER (.DCX40,<LINK ABORTED DUE TO DATA LOSS>)
	DCXER (.DCX41,<DESTINATION PROCESS DOES NOT EXIST>)
	DCXER (.DCX42,<CONFIRMATION IF DI>)
	DCXER (.DCX43,<IMAGE DATA FIELD TOO LONG>)

	PAGE
	SUBTTL ERRLNK - JSYS ERROR ON LINK ROUTINE
;
;ERRLNK - ROUTINE TO HANDLE "LINK JSYS ERRORS" AND PROVIDE COMMON 
;	ERROR HANDLING FOR NETWORK ERROR CONDITIONS
;
;ACCEPTS: LCBPTR/ POINTER TO LCB
;
;	ERCAL ERRLNK
;	CALL  ERRLNK
;	ERJMP ERRLNK
;	CALLRET ERRLNK
;
;RETURNS+1: ALWAYS, WITH ERROR INFO STORED IN LCBLER
;
ERRLNK:				;ENTRY
				;ENTRY POINT FOR JSYS' WITH +1 ALWAYS RETURN
	PUSH   P,T1		;SAVE T1
	PUSH   P,T2		;SAVE T2
				;GET THE LAST MONITOR ERROR CODE
	MOVX   T1,.FHSLF	;THIS PROCESS
	GETER			;GET IT FROM MONITOR
	 JSHLT (<GETER FAILED>)	;SHOULD NEVER GET HERE !!!!!
	HRLI   T2,0		;CLEAR THE PROCESS HANDLE 
	MOVE   T1,T2		;COPY ERROR CODE TO T1
	POP    P,T2		;RESTORE T2
	CALL   ER1LNK		;STORE ERROR CODE IN T2
	POP    P,T1		;RESTORE T1
	RET			;DONE, RETURN


ER1LNK:				;ENTRY POINT FOR JSYS' WITH ERROR IN AC1
	STOR   T1,LCBLER	;STORE MONITOR ERROR IN LCB
	STOR   T2,LCBDER	;STORE DYNETS ERROR CODE IN LCB
	RET			;DONE, RETURN

ER2LNK:				;ENTRY POINT FOR JSYS' WITH ERROR IN AC2
	STOR   T1,LCBDER	;STORE DYNETS ERROR CODE IN LCB
	STOR   T2,LCBLER	;STORE MONITOR ERROR IN THE LCB
	RET			;DONE, RETURN


ERXLNK:				;ENTRY TO PRINT DYNETS/MONITOR STRINGS
	LOAD   T2,LCBDER	;GET DYNETS ERROR
	LOAD   T1,LCBLER	;GET THE DYNETS/MONITOR ERROR CODES
	HRLI   T1,(T2)		;PUT BOTH IN 1
	CALL   DYXERR		;CALL ROUTINE TO PRINT DYNETS ERROR MSG
	RET			;DONE, RETURN
	PAGE
	SUBTTL ILKDTA - INITIALIZE THE LINK DATA AREA
;
;ILKDTA - ROUTINE TO GET STORAGE FOR, AND SET UP THE STRING POINTERS
;	FOR THE LINK DATA AREA ASSOCIATED WITH A LINKS LCB
;
;ACCEPTS Q1(LCBPTR)/ POINTER TO LCB
;
;	CALL ILKDTA
;
;RETURNS+1: FAILURE, IF COULD NOT OBTAIN STORAGE
;	+2: SUCCESS
;
ILKDTA:				;ENTRY
	JN     (LCBHST,,ILKDT1)	;ALREADY GOT A LINK DATA AREA ?
	MOVEI  T1,NWLKDA	;NO, GET SIZE OF LINK DATA AREA
	CALL   M%GMEM		;GET STORAGE FOR STRINGS
	JUMPE  [RET]		;TAKE FAILURE RETURN, NO STORAGE
	HRLI   T2,(POINT 7,0)	;MAKE IT A 7 BIT BYTE POINTER
	STOR   T2,LCBHST	;POINTER TO HOST STRING
	ADDI   T2,NWLKHN	;NUMBER OF WORDS FOR HOST STRING
	STOR   T2,LCBODS	;POINTER TO OBJECT-DESCRIPTOR STRING
	ADDI   T2,NWLKOD	;NUMBER OF WORDS FOR OBJECT DESCRIPTOR
	STOR   T2,LCBTSK	;POINTER TO TASK NAME STRING
	ADDI   T2,NWLKTS	;NUMBER OF WORDS FOR TASK NAME STRING
	STOR   T2,LCBUSE	;POINTER TO USER ID STRING
	ADDI   T2,NWLKUI	;NUMBER OF WORDS FOR USERID STRING
	HRLI   T2,(POINT 8,0)	;8 BIT BYTES FOR PASSWORD
	STOR   T2,LCBPAS	;POINTER TO PASSWORD STRING
	ADDI   T2,NWLKPW	;NUMBER OF WORDS FOR PASSWORD
	HRLI   T2,(POINT 7,0)	;7 BIT BYTES FOR ACCOUNT
	STOR   T2,LCBACT	;POINTER TO ACCOUNT STRING
	ADDI   T2,NWLKAC	;NUMBER OF WORDS FOR ACCOUNT
	HRLI   T2,(POINT 8,0)	;8 BIT BYTES FOR OPTIONAL DATA
	STOR   T2,LCBOPT	;POINTER TO OPTIONAL DATA STRING
	ADDI   T2,NWLKOP	;NUMBER OF WORDS FOR OPTIONAL DATA
ILKDT1:				;HERE TO RETURN IF ALREADY INIT
	RETSKP
	PAGE
	SUBTTL PRTOBJ - PRINT HOST-OBJECT-DESCRIPTOR.TASKNAME FOR LINK
;
;PRTOBJ - ROUTINE TO PRINT OUT NAME OF CONNECTOR
;
;ACCEPTS: T1/DESTINATION DESIGNATOR
;	  LCBPTR/ POINTER TO LCB
;
;	CALL PRTOBJ
;
;RETURNS+1: ALWAYS
;
PRTOBJ:				;ENTRY

IFN DTRSW,<			;BEGIN DTR CONDITIONAL CODE
	SKIPN  DTRFLG		;IN DTR MODE ?
	JRST   PRTOBX		;NO, JUST PRINT
	JE     DTRPRT,,R	;PRINT OPTION SET ?, NO, JUST RETURN
				;YES, FALL THROUGH
PRTOBX:
				>;END DTR CONDITIONAL

	HRROI  T1,BUFFER	;POINT TO TEXT BUFFER
	SETZI  T3,0		;TERMINATE ON NULL
	LOAD   T2,LCBHST	;GET POINTER TO HOST NAME
	SOUT
	MOVEI  T2,"-"
	BOUT
	LOAD   T2,LCBODS	;GET POINTER TO OBJECT DESCRIPTOR
	SOUT
	MOVEI  T2,"."
	BOUT
	LOAD   T2,LCBTSK	;GET POINTER TO TASK NAME
	SOUT
	HRROI  T1,BUFFER	;POINT TO BUFFER
	CALL   SNDSTR		;WRITE STRING TO USER
	RET			;DONE, RETURN
	PAGE
	SUBTTL PRTACC - PRINT ACCESS CONTROL INFORMATION FOR LINK
;
;PRTACC - ROUTINE TO OUTPUT THE ACCESS CONTROL INFORMATION
;
;ACCEPTS: T1/ DESTINATION DESIGNATOR
;	  LCBPTR/ POINTER TO LCB
;
;	CALL PRTACC
;
;RETURNS+1: ALWAYS
;
PRTACC:				;ENTRY
IFN DTRSW,<			;BEGIN DTR CONDITIONAL CODE
	SKIPN  DTRFLG		;IN DTR MODE ?
	JRST   PRTACX		;NO, JUST PRINT
	JE     DTRPRT,,R	;PRINT OPTION SET ?, NO, JUST RETURN
				;YES, FALL THROUGH
PRTACX:
				>;END DTR CONDITIONAL
	HRROI  T1,BUFFER	;POINT TO TEXT BUFFER
	HRROI  T2,[ASCIZ/USER-ID(/] ;OUTPUT HEADER
	SETZI  T3,0		;TERMINATE ON NULL
	SOUT			;OUTPUT STRING
	LOAD   T2,LCBUSE	;GET POINTER TO USER ID FOR LINK
	SOUT			;OUTPUT STRING
	HRROI  T2,[ASCIZ/) PASSWORD(/]
	SOUT			;OUTPUT STRING
	LOAD   T2,LCBPAS	;GET POINTER TO PASSWORD FOR LINK
	LOAD   T3,LCBPWC	;GET COUNT OF CHARS IN PASSWORD
	SOUT			;OUTPUT STRING
	HRROI  T2,[ASCIZ/) ACCOUNT(/]
	SOUT			;OUTPUT STRING
	LOAD   T2,LCBACT	;GET POINTER TO ACCOUNT
	SOUT			;OUTPUT STRING
	HRROI  T2,[ASCIZ/)/]
	SOUT
	HRROI  T1,BUFFER	;POINT TO BUFFER
	CALL   SNDSTR		;WRITE TO USER
	RET			;DONE, RETURN
	PAGE
	SUBTTL PRTOPT - PRINT OPTIONAL DATA
;
;PRTOPT - ROUTINE TO PRINT THE OPTIONAL DATA RECEIVED ON EITHER
;	A CONNECTION OR DISCONNECTION
;
;ACCEPTS: T1/ DESTINATION DESIGNATOR
;	    LCBPTR/ POINTER TO LCB
;
;	CALL PRTOPT
;
;RETURNS+1: ALWAYS
;
PRTOPT:				;ENTRY
IFN DTRSW,<			;BEGIN DTR CONDITIONAL CODE
	SKIPN  DTRFLG		;IN DTR MODE ?
	JRST   PRTOPX		;NO, JUST PRINT
	JE     DTRPRT,,R	;PRINT OPTION SET ?, NO, JUST RETURN
				;YES, FALL THROUGH
PRTOPX:
				>;END DTR CONDITIONAL
	STKVAR <OPDPTR,COUNT>	;VARIABLES
	HRROI  T1,BUFFER	;POINT TO TEXT BUFFER
	LOAD   T2,LCBOPT	;GET POINTER TO OPT DATA
	MOVEM  T2,OPDPTR	;SAVE COPY OF POINTER TO OPT DATA
	JUMPE  T2,R		;ANY OPT DATA ?? , NO JUST RETURN
	LOAD   T3,LCBROC	;GET COUNT OF OPT DATA BYTES RECEIVED
	JUMPE  T3,R		;IF ZERO COUNT, JUST RETURN
	MOVEM  T3,COUNT		;SAVE COUNT OF # OF BYTES
AA:	MOVEI  T3,10		;PRINT OCTAL VALUE OF EACH BYTE
	HRLI   T3,(<NO%LFL+NO%MAG+NO%ZRO+FLD(3,NO%COL)>) ;OUTPUT 3 DIGITS
PRTOP1:				;HERE FOR NEXT OPT DATA BYTE
	SOSGE  COUNT		;GOT ALL BYTES ?
	JRST   PRTOP2		;YES, STRING BUILT
	ILDB   T2,OPDPTR	;GET NEXT OPT DATA BYTE
	NOUT			;OUTPUT THE 8 BIT BYTE AS 3 OCTAL DIGITS
	 JSRET (<NOUT FAILED>)
	JRST   PRTOP1		;DO NEXT BYTE


PRTOP2:				;HERE WHEN ALL OPT DATA BYTES IN STRING
	HRROI  T1,BUFFER	;POINT TO BUFFER WHERE STRING IS
	CALLRET SNDSTR		;WRITE IT TO USER
	PAGE
	SUBTTL PRTRSN - PRINT DISCONNECT REASON CODE
;
;PRTRSN - ROUTINE TO OUTPUT THE DISCONNECT REASON CODE
;
;ACCEPTS: T1/ DESTINATION DESIGNATOR
;	  LCBPTR/ POINTER TO LCB
;
;	CALL PRTRSN
;
;RETURNS+1: ALWAYS
;
PRTRSN:				;ENTRY
IFN DTRSW,<			;BEGIN DTR CONDITIONAL CODE
	SKIPN  DTRFLG		;IN DTR MODE ?
	JRST   PRTRSX		;NO, JUST PRINT
	JE     DTRPRT,,R	;PRINT OPTION SET ?, NO, JUST RETURN
				;YES, FALL THROUGH
PRTRSX:
				>;END DTR CONDITIONAL
	HRROI  T1,BUFFER	;POINT TO TEXT BUFFER
	LOAD   T2,LCBSTS	;GET THE STATUS & REASON CODE
	HRRZI  T2,(T2)		;ISOLATE JUST THE REASON CODE
	MOVEI  T3,^D10		;OUTPUT IT IN DECIMAL
	NOUT			;OUTPUT THE NUMBER
	 JSRET (<NOUT FAILED>)
	HRROI T2,[BYTE (7)" ",";"]
	SETZI T3,
	SOUT
	 JSRET (<SOUT FAILED>)
	LOAD T2,LCBRSN		;GET REASON CODE
	CALL DCXERR		;GET NSP ERROR TEXT
	HRROI  T1,BUFFER	;POINT TO BUFFER
	CALLRET SNDSTR		;WRITE TO USER & RETURN
	PAGE
	SUBTTL PRTSGS - PRINT SEGMENT SIZE FOR LINK
;
;PRTSGS - ROUTINE TO PRINT OUT THE SEGMENT SIZE FOR A LINK
;
;ACCEPTS: T1/ DESTINATION DESIGNATOR
;	  LCBPTR/ POINTER TO LCB
;
;	CALL PRTSGS
;
;RETURNS+1: ALWAYS
;
PRTSGS:				;ENTRY
IFN DTRSW,<			;BEGIN DTR CONDITIONAL CODE
	SKIPN  DTRFLG		;IN DTR MODE ?
	JRST   PRTSGX		;NO, JUST PRINT
	JE     DTRPRT,,R	;PRINT OPTION SET ?, NO, JUST RETURN
				;YES, FALL THROUGH
PRTSGX:
				>;END DTR CONDITIONAL
	HRROI  T1,BUFFER	;POINT TO BUFFER
	LOAD   T2,LCBSGS	;GET THE SEGMENT SIZE FROM LCB
	MOVEI  T3,^D10		;PRINT IN DECIMAL
	NOUT
	 JSRET (<NOUT FAILED>)
	HRROI  T1,BUFFER	;GET BUFFER POINTER
	CALLRET SNDSTR		;GO WRITE FOR USER & RETURN
	PAGE
	SUBTTL PRTCNT - PRINT SEND TOTALS MESSAGE
;
;PRTCNT - ROUTINE TO PRINT OUT THE NUMBER OF TOTAL MESSAGES SENT
;
;ACCEPTS: NO ARGUMENTS
;
;	CALL PRTCNT
;
;RETURNS+1: ALWAYS
;
PRTCNT:				;ENTRY
IFN DTRSW,<			;BEGIN DTR CONDITIONAL CODE
	SKIPN  DTRFLG		;IN DTR MODE ?
	JRST   PRTCNX		;NO, JUST PRINT
	JE     DTRPRT,,R	;PRINT OPTION SET ?, NO, JUST RETURN
				;YES, FALL THROUGH
PRTCNX:
				>;END DTR CONDITIONAL
	PRTWRN (<TOTAL MESSAGES SENT = >) ;SEND HEADER
	HRROI  T1,BUFFER	;POINT TO TEXT BUFFER
	MOVE   T2,TMSGCT	;GET TOTAL MSG COUNT
	MOVEI  T3,^D10		;OUTPUT IN DECIMAL
	NOUT			;OUTPUT THE COUNT TO BUFFER
	 JSRET (<NOUT FAILED>)
	HRROI  T1,BUFFER
	CALLRET SNDSTR		;WRITE TO USER

	PAGE
	SUBTTL PRTSND - PRINT SEND COUNT FOR LINK
;
;PRTSND - ROUTINE TO PRINT OUT THE NUMBER OF MESSAGES SENT
;
;ACCEPTS: NO ARGUMENTS
;
;	CALL PRTSND
;
;RETURNS+1: ALWAYS
;
PRTSND:				;ENTRY
IFN DTRSW,<			;BEGIN DTR CONDITIONAL CODE
	SKIPN  DTRFLG		;IN DTR MODE ?
	JRST   PRTSNX		;NO, JUST PRINT
	JE     DTRPRT,,R	;PRINT OPTION SET ?, NO, JUST RETURN
				;YES, FALL THROUGH
PRTSNX:
				>;END DTR CONDITIONAL
	PRTWRN (<MESSAGES SENT = >) ;SEND HEADER
	HRROI  T1,BUFFER	;POINT TO TEXT BUFFER
	LOAD T2,LCBSND		;GET SEND COUNT FOR LINK
	MOVEI  T3,^D10		;OUTPUT IN DECIMAL
	NOUT			;OUTPUT THE COUNT TO BUFFER
	 JSRET (<NOUT FAILED>)
	HRROI  T1,BUFFER
	CALLRET SNDSTR		;WRITE TO USER

	PAGE
	SUBTTL PRTRCV - PRINT RECEIVE MESSAGE COUNT FOR LINK
;
;PRTRCV - ROUTINE TO PRINT OUT THE NUMBER OF MESSAGES RECEIVED
;
;ACCEPTS: NO ARGUMENTS
;
;	CALL PRTRCV
;
;RETURNS+1: ALWAYS
;
PRTRCV:				;ENTRY
IFN DTRSW,<			;BEGIN DTR CONDITIONAL CODE
	SKIPN  DTRFLG		;IN DTR MODE ?
	JRST   PRTRCX		;NO, JUST PRINT
	JE     DTRPRT,,R	;PRINT OPTION SET ?, NO, JUST RETURN
				;YES, FALL THROUGH
PRTRCX:
				>;END DTR CONDITIONAL
	PRTWRN (<MESSAGES RECEIVED = >) ;SEND HEADER
	HRROI  T1,BUFFER	;POINT TO TEXT BUFFER
	LOAD T2,LCBRCV		;GET RECEIVE COUNT FOR LINK
	MOVEI  T3,^D10		;OUTPUT IN DECIMAL
	NOUT			;OUTPUT THE COUNT TO BUFFER
	 JSRET (<NOUT FAILED>)
	HRROI  T1,BUFFER
	CALLRET SNDSTR		;WRITE TO USER


	PAGE
	SUBTTL PRTEFF - PRINT DATA RATE AND EFFICIENCY

PRTEFF:				;HERE TO CALCULATE AND PRINT BAUD RATE FOR LINK
IFN DTRSW,<			;BEGIN DTR CONDITIONAL CODE
	SKIPN  DTRFLG		;IN DTR MODE ?
	JRST   PRTEFX		;NO, JUST PRINT
	JE     DTRPRT,,R	;PRINT OPTION SET ?, NO, JUST RETURN
				;YES, FALL THROUGH
PRTEFX:
				>;END DTR CONDITIONAL
	LOAD T1,DTRFTI		;GET FINISH TIME
	OPSTR <SUB T1,>,DTRSTI	;ELAPSED TIME IN MILLISECONDS
	STOR T1,DTRFTI		;SAVE ELAPSED TIME
	CALL PRTSND		;PRINT SEND COUNTS
	CALL PRTRCV		;PRINT RECEIVE COUNTS
	PRTWRN (<ELAPSED TIME IN MILLISECONDS - >) ;PRINT ELAPSED TIME
	HRROI T1,BUFFER
	LOAD T2,DTRFTI		;RESTORE ELAPSED TIME
	MOVEI T3,^D10
	NOUT
	 JSCONT
	HRROI T1,BUFFER
	CALL SNDSTR
	LOAD T1,LCBSBC		;TOTAL BYTES SENT
	OPSTR <ADD T1,>,LCBRBC	; PLUS RECEIVED
	OPSTR <MUL T1,>,LCBBSZ	;TOTAL BITS SENT + RECEIVED
	MULI T2,^D1000		;BITS X 1000
	OPSTR <DIV T2,>,DTRFTI	;BITS PER SECOND
	MOVE P1,T2		;SAVE BPS
	PRTWRN (<BITS PER SECOND = >)
	HRROI T1,BUFFER
	MOVE T2,P1		;RESTORE BPS
	MOVX T3,^D10
	NOUT
	 JSRET (<NOUT FAILED>)
	HRROI T1,BUFFER
	CALL SNDSTR
	RET

	PAGE
	SUBTTL CLRGJF - CLEAR GTJFN ARGUMENT BLOCK
;
; ROUTINE TO CLEAR GTJFN BLOCK
;
; CALL:		CALL CLRGJF
; RETURNS: +1 ALWAYS

CLRGJF:	MOVE T1,[GJFBLK,,GJFBLK+1] ;SET UP TO CLEAR GTJFN BLOCK
	SETZM GJFBLK		;CLEAR FIRST WORD OF BLOCK
	BLT T1,GJFBLK+GJFSIZ-1	;CLEAR GTJFN BLOCK
	RET			;RETURN TO WHENCE WE CAME ...
	PAGE
	SUBTTL STRCMP - STRING COMPARISON ROUTINE
;
;STRCMP - STRING COMPARE FOR ANY BYTE SIZE STRING, STRICTLY EQUAL COMPARE
;	  NO UPPER/LOWER CASE STUFF
;
;ACCEPTS: T1/ BYTE POINTER TO STRING 
;	  T2/ BYTE POINTER TO STING TO COMPARE WITH
;	  T3/ LENGTH TO COMPARE
;
;	CALL  STRCMP
;
;RETURNS+1: STRINGS UNEQUAL, T1,T2/ UPDATED
;	+2: STRINGS EQUAL
STRCMP:				;ENTRY
	STKVAR <STRPT1,STRPT2> ;VARIABLES
	MOVEM  T1,STRPT1	;SAVE POINTER TO FIRST STRING
	MOVEM  T2,STRPT2	;AND SECOND ALSO
STRCM1:				;LOOP THRU HERE FOR EACH BYTE OF STRINGS
	ILDB   T1,STRPT1	;GET BYTE FROM FIRST STRING
	ILDB   T2,STRPT2	;AND BYTE FROM SECOND
	CAME   T1,T2		;COMPARE THEM
	RET			;NOT EQUAL, RETURN +1
	SOJG   T3,STRCM1	;EQUAL, LOOP FOR NEXT BYTE
	MOVE   T1,STRPT1	;RESTORE UPDATED POINTERS
	MOVE   T2,STRPT2
	RETSKP			;DONE, RETURN
	PAGE
	SUBTTL LOAD11 - LOAD A PDP-11 FORMATTED INTEGER
;
;LOAD11 - ROUTINE TO LOAD AN -11 FORMATTED INTEGER INTO ITS -20 EQUIVALENT
;
;ACCEPTS: T1/ 8 BIT BYTE POINTER TO STRING
;	  T2/ COUNT OF BYTES IN INTEGER
;
;	CALL   LOAD11
;
;RETURNS+1: ALWAYS, T1/ UPDATED POINTER
;		    T2/ INTEGER RESULT
;
LOAD11:				;ENTRY TO LOAD11 ROUTINE
	STKVAR <PTR,INTGR>
	MOVEM  T1,PTR		;SAVE THE POINTER
	SETZM  INTGR		;INIT THE RESULT VARIABLE
	SETZI  T3,0		;INITIALIZE SHIFT VALUE
LDNX11:				;HERE TO GET EACH -11 BYTE
	ILDB   T1,PTR		;GET BYTE
	LSH    T1,(T3)		;SHIFT PROPER NUMBER OF PLACES
	ADDM   T1,INTGR		;ADD IT INTO RESULT
	ADDI   T3,8		;INCREMENT SHIFT AMOUNT TO NEXT HIGHER BYTE
	SOJG   T2,LDNX11	;DECREMENT BYTE COUNT, DONE ? NO, DO NEXT BYTE
	MOVE   T1,PTR		;YES, RESTORE UPDATED POINTER
	MOVE   T2,INTGR		;PICK UP THE RESULT
	RET			;DONE, RETURN
	PAGE
	SUBTTL TCBINI - INITIALIZE THE TCB AND SCB LOOKUP TABLES
;
;
;
TCBINI::			;ENTRY
	SETZM  TCBLKT		;CLEAR FIRST WORD OF TABLE
	HRLZI  T1,TCBLKT	;FROM
	HRRI   T1,TCBLKT+1	;TO
	BLT    T1,TCBLKT+TLTSIZ	;CLEAR TCB LOOKUP TABLE
	MOVEI  T1,TLTSIZ	;SIZE OF TCB LOOKUP TABLE
	MOVEM  T1,TCBLKT	;STORE MAXIMUM SIZE IN TABLE
	SETZM  TCBLST		;CLEAR THE LIST CHAIN ANCHOR
;
;AND SAME FOR SCB TABLE
;
	SETZM  SCBLKT		;CLEAR FIRST WORD OF TABLE
	HRLZI  T1,SCBLKT	;FROM
	HRRI   T1,SCBLKT+1	;TO
	BLT    T1,SCBLKT+SLTSIZ	;CLEAR SCB LOOKUP TABLE
	MOVEI  T1,SLTSIZ	;SIZE OF SCB LOOKUP TABLE
	MOVEM  T1,SCBLKT	;STORE MAXIMUM SIZE IN TABLE
	SETZM  SCBLST		;CLEAR THE LIST CHAIN ANCHOR
	SETZM  CONLST		;CLEAR CONNECT LIST ANCHOR
	SETZM  RCVLST		;CLEAR RECEIVE LIST ANCHOR
	SETZM  RCVLTT
	SETZM  SNDLQH		;CLEAR SEND QUEUE POINTERS
	SETZM  SNDLQT
	RET			;DONE
	PAGE
	SUBTTL ERROR - STANDARD ERROR ROUTINE
;
;
;
ERROR::				;ENTRY
	PUSH   P,T1		;SAVE T1
	MOVEI  T1,.PRIIN	;GET PRIMARY INPUT
	CFIBF			;CLEAR THE INPUT BUFFER TYPEAHEAD
	 ERJMP .+1		;FORGET IT IF ERROR
	MOVEI  T1,.PRIOU	;PRIMARY OUTPUT
	DOBE			;WAIT FOR OUTPUT BUFFER TO EMPTY
	 ERJMP .+1		;FORGET THE ERROR
	
	HRROI  T1,[ASCIZ/
? DYNETS: JSYS ERROR - /]
	CALL   SNDMSG		;OUTPUT ERROR MESSAGE HEADER
	 ERJMP .+1		;FORGET ERROR
	MOVEI  T1,.PRIOU	;PRIMARY OUTPUT
	HRLOI  T2,.FHSLF	;OUR PROCESS, LAST ERROR
	SETZI  T3,0		;WHOLE STRING
	ERSTR			;OUTPUT ERROR STRING
	 JFCL
	 JFCL
	POP    P,T1
	RET			;DONE, RETURN
	PAGE
	SUBTTL PRERRJ - PRINT ERROR FOR JSYS
;
;PRERRJ - ROUTINE TO PRINT ERROR TEXT AND MONITOR ERROR MESSAGE FOR JSYS
;
;	USED IN CONJUNCTION WITH JSCONT, JSRET, & JSHLT MACROS
;
PRERRJ:				;ENTRY
	HRROI  T1,BUFFER	;GET POINTER TO TEXT BUFFER
	HRROI  T2,[ASCIZ/? DYNETS: (JSYS ERROR) /] ;GET POINTER TO HEADER STRING
	SETZI  T3,0		;TERMINATE ON NULL
	SOUT			;OUTPUT STRING
	HRRO   T2,@(P)		;GET POINTER TO ERROR TEXT
	SOUT			;OUTPUT TO BUFFER
	HRROI  T2,[ASCIZ/ AT PC=/] ;STRING
	SOUT			;OUTPUT IT
	HRRZI  T2,@(P)		;GET ADDRESS OF WHERE WE WERE CALLED FROM
	MOVEI  T3,10		;PRINT IN OCTAL
	NOUT
	 JSRET (<NOUT FAILED>)
	HRROI  T2,[ASCIZ/ /]
	SOUT			;BLANK
	HRLOI  T2,.FHSLF	;OUR PROCESS, LAST ERROR
	ERSTR			;OUTPUT MONITOR ERROR STRING
	 JFCL
	 JFCL
	HRROI  T1,BUFFER	;POINTER TO START OF BUFFER
	CALL   SNDMSG		;GO WRITE IT TO USER
	RETSKP			;RETURN SKIP
	PAGE
	SUBTTL PRWARN - PRINT WARNING MESSAGE ROUTINE
;
;PRWARN - ROUTINE TO PRINT A WARNING MESSAGE,
;	USED IN CONJUNCTION WITH PRTWRN MACRO
;
PRWARN:				;ENTRY
IFN DTRSW,<			;BEGIN DTR CONDITIONAL CODE
	SKIPN  DTRFLG		;IN DTR MODE ?
	JRST   PRTWAX		;NO, JUST PRINT
	JE     DTRPRT,,<1(P5)>	;PRINT OPTION SET ?, NO, JUST RETURN
				;YES, FALL THROUGH
PRTWAX:
				>;END DTR CONDITIONAL
	HRROI  T1,BUFFER	;GET POINTER TO TEXT BUFFER
	HRROI  T2,[ASCIZ/% DYNETS: /] ;GET POINTER TO HEADER STRING
	SETZI  T3,0		;TERMINATE ON NULL
	SOUT			;OUTPUT STRING
	HRRO   T2,(P5)		;GET POINTER TO WARNING TEXT
	SOUT			;OUTPUT TO BUFFER
	HRROI  T1,BUFFER	;POINTER TO START OF BUFFER
	CALL   SNDMSG		;GO WRITE IT TO USER
	JRST   1(P5)		;RETURN SKIP
	PAGE
	SUBTTL PRERRN - PRINT ERROR MESSAGE ROUTINE
;
;PRERRN - ROUTINE TO PRINT AN ERROR MESSAGE,
;	USED IN CONJUNCTION WITH PRTERR MACRO
;
PRERRN:				;ENTRY
	HRROI  T1,BUFFER	;GET POINTER TO TEXT BUFFER
	HRROI  T2,[ASCIZ/? DYNETS: /] ;GET POINTER TO HEADER STRING
	SETZI  T3,0		;TERMINATE ON NULL
	SOUT			;OUTPUT STRING
	HRRO   T2,(P5)		;GET POINTER TO ERROR TEXT
	SOUT			;OUTPUT TO BUFFER
	HRROI  T2,[ASCIZ/ AT PC=/] ;STRING
	SOUT			;OUTPUT IT
	HRRZI  T2,(P5)		;GET ADDRESS OF WHERE WE WERE CALLED FROM
	MOVEI  T3,10		;PRINT IN OCTAL
	NOUT
	 JSRET (<NOUT FAILED>)
	HRROI  T1,BUFFER	;POINTER TO START OF BUFFER
	CALL   SNDMSG		;GO WRITE IT TO USER
	JRST   1(P5)		;RETURN SKIP
	PAGE
	SUBTTL DYXERR - DYNETS ERROR HANDLING ROUTINE
;
;DYXERR - ROUTINE TO TYPE OUT A DYNETS ERROR STRING
;
;ACCEPTS IN T1/	DYNETS ERROR NUMBER,,MONITOR ERROR
;
;	CALL   DYXERR
;
;RETURNS +1:	ALWAYS
;

DYXERR::			;ENTRY
	HRROI T2,ERRSTR		;SET UP STRING POINTER FOR ERROR STRING
	MOVEI T3,.FHSLF		;THIS FORK
	CALL ERRORB		;BUILD THE ERROR STRING
	HRROI T1,ERRSTR		;GET POINTER TO STRING
	CALL   SNDMSG			;TYPE OUT THE MESSAGE
	RET			;AND EXIT
	PAGE
;
;ROUTINE TO BUILD AN ERROR MESSAGE STRING
;
;ACCEPTS IN T1/ DYNETS ERROR CODE,,MONITOR JSYS ERROR CODE
;	    T2/	POINTER TO WHERE TO PUT THE STRING
;	    T3/	FORK HANDLE
;
;RETURNS +1:	T2/	UPDATED STRING POINTER
;
ERRORB:	STKVAR <ERRORC,ERRORP,ERRORH>
	MOVEM T1,ERRORC		;SAVE THE ERROR NUMBERS
	MOVEM T3,ERRORH		;SAVE FORK HANDLE
	MOVE T1,T2		;SET UP POINTER TO ERROR STRING
	HRROI T2,[ASCIZ/? DYNETS: /]
	SETZ T3,
	SOUT			;OUTPUT THE TEXT
	HLRZ T2,ERRORC		;NOW TYPE THE ERROR MESSAGE
	SUBI T2,ERRCD0		;GET OFFSET INTO ERROR CODE TABLE
	SKIPL T2		;ERROR?
	CAIL T2,ERRTBL		;IS ERROR CODE IN CORRECT RANGE?
	SKIPA T2,[-1,,[ASCIZ/UNKNOWN DYNETS ERROR/]]
	HRRO T2,ERRTAB(T2)	;YES, GET POINTER TO ERROR STRING
	SOUT			;TYPE OUT THE ERROR MESSAGE
	MOVEM T1,ERRORP		;SAVE THE POINTER
	MOVE T1,ERRORH		;GET THE LAST ERROR CODE FOR THE FORK
	GETER
	HRLM  T2,ERRORH		;SAVE IT FOR LATER
	MOVE T1,ERRORP		;GET BACK THE POINTER
	HRROI T2,[ASCIZ/ - /]
	SETZ T3,
	SOUT			;NOW PRINT OUT THE LAST ERROR
	HRL  T2,ERRORH		;GET THE FORK HANDLE
	HRR   T2,ERRORC		;GET THE MONITOR ERROR CODE
	SETZ T3,		;NO LENGTH LIMIT
	ERSTR			;TYPE OUT MESSAGE
	 JFCL
	 JRST [	HRROI T2,[ASCIZ/NO ERROR MESSAGE FOR ERROR CODE: /]
		SOUT
		MOVE T2,ERRORC	;NOW TYPE OUT ERROR CODE IN OCTAL
		MOVEI T3,10
		NOUT
		 JFCL
		JRST .+1]
	HRROI T2,[BYTE (7)12,15] ;CR/LF
	SETZ T3,
	SOUT			;FINISH THE MESSAGE
	MOVE T2,T1		;RETURN WITH UPDATED POINTER IN T2
	RET			;AND RETURN
	PAGE
	SUBTTL DYNETS ERROR CODES AND MESSAGES
;
;DYNETS ERROR CODES
;
	ERRCD0==100000		;STARTING ERROR CODE VALUE

DEFINE ERR (ERRSYM,ERRMSG) <
IF1 <IFDEF ERRSYM,<PRINTX ERROR CODE "ERRSYM" IS MULTIPLY DEFINED>>
IFNDEF ERRNUM,<ERRNUM==ERRCD0>
IF1 <	ERRSYM==ERRNUM>
	[ASCIZ\ERRMSG\]
IF1 <	ERRNUM==ERRNUM+1>>

ERRTAB:				;BEGINNING OF ERROR TABLE
ERR .ERR1,<DYNETS INITIALIZATION FAILURE>
ERR .ERR2,<ILLEGAL DYNETS COMMAND>
ERR .ERR3,<DYNETS TERMINATION FAILURE>
ERR .ERR4,<UNKNOWN NETWORK NAME>
ERR .ERR5,<LINK OPEN FAILURE>
ERR .ERR6,<SET CONNECT INTERRUPT CHANNEL FAILURE>
ERR .ERR7,<INVALID MESSAGE LOG JFN OR POINTER>
ERR .ERR8,<SET DATA INTERRUPT CHANNEL FAILURE>
ERR .ERR9,<UNABLE TO OBTAIN MESSAGE LOG JFN>
ERR .ERR10,<OPEN FAILED FOR MESSAGE LOG>
ERR .ERR11,<CLOSE FAILED FOR MESSAGE LOG>
ERR .ERR12,<CURRENTLY UNIMPLEMENTED FUNCTION>
ERR .ERR13,<LINK CONNECTION LOST>
ERR .OPNERR,<LINK OPEN FAILED>
ERR .RLSER,<READ LINK STATUS FAILED>
ERR .RLDER,<READ LINK DATA FAILED>
ERR .RHNER,<READ LINK HOST NAME FAILED>
ERR .RODER,<READ LINK OBJECT-DESCRIPTOR FAILED>
ERR .RTNER,<READ LINK TASK-NAME FAILED>
ERR .RUSER,<READ LINK USERID FAILED>
ERR .RPWER,<READ LINK PASSWORD FAILED>
ERR .RACER,<READ LINK ACCOUNT FAILED>
ERR .RDAER,<READ LINK OPTIONAL-DATA FAILED>
ERR .RCNER,<READ LINK OBJECT-NUMBER FAILED>
ERR .RSSER,<READ LINK SEGMENT-SIZE FAILED>
ERR .ACPER,<ACCEPT LINK CONNECTION FAILED>
ERR .SNDER,<SEND LINK FAILED>
ERR .RCVER,<RECEIVE LINK FAILED>
ERR .CLZER,<CLOSE LINK FAILED>
ERR .REJER,<REJECT LINK FAILED>
ERR .SIMER,<SEND LINK INT MSG FAILED>
ERR .RIMER,<RECEIVE LINK INT MSG FAILED>
ERR .SETER,<SET/CLEAR LINK INTERRUPT ASSIGNMENT FAILED>

				;END OF ERROR TABLE
	ERRTBL==.-ERRTAB	;ERROR TABLE LENGTH


	PAGE
	SUBTTL MEMINI - INITIALIZE THE MEMORY ALLOCATION ROUTINES
;
;MEMINI - ROUTINES TO INITIALIZE THE MEMORY ALLOCATION ROUTINES, CALLED BY
;	MAINLINE CODE AT SYSTEM INITIALIZATION TIME
;
;	CALL MEMINI
;
	IBSIZ==7			;SIZE OF THE IB
;
MEMINI::			;ENTRY POINT
	CALL   M%INIT##		;CALL MEMORY INIT ROUTINE
	SKIPN  F		;CHECK FOR GOOD RETURN
	JRST   [
		HRROI  T1,[ASCIZ/? DYNETS: INITIALIZATION FAILURE, MEMORY SUBSYS FAILED/]
		CALL   SNDMSG
		HALTF
		JRST   .]
	MOVEI  T1,IBSIZ		;SIZE OF THE IB
	MOVEI  T2,IB		;ADDRESS OF IB
	CALL   .INIT##		;INITIALIZE COMMON MODULES
	SKIPN  F		;CHECK FOR GOOD RETURN
	JRST   [
		HRROI  T1,[ASCIZ/? DYNETS: INITIALIZATION FAILURE/]
		CALL   SNDMSG
		HALTF
		JRST   .]
	CALL   T%INIT##		;INITIALIZE TEXT MODULE
	SKIPN  F		;CHECK FOR GOOD RETURN
	JRST   [
		HRROI  T1,[ASCIZ/? DYNETS: INITIALIZATION FAILURE/]
		CALL   SNDMSG
		HALTF
		JRST   .]
	RET			;RETURN
;
;RETURN FOR STOP ROUTINE
;
I%EXIT::	HALTF
	JRST   .-1
;
;DEFAULT TEXT ROUTINE
;
TXTRTN:				;ENTRY
	PBOUT			;OUTPUT THE BYTE
	 JFCL			;IGNORE ERROR
	SETOI  T1,0		;MAKE .TRUE.
	RET			;RETURN
;
;INITIALIZATION BLOCK
;
IB:	SIXBIT /DYNETS/		;PROGRAM NAME
	TXTRTN			;DEFAULT TEXT ROUTINE
	Z			;IPCF CONTROL WORD
	Z			;IPCF PARAMETERS
	EXP 4			;PROGRAM ID
	EXP 1			;VERSION NUMBER
	Z			;INTERRUPT VECTOR BASE
	PAGE
	SUBTTL PIOFF/PION ROUTINES
;
;ROUTINES TO TURN OFF AND ON THE INTERRUPT SYSTEM
;ALL ACS ARE PRESERVED
;
;
;TURN INTERRUPT SYSTEM OFF
;
PIOFF:			;ENTRY
	PUSH P,T1		;SAVE ALL ACS
	MOVEI T1,.FHSLF		;THIS FORK
	DIR			;DISABLE INTERRUPT SYSTEM
	POP P,T1		;RESTORE AC
	RET			;AND RETURN
;
;TURN INTERRUPT SYSTEM ON
;
PION:				;ENTRY
	PUSH P,T1		;SAVE ALL ACS
	MOVEI T1,.FHSLF		;THIS FORK
	EIR			;ENABLE INTERRUPTS AGAIN
	POP P,T1		;RESTORE AC
	RET			;AND RETURN
	PAGE
	SUBTTL PSIINI - INITIALIZE THE SOFTWARE INTERRUPT SYSTEM
;
;PSIINI - ROUTINE TO INITIALIZE THE PSI SYSTEM
;
;RETURNS +1:	ALWAYS
;
PSIINI::			;ENTRY
	CIS			;CLEAR THE INTERRUPT SYSTEM
	MOVE   T1,[COINSL,,COINSH] ;SET UP CHANNEL TABLE FOR CONNECT INTERRUPT
	MOVEM  T1,CHNTAB+COCHNS	
	MOVE   T1,[DAINSL,,DAINSH] ;SET UP TABLE FOR SERVER DATA AVAILABLE
	MOVEM  T1,CHNTAB+DACHNS
	MOVE   T1,[IMINSL,,IMINSH] ;SETUP TABLE FOR SERVER INTERRUPT MESSAGE
	MOVEM  T1,CHNTAB+IMCHNS
	MOVE   T1,[COINTL,,COINTH] ;SET UP CHANNEL TABLE FOR CONNECT EVENT
	MOVEM  T1,CHNTAB+COCHNT	
	MOVE   T1,[DAINTL,,DAINTH] ;SET UP TABLE FOR TARGET DATA AVAILABLE
	MOVEM  T1,CHNTAB+DACHNT
	MOVE   T1,[IMINTL,,IMINTH] ;SETUP TABLE FOR TARGET INTERRUPT MESSAGE
	MOVEM  T1,CHNTAB+IMCHNT
	MOVEI  T1,.FHSLF	;THIS FORK
	MOVE   T2,[LEVTAB,,CHNTAB]
	SIR			;SET UP LEVTAB AND CHNTAB
	MOVE   T2,ONCHNS	;GET MASK OF CHANNELS TO ENABLE
	AIC			;ACTIVATE THE CHANNELS
	EIR			;ENABLE THE PI SYSTEM FOR INTERRUPTS
	RET			;DONE
	PAGE
	SUBTTL SLEEP - PUT ROUTINE TO SLEEP FOR INTERVAL OR FOREVER
;
;SLEEP - SLEEP FOR NUMBER OF SECONDS, INDEFINITELY, OR NOT AT ALL
;
;ACCEPTS: T1/ TIME IN SECONDS TO SLEEP
;		IF < 0 -- SLEEP INDEFINITELY
;		IF = 0 -- DON'T SLEEP AT ALL
;		IF > 0 -- SLEEP FOR NUMBER OF SECONDS
;
;
SLEEP:				;ENTRY
	SETZM  TIMOUT		;CLEAR TIMEOUT FLAG
	SKIPN  T1		;SLEEP AT ALL ??
	RET			;NO, JUST RETURN
	SKIPL  T1		;TIMED SLEEP ??
	IMULI  T1,^D1000	;YES, MAKE MILLISECONDS
SLP0:
	SKIPE  AWOKEN		;SEE IF WAKE-UP HAS OCCURED
	JRST   SLP1		;YES, DON'T SLEEP
	SKIPG  T1		;TIMED SLEEP ?
	WAIT			;NO, SLEEP FOREVER
	DISMS			;YES, SLEEP FOR A TIME
	 JFCL
	SETOM  TIMOUT		;SET FLAG TO SAY TIME EXPIRED
SLP1:
	SETZM  AWOKEN		;CLEAR "NEED WAKE-UP" FLAG
	RET			;DONE, RETURN


;
;THE CORRESPONDING WAKEUP ROUTINE
;
;ACCEPTS: T1/INTERRUPT LEVEL


WAKEUP:				;ENTRY
	SETOM  AWOKEN		;TURN ON WAKEUP FLAG
	MOVEI  T2,SLP1		;ADDRESS TO WHERE WAKEUP
	HRRZ   T3,@LEVTAB-1(T1)	;GET CURRENT PC THIS LEVEL
	CAIL   T3,SLP0		;SLEEPING ??
	CAILE  T3,SLP1
	SKIPA			;NO, JUST RETURN
	HRRM   T2,@LEVTAB-1(T1)	;YES, ALTER CURRENT PC
	RET
	PAGE
	SUBTTL LITERAL POOL AND CONSTANTS
	XLIST
LTPOOL:	LIT			;BEGINNING OF LITERAL POOL
	LIST
;
;INTERRUPT CHANNEL TABLES
;

ONCHNS:	1B<COCHNS>!1B<DACHNS>!1B<IMCHNS>!1B<COCHNT>!1B<DACHNT>!1B<IMCHNT>

	RADIX 5+5

CHNTAB:
ICH000:	BLOCK 1			;ASSIGNABLE CHANNEL 0
ICH001:	BLOCK 1			;ASSIGNABLE CHANNEL 1
ICH002:	BLOCK 1			;ASSIGNABLE CHANNEL 2
ICH003:	BLOCK 1			;ASSIGNABLE CHANNEL 3
ICH004:	BLOCK 1			;ASSIGNABLE CHANNEL 4
ICH005:	BLOCK 1			;ASSIGNABLE CHANNEL 5
ICHAOV:	BLOCK 1			;ARITHMETIC OVERFLOW
ICHFOV:	BLOCK 1			;FLOATING OVERFLOW
ICH008:	BLOCK 1			;RESERVED
ICHPOV:	BLOCK 1			;PDL OVERFLOW
ICHEOF:	BLOCK 1			;END OF FILE
ICHDAE:	BLOCK 1			;DATA ERROR
ICHQTA:	BLOCK 1			;QUOTA EXCEEDED
ICH013:	BLOCK 1			;RESERVED
ICHTOD:	BLOCK 1			;TIME OF DAY (RESERVED)
ICHILI:	BLOCK 1			;ILLEG INSTRUCTION
ICHIRD:	BLOCK 1			;ILLEGAL READ
ICHIWR:	BLOCK 1			;ILLEGAL WRITE
ICHIEX:	BLOCK 1			;ILLEGAL EXECUTE (RESERVED)
ICHIFT:	BLOCK 1			;INFERIOR FORK TERMINATION
ICHMSE:	BLOCK 1			;MACHINE SIZE EXCEEDED
ICHTRU:	BLOCK 1			;TRAP TO USER (RESERVED)
ICHNXP:	BLOCK 1			;NONEXISTENT PAGE REFERENCED
ICH023:	BLOCK 1			;ASSIGNABLE CHANNEL 23
ICH024:	BLOCK 1			;ASSIGNABLE CHANNEL 24
ICH025:	BLOCK 1			;ASSIGNABLE CHANNEL 25
ICH026:	BLOCK 1			;ASSIGNABLE CHANNEL 26
ICH027:	BLOCK 1			;ASSIGNABLE CHANNEL 27
ICH028:	BLOCK 1			;ASSIGNABLE CHANNEL 28
ICH029:	BLOCK 1			;ASSIGNABLE CHANNEL 29
ICH030:	BLOCK 1			;ASSIGNABLE CHANNEL 30
ICH031:	BLOCK 1			;ASSIGNABLE CHANNEL 31
ICH032:	BLOCK 1			;ASSIGNABLE CHANNEL 32
ICH033:	BLOCK 1			;ASSIGNABLE CHANNEL 33
ICH034:	BLOCK 1			;ASSIGNABLE CHANNEL 34
ICH035:	BLOCK 1			;ASSIGNABLE CHANNEL 35

	RADIX 8

STDPAT:				;STANDARD DATA PATTERN FOR DTR
STDINT:	POINT 8,.+1		;POINTER TO STANDARD INTERRUPT MESSAGE
	BYTE (8)"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P"
	BYTE (8)"Q","R","S","T","U","V","W","X","Y","Z","0","1","2","3","4","5"
	BYTE (8)"6","7","8","9"
	PAGE
	SUBTTL VARIABLE DATA STORAGE
	RELOC   <<.+140>/1000+1>*1000-140	;ORG AT NEXT HIGHER PAGE BOUNDARY
	VAR
CONLST:	BLOCK 1			;CONNECT LIST CHAIN ANCHOR FOR SERVERS
RCVLST:	BLOCK 1			;RECEIVE LIST CHAIN ANCHOR FOR SERVERS
CONLTT:	BLOCK 1			;CONNECT LIST CHAIN ANCHOR TARGETS
RCVLTT:	BLOCK 1			;RECEIVE LIST CHAIN ANCHOR FOR TARGETS
SNDLQH:	BLOCK 1			;POINTER TO HEAD OF LCB SEND QUEUE
SNDLQT:	BLOCK 1			;POINTER TO TAIL OF LCB SEND QUEUE
TCBLST:: BLOCK  1		;TCB LIST POINTER
SCBLST:: BLOCK  1		;SCB LIST POINTER
TCBLKT:	EXP TLTSIZ
	BLOCK TLTSIZ		;TCB LOOKUP TABLE
SCBLKT:	EXP SLTSIZ
	BLOCK SLTSIZ		;SCB LOOKUP TABLE
	PAGE
AWOKEN:	BLOCK 1			;WAKE-UP FLAG FOR SLEEP ROUTINE
TIMOUT:	BLOCK 1			;TIME EXPIRED FLAG
DBUGF1:	BLOCK 1			;DEBUG FLAG
TMSGCT:	BLOCK 1			;GLOBAL MESSAGE SEND COUNT
LEVTAB:	LEV1PC			;LEVEL 1 PC
	LEV2PC			;LEVEL 2 PC
	LEV3PC			;LEVEL 3 PC
LEV1PC:	BLOCK 1
LEV2PC:	BLOCK 1
LEV3PC:	BLOCK 1
GJFBLK:	BLOCK GJFSIZ		;GTJFN BLOCK
BUFFER:	BLOCK 50		;TEXT BUFFER
ERRSTR:	BLOCK 20		;ERROR STRING BUFFER
TCBSTR:	BLOCK 40		;STORAGE FOR TCB HOST/OBJ/DESCR STRING
	PAGE
;*******************************************************************************
;
;VARIABLES FOR DTR/DTS MODE
;
;*******************************************************************************



DTRFLG:				; FLAG FOR DTR MODE
IFN DTRSW,<EXP -1>		; DTR mode on
IFE DTRSW,<EXP 0>		; No DTR

DTSFLG:	BLOCK 1			;FLAG FOR DTS MODE


	END