mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-23 07:35:19 +00:00
177 lines
3.3 KiB
Plaintext
177 lines
3.3 KiB
Plaintext
NEW
|
||
PREFIX /A2OSX.BUILD
|
||
AUTO 4,1
|
||
.LIST OFF
|
||
*--------------------------------------
|
||
UDP.IN jsr IP.FillSKT.TemplateSrcDst
|
||
|
||
ldy #S.UDP.SRCPORT
|
||
lda (ZPFrameInPtr),y
|
||
sta SKT.Template+S.SOCKET.DST.PORT+1
|
||
iny
|
||
lda (ZPFrameInPtr),y
|
||
sta SKT.Template+S.SOCKET.DST.PORT
|
||
|
||
ldy #S.UDP.DSTPORT
|
||
lda (ZPFrameInPtr),y
|
||
sta SKT.Template+S.SOCKET.SRC.PORT+1
|
||
iny
|
||
lda (ZPFrameInPtr),y
|
||
sta SKT.Template+S.SOCKET.SRC.PORT
|
||
|
||
lda hSocketTable
|
||
>SYSCALL GetMemPtr.A
|
||
>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 SKT.Template,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 SKT.Template,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 FreeMem.A
|
||
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
|
||
*--------------------------------------
|
||
DecDataInLen lda ZPDataInLen
|
||
bne .1
|
||
lda ZPDataInLen+1
|
||
beq .9
|
||
dec ZPDataInLen+1
|
||
.1 dec ZPDataInLen
|
||
lda #$FF Make NZ
|
||
.9 rts
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE /A2OSX.SRC/LIB/LIBTCPIP.S.UDP
|
||
LOAD /A2OSX.SRC/LIB/LIBTCPIP.S
|
||
ASM
|