1
0
mirror of https://github.com/PDP-10/stacken.git synced 2026-01-28 12:39:06 +00:00
Files
PDP-10.stacken/files/stacken-tape-backup/dskb:1_2/telnet.mac
Lars Brinkhoff 6e18f5ebef Extract files from tape images.
Some tapes could not be extracted.
2021-01-29 10:47:33 +01:00

334 lines
6.1 KiB
Plaintext

title telnet -- first telnet attepmt.
search jobdat, uuosym,macten
.text "/symseg:low/locals"
opdef tcp. [call [sixbit "tcp."]]
define error(msg),<
jrst[ outstr[ asciz "msg"]
outstr[ byte (7) 15, 12, 0]
jrst quit]
>;error macro
tty==1
tcp==2
t1==1
t2==2
t3==3
t4==4
pc==16 ;State for coroutine.
p==17
dummy: block 1
rport: exp ^D23 ;Telnet, default port.
raddr: pc2 ;Default remote address.
pc2: byte (8) ^D192, ^D168, ^D111, ^D58
bygg2: byte (8) ^D192, ^D168, ^D111, ^D59
topsy: byte (8) ^D192, ^D168, ^D111, ^D60
paf.se: byte (8) ^D64, ^D168, ^D243, ^D36
spare: exp 0
tib: block 3 ;TCP: input buffer header.
tob: block 3 ;TCP: output buffer header.
tcb: phase 0
.tcfnc:!block 1 ;Function code.
.tcfoa==0 ; Open active.
.tcfop==1 ; Open passive.
.tcfcl==2 ; Close.
.tcfab==3 ; Abort.
.tcfgs==4 ; Get status.
.tcdev:!block 1 ;Device/channel.
.tcflg:!block 1 ;Flags etc.
.tclad:!block 1 ;local address.
.tcrad:!block 1 ;remote address.
.tclpr:!block 1 ;local port.
.tcrpr:!block 1 ;remote port.
.tcbuf:!block 1 ;status buffer ptr.
.tccnt:!block 1 ;status buffer size.
dephase
dirty: exp 0 ;TCP: buffer has data, needs dumping.
ttyflg: exp 0 ;TTY: input done flag.
tcpflg: exp 0 ;TCP: input done flag.
slploc: sleep t1, ;Race condition workaround.
pdl: block <pdllen==^D100> ;Stack.
vector:
vectcp: exp tcpint, 0, 0, 0
vectty: exp ttyint, 0, 0, 0
tt:: jfcl
reset
move p,[iowd pdllen,pdl]
movei t1,vector
piini. t1,
jfcl
movx t1,ps.fon
pisys. t1,
jfcl
open tcp,[
exp uu.aio+.iobyt
sixbit 'tcp'
xwd tob, tib]
error(Can't open TCP:)
move t1,[
ps.fac+[exp tcp
xwd <vectcp-vector>,ps.rid!ps.rod!ps.rdo!ps.rol!ps.rsw
xwd 0,0]]
pisys. t1,
jfcl
open tty,[
exp uu.aio+io.sup+.ioasc
sixbit 'tty'
xwd 0, 0] ;Do TTCALLs.
error(Can't open TTY:)
move t1,[
ps.fac+[exp tty
xwd <vectty-vector>,ps.rid!ps.rod!ps.ria
xwd 0,0]]
pisys. t1,
jfcl
skpinc ;Prime the pump.
jfcl ; . . .
movei t1,.tcfoa
movem t1,tcb+.tcfnc ;Function, open active.
movei t1,tcp
movem t1,tcb+.tcdev ;Device/channel.
setzm tcb+.tcflg ;No flags.
setzm tcb+.tclad ;Default the local address.
mstime t1, ;Get some random value.
andi t1,177776 ;Mask down to 16 bits, -
addi t1,1 ; and a non-zero value.
movem t1,tcb+.tclpr ;This is our local port.
move t1,rport
movem t1,tcb+.tcrpr ;Set up our remote port.
move t1,@raddr
movem t1,tcb+.tcrad ;Set up our remote address.
setzm tcb+.tcbuf ;No buffer.
movei t1,tcb ;Try to connect.
tcp. t1,
error(Can't open tcp connection)
jsp pc,istm ;Init input state machine.
loop: move t2,[sleep t1,]
movem t2,slploc
skipe ttyflg
pushj p,dotty
skipe tcpflg
pushj p,dotcp
movei t1,^D60
xct slploc
jrst loop
dotty: setzm ttyflg
setzm dirty
tloop: inchrs t3
jrst tcpfls
pushj p,tcpchr
jrst tloop
tcpchr: sosge tob+.bfctr
jrst[ out tcp,
jrst tcpchr
movei t2,1
sleep t2,
jrst @.]
idpb t3,tob+.bfptr
setom dirty
popj p,
tcpfls: skipn dirty
popj p,
setzm dirty
out tcp,
popj p,
movei t2,1
sleep t2,
jrst tcpfls
quit: monrt.
jrst tt
dotcp: sosge tib+.bfctr
jrst[ in tcp,
jrst dotcp
jrst tcpfls]
ildb t3,tib+.bfptr
jsp pc,(pc)
jrst dotcp
; state machine for input data:
istm: jsp pc,(pc) ;Get next char.
cain t3,^D255 ;IAC?
jrst i.iac ; Yep.
istm2: outchr t3
jrst istm ;Loop.
i.iac: jsp pc,(pc) ;Get next char.
cain t3,^D255 ;IAC again?
jrst istm2 ; Yep, is itself.
cain t3,^D254 ;DONT?
jrst i.dont
cain t3,^D253 ;DO?
jrst i.do
cain t3,^D252 ;WONT?
jrst i.wont
cain t3,^D251 ;WILL?
jrst i.will
; ...
jrst istm
; 251.
i.will: jsp pc,(pc) ;Get option.
cain t3,1 ;ECHO?
jrst wl.e ; Handle.
cain t3,3 ;SUP GA?
jrst wl.sga ; Handle.
push p,t3 ;Save.
movei t3,^D255
pushj p,tcpchr
movei t3,^D254 ;DONT
pushj p,tcpchr
pop p,t3
pushj p,tcpchr
jrst istm
wl.e: movei t3,^D255 ;IAC
pushj p,tcpchr
movei t3,^D253 ;DO
pushj p,tcpchr
movei t3,^D1 ;ECHO
pushj p,tcpchr
jrst istm
wl.sga: movei t3,^D255 ;IAC
pushj p,tcpchr
movei t3,^D253 ;DO
pushj p,tcpchr
movei t3,^D3 ;SUP GA.
pushj p,tcpchr
jrst istm
; 252.
i.wont: jsp pc,(pc) ;Get option.
push p,t3 ;Save.
movei t3,^D255
pushj p,tcpchr
movei t3,^D254 ;DONT
pushj p,tcpchr
pop p,t3
pushj p,tcpchr
jrst istm
; 253.
i.do: jsp pc,(pc) ;Get option.
cain t3,1 ;ECHO?
jrst do.e ; Yes, handle.
cain t3,3 ;SUP-GA?
jrst do.sga ; Yes, accept.
push p,t3 ;Save.
movei t3,^D255
pushj p,tcpchr
movei t3,^D252 ;WONT
pushj p,tcpchr
pop p,t3
pushj p,tcpchr
jrst istm
do.e:
do.sga: push p,t3 ;Save opt.
movei t3,^D255 ;IAC
pushj p,tcpchr
movei t3,^D251 ;WILL
pushj p,tcpchr
pop p,t3 ;Option.
pushj p,tcpchr
jrst istm
; 254.
i.dont: jsp pc,(pc) ;Get option.
push p,t3 ;Save.
movei t3,^D255
pushj p,tcpchr
movei t3,^D252 ;WONT
pushj p,tcpchr
pop p,t3
pushj p,tcpchr
jrst istm
ttyint: setom ttyflg
dismis: movem t1,slploc
movsi t1,(jfcl)
exch t1,slploc
debrk.
jfcl
error(DEBRK. returned!)
tcpint: setom tcpflg
jrst dismis
foo: move t1,vectcp+.psvfl
trnn t1,ps.rsw
jrst hand.2
movei t1,[
exp 4
exp tcp
repeat 10,<0>]
tcp. t1,
halt
cail t1,0
caile t1,^D10
movei t1,^D11
outstr[ asciz "state: "]
outstr@[exp[ asciz "closed"]
exp[ asciz "listen"]
exp[ asciz "syn-sent"]
exp[ asciz "syn-received"]
exp[ asciz "established"]
exp[ asciz "fin-wait 1"]
exp[ asciz "fin-wait 2"]
exp[ asciz "closing"]
exp[ asciz "time-wait"]
exp[ asciz "close-wait"]
exp[ asciz "last-ack"]
exp[ asciz "???"]](1)
outstr[ byte (7) 15, 12, 0]
hand.2: jfcl
copy: sosge tib+.bfctr
jrst nxtbuf
ildb t1,tib+.bfptr
jsp pc,(pc)
jrst copy
nxtbuf: statz tcp,io.eof
jrst hand.4
in tcp,
jrst copy
hand.3: statz tcp,io.eof
hand.4: outstr[asciz "EOF
"]
movei t1,^D60
debrk.
jfcl
halt
end tt