A2osX/LIB/LIBTCPIP.S.TCP.txt

654 lines
13 KiB
Plaintext
Raw Normal View History

2017-12-22 21:24:30 +00:00
NEW
2019-05-05 17:15:37 +00:00
AUTO 3,1
*--------------------------------------
2019-05-05 17:15:37 +00:00
TCP.IN jsr FRM.GetTargetSKT.TCPUDP
2018-10-01 05:48:42 +00:00
jsr SKT.FindMatchingLocRem
2019-10-28 16:20:40 +00:00
bcs TCP.IN.JMP.DISCARD no socket, go discard
2018-11-17 17:17:13 +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
2019-10-28 16:20:40 +00:00
2018-09-28 15:24:44 +00:00
ldy #S.SOCKET.TCP.S
lda (ZPPtrSKT),y
asl
tax
2018-09-27 15:34:38 +00:00
jmp (J.TCP.IN,x)
*--------------------------------------
TCP.IN.RST lda #S.SOCKET.TCP.S.TIMEWT
2020-09-12 12:09:24 +00:00
ldy #S.SOCKET.TCP.S
sta (ZPPtrSKT),y
2018-10-01 05:48:42 +00:00
*--------------------------------------
TCP.IN.JMP.CLOSED
TCP.IN.JMP.OPENED
2019-10-28 16:20:40 +00:00
TCP.IN.JMP.DISCARD
clc
rts
*--------------------------------------
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
2019-10-28 16:20:40 +00:00
bcs TCP.IN.JMP.DISCARD
2018-10-01 15:52:58 +00:00
jsr SKT.AddToQueueA Queued successfully ?
2021-01-12 21:14:13 +00:00
bcs TCP.IN.JMP.DISCARD no, discard frame and new socket
2018-10-01 05:48:42 +00:00
jsr ARP.AddFromFrameInPtr
2018-10-01 15:52:58 +00:00
lda ZPTmpPtr1
sta ZPPtrSKT
2018-11-01 08:53:47 +00:00
lda ZPTmpPtr1+1
sta ZPPtrSKT+1
2018-11-01 08:53:47 +00:00
jsr SKT.SetLocAddr
jsr SKT.SetRemAddr
jsr SKT.NewTCB
2020-06-05 19:26:34 +00:00
bcs .9
2019-10-28 16:20:40 +00:00
2018-11-01 08:53:47 +00:00
jsr TCP.IN.ACKTheSYN
2020-05-30 20:38:47 +00:00
lda #S.SOCKET.TCP.S.OPENED
jsr SKT.StoreTCB.S
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
bcs .9
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
2021-01-12 21:14:13 +00:00
2020-06-05 19:26:34 +00:00
.9 rts
*--------------------------------------
TCP.IN.JMP.SYNSENT
2021-01-12 21:14:13 +00:00
ldy #S.TCP.OPTIONS SYN Send, only accept SYN.ACK packet, then Send ACK
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
jsr SKT.GetTCB
ldx #3
ldy #S.TCP.ACKNUM+3
sec Check if ACK=OUTNEXTSEQ+1
2018-11-08 14:23:06 +00:00
.1 lda SKT.Cache+S.SOCKET.TCP.OUTNEXTSEQ,x
adc #0
2021-01-12 21:14:13 +00:00
sta SKT.Cache+S.SOCKET.TCP.OUTNEXTSEQ,x
eor (ZPFrameInPtr),y
2018-09-12 15:27:00 +00:00
bne .9
dey
dex
bpl .1
2018-09-21 15:28:46 +00:00
jsr TCP.IN.ACKTheSYN
2018-09-03 06:01:07 +00:00
2021-05-19 12:44:47 +00:00
jsr TCP.OUT.SendACK SYN.ACK received, Send, ACK
bcs .9
2021-05-19 12:44:47 +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
2021-05-19 12:44:47 +00:00
2018-09-12 15:27:00 +00:00
.9 lda #S.TCP.OPTIONS.RST
2019-06-12 15:39:07 +00:00
jsr TCP.OUT.SendOptA Send RST
jmp TCP.IN.RST
*--------------------------------------
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
lda (ZPFrameInPtr),y
cmp #S.TCP.OPTIONS.ACK
bne .8
jsr SKT.GetTCB
2021-01-12 21:14:13 +00:00
ldx #3
ldy #S.TCP.ACKNUM+3
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
adc #0
2019-06-17 06:35:54 +00:00
sta SKT.Cache+S.SOCKET.TCP.OUTSENTSEQ,x setup SEQNUM
2018-11-08 14:23:06 +00:00
sta SKT.Cache+S.SOCKET.TCP.OUTNEXTSEQ,x ...and update NEXTSEQ
eor (ZPFrameInPtr),y
bne .8
2021-05-19 12:44:47 +00:00
dey
dex
bpl .1
2021-05-19 12:44:47 +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
2021-01-12 21:14:13 +00:00
.8 clc
.9 rts
*--------------------------------------
TCP.IN.JMP.ESTBLSH
jsr SKT.GetTCB
ldy #S.TCP.OPTIONS
lda (ZPFrameInPtr),y
and #S.TCP.OPTIONS.ACK Remote side ACKed data ?
2019-06-05 15:34:49 +00:00
beq .4
*--------------------------------------
2021-01-12 21:14:13 +00:00
* Ack sent data
*--------------------------------------
2019-06-05 15:34:49 +00:00
ldy #S.TCP.ACKNUM+3 Get new ACK number from FrameIn...
ldx #3 Substract old ACK from socket
sec
.1 lda (ZPFrameInPtr),y
pha
2019-06-17 06:35:54 +00:00
sbc SKT.Cache+S.SOCKET.TCP.OUTSENTSEQ,x
2019-06-05 15:34:49 +00:00
sta TmpDWord,x
pla ....and Set SEQ = new SEQ
2019-06-17 06:35:54 +00:00
sta SKT.Cache+S.SOCKET.TCP.OUTSENTSEQ,x
2019-06-05 15:34:49 +00:00
dey
dex
bpl .1
bcc .7 ACK > SENT SEQ ????
2021-03-11 21:40:55 +00:00
2019-06-05 15:34:49 +00:00
lda TmpDWord+3
ldx TmpDWord+2
bne .2
2021-03-11 21:40:55 +00:00
2019-06-05 15:34:49 +00:00
tay
2019-06-12 05:56:34 +00:00
beq .4
2019-06-05 15:34:49 +00:00
2019-06-17 06:35:54 +00:00
.2 pha
clc
2019-06-05 15:34:49 +00:00
adc SKT.Cache+S.SOCKET.TCP.OUTTAIL
sta SKT.Cache+S.SOCKET.TCP.OUTTAIL
txa
adc SKT.Cache+S.SOCKET.TCP.OUTTAIL+1
and /K.TCP.WSIZE-1
sta SKT.Cache+S.SOCKET.TCP.OUTTAIL+1
2019-06-17 06:35:54 +00:00
pla
2019-06-05 15:34:49 +00:00
clc
2019-06-17 06:35:54 +00:00
adc SKT.Cache+S.SOCKET.TCP.OUTFREE
2019-06-05 15:34:49 +00:00
sta SKT.Cache+S.SOCKET.TCP.OUTFREE
2019-06-17 06:35:54 +00:00
txa
adc SKT.Cache+S.SOCKET.TCP.OUTFREE+1
2019-06-05 15:34:49 +00:00
sta SKT.Cache+S.SOCKET.TCP.OUTFREE+1
lda SKT.Cache+S.SOCKET.TCP.OUTUSED
sec
sbc TmpDWord+3
sta SKT.Cache+S.SOCKET.TCP.OUTUSED
lda SKT.Cache+S.SOCKET.TCP.OUTUSED+1
sbc TmpDWord+2
sta SKT.Cache+S.SOCKET.TCP.OUTUSED+1
2019-07-07 20:48:57 +00:00
jsr SKT.StoreTCB
*--------------------------------------
2019-06-17 06:35:54 +00:00
* Store incoming data
*--------------------------------------
2019-06-05 15:34:49 +00:00
.4 jsr TCP.IN.SetDataInPtrAndLen
lda ZPDataInLen Incoming Data in this frame ?
ora ZPDataInLen+1
2019-06-11 15:47:18 +00:00
beq .7 No data, ...
ldy #S.TCP.SEQNUM+3
ldx #3
.5 lda (ZPFrameInPtr),y
eor SKT.Cache+S.SOCKET.TCP.INSEQNUM,x
2020-11-29 18:24:11 +00:00
bne .90 Missed a frame.....
2021-01-12 21:14:13 +00:00
2020-06-05 19:26:34 +00:00
dey
2019-06-11 15:47:18 +00:00
dex
bpl .5
2020-06-05 19:26:34 +00:00
ldy #S.SOCKET.T
2019-10-28 16:20:40 +00:00
lda (ZPPtrSKT),y
cmp #S.SOCKET.T.STREAM
bne .52
2020-06-05 19:26:34 +00:00
jsr SKT.AddDataToSktIn yes, queue data if there is room for....
2020-06-07 13:47:00 +00:00
bcc .6
2021-01-12 21:14:13 +00:00
2020-06-07 13:47:00 +00:00
rts
2021-01-12 21:14:13 +00:00
2019-10-28 16:20:40 +00:00
.52 lda hFrameIn
jsr SKT.AddToQueueA
2020-09-05 13:38:04 +00:00
bcs .99
2020-06-05 19:26:34 +00:00
2020-06-07 13:47:00 +00:00
stz hFrameIn DON'T DISCARD
2020-06-05 19:26:34 +00:00
.6 lda ZPDataInLen
2019-07-28 20:39:30 +00:00
ldy ZPDataInLen+1
ldx #S.SOCKET.TCP.INSEQNUM
jsr TCP.AddAYToSktCacheAtX
2021-01-12 21:14:13 +00:00
2020-06-05 19:26:34 +00:00
jsr SKT.StoreTCB update socket
2019-07-07 20:48:57 +00:00
2019-06-11 15:47:18 +00:00
.7 ldy #S.TCP.OPTIONS
lda (ZPFrameInPtr),y
and #S.TCP.OPTIONS.FIN
beq .8
2018-09-09 08:11:42 +00:00
jsr TCP.IN.ACKTheFIN
2023-10-18 05:41:12 +00:00
jsr TCP.OUT.SendFINACK
lda #S.SOCKET.TCP.S.LASTACK
2020-06-29 05:49:24 +00:00
jmp SKT.StoreTCB.S
2020-06-17 19:05:36 +00:00
.8 ldy #S.SOCKET.TCP.O
lda (ZPPtrSKT),y
2020-09-07 20:40:50 +00:00
bne .91
2021-01-12 21:14:13 +00:00
2020-06-17 19:05:36 +00:00
.80 clc
2020-09-07 20:40:50 +00:00
.99 rts
2020-09-05 13:38:04 +00:00
2021-03-15 15:00:27 +00:00
.90
* lda #S.TCP.OPTIONS.ACK Send 3 ACK for last SEQ number
* jsr TCP.OUT.SendOptA
2021-01-12 21:14:13 +00:00
2021-03-15 15:00:27 +00:00
* lda #S.TCP.OPTIONS.ACK
* jsr TCP.OUT.SendOptA
2021-01-12 21:14:13 +00:00
2020-11-29 18:24:11 +00:00
lda #S.TCP.OPTIONS.ACK
2020-09-07 20:40:50 +00:00
.91 jmp TCP.OUT.SendOptA
*--------------------------------------
TCP.IN.JMP.CLWAIT
clc Wait for SKT.shutdown
rts
*--------------------------------------
TCP.IN.JMP.LASTACK
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 TCP.IN.JMP.CLWAIT
2021-05-19 12:44:47 +00:00
jsr SKT.GetTCB
2020-06-17 19:05:36 +00:00
* jsr TCP.OUT.SendACK
lda #S.SOCKET.TCP.S.CLWAIT
jmp SKT.StoreTCB.S
*--------------------------------------
TCP.IN.JMP.FINWT1
2018-11-11 22:05:04 +00:00
ldy #S.TCP.OPTIONS FIN sent, accept ACK or FIN/ACK packet
lda (ZPFrameInPtr),y
2018-11-10 19:47:45 +00:00
bit #S.TCP.OPTIONS.FIN
bne TCP.IN.2TIMEWT FIN/ACK
2018-11-11 22:05:04 +00:00
jsr SKT.GetTCB
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
*--------------------------------------
TCP.IN.JMP.FINWT2
ldy #S.TCP.OPTIONS FIN sent & ACKed, awaiting FIN
lda (ZPFrameInPtr),y
2018-11-10 19:47:45 +00:00
bit #S.TCP.OPTIONS.FIN
2019-07-07 20:48:57 +00:00
beq TCP.IN.JMP.TIMEWT
2020-06-17 19:05:36 +00:00
TCP.IN.2TIMEWT jsr SKT.GetTCB
jsr TCP.IN.ACKTheFIN
jsr TCP.OUT.SendACK FIN received, Send ACK
2019-07-07 20:48:57 +00:00
bcs TCP.IN.JMP.TIMEWT.RTS
2021-01-12 21:14:13 +00:00
lda #S.SOCKET.TCP.S.TIMEWT
2018-11-11 22:05:04 +00:00
jmp SKT.StoreTCB.S
*--------------------------------------
TCP.IN.JMP.CLOSING
* Wait for SKT.Shutdown
TCP.IN.JMP.TIMEWT
clc Wait for TCP.SendClose
2019-07-07 20:48:57 +00:00
TCP.IN.JMP.TIMEWT.RTS
2018-11-07 06:59:37 +00:00
rts
*--------------------------------------
2018-09-21 15:28:46 +00:00
TCP.IN.ACKTheSYN
ldy #S.TCP.SEQNUM+3 Get Remote SEQ
ldx #3
2020-06-17 19:05:36 +00:00
2018-09-21 15:28:46 +00:00
sec
2020-06-17 19:05:36 +00:00
2018-09-21 15:28:46 +00:00
.3 lda (ZPFrameInPtr),y Set OUTACK=SEQ+1 for new socket...
adc #0
2019-06-11 15:47:18 +00:00
sta SKT.Cache+S.SOCKET.TCP.INSEQNUM,x
sta SKT.Cache+S.SOCKET.TCP.INACKNUM,x
2018-09-21 15:28:46 +00:00
dey
dex
bpl .3
2019-06-12 15:39:07 +00:00
2018-09-21 15:28:46 +00:00
rts
*--------------------------------------
TCP.IN.ACKTheFIN
ldx #3
.1 inc SKT.Cache+S.SOCKET.TCP.INACKNUM,x
bne .2
dex
bpl .1
.2 rts
*--------------------------------------
TCP.IN.SetDataInPtrAndLen
ldy #S.IP.TOTAL.LENGTH+1
lda (ZPFrameInPtr),y
sec
2018-11-06 16:31:13 +00:00
sbc #S.IP-S.ETH.EII
sta ZPDataInLen
dey
lda (ZPFrameInPtr),y
2018-11-06 16:31:13 +00:00
sbc /S.IP-S.ETH.EII
sta ZPDataInLen+1
ldy #S.TCP.DATAOFFSET
lda (ZPFrameInPtr),y
and #$F0 Get TCP Header len in DWORD
lsr
lsr
2019-05-13 15:40:37 +00:00
sta ZPDataInPtr TMP Storage
lda ZPDataInLen
sec
2019-05-13 15:40:37 +00:00
sbc ZPDataInPtr TMP Storage
sta ZPDataInLen
bcs .1
dec ZPDataInLen+1
.1 lda ZPFrameInPtr
clc
adc #S.IP
pha
lda ZPFrameInPtr+1
adc /S.IP
tax
pla
clc
2019-05-13 15:40:37 +00:00
adc ZPDataInPtr TMP Storage
bcc .2
inx
.2 sta ZPDataInPtr
stx ZPDataInPtr+1
2019-05-08 19:41:46 +00:00
TCP.IN.RTS rts
*--------------------------------------
2023-10-18 05:41:12 +00:00
TCP.SENDCLOSE ldx #1
2019-06-10 08:19:13 +00:00
.1 phx
2023-10-18 05:41:12 +00:00
lda FDs.pHI-1,x
2019-06-10 08:19:13 +00:00
beq .8
2020-06-07 08:06:51 +00:00
2023-10-18 05:41:12 +00:00
ldy FDs.pLO-1,x
>STYA ZPPtrSKT
2019-06-10 08:19:13 +00:00
ldy #S.SOCKET.AF
lda (ZPPtrSKT),y
cmp #AF.INET
bne .8
2020-06-07 08:06:51 +00:00
2020-09-03 20:52:37 +00:00
iny #S.SOCKET.T
2019-06-10 08:19:13 +00:00
lda (ZPPtrSKT),y
2020-06-07 08:06:51 +00:00
cmp #S.SOCKET.T.SEQPKT
2019-06-10 08:19:13 +00:00
bcc .8
2020-06-07 08:06:51 +00:00
tax
2019-06-10 08:19:13 +00:00
ldy #S.SOCKET.TCP.S
lda (ZPPtrSKT),y
cmp #S.SOCKET.TCP.S.TIMEWT
beq .4
2020-06-07 08:06:51 +00:00
2019-06-10 08:19:13 +00:00
cmp #S.SOCKET.TCP.S.ESTBLSH
bne .3
2020-06-07 08:06:51 +00:00
cpx #S.SOCKET.T.SEQPKT
beq .2
2020-06-07 08:06:51 +00:00
2019-06-10 08:19:13 +00:00
jsr TCP.OUT
bra .8
.2 ldy #S.SOCKET.TCP.O
lda (ZPPtrSKT),y
and #S.TCP.OPTIONS.ACK
beq .8
jsr SKT.GetTCB
jsr TCP.OUT.SendOpt
bra .8
2020-06-07 08:06:51 +00:00
.3 cmp #S.SOCKET.TCP.S.OPENED
2019-07-07 20:48:57 +00:00
bne .8
2020-06-07 08:06:51 +00:00
2019-07-07 20:48:57 +00:00
jsr SKT.GetTCB
lda #S.TCP.OPTIONS.SYN
jsr TCP.OUT.SendOptA Send SYN
bcs .8 failed ARP lookup....
lda #S.SOCKET.TCP.S.SYNSENT
jsr SKT.StoreTCB.S
bra .8
2020-06-07 08:06:51 +00:00
*--------------------------------------
.4 cpx #S.SOCKET.T.SEQPKT
2020-09-03 20:52:37 +00:00
bne .6
2021-01-12 21:14:13 +00:00
2020-09-03 20:52:37 +00:00
.5 jsr SKT.GetFromQueue
bcs .7
>SYSCALL2 FreeMem
2021-01-12 21:14:13 +00:00
bra .5
2020-09-03 20:52:37 +00:00
.6 ldy #S.SOCKET.SQ.hInMem
2020-06-07 08:06:51 +00:00
jsr TCP.SENDCLOSE.PIPE
2019-06-17 15:40:26 +00:00
2020-06-07 08:06:51 +00:00
ldy #S.SOCKET.SQ.hOutMem
jsr TCP.SENDCLOSE.PIPE
2023-10-18 05:41:12 +00:00
.7 pla
pha
2023-10-18 05:41:12 +00:00
jsr SKT.FreeFD
2020-06-07 08:06:51 +00:00
2019-06-10 08:19:13 +00:00
.8 plx
2019-06-10 08:19:13 +00:00
inx
2023-10-18 05:41:12 +00:00
cpx #K.FD.MAX+1
bcc .1
2019-06-10 08:19:13 +00:00
2021-01-12 21:14:13 +00:00
clc
2020-06-07 08:06:51 +00:00
rts
2021-01-12 21:14:13 +00:00
2020-06-07 08:06:51 +00:00
TCP.SENDCLOSE.PIPE
lda (ZPPtrSKT),y
beq .8
.DO AUXPIPE=1
>SYSCALL2 FreeStkObj
.ELSE
>SYSCALL2 freemem
.FIN
.8 rts
2019-06-10 08:19:13 +00:00
*--------------------------------------
TCP.OUT jsr SKT.GetTCB
lda SKT.Cache+S.SOCKET.TCP.OUTTOSEND+1
2018-11-08 14:23:06 +00:00
ldy SKT.Cache+S.SOCKET.TCP.OUTTOSEND
2017-02-13 07:26:18 +00:00
bne .1
2021-01-12 21:14:13 +00:00
tax
bne .1
2021-01-12 21:14:13 +00:00
* Y,A=0 : no data to send
2018-09-28 15:24:44 +00:00
ldy #S.SOCKET.TCP.O
lda (ZPPtrSKT),y
bne TCP.OUT.SendOpt a least an option...
2019-05-09 21:00:23 +00:00
clc No data, no flag....exit
2019-06-10 08:19:13 +00:00
.9 rts
2019-10-03 06:25:27 +00:00
2017-02-13 07:26:18 +00:00
.1 cpy #K.TCP.MSS
pha
sbc /K.TCP.MSS OUTDATA > MSS ?
pla
bcc .2 no....keep data len
2017-02-13 07:26:18 +00:00
>LDYAI K.TCP.MSS yes send only MSS
.2 jsr TCP.NewFrame
2019-06-10 08:19:13 +00:00
bcs .9
jsr SKT.GetDataFromSktOut
2019-11-17 14:39:55 +00:00
2020-06-05 19:26:34 +00:00
TCP.OUT.SEQSEND ldy #S.TCP.WINDOW
2019-06-12 15:39:07 +00:00
lda SKT.Cache+S.SOCKET.TCP.INFREE+1
sta (ZPFrameOutPtr),y
iny
lda SKT.Cache+S.SOCKET.TCP.INFREE
sta (ZPFrameOutPtr),y
2019-11-17 14:39:55 +00:00
2020-06-05 19:26:34 +00:00
lda #S.TCP.OPTIONS.ACK+S.TCP.OPTIONS.PSH
2019-05-08 19:41:46 +00:00
jsr TCP.OUT.Send
2019-11-17 14:39:55 +00:00
bcs TCP.OUT.Send.RTS
2019-07-28 20:39:30 +00:00
lda ZPDataOutLen
ldy ZPDataOutLen+1
ldx #S.SOCKET.TCP.OUTNEXTSEQ
jsr TCP.AddAYToSktCacheAtX
jmp SKT.StoreTCB exits with CC
*--------------------------------------
2023-10-18 05:41:12 +00:00
TCP.OUT.SendFINACK
lda #S.TCP.OPTIONS.FIN+S.TCP.OPTIONS.ACK
jsr TCP.OUT.SendOptA Send FIN/ACK
bcs .9
ldx #3
.1 inc SKT.Cache+S.SOCKET.TCP.OUTNEXTSEQ,x
bne .9
dex
bpl .1
.9 rts
*--------------------------------------
2021-05-19 12:44:47 +00:00
TCP.OUT.SendACK lda #S.TCP.OPTIONS.ACK
TCP.OUT.SendOptA
2019-05-13 15:40:37 +00:00
jsr TCP.SetSocketTCPO
2019-05-08 19:41:46 +00:00
TCP.OUT.SendOpt >LDYAI 0
jsr TCP.NewFrame
2019-11-17 14:39:55 +00:00
bcs TCP.OUT.Send.RTS
2019-06-12 15:39:07 +00:00
ldy #S.SOCKET.TCP.INFREE+1
lda (ZPPtrSKT),y
tax
dey
lda (ZPPtrSKT),y
2019-06-13 06:00:56 +00:00
ldy #S.TCP.WINDOW+1
2019-06-12 15:39:07 +00:00
sta (ZPFrameOutPtr),y
2019-06-13 06:00:56 +00:00
dey
2019-06-12 15:39:07 +00:00
txa
sta (ZPFrameOutPtr),y
2019-05-10 14:49:53 +00:00
ldy #S.SOCKET.TCP.O
2019-05-08 19:41:46 +00:00
lda (ZPPtrSKT),y
2019-05-10 14:49:53 +00:00
2023-10-18 05:41:12 +00:00
* sec DONT Queue if fail
* .HS 90 BCC
TCP.OUT.Send clc Queue if fail
php
ldy #S.TCP.OPTIONS
sta (ZPFrameOutPtr),y
bit #S.TCP.OPTIONS.ACK
beq .2
2021-01-12 21:14:13 +00:00
ldx #3
ldy #S.TCP.ACKNUM+3
2019-10-05 17:24:41 +00:00
.1 lda SKT.Cache+S.SOCKET.TCP.INACKNUM,x
sta (ZPFrameOutPtr),y
dey
dex
bpl .1
2019-10-05 17:24:41 +00:00
2019-05-08 19:41:46 +00:00
.2 ldx #3
ldy #S.TCP.SEQNUM+3
2019-10-05 17:24:41 +00:00
2019-05-08 19:41:46 +00:00
.3 lda SKT.Cache+S.SOCKET.TCP.OUTNEXTSEQ,x
sta (ZPFrameOutPtr),y
dey
dex
2019-05-08 19:41:46 +00:00
bpl .3
plp Get back Queue status
2019-10-05 17:24:41 +00:00
jsr FRM.SendIP
2019-11-17 14:39:55 +00:00
bcs TCP.OUT.Send.RTS
2018-09-28 15:24:44 +00:00
ldy #S.SOCKET.TCP.O
2017-03-09 07:11:44 +00:00
lda #0
sta (ZPPtrSKT),y
2018-09-13 15:29:02 +00:00
* clc
2019-11-17 14:39:55 +00:00
TCP.OUT.Send.RTS
rts
2019-06-12 15:39:07 +00:00
*--------------------------------------
TCP.SetSocketTCPO
ldy #S.SOCKET.TCP.O
ora (ZPPtrSKT),y
sta (ZPPtrSKT),y
2019-05-13 15:40:37 +00:00
rts
*--------------------------------------
TCP.NewFrame ldx #S.IP.PROTOCOL.TCP
jsr FRM.NewIP
bcs .9
2021-05-19 12:44:47 +00:00
jsr SKT.SetFrameOutDstIP
2018-09-17 15:42:38 +00:00
jsr SKT.SetFrameOutTCPUDPPorts
ldy #S.TCP.DATAOFFSET
lda #$50 Header size = 5 DWORDS
sta (ZPFrameOutPtr),y
2021-05-19 12:44:47 +00:00
2016-04-09 09:15:11 +00:00
clc
.9 rts
2019-07-28 20:39:30 +00:00
*--------------------------------------
TCP.AddAYToSktCacheAtX
clc
adc SKT.Cache+3,x
sta SKT.Cache+3,x
tya
adc SKT.Cache+2,x
sta SKT.Cache+2,x
bcc .8
2021-05-19 12:44:47 +00:00
2019-07-28 20:39:30 +00:00
inc SKT.Cache+1,x
bne .8
2021-05-19 12:44:47 +00:00
2019-07-28 20:39:30 +00:00
inc SKT.Cache,x
2021-05-19 12:44:47 +00:00
2019-07-28 20:39:30 +00:00
.8 rts
2016-04-09 09:15:11 +00:00
*--------------------------------------
MAN
2020-06-07 08:06:51 +00:00
SAVE usr/src/lib/libtcpip.s.tcp
LOAD usr/src/lib/libtcpip.s
ASM