From: bygg@sunic.sunet.se (Johnny Eriksson)
Subject: Re: TCP/IP for Tops-10
Organization: Royal Institute of Technology, Stockholm, Sweden
Date: Sun, 10 Jan 1993 00:18:13 GMT

In article <1993Jan8.195139.27625@novell.com> donp@novell.com (don provan) writes:

>Gee, if i'd known there'd be this much interest, i would have posted the
>answer instead of just sending it directly.  I implemented TCP/IP on
>TOPS-10.  There's no relation between the TOPS-10 implementation and the
>TENEX/TOPS-20 implementation.  On the other hand, a derivitive of the
>TOPS-10 code ran on WAITS, just in case anyone thought this conversation
>wasn't obscure enough yet.  To my knowledge, there is no copy of the
>code on the face of the earth, though i'd be happy to hear someone tell
>me i'm wrong, particularly if they could send me a copy.

See below.

>And, although i can't imagine anyone really cares, it ran on 6.02 and
>6.03a.  After that i'm a little vague, but i think i got it to run on
>7.00, but not 7.01.  Something about radical changes to the IO system
>in 7.01, but, gee, that was many years ago so i don't remember the details.

It has been running on 7.02, talking IP-on-top-of-DDCMP to a VAX running
BSD 4.2, thru an ANF-10 front end sync port instead of using an IMP.
This required some slight changes...

Beginning if TCPSER.MAC follows, to prove I'm not lying:

title	TCPSer
subttl	provan

	search	f,s
	search	NetDef		; network definitions
	search	MacTen		; search only if symbol not found in NetDef

	sall

	$reloc
	$high

XP	VTCPSr,7		; TCP version
comment	\

this module contains the support routines for the transmission
control protocol as defined in RFC-793

\
	subttl	compilation control

; number of perpetual listens to allow at one time.
; [udp] make global
ifndef PlsLen,<	PlsLen==:^d10 >		; default is 10 entries
	subttl	TCP states


; first define the states we have for TCP

S%Clos==^d0		;; closed (sometimes convenient, although usually
			;;		detected by absense of DDB)
			;; must ALWAYS be zero.  "closed" type states are
			;;	less than or equal to zero.
S%List==^d1		;; listen
S%SynS==^d2		;; SYN sent
S%SyRP==^d3		;; SYN received, passive
S%SyRA==^d4		;; SYN received, active (from S%SynS)
S%Estb==^d5		;; established
S%Fin1==^d6		;; FIN wait 1
S%Fin2==^d7		;; FIN wait 2
S%Clsn==^d8		;; Closing
S%TimW==^d9		;; time wait
S%ClsW==^d10		;; Close wait
S%LAck==^d11		;; last ACK
	subttl	macro for dispatching on different states


; now define a macro to define a dispatch vector.  there are three
;  arguments.  the first is the register containing the state code.
;  the second is the location to jump to if a state comes which
;  is not defined in this table.  the third is a list of pairs of
;  entries: the state code and the instruction to execute.

;warning: the state pairs MUST begin on the same line as the second
;	argument.  state pairs MUST be separated from each other with
;	commas (between each pair) which MUST be on the same line as
;	the macro which FOLLOWs.

define	Dispat (AC,ErrLoc,StPair),
    <
	...min==777777			;; a high starting point
	...max==-1			;; and a low one
	define	Pair (state,instr),
	    <
		ifl <state>-...min,<	...min==<state>	>
		ifg <state>-...max,<	...max==<state>	>
	    >

	define	$$help(bogus),<	pair(bogus) >	;; your classic helper macro

	irp StPair,<		;; for each pair
		$$help(StPair)	;; expand the Pair macro with each pair
				;;  the as arguments.
	>

	;; code to check to see if the state is in the legal range
	cail	<AC>,...min		;; less than the lowest we know
	 caile	<AC>,...max		;; or greater than the highest
	  jrst	<ErrLoc>		;; go to the error handler

	define	Pair (state,instr),
	    <
		ife ...x-<state>,<	;; is this our state?
			instr		;; expand the instruction
			...flg==1	;; and tell that we did something
		>
	    >

	;; code for the actual dispatching
	xct	[
		 ...x==...min		;; start with lowest state
		 repeat ...max-...min+1,<	;; do every state in the range
		    ...flg==0		;; nobody's claimed this spot yet
		    irp StPair,<	;; go through all the pairs
			$$help(StPair)	;; expanding the Pair macro with each.
		    >
		    ife ...flg,<	;; if no one claimed to be this
			jrst	<ErrLoc>;; go to the error handler
		    >
		    ...x==...x+1	;; next place.
		 >
		]-...min(<AC>)		;; now correctly index the XCT
	purge	...min,...max,...x,...flg
    >	;; end of Dispat macro definition

;; Let's skip to an interesting routine:

	subttl	SecChk

;++
; Functional description:
;
;	Classified.
;
;
; Calling sequence:
;
;	Classified.
;
; Input parameters:
;
;	Classified.
;
; Output parameters:
;
;	Classified.
;
; Implicit inputs:
;
;	Classified.
;
; Implicit outputs:
;
;	Classified.
;
; Routine value:
;
;	Classified.
;
; Side effects:
;
;	Classified.
;
;--


SecChk:	pjrst	cpopj1##		; security looks good.

>						don provan
>						donp@novell.com

--Johnny

"When in doubt -- hesitate!"