A2osX/LIB/LIBTCPIP.S.ARP.txt

385 lines
6.6 KiB
Plaintext
Raw Normal View History

2017-12-22 21:24:30 +00:00
NEW
2019-05-05 17:15:37 +00:00
AUTO 3,1
2015-03-14 21:48:35 +00:00
.LIST OFF
*/--------------------------------------
* # ARP.Clear
* Clear ARP Cache
2018-06-18 08:44:02 +00:00
* **In:**
2018-10-11 15:23:06 +00:00
* ## RETURN VALUE
*\--------------------------------------
2019-06-20 06:39:28 +00:00
ARP.Clear lda hARPCache
bne .1
2019-10-06 12:50:43 +00:00
2019-06-20 06:39:28 +00:00
>LDYAI K.ARPCACHE.SIZE*S.ARPCACHE
>SYSCALL2 GetMem0
bcs .9
2019-10-06 12:50:43 +00:00
2019-06-20 06:39:28 +00:00
stx hARPCache
rts
2019-06-20 06:39:28 +00:00
.1 jsr ARP.GetCache
lda #0
tay
.2 sta (ZPCachePtr),y
iny
cpy #K.ARPCACHE.SIZE*S.ARPCACHE
bne .1
clc
.9 rts
*/--------------------------------------
* # ARP.Query
* Query ARP Cache and returns HW address
2018-06-14 15:31:36 +00:00
* **In:**
* PUSHW PTR to MAC (to fill)
* PUSHW PTR to IP
2018-10-11 15:23:06 +00:00
* ## RETURN VALUE
* CC: hit: MAC filled
* CS: missed
*\--------------------------------------
2019-10-06 12:50:43 +00:00
ARP.Query jsr ARP.GetIP
>PULLW ZPPtrMAC MAC
2019-10-06 12:50:43 +00:00
jsr ARP.QUERY.I
bcs .9
2019-10-06 12:50:43 +00:00
ldy #5
2019-10-06 12:50:43 +00:00
.2 lda ARP.TmpCache+S.ARPCACHE.MAC,y
sta (ZPPtrMAC),y
dey
bpl .2
2019-10-06 12:50:43 +00:00
* clc
2019-10-03 06:25:27 +00:00
.9 rts
*/--------------------------------------
* # ARP.Add
* Add a static ARP cache record
2018-06-14 15:31:36 +00:00
* **In:**
* PUSHW PTR to MAC
* PUSHW PTR to IP
*\--------------------------------------
2019-10-06 12:50:43 +00:00
ARP.Add jsr ARP.GetIP
2018-09-21 15:28:46 +00:00
2019-10-06 12:50:43 +00:00
>PULLW ZPPtrMAC MAC
ldy #5
2018-09-21 15:28:46 +00:00
.2 lda (ZPPtrMAC),y
sta ARP.TmpCache+S.ARPCACHE.MAC,y
dey
bpl .2
2019-10-06 12:50:43 +00:00
stz ARP.TmpCache+S.ARPCACHE.TTL
stz ARP.TmpCache+S.ARPCACHE.TTL+1
2018-11-09 13:29:23 +00:00
lda #S.ARPCACHE.S.RESOLVED+S.ARPCACHE.S.STATIC
2019-10-06 12:50:43 +00:00
ARP.ADD.I sta ARP.TmpCache
jsr ARP.FIND.BY.IP
bcc .1
2019-10-06 12:50:43 +00:00
jsr ARP.FIND.FREE
2019-10-06 12:50:43 +00:00
.1 ldy #S.ARPCACHE-1
2018-09-21 15:28:46 +00:00
.2 lda ARP.TmpCache,y
sta (ZPCachePtr),y
dey
bpl .2
2019-10-06 12:50:43 +00:00
clc
rts
*/--------------------------------------
2018-09-21 15:28:46 +00:00
* # ARP.GetCache
* Return a Ptr to ARP Cache Table
2018-06-14 15:31:36 +00:00
* **In:**
2018-10-11 15:23:06 +00:00
* ## RETURN VALUE
* Y,A = PTR to ARP.CACHE
*\--------------------------------------
2019-06-20 06:39:28 +00:00
ARP.GetCache lda hARPCache
>SYSCALL2 GetMemPtr
bcs .9
>STYA ZPCachePtr
.9 rts
*--------------------------------------
* PRIVATE
*--------------------------------------
2016-03-16 16:37:02 +00:00
ARP.IN ldy #S.ARP.TPA+3
ldx #3
2018-08-08 15:13: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
2019-10-06 12:50:43 +00:00
2016-03-16 16:37:02 +00:00
ldy #S.ARP.OPERATION+1 HI byte
lda (ZPFrameInPtr),y
2016-03-16 16:37:02 +00:00
cmp #S.ARP.OPERATION.REQ
beq ARP.IN.REQ
2019-10-06 12:50:43 +00:00
2016-03-16 16:37:02 +00:00
cmp #S.ARP.OPERATION.REP
beq ARP.IN.REP
2019-10-06 12:50:43 +00:00
2017-01-29 21:47:19 +00:00
ARP.IN.EXIT lda hFrameIn
2018-08-08 15:13:37 +00:00
beq .8
2019-10-06 12:50:43 +00:00
2018-08-08 15:13:37 +00:00
stz hFrameIn
2019-05-05 17:15:37 +00:00
>SYSCALL2 FreeMem
2018-08-08 15:13:37 +00:00
.8 clc
2016-03-16 16:37:02 +00:00
rts
2019-10-06 12:50:43 +00:00
2016-03-16 16:37:02 +00:00
ARP.IN.REQ ldy #S.ARP.SPA+3
ldx #3
2019-10-06 12:50:43 +00:00
.1 lda (ZPFrameInPtr),y
2016-03-16 16:37:02 +00:00
sta ARP.REP.TPA,x
dey
dex
bpl .1
2019-10-06 12:50:43 +00:00
2016-03-16 16:37:02 +00:00
ldy #S.ARP.SHA+5
ldx #5
2019-10-06 12:50:43 +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
2019-10-06 12:50:43 +00:00
2019-01-16 21:51:57 +00:00
>LDYA L.ARP.REP
jsr ARP.Send
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
2019-10-06 12:50:43 +00:00
2016-03-16 16:37:02 +00:00
ldy #S.ARP.SPA+3
2019-10-06 12:50:43 +00:00
jsr ARP.GetIPFromFrameInPtrY
2016-03-16 16:37:02 +00:00
ldy #S.ARP.SHA+5
2019-10-06 12:50:43 +00:00
jsr ARP.GetMacFromFrameInPtrY
2018-11-09 13:29:23 +00:00
lda #S.ARPCACHE.S.RESOLVED
2016-03-16 16:37:02 +00:00
jsr ARP.ADD.I
2019-10-06 12:50:43 +00:00
bra 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...
2019-10-06 12:50:43 +00:00
ldy #S.ARPCACHE.MAC
2019-10-06 12:50:43 +00:00
2016-03-16 07:19:54 +00:00
.2 lda (ZPCachePtr),y
sta ARP.TmpCache,y
iny
cpy #S.ARPCACHE.MAC+6
bne .2
2019-10-06 12:50:43 +00:00
2018-09-04 15:29:15 +00:00
ldy #S.ARPCACHE.TTL
lda #K.ARP.TTL
sta (ZPCachePtr),y
iny
lda /K.ARP.TTL
sta (ZPCachePtr),y
2019-10-06 12:50:43 +00:00
2016-03-16 07:19:54 +00:00
clc
rts
.3 ldx #3
2016-03-16 16:37:02 +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
2019-10-06 12:50:43 +00:00
2019-01-16 21:51:57 +00:00
>LDYA L.ARP.REQ
jsr ARP.Send
2016-03-16 16:37:02 +00:00
bcs .99
2019-10-06 12:50:43 +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
2018-11-09 13:29:23 +00:00
lda #S.ARPCACHE.S.PENDING
2016-03-16 16:37:02 +00:00
jsr ARP.ADD.I
2019-10-06 12:50:43 +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
*--------------------------------------
2019-06-20 06:39:28 +00:00
ARP.FIND.BY.IP jsr ARP.GetCache
2016-03-16 16:37:02 +00:00
2019-05-13 15:40:37 +00:00
ldx #K.ARPCACHE.SIZE
2016-03-16 16:37:02 +00:00
.1 lda (ZPCachePtr)
beq .3
2016-03-16 16:37:02 +00:00
2019-05-13 15:40:37 +00:00
ldy #S.ARPCACHE.IP
2019-10-06 12:50:43 +00:00
2019-05-13 15:40:37 +00:00
.2 lda ARP.TmpCache,y
cmp (ZPCachePtr),y
bne .3
2019-10-06 12:50:43 +00:00
2019-05-13 15:40:37 +00:00
iny
cpy #S.ARPCACHE.IP+4
bne .2
2019-10-06 12:50:43 +00:00
2016-03-16 16:37:02 +00:00
clc
rts
2019-10-06 12:50:43 +00:00
.3 jsr ARP.NextCache
dex
2016-03-16 16:37:02 +00:00
bne .1
2019-05-13 15:40:37 +00:00
2016-03-16 16:37:02 +00:00
sec
2015-03-14 21:48:35 +00:00
rts
2016-03-16 16:37:02 +00:00
*--------------------------------------
2019-06-20 06:39:28 +00:00
ARP.FIND.FREE jsr ARP.GetCache
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
2019-10-06 12:50:43 +00:00
2016-03-16 16:37:02 +00:00
.1 lda (ZPCachePtr)
beq .8
bpl .6
2019-10-06 12:50:43 +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
2019-10-06 12:50:43 +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
>LDYA ZPCachePtr
>STYA ZPTmpPtr1 save lowest TTL slot ...
2015-09-11 18:48:12 +00:00
2019-10-06 12:50:43 +00:00
.6 jsr ARP.NextCache
dex
2016-03-16 16:37:02 +00:00
bne .1
2019-10-06 12:50:43 +00:00
2016-03-16 16:37:02 +00:00
>LDYA ZPTmpPtr1
>STYA ZPCachePtr
lda #0
sta (ZPCachePtr)
2019-10-06 12:50:43 +00:00
2016-03-16 16:37:02 +00:00
.8 clc
2016-03-16 07:19:54 +00:00
rts
2015-03-14 21:48:35 +00:00
*--------------------------------------
2019-06-20 06:39:28 +00:00
ARP.EXPIRE jsr ARP.GetCache
2019-10-06 12:50:43 +00:00
2016-03-16 07:19:54 +00:00
ldx #K.ARPCACHE.SIZE
2019-10-06 12:50:43 +00:00
2016-03-16 07:19:54 +00:00
.1 lda (ZPCachePtr)
2016-03-29 06:28:28 +00:00
beq .2
2019-10-06 12:50:43 +00:00
2018-11-09 13:29:23 +00:00
and #S.ARPCACHE.S.STATIC
bne .2
2019-10-06 12:50:43 +00:00
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
2019-10-06 12:50:43 +00:00
2016-03-16 07:19:54 +00:00
lda #0
sta (ZPCachePtr)
2019-10-06 12:50:43 +00:00
.2 jsr ARP.NextCache
dex
bne .1
rts
*--------------------------------------
ARP.NextCache lda ZPCachePtr
2015-03-14 21:48:35 +00:00
clc
adc #S.ARPCACHE
2016-03-16 07:19:54 +00:00
sta ZPCachePtr
2019-10-06 12:50:43 +00:00
bcc .8
2016-03-16 07:19:54 +00:00
inc ZPCachePtr+1
2019-10-06 12:50:43 +00:00
.8 rts
*--------------------------------------
ARP.GetIP >PULLW ZPPtrIP
ldy #3
.1 lda (ZPPtrIP),y
sta ARP.TmpCache+S.ARPCACHE.IP,y
dey
bpl .1
rts
*--------------------------------------
ARP.AddFromFrameInPtr
ldy #S.IP.SRC+3
jsr ARP.GetIPFromFrameInPtrY
ldy #S.ETH.SRCMAC+5
jsr ARP.GetMacFromFrameInPtrY
lda #K.ARP.TTL
sta ARP.TmpCache+S.ARPCACHE.TTL
lda /K.ARP.TTL
sta ARP.TmpCache+S.ARPCACHE.TTL+1
lda #S.ARPCACHE.S.RESOLVED
jmp ARP.ADD.I
*--------------------------------------
ARP.GetIPFromFrameInPtrY
ldx #3
.1 lda (ZPFrameInPtr),y
sta ARP.TmpCache+S.ARPCACHE.IP,x
dey
dex
bpl .1
rts
*--------------------------------------
ARP.GetMacFromFrameInPtrY
ldx #5
.1 lda (ZPFrameInPtr),y
sta ARP.TmpCache+S.ARPCACHE.MAC,x
dey
dex
bpl .1
2016-03-16 07:19:54 +00:00
rts
*--------------------------------------
2019-01-16 21:51:57 +00:00
ARP.Send >STYA IOCTL+S.IOCTL.BUFPTR
>LDYAI S.ARP
>STYA IOCTL+S.IOCTL.BYTECNT
jmp FRM.Send.IOCTL
*--------------------------------------
2015-03-14 21:48:35 +00:00
MAN
2018-11-17 17:17:13 +00:00
SAVE USR/SRC/LIB/LIBTCPIP.S.ARP
LOAD USR/SRC/LIB/LIBTCPIP.S
2015-03-14 21:48:35 +00:00
ASM