2017-12-22 21:24:30 +00:00
|
|
|
|
NEW
|
2017-03-29 15:48:15 +00:00
|
|
|
|
PREFIX /A2OSX.BUILD
|
2017-12-22 21:24:30 +00:00
|
|
|
|
AUTO 4,1
|
2015-03-14 21:48:35 +00:00
|
|
|
|
.LIST OFF
|
2017-02-15 16:14:41 +00:00
|
|
|
|
*/--------------------------------------
|
2017-03-30 16:11:31 +00:00
|
|
|
|
* # ARP.Clear
|
2017-02-15 16:14:41 +00:00
|
|
|
|
* Clear ARP Cache
|
2018-06-18 08:44:02 +00:00
|
|
|
|
* **In:**
|
|
|
|
|
* **Out:**
|
2017-02-15 16:14:41 +00:00
|
|
|
|
*\--------------------------------------
|
|
|
|
|
ARP.Clear ldx #K.ARPCACHE.SIZE*S.ARPCACHE
|
2017-01-29 21:47:19 +00:00
|
|
|
|
.1 stz ARP.CACHE-1,x
|
|
|
|
|
dex
|
2016-03-20 22:16:01 +00:00
|
|
|
|
bne .1
|
|
|
|
|
clc
|
|
|
|
|
rts
|
2017-02-15 16:14:41 +00:00
|
|
|
|
*/--------------------------------------
|
2017-03-30 16:11:31 +00:00
|
|
|
|
* # ARP.Query
|
2017-02-15 16:14:41 +00:00
|
|
|
|
* Query ARP Cache and returns HW address
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **In:**
|
2017-02-15 16:14:41 +00:00
|
|
|
|
* PUSHW PTR to MAC (to fill)
|
|
|
|
|
* PUSHW PTR to IP
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **Out:**
|
2017-02-15 16:14:41 +00:00
|
|
|
|
* CC: hit: MAC filled
|
|
|
|
|
* CS: missed
|
|
|
|
|
*\--------------------------------------
|
|
|
|
|
ARP.Query >PULLW ZPPtrIP IP
|
2016-03-20 22:16:01 +00:00
|
|
|
|
>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
|
2017-02-15 16:14:41 +00:00
|
|
|
|
*/--------------------------------------
|
2017-03-30 16:11:31 +00:00
|
|
|
|
* # ARP.Add
|
2017-02-15 16:14:41 +00:00
|
|
|
|
* Add a static ARP cache record
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **In:**
|
2017-02-15 16:14:41 +00:00
|
|
|
|
* PUSHW PTR to MAC
|
|
|
|
|
* PUSHW PTR to IP
|
|
|
|
|
*\--------------------------------------
|
|
|
|
|
ARP.Add >PULLW ZPPtrIP IP
|
2016-03-20 22:16:01 +00:00
|
|
|
|
>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
|
2017-02-15 16:14:41 +00:00
|
|
|
|
*/--------------------------------------
|
2017-10-06 15:25:14 +00:00
|
|
|
|
* # ARP.GetCAche
|
2017-02-15 16:14:41 +00:00
|
|
|
|
* Return a Ptr to ARP Cache Table
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **In:**
|
|
|
|
|
* **Out:**
|
2016-03-20 22:16:01 +00:00
|
|
|
|
* Y,A = PTR to ARP.CACHE
|
2017-02-15 16:14:41 +00:00
|
|
|
|
*\--------------------------------------
|
2017-10-06 15:25:14 +00:00
|
|
|
|
ARP.GetCAche >LDYA L.ARP.CACHE
|
2016-03-20 22:16:01 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* PRIVATE
|
|
|
|
|
*--------------------------------------
|
2017-02-17 07:20:57 +00:00
|
|
|
|
ARP.AddFromFrameInPtr
|
|
|
|
|
ldy #S.IP.SRC+3
|
|
|
|
|
ldx #3
|
|
|
|
|
|
|
|
|
|
.1 lda (ZPFrameInPtr),y
|
|
|
|
|
sta ARP.TmpCache+S.ARPCACHE.IP,x
|
|
|
|
|
dey
|
|
|
|
|
dex
|
|
|
|
|
bpl .1
|
|
|
|
|
|
|
|
|
|
ldy #S.ETH.SRCMAC+5
|
|
|
|
|
ldx #5
|
|
|
|
|
|
|
|
|
|
.2 lda (ZPFrameInPtr),y
|
|
|
|
|
sta ARP.TmpCache+S.ARPCACHE.MAC,x
|
|
|
|
|
dey
|
|
|
|
|
dex
|
|
|
|
|
bpl .2
|
|
|
|
|
|
|
|
|
|
lda #K.ARP.TTL
|
|
|
|
|
sta ARP.TmpCache+S.ARPCACHE.TTL
|
|
|
|
|
lda /K.ARP.TTL
|
|
|
|
|
sta ARP.TmpCache+S.ARPCACHE.TTL+1
|
|
|
|
|
|
|
|
|
|
lda #S.ARPCACHE.STATUS.RESOLVED
|
|
|
|
|
jmp ARP.ADD.I
|
|
|
|
|
*--------------------------------------
|
2016-03-16 16:37:02 +00:00
|
|
|
|
ARP.IN ldy #S.ARP.TPA+3
|
|
|
|
|
ldx #3
|
|
|
|
|
|
2017-01-31 16:40:37 +00:00
|
|
|
|
.1 lda (ZPFrameInPtr),y
|
2016-03-16 16:37:02 +00:00
|
|
|
|
cmp IPCFG+S.IPCFG.IP,x
|
2017-01-29 21:47:19 +00:00
|
|
|
|
bne ARP.IN.EXIT
|
2016-03-16 16:37:02 +00:00
|
|
|
|
dey
|
|
|
|
|
dex
|
|
|
|
|
bpl .1
|
|
|
|
|
|
|
|
|
|
ldy #S.ARP.OPERATION+1 HI byte
|
2017-01-31 16:40:37 +00:00
|
|
|
|
lda (ZPFrameInPtr),y
|
2016-03-16 16:37:02 +00:00
|
|
|
|
cmp #S.ARP.OPERATION.REQ
|
|
|
|
|
beq ARP.IN.REQ
|
|
|
|
|
|
|
|
|
|
cmp #S.ARP.OPERATION.REP
|
|
|
|
|
beq ARP.IN.REP
|
|
|
|
|
|
2017-01-29 21:47:19 +00:00
|
|
|
|
ARP.IN.EXIT lda hFrameIn
|
2018-07-18 15:30:42 +00:00
|
|
|
|
>SYSCALL FreeMem
|
2017-01-29 21:47:19 +00:00
|
|
|
|
clc
|
2016-03-16 16:37:02 +00:00
|
|
|
|
rts
|
2017-01-29 21:47:19 +00:00
|
|
|
|
|
2016-03-16 16:37:02 +00:00
|
|
|
|
ARP.IN.REQ ldy #S.ARP.SPA+3
|
|
|
|
|
ldx #3
|
|
|
|
|
|
2017-01-31 16:40:37 +00:00
|
|
|
|
.1 lda (ZPFrameInPtr),y
|
2016-03-16 16:37:02 +00:00
|
|
|
|
sta ARP.REP.TPA,x
|
|
|
|
|
dey
|
|
|
|
|
dex
|
|
|
|
|
bpl .1
|
|
|
|
|
|
|
|
|
|
ldy #S.ARP.SHA+5
|
|
|
|
|
ldx #5
|
|
|
|
|
|
2017-01-31 16:40:37 +00:00
|
|
|
|
.2 lda (ZPFrameInPtr),y
|
2016-03-16 16:37:02 +00:00
|
|
|
|
sta ARP.REP.DSTMAC,x
|
|
|
|
|
sta ARP.REP.THA,x
|
|
|
|
|
dey
|
|
|
|
|
dex
|
|
|
|
|
bpl .2
|
|
|
|
|
|
2017-01-26 21:57:35 +00:00
|
|
|
|
>LDYA L.ARP.REP
|
2018-05-24 15:21:38 +00:00
|
|
|
|
jsr FRM.Send.YA
|
2017-01-29 21:47:19 +00:00
|
|
|
|
bra ARP.IN.EXIT
|
2016-03-16 16:37:02 +00:00
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
2017-01-31 16:40:37 +00:00
|
|
|
|
.1 lda (ZPFrameInPtr),y
|
2016-03-16 16:37:02 +00:00
|
|
|
|
sta ARP.TmpCache+S.ARPCACHE.IP,x
|
|
|
|
|
dey
|
|
|
|
|
dex
|
|
|
|
|
bpl .1
|
|
|
|
|
|
|
|
|
|
ldy #S.ARP.SHA+5
|
|
|
|
|
ldx #5
|
|
|
|
|
|
2017-01-31 16:40:37 +00:00
|
|
|
|
.2 lda (ZPFrameInPtr),y
|
2016-03-16 16:37:02 +00:00
|
|
|
|
sta ARP.TmpCache+S.ARPCACHE.MAC,x
|
|
|
|
|
dey
|
|
|
|
|
dex
|
|
|
|
|
bpl .2
|
|
|
|
|
|
|
|
|
|
lda #S.ARPCACHE.STATUS.RESOLVED
|
|
|
|
|
|
|
|
|
|
jsr ARP.ADD.I
|
2017-01-29 21:47:19 +00:00
|
|
|
|
jmp ARP.IN.EXIT
|
2016-03-16 16:37:02 +00:00
|
|
|
|
*--------------------------------------
|
2016-03-16 07:19:54 +00:00
|
|
|
|
ARP.QUERY.I jsr ARP.FIND.BY.IP
|
2016-03-16 16:37:02 +00:00
|
|
|
|
bcs .3 send an ARP request
|
2016-03-16 07:19:54 +00:00
|
|
|
|
|
|
|
|
|
lda (ZPCachePtr) get status...
|
|
|
|
|
bpl .9 Pending...
|
|
|
|
|
|
2016-03-20 22:16:01 +00:00
|
|
|
|
ldy #S.ARPCACHE.MAC
|
2016-03-16 07:19:54 +00:00
|
|
|
|
|
|
|
|
|
.2 lda (ZPCachePtr),y
|
2016-03-20 22:16:01 +00:00
|
|
|
|
sta ARP.TmpCache,y
|
|
|
|
|
iny
|
|
|
|
|
cpy #S.ARPCACHE.MAC+6
|
|
|
|
|
bne .2
|
2016-03-16 07:19:54 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
2016-03-20 22:16:01 +00:00
|
|
|
|
.3 ldx #3
|
2016-03-16 16:37:02 +00:00
|
|
|
|
|
2016-03-20 22:16:01 +00:00
|
|
|
|
.4 lda ARP.TmpCache+S.ARPCACHE.IP,x
|
|
|
|
|
sta ARP.REQ.TPA,x
|
|
|
|
|
dex
|
2016-03-16 16:37:02 +00:00
|
|
|
|
bpl .4
|
2016-03-16 07:19:54 +00:00
|
|
|
|
|
2017-01-26 21:57:35 +00:00
|
|
|
|
>LDYA L.ARP.REQ
|
2018-05-24 15:21:38 +00:00
|
|
|
|
jsr FRM.Send.YA
|
2016-03-16 16:37:02 +00:00
|
|
|
|
bcs .99
|
|
|
|
|
|
2016-03-27 21:06:56 +00:00
|
|
|
|
lda #K.ARP.PENDING.TTL
|
2016-03-16 16:37:02 +00:00
|
|
|
|
sta ARP.TmpCache+S.ARPCACHE.TTL
|
|
|
|
|
stz ARP.TmpCache+S.ARPCACHE.TTL+1
|
2016-03-16 07:19:54 +00:00
|
|
|
|
|
|
|
|
|
lda #S.ARPCACHE.STATUS.PENDING
|
2016-03-16 16:37:02 +00:00
|
|
|
|
jsr ARP.ADD.I
|
2016-03-16 07:19:54 +00:00
|
|
|
|
|
2016-03-20 22:16:01 +00:00
|
|
|
|
.9 lda #ERR.ARP.PENDING
|
2016-03-16 07:19:54 +00:00
|
|
|
|
sec
|
2016-03-16 16:37:02 +00:00
|
|
|
|
.99 rts
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2016-03-16 16:37:02 +00:00
|
|
|
|
ARP.FIND.BY.IP >LDYA L.ARP.CACHE
|
|
|
|
|
>STYA ZPCachePtr
|
|
|
|
|
|
2016-03-17 15:50:11 +00:00
|
|
|
|
lda #K.ARPCACHE.SIZE
|
|
|
|
|
sta TmpOffset
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2016-03-16 16:37:02 +00:00
|
|
|
|
.1 lda (ZPCachePtr)
|
2016-03-17 15:50:11 +00:00
|
|
|
|
beq .3
|
2016-03-16 16:37:02 +00:00
|
|
|
|
|
2016-03-17 15:50:11 +00:00
|
|
|
|
ldx #3
|
2016-03-16 16:37:02 +00:00
|
|
|
|
ldy #S.ARPCACHE.IP+3
|
2016-03-17 15:50:11 +00:00
|
|
|
|
|
2016-03-20 22:16:01 +00:00
|
|
|
|
.2 lda ARP.TmpCache+S.ARPCACHE.IP,x
|
|
|
|
|
cmp (ZPCachePtr),y
|
2016-03-17 15:50:11 +00:00
|
|
|
|
bne .3
|
|
|
|
|
dey
|
|
|
|
|
dex
|
|
|
|
|
bpl .2
|
2016-03-16 16:37:02 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2016-03-17 15:50:11 +00:00
|
|
|
|
.3 lda ZPCachePtr
|
2016-03-16 16:37:02 +00:00
|
|
|
|
clc
|
|
|
|
|
adc #S.ARPCACHE
|
|
|
|
|
sta ZPCachePtr
|
|
|
|
|
bcc .8
|
|
|
|
|
inc ZPCachePtr+1
|
2016-03-16 07:19:54 +00:00
|
|
|
|
|
2016-03-17 15:50:11 +00:00
|
|
|
|
.8 dec TmpOffset
|
2016-03-16 16:37:02 +00:00
|
|
|
|
bne .1
|
|
|
|
|
sec
|
2015-03-14 21:48:35 +00:00
|
|
|
|
rts
|
2016-03-16 16:37:02 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
ARP.FIND.FREE >LDYA L.ARP.CACHE
|
|
|
|
|
>STYA ZPCachePtr
|
2016-03-16 07:19:54 +00:00
|
|
|
|
|
2016-03-16 16:37:02 +00:00
|
|
|
|
lda #$ff
|
|
|
|
|
sta TmpDWord
|
|
|
|
|
sta TmpDWord+1
|
|
|
|
|
|
|
|
|
|
ldx #K.ARPCACHE.SIZE
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2016-03-16 16:37:02 +00:00
|
|
|
|
.1 lda (ZPCachePtr)
|
|
|
|
|
beq .8
|
|
|
|
|
bpl .6
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2016-03-16 16:37:02 +00:00
|
|
|
|
ldy #S.ARPCACHE.TTL
|
|
|
|
|
lda (ZPCachePtr),y
|
|
|
|
|
sec
|
|
|
|
|
sbc TmpDWord
|
|
|
|
|
iny
|
|
|
|
|
lda (ZPCachePtr),y
|
|
|
|
|
sbc TmpDWord+1
|
|
|
|
|
bcc .6
|
2016-03-16 07:19:54 +00:00
|
|
|
|
|
2016-03-16 16:37:02 +00:00
|
|
|
|
lda (ZPCachePtr),y
|
|
|
|
|
sta TmpDWord+1
|
2016-03-16 07:19:54 +00:00
|
|
|
|
dey
|
2016-03-16 16:37:02 +00:00
|
|
|
|
lda (ZPCachePtr),y
|
|
|
|
|
sta TmpDWord
|
2016-03-16 07:19:54 +00:00
|
|
|
|
|
2016-03-16 16:37:02 +00:00
|
|
|
|
>LDYA ZPCachePtr
|
|
|
|
|
>STYA ZPTmpPtr1 save lowest TTL slot ...
|
2015-09-11 18:48:12 +00:00
|
|
|
|
|
2016-03-16 16:37:02 +00:00
|
|
|
|
.6 lda ZPCachePtr
|
2016-03-16 07:19:54 +00:00
|
|
|
|
clc
|
2016-03-16 16:37:02 +00:00
|
|
|
|
adc #S.ARPCACHE
|
|
|
|
|
sta ZPCachePtr
|
|
|
|
|
bcc .7
|
|
|
|
|
inc ZPCachePtr+1
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2016-03-16 16:37:02 +00:00
|
|
|
|
.7 dex
|
|
|
|
|
bne .1
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2016-03-16 16:37:02 +00:00
|
|
|
|
>LDYA ZPTmpPtr1
|
|
|
|
|
>STYA ZPCachePtr
|
|
|
|
|
lda #0
|
|
|
|
|
sta (ZPCachePtr)
|
|
|
|
|
|
|
|
|
|
.8 clc
|
2016-03-16 07:19:54 +00:00
|
|
|
|
rts
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2016-03-16 07:19:54 +00:00
|
|
|
|
ARP.EXPIRE >LDYA L.ARP.CACHE
|
|
|
|
|
>STYA ZPCachePtr
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2016-03-16 07:19:54 +00:00
|
|
|
|
ldx #K.ARPCACHE.SIZE
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2016-03-16 07:19:54 +00:00
|
|
|
|
.1 lda (ZPCachePtr)
|
2016-03-29 06:28:28 +00:00
|
|
|
|
beq .2
|
2016-03-16 07:19:54 +00:00
|
|
|
|
|
|
|
|
|
ldy #S.ARPCACHE.TTL
|
|
|
|
|
sec
|
|
|
|
|
lda (ZPCachePtr),y
|
|
|
|
|
sbc #1
|
|
|
|
|
sta (ZPCachePtr),y
|
2015-03-14 21:48:35 +00:00
|
|
|
|
iny
|
2016-03-16 07:19:54 +00:00
|
|
|
|
lda (ZPCachePtr),y
|
|
|
|
|
sbc #0
|
|
|
|
|
sta (ZPCachePtr),y
|
|
|
|
|
bcs .2
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2016-03-16 07:19:54 +00:00
|
|
|
|
lda #0
|
|
|
|
|
sta (ZPCachePtr)
|
|
|
|
|
|
|
|
|
|
.2 lda ZPCachePtr
|
2015-03-14 21:48:35 +00:00
|
|
|
|
clc
|
|
|
|
|
adc #S.ARPCACHE
|
2016-03-16 07:19:54 +00:00
|
|
|
|
sta ZPCachePtr
|
|
|
|
|
bcc .3
|
|
|
|
|
inc ZPCachePtr+1
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2016-03-16 07:19:54 +00:00
|
|
|
|
.3 dex
|
|
|
|
|
bne .1
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2015-03-14 21:48:35 +00:00
|
|
|
|
MAN
|
2017-03-30 06:31:12 +00:00
|
|
|
|
SAVE /A2OSX.SRC/LIB/LIBTCPIP.S.ARP
|
|
|
|
|
LOAD /A2OSX.SRC/LIB/LIBTCPIP.S
|
2015-03-14 21:48:35 +00:00
|
|
|
|
ASM
|