A2osX/LIB/LIBTCPIP.S.IP.txt
2016-01-16 23:04:22 +01:00

102 lines
1.8 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

PR#3
PREFIX /A2OSX.SRC
NEW
INC 1
AUTO 6
.LIST OFF
*--------------------------------------
IP.IN >PULLW ZPFrameBase1
>PULLW ZPFrameLen1
ldy #S.IP.PROTOCOL
lda (ZPFrameBase1),y
cmp #S.IP.PROTOCOL.ICMP
bne .2
jmp ICMP.IN
.2 cmp #S.IP.PROTOCOL.UDP
bne .3
ldy #S.UDP.DSTPORT
lda /UDP.PORT.DNS
cmp (ZPFrameBase1),y
bne .21
iny
lda #UDP.PORT.DNS
cmp (ZPFrameBase1),y
bne .21
jmp DNS.IN
.21 jmp UDP.IN
.3 cmp #S.IP.PROTOCOL.TCP
bne .9
jmp TCP.IN
.9 sec
rts
*--------------------------------------
* In:
* PULLW = Start Offset
* PULLW = End Offset
* Out:
* Y,A = CheckSum
*--------------------------------------
IP.ComputeChecksum
>PULLA
clc
adc ZPFrameBase1
sta ZPTmpPtr1
>PULLA
adc ZPFrameBase1+1
sta ZPTmpPtr1+1
>PULLA
clc
adc ZPFrameBase1
sta TmpOffset
>PULLA
adc ZPFrameBase1+1
sta TmpOffset+1
stz IP.CHECKSUM RESET.IP.CHECKSUM
stz IP.CHECKSUM+1
stz IP.CHECKSUM+2
stz IP.CHECKSUM+3
ldy #1
.1 lda (ZPTmpPtr1),y
clc
adc IP.CHECKSUM
sta IP.CHECKSUM
lda (ZPTmpPtr1)
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
*--------------------------------------
MAN
SAVE LIB/LIBTCPIP.S.IP
LOAD LIB/LIBTCPIP.S
ASM