2017-12-22 21:24:30 +00:00
|
|
|
|
NEW
|
2019-05-05 17:15:37 +00:00
|
|
|
|
AUTO 3,1
|
2016-01-16 22:04:22 +00:00
|
|
|
|
.LIST OFF
|
|
|
|
|
*--------------------------------------
|
2019-05-05 17:15:37 +00:00
|
|
|
|
TCP.IN jsr FRM.GetTargetSKT.TCPUDP
|
2018-11-01 08:53:47 +00:00
|
|
|
|
|
2018-10-01 05:48:42 +00:00
|
|
|
|
jsr SKT.FindMatchingLocRem
|
|
|
|
|
bcs TCP.IN.JMP.CLOSED no socket, go discard
|
2018-11-17 17:17:13 +00:00
|
|
|
|
|
2018-10-01 05:48:42 +00:00
|
|
|
|
ldy #S.SOCKET.PROTO
|
2016-03-13 22:09:00 +00:00
|
|
|
|
lda (ZPPtrSKT),y
|
2018-10-08 15:41:00 +00:00
|
|
|
|
cmp #S.IP.PROTOCOL.TCP
|
2018-10-01 05:48:42 +00:00
|
|
|
|
bne TCP.IN.JMP.CLOSED wrong protocol, go discard
|
2017-03-13 07:07:07 +00:00
|
|
|
|
|
2017-03-07 16:40:32 +00:00
|
|
|
|
ldy #S.TCP.OPTIONS
|
|
|
|
|
lda (ZPFrameInPtr),y
|
2018-10-01 05:48:42 +00:00
|
|
|
|
and #S.TCP.OPTIONS.RST RST ? go Kill this socket...
|
|
|
|
|
bne TCP.IN.RST ...and discard frame
|
2017-03-07 16:40:32 +00:00
|
|
|
|
|
2018-09-28 15:24:44 +00:00
|
|
|
|
ldy #S.SOCKET.TCP.S
|
2017-02-16 16:26:11 +00:00
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
asl
|
|
|
|
|
tax
|
2018-09-27 15:34:38 +00:00
|
|
|
|
jmp (J.TCP.IN,x)
|
2017-02-16 16:26:11 +00:00
|
|
|
|
*--------------------------------------
|
2018-11-07 06:59:37 +00:00
|
|
|
|
TCP.IN.RST lda SKT.TABLE,x
|
|
|
|
|
jsr SKT.shutdown
|
2018-10-01 05:48:42 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
TCP.IN.JMP.CLOSED
|
2018-11-07 06:59:37 +00:00
|
|
|
|
lda hFrameIn
|
|
|
|
|
stz hFrameIn
|
2019-05-05 17:15:37 +00:00
|
|
|
|
>SYSCALL2 FreeMem
|
2018-10-01 05:48:42 +00:00
|
|
|
|
rts
|
2017-03-07 16:40:32 +00:00
|
|
|
|
*--------------------------------------
|
2019-05-05 17:15:37 +00:00
|
|
|
|
TCP.SENDCLOSE ldx #0
|
2018-11-07 06:59:37 +00:00
|
|
|
|
|
|
|
|
|
.1 phx
|
|
|
|
|
lda SKT.TABLE,x
|
|
|
|
|
beq .8
|
|
|
|
|
|
2019-05-05 17:15:37 +00:00
|
|
|
|
>SYSCALL2 GetMemPtr
|
|
|
|
|
>STYA ZPPtrSKT
|
2018-11-07 06:59:37 +00:00
|
|
|
|
|
|
|
|
|
ldy #S.SOCKET.AF
|
2019-05-05 17:15:37 +00:00
|
|
|
|
lda (ZPPtrSKT),y
|
2018-11-07 06:59:37 +00:00
|
|
|
|
cmp #AF.INET
|
|
|
|
|
bne .8
|
|
|
|
|
|
|
|
|
|
iny #S.SOCKET.T
|
|
|
|
|
|
2019-05-05 17:15:37 +00:00
|
|
|
|
lda (ZPPtrSKT),y
|
2018-11-07 06:59:37 +00:00
|
|
|
|
cmp #S.SOCKET.T.SEQPACKET
|
|
|
|
|
bcc .8
|
|
|
|
|
|
|
|
|
|
ldy #S.SOCKET.TCP.S
|
2019-05-05 17:15:37 +00:00
|
|
|
|
lda (ZPPtrSKT),y
|
2018-11-07 06:59:37 +00:00
|
|
|
|
cmp #S.SOCKET.TCP.S.TIMEWT
|
2019-05-05 17:15:37 +00:00
|
|
|
|
beq .4
|
|
|
|
|
|
|
|
|
|
cmp #S.SOCKET.TCP.S.ESTBLSH
|
2018-11-11 22:05:04 +00:00
|
|
|
|
bne .8
|
|
|
|
|
|
2019-05-05 17:15:37 +00:00
|
|
|
|
jsr TCP.OUT
|
|
|
|
|
|
|
|
|
|
bra .8
|
|
|
|
|
|
|
|
|
|
.4 ldy #S.SOCKET.SQ.hInMem
|
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
>SYSCALL2 freemem
|
|
|
|
|
|
2018-11-11 22:05:04 +00:00
|
|
|
|
ldy #S.SOCKET.SQ.hOutMem
|
2019-05-05 17:15:37 +00:00
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
>SYSCALL2 freemem
|
2018-11-07 06:59:37 +00:00
|
|
|
|
|
|
|
|
|
plx
|
|
|
|
|
phx
|
|
|
|
|
lda SKT.TABLE,x
|
2019-05-05 17:15:37 +00:00
|
|
|
|
>SYSCALL2 freemem
|
2018-11-11 22:05:04 +00:00
|
|
|
|
|
|
|
|
|
plx
|
|
|
|
|
phx
|
|
|
|
|
stz SKT.TABLE,x
|
2018-11-07 06:59:37 +00:00
|
|
|
|
|
|
|
|
|
.8 plx
|
|
|
|
|
inx
|
|
|
|
|
cpx #K.SKTTABLE.SIZE
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
2017-02-16 16:26:11 +00:00
|
|
|
|
TCP.IN.JMP.LISTEN
|
2018-10-01 15:52:58 +00:00
|
|
|
|
ldy #S.SOCKET.T Create a new client socket
|
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
tax Same type a listening socket
|
2018-11-01 08:53:47 +00:00
|
|
|
|
iny #S.SOCKET.PROTO
|
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
|
2018-10-01 15:52:58 +00:00
|
|
|
|
jsr SKT.Socket.I get new socket in ZPTmpPtr1
|
|
|
|
|
bcs TCP.IN.JMP.CLOSED
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2018-10-01 15:52:58 +00:00
|
|
|
|
jsr SKT.AddToQueueA Queued successfully ?
|
2016-04-09 09:15:11 +00:00
|
|
|
|
|
2018-10-01 15:52:58 +00:00
|
|
|
|
bcs TCP.IN.JMP.CLOSED no, discard frame and new socket
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2018-10-01 05:48:42 +00:00
|
|
|
|
jsr ARP.AddFromFrameInPtr
|
|
|
|
|
|
2018-10-01 15:52:58 +00:00
|
|
|
|
lda ZPTmpPtr1
|
2017-03-13 07:07:07 +00:00
|
|
|
|
sta ZPPtrSKT
|
2018-11-01 08:53:47 +00:00
|
|
|
|
lda ZPTmpPtr1+1
|
2017-03-13 07:07:07 +00:00
|
|
|
|
sta ZPPtrSKT+1
|
2017-02-17 07:20:57 +00:00
|
|
|
|
|
2018-11-01 08:53:47 +00:00
|
|
|
|
jsr SKT.SetLocAddr
|
|
|
|
|
jsr SKT.SetRemAddr
|
|
|
|
|
|
|
|
|
|
jsr SKT.NewTCB
|
|
|
|
|
bcs .99
|
2017-02-17 07:20:57 +00:00
|
|
|
|
|
2018-11-01 08:53:47 +00:00
|
|
|
|
jsr TCP.IN.ACKTheSYN
|
2017-02-16 16:26:11 +00:00
|
|
|
|
|
2017-03-23 16:41:36 +00:00
|
|
|
|
lda #S.TCP.OPTIONS.SYN+S.TCP.OPTIONS.ACK
|
2018-09-21 15:28:46 +00:00
|
|
|
|
jsr TCP.OUT.SendOptA SYN received, Send SYN.ACK
|
2017-02-16 16:26:11 +00:00
|
|
|
|
bcs .9
|
2017-03-14 07:32:31 +00:00
|
|
|
|
|
2018-09-28 15:24:44 +00:00
|
|
|
|
lda #S.SOCKET.TCP.S.SYNRCVD
|
2018-11-11 22:05:04 +00:00
|
|
|
|
jmp SKT.StoreTCB.S
|
2017-03-13 07:07:07 +00:00
|
|
|
|
|
2018-11-01 08:53:47 +00:00
|
|
|
|
.9 lda #ERR.SKT.OOS
|
2017-03-13 07:07:07 +00:00
|
|
|
|
.99 rts
|
2017-01-28 22:05:20 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
TCP.IN.JMP.SYNSENT
|
2017-03-14 16:46:29 +00:00
|
|
|
|
ldy #S.TCP.OPTIONS SYN Send, only accept SYN.ACK packet, then Send ACK
|
2017-03-10 16:35:54 +00:00
|
|
|
|
lda (ZPFrameInPtr),y
|
2018-09-12 15:27:00 +00:00
|
|
|
|
and #S.TCP.OPTIONS.SYN+S.TCP.OPTIONS.ACK
|
|
|
|
|
cmp #S.TCP.OPTIONS.SYN+S.TCP.OPTIONS.ACK
|
|
|
|
|
bne .9
|
2017-03-10 16:35:54 +00:00
|
|
|
|
|
2017-03-13 15:34:56 +00:00
|
|
|
|
jsr SKT.GetTCB
|
|
|
|
|
|
|
|
|
|
ldx #3
|
2017-04-10 06:07:14 +00:00
|
|
|
|
ldy #S.TCP.ACKNUM+3
|
2017-03-10 16:35:54 +00:00
|
|
|
|
|
2017-04-10 06:07:14 +00:00
|
|
|
|
sec Check if ACK=OUTNEXTSEQ+1
|
2017-03-10 16:35:54 +00:00
|
|
|
|
|
2018-11-08 14:23:06 +00:00
|
|
|
|
.1 lda SKT.Cache+S.SOCKET.TCP.OUTNEXTSEQ,x
|
2017-03-13 15:34:56 +00:00
|
|
|
|
adc #0
|
2018-11-08 14:23:06 +00:00
|
|
|
|
sta SKT.Cache+S.SOCKET.TCP.OUTNEXTSEQ,x
|
2017-03-13 15:34:56 +00:00
|
|
|
|
eor (ZPFrameInPtr),y
|
2018-09-12 15:27:00 +00:00
|
|
|
|
bne .9
|
2017-03-13 15:34:56 +00:00
|
|
|
|
dey
|
|
|
|
|
dex
|
|
|
|
|
bpl .1
|
|
|
|
|
|
2018-09-21 15:28:46 +00:00
|
|
|
|
jsr TCP.IN.ACKTheSYN
|
2018-09-03 06:01:07 +00:00
|
|
|
|
|
2017-03-13 15:34:56 +00:00
|
|
|
|
lda #S.TCP.OPTIONS.ACK
|
2017-04-10 06:07:14 +00:00
|
|
|
|
jsr TCP.OUT.SendOptA SYN.ACK recieved, Send, ACK
|
2017-03-13 15:34:56 +00:00
|
|
|
|
bcs .9
|
2017-03-10 16:35:54 +00:00
|
|
|
|
|
2018-09-28 15:24:44 +00:00
|
|
|
|
lda #S.SOCKET.TCP.S.ESTBLSH
|
2018-11-11 22:05:04 +00:00
|
|
|
|
jmp SKT.StoreTCB.S
|
2017-03-10 16:35:54 +00:00
|
|
|
|
|
2018-09-12 15:27:00 +00:00
|
|
|
|
.9 lda #S.TCP.OPTIONS.RST
|
|
|
|
|
jsr TCP.OUT.SendOptA
|
|
|
|
|
|
2018-11-08 14:23:06 +00:00
|
|
|
|
ldx SKT.Index
|
|
|
|
|
lda SKT.TABLE,x
|
|
|
|
|
jmp SKT.shutdown
|
2017-03-10 16:35:54 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
TCP.IN.JMP.SYNRCVD
|
2018-09-21 15:28:46 +00:00
|
|
|
|
ldy #S.TCP.OPTIONS SYN Received, SYN.ACK Sent, only accept ACK packet
|
2017-01-31 16:40:37 +00:00
|
|
|
|
lda (ZPFrameInPtr),y
|
2016-03-13 22:09:00 +00:00
|
|
|
|
cmp #S.TCP.OPTIONS.ACK
|
|
|
|
|
bne .8
|
|
|
|
|
|
2017-03-10 16:35:54 +00:00
|
|
|
|
jsr SKT.GetTCB
|
|
|
|
|
|
2016-03-13 22:09:00 +00:00
|
|
|
|
ldx #3
|
2017-04-10 06:07:14 +00:00
|
|
|
|
ldy #S.TCP.ACKNUM+3
|
2017-03-10 16:35:54 +00:00
|
|
|
|
|
2017-03-29 06:33:26 +00:00
|
|
|
|
sec
|
2018-11-15 07:08:20 +00:00
|
|
|
|
|
2018-11-08 14:23:06 +00:00
|
|
|
|
.1 lda SKT.Cache+S.SOCKET.TCP.OUTNEXTSEQ,x Check if ACK=OUTNEXTSEQ+1
|
2017-03-29 06:33:26 +00:00
|
|
|
|
adc #0
|
2018-11-08 14:23:06 +00:00
|
|
|
|
sta SKT.Cache+S.SOCKET.TCP.OUTSEQNUM,x setup SEQNUM
|
|
|
|
|
sta SKT.Cache+S.SOCKET.TCP.OUTNEXTSEQ,x ...and update NEXTSEQ
|
2017-03-10 16:35:54 +00:00
|
|
|
|
eor (ZPFrameInPtr),y
|
2016-03-13 22:09:00 +00:00
|
|
|
|
bne .8
|
2017-03-13 07:07:07 +00:00
|
|
|
|
dey
|
2016-03-13 22:09:00 +00:00
|
|
|
|
dex
|
2017-03-10 16:35:54 +00:00
|
|
|
|
bpl .1
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2018-09-28 15:24:44 +00:00
|
|
|
|
lda #S.SOCKET.TCP.S.ESTBLSH
|
2018-11-11 22:05:04 +00:00
|
|
|
|
jmp SKT.StoreTCB.S
|
2017-03-13 07:07:07 +00:00
|
|
|
|
|
2016-03-13 22:09:00 +00:00
|
|
|
|
.8 clc
|
2017-03-24 16:27:44 +00:00
|
|
|
|
.9 rts
|
2017-01-28 22:05:20 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
TCP.IN.JMP.ESTBLSH
|
2017-03-10 16:35:54 +00:00
|
|
|
|
jsr SKT.GetTCB
|
|
|
|
|
|
2017-01-28 22:05:20 +00:00
|
|
|
|
ldy #S.TCP.OPTIONS
|
2017-01-31 16:40:37 +00:00
|
|
|
|
lda (ZPFrameInPtr),y
|
2017-03-27 06:28:25 +00:00
|
|
|
|
and #S.TCP.OPTIONS.ACK Remote side ACKed data ?
|
2017-03-10 16:35:54 +00:00
|
|
|
|
beq .1
|
2017-02-17 16:39:38 +00:00
|
|
|
|
|
2017-03-27 06:28:25 +00:00
|
|
|
|
jsr SKT.AckDataToSktOut Yes, Discard sent data
|
|
|
|
|
jsr SKT.StoreTCB and update SKT
|
2017-02-17 16:39:38 +00:00
|
|
|
|
|
2017-03-13 15:34:56 +00:00
|
|
|
|
.1 jsr TCP.IN.SetDataInPtrAndLen
|
2017-03-13 07:07:07 +00:00
|
|
|
|
|
2017-03-14 16:46:29 +00:00
|
|
|
|
lda ZPDataInLen Incoming Data in this frame ?
|
2017-03-10 16:35:54 +00:00
|
|
|
|
ora ZPDataInLen+1
|
2017-03-14 16:46:29 +00:00
|
|
|
|
beq .2 No data, ...
|
2017-03-19 21:47:54 +00:00
|
|
|
|
|
2017-03-14 16:46:29 +00:00
|
|
|
|
jsr SKT.AddDataToSktIn yes, queue data if there is room for....
|
2017-04-10 06:07:14 +00:00
|
|
|
|
bcs .2
|
2019-05-08 19:41:46 +00:00
|
|
|
|
|
2017-04-10 06:07:14 +00:00
|
|
|
|
jsr SKT.StoreTCB success, update socket
|
|
|
|
|
|
2017-03-10 16:35:54 +00:00
|
|
|
|
.2 ldy #S.TCP.OPTIONS
|
|
|
|
|
lda (ZPFrameInPtr),y
|
2017-03-27 06:28:25 +00:00
|
|
|
|
and #S.TCP.OPTIONS.FIN
|
2017-03-13 07:07:07 +00:00
|
|
|
|
beq .8
|
2018-09-09 08:11:42 +00:00
|
|
|
|
|
2018-09-13 15:29:02 +00:00
|
|
|
|
jsr TCP.IN.ACKTheFIN
|
2018-11-11 22:05:04 +00:00
|
|
|
|
lda #S.TCP.OPTIONS.FIN+S.TCP.OPTIONS.ACK
|
|
|
|
|
jsr TCP.OUT.SendOptA FIN received, Send FIN.ACK
|
2017-03-27 06:28:25 +00:00
|
|
|
|
bcs .9
|
2017-03-24 16:27:44 +00:00
|
|
|
|
|
2018-09-28 15:24:44 +00:00
|
|
|
|
lda #S.SOCKET.TCP.S.CLWAIT
|
2018-11-11 22:05:04 +00:00
|
|
|
|
jmp SKT.StoreTCB.S
|
2018-11-01 08:53:47 +00:00
|
|
|
|
|
2017-03-27 06:28:25 +00:00
|
|
|
|
.8 clc
|
2017-03-10 16:35:54 +00:00
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
TCP.IN.JMP.CLWAIT
|
2018-11-01 08:53:47 +00:00
|
|
|
|
clc Wait for SKT.shutdown
|
2017-03-10 16:35:54 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
TCP.IN.JMP.LASTACK
|
2017-03-13 15:34:56 +00:00
|
|
|
|
ldy #S.TCP.OPTIONS only accept ACK packet
|
2017-03-10 16:35:54 +00:00
|
|
|
|
lda (ZPFrameInPtr),y
|
2018-09-09 08:11:42 +00:00
|
|
|
|
bit #S.TCP.OPTIONS.ACK
|
|
|
|
|
beq .8
|
2017-02-17 16:39:38 +00:00
|
|
|
|
|
2018-11-11 22:05:04 +00:00
|
|
|
|
ldy #S.SOCKET.TCP.S
|
|
|
|
|
lda #S.SOCKET.TCP.S.TIMEWT
|
|
|
|
|
sta (ZPPtrSKT),y
|
2017-01-28 22:05:20 +00:00
|
|
|
|
|
2017-02-17 16:39:38 +00:00
|
|
|
|
.8 clc
|
2017-02-01 16:49:44 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
TCP.IN.JMP.FINWT1
|
2018-11-11 22:05:04 +00:00
|
|
|
|
jsr SKT.GetTCB
|
|
|
|
|
|
|
|
|
|
ldy #S.TCP.OPTIONS FIN sent, accept ACK or FIN/ACK packet
|
2017-03-24 16:27:44 +00:00
|
|
|
|
lda (ZPFrameInPtr),y
|
2018-11-10 19:47:45 +00:00
|
|
|
|
bit #S.TCP.OPTIONS.FIN
|
2018-11-11 22:05:04 +00:00
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
lda #S.TCP.OPTIONS.FIN+S.TCP.OPTIONS.ACK
|
|
|
|
|
jsr TCP.OUT.SendOptA Send FIN.ACK
|
2018-11-10 19:47:45 +00:00
|
|
|
|
bcs .9
|
2018-11-11 22:05:04 +00:00
|
|
|
|
|
2018-09-28 15:24:44 +00:00
|
|
|
|
lda #S.SOCKET.TCP.S.FINWT2
|
2018-11-11 22:05:04 +00:00
|
|
|
|
jmp SKT.StoreTCB.S
|
|
|
|
|
|
|
|
|
|
.1 jsr TCP.IN.ACKTheFIN FIN/ACK
|
|
|
|
|
|
|
|
|
|
lda #S.TCP.OPTIONS.FIN+S.TCP.OPTIONS.ACK
|
|
|
|
|
jsr TCP.OUT.SendOptA Send FIN.ACK
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
lda #S.SOCKET.TCP.S.TIMEWT
|
|
|
|
|
jmp SKT.StoreTCB.S
|
2018-11-10 19:47:45 +00:00
|
|
|
|
|
2018-11-11 22:05:04 +00:00
|
|
|
|
* clc
|
2018-11-10 19:47:45 +00:00
|
|
|
|
.9 rts
|
2017-03-10 16:35:54 +00:00
|
|
|
|
*--------------------------------------
|
2017-02-01 16:49:44 +00:00
|
|
|
|
TCP.IN.JMP.FINWT2
|
2017-03-24 16:27:44 +00:00
|
|
|
|
ldy #S.TCP.OPTIONS only accept FIN packet
|
|
|
|
|
lda (ZPFrameInPtr),y
|
2018-11-10 19:47:45 +00:00
|
|
|
|
|
2018-09-05 11:31:49 +00:00
|
|
|
|
bit #S.TCP.OPTIONS.FIN
|
2018-11-10 19:47:45 +00:00
|
|
|
|
beq .8
|
2017-03-24 16:27:44 +00:00
|
|
|
|
|
2018-11-11 22:05:04 +00:00
|
|
|
|
jsr SKT.GetTCB
|
2018-09-13 15:29:02 +00:00
|
|
|
|
jsr TCP.IN.ACKTheFIN
|
2017-03-24 16:27:44 +00:00
|
|
|
|
|
2018-11-11 22:05:04 +00:00
|
|
|
|
lda #S.TCP.OPTIONS.ACK
|
|
|
|
|
jsr TCP.OUT.SendOptA FIN received, Send ACK
|
|
|
|
|
bcs .9
|
|
|
|
|
|
2018-09-28 15:24:44 +00:00
|
|
|
|
lda #S.SOCKET.TCP.S.TIMEWT
|
2018-11-11 22:05:04 +00:00
|
|
|
|
jmp SKT.StoreTCB.S
|
2017-03-24 16:27:44 +00:00
|
|
|
|
|
|
|
|
|
.8 clc
|
|
|
|
|
.9 rts
|
2017-03-10 16:35:54 +00:00
|
|
|
|
*--------------------------------------
|
2017-02-01 16:49:44 +00:00
|
|
|
|
TCP.IN.JMP.CLOSING
|
2017-03-24 16:27:44 +00:00
|
|
|
|
ldy #S.TCP.OPTIONS only accept ACK packet
|
|
|
|
|
lda (ZPFrameInPtr),y
|
2018-09-09 08:11:42 +00:00
|
|
|
|
bit #S.TCP.OPTIONS.ACK
|
|
|
|
|
beq .1
|
2017-03-24 16:27:44 +00:00
|
|
|
|
|
2018-09-28 15:24:44 +00:00
|
|
|
|
ldy #S.SOCKET.TCP.S
|
|
|
|
|
lda #S.SOCKET.TCP.S.TIMEWT
|
2017-03-24 16:27:44 +00:00
|
|
|
|
sta (ZPPtrSKT),y
|
|
|
|
|
|
|
|
|
|
.1 clc
|
|
|
|
|
rts
|
2017-03-10 16:35:54 +00:00
|
|
|
|
*--------------------------------------
|
2017-02-01 16:49:44 +00:00
|
|
|
|
TCP.IN.JMP.TIMEWT
|
2018-11-07 06:59:37 +00:00
|
|
|
|
clc Wait for TCP.Close
|
|
|
|
|
rts
|
2017-03-13 15:34:56 +00:00
|
|
|
|
*--------------------------------------
|
2018-09-21 15:28:46 +00:00
|
|
|
|
TCP.IN.ACKTheSYN
|
|
|
|
|
ldy #S.TCP.SEQNUM+3 Get Remote SEQ
|
|
|
|
|
ldx #3
|
|
|
|
|
|
|
|
|
|
sec
|
|
|
|
|
|
|
|
|
|
.3 lda (ZPFrameInPtr),y Set OUTACK=SEQ+1 for new socket...
|
|
|
|
|
adc #0
|
2018-11-08 14:23:06 +00:00
|
|
|
|
sta SKT.Cache+S.SOCKET.TCP.INLASTSEQNUM,x
|
|
|
|
|
sta SKT.Cache+S.SOCKET.TCP.OUTACKNUM,x
|
2018-09-21 15:28:46 +00:00
|
|
|
|
dey
|
|
|
|
|
dex
|
|
|
|
|
bpl .3
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2018-09-13 15:29:02 +00:00
|
|
|
|
TCP.IN.ACKTheFIN
|
2018-09-28 15:24:44 +00:00
|
|
|
|
ldy #S.SOCKET.TCP.O
|
2018-09-13 15:29:02 +00:00
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
ora #S.TCP.OPTIONS.ACK
|
|
|
|
|
sta (ZPPtrSKT),y
|
|
|
|
|
|
2018-11-11 22:05:04 +00:00
|
|
|
|
ldx #3
|
|
|
|
|
|
|
|
|
|
sec
|
2018-09-13 15:29:02 +00:00
|
|
|
|
|
2018-11-11 22:05:04 +00:00
|
|
|
|
.2 lda SKT.Cache+S.SOCKET.TCP.INLASTSEQNUM,x
|
|
|
|
|
adc #0
|
|
|
|
|
sta SKT.Cache+S.SOCKET.TCP.INLASTSEQNUM,x
|
|
|
|
|
dex
|
|
|
|
|
bpl .2
|
|
|
|
|
|
2018-09-13 15:29:02 +00:00
|
|
|
|
ldx #3
|
|
|
|
|
|
|
|
|
|
sec
|
|
|
|
|
|
2018-11-08 14:23:06 +00:00
|
|
|
|
.3 lda SKT.Cache+S.SOCKET.TCP.OUTACKNUM,x
|
2018-09-13 15:29:02 +00:00
|
|
|
|
adc #0
|
2018-11-08 14:23:06 +00:00
|
|
|
|
sta SKT.Cache+S.SOCKET.TCP.OUTACKNUM,x
|
2018-09-13 15:29:02 +00:00
|
|
|
|
dex
|
|
|
|
|
bpl .3
|
|
|
|
|
|
2018-11-11 22:05:04 +00:00
|
|
|
|
rts
|
2018-09-13 15:29:02 +00:00
|
|
|
|
*--------------------------------------
|
2017-03-13 15:34:56 +00:00
|
|
|
|
TCP.IN.SetDataInPtrAndLen
|
2017-03-19 21:47:54 +00:00
|
|
|
|
ldy #S.IP.TOTAL.LENGTH+1
|
|
|
|
|
lda (ZPFrameInPtr),y
|
|
|
|
|
sec
|
2018-11-06 16:31:13 +00:00
|
|
|
|
sbc #S.IP-S.ETH.EII
|
2017-03-19 21:47:54 +00:00
|
|
|
|
sta ZPDataInLen
|
|
|
|
|
|
|
|
|
|
dey
|
|
|
|
|
lda (ZPFrameInPtr),y
|
2018-11-06 16:31:13 +00:00
|
|
|
|
sbc /S.IP-S.ETH.EII
|
2017-03-19 21:47:54 +00:00
|
|
|
|
sta ZPDataInLen+1
|
|
|
|
|
|
2017-03-13 15:34:56 +00:00
|
|
|
|
ldy #S.TCP.DATAOFFSET
|
|
|
|
|
lda (ZPFrameInPtr),y
|
2017-03-15 06:58:13 +00:00
|
|
|
|
and #$F0 Get TCP Header len in DWORD
|
2017-03-13 15:34:56 +00:00
|
|
|
|
lsr
|
2017-03-15 06:58:13 +00:00
|
|
|
|
lsr
|
2017-03-13 15:34:56 +00:00
|
|
|
|
sta TmpOffset
|
|
|
|
|
|
2017-03-19 21:47:54 +00:00
|
|
|
|
lda ZPDataInLen
|
2017-03-13 15:34:56 +00:00
|
|
|
|
sec
|
|
|
|
|
sbc TmpOffset
|
|
|
|
|
sta ZPDataInLen
|
|
|
|
|
|
2017-03-19 21:47:54 +00:00
|
|
|
|
bcs .1
|
|
|
|
|
dec ZPDataInLen+1
|
2017-03-15 06:58:13 +00:00
|
|
|
|
|
|
|
|
|
.1 lda ZPFrameInPtr
|
2017-03-19 21:47:54 +00:00
|
|
|
|
clc
|
|
|
|
|
adc #S.IP
|
2017-03-21 21:54:59 +00:00
|
|
|
|
pha
|
2017-03-15 06:58:13 +00:00
|
|
|
|
|
|
|
|
|
lda ZPFrameInPtr+1
|
2017-03-19 21:47:54 +00:00
|
|
|
|
adc /S.IP
|
2017-03-21 21:54:59 +00:00
|
|
|
|
tax
|
2017-03-19 21:47:54 +00:00
|
|
|
|
|
2017-03-21 21:54:59 +00:00
|
|
|
|
pla
|
2017-03-19 21:47:54 +00:00
|
|
|
|
clc
|
|
|
|
|
adc TmpOffset
|
|
|
|
|
bcc .2
|
|
|
|
|
|
2017-03-21 21:54:59 +00:00
|
|
|
|
inx
|
2017-03-19 21:47:54 +00:00
|
|
|
|
|
2017-03-21 21:54:59 +00:00
|
|
|
|
.2 sta ZPDataInPtr
|
|
|
|
|
stx ZPDataInPtr+1
|
2019-05-08 19:41:46 +00:00
|
|
|
|
|
|
|
|
|
TCP.IN.RTS rts
|
2017-03-13 15:34:56 +00:00
|
|
|
|
*--------------------------------------
|
2017-03-10 16:35:54 +00:00
|
|
|
|
TCP.OUT jsr SKT.GetTCB
|
|
|
|
|
|
2018-11-08 14:23:06 +00:00
|
|
|
|
TCP.OUT.I lda SKT.Cache+S.SOCKET.TCP.OUTTOSEND+1
|
|
|
|
|
ldy SKT.Cache+S.SOCKET.TCP.OUTTOSEND
|
2017-03-10 16:35:54 +00:00
|
|
|
|
|
2017-02-13 07:26:18 +00:00
|
|
|
|
bne .1
|
2017-03-19 21:47:54 +00:00
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
tax
|
2017-03-29 06:33:26 +00:00
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
* Y,A=0 : no data to send
|
2017-03-14 07:32:31 +00:00
|
|
|
|
|
2018-09-28 15:24:44 +00:00
|
|
|
|
ldy #S.SOCKET.TCP.O
|
2017-03-14 07:32:31 +00:00
|
|
|
|
lda (ZPPtrSKT),y
|
2017-04-10 06:07:14 +00:00
|
|
|
|
bne TCP.OUT.SendOptA a least an option...
|
2017-03-23 16:41:36 +00:00
|
|
|
|
clc No, data, no flag....exit
|
|
|
|
|
rts
|
|
|
|
|
|
2017-02-13 07:26:18 +00:00
|
|
|
|
.1 cpy #K.TCP.MSS
|
|
|
|
|
pha
|
|
|
|
|
sbc /K.TCP.MSS OUTDATA > MSS ?
|
|
|
|
|
pla
|
2017-03-24 07:31:30 +00:00
|
|
|
|
bcc .2 no....keep data len
|
2017-02-13 07:26:18 +00:00
|
|
|
|
|
2017-04-10 06:07:14 +00:00
|
|
|
|
>LDYAI K.TCP.MSS yes send only MSS
|
2017-02-15 16:14:41 +00:00
|
|
|
|
|
2017-03-14 07:32:31 +00:00
|
|
|
|
.2 jsr TCP.NewFrame
|
2019-05-08 19:41:46 +00:00
|
|
|
|
bcs TCP.IN.RTS
|
2017-02-15 16:14:41 +00:00
|
|
|
|
|
|
|
|
|
jsr SKT.GetDataFromSktOut
|
2017-03-10 16:35:54 +00:00
|
|
|
|
|
2018-09-28 15:24:44 +00:00
|
|
|
|
ldy #S.SOCKET.TCP.O
|
2017-02-15 16:14:41 +00:00
|
|
|
|
lda (ZPPtrSKT),y
|
2019-05-05 17:15:37 +00:00
|
|
|
|
ora #S.TCP.OPTIONS.ACK+S.TCP.OPTIONS.PSH
|
2019-05-08 19:41:46 +00:00
|
|
|
|
sta (ZPPtrSKT),y
|
|
|
|
|
|
|
|
|
|
jsr TCP.OUT.Send
|
2017-02-15 16:14:41 +00:00
|
|
|
|
|
2019-05-08 19:41:46 +00:00
|
|
|
|
bcs TCP.IN.RTS
|
2017-03-31 06:28:43 +00:00
|
|
|
|
|
2018-11-08 14:23:06 +00:00
|
|
|
|
lda SKT.Cache+S.SOCKET.TCP.OUTNEXTSEQ+3
|
2017-03-31 06:28:43 +00:00
|
|
|
|
clc
|
|
|
|
|
adc ZPDataOutLen
|
2018-11-08 14:23:06 +00:00
|
|
|
|
sta SKT.Cache+S.SOCKET.TCP.OUTNEXTSEQ+3
|
2017-03-31 06:28:43 +00:00
|
|
|
|
|
2018-11-08 14:23:06 +00:00
|
|
|
|
lda SKT.Cache+S.SOCKET.TCP.OUTNEXTSEQ+2
|
2017-03-31 06:28:43 +00:00
|
|
|
|
adc ZPDataOutLen+1
|
2018-11-08 14:23:06 +00:00
|
|
|
|
sta SKT.Cache+S.SOCKET.TCP.OUTNEXTSEQ+2
|
2017-03-31 06:28:43 +00:00
|
|
|
|
bcc .80
|
2018-11-08 14:23:06 +00:00
|
|
|
|
inc SKT.Cache+S.SOCKET.TCP.OUTNEXTSEQ+1
|
2017-03-31 06:28:43 +00:00
|
|
|
|
bne .80
|
2018-11-08 14:23:06 +00:00
|
|
|
|
inc SKT.Cache+S.SOCKET.TCP.OUTNEXTSEQ
|
2017-03-31 06:28:43 +00:00
|
|
|
|
|
2018-09-04 15:29:15 +00:00
|
|
|
|
.80 jmp SKT.StoreTCB exits with CC
|
2017-03-23 16:41:36 +00:00
|
|
|
|
*--------------------------------------
|
2017-04-10 06:07:14 +00:00
|
|
|
|
TCP.OUT.SendOptA
|
2019-05-08 19:41:46 +00:00
|
|
|
|
ldy #S.SOCKET.TCP.O
|
|
|
|
|
ora (ZPPtrSKT),y
|
|
|
|
|
sta (ZPPtrSKT),y
|
|
|
|
|
|
2017-03-23 16:41:36 +00:00
|
|
|
|
>LDYAI 0
|
|
|
|
|
jsr TCP.NewFrame
|
2019-05-08 19:41:46 +00:00
|
|
|
|
bcs TCP.IN.RTS
|
2017-03-23 16:41:36 +00:00
|
|
|
|
|
2019-05-08 19:41:46 +00:00
|
|
|
|
TCP.OUT.Send ldy #S.SOCKET.TCP.O
|
|
|
|
|
lda (ZPPtrSKT),y
|
2017-04-10 06:07:14 +00:00
|
|
|
|
ldy #S.TCP.OPTIONS
|
2017-03-27 06:28:25 +00:00
|
|
|
|
sta (ZPFrameOutPtr),y
|
2019-05-08 19:41:46 +00:00
|
|
|
|
|
2018-09-05 11:31:49 +00:00
|
|
|
|
bit #S.TCP.OPTIONS.ACK
|
2019-05-08 19:41:46 +00:00
|
|
|
|
beq .2
|
2017-04-07 06:31:47 +00:00
|
|
|
|
|
2017-03-29 06:33:26 +00:00
|
|
|
|
ldx #3
|
2017-04-10 06:07:14 +00:00
|
|
|
|
ldy #S.TCP.ACKNUM+3
|
2017-03-29 06:33:26 +00:00
|
|
|
|
|
2018-11-08 14:23:06 +00:00
|
|
|
|
.1 lda SKT.Cache+S.SOCKET.TCP.OUTACKNUM,x
|
2017-03-29 06:33:26 +00:00
|
|
|
|
sta (ZPFrameOutPtr),y
|
|
|
|
|
dey
|
|
|
|
|
dex
|
2017-04-12 06:12:39 +00:00
|
|
|
|
bpl .1
|
2017-03-29 06:33:26 +00:00
|
|
|
|
|
2019-05-08 19:41:46 +00:00
|
|
|
|
.2 ldx #3
|
2017-04-10 06:07:14 +00:00
|
|
|
|
ldy #S.TCP.SEQNUM+3
|
2017-03-13 15:34:56 +00:00
|
|
|
|
|
2019-05-08 19:41:46 +00:00
|
|
|
|
.3 lda SKT.Cache+S.SOCKET.TCP.OUTNEXTSEQ,x
|
2017-03-13 15:34:56 +00:00
|
|
|
|
sta (ZPFrameOutPtr),y
|
|
|
|
|
dey
|
|
|
|
|
dex
|
2019-05-08 19:41:46 +00:00
|
|
|
|
bpl .3
|
2017-03-13 15:34:56 +00:00
|
|
|
|
|
2017-03-23 16:41:36 +00:00
|
|
|
|
ldy #S.TCP.WINDOW
|
2018-11-08 14:23:06 +00:00
|
|
|
|
lda SKT.Cache+S.SOCKET.TCP.INFREE+1
|
2017-03-23 16:41:36 +00:00
|
|
|
|
sta (ZPFrameOutPtr),y
|
|
|
|
|
iny
|
2018-11-08 14:23:06 +00:00
|
|
|
|
lda SKT.Cache+S.SOCKET.TCP.INFREE
|
2017-03-23 16:41:36 +00:00
|
|
|
|
sta (ZPFrameOutPtr),y
|
|
|
|
|
|
|
|
|
|
jsr FRM.SendIP
|
2017-02-15 16:14:41 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
2018-09-28 15:24:44 +00:00
|
|
|
|
ldy #S.SOCKET.TCP.O
|
2017-03-09 07:11:44 +00:00
|
|
|
|
lda #0
|
2017-02-15 16:14:41 +00:00
|
|
|
|
sta (ZPPtrSKT),y
|
2017-03-23 16:41:36 +00:00
|
|
|
|
|
2018-09-13 15:29:02 +00:00
|
|
|
|
* clc
|
2017-02-15 16:14:41 +00:00
|
|
|
|
.9 rts
|
2017-02-13 07:26:18 +00:00
|
|
|
|
*--------------------------------------
|
2017-02-16 16:26:11 +00:00
|
|
|
|
TCP.NewFrame ldx #S.IP.PROTOCOL.TCP
|
|
|
|
|
jsr FRM.NewIP
|
|
|
|
|
bcs .9
|
2017-01-28 22:05:20 +00:00
|
|
|
|
|
2017-02-16 16:26:11 +00:00
|
|
|
|
jsr SKT.SetFrameOutDstIP
|
|
|
|
|
|
2018-09-17 15:42:38 +00:00
|
|
|
|
jsr SKT.SetFrameOutTCPUDPPorts
|
2017-02-17 07:20:57 +00:00
|
|
|
|
|
|
|
|
|
ldy #S.TCP.DATAOFFSET
|
|
|
|
|
lda #$50 Header size = 5 DWORDS
|
|
|
|
|
sta (ZPFrameOutPtr),y
|
|
|
|
|
|
|
|
|
|
ldy #S.TCP.WINDOW
|
2018-11-08 14:23:06 +00:00
|
|
|
|
lda SKT.Cache+S.SOCKET.TCP.INFREE+1
|
2017-02-17 07:20:57 +00:00
|
|
|
|
sta (ZPFrameOutPtr),y
|
|
|
|
|
iny
|
2018-11-08 14:23:06 +00:00
|
|
|
|
lda SKT.Cache+S.SOCKET.TCP.INFREE
|
2017-02-17 07:20:57 +00:00
|
|
|
|
sta (ZPFrameOutPtr),y
|
|
|
|
|
|
2016-04-09 09:15:11 +00:00
|
|
|
|
clc
|
2017-02-16 16:26:11 +00:00
|
|
|
|
.9 rts
|
2016-04-09 09:15:11 +00:00
|
|
|
|
*--------------------------------------
|
2016-01-16 22:04:22 +00:00
|
|
|
|
MAN
|
2018-11-17 17:17:13 +00:00
|
|
|
|
SAVE USR/SRC/LIB/LIBTCPIP.S.TCP
|
|
|
|
|
LOAD USR/SRC/LIB/LIBTCPIP.S
|
2016-01-16 22:04:22 +00:00
|
|
|
|
ASM
|