Kernel version 0.9 : TCP & SKT, added code for TCP conn. close

This commit is contained in:
Rémy GIBERT 2017-03-24 17:27:44 +01:00
parent 1440f681a8
commit b4f18d1aec
5 changed files with 80 additions and 21 deletions

Binary file not shown.

Binary file not shown.

View File

@ -104,7 +104,7 @@ SKT.New.Listen sec
>LDYA ZPTmpPtr3
>STYA ZPPtrSKT
lda #S.TCP.OPTIONS.SYN
jsr TCP.OUT.A Only for CLIENT conn!!!!
jsr TCP.OUT.SendOpt Only for CLIENT conn!!!!
bcs .99
ldy #S.SOCKET.TCP.STATUS
@ -404,10 +404,10 @@ SKT.Write.TCP ldy #S.SOCKET.TCP.STATUS
cmp #S.SOCKET.TCP.STATUS.ESTBLSH
bne .91
jsr SKT.AddDataToSktOut
jsr SKT.AddDataToSktOut will call SKT.GetTCB
bcs .90
jsr TCP.OUT.I try to push, ignore error....
jsr TCP.OUT.I SKT.GetTCB called, try to push, ignore error....
clc
rts
@ -718,6 +718,7 @@ SKT.AddDataToSktIn
* Y,A = bytes read
*--------------------------------------
SKT.GetDataFromSktIn
jsr SKT.GetTCB
lda SKT.TCBCache+S.TCB.INUSED
ora SKT.TCBCache+S.TCB.INUSED+1
bne .10
@ -729,8 +730,6 @@ SKT.GetDataFromSktIn
>SYSCALL GetMemPtrA
>STYA ZPTmpPtr1 Make ZPTmpPtr1=buffer base
jsr SKT.GetTCB
lda ZPTmpPtr1
clc
adc SKT.TCBCache+S.TCB.INTAIL
@ -857,7 +856,7 @@ SKT.GetDataFromSktIn
ora #S.TCP.OPTIONS.ACK
sta (ZPPtrSKT),y
jsr TCP.OUT.I
jsr TCP.OUT.I SKT.GetTCB already called, Try to ACK read DATA
>LDYA ZPTmpPtr3
clc

View File

@ -133,7 +133,7 @@ TCP.IN.JMP.LISTEN
jsr ARP.AddFromFrameInPtr
lda #S.TCP.OPTIONS.SYN+S.TCP.OPTIONS.ACK
jsr TCP.OUT.A
jsr TCP.OUT.SendOpt
bcs .9
ldy #S.SOCKET.TCP.STATUS
@ -170,11 +170,8 @@ TCP.IN.JMP.SYNSENT
dex
bpl .1
ldy #S.SOCKET.TCP.OPTIONS
lda #S.TCP.OPTIONS.ACK
sta (ZPPtrSKT),y
jsr TCP.OUT.I
jsr TCP.OUT.SendOpt
bcs .9
ldy #S.SOCKET.TCP.STATUS
@ -207,13 +204,14 @@ TCP.IN.JMP.SYNRCVD
bpl .1
jsr SKT.StoreTCB
bcs .9
ldy #S.SOCKET.TCP.STATUS
lda #S.SOCKET.TCP.STATUS.ESTBLSH
sta (ZPPtrSKT),y
.8 clc
rts
.9 rts
*--------------------------------------
TCP.IN.JMP.ESTBLSH
jsr SKT.GetTCB
@ -223,7 +221,7 @@ TCP.IN.JMP.ESTBLSH
bit #S.TCP.OPTIONS.ACK Remote side ACKed data ?
beq .1
jsr SKT.AckDataToSktOut Yes, Discard sent data
jsr SKT.AckDataToSktOut (will call SKT.GetTCB) Yes, Discard sent data
.1 jsr TCP.IN.SetDataInPtrAndLen
@ -238,16 +236,20 @@ TCP.IN.JMP.ESTBLSH
bit #S.TCP.OPTIONS.FIN
beq .8
ldy #S.TCP.OPTIONS
lda (ZPFrameInPtr),y
ora #S.TCP.OPTIONS.ACK ACK the FIN....
sta (ZPFrameInPtr),y
ldy #S.SOCKET.TCP.STATUS
lda #S.SOCKET.TCP.STATUS.CLWAIT
sta (ZPPtrSKT),y
.8 jmp TCP.OUT.I
.8 jmp TCP.OUT.I SKT.GetTCB called try to ACK
.9 rts
*--------------------------------------
TCP.IN.JMP.CLWAIT
clc
clc Wait for SKT.CloseA from Daemon
rts
*--------------------------------------
TCP.IN.JMP.LASTACK
@ -262,10 +264,68 @@ TCP.IN.JMP.LASTACK
rts
*--------------------------------------
TCP.IN.JMP.FINWT1
ldy #S.TCP.OPTIONS only accept ACK packet
lda (ZPFrameInPtr),y
cmp #S.TCP.OPTIONS.ACK
bne .1
ldy #S.SOCKET.TCP.STATUS
lda #S.SOCKET.TCP.STATUS.FINWT2
sta (ZPPtrSKT),y
clc
rts
.1 cmp #S.TCP.OPTIONS.FIN
bne .8
ldy #S.SOCKET.TCP.OPTIONS
lda (ZPPtrSKT),y
ora #S.TCP.OPTIONS.ACK
sta (ZPPtrSKT),y
jsr TCP.OUT
bcs .9
ldy #S.SOCKET.TCP.STATUS
lda #S.SOCKET.TCP.STATUS.CLOSING
sta (ZPPtrSKT),y
.8 clc
.9 rts
*--------------------------------------
TCP.IN.JMP.FINWT2
ldy #S.TCP.OPTIONS only accept FIN packet
lda (ZPFrameInPtr),y
cmp #S.TCP.OPTIONS.FIN
bne .8
ldy #S.SOCKET.TCP.OPTIONS
lda (ZPPtrSKT),y
ora #S.TCP.OPTIONS.ACK
sta (ZPPtrSKT),y
jsr TCP.OUT
bcs .9
ldy #S.SOCKET.TCP.STATUS
lda #S.SOCKET.TCP.STATUS.TIMEWT
sta (ZPPtrSKT),y
.8 clc
.9 rts
*--------------------------------------
TCP.IN.JMP.CLOSING
ldy #S.TCP.OPTIONS only accept ACK packet
lda (ZPFrameInPtr),y
cmp #S.TCP.OPTIONS.ACK
bne .1
ldy #S.SOCKET.TCP.STATUS
lda #S.SOCKET.TCP.STATUS.TIMEWT
sta (ZPPtrSKT),y
.1 clc
rts
*--------------------------------------
TCP.IN.JMP.TIMEWT
*--------------------------------------
@ -332,7 +392,7 @@ TCP.OUT.I lda SKT.TCBCache+S.TCB.OUTUSED+1
ldy #S.SOCKET.TCP.OPTIONS
lda (ZPPtrSKT),y
bne TCP.OUT.A a least an option...
bne TCP.OUT.SendOpt a least an option...
clc No, data, no flag....exit
rts
@ -355,12 +415,12 @@ TCP.OUT.I lda SKT.TCBCache+S.TCB.OUTUSED+1
ldy #S.TCP.OPTIONS
sta (ZPFrameOutPtr),y
.7 jsr TCP.OUT.SEND
.7 jsr TCP.OUT.Send
bcs TCP.OUT.9
jmp SKT.StoreTCB
TCP.OUT.9 rts
*--------------------------------------
TCP.OUT.A sta .1+1
TCP.OUT.SendOpt sta .1+1
>LDYAI 0
jsr TCP.NewFrame
bcs TCP.OUT.9
@ -370,7 +430,7 @@ TCP.OUT.A sta .1+1
.1 lda #$ff
sta (ZPFrameOutPtr),y
TCP.OUT.SEND ldx #7
TCP.OUT.Send ldx #7
ldy #S.TCP.SEQ.NUMBER+7
.2 lda SKT.TCBCache+S.TCB.SEQNUM,x

View File

@ -11,7 +11,7 @@ AUTO 6
.INB /A2OSX.DEV/INC/MACROS.I
.INB /A2OSX.DEV/INC/A2OSX.I
.INB /A2OSX.DEV/INC/LIBTCPIP.I
.INB /A2OSX.DEV/INC/DHCP.I
.INB /A2OSX.DEV/INC/NET.DHCP.I
*--------------------------------------
TIMEOUT.MAX .EQ 200 20 sec.
*--------------------------------------