mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-26 13:49:18 +00:00
184 lines
3.3 KiB
Plaintext
184 lines
3.3 KiB
Plaintext
PR#3
|
||
PREFIX /A2OSX.SRC
|
||
NEW
|
||
INC 1
|
||
AUTO 6
|
||
.LIST OFF
|
||
*--------------------------------------
|
||
UDP.IN ldy #S.IP.SRC+3
|
||
ldx #3
|
||
.1 lda (ZPFrameBase1),y
|
||
sta TmpSocket+S.SOCKET.DST.ADDR,x
|
||
dey
|
||
dex
|
||
bpl .1
|
||
|
||
ldy #S.UDP.SRCPORT
|
||
lda (ZPFrameBase1),y
|
||
sta TmpSocket+S.SOCKET.DST.PORT+1
|
||
iny
|
||
lda (ZPFrameBase1),y
|
||
sta TmpSocket+S.SOCKET.DST.PORT
|
||
|
||
ldy #S.IP.DST+3
|
||
ldx #3
|
||
.2 lda (ZPFrameBase1),y
|
||
sta TmpSocket+S.SOCKET.SRC.ADDR,x
|
||
dey
|
||
dex
|
||
bpl .2
|
||
|
||
ldy #S.UDP.DSTPORT
|
||
lda (ZPFrameBase1),y
|
||
sta TmpSocket+S.SOCKET.SRC.PORT+1
|
||
iny
|
||
lda (ZPFrameBase1),y
|
||
sta TmpSocket+S.SOCKET.SRC.PORT
|
||
|
||
>LDYA L.SKT.TABLE
|
||
>STYA ZPPtrSKT
|
||
|
||
ldx #0
|
||
|
||
.3 lda (ZPPtrSKT)
|
||
beq .7
|
||
cmp #S.SOCKET.SOCK.DGRAM
|
||
bne .7
|
||
|
||
ldy #S.SOCKET.SRC.ADDR
|
||
lda (ZPPtrSKT),y SOCKET.SRC.ADDR=0.0.0.0 ?
|
||
bne .41
|
||
ldy #S.SOCKET.SRC.PORT yes, do not check if IP match
|
||
|
||
.4 lda (ZPPtrSKT),y
|
||
.41 cmp TmpSocket,y
|
||
bne .7
|
||
iny
|
||
cpy #S.SOCKET.DST.ADDR
|
||
bne .4
|
||
|
||
lda (ZPPtrSKT),y SOCKET.DST.ADDR=FF.FF.FF.FF ?
|
||
cmp #$FF
|
||
bne .51
|
||
ldy #S.SOCKET.DST.PORT yes, do not check if IP match
|
||
|
||
.5 lda (ZPPtrSKT),y
|
||
.51 cmp TmpSocket,y
|
||
bne .7
|
||
iny
|
||
cpy #S.SOCKET.DST.PORT+2
|
||
bne .5
|
||
|
||
jsr SKT.AddToQueueD
|
||
bcs .99
|
||
lda (pEvent) Make sure kernel not discard frame...
|
||
and #$FF^S.EVT.F.hMEM1
|
||
sta (pEvent)
|
||
clc ...when clearing event!!!!
|
||
rts
|
||
|
||
.7 lda ZPPtrSKT
|
||
clc
|
||
adc #S.SOCKET
|
||
sta ZPPtrSKT
|
||
bcc .8
|
||
inc ZPPtrSKT+1
|
||
|
||
.8 inx
|
||
cpx #K.SKTTABLE.SIZE
|
||
bne .3
|
||
|
||
.9 sec
|
||
.99 rts
|
||
*--------------------------------------
|
||
UDP.ComputeChecksum
|
||
lda #0 RESET.TCP.CHECKSUM
|
||
ldy #S.UDP.CHECKSUM
|
||
sta (ZPFrameBase1),y
|
||
iny
|
||
sta (ZPFrameBase1),y
|
||
|
||
>LDYA ZPFrameBase1
|
||
>STYA ZPTmpPtr1
|
||
|
||
lda ZPFrameLen1
|
||
sec
|
||
sbc #S.IP-2
|
||
sta ZPDataLen
|
||
|
||
lda ZPFrameLen1+1
|
||
sbc /S.IP-2
|
||
sta ZPDataLen+1
|
||
|
||
clc
|
||
|
||
ldy #S.UDP.LENGTH
|
||
lda (ZPFrameBase1),y
|
||
* adc #0 RESERVED (all zero)
|
||
sta IP.CHECKSUM
|
||
|
||
iny
|
||
lda (ZPFrameBase1),y
|
||
adc #S.IP.PROTOCOL.UDP
|
||
sta IP.CHECKSUM+1
|
||
|
||
ldy #S.IP.SRC
|
||
|
||
ldx #4 4 words for SRC & DST IP
|
||
|
||
.10 lda (ZPFrameBase1),y
|
||
adc IP.CHECKSUM
|
||
sta IP.CHECKSUM
|
||
iny
|
||
lda (ZPFrameBase1),y
|
||
adc IP.CHECKSUM+1
|
||
sta IP.CHECKSUM+1
|
||
iny
|
||
dex
|
||
bne .10
|
||
|
||
ldy #S.IP
|
||
|
||
.1 jsr DecDataLen
|
||
beq .8
|
||
|
||
lda (ZPTmpPtr1),y
|
||
adc IP.CHECKSUM
|
||
sta IP.CHECKSUM
|
||
|
||
iny
|
||
bne .20
|
||
inc ZPTmpPtr1+1
|
||
|
||
.20 jsr DecDataLen
|
||
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.UDP.CHECKSUM
|
||
lda IP.CHECKSUM
|
||
adc #0 Don't forget to add last carry!!!
|
||
eor #$FF
|
||
sta (ZPFrameBase1),y
|
||
iny
|
||
lda IP.CHECKSUM+1
|
||
adc #0 Don't forget to add last carry!!!
|
||
eor #$FF
|
||
sta (ZPFrameBase1),y
|
||
rts
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE LIB/LIBTCPIP.S.UDP
|
||
LOAD LIB/LIBTCPIP.S
|
||
ASM
|