2016-01-16 22:04:22 +00:00
|
|
|
|
PR#3
|
|
|
|
|
PREFIX /A2OSX.SRC
|
2017-03-15 16:44:15 +00:00
|
|
|
|
LOMEM $A00
|
2016-01-16 22:04:22 +00:00
|
|
|
|
INC 1
|
|
|
|
|
AUTO 6
|
|
|
|
|
.LIST OFF
|
|
|
|
|
*--------------------------------------
|
2017-02-16 16:26:11 +00:00
|
|
|
|
UDP.IN jsr IP.FillSKT.TemplateSrcDst
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
|
|
|
|
ldy #S.UDP.SRCPORT
|
2017-01-31 16:40:37 +00:00
|
|
|
|
lda (ZPFrameInPtr),y
|
2017-02-16 16:26:11 +00:00
|
|
|
|
sta SKT.Template+S.SOCKET.DST.PORT+1
|
2016-03-13 22:09:00 +00:00
|
|
|
|
iny
|
2017-01-31 16:40:37 +00:00
|
|
|
|
lda (ZPFrameInPtr),y
|
2017-02-16 16:26:11 +00:00
|
|
|
|
sta SKT.Template+S.SOCKET.DST.PORT
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
|
|
|
|
ldy #S.UDP.DSTPORT
|
2017-01-31 16:40:37 +00:00
|
|
|
|
lda (ZPFrameInPtr),y
|
2017-02-16 16:26:11 +00:00
|
|
|
|
sta SKT.Template+S.SOCKET.SRC.PORT+1
|
2016-03-13 22:09:00 +00:00
|
|
|
|
iny
|
2017-01-31 16:40:37 +00:00
|
|
|
|
lda (ZPFrameInPtr),y
|
2017-02-16 16:26:11 +00:00
|
|
|
|
sta SKT.Template+S.SOCKET.SRC.PORT
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2017-02-10 07:29:58 +00:00
|
|
|
|
lda hSocketTable
|
|
|
|
|
>SYSCALL GetMemPtrA
|
2016-03-13 22:09:00 +00:00
|
|
|
|
>STYA ZPPtrSKT
|
|
|
|
|
|
|
|
|
|
ldx #0
|
2016-03-27 21:06:56 +00:00
|
|
|
|
|
2016-03-13 22:09:00 +00:00
|
|
|
|
.3 lda (ZPPtrSKT)
|
|
|
|
|
beq .7
|
|
|
|
|
cmp #S.SOCKET.SOCK.DGRAM
|
|
|
|
|
bne .7
|
|
|
|
|
|
|
|
|
|
ldy #S.SOCKET.SRC.ADDR
|
2016-03-27 21:06:56 +00:00
|
|
|
|
lda (ZPPtrSKT),y SOCKET.SRC.ADDR=0.0.0.0 ?
|
|
|
|
|
bne .41
|
|
|
|
|
ldy #S.SOCKET.SRC.PORT yes, do not check if IP match
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2016-03-27 21:06:56 +00:00
|
|
|
|
.4 lda (ZPPtrSKT),y
|
2017-02-16 16:26:11 +00:00
|
|
|
|
.41 cmp SKT.Template,y
|
2016-03-13 22:09:00 +00:00
|
|
|
|
bne .7
|
|
|
|
|
iny
|
2016-03-27 21:06:56 +00:00
|
|
|
|
cpy #S.SOCKET.DST.ADDR
|
2016-03-13 22:09:00 +00:00
|
|
|
|
bne .4
|
|
|
|
|
|
2016-03-27 21:06:56 +00:00
|
|
|
|
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
|
2017-02-16 16:26:11 +00:00
|
|
|
|
.51 cmp SKT.Template,y
|
2016-03-27 21:06:56 +00:00
|
|
|
|
bne .7
|
|
|
|
|
iny
|
|
|
|
|
cpy #S.SOCKET.DST.PORT+2
|
|
|
|
|
bne .5
|
|
|
|
|
|
2017-01-30 16:30:39 +00:00
|
|
|
|
lda hFrameIn
|
|
|
|
|
jsr SKT.AddToQueueA
|
2017-01-29 21:47:19 +00:00
|
|
|
|
bcs .9 Q full, discard...
|
|
|
|
|
|
|
|
|
|
rts DO NOT Discard this queued frame
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
|
|
|
|
.7 lda ZPPtrSKT
|
|
|
|
|
clc
|
|
|
|
|
adc #S.SOCKET
|
|
|
|
|
sta ZPPtrSKT
|
|
|
|
|
bcc .8
|
|
|
|
|
inc ZPPtrSKT+1
|
|
|
|
|
|
|
|
|
|
.8 inx
|
|
|
|
|
cpx #K.SKTTABLE.SIZE
|
|
|
|
|
bne .3
|
|
|
|
|
|
2017-01-29 21:47:19 +00:00
|
|
|
|
.9 lda hFrameIn
|
|
|
|
|
>SYSCALL FreeMemA
|
|
|
|
|
rts
|
2016-03-13 22:09:00 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
UDP.ComputeChecksum
|
|
|
|
|
lda #0 RESET.TCP.CHECKSUM
|
|
|
|
|
ldy #S.UDP.CHECKSUM
|
2017-01-31 16:40:37 +00:00
|
|
|
|
sta (ZPFrameOutPtr),y
|
2016-03-13 22:09:00 +00:00
|
|
|
|
iny
|
2017-01-31 16:40:37 +00:00
|
|
|
|
sta (ZPFrameOutPtr),y
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2017-01-31 16:40:37 +00:00
|
|
|
|
>LDYA ZPFrameOutPtr
|
2016-03-13 22:09:00 +00:00
|
|
|
|
>STYA ZPTmpPtr1
|
|
|
|
|
|
2017-01-31 16:40:37 +00:00
|
|
|
|
lda ZPFrameOutLen
|
2016-03-13 22:09:00 +00:00
|
|
|
|
sec
|
|
|
|
|
sbc #S.IP-2
|
2017-01-31 16:40:37 +00:00
|
|
|
|
sta ZPDataInLen
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2017-01-31 16:40:37 +00:00
|
|
|
|
lda ZPFrameOutLen+1
|
2016-03-13 22:09:00 +00:00
|
|
|
|
sbc /S.IP-2
|
2017-01-31 16:40:37 +00:00
|
|
|
|
sta ZPDataInLen+1
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
|
|
|
|
clc
|
|
|
|
|
|
|
|
|
|
ldy #S.UDP.LENGTH
|
2017-01-31 16:40:37 +00:00
|
|
|
|
lda (ZPFrameOutPtr),y
|
2016-03-13 22:09:00 +00:00
|
|
|
|
* adc #0 RESERVED (all zero)
|
|
|
|
|
sta IP.CHECKSUM
|
|
|
|
|
|
|
|
|
|
iny
|
2017-01-31 16:40:37 +00:00
|
|
|
|
lda (ZPFrameOutPtr),y
|
2016-03-13 22:09:00 +00:00
|
|
|
|
adc #S.IP.PROTOCOL.UDP
|
|
|
|
|
sta IP.CHECKSUM+1
|
|
|
|
|
|
|
|
|
|
ldy #S.IP.SRC
|
|
|
|
|
|
|
|
|
|
ldx #4 4 words for SRC & DST IP
|
|
|
|
|
|
2017-01-31 16:40:37 +00:00
|
|
|
|
.10 lda (ZPFrameOutPtr),y
|
2016-03-13 22:09:00 +00:00
|
|
|
|
adc IP.CHECKSUM
|
|
|
|
|
sta IP.CHECKSUM
|
|
|
|
|
iny
|
2017-01-31 16:40:37 +00:00
|
|
|
|
lda (ZPFrameOutPtr),y
|
2016-03-13 22:09:00 +00:00
|
|
|
|
adc IP.CHECKSUM+1
|
|
|
|
|
sta IP.CHECKSUM+1
|
|
|
|
|
iny
|
|
|
|
|
dex
|
|
|
|
|
bne .10
|
|
|
|
|
|
|
|
|
|
ldy #S.IP
|
|
|
|
|
|
2017-01-31 16:40:37 +00:00
|
|
|
|
.1 jsr DecDataInLen
|
2016-03-13 22:09:00 +00:00
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
|
|
lda (ZPTmpPtr1),y
|
|
|
|
|
adc IP.CHECKSUM
|
|
|
|
|
sta IP.CHECKSUM
|
|
|
|
|
|
|
|
|
|
iny
|
|
|
|
|
bne .20
|
|
|
|
|
inc ZPTmpPtr1+1
|
|
|
|
|
|
2017-01-31 16:40:37 +00:00
|
|
|
|
.20 jsr DecDataInLen
|
2016-03-13 22:09:00 +00:00
|
|
|
|
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
|
2017-01-31 16:40:37 +00:00
|
|
|
|
sta (ZPFrameOutPtr),y
|
2016-03-13 22:09:00 +00:00
|
|
|
|
iny
|
|
|
|
|
lda IP.CHECKSUM+1
|
|
|
|
|
adc #0 Don't forget to add last carry!!!
|
|
|
|
|
eor #$FF
|
2017-01-31 16:40:37 +00:00
|
|
|
|
sta (ZPFrameOutPtr),y
|
2016-01-16 22:04:22 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
|
|
|
|
SAVE LIB/LIBTCPIP.S.UDP
|
|
|
|
|
LOAD LIB/LIBTCPIP.S
|
|
|
|
|
ASM
|