Google
 

Trailing-Edge - PDP-10 Archives - BB-J713A-BM - 4-sources/ftsctl.mac
There is 1 other file named ftsctl.mac in the archive. Click here to see a list.
;<4.ARPA-UTILITIES>FTSCTL.MAC.4,  4-Jan-80 09:46:37, EDIT BY R.ACE
;UPDATE COPYRIGHT DATES
;<4.ARPA-UTILITIES>FTSCTL.MAC.3,  9-Jan-79 13:59:27, Edit by LCAMPBELL
; Update copyright notice
;<3A.ARPA-UTILITIES>FTSCTL.MAC.3, 26-Jul-78 14:03:06, Edit by ENGEL
;CHANGE <SYSTEM> TO SYSTEM:
;<JBORCHEK>FTSCTL.MAC.2, 24-Apr-78 17:02:10, EDIT BY JBORCHEK
;USE IPCF TO CHECK IF FTPSER HAS DIED
;<3.ARPA-UTILITIES>FTSCTL.MAC.5, 14-Nov-77 10:19:12, EDIT BY CROSSLAND
;CORRECT COPYRIGHT NOTICE
;<3.ARPA-UTILITIES>FTSCTL.MAC.4, 26-Oct-77 02:37:01, EDIT BY CROSSLAND
;UPDATE COPYRIGHT FOR RELEASE 3
;<3-UTILITIES>FTSCTL.MAC.3, 27-Jul-77 01:00:45, EDIT BY CROSSLAND
;ADD SPACE FOR NEW AND FUTRE CRJOB ARGS.
;<3-UTILITIES>FTSCTL.MAC.2, 11-Jun-77 02:17:46, EDIT BY CROSSLAND
;MAKE COMPATIBLE WITH MOUNTABLE STRUCTURES
;<A-UTILITIES>FTSCTL.MAC.3,  3-Dec-76 15:57:22, EDIT BY CLEMENTS
;PUT IN IPCF LISTENER - CONDITIONED OUT TIL COMPLETED SOMEDAY
;put back in jobont. it's really needed.
; CHANGE FOR NEW CRJOB LAYOUT, LACK OF JOBONT, QUOTE "#".
;<2MURPHY>FTSCTL.MAC.2, 16-Jul-76 17:19:52, EDIT BY MURPHY
;CHANGE STENEX TO MONSYM,MACSYM
;<SOURCES>FTSCTL.MAC;20    11-May-76 14:58:38    EDIT BY CLEMENTS
; Fix tight loop when entflg is off
;<SOURCES>FTSCTL.MAC;19    23-Apr-76 15:37:16    EDIT BY CLEMENTS
;<SOURCES>FTSCTL.MAC;18    22-SEP-75 13:06:18    EDIT BY CLEMENTS
;<CLEMENTS>FTSCTL.MAC;16    11-JUL-75 15:48:09    EDIT BY CLEMENTS
;<CLEMENTS>FTSCTL.MAC;15    11-JUL-75 15:17:01    EDIT BY CLEMENTS
;<CLEMENTS>FTSCTL.MAC;14    10-JUL-75 13:08:53    EDIT BY CLEMENTS


;This software is furnished under a license and may only be used
;  or copied in accordance with the terms of such license.
;
;Copyright (C) 1976,1977,1978,1979,1980 Digital Equipment Corporation, Maynard, Mass.


TITLE FTSCTL	CONTROL JOB FOR FTP SERVICE USING CRJOB

SEARCH MONSYM,MACSYM

VWHO==0			;LAST EDITED BY DEC
VMAJOR==4		;MAJOR VERSION #
VMINOR==0		;REVISION #
VEDIT==4		;EDIT NUMBER

	LOC	<.JBVER==137>
VERSIO:	<VWHO>B2+<VMAJOR>B11+<VMINOR>B17+VEDIT ;VERSION NUMBER

	RELOC

F=0
A=1
B=2
C=3
D=4
W=5			;SOME WORK AC'S
W1=6
W2=7
W3=10
X=15
Y=16

P=17

LSNCHN==1		;PSI HERE WHEN ICP SOCKET IS POKED
JLOCHN==2		;PSI WHEN OWNED JOB LOGS OUT
PIDCHN==3		;PSI HERE WHEN IPCF TRAFFIC ARRIVES


;Note: so far this just listens on one socket and connects up an
;old-style NVT. should add second listener, new style NVT
; and new FTP server, (1b2 on in AC1 of ATNVT).
FTSCTL:	RESET
	MOVEI F,0
	MOVE P,PDP
	MOVEI A,400000
	RPCAP
	IOR C,B
	EPCAP
	MOVEI A,400000		;SET UP PSI SYS THIS FORK
	MOVE B,[LEVTAB,,CHNTAB]	; ..
	SIR
	MOVSI B,(1B1+1B3)	;CHANNELS TO TURN ON
	AIC
	EIR			;TURN PSI SYSTEM ON
	MOVX W,IP%CPD		;CREATE A PID
	SETZB W1,W2		;SPACE FOR SEND/RCV PIDS
	MOVE W3,[ENDPKT-DEFPKT,,DEFPKT]
	MOVEI A,4		;LENGTH OF DESCRIPTOR
	MOVEI B,W		;WHERE DESCRIPTOR IS
	MSEND			;SEND TO SYSTEM INFO
	 JRST NOPID		;NONE AVAILABLE?
	MOVEM W1,MYPID		;SAVE PID IN CRJOB BLOCK
	MOVEI A,3		;SET UP PI CHANNEL OF PID
	MOVEI B,W		;IN WORK AC'S
	MOVEI W,.MUPIC
	MOVE W1,MYPID
	MOVEI W2,PIDCHN		;CHANNEL WILL BE POKED
	MUTIL			;WHEN TRAFFIC COMES FOR PID
	 JRST NOPID		;CAN'T?

	SETZM LSNCHK		;NOT POKED TO LISTEN YET
	SETZM LGOCHK		;NOR FOR A LOGGING OUT OWNED JOB
	SETZM PIDCHK		;NOR FOR LOGGING
	SETOM PNDJOB		;NO PENDING JOB YET
	SETOM LSNJFN		;NO LISTEN SOCKET JFN YET
REGO:	MOVE A,['NETRDY']
	SYSGT
	JUMPGE A,WREGO		;QUIT IF NET NOT UP YET
	MOVEI A,^D5000		;MAKE SURE THERE IS NO TIGHT LOOP HERE.
	DISMS			;WAIT A LITTLE WHILE.

OLOOP:	MOVE P,PDP		;RESET STACK
	PUSHJ P,CHKLGO		;SEE IF ANY PENDING LOGOUTS
	PUSHJ P,CHKLSN		;MAKE SURE ICP SOCKET IS LISTENING
	SKIPE PIDCHK		;ANY PENDING INTS?
	 PUSHJ P,CHKPID		;SEE IF ANY LOGGING PACKETS
	PUSHJ P,GETJOB		;MAKE SURE A JOB IS ON THE SHELF
	MOVEI A,^D60000		;LOOK AGAIN IN A MINUTE
	SKIPL LSNJFN		;ARE BOTH SOCKET AND JOB READY?
	SKIPGE PNDJOB		; ..
	MOVEI A,^D1000		;NO, DON'T SLEEP SO LONG.
WAITPC:	DISMS
	JRST OLOOP		;GO CHECK JOB AND SOCKET AGAIN

NOPID:	MOVEI A,^D5000
	DISMS
	JRST REGO

IMPDED:	SKIPL A,LSNJFN
	CLOSF
	  JFCL
	SETOM LSNJFN
	MOVEI A,^D60000
	DISMS
	JRST REGO

;CALL HERE TO MAKE SURE THERE IS A JOB PENDING

GETJOB:	SKIPLE PNDJOB		;JOB ALREADY PENDING?
	JRST NOCRJ		;YES. NO MORE, THANKS.
	MOVX A,<CJ%FIL!CJ%WTA!CJ%CAP!CJ%SLO> ;GET A JOB
	MOVEI 2,CRJBLK		; ..
	CRJOB
	  JRST CRJXXX
	MOVEM A,PNDJOB		;THIS JOB IS PENDING
	MOVEI A,^D100000(A)	;COMPUTE LOCAL SOCKET RELATIVE TO IT
	LSH A,^D15		; ..
	MOVEM A,SOKETS		;SAVE SOCKET "S"
NOCRJ:	POPJ P,0		;THERE IS A JOB
LISTEN:	HRROI A,GTJSTR		;BUILD STRING TO GTJFN THE LISTEN SOCKET
	HRROI B,[ASCIZ /NET:/]
	MOVEI C,0
	SOUT
	MOVE B,ICPSKT		;THE SOCKET NUMBER TO LISTEN ON
	SKIPE PRIVF		;PRIVATE?
	 TRO B,400
	MOVEI C,10		;OCTAL
	NOUT
	  0			;CAN'T FAIL
	HRROI B,ABSTXT		;ABSOLUTE SOCKET
	MOVEI C,0		;AND NO REMOTE SOCKET
	SOUT
	MOVSI A,400001		;GET A JFN FOR ICP SOCKET
	HRROI B,GTJSTR		; ..
	GTJFN
	  POPJ P,0		;CAN'T?
	MOVEM A,LSNJFN
	MOVE B,[400000,,100000]	;WILL SEND 32 BIT BYTE ON IT LATER
	OPENF
	  JRST [MOVE A,LSNJFN
		RLJFN
		  JFCL
		SETOM LSNJFN
		POPJ P,0]
	MOVSI C,777700+LSNCHN
	MOVEI B,24
	MTOPR			;SET FOR PSI ON RFC
CPOPJ1:	AOS 0(P)		;SKIP RETURN
CPOPJ:	POPJ P,0		;RETURN
CHKLSN:	SKIPL LSNJFN		;IS ICP SOCKET KNOWN?
	JRST CHKLS1		;YES
	PUSHJ P,LISTEN		;NO. MAKE ONE.
	  JRST LSNXXX		;FAILED TO MAKE LISTENER
CHKLS1:	MOVE A,['NETRDY']
	SYSGT			;MAKE SURE NET STILL UP
	JUMPGE A,IMPDED
	MOVE A,['ENTFLG']
	SYSGT			;MAKE SURE SYSTEM ACCEPTING LOGINS
	SKIPE B
	JUMPE A,REJECT		;REJECT IF NOT.
	MOVEI A,.GTNJF		;GET STATUS OF NETWORK JFN
	MOVE B,LSNJFN
	MOVEI C,NCPBLK		;GET ENTIRE BLOCK OF DATA
	MOVSI D,-20
	GTNCP
	 JRST CHKLSX		;DEAD
	MOVE A,NCPBLK+.NCFSM	;STILL LISTENING?
	CAIE A,.NSLSN
	 JRST CHKLS2
	SKIPGE NCPBLK+.NCFHS	;LSN AND CONNECTED TO A HOST
	 POPJ P,
CHKLSX:	MOVE A,LSNJFN
	TLO A,(1B1)
	CLOSF			;GET RID OF THIS GLITCHED SOCKET
	  JFCL
	SETOM LSNJFN		;FAILED
	JRST CHKLSN		;AND TRY AGAIN

CHKLS2:	SETZM LSNCHK
	MOVE C,NCPBLK+.NCFHS	;HOST
	MOVEM C,FHSTN
	MOVE D,NCPBLK+.NCFSK	;SOCKET
	MOVEM D,FORNS
	MOVE A,NCPBLK+.NCSIZ	;CONNECTION SIZE
	CAIE A,40
	JRST REJECT
	MOVE A,NCPBLK+.NCFSM
	CAIE A,.NSRCR		;RFCR?
	JRST REJECT		;NO
	JRST ACCEPT		;YES, GO ANSWER IT
ACCEPT:	SETOM RJFN
	SETOM SJFN		;TELNET SOCKETS
	HRROI A,GTJSTR		;MAKE A NAME FOR THE TELNET SOCKETS
	HRROI B,[ASCIZ /NET:/]
	MOVEI C,0
	SOUT
	MOVE B,SOKETS		;LOCAL SOCKET NUMBER
	MOVEI C,10		;OCTAL
	NOUT
	  0
	HRROI B,ABSTXT		;ABS SOCKET FLAG
	MOVEI C,0
	SOUT
	MOVE B,FHSTN		;FOREIGN HOST NUMBER
	MOVEI C,10		;OCTAL
	NOUT
	  0
	MOVEI B,"-"
	IDPB B,A
	MOVE B,FORNS		;SOCKET "U"
	ADDI B,2		;U+2 AND U+3
	NOUT
	  0
;FALL THRU
;FALLS IN FROM ABOVE
ACPT1:	MOVSI A,1
	HRROI B,GTJSTR
	GTJFN
	  JRST REJECT
	MOVEM A,SJFN
	MOVSI A,1
	HRROI B,GTJSTR
	GTJFN
	  JRST REJECT
	MOVEM A,RJFN
	MOVE A,LSNJFN
	MOVEI B,20		;ACCEPT THE ICP
	MTOPR
	MOVE A,LSNJFN
	MOVE B,SOKETS
	BOUT			;SEND HIM "S"
	  ERJMP REJECT 
	TLO A,(1B1)
	CLOSF
	  JFCL
	SETOM LSNJFN
	MOVE A,SJFN
	MOVE B,[103400,,100000]
	OPENF			;OPEN TELNET SEND JFN
	  JRST REJEC1
	MOVE A,RJFN
	MOVE B,[103400,,200000]
	OPENF
	  JRST REJEC1
	HRRZ A,RJFN
	HRRZ B,SJFN
ZATNVT:	ATNVT
	  JRST REJEC2
	MOVEM A,TTYNUM
	SETOM RJFN
	SETOM SJFN
	HRRZ D,TTYNUM
	ANDI D,377777
	HRRZ A,PNDJOB
	HRLI A,(1B2)		;FLAG FOR PROXY ATACH
	MOVSI B,500000
	SETZ C,
ZATACH:	ATACH
	  JRST REJEC4
	SETOM PNDJOB
	JRST REGO

REJECT:	MOVE A,LSNJFN
	TLO A,(1B1)
	SKIPL A
	CLOSF
	  JFCL
	SETOM LSNJFN
	JRST REGO
REJEC1:	MOVE A,RJFN
	TLO A,(1B1)
	SKIPL A
	CLOSF
	  JFCL
	SETOM RJFN
	MOVE A,SJFN
	TLO A,(1B1)
	SKIPL A
	CLOSF
	  JFCL
	SETOM SJFN
	JRST REJECT

REJEC2:	JRST REJEC1
REJEC4:	JRST REJEC1
chklgo:
	POPJ P,			;DO NOTHING IF WE USE IPCF INSTEAD
	setzm lgochk		;see if there are any pending lgouts
	gjinf			;get my job number
	movei y,(c)		;save it here
	move a,['jobont']	;where to look for my jobs
	sysgt
	jumpe b,cpopj		;gotta have that table
	hllz x,b		;table length
	hrrz d,b		;and number
cklo1:	move a,d
	hrl a,x
	getab
	 jrst cpopj
	caie y,(a)		;is this my job?
	jrst cklo3		;no
	tlnn a,(1b1)		;yes. is it trying to log out?
	jrst cklo2		;no.
	movei a,(x)		;yes. log it out from here.
	lgout			; ... should do any statistics first
	 jfcl			;should succeed
	movei a,(x)		;is this the one i had pending?
	camn a,pndjob		; ..
	setom pndjob		;yes. somebody lgd it out. get another.
cklo2:	aobjn x,cklo1		;check all jobs in system
	popj p,0

cklo3:	movei a,(x)		;not my job. did i think it was?
	camn a,pndjob		;was it my on-shelf job?
	setom pndjob		;yes. it isn't. make another.
	jrst cklo2
CHKPID:	SETZM PIDCHK		;HAVE SEEN THE INT.
	MOVEI A,7
	MOVEI B,PIDARG		;SEE WHAT IS ON THIS PID
	MOVE W,MYPID
	MOVEM W,PIDARG+1
	MOVEI W,.MUQRY		;INQUIRY FUNCTION
	MOVEM W,PIDARG
	MUTIL			;ASK SYSTEM
	 JRST CKPIDN		;NONE
	MOVEI A,6		;OK, RECEIVE ONE
	MOVEI B,W
	MOVE W2,MYPID
	MOVE W3,[1000,,PIDBLK]	;MESSAGE STORAGE
	MRECV			;GET THE MSG
	 JRST CKPIDN		;NONE?
	TRNN W,6B32		;FROM SYSTEM INFO (NOT SYSTEM IPCF)?
	JRST NOTINF		;NO, PROB FROM FTPSER JOB
	TRNN W,77B29		;YES, IS IT AN ERROR?
	JRST CKPIDN		;NO, IGNORE IT.
	ANDI W,7B32		;MAKE SURE ITS FROM INFO
	CAIE W,20		; ..
	JRST CKPIDN		;NOT. IGNORE.
	MOVE W,PIDARG		;YES, SEE IF RESTART ERROR
	ANDI W,77B29		; ..
	CAIE W,<.IPCSN>B29	; ..
	JRST [HRROI A,[ASCIZ /
?FTSCTL: UNKNOWN ERROR FROM INFO
/]
		PSOUT
		RET]
	CALL TELINF		;TELL INFO WHO WE ARE AGAIN
	RET

NOTINF:
	MOVE A,PIDBLK		;A LOGOUT MESSAGE?
	CAIE A,.IPCLO
	 JRST CKPIDN
	HRRZ A,PIDBLK+1		;GET JOB NUMBER
	CAMN A,PNDJOB		;IS IT THE PENDING JOB?
	 SETOM PNDJOB		;YES, REMEMBER IT IS GONE
CKPIDN:	RET

TELINF:	MOVEI A,4		;INFORM INFO WHO WE ARE
	MOVEI B,PIDARG
	SETZM PIDARG+1
	SETZM PIDARG+3
	MOVE W,MYPID		;MY PID IS STILL GOOD
	MOVEM W,PIDARG+2	;JUST TELL INFO ABOUT IT
	MOVE W,[ENDPKT-DEFPKT,,DEFPKT]
	MOVEM W,PIDARG+4
	MSEND			;SEND IT TO INFO
	 JRST [MOVEI A,^D500
		DISMS
		JRST TELINF]
	RET
PIDINT:	SETOM PIDCHK		;FLAG TO LOOK AT IT
	JRST INTWKQ		;SEE IF WANT TO WAKE UP
LSNINT:	SETOM LSNCHK		;FLAG TO LOOK AT IT
INTWKQ:	MOVEM A,PSI2A		;SAVE AC
	HRRZ A,RETPC2
	CAIE A,WAITPC
	CAIN A,WAITPC+1
	JRST LSNIN1
	MOVE A,PSI2A
	DEBRK
lgoin1:
LSNIN1:	MOVEI A,WAITPC+1
	HRLI A,(1B5)		;WITH USER MODE BIT
	MOVEM A,RETPC2
	MOVE A,PSI2A
	DEBRK


lgoint:	setom lgochk		;flag to look for logouts
	movem a,psi2a		;save an ac
	hrrz a,retpc2		;see where the process was.
	caie a,waitpc		;sleeping?
	cain a,waitpc+1		; ..
	jrst lgoin1		;yes. wake it up.
	move a,psi2a		;no. dismiss
	debrk

CRJXXX:	HRROI 1,[ASCIZ /
?FTSCTL: CAN'T CREATE JOB FOR FTP SERVICE
/]
	PSOUT
	JRST WREGO
LSNXXX:	HRROI 1,[ASCIZ /
?FTSCTL: CAN'T CREATE LISTENER SOCKET
/]
	PSOUT
WREGO:	MOVEI A,^D120000
	DISMS
	JRST REGO
PDLL==40
CRJBLK:	0		;NAME STRING FOR LOGIN
	0		;PASSWORD
	0		;ACCOUNT
	440700,,RUNFIL	;FILE TO GET
	0		;SFORKV OFFSET
	0,,377777	;TERMINAL TO START ON
	0		;TIME LIMIT
	ACBLK		;ACS TO STUFF INTO FORK
	0		;FLAGS FOR EXEC
	0		;PRIMARY JFNS
	0		;NO RUNTIME LIMIT
	0		;CAP MASK
MYPID:	0		;PID FOR IPCF ON LOGOUT OF JOB
	BLOCK 6		;SPACE FOR NEW AND FUTRE ARGS
;END OF BLOCK

ICPSKT:	3			;THE STANDARD FTP LISTENER
RUNFIL:	ASCIZ /SYSTEM:FTPSER.EXE/
LEVTAB:	RETPC1
	RETPC2
	RETPC3
CHNTAB:	0
	2,,LSNINT
	0
	2,,PIDINT		;WHEN IPCF TRAFFIC COMES
	REPEAT ^D32,<0>
DEFPKT:				;PACKET TO DEFINE FTSCTL
	4
	0
	ASCIZ /[SYSTEM]FTSCTL/	;MY NAME
ENDPKT:
CRLFM:	BYTE (7) 15,12,0
ABSTXT:	BYTE (7) <"V">&37,"#",".",0
PDP:	IOWD PDLL,PDL
SOKETS:	BLOCK 1			;SOCKET BASE OF CREATED JOB
GTJSTR:	BLOCK 20		;PLACE TO BUILD STRING FOR GTJFN
ACBLK:	BLOCK 20		;AC'S STUFFED IN SUBJOB
PDL:	BLOCK PDLL
FHSTN:	BLOCK 1
FORNS:	BLOCK 1
LSNJFN:	BLOCK 1
RJFN:	BLOCK 1
SJFN:	BLOCK 1
TTYNUM:	BLOCK 1
RETPC1:	BLOCK 1
RETPC2:	BLOCK 1
RETPC3:	BLOCK 1
PSI2A:	BLOCK 1
LSNCHK:	BLOCK 1
LGOCHK:	BLOCK 1
PRIVF:	0
NCPBLK:	BLOCK 20
PIDCHK:	BLOCK 1
PNDJOB:	BLOCK 1
PIDARG:	BLOCK 20
PIDBLK=650000		;USE PAGE 650 FOR PID TRAFFIC

	END FTSCTL