mirror of
https://github.com/A2osX/A2osX.git
synced 2024-12-25 19:30:44 +00:00
170 lines
3.1 KiB
Plaintext
170 lines
3.1 KiB
Plaintext
PR#3
|
||
PREFIX /A2OSX.SRC
|
||
LOMEM $A00
|
||
INC 1
|
||
AUTO 6
|
||
.LIST OFF
|
||
*--------------------------------------
|
||
UDP.IN jsr IP.FillTmpSocketSrcDst
|
||
|
||
ldy #S.UDP.SRCPORT
|
||
lda (ZPFrameInPtr),y
|
||
sta TmpSocket+S.SOCKET.DST.PORT+1
|
||
iny
|
||
lda (ZPFrameInPtr),y
|
||
sta TmpSocket+S.SOCKET.DST.PORT
|
||
|
||
ldy #S.UDP.DSTPORT
|
||
lda (ZPFrameInPtr),y
|
||
sta TmpSocket+S.SOCKET.SRC.PORT+1
|
||
iny
|
||
lda (ZPFrameInPtr),y
|
||
sta TmpSocket+S.SOCKET.SRC.PORT
|
||
|
||
lda hSocketTable
|
||
>SYSCALL GetMemPtrA
|
||
>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
|
||
|
||
lda hFrameIn
|
||
jsr SKT.AddToQueueA
|
||
bcs .9 Q full, discard...
|
||
|
||
rts DO NOT Discard this queued frame
|
||
|
||
.7 lda ZPPtrSKT
|
||
clc
|
||
adc #S.SOCKET
|
||
sta ZPPtrSKT
|
||
bcc .8
|
||
inc ZPPtrSKT+1
|
||
|
||
.8 inx
|
||
cpx #K.SKTTABLE.SIZE
|
||
bne .3
|
||
|
||
.9 lda hFrameIn
|
||
>SYSCALL FreeMemA
|
||
rts
|
||
*--------------------------------------
|
||
UDP.ComputeChecksum
|
||
lda #0 RESET.TCP.CHECKSUM
|
||
ldy #S.UDP.CHECKSUM
|
||
sta (ZPFrameOutPtr),y
|
||
iny
|
||
sta (ZPFrameOutPtr),y
|
||
|
||
>LDYA ZPFrameOutPtr
|
||
>STYA ZPTmpPtr1
|
||
|
||
lda ZPFrameOutLen
|
||
sec
|
||
sbc #S.IP-2
|
||
sta ZPDataInLen
|
||
|
||
lda ZPFrameOutLen+1
|
||
sbc /S.IP-2
|
||
sta ZPDataInLen+1
|
||
|
||
clc
|
||
|
||
ldy #S.UDP.LENGTH
|
||
lda (ZPFrameOutPtr),y
|
||
* adc #0 RESERVED (all zero)
|
||
sta IP.CHECKSUM
|
||
|
||
iny
|
||
lda (ZPFrameOutPtr),y
|
||
adc #S.IP.PROTOCOL.UDP
|
||
sta IP.CHECKSUM+1
|
||
|
||
ldy #S.IP.SRC
|
||
|
||
ldx #4 4 words for SRC & DST IP
|
||
|
||
.10 lda (ZPFrameOutPtr),y
|
||
adc IP.CHECKSUM
|
||
sta IP.CHECKSUM
|
||
iny
|
||
lda (ZPFrameOutPtr),y
|
||
adc IP.CHECKSUM+1
|
||
sta IP.CHECKSUM+1
|
||
iny
|
||
dex
|
||
bne .10
|
||
|
||
ldy #S.IP
|
||
|
||
.1 jsr DecDataInLen
|
||
beq .8
|
||
|
||
lda (ZPTmpPtr1),y
|
||
adc IP.CHECKSUM
|
||
sta IP.CHECKSUM
|
||
|
||
iny
|
||
bne .20
|
||
inc ZPTmpPtr1+1
|
||
|
||
.20 jsr DecDataInLen
|
||
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 (ZPFrameOutPtr),y
|
||
iny
|
||
lda IP.CHECKSUM+1
|
||
adc #0 Don't forget to add last carry!!!
|
||
eor #$FF
|
||
sta (ZPFrameOutPtr),y
|
||
rts
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE LIB/LIBTCPIP.S.UDP
|
||
LOAD LIB/LIBTCPIP.S
|
||
ASM
|