mirror of
https://github.com/A2osX/A2osX.git
synced 2024-10-30 01:26:10 +00:00
179 lines
3.1 KiB
Plaintext
179 lines
3.1 KiB
Plaintext
NEW
|
||
PREFIX /A2OSX.BUILD
|
||
AUTO 4,1
|
||
.LIST OFF
|
||
*--------------------------------------
|
||
IP.IN ldy #S.IP.PROTOCOL
|
||
lda (ZPFrameInPtr),y
|
||
cmp #S.IP.PROTOCOL.ICMP
|
||
bne .2
|
||
jmp ICMP.IN
|
||
|
||
.2 cmp #S.IP.PROTOCOL.UDP
|
||
bne .3
|
||
|
||
jmp UDP.IN
|
||
|
||
.3 cmp #S.IP.PROTOCOL.TCP
|
||
bne .9
|
||
jsr TCP.IN TCP will NOT discard FrameIn
|
||
|
||
.9 lda hFrameIn
|
||
>SYSCALL FreeMem
|
||
rts
|
||
*--------------------------------------
|
||
* In:
|
||
* PULLW = Start Offset
|
||
* PULLW = End Offset
|
||
* Out:
|
||
* Y,A = CheckSum
|
||
*--------------------------------------
|
||
IP.ComputeChecksum
|
||
>PULLA
|
||
clc
|
||
adc ZPFrameOutPtr
|
||
sta ZPTmpPtr1
|
||
>PULLA
|
||
adc ZPFrameOutPtr+1
|
||
sta ZPTmpPtr1+1
|
||
|
||
>PULLA
|
||
clc
|
||
adc ZPFrameOutPtr
|
||
sta TmpOffset
|
||
>PULLA
|
||
adc ZPFrameOutPtr+1
|
||
sta TmpOffset+1
|
||
|
||
stz IP.CHECKSUM
|
||
stz IP.CHECKSUM+1
|
||
stz IP.CHECKSUM+2
|
||
stz IP.CHECKSUM+3
|
||
|
||
ldy #2
|
||
|
||
.1 clc
|
||
|
||
iny
|
||
lda (ZPTmpPtr1),y
|
||
adc IP.CHECKSUM
|
||
sta IP.CHECKSUM
|
||
|
||
dey
|
||
lda (ZPTmpPtr1),y
|
||
adc IP.CHECKSUM+1
|
||
sta IP.CHECKSUM+1
|
||
|
||
bcc .3
|
||
inc IP.CHECKSUM+2
|
||
bne .3
|
||
inc IP.CHECKSUM+3
|
||
|
||
.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
|
||
|
||
lda IP.CHECKSUM
|
||
clc
|
||
adc IP.CHECKSUM+2
|
||
eor #$FF
|
||
tay
|
||
lda IP.CHECKSUM+1
|
||
adc IP.CHECKSUM+3
|
||
eor #$FF
|
||
rts
|
||
*--------------------------------------
|
||
IP.FillSKT.TemplateSrcDst
|
||
ldy #S.IP.SRC+3
|
||
ldx #3
|
||
.1 lda (ZPFrameInPtr),y
|
||
sta SKT.Template+S.SOCKET.DST.ADDR,x
|
||
dey
|
||
dex
|
||
bpl .1
|
||
|
||
ldy #S.IP.DST+3
|
||
ldx #3
|
||
.2 lda (ZPFrameInPtr),y
|
||
sta SKT.Template+S.SOCKET.SRC.ADDR,x
|
||
dey
|
||
dex
|
||
bpl .2
|
||
rts
|
||
*--------------------------------------
|
||
IP.SetDestMAC ldy #S.IP.DST
|
||
lda (ZPFrameOutPtr),y
|
||
iny
|
||
|
||
.1 and (ZPFrameOutPtr),y
|
||
iny
|
||
cpy #S.IP.DST+4
|
||
bne .1
|
||
|
||
cmp #$FF
|
||
bne .3 not a broadcast....
|
||
|
||
ldy #S.ETH.DSTMAC
|
||
|
||
.2 sta (ZPFrameOutPtr),y
|
||
iny
|
||
cpy #S.ETH.DSTMAC+6
|
||
bne .2
|
||
|
||
clc
|
||
rts
|
||
|
||
.3 ldy #S.IP.DST+3
|
||
ldx #3
|
||
|
||
.4 lda (ZPFrameOutPtr),y
|
||
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
|
||
|
||
.5 lda (ZPFrameOutPtr),y
|
||
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
|
||
sta (ZPFrameOutPtr),y
|
||
dey
|
||
dex
|
||
bpl .11
|
||
clc
|
||
.99 rts
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE /A2OSX.SRC/LIB/LIBTCPIP.S.IP
|
||
LOAD /A2OSX.SRC/LIB/LIBTCPIP.S
|
||
ASM
|