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