Google
 

Trailing-Edge - PDP-10 Archives - BB-R598A-RM_1983 - swskit-v3/pmr/snolib.mac
There is 1 other file named snolib.mac in the archive. Click here to see a list.
	SEARCH MONSYM,MACSYM,JOBDAT
	STDAC.

OPDEF ERJMP [JUMP 16,]
P==17
DEFOPD:	BYTE (8)144,11		;DEFAULT OPTIONAL DATA ARG
XSTR:	BLOCK 15
OPABUF:	BLOCK 12		;ASCII OPT DATA STRING
OPDBUF:	BLOCK 4			;PLACE FOR OPTIONAL DATA STRING
BUFF:	BLOCK 30000		;PAGE FOR DATA MOVEMENT
BUFFD:	BLOCK 30000		;DOWNSTREEAM INPUT
JFN:	BLOCK 1			;UPSTREAM JFN
JFN1:	BLOCK 1			;DOWNSTREAM JFN
FORK:	BLOCK 1
SINRMX==30000*4			;MAX SIZE OF BUFFER


;MACRO TO MAKE ENTRIES IN NSP ERROR TABLE

	MAXMSG==^D50		; Maximum number of NSP error messages

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

REPEAT MAXMSG,<POINT 7,[ASCIZ\: Undefined NSP error\]> ;MAKE TABLE SPACE
				; & UNDEFINED ENTRIES

	NSPERR (.DCX0,<No special error>)
	NSPERR (.DCX1,<Resource allocation failure>)
	NSPERR (.DCX2,<Destination node does not exist>)
	NSPERR (.DCX3,<Node shutting down>)
	NSPERR (.DCX4,<No servers available>)
	NSPERR (.DCX5,<Invalid name field>)
	NSPERR (.DCX9,< Remote Server aborted link>)
	NSPERR (.DCX11,<Undefined error>)
	NSPERR (.DCX21,<CI with illegal destination address>)
	NSPERR (.DCX24,<Flow control violation>)
	NSPERR (.DCX32,<Too many connections to node>)
	NSPERR (.DCX33,<No servers available>)
	NSPERR (.DCX34,<Access not permitted>)
	NSPERR (.DCX35,<Logical link services mismatch>)
	NSPERR (.DCX36,<Invalid account>)
	NSPERR (.DCX37,<Segment size too small>)
	NSPERR (.DCX38,<Process aborted>)
	NSPERR (.DCX39,<No path to destination node>)
	NSPERR (.DCX40,<Link aborted due to data loss>)
	NSPERR (.DCX41,<Destination logical link address does not exist>)
	NSPERR (.DCX42,<Confirmation of disconnect initiate>)
	NSPERR (.DCX43,<Image data field too long>)



;INIT routine called from SNOBOL main program

CASEER::HRRZ 1,@0(16)		;GET ROUTINE TO DO
	JRST @[	INITER
		GETNET
		DONETN
		DONETL
		GETOPT](1)
INITER:	RET

;Routine to build and return optional data string

GETOPT:	MOVE 1,JFN		;SRV JFN
	MOVE 3,[POINT 8,OPDBUF]
	MOVEI 2,.MORDA		;GET OPTIONAL DATA
	MTOPR			;DO IT
	 ERJMP [SETZM 4
		JRST .+1]
	MOVE 3,[POINT 7,OPABUF] ;DEST BUFFER
	MOVE 1,[POINT 8,OPDBUF]	;SOURCE BUFFER
	SKIPE 2,4		;ANYTHING HERE?
	JRST GOTSOM		;YEP
	MOVEI 2,2		;NO DATA. USE DEFAULT
	MOVE 1,[POINT 8,DEFOPD]
GOTSOM:	CALL CVOPT		;CONVERT TO ASCII
	MOVEI OPABUF		;RETURN DATA
	RET


GETNET:	MOVX 1,GJ%SHT
	HRROI 2,[ASCIZ /SRV:123/] ;BECOME A SERVER
	GTJFN
	 JRST RSKP		;FAIL!
	MOVEM 1,JFN		;SAVE SERVER JFN
	MOVE 2,[100000,,300000]
	OPENF			;OPEN IT UP
	 ERJMP [MOVE 1,JFN
		RLJFN		;RELEASE JFN
		 JFCL
		SETZM JFN
		JRST RSKP]	;AND GIVE UP

;NOW WAIT FOR SOMETHING TO DO

	MOVNI 3,SINRMX
	HRROI 2,BUFF
	SINR			;WAIT FOR DATA
	 ERJMP [RESET
		JRST RSKP]	;FAILURE
	SETZM 3
	IDPB 3,2		;TIE OFF STRING
	MOVX 3,1B6
	ADDM 3,BUFF
	MOVEI BUFF		;RETURN STRING
	POPJ P,			;DO IT

;UTILITIES

ABOAL0:	MOVE 1,JFN
	MOVEI 2,2
	BOUT			;INDICATE FAILURE
	 ERJMP ABOALL
	MOVEI 2,"%"
	BOUT
	 ERJMP ABOALL
	HRRO 2,3(16)		;GET NAME WE ARE GOING TO
	SETZM 3
	SOUT			;OUTPUT IT
	 ERJMP ABOALL
	HRROI 2,[ASCIZ / not reachable because /]
	SOUT			;say so
	 ERJMP ABOALL
	SKIPN 1,JFN1		;HAVE A LINE?
	JRST [	HRROI 1,XSTR	;NO
		HRLOI 2,.FHSLF
		SETZM 3
		ERSTR
		 NOP
		 NOP
		HRROI 2,XSTR
		JRST EMSG]
	MOVEI 2,.MORLS
	MTOPR
	 ERJMP ABOALL
	HRRZS 3
	MOVE 2,MSGTBL(3)
EMSG:	MOVE 1,JFN
	SETZM 3
	SOUTR
	 ERJMP ABOALL
	CLOSF			; close it now
	 ERJMP ABOALL
ABOALL:	SKIPN 1,JFN		;ANYTHING HERE?
	JRST ABOALZ		;NO
	TXO 1,CZ%ABT
	CLOSF
	 JFCL
	SETZM JFN
ABOALZ:	SKIPN 1,JFN1
	JRST RSKP
	TXO 1,CZ%ABT
	CLOSF
	 JFCL
	SETZM JFN1
RSKP:	AOS 0(17)
	POPJ P,			;FAIL RETURN


OPNCOM:	MOVX 1,GJ%SHT
	HRRO 2,1(16)		;GET STRING POINTER
	GTJFN			;OPEN THE LINE
	 POPJ P,			;ERROR
	MOVEM 1,JFN1		;SAVE OTHER SIDE OF THE LINK
	MOVE 2,[100000,,300000]
	OPENF
	 ERJMP[	SETZM 1
		EXCH 1,JFN1
		RLJFN
		 JFCL
		POPJ P,]
	JRST RSKP		;DID IT


;HERE IF WE ARE NOT THE LAST PASS THROUGH SERVER IN THE CHAIN.
;OPEN LINK TO NEXT SERVER INDICATED BY FIRST ARG AND PASS
;IT THE DATA INDICATED BY THE SECOND ARG.

DONETN::
	PUSHJ P,OPNCOM
	 JRST ABOAL0

;TIME OUT THE CONNECTION ATTEMPT

	MOVEI T4,^D10		;10 TRIES FOR THE CONNECTION
TSTCON:	MOVEI T1,^D2000		;2 SECONDS BETWEEN TRIES
	DISMS			;WAIT
	MOVE T1,JFN1		;GET BACK THE JFN
	MOVX T2,.MORLS		;READ LINK STATUS
	MTOPR
	 ERJMP TSTCO1		;FAILED, MOVE ON
	TXNE T3,MO%CON		;CONNECTED?
	JRST GOTCON		;YES, GO TO IT
	TXNE T3,MO%WFC		;NO, WAITING FOR A CONNECT?
	JRST TSTCO1		;YES, WAIT FOR A BIT
	TXNE T3,MO%ABT		;NO, CONNECT BEEN REJECTED?
	JRST ABOAL0		;YES, GIVE UP
TSTCO1:	SOJE T4,ABOAL0		;TRIED ENOUGH?
	JRST TSTCON		;NO, TRY AGAIN

;HAVE A CONNECTION

GOTCON:	HRRO 2,2(16)		;GET STRING TO SEND
	SETZM 3
	MOVE 1,JFN1
	SOUTR			;SEND IT TO OTHER GUY
	 ERJMP ABOAL0		;ZAP ALL LINKS AND PROCEED
WAITM:	MOVE 1,JFN1
	HRROI 2,BUFF
	MOVNI 3,SINRMX
	SINR			;WAIT FOR REPLY
	 ERJMP ABOAL0		;OOPS
	SETZM 3
	IDPB 3,2		;TIE OFF STRING

;HAVE REPLY FROM OTHER SERVERS. PUT ON NAME WE DID AND SEND IT BACK

	MOVE 4,[POINT 7,BUFF]
	MOVE 1,JFN
	ILDB 2,4
	BOUT
	 ERJMP ABOALL
	SOJG 2,FAIL		;IF FAILURE, DON'T ADD OUR NAME
	HRRO 2,3(16)		;GET OUR NAME
	SETZM 3
	SOUT
	 ERJMP ABOALL
FAIL:	MOVE 2,4
	SOUTR			;SEND REST OF MESSAGE
	 ERJMP ABOALL
	LDB 2,[POINT 7,BUFF,6]
	JUMPE 2,WAITM
	JRST DODATA		;READY TO DO DATA MOVING

;ENTRY IF WE ARE THE LAST IN LINE

DONETL::
	PUSHJ P,OPNCOM		;DO OPEN
	 JRST ABOAL0		;BAD
	MOVEI 4,^D60		;WAIT 30 SECS FOR THIS
WAITER:	MOVEI 1,^D500		;WAIT 1/2 SEC
	DISMS
	MOVE 1,JFN1		;POLL CONNECTION
	MOVEI 2,.MORLS
	MTOPR			;GET STATUS
	 ERJMP ABOALL		;IF BOMBED, ERROR
	TXNE 3,MO%CON		;NOW CONNECTED?
	JRST YESCON
	TXNE 3,MO%ABT!MO%SYN	;ABORTED?
	JRST ZAPPED

	SOJG 4,WAITER
	SETZM 3
	JRST ZAPPED

;LINK ACCEPTED IT HERE

YESCON:	MOVE 1,JFN
	MOVEI 2,1
	BOUT
	 ERJMP ABOALL
	HRRO 2,3(16)
	SETZM 3
	SOUTR			;SAY WE DID IT
	 ERJMP ABOALL
	JRST DODATA

;LINK ABORTED IF HERE

ZAPPED:	MOVE 1,JFN
	MOVEI 2,2
	BOUT
	 ERJMP ABOALL
	MOVEI 2,"%"
	BOUT
	 ERJMP ABOALL
	JUMPE 3,[HRROI 4,[ASCIZ /Timeout/]
		JRST ZAP00]
	HRRZ 4,3		;SAVE REASON
	MOVE 4,MSGTBL(4)
ZAP00:	HRRO 2,3(16)
	SETZM 3
	SOUT
	 ERJMP ABOALL
	HRROI 2,[ASCIZ / not reachable because /]
	SOUT
	 ERJMP ABOALL
	MOVE 2,4
	SOUTR
	 ERJMP ABOALL
	MOVE 1,JFN
	CLOSF			;NORMAL CLOSE
	 ERJMP ABOALL
	SETZM JFN		;NOTHING HERE ANYMORE
	SKIPN 1,JFN1		;GET OTHER JFN
	POPJ P,			;NONE HERE. STRANGE
	TXO 1,CZ%ABT		;GET RID OF IT
	CLOSF			;""
	 NOP			;HAS TO WORK
	SETZM JFN1		;NOTHING LEFT
	POPJ P,			;DONE

;HERE WHEN READY TO MOVE DATA. CREATE ANOTHE FORK TO READ FROM
;DOWNSTEAM SIDE, AND READ FROM UPSTREAM SIDE HERE.


DODATA: MOVX 1,CR%MAP!CR%ST
	HRRI 1,DWNSTM
	CFORK			;CREATE AND START FORK
	 ERJMP ABOALL		;OOPS
	MOVEM 1,FORK		;SAVE HANDLE

;START OF UPSTREAM CODE. READ UPSTREAM DATA AND WRITE DOWNSTREAM DATA

UPS:	MOVE 1,JFN
	MOVE 2,[POINT 8,BUFF]
	MOVNI 3,SINRMX
	SINR			;GET IT
	 ERJMP [MOVE 1,FORK
		KFORK		;ZAP FORK
		JRST ABOALL]	;AND DONE
	ADDI 3,SINRMX		;COMPUTE BYTES TAKEN
	MOVNS 3			;GET NEG OF BYTES TAKEN
	MOVE 1,JFN1
	MOVE 2,[POINT 8,BUFF]
	SOUTR			;WRITE IT
	  ERJMP [MOVE 1,FORK
		KFORK
		JRST ABOALL]	;DONE
	JRST UPS		;DO IT AGAIN

DWNSTM:	MOVE 1,JFN1
	MOVE 2,[POINT 8,BUFFD]
	MOVNI 3,SINRMX
	SINR			;GET DATA
	 ERJMP ABOALL		;MAKE OTHER GUY SEE IT
	ADDI 3,SINRMX
	JUMPE 3,ABOALL		;IF EOF, DONE
	MOVNS 3
	MOVE 1,JFN
	MOVE 2,[POINT 8,BUFFD]
	SOUTR			;SEND IT UPSTREAM
	 ERJMP ABOALL
	JRST DWNSTM		;AND GO ON


;routine to convert incoming optional data to outgoing form

;	1/ PTR TO OPTIONAL DATA
;	2/ COUNT OF BYTES
;	3/ ASCII POINTER FOR FILE SPEC

CVOPT:	PUSH P,1		;SOURCE POINTER
	PUSH P,3		;DEST POINTER
CVOPT0:	MOVEI 4,2
	ILDB 1,-1(P)		;NEXT SOURCE BYTE
CVOPT1:	LDB 3,[	POINT 3,1,35
		POINT 3,1,32
		POINT 2,1,29](4) ;NIBBLE
	IORI 3,"0"		;MAKE IT ASCII
	IDPB 3,0(P)
	SOJGE 4,CVOPT1
	SOJG 2,CVOPT0
	IDPB 2,0(P)		;TIE IT OFF
	ADJSP P,-2		;CLEAN UP STACK
	RET			;DONE


	END