mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-29 17:50:18 +00:00
325 lines
5.6 KiB
Plaintext
325 lines
5.6 KiB
Plaintext
PR#3
|
||
PREFIX /A2OSX.SRC
|
||
NEW
|
||
INC 1
|
||
AUTO 6
|
||
.LIST OFF
|
||
*--------------------------------------
|
||
ARP.CLEAR ldx #K.ARPCACHE.SIZE*S.ARPCACHE
|
||
.1 dex
|
||
stz ARP.CACHE,x
|
||
txa
|
||
bne .1
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
* ARP.QUERY
|
||
* In:
|
||
* PULLW PTR to IP
|
||
* PULLW PTR to MAC (to fill)
|
||
* Out:
|
||
* CC: hit: MAC filled
|
||
* CS: missed
|
||
*--------------------------------------
|
||
ARP.QUERY >PULLW ZPPtrIP IP
|
||
>PULLW ZPPtrMAC MAC
|
||
|
||
ldy #3
|
||
.1 lda (ZPPtrIP),y
|
||
sta ARP.TmpCache+S.ARPCACHE.IP,y
|
||
dey
|
||
bpl .1
|
||
jsr ARP.QUERY.I
|
||
bcs .9
|
||
|
||
ldy #5
|
||
.2 lda ARP.TmpCache+S.ARPCACHE.MAC,y
|
||
sta (ZPPtrMAC),y
|
||
dey
|
||
bpl .2
|
||
clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
* ARP.ADD
|
||
* In:
|
||
* PULLW PTR to IP
|
||
* PULLW PTR to MAC
|
||
*--------------------------------------
|
||
ARP.ADD >PULLW ZPPtrIP IP
|
||
>PULLW ZPPtrMAC MAC
|
||
|
||
stz ARP.TmpCache+S.ARPCACHE.TTL
|
||
stz ARP.TmpCache+S.ARPCACHE.TTL+1
|
||
|
||
ldy #3
|
||
.1 lda (ZPPtrIP),y
|
||
sta ARP.TmpCache+S.ARPCACHE.IP,y
|
||
dey
|
||
bpl .1
|
||
|
||
ldy #5
|
||
.2 lda (ZPPtrMAC),y
|
||
sta ARP.TmpCache+S.ARPCACHE.MAC,y
|
||
dey
|
||
bpl .2
|
||
|
||
lda #S.ARPCACHE.STATUS.RESOLVED+S.ARPCACHE.STATUS.STATIC
|
||
|
||
ARP.ADD.I sta ARP.TmpCache
|
||
|
||
jsr ARP.FIND.BY.IP
|
||
bcc .1
|
||
jsr ARP.FIND.FREE
|
||
|
||
.1 ldy #S.ARPCACHE-1
|
||
.2 lda ARP.TmpCache,y
|
||
sta (ZPCachePtr),y
|
||
dey
|
||
bpl .2
|
||
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
* ARP.GETCACHE
|
||
* Out:
|
||
* Y,A = PTR to ARP.CACHE
|
||
*--------------------------------------
|
||
ARP.GETCACHE >LDYA L.ARP.CACHE
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
* PRIVATE
|
||
*--------------------------------------
|
||
ARP.IN ldy #S.ARP.TPA+3
|
||
ldx #3
|
||
|
||
.1 lda (ZPFrameBase1),y
|
||
cmp IPCFG+S.IPCFG.IP,x
|
||
bne .9
|
||
dey
|
||
dex
|
||
bpl .1
|
||
|
||
ldy #S.ARP.OPERATION+1 HI byte
|
||
lda (ZPFrameBase1),y
|
||
cmp #S.ARP.OPERATION.REQ
|
||
beq ARP.IN.REQ
|
||
|
||
cmp #S.ARP.OPERATION.REP
|
||
beq ARP.IN.REP
|
||
|
||
.9 clc Discard any other ARP frames
|
||
rts
|
||
|
||
ARP.IN.REQ ldy #S.ARP.SPA+3
|
||
ldx #3
|
||
|
||
.1 lda (ZPFrameBase1),y
|
||
sta ARP.REP.TPA,x
|
||
dey
|
||
dex
|
||
bpl .1
|
||
|
||
ldy #S.ARP.SHA+5
|
||
ldx #5
|
||
|
||
.2 lda (ZPFrameBase1),y
|
||
sta ARP.REP.DSTMAC,x
|
||
sta ARP.REP.THA,x
|
||
dey
|
||
dex
|
||
bpl .2
|
||
|
||
>PUSHW L.ARP.REP
|
||
ldx #DEVMGR.NET.SEND
|
||
jsr NetDevJmp
|
||
|
||
ARP.IN.REP lda #K.ARP.TTL
|
||
sta ARP.TmpCache+S.ARPCACHE.TTL
|
||
lda /K.ARP.TTL
|
||
sta ARP.TmpCache+S.ARPCACHE.TTL+1
|
||
|
||
ldy #S.ARP.SPA+3
|
||
ldx #3
|
||
|
||
.1 lda (ZPFrameBase1),y
|
||
sta ARP.TmpCache+S.ARPCACHE.IP,x
|
||
dey
|
||
dex
|
||
bpl .1
|
||
|
||
ldy #S.ARP.SHA+5
|
||
ldx #5
|
||
|
||
.2 lda (ZPFrameBase1),y
|
||
sta ARP.TmpCache+S.ARPCACHE.MAC,x
|
||
dey
|
||
dex
|
||
bpl .2
|
||
|
||
lda #S.ARPCACHE.STATUS.RESOLVED
|
||
|
||
jsr ARP.ADD.I
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
ARP.QUERY.I jsr ARP.FIND.BY.IP
|
||
bcs .3 send an ARP request
|
||
|
||
lda (ZPCachePtr) get status...
|
||
bpl .9 Pending...
|
||
|
||
ldy #S.ARPCACHE.MAC
|
||
|
||
.2 lda (ZPCachePtr),y
|
||
sta ARP.TmpCache,y
|
||
iny
|
||
cpy #S.ARPCACHE.MAC+6
|
||
bne .2
|
||
clc
|
||
rts
|
||
|
||
.3 ldx #3
|
||
|
||
.4 lda ARP.TmpCache+S.ARPCACHE.IP,x
|
||
sta ARP.REQ.TPA,x
|
||
dex
|
||
bpl .4
|
||
|
||
>PUSHW L.ARP.REQ
|
||
ldx #DEVMGR.NET.SEND
|
||
jsr NetDevJmp
|
||
|
||
bcs .99
|
||
|
||
lda #K.ARP.PENDING.TTL
|
||
sta ARP.TmpCache+S.ARPCACHE.TTL
|
||
stz ARP.TmpCache+S.ARPCACHE.TTL+1
|
||
|
||
lda #S.ARPCACHE.STATUS.PENDING
|
||
jsr ARP.ADD.I
|
||
|
||
.9 lda #ERR.ARP.PENDING
|
||
sec
|
||
.99 rts
|
||
*--------------------------------------
|
||
ARP.FIND.BY.IP >LDYA L.ARP.CACHE
|
||
>STYA ZPCachePtr
|
||
|
||
lda #K.ARPCACHE.SIZE
|
||
sta TmpOffset
|
||
|
||
.1 lda (ZPCachePtr)
|
||
beq .3
|
||
|
||
ldx #3
|
||
ldy #S.ARPCACHE.IP+3
|
||
|
||
.2 lda ARP.TmpCache+S.ARPCACHE.IP,x
|
||
cmp (ZPCachePtr),y
|
||
bne .3
|
||
dey
|
||
dex
|
||
bpl .2
|
||
clc
|
||
rts
|
||
|
||
.3 lda ZPCachePtr
|
||
clc
|
||
adc #S.ARPCACHE
|
||
sta ZPCachePtr
|
||
bcc .8
|
||
inc ZPCachePtr+1
|
||
|
||
.8 dec TmpOffset
|
||
bne .1
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
ARP.FIND.FREE >LDYA L.ARP.CACHE
|
||
>STYA ZPCachePtr
|
||
|
||
lda #$ff
|
||
sta TmpDWord
|
||
sta TmpDWord+1
|
||
|
||
ldx #K.ARPCACHE.SIZE
|
||
|
||
.1 lda (ZPCachePtr)
|
||
beq .8
|
||
bpl .6
|
||
|
||
ldy #S.ARPCACHE.TTL
|
||
lda (ZPCachePtr),y
|
||
sec
|
||
sbc TmpDWord
|
||
iny
|
||
lda (ZPCachePtr),y
|
||
sbc TmpDWord+1
|
||
bcc .6
|
||
|
||
lda (ZPCachePtr),y
|
||
sta TmpDWord+1
|
||
dey
|
||
lda (ZPCachePtr),y
|
||
sta TmpDWord
|
||
|
||
>LDYA ZPCachePtr
|
||
>STYA ZPTmpPtr1 save lowest TTL slot ...
|
||
|
||
.6 lda ZPCachePtr
|
||
clc
|
||
adc #S.ARPCACHE
|
||
sta ZPCachePtr
|
||
bcc .7
|
||
inc ZPCachePtr+1
|
||
|
||
.7 dex
|
||
bne .1
|
||
|
||
>LDYA ZPTmpPtr1
|
||
>STYA ZPCachePtr
|
||
lda #0
|
||
sta (ZPCachePtr)
|
||
|
||
.8 clc
|
||
rts
|
||
*--------------------------------------
|
||
ARP.EXPIRE >LDYA L.ARP.CACHE
|
||
>STYA ZPCachePtr
|
||
|
||
ldx #K.ARPCACHE.SIZE
|
||
|
||
.1 lda (ZPCachePtr)
|
||
beq .2
|
||
|
||
ldy #S.ARPCACHE.TTL
|
||
sec
|
||
lda (ZPCachePtr),y
|
||
sbc #1
|
||
sta (ZPCachePtr),y
|
||
iny
|
||
lda (ZPCachePtr),y
|
||
sbc #0
|
||
sta (ZPCachePtr),y
|
||
bcs .2
|
||
|
||
lda #0
|
||
sta (ZPCachePtr)
|
||
|
||
.2 lda ZPCachePtr
|
||
clc
|
||
adc #S.ARPCACHE
|
||
sta ZPCachePtr
|
||
bcc .3
|
||
inc ZPCachePtr+1
|
||
|
||
.3 dex
|
||
bne .1
|
||
rts
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE LIB/LIBTCPIP.S.ARP
|
||
LOAD LIB/LIBTCPIP.S
|
||
ASM
|