A2osX/LIB/LIBTCPIP.S.TCP.txt

589 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
.LIST OFF
*--------------------------------------
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)
*--------------------------------------
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
*--------------------------------------
2019-07-07 20:48:57 +00:00
TCP.IN.JMP.OPENED
2018-10-01 05:48:42 +00:00
TCP.IN.JMP.CLOSED
2019-10-28 16:20:40 +00:00
TCP.IN.JMP.DISCARD
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
*--------------------------------------
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 ?
2019-10-28 16:20:40 +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
bcs .99
2019-10-28 16:20:40 +00:00
2018-11-01 08:53:47 +00:00
jsr TCP.IN.ACKTheSYN
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
2018-11-01 08:53:47 +00:00
.9 lda #ERR.SKT.OOS
.99 rts
*--------------------------------------
TCP.IN.JMP.SYNSENT
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
2018-11-08 14:23:06 +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
lda #S.TCP.OPTIONS.ACK
2019-07-09 06:03:49 +00:00
jsr TCP.OUT.SendOptA SYN.ACK received, Send, ACK
bcs .9
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
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
2018-11-08 14:23:06 +00:00
ldx SKT.Index
lda SKT.TABLE,x
jmp SKT.shutdown
*--------------------------------------
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
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
dey
dex
bpl .1
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
.8 clc
.9 rts
*--------------------------------------
TCP.IN.JMP.ESTBLSH
2019-06-17 06:35:54 +00:00
.DO IPDEBUG=1
jsr DEBUG.IPID
.FIN
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
2019-06-17 06:35:54 +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
lda TmpDWord+3
ldx TmpDWord+2
bne .2
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
2019-06-17 06:35:54 +00:00
bne .9 Missed a frame.....
2019-07-07 20:48:57 +00:00
.51 dey
2019-06-11 15:47:18 +00:00
dex
bpl .5
2019-10-28 16:20:40 +00:00
ldy #S.SOCKET.T Create a new client socket
lda (ZPPtrSKT),y
cmp #S.SOCKET.T.STREAM
bne .52
jsr SKT.AddDataToSktIn yes, queue data if there is room for....
2019-10-28 16:20:40 +00:00
bra .59
.52 lda hFrameIn
jsr SKT.AddToQueueA
bcs .9
.59 lda ZPDataInLen
2019-07-28 20:39:30 +00:00
ldy ZPDataInLen+1
ldx #S.SOCKET.TCP.INSEQNUM
jsr TCP.AddAYToSktCacheAtX
2019-05-13 15:40:37 +00:00
2019-06-12 15:39:07 +00:00
.6 jsr SKT.StoreTCB update socket
2019-07-07 20:48:57 +00:00
* jsr TCP.SetSocketTCPO.ACK ...and ack data
lda #S.TCP.OPTIONS.ACK
jsr TCP.OUT.SendOptA
* bcs *
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
2019-06-12 05:56:34 +00:00
lda #S.SOCKET.TCP.S.CLWAIT
ldy #S.SOCKET.TCP.S
sta (ZPPtrSKT),y
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
2019-06-17 06:35:54 +00:00
jsr TCP.SetSocketTCPO FIN received, Send FIN.ACK
2019-10-03 06:25:27 +00:00
* jsr TCP.OUT.SendOptA
2019-10-28 16:20:40 +00:00
.8 clc
2019-07-07 20:48:57 +00:00
rts
2019-10-05 17:24:41 +00:00
2019-10-03 06:25:27 +00:00
.9 sec
2019-07-07 20:48:57 +00:00
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 .8
2018-11-11 22:05:04 +00:00
ldy #S.SOCKET.TCP.S
lda #S.SOCKET.TCP.S.TIMEWT
sta (ZPPtrSKT),y
2019-10-28 16:20:40 +00:00
.8
*--------------------------------------
TCP.IN.JMP.CLWAIT
clc Wait for SKT.shutdown
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
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
2019-07-07 20:48:57 +00:00
bcs TCP.IN.JMP.TIMEWT.RTS
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
2019-07-07 20:48:57 +00:00
bra TCP.IN.JMP.FINWT.ACK Send FIN.ACK
*--------------------------------------
TCP.IN.JMP.FINWT2
2019-06-10 08:19:13 +00:00
ldy #S.TCP.OPTIONS only accept ACK packet
lda (ZPFrameInPtr),y
2018-11-10 19:47:45 +00:00
2019-06-10 08:19:13 +00:00
bit #S.TCP.OPTIONS.ACK
2019-07-07 20:48:57 +00:00
beq TCP.IN.JMP.TIMEWT
2018-11-11 22:05:04 +00:00
jsr SKT.GetTCB
2018-09-13 15:29:02 +00:00
jsr TCP.IN.ACKTheFIN
2018-11-11 22:05:04 +00:00
lda #S.TCP.OPTIONS.ACK
2019-07-07 20:48:57 +00:00
TCP.IN.JMP.FINWT.ACK
2018-11-11 22:05:04 +00:00
jsr TCP.OUT.SendOptA FIN received, Send ACK
2019-07-07 20:48:57 +00:00
bcs TCP.IN.JMP.TIMEWT.RTS
2018-11-11 22:05:04 +00:00
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
*--------------------------------------
TCP.IN.JMP.CLOSING
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
2018-09-28 15:24:44 +00:00
ldy #S.SOCKET.TCP.S
lda #S.SOCKET.TCP.S.TIMEWT
sta (ZPPtrSKT),y
2019-10-03 06:25:27 +00:00
.1
2019-06-17 15:40:26 +00:00
* clc
* rts
*--------------------------------------
TCP.IN.JMP.TIMEWT
2018-11-07 06:59:37 +00:00
clc Wait for TCP.Close
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
sec
.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
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
*--------------------------------------
2018-09-13 15:29:02 +00:00
TCP.IN.ACKTheFIN
2019-05-13 15:40:37 +00:00
jsr TCP.SetSocketTCPO.ACK
2018-11-11 22:05:04 +00:00
ldx #3
2019-06-11 15:47:18 +00:00
.1 inc SKT.Cache+S.SOCKET.TCP.INSEQNUM,x
bne .8
2018-11-11 22:05:04 +00:00
dex
2019-06-10 08:19:13 +00:00
bpl .1
2018-11-11 22:05:04 +00:00
2019-06-10 08:19:13 +00:00
.8 rts
2018-09-13 15:29:02 +00:00
*--------------------------------------
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
*--------------------------------------
2019-06-10 08:19:13 +00:00
TCP.SENDCLOSE ldx #0
.1 phx
lda SKT.TABLE,x
beq .8
>SYSCALL2 GetMemPtr
>STYA ZPPtrSKT
ldy #S.SOCKET.AF
lda (ZPPtrSKT),y
cmp #AF.INET
bne .8
iny #S.SOCKET.T
lda (ZPPtrSKT),y
cmp #S.SOCKET.T.SEQPACKET
bcc .8
ldy #S.SOCKET.TCP.S
lda (ZPPtrSKT),y
cmp #S.SOCKET.TCP.S.TIMEWT
beq .4
cmp #S.SOCKET.TCP.S.ESTBLSH
2019-07-07 20:48:57 +00:00
bne .2
2019-06-12 15:39:07 +00:00
jsr SKT.GetTCB
2019-06-10 08:19:13 +00:00
jsr TCP.OUT
bra .8
2019-07-07 20:48:57 +00:00
.2 cmp #S.SOCKET.TCP.S.OPENED
bne .8
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
lda #S.TCP.OPTIONS.SYN
jsr TCP.OUT.SendOptA Send SYN
bra .8
2019-06-10 08:19:13 +00:00
.4 ldy #S.SOCKET.SQ.hInMem
lda (ZPPtrSKT),y
2019-06-17 06:35:54 +00:00
beq .5
2019-06-17 15:40:26 +00:00
.DO AUXPIPE=1
>SYSCALL2 FreeStkObj
.ELSE
2019-06-10 08:19:13 +00:00
>SYSCALL2 freemem
2019-06-17 15:40:26 +00:00
.FIN
2019-06-17 06:35:54 +00:00
.5 ldy #S.SOCKET.SQ.hOutMem
2019-06-10 08:19:13 +00:00
lda (ZPPtrSKT),y
2019-06-17 06:35:54 +00:00
beq .6
2019-06-17 15:40:26 +00:00
.DO AUXPIPE=1
>SYSCALL2 FreeStkObj
.ELSE
2019-06-10 08:19:13 +00:00
>SYSCALL2 freemem
2019-06-17 15:40:26 +00:00
.FIN
2019-06-17 06:35:54 +00:00
.6 plx
2019-06-10 08:19:13 +00:00
phx
lda SKT.TABLE,x
stz SKT.TABLE,x
2019-06-11 05:52:24 +00:00
>SYSCALL2 freemem
2019-06-10 08:19:13 +00:00
.8 plx
inx
cpx #K.SKTTABLE.SIZE
bne .1
.9 rts
*--------------------------------------
2019-06-12 15:39:07 +00:00
TCP.OUT 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
tax
bne .1
* 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.SendOptA 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-06-12 15:39:07 +00:00
ldy #S.TCP.WINDOW
lda SKT.Cache+S.SOCKET.TCP.INFREE+1
sta (ZPFrameOutPtr),y
iny
lda SKT.Cache+S.SOCKET.TCP.INFREE
sta (ZPFrameOutPtr),y
lda #S.TCP.OPTIONS.ACK+S.TCP.OPTIONS.PSH
2019-05-08 19:41:46 +00:00
jsr TCP.OUT.Send
2019-06-10 08:19:13 +00:00
bcs .9
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
*--------------------------------------
TCP.OUT.SendOptA
2019-05-13 15:40:37 +00:00
jsr TCP.SetSocketTCPO
2019-05-08 19:41:46 +00:00
>LDYAI 0
jsr TCP.NewFrame
2019-06-12 15:39:07 +00:00
bcs TCP.OUT.Send.9
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
TCP.OUT.Send ldy #S.TCP.OPTIONS
sta (ZPFrameOutPtr),y
2018-09-05 11:31:49 +00:00
bit #S.TCP.OPTIONS.ACK
2019-05-08 19:41:46 +00:00
beq .2
2019-10-05 17:24:41 +00:00
ldx #3
ldy #S.TCP.ACKNUM+3
2019-10-05 17:24:41 +00:00
2019-06-11 15:47:18 +00:00
.1 lda SKT.Cache+S.SOCKET.TCP.INSEQNUM,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
2019-07-07 20:48:57 +00:00
sec DONT Queue if fail
2019-10-05 17:24:41 +00:00
jsr FRM.SendIP
2019-06-12 15:39:07 +00:00
bcs TCP.OUT.Send.9
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-06-12 15:39:07 +00:00
TCP.OUT.Send.9 rts
*--------------------------------------
TCP.SetSocketTCPO.ACK
lda #S.TCP.OPTIONS.ACK
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
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
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
inc SKT.Cache+1,x
bne .8
inc SKT.Cache,x
.8 rts
2019-06-17 15:40:26 +00:00
*--------------------------------------
.DO IPDEBUG=1
DEBUG.IPID ldy #S.IP.IDENTIFICATION
lda (ZPFrameInPtr),y
>PUSHA
iny
lda (ZPFrameInPtr),y
>PUSHA
>PUSHBI 2
>LDYA L.MSG.IPID
>SYSCALL printf
rts
.FIN
2016-04-09 09:15:11 +00:00
*--------------------------------------
MAN
2018-11-17 17:17:13 +00:00
SAVE USR/SRC/LIB/LIBTCPIP.S.TCP
LOAD USR/SRC/LIB/LIBTCPIP.S
ASM