2016-01-16 22:04:22 +00:00
|
|
|
|
PR#3
|
|
|
|
|
PREFIX /A2OSX.SRC
|
2017-02-15 21:46:21 +00:00
|
|
|
|
LOMEM $900
|
2016-01-16 22:04:22 +00:00
|
|
|
|
INC 1
|
|
|
|
|
AUTO 6
|
|
|
|
|
.LIST OFF
|
|
|
|
|
*--------------------------------------
|
2017-02-16 16:26:11 +00:00
|
|
|
|
TCP.IN jsr IP.FillSKT.TemplateSrcDst
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
|
|
|
|
ldy #S.TCP.SRCPORT
|
2017-01-31 16:40:37 +00:00
|
|
|
|
lda (ZPFrameInPtr),y
|
2017-02-16 16:26:11 +00:00
|
|
|
|
sta SKT.Template+S.SOCKET.DST.PORT+1
|
2016-03-13 22:09:00 +00:00
|
|
|
|
iny
|
2017-01-31 16:40:37 +00:00
|
|
|
|
lda (ZPFrameInPtr),y
|
2017-02-16 16:26:11 +00:00
|
|
|
|
sta SKT.Template+S.SOCKET.DST.PORT
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
|
|
|
|
ldy #S.TCP.DSTPORT
|
2017-01-31 16:40:37 +00:00
|
|
|
|
lda (ZPFrameInPtr),y
|
2017-02-16 16:26:11 +00:00
|
|
|
|
sta SKT.Template+S.SOCKET.SRC.PORT+1
|
2016-03-13 22:09:00 +00:00
|
|
|
|
iny
|
2017-01-31 16:40:37 +00:00
|
|
|
|
lda (ZPFrameInPtr),y
|
2017-02-16 16:26:11 +00:00
|
|
|
|
sta SKT.Template+S.SOCKET.SRC.PORT
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2017-02-10 07:29:58 +00:00
|
|
|
|
lda hSocketTable
|
|
|
|
|
>SYSCALL GetMemPtrA
|
2016-03-13 22:09:00 +00:00
|
|
|
|
>STYA ZPPtrSKT
|
|
|
|
|
|
|
|
|
|
ldx #0
|
|
|
|
|
|
|
|
|
|
.3 lda (ZPPtrSKT)
|
|
|
|
|
beq .7
|
|
|
|
|
cmp #S.SOCKET.SOCK.STREAM
|
|
|
|
|
bne .7
|
|
|
|
|
|
|
|
|
|
ldy #S.SOCKET.SRC.ADDR
|
|
|
|
|
|
2017-02-16 16:26:11 +00:00
|
|
|
|
.4 lda SKT.Template,y
|
2016-03-13 22:09:00 +00:00
|
|
|
|
cmp (ZPPtrSKT),y
|
|
|
|
|
bne .7 Not for this socket...
|
2017-02-15 16:14:41 +00:00
|
|
|
|
|
2016-03-13 22:09:00 +00:00
|
|
|
|
iny
|
|
|
|
|
cpy #S.SOCKET.SRC.PORT+2
|
|
|
|
|
bne .4
|
|
|
|
|
|
|
|
|
|
ldy #S.SOCKET.SO
|
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
and #S.SOCKET.SO.ACCEPTCONN Listening socket?
|
2017-02-16 16:26:11 +00:00
|
|
|
|
beq .5 no, go check if Dst Match
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2017-02-16 16:26:11 +00:00
|
|
|
|
ldy #S.TCP.OPTIONS yes, only accept SYN packet
|
2017-02-15 21:46:21 +00:00
|
|
|
|
lda (ZPFrameInPtr),y
|
|
|
|
|
|
2017-03-13 15:34:56 +00:00
|
|
|
|
cmp #S.TCP.OPTIONS.SYN SYN only, if SYN.ACK, pass to regular socket
|
|
|
|
|
beq TCP.IN.JMP.LISTEN
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
|
|
|
|
.5 ldy #S.SOCKET.DST.ADDR
|
|
|
|
|
|
2017-03-13 07:07:07 +00:00
|
|
|
|
.6 lda SKT.Template,y regular socket, check remote ADDR/PORT
|
2016-03-13 22:09:00 +00:00
|
|
|
|
cmp (ZPPtrSKT),y
|
|
|
|
|
bne .7
|
|
|
|
|
iny
|
|
|
|
|
cpy #S.SOCKET.DST.PORT+2
|
|
|
|
|
bne .6
|
2017-03-13 07:07:07 +00:00
|
|
|
|
|
2017-03-07 16:40:32 +00:00
|
|
|
|
ldy #S.TCP.OPTIONS
|
|
|
|
|
lda (ZPFrameInPtr),y
|
|
|
|
|
and #S.TCP.OPTIONS.RST RST ? go Kill this socket.
|
|
|
|
|
bne TCP.IN.RST
|
|
|
|
|
|
2017-02-16 16:26:11 +00:00
|
|
|
|
ldy #S.SOCKET.TCP.STATUS
|
|
|
|
|
lda (ZPPtrSKT),y
|
2017-03-09 07:11:44 +00:00
|
|
|
|
cmp #S.SOCKET.TCP.STATUS.TIMEWT
|
|
|
|
|
bcs *
|
2017-02-16 16:26:11 +00:00
|
|
|
|
asl
|
|
|
|
|
tax
|
2017-03-13 07:07:07 +00:00
|
|
|
|
|
2017-02-16 16:26:11 +00:00
|
|
|
|
jmp (L.TCP.IN.JMP,x)
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
|
|
|
|
.7 lda ZPPtrSKT
|
|
|
|
|
clc
|
|
|
|
|
adc #S.SOCKET
|
|
|
|
|
sta ZPPtrSKT
|
|
|
|
|
bcc .8
|
|
|
|
|
inc ZPPtrSKT+1
|
|
|
|
|
|
|
|
|
|
.8 inx
|
|
|
|
|
cpx #K.SKTTABLE.SIZE
|
|
|
|
|
bne .3
|
|
|
|
|
|
2017-02-16 16:26:11 +00:00
|
|
|
|
.9 clc Discard frame
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-03-09 07:11:44 +00:00
|
|
|
|
TCP.IN.RST lda #0
|
|
|
|
|
sta (ZPPtrSKT)
|
2017-03-07 16:40:32 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-02-16 16:26:11 +00:00
|
|
|
|
TCP.IN.JMP.LISTEN
|
2016-03-13 22:09:00 +00:00
|
|
|
|
lda #S.SOCKET.SOCK.STREAM
|
2017-02-16 16:26:11 +00:00
|
|
|
|
sta SKT.Template+S.SOCKET.SOCK
|
|
|
|
|
stz SKT.Template+S.SOCKET.SO
|
2017-03-13 07:07:07 +00:00
|
|
|
|
stz SKT.Template+S.SOCKET.TCP.STATUS
|
|
|
|
|
|
2017-02-16 16:26:11 +00:00
|
|
|
|
>PUSHW L.SKT.Template
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2017-03-13 07:07:07 +00:00
|
|
|
|
jsr SKT.New.Listen
|
|
|
|
|
bcs .99
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2017-03-13 07:07:07 +00:00
|
|
|
|
sty .1+1
|
|
|
|
|
sta .2+1
|
2016-04-09 09:15:11 +00:00
|
|
|
|
txa
|
2016-06-07 06:10:18 +00:00
|
|
|
|
|
2017-01-31 16:40:37 +00:00
|
|
|
|
jsr SKT.AddToQueueA
|
2016-04-09 09:15:11 +00:00
|
|
|
|
|
2017-03-13 07:07:07 +00:00
|
|
|
|
bcs .99 Queued successfully ?
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2017-03-13 07:07:07 +00:00
|
|
|
|
.1 lda #$ff
|
|
|
|
|
sta ZPPtrSKT
|
|
|
|
|
.2 lda #$ff
|
|
|
|
|
sta ZPPtrSKT+1
|
2017-02-17 07:20:57 +00:00
|
|
|
|
|
2017-03-13 07:07:07 +00:00
|
|
|
|
ldy #S.TCP.SEQ.NUMBER+3
|
2017-02-17 07:20:57 +00:00
|
|
|
|
ldx #3
|
|
|
|
|
|
|
|
|
|
sec
|
|
|
|
|
|
2017-03-13 07:07:07 +00:00
|
|
|
|
.3 lda (ZPFrameInPtr),y Set ACK=SEQ+1 for new socket...
|
2017-02-17 07:20:57 +00:00
|
|
|
|
adc #0
|
2017-03-10 16:35:54 +00:00
|
|
|
|
sta SKT.TCBCache+S.TCB.ACKNUM,x
|
2017-03-13 07:07:07 +00:00
|
|
|
|
dey
|
2017-02-17 07:20:57 +00:00
|
|
|
|
dex
|
2017-03-13 07:07:07 +00:00
|
|
|
|
bpl .3
|
2017-02-17 07:20:57 +00:00
|
|
|
|
|
2017-03-10 16:35:54 +00:00
|
|
|
|
jsr SKT.StoreTCB
|
2017-02-16 16:26:11 +00:00
|
|
|
|
|
2017-03-10 16:35:54 +00:00
|
|
|
|
jsr ARP.AddFromFrameInPtr
|
|
|
|
|
|
2017-03-09 07:11:44 +00:00
|
|
|
|
jsr TCP.OUT.SYNACK
|
2017-02-16 16:26:11 +00:00
|
|
|
|
bcs .9
|
2017-03-14 07:32:31 +00:00
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
ldy #S.SOCKET.TCP.STATUS
|
2017-03-10 16:35:54 +00:00
|
|
|
|
lda #S.SOCKET.TCP.STATUS.SYNRCVD
|
2017-02-16 16:26:11 +00:00
|
|
|
|
sta (ZPPtrSKT),y
|
|
|
|
|
|
|
|
|
|
clc
|
|
|
|
|
rts
|
2017-03-13 07:07:07 +00:00
|
|
|
|
|
|
|
|
|
.9 lda #0 error
|
|
|
|
|
sta (ZPPtrSKT) clear this socket
|
|
|
|
|
lda #ERR.SKT.OOS
|
|
|
|
|
.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
|
|
|
|
|
cmp #S.TCP.OPTIONS.SYN+S.TCP.OPTIONS.ACK
|
|
|
|
|
bne .8
|
|
|
|
|
|
2017-03-13 15:34:56 +00:00
|
|
|
|
jsr SKT.GetTCB
|
|
|
|
|
|
|
|
|
|
ldx #3
|
|
|
|
|
ldy #S.TCP.SEQ.NUMBER+3
|
2017-03-10 16:35:54 +00:00
|
|
|
|
|
2017-03-13 15:34:56 +00:00
|
|
|
|
sec
|
2017-03-10 16:35:54 +00:00
|
|
|
|
|
2017-03-13 15:34:56 +00:00
|
|
|
|
.1 lda SKT.TCBCache+S.TCB.ACKNUM,x
|
|
|
|
|
adc #0
|
|
|
|
|
sta SKT.TCBCache+S.TCB.ACKNUM,x
|
|
|
|
|
eor (ZPFrameInPtr),y
|
|
|
|
|
bne .8
|
|
|
|
|
dey
|
|
|
|
|
dex
|
|
|
|
|
bpl .1
|
|
|
|
|
|
|
|
|
|
ldy #S.SOCKET.TCP.OPTIONS
|
|
|
|
|
lda #S.TCP.OPTIONS.ACK
|
|
|
|
|
sta (ZPPtrSKT),y
|
2017-03-10 16:35:54 +00:00
|
|
|
|
|
2017-03-13 15:34:56 +00:00
|
|
|
|
jsr TCP.OUT.I
|
|
|
|
|
bcs .9
|
2017-03-10 16:35:54 +00:00
|
|
|
|
|
|
|
|
|
ldy #S.SOCKET.TCP.STATUS
|
|
|
|
|
lda #S.SOCKET.TCP.STATUS.ESTBLSH
|
|
|
|
|
sta (ZPPtrSKT),y
|
|
|
|
|
|
|
|
|
|
.8 clc
|
2017-03-13 15:34:56 +00:00
|
|
|
|
.9 rts
|
2017-03-10 16:35:54 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
TCP.IN.JMP.SYNRCVD
|
2017-03-13 15:34:56 +00:00
|
|
|
|
ldy #S.TCP.OPTIONS SYN Recieved, 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-03-13 07:07:07 +00:00
|
|
|
|
ldy #S.TCP.ACK.NUMBER+3
|
2017-03-10 16:35:54 +00:00
|
|
|
|
|
2016-03-13 22:09:00 +00:00
|
|
|
|
sec
|
2017-02-17 07:20:57 +00:00
|
|
|
|
|
2017-03-10 16:35:54 +00:00
|
|
|
|
.1 lda SKT.TCBCache+S.TCB.SEQNUM,x
|
2016-03-13 22:09:00 +00:00
|
|
|
|
adc #0
|
2017-03-10 16:35:54 +00:00
|
|
|
|
sta SKT.TCBCache+S.TCB.SEQNUM,x
|
|
|
|
|
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
|
|
|
|
|
2017-03-10 16:35:54 +00:00
|
|
|
|
jsr SKT.StoreTCB
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
ldy #S.SOCKET.TCP.STATUS
|
|
|
|
|
lda #S.SOCKET.TCP.STATUS.ESTBLSH
|
2017-03-10 16:35:54 +00:00
|
|
|
|
sta (ZPPtrSKT),y
|
2017-03-13 07:07:07 +00:00
|
|
|
|
|
2016-03-13 22:09:00 +00:00
|
|
|
|
.8 clc
|
|
|
|
|
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-14 16:46:29 +00:00
|
|
|
|
bit #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-14 16:46:29 +00:00
|
|
|
|
jsr SKT.AckDataToSktOut Yes, Discard sent data
|
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-01-28 22:05:20 +00:00
|
|
|
|
|
2017-03-14 16:46:29 +00:00
|
|
|
|
jsr SKT.AddDataToSktIn yes, queue data if there is room for....
|
|
|
|
|
|
2017-03-10 16:35:54 +00:00
|
|
|
|
.2 ldy #S.TCP.OPTIONS
|
|
|
|
|
lda (ZPFrameInPtr),y
|
|
|
|
|
bit #S.TCP.OPTIONS.FIN
|
2017-03-13 07:07:07 +00:00
|
|
|
|
beq .8
|
2017-03-10 16:35:54 +00:00
|
|
|
|
|
|
|
|
|
ldy #S.SOCKET.TCP.STATUS
|
|
|
|
|
lda #S.SOCKET.TCP.STATUS.CLWAIT
|
2017-02-17 16:39:38 +00:00
|
|
|
|
sta (ZPPtrSKT),y
|
|
|
|
|
|
2017-03-13 07:07:07 +00:00
|
|
|
|
.8 jmp TCP.OUT.I
|
2017-03-10 16:35:54 +00:00
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
TCP.IN.JMP.CLWAIT
|
|
|
|
|
|
|
|
|
|
clc
|
|
|
|
|
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
|
|
|
|
|
cmp #S.TCP.OPTIONS.ACK
|
|
|
|
|
bne .8
|
2017-02-17 16:39:38 +00:00
|
|
|
|
|
2017-03-10 16:35:54 +00:00
|
|
|
|
ldy #S.SOCKET.SQ.hOutMem
|
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
beq .1
|
|
|
|
|
>SYSCALL FreeMemA
|
2017-03-07 20:15:47 +00:00
|
|
|
|
|
2017-03-10 16:35:54 +00:00
|
|
|
|
.1 ldy #S.SOCKET.SQ.hInMem
|
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
beq .2
|
|
|
|
|
>SYSCALL FreeMemA
|
2017-01-28 22:05:20 +00:00
|
|
|
|
|
2017-03-10 16:35:54 +00:00
|
|
|
|
.2 ldy #S.SOCKET.SQ.hTCB
|
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
beq .3
|
|
|
|
|
>SYSCALL FreeMemA
|
|
|
|
|
|
|
|
|
|
.3 lda #0
|
|
|
|
|
sta (ZPPtrSKT)
|
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
|
2017-03-10 16:35:54 +00:00
|
|
|
|
*--------------------------------------
|
2017-02-01 16:49:44 +00:00
|
|
|
|
TCP.IN.JMP.FINWT2
|
2017-03-10 16:35:54 +00:00
|
|
|
|
*--------------------------------------
|
2017-02-01 16:49:44 +00:00
|
|
|
|
TCP.IN.JMP.CLOSING
|
2017-03-10 16:35:54 +00:00
|
|
|
|
*--------------------------------------
|
2017-02-01 16:49:44 +00:00
|
|
|
|
TCP.IN.JMP.TIMEWT
|
2017-03-13 15:34:56 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
TCP.IN.JMP.CLOSED
|
2017-02-01 16:49:44 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-03-13 15:34:56 +00:00
|
|
|
|
TCP.IN.SetDataInPtrAndLen
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
* clc
|
|
|
|
|
adc #S.IP-2
|
2017-03-13 15:34:56 +00:00
|
|
|
|
sta TmpOffset
|
|
|
|
|
|
|
|
|
|
lda #0
|
2017-03-15 06:58:13 +00:00
|
|
|
|
adc /S.IP-2
|
2017-03-13 15:34:56 +00:00
|
|
|
|
sta TmpOffset+1 TmpOffset=Data Offset in Frame
|
|
|
|
|
|
|
|
|
|
lda ZPFrameInLen
|
|
|
|
|
sec
|
|
|
|
|
sbc TmpOffset
|
|
|
|
|
sta ZPDataInLen
|
|
|
|
|
|
|
|
|
|
lda ZPFrameInLen+1
|
|
|
|
|
sbc TmpOffset+1
|
|
|
|
|
sta ZPDataInLen+1
|
2017-03-15 06:58:13 +00:00
|
|
|
|
|
|
|
|
|
lda TmpOffset
|
|
|
|
|
clc
|
|
|
|
|
adc #2
|
|
|
|
|
sta TmpOffset
|
|
|
|
|
bcc .1
|
|
|
|
|
inc TmpOffset+1
|
|
|
|
|
clc
|
|
|
|
|
|
|
|
|
|
.1 lda ZPFrameInPtr
|
|
|
|
|
adc TmpOffset
|
|
|
|
|
sta ZPDataInPtr
|
|
|
|
|
|
|
|
|
|
lda ZPFrameInPtr+1
|
|
|
|
|
adc #0
|
|
|
|
|
sta ZPDataInPtr+1
|
2017-03-13 15:34:56 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-03-10 16:35:54 +00:00
|
|
|
|
TCP.OUT.SYN >LDYAI 0
|
2017-02-16 16:26:11 +00:00
|
|
|
|
jsr TCP.NewFrame
|
|
|
|
|
bcs .9
|
|
|
|
|
|
2017-03-09 07:11:44 +00:00
|
|
|
|
ldx #3
|
2017-03-13 07:07:07 +00:00
|
|
|
|
ldy #S.TCP.SEQ.NUMBER+3
|
2017-03-09 07:11:44 +00:00
|
|
|
|
|
2017-03-10 16:35:54 +00:00
|
|
|
|
.1 lda SKT.TCBCache+S.TCB.SEQNUM,x
|
2017-03-09 07:11:44 +00:00
|
|
|
|
sta (ZPFrameOutPtr),y
|
2017-03-13 07:07:07 +00:00
|
|
|
|
dey
|
2017-03-09 07:11:44 +00:00
|
|
|
|
dex
|
|
|
|
|
bpl .1
|
|
|
|
|
|
2017-02-16 16:26:11 +00:00
|
|
|
|
ldy #S.TCP.OPTIONS
|
2017-03-10 16:35:54 +00:00
|
|
|
|
lda #S.TCP.OPTIONS.SYN
|
|
|
|
|
sta (ZPFrameOutPtr),y
|
|
|
|
|
|
|
|
|
|
iny S.TCP.WINDOW
|
|
|
|
|
lda /K.TCP.WSIZE
|
2017-03-09 07:11:44 +00:00
|
|
|
|
sta (ZPFrameOutPtr),y
|
2017-03-10 16:35:54 +00:00
|
|
|
|
iny
|
|
|
|
|
lda #K.TCP.WSIZE
|
|
|
|
|
sta (ZPFrameOutPtr),y
|
|
|
|
|
|
|
|
|
|
jsr FRM.SendIP
|
2017-02-16 16:26:11 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
2017-03-09 07:11:44 +00:00
|
|
|
|
ldy #S.SOCKET.TCP.OPTIONS
|
2017-02-16 16:26:11 +00:00
|
|
|
|
lda #0
|
2017-03-13 15:34:56 +00:00
|
|
|
|
sta (ZPPtrSKT),y
|
2017-02-16 16:26:11 +00:00
|
|
|
|
|
|
|
|
|
clc
|
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
2017-03-10 16:35:54 +00:00
|
|
|
|
TCP.OUT.SYNACK >LDYAI 0
|
|
|
|
|
jsr TCP.NewFrame
|
|
|
|
|
bcs .9
|
2017-02-13 07:26:18 +00:00
|
|
|
|
|
2017-03-13 07:07:07 +00:00
|
|
|
|
ldx #7
|
|
|
|
|
ldy #S.TCP.SEQ.NUMBER+7
|
2017-02-15 16:14:41 +00:00
|
|
|
|
|
2017-03-10 16:35:54 +00:00
|
|
|
|
.1 lda SKT.TCBCache+S.TCB.SEQNUM,x
|
|
|
|
|
sta (ZPFrameOutPtr),y
|
2017-03-13 07:07:07 +00:00
|
|
|
|
dey
|
2017-03-10 16:35:54 +00:00
|
|
|
|
dex
|
|
|
|
|
bpl .1
|
|
|
|
|
|
|
|
|
|
ldy #S.TCP.OPTIONS
|
|
|
|
|
lda #S.TCP.OPTIONS.SYN+S.TCP.OPTIONS.ACK
|
|
|
|
|
sta (ZPFrameOutPtr),y
|
|
|
|
|
|
|
|
|
|
iny S.TCP.WINDOW
|
|
|
|
|
lda /K.TCP.WSIZE
|
|
|
|
|
sta (ZPFrameOutPtr),y
|
|
|
|
|
iny
|
|
|
|
|
lda #K.TCP.WSIZE
|
|
|
|
|
sta (ZPFrameOutPtr),y
|
|
|
|
|
|
|
|
|
|
jsr FRM.SendIP
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
ldy #S.SOCKET.TCP.OPTIONS
|
|
|
|
|
lda #0
|
|
|
|
|
sta (ZPPtrSKT),y
|
|
|
|
|
|
|
|
|
|
clc
|
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
TCP.OUT jsr SKT.GetTCB
|
|
|
|
|
|
2017-03-13 07:07:07 +00:00
|
|
|
|
TCP.OUT.I lda SKT.TCBCache+S.TCB.OUTUSED+1
|
2017-03-10 16:35:54 +00:00
|
|
|
|
ldy SKT.TCBCache+S.TCB.OUTUSED
|
|
|
|
|
|
2017-02-13 07:26:18 +00:00
|
|
|
|
bne .1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
|
|
|
|
|
tax
|
2017-03-14 07:32:31 +00:00
|
|
|
|
bne .1 Y,A=0 : nothing to send
|
|
|
|
|
|
|
|
|
|
ldy #S.SOCKET.TCP.OPTIONS
|
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
beq .88 No, data, no flag....exit
|
|
|
|
|
|
|
|
|
|
txa a least one flag to send
|
|
|
|
|
tay
|
|
|
|
|
bra .2 go send a O len frame
|
2017-02-13 07:26:18 +00:00
|
|
|
|
|
|
|
|
|
.1 cpy #K.TCP.MSS
|
|
|
|
|
pha
|
|
|
|
|
sbc /K.TCP.MSS OUTDATA > MSS ?
|
|
|
|
|
pla
|
|
|
|
|
bcs .2 no....get data len
|
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
>LDYAI K.TCP.MSS yes get only MSS
|
|
|
|
|
|
2017-03-14 07:32:31 +00:00
|
|
|
|
.2 jsr TCP.NewFrame
|
2017-02-15 16:14:41 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
jsr SKT.GetDataFromSktOut
|
2017-03-10 16:35:54 +00:00
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
ldy #S.SOCKET.TCP.OPTIONS
|
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
ldy #S.TCP.OPTIONS
|
|
|
|
|
sta (ZPFrameOutPtr),y
|
|
|
|
|
|
2017-03-13 15:34:56 +00:00
|
|
|
|
ldx #7
|
|
|
|
|
ldy #S.TCP.SEQ.NUMBER+7
|
|
|
|
|
|
|
|
|
|
.3 lda SKT.TCBCache+S.TCB.SEQNUM,x
|
|
|
|
|
sta (ZPFrameOutPtr),y
|
|
|
|
|
dey
|
|
|
|
|
dex
|
|
|
|
|
bpl .3
|
|
|
|
|
|
2017-03-10 16:35:54 +00:00
|
|
|
|
.7 jsr FRM.SendIP
|
2017-02-15 16:14:41 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
2017-02-15 21:46:21 +00:00
|
|
|
|
ldy #S.SOCKET.TCP.OPTIONS
|
2017-02-15 16:14:41 +00:00
|
|
|
|
lda (ZPPtrSKT),y
|
2017-03-09 07:11:44 +00:00
|
|
|
|
bit #S.TCP.OPTIONS.FIN
|
2017-03-10 16:35:54 +00:00
|
|
|
|
beq .8
|
2017-03-09 07:11:44 +00:00
|
|
|
|
|
|
|
|
|
ldy #S.SOCKET.TCP.STATUS
|
|
|
|
|
lda #S.SOCKET.TCP.STATUS.FINWT1
|
|
|
|
|
sta (ZPPtrSKT),y
|
|
|
|
|
|
2017-03-10 16:35:54 +00:00
|
|
|
|
.8 ldy #S.SOCKET.TCP.OPTIONS
|
2017-03-09 07:11:44 +00:00
|
|
|
|
lda #0
|
2017-02-15 16:14:41 +00:00
|
|
|
|
sta (ZPPtrSKT),y
|
|
|
|
|
|
2017-03-10 16:35:54 +00:00
|
|
|
|
jmp SKT.StoreTCB
|
2017-03-14 07:32:31 +00:00
|
|
|
|
.88 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
|
|
|
|
|
|
2016-04-09 09:15:11 +00:00
|
|
|
|
ldy #S.SOCKET.SRC.PORT
|
|
|
|
|
lda (ZPPtrSKT),y
|
2017-02-16 16:26:11 +00:00
|
|
|
|
tax
|
2016-04-09 09:15:11 +00:00
|
|
|
|
iny
|
|
|
|
|
lda (ZPPtrSKT),y
|
2017-02-16 16:26:11 +00:00
|
|
|
|
ldy #S.TCP.SRCPORT
|
|
|
|
|
sta (ZPFrameOutPtr),y
|
|
|
|
|
iny
|
|
|
|
|
txa
|
|
|
|
|
sta (ZPFrameOutPtr),y
|
2016-04-09 09:15:11 +00:00
|
|
|
|
|
|
|
|
|
ldy #S.SOCKET.DST.PORT
|
|
|
|
|
lda (ZPPtrSKT),y
|
2017-02-16 16:26:11 +00:00
|
|
|
|
tax
|
2016-04-09 09:15:11 +00:00
|
|
|
|
iny
|
|
|
|
|
lda (ZPPtrSKT),y
|
2017-02-16 16:26:11 +00:00
|
|
|
|
ldy #S.TCP.DSTPORT
|
|
|
|
|
sta (ZPFrameOutPtr),y
|
|
|
|
|
iny
|
|
|
|
|
txa
|
|
|
|
|
sta (ZPFrameOutPtr),y
|
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
|
2017-03-13 07:07:07 +00:00
|
|
|
|
lda SKT.TCBCache+S.TCB.INFREE+1
|
2017-02-17 07:20:57 +00:00
|
|
|
|
sta (ZPFrameOutPtr),y
|
|
|
|
|
iny
|
2017-03-13 07:07:07 +00:00
|
|
|
|
lda SKT.TCBCache+S.TCB.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-03-13 22:09:00 +00:00
|
|
|
|
TCP.ComputeChecksum
|
|
|
|
|
lda #0 RESET.TCP.CHECKSUM
|
|
|
|
|
ldy #S.TCP.CHECKSUM
|
2017-01-31 16:40:37 +00:00
|
|
|
|
sta (ZPFrameOutPtr),y
|
2016-03-13 22:09:00 +00:00
|
|
|
|
iny
|
2017-01-31 16:40:37 +00:00
|
|
|
|
sta (ZPFrameOutPtr),y
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2017-01-31 16:40:37 +00:00
|
|
|
|
>LDYA ZPFrameOutPtr
|
2016-03-13 22:09:00 +00:00
|
|
|
|
>STYA ZPTmpPtr1
|
|
|
|
|
|
2017-01-31 16:40:37 +00:00
|
|
|
|
lda ZPFrameOutLen
|
2016-03-13 22:09:00 +00:00
|
|
|
|
sec
|
|
|
|
|
sbc #S.IP-2
|
2017-01-31 16:40:37 +00:00
|
|
|
|
sta ZPDataInLen
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2017-01-31 16:40:37 +00:00
|
|
|
|
lda ZPFrameOutLen+1
|
2016-03-13 22:09:00 +00:00
|
|
|
|
sbc /S.IP-2
|
2017-01-31 16:40:37 +00:00
|
|
|
|
sta ZPDataInLen+1
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
|
|
|
|
clc
|
|
|
|
|
|
2017-01-31 16:40:37 +00:00
|
|
|
|
* lda ZPDataInLen+1
|
2016-03-13 22:09:00 +00:00
|
|
|
|
* adc #0 RESERVED (all zero)
|
|
|
|
|
sta IP.CHECKSUM
|
|
|
|
|
|
2017-01-31 16:40:37 +00:00
|
|
|
|
lda ZPDataInLen
|
2016-03-13 22:09:00 +00:00
|
|
|
|
adc #S.IP.PROTOCOL.TCP
|
|
|
|
|
sta IP.CHECKSUM+1
|
|
|
|
|
|
|
|
|
|
ldy #S.IP.SRC
|
|
|
|
|
|
|
|
|
|
ldx #4 4 words for SRC & DST IP
|
|
|
|
|
|
2017-01-31 16:40:37 +00:00
|
|
|
|
.10 lda (ZPFrameOutPtr),y
|
2016-03-13 22:09:00 +00:00
|
|
|
|
adc IP.CHECKSUM
|
|
|
|
|
sta IP.CHECKSUM
|
|
|
|
|
iny
|
2017-01-31 16:40:37 +00:00
|
|
|
|
lda (ZPFrameOutPtr),y
|
2016-03-13 22:09:00 +00:00
|
|
|
|
adc IP.CHECKSUM+1
|
|
|
|
|
sta IP.CHECKSUM+1
|
|
|
|
|
iny
|
|
|
|
|
dex
|
|
|
|
|
bne .10
|
|
|
|
|
|
|
|
|
|
ldy #S.IP
|
|
|
|
|
|
2017-01-31 16:40:37 +00:00
|
|
|
|
.1 jsr DecDataInLen
|
2016-03-13 22:09:00 +00:00
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
|
|
lda (ZPTmpPtr1),y
|
|
|
|
|
adc IP.CHECKSUM
|
|
|
|
|
sta IP.CHECKSUM
|
|
|
|
|
|
|
|
|
|
iny
|
|
|
|
|
bne .20
|
|
|
|
|
inc ZPTmpPtr1+1
|
|
|
|
|
|
2017-01-31 16:40:37 +00:00
|
|
|
|
.20 jsr DecDataInLen
|
2016-03-13 22:09:00 +00:00
|
|
|
|
bne .2
|
|
|
|
|
lda #0
|
|
|
|
|
bra .21
|
|
|
|
|
|
|
|
|
|
.2 lda (ZPTmpPtr1),y
|
|
|
|
|
|
|
|
|
|
.21 adc IP.CHECKSUM+1
|
|
|
|
|
sta IP.CHECKSUM+1
|
|
|
|
|
|
|
|
|
|
iny
|
|
|
|
|
bne .1
|
|
|
|
|
inc ZPTmpPtr1+1
|
|
|
|
|
bra .1
|
|
|
|
|
|
|
|
|
|
.8 ldy #S.TCP.CHECKSUM
|
|
|
|
|
lda IP.CHECKSUM
|
|
|
|
|
adc #0 Don't forget to add last carry!!!
|
|
|
|
|
eor #$FF
|
2017-01-31 16:40:37 +00:00
|
|
|
|
sta (ZPFrameOutPtr),y
|
2016-03-13 22:09:00 +00:00
|
|
|
|
iny
|
|
|
|
|
lda IP.CHECKSUM+1
|
|
|
|
|
adc #0 Don't forget to add last carry!!!
|
|
|
|
|
eor #$FF
|
2017-01-31 16:40:37 +00:00
|
|
|
|
sta (ZPFrameOutPtr),y
|
2016-01-16 22:04:22 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
|
|
|
|
SAVE LIB/LIBTCPIP.S.TCP
|
|
|
|
|
LOAD LIB/LIBTCPIP.S
|
|
|
|
|
ASM
|