2016-01-16 22:04:22 +00:00
|
|
|
|
PR#3
|
2017-03-29 15:48:15 +00:00
|
|
|
|
PREFIX /A2OSX.BUILD
|
2017-03-15 16:44:15 +00:00
|
|
|
|
LOMEM $A00
|
2016-01-16 22:04:22 +00:00
|
|
|
|
INC 1
|
|
|
|
|
AUTO 6
|
|
|
|
|
.LIST OFF
|
|
|
|
|
*--------------------------------------
|
2016-03-13 22:09:00 +00:00
|
|
|
|
IP.IN ldy #S.IP.PROTOCOL
|
2017-01-31 16:40:37 +00:00
|
|
|
|
lda (ZPFrameInPtr),y
|
2016-01-16 22:04:22 +00:00
|
|
|
|
cmp #S.IP.PROTOCOL.ICMP
|
|
|
|
|
bne .2
|
|
|
|
|
jmp ICMP.IN
|
|
|
|
|
|
|
|
|
|
.2 cmp #S.IP.PROTOCOL.UDP
|
|
|
|
|
bne .3
|
|
|
|
|
|
2017-01-29 21:47:19 +00:00
|
|
|
|
jmp UDP.IN
|
2016-01-16 22:04:22 +00:00
|
|
|
|
|
|
|
|
|
.3 cmp #S.IP.PROTOCOL.TCP
|
|
|
|
|
bne .9
|
2017-03-14 16:46:29 +00:00
|
|
|
|
jsr TCP.IN TCP will NOT discard FrameIn
|
2016-01-16 22:04:22 +00:00
|
|
|
|
|
2017-01-29 21:47:19 +00:00
|
|
|
|
.9 lda hFrameIn
|
|
|
|
|
>SYSCALL FreeMemA
|
2016-01-16 22:04:22 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* In:
|
|
|
|
|
* PULLW = Start Offset
|
|
|
|
|
* PULLW = End Offset
|
|
|
|
|
* Out:
|
|
|
|
|
* Y,A = CheckSum
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
IP.ComputeChecksum
|
|
|
|
|
>PULLA
|
|
|
|
|
clc
|
2017-01-31 16:40:37 +00:00
|
|
|
|
adc ZPFrameOutPtr
|
2016-01-16 22:04:22 +00:00
|
|
|
|
sta ZPTmpPtr1
|
|
|
|
|
>PULLA
|
2017-01-31 16:40:37 +00:00
|
|
|
|
adc ZPFrameOutPtr+1
|
2016-01-16 22:04:22 +00:00
|
|
|
|
sta ZPTmpPtr1+1
|
|
|
|
|
|
|
|
|
|
>PULLA
|
|
|
|
|
clc
|
2017-01-31 16:40:37 +00:00
|
|
|
|
adc ZPFrameOutPtr
|
2016-01-16 22:04:22 +00:00
|
|
|
|
sta TmpOffset
|
|
|
|
|
>PULLA
|
2017-01-31 16:40:37 +00:00
|
|
|
|
adc ZPFrameOutPtr+1
|
2016-01-16 22:04:22 +00:00
|
|
|
|
sta TmpOffset+1
|
|
|
|
|
|
2016-03-13 22:09:00 +00:00
|
|
|
|
stz IP.CHECKSUM
|
2016-01-16 22:04:22 +00:00
|
|
|
|
stz IP.CHECKSUM+1
|
|
|
|
|
stz IP.CHECKSUM+2
|
|
|
|
|
stz IP.CHECKSUM+3
|
|
|
|
|
|
2016-03-13 22:09:00 +00:00
|
|
|
|
ldy #2
|
|
|
|
|
|
|
|
|
|
.1 clc
|
|
|
|
|
|
|
|
|
|
iny
|
|
|
|
|
lda (ZPTmpPtr1),y
|
2016-01-16 22:04:22 +00:00
|
|
|
|
adc IP.CHECKSUM
|
|
|
|
|
sta IP.CHECKSUM
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
|
|
|
|
dey
|
|
|
|
|
lda (ZPTmpPtr1),y
|
2016-01-16 22:04:22 +00:00
|
|
|
|
adc IP.CHECKSUM+1
|
|
|
|
|
sta IP.CHECKSUM+1
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2016-01-16 22:04:22 +00:00
|
|
|
|
bcc .3
|
|
|
|
|
inc IP.CHECKSUM+2
|
|
|
|
|
bne .3
|
|
|
|
|
inc IP.CHECKSUM+3
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2016-01-16 22:04:22 +00:00
|
|
|
|
.3 lda ZPTmpPtr1
|
|
|
|
|
clc
|
|
|
|
|
adc #2
|
|
|
|
|
sta ZPTmpPtr1
|
|
|
|
|
bcc .4
|
|
|
|
|
inc ZPTmpPtr1+1
|
|
|
|
|
.4 cmp TmpOffset
|
|
|
|
|
bne .1
|
|
|
|
|
lda ZPTmpPtr1+1
|
|
|
|
|
cmp TmpOffset+1
|
|
|
|
|
bne .1
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2016-01-16 22:04:22 +00:00
|
|
|
|
lda IP.CHECKSUM
|
|
|
|
|
clc
|
|
|
|
|
adc IP.CHECKSUM+2
|
|
|
|
|
eor #$FF
|
|
|
|
|
tay
|
|
|
|
|
lda IP.CHECKSUM+1
|
|
|
|
|
adc IP.CHECKSUM+3
|
|
|
|
|
eor #$FF
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-02-16 16:26:11 +00:00
|
|
|
|
IP.FillSKT.TemplateSrcDst
|
2017-01-30 16:30:39 +00:00
|
|
|
|
ldy #S.IP.SRC+3
|
|
|
|
|
ldx #3
|
2017-01-31 16:40:37 +00:00
|
|
|
|
.1 lda (ZPFrameInPtr),y
|
2017-02-16 16:26:11 +00:00
|
|
|
|
sta SKT.Template+S.SOCKET.DST.ADDR,x
|
2017-01-30 16:30:39 +00:00
|
|
|
|
dey
|
|
|
|
|
dex
|
|
|
|
|
bpl .1
|
|
|
|
|
|
|
|
|
|
ldy #S.IP.DST+3
|
|
|
|
|
ldx #3
|
2017-01-31 16:40:37 +00:00
|
|
|
|
.2 lda (ZPFrameInPtr),y
|
2017-02-16 16:26:11 +00:00
|
|
|
|
sta SKT.Template+S.SOCKET.SRC.ADDR,x
|
2017-01-30 16:30:39 +00:00
|
|
|
|
dey
|
|
|
|
|
dex
|
|
|
|
|
bpl .2
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2016-03-20 22:16:01 +00:00
|
|
|
|
IP.SetDestMAC ldy #S.IP.DST
|
2017-01-31 16:40:37 +00:00
|
|
|
|
lda (ZPFrameOutPtr),y
|
2016-03-20 22:16:01 +00:00
|
|
|
|
iny
|
|
|
|
|
|
2017-01-31 16:40:37 +00:00
|
|
|
|
.1 and (ZPFrameOutPtr),y
|
2016-03-20 22:16:01 +00:00
|
|
|
|
iny
|
|
|
|
|
cpy #S.IP.DST+4
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
cmp #$FF
|
|
|
|
|
bne .3 not a broadcast....
|
|
|
|
|
|
|
|
|
|
ldy #S.ETH.DSTMAC
|
|
|
|
|
|
2017-01-31 16:40:37 +00:00
|
|
|
|
.2 sta (ZPFrameOutPtr),y
|
2016-03-20 22:16:01 +00:00
|
|
|
|
iny
|
|
|
|
|
cpy #S.ETH.DSTMAC+6
|
|
|
|
|
bne .2
|
|
|
|
|
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.3 ldy #S.IP.DST+3
|
|
|
|
|
ldx #3
|
|
|
|
|
|
2017-01-31 16:40:37 +00:00
|
|
|
|
.4 lda (ZPFrameOutPtr),y
|
2016-03-20 22:16:01 +00:00
|
|
|
|
eor IPCFG+S.IPCFG.IP,x
|
|
|
|
|
and IPCFG+S.IPCFG.MASK,x
|
|
|
|
|
bne .6
|
|
|
|
|
dey
|
|
|
|
|
dex
|
|
|
|
|
bpl .4
|
|
|
|
|
|
|
|
|
|
ldy #S.IP.DST+3 Same network, query ARP for dest IP
|
|
|
|
|
ldx #3
|
|
|
|
|
|
2017-01-31 16:40:37 +00:00
|
|
|
|
.5 lda (ZPFrameOutPtr),y
|
2016-03-20 22:16:01 +00:00
|
|
|
|
sta ARP.TmpCache+S.ARPCACHE.IP,x
|
|
|
|
|
dey
|
|
|
|
|
dex
|
|
|
|
|
bpl .5
|
|
|
|
|
bra .8
|
|
|
|
|
|
|
|
|
|
.6 ldx #3 Not Same network, query ARP for GW
|
|
|
|
|
|
|
|
|
|
.7 lda IPCFG+S.IPCFG.GW,x
|
|
|
|
|
sta ARP.TmpCache+S.ARPCACHE.IP,x
|
|
|
|
|
dex
|
|
|
|
|
bpl .7
|
|
|
|
|
|
|
|
|
|
.8 jsr ARP.QUERY.I
|
|
|
|
|
bcs .99
|
|
|
|
|
|
|
|
|
|
ldx #5
|
|
|
|
|
ldy #S.ETH.DSTMAC+5
|
|
|
|
|
.11 lda ARP.TmpCache+S.ARPCACHE.MAC,x
|
2017-01-31 16:40:37 +00:00
|
|
|
|
sta (ZPFrameOutPtr),y
|
2016-03-20 22:16:01 +00:00
|
|
|
|
dey
|
|
|
|
|
dex
|
|
|
|
|
bpl .11
|
|
|
|
|
clc
|
|
|
|
|
.99 rts
|
|
|
|
|
*--------------------------------------
|
2016-01-16 22:04:22 +00:00
|
|
|
|
MAN
|
2017-03-30 06:31:12 +00:00
|
|
|
|
SAVE /A2OSX.SRC/LIB/LIBTCPIP.S.IP
|
|
|
|
|
LOAD /A2OSX.SRC/LIB/LIBTCPIP.S
|
2016-01-16 22:04:22 +00:00
|
|
|
|
ASM
|