2015-03-14 21:47:37 +00:00
|
|
|
|
NEW
|
2019-09-19 15:22:14 +00:00
|
|
|
|
AUTO 3,1
|
2015-03-14 21:47:37 +00:00
|
|
|
|
.LIST OFF
|
|
|
|
|
.OP 65C02
|
|
|
|
|
.OR $2000
|
2020-08-12 19:31:36 +00:00
|
|
|
|
.TF bin/arp
|
2015-03-14 21:47:37 +00:00
|
|
|
|
*--------------------------------------
|
2020-08-12 19:31:36 +00:00
|
|
|
|
.INB inc/macros.i
|
|
|
|
|
.INB inc/a2osx.i
|
|
|
|
|
.INB inc/eth.i
|
|
|
|
|
.INB inc/libtcpip.i
|
2015-03-14 21:47:37 +00:00
|
|
|
|
*--------------------------------------
|
2016-03-16 07:19:54 +00:00
|
|
|
|
TIMEOUT.MAX .EQ 40 40*100ms = 4 sec.
|
2015-03-14 21:47:37 +00:00
|
|
|
|
*--------------------------------------
|
2019-10-06 12:50:43 +00:00
|
|
|
|
.DUMMY
|
|
|
|
|
.OR ZPBIN
|
|
|
|
|
ZS.START
|
|
|
|
|
ZPPTR1 .BS 2
|
|
|
|
|
EntryCount .BS 1
|
2020-08-12 19:31:36 +00:00
|
|
|
|
ZS.END .ED
|
2015-03-14 21:47:37 +00:00
|
|
|
|
*--------------------------------------
|
2015-06-03 18:30:57 +00:00
|
|
|
|
* File Header (16 Bytes)
|
2015-03-14 21:47:37 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.START cld
|
|
|
|
|
jmp (.1,x)
|
2015-06-03 18:30:57 +00:00
|
|
|
|
.DA #$61 6502,Level 1 (65c02)
|
|
|
|
|
.DA #1 BIN Layout Version 1
|
2018-11-06 19:26:45 +00:00
|
|
|
|
.DA #S.PS.F.EVENT
|
|
|
|
|
.DA #0
|
2019-10-06 12:50:43 +00:00
|
|
|
|
.DA CS.END-CS.START Code Size (without Constants)
|
|
|
|
|
.DA DS.END-DS.START Data Segment Size
|
|
|
|
|
.DA #32 Stack Size
|
|
|
|
|
.DA #ZS.END-ZS.START Zero Page Size
|
2015-06-03 18:30:57 +00:00
|
|
|
|
.DA 0
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Relocation Table
|
|
|
|
|
*--------------------------------------
|
2015-03-14 21:47:37 +00:00
|
|
|
|
.1 .DA CS.INIT
|
|
|
|
|
.DA CS.RUN
|
2015-06-03 18:30:57 +00:00
|
|
|
|
.DA CS.DOEVENT
|
2015-03-14 21:47:37 +00:00
|
|
|
|
.DA CS.QUIT
|
|
|
|
|
L.LIBTCPIP .DA LIBTCPIP
|
|
|
|
|
L.SSCANF.IP .DA SSCANF.IP
|
2018-05-25 15:09:14 +00:00
|
|
|
|
L.SSCANF.MAC .DA SSCANF.MAC
|
2018-11-09 13:29:23 +00:00
|
|
|
|
L.MSG.Usage .DA MSG.Usage
|
2015-03-14 21:47:37 +00:00
|
|
|
|
L.MSG0 .DA MSG0
|
|
|
|
|
L.MSG1 .DA MSG1
|
|
|
|
|
L.MSG2 .DA MSG2
|
|
|
|
|
.DA 0
|
|
|
|
|
*--------------------------------------
|
2016-10-18 06:26:24 +00:00
|
|
|
|
CS.INIT >LDYA L.LIBTCPIP
|
2018-07-19 15:33:55 +00:00
|
|
|
|
>SYSCALL LoadLib
|
2018-01-16 07:32:11 +00:00
|
|
|
|
bcs .9
|
2015-03-14 21:47:37 +00:00
|
|
|
|
sta hLIBTCPIP
|
2018-01-16 07:32:11 +00:00
|
|
|
|
.9 rts
|
2017-01-29 21:47:19 +00:00
|
|
|
|
*--------------------------------------
|
2019-01-16 21:51:57 +00:00
|
|
|
|
CS.RUN >LIBCALL hLIBTCPIP,LIBTCPIP.GETCFG
|
2018-11-09 13:29:23 +00:00
|
|
|
|
>STYA ZPPTR1
|
|
|
|
|
|
2019-02-03 21:58:26 +00:00
|
|
|
|
lda (ZPPTR1)
|
2018-11-09 13:29:23 +00:00
|
|
|
|
bmi .1
|
|
|
|
|
|
|
|
|
|
jmp CS.RUN.ERR
|
2020-05-05 20:54:25 +00:00
|
|
|
|
|
2018-11-09 13:29:23 +00:00
|
|
|
|
.1 ldy #S.PS.ARGC
|
2020-02-28 07:21:46 +00:00
|
|
|
|
lda (pPS),y
|
2018-11-23 16:20:19 +00:00
|
|
|
|
cmp #1
|
2018-11-09 13:29:23 +00:00
|
|
|
|
bcs .2
|
2022-11-02 06:54:30 +00:00
|
|
|
|
|
2017-01-29 21:47:19 +00:00
|
|
|
|
jmp CS.RUN.DUMP
|
2015-03-14 21:47:37 +00:00
|
|
|
|
|
2020-02-14 16:32:52 +00:00
|
|
|
|
.2 lda #1
|
|
|
|
|
>SYSCALL ArgV
|
|
|
|
|
>PUSHYA
|
|
|
|
|
>PUSHW L.SSCANF.IP
|
2018-05-23 15:27:37 +00:00
|
|
|
|
>PUSHEA.G DST.IP
|
2020-02-14 16:32:52 +00:00
|
|
|
|
>PUSHEA.G DST.IP+1
|
|
|
|
|
>PUSHEA.G DST.IP+2
|
|
|
|
|
>PUSHEA.G DST.IP+3
|
2018-11-09 13:29:23 +00:00
|
|
|
|
>PUSHBI 8 4 Ptrs
|
2020-08-12 19:31:36 +00:00
|
|
|
|
>SYSCALL SScanF
|
2018-11-09 13:29:23 +00:00
|
|
|
|
bcs CS.RUN.ERR
|
2020-02-14 16:32:52 +00:00
|
|
|
|
|
2018-05-25 15:09:14 +00:00
|
|
|
|
ldy #S.PS.ARGC
|
2020-02-28 07:21:46 +00:00
|
|
|
|
lda (pPS),y
|
2018-11-23 16:20:19 +00:00
|
|
|
|
cmp #1
|
2018-05-25 15:09:14 +00:00
|
|
|
|
beq CS.RUN.QUERY
|
2018-11-09 13:29:23 +00:00
|
|
|
|
cmp #3
|
|
|
|
|
bne CS.RUN.ERR
|
|
|
|
|
jmp CS.RUN.ADD
|
2020-01-29 21:20:43 +00:00
|
|
|
|
|
2022-11-02 06:54:30 +00:00
|
|
|
|
CS.RUN.ERR >LDYA L.MSG.Usage
|
|
|
|
|
>SYSCALL PutS
|
2018-11-09 13:29:23 +00:00
|
|
|
|
lda #E.SYN
|
2017-01-29 21:47:19 +00:00
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN.QUERY jsr Init.Timeout
|
2017-02-13 07:26:18 +00:00
|
|
|
|
|
2018-05-23 15:27:37 +00:00
|
|
|
|
.1 >PUSHEA.G DST.MAC
|
|
|
|
|
>PUSHEA.G DST.IP
|
2020-08-12 19:31:36 +00:00
|
|
|
|
>LIBCALL hLIBTCPIP,LIBTCPIP.ARP.Query
|
2017-01-29 21:47:19 +00:00
|
|
|
|
bcc .2 success, print & exit
|
2022-11-02 06:54:30 +00:00
|
|
|
|
|
2017-01-29 21:47:19 +00:00
|
|
|
|
jsr Wait.TimeOut
|
2018-11-09 13:29:23 +00:00
|
|
|
|
bcs .8
|
2022-11-02 06:54:30 +00:00
|
|
|
|
|
2017-11-17 16:16:05 +00:00
|
|
|
|
>SLEEP
|
|
|
|
|
>SYSCALL GetChar
|
2017-01-29 21:47:19 +00:00
|
|
|
|
bcs .1
|
2022-11-02 06:54:30 +00:00
|
|
|
|
|
2017-01-29 21:47:19 +00:00
|
|
|
|
cmp #3
|
2018-11-09 13:29:23 +00:00
|
|
|
|
beq .9
|
2022-11-02 06:54:30 +00:00
|
|
|
|
|
2017-01-29 21:47:19 +00:00
|
|
|
|
bra .1
|
2020-01-29 21:20:43 +00:00
|
|
|
|
|
|
|
|
|
.2 >PUSHW L.MSG2
|
|
|
|
|
|
|
|
|
|
ldx #4
|
|
|
|
|
ldy #DST.IP
|
|
|
|
|
|
2019-01-16 21:51:57 +00:00
|
|
|
|
.4 >PUSHB (pData),y
|
2020-01-29 21:20:43 +00:00
|
|
|
|
iny
|
2019-01-16 21:51:57 +00:00
|
|
|
|
dex
|
2020-01-29 21:20:43 +00:00
|
|
|
|
bne .4
|
|
|
|
|
|
|
|
|
|
ldx #6
|
|
|
|
|
ldy #DST.MAC
|
|
|
|
|
|
|
|
|
|
.3 >PUSHB (pData),y
|
|
|
|
|
iny
|
|
|
|
|
dex
|
|
|
|
|
bne .3
|
|
|
|
|
|
2018-08-22 15:23:27 +00:00
|
|
|
|
>PUSHBI 10
|
2020-02-28 07:21:46 +00:00
|
|
|
|
>SYSCALL PrintF
|
2022-11-02 06:54:30 +00:00
|
|
|
|
|
2017-01-29 21:47:19 +00:00
|
|
|
|
.8 lda #0
|
2022-11-02 06:54:30 +00:00
|
|
|
|
|
2017-01-29 21:47:19 +00:00
|
|
|
|
.9 sec
|
2015-03-14 21:47:37 +00:00
|
|
|
|
rts
|
2018-05-25 15:09:14 +00:00
|
|
|
|
*--------------------------------------
|
2020-02-14 16:32:52 +00:00
|
|
|
|
CS.RUN.ADD lda #2
|
|
|
|
|
>SYSCALL ArgV
|
|
|
|
|
>PUSHYA
|
|
|
|
|
>PUSHW L.SSCANF.MAC
|
2018-05-28 06:00:45 +00:00
|
|
|
|
>PUSHEA.G DST.MAC
|
2020-02-14 16:32:52 +00:00
|
|
|
|
>PUSHEA.G DST.MAC+1
|
|
|
|
|
>PUSHEA.G DST.MAC+2
|
|
|
|
|
>PUSHEA.G DST.MAC+3
|
|
|
|
|
>PUSHEA.G DST.MAC+4
|
|
|
|
|
>PUSHEA.G DST.MAC+5
|
2018-11-09 13:29:23 +00:00
|
|
|
|
>PUSHBI 12 6 Ptrs
|
2020-08-12 19:31:36 +00:00
|
|
|
|
>SYSCALL SScanF
|
2018-05-28 06:00:45 +00:00
|
|
|
|
bcs .9
|
2018-05-25 15:09:14 +00:00
|
|
|
|
|
2018-05-28 06:00:45 +00:00
|
|
|
|
>PUSHEA.G DST.MAC
|
|
|
|
|
>PUSHEA.G DST.IP
|
2020-08-12 19:31:36 +00:00
|
|
|
|
>LIBCALL hLIBTCPIP,LIBTCPIP.ARP.Add
|
2022-11-02 06:54:30 +00:00
|
|
|
|
|
2018-11-09 13:29:23 +00:00
|
|
|
|
clc
|
2022-11-02 06:54:30 +00:00
|
|
|
|
rts
|
|
|
|
|
|
2018-11-09 13:29:23 +00:00
|
|
|
|
.9 jmp CS.RUN.ERR
|
2016-03-16 07:19:54 +00:00
|
|
|
|
*--------------------------------------
|
2020-08-12 19:31:36 +00:00
|
|
|
|
CS.RUN.DUMP >LIBCALL hLIBTCPIP,LIBTCPIP.ARP.GetCache
|
2015-03-14 21:47:37 +00:00
|
|
|
|
>STYA ZPPTR1
|
2016-10-18 06:26:24 +00:00
|
|
|
|
>LDYA L.MSG0
|
2020-02-28 07:21:46 +00:00
|
|
|
|
>SYSCALL PutS
|
2015-03-14 21:47:37 +00:00
|
|
|
|
|
2019-10-06 12:50:43 +00:00
|
|
|
|
lda #K.ARPCACHE.SIZE
|
|
|
|
|
sta EntryCount
|
|
|
|
|
|
2015-03-14 21:47:37 +00:00
|
|
|
|
.1 lda (ZPPTR1)
|
2017-03-10 16:35:54 +00:00
|
|
|
|
beq .4
|
2019-10-06 12:50:43 +00:00
|
|
|
|
|
2020-01-29 21:20:43 +00:00
|
|
|
|
>PUSHW L.MSG1
|
|
|
|
|
|
|
|
|
|
>PUSHB (ZPPTR1)
|
|
|
|
|
|
|
|
|
|
ldy #S.ARPCACHE.TTL+1
|
|
|
|
|
>PUSHB (ZPPTR1),y
|
|
|
|
|
dey
|
2016-03-16 07:19:54 +00:00
|
|
|
|
>PUSHB (ZPPTR1),y
|
2019-10-06 12:50:43 +00:00
|
|
|
|
|
2020-01-29 21:20:43 +00:00
|
|
|
|
ldy #S.ARPCACHE.MAC
|
2019-10-06 12:50:43 +00:00
|
|
|
|
|
2020-01-29 21:20:43 +00:00
|
|
|
|
.3 >PUSHB (ZPPTR1),y
|
|
|
|
|
iny
|
|
|
|
|
cpy #S.ARPCACHE.MAC+6
|
2015-03-14 21:47:37 +00:00
|
|
|
|
bne .3
|
2019-10-06 12:50:43 +00:00
|
|
|
|
|
2020-01-29 21:20:43 +00:00
|
|
|
|
ldy #S.ARPCACHE.IP
|
|
|
|
|
|
|
|
|
|
.2 >PUSHB (ZPPTR1),y
|
|
|
|
|
iny
|
|
|
|
|
cpy #S.ARPCACHE.IP+4
|
|
|
|
|
bne .2
|
|
|
|
|
|
2018-08-22 15:23:27 +00:00
|
|
|
|
>PUSHBI 13
|
2020-02-28 07:21:46 +00:00
|
|
|
|
>SYSCALL PrintF
|
2019-10-06 12:50:43 +00:00
|
|
|
|
|
2016-03-29 06:29:48 +00:00
|
|
|
|
.4 lda ZPPTR1
|
2015-03-14 21:47:37 +00:00
|
|
|
|
clc
|
|
|
|
|
adc #S.ARPCACHE
|
|
|
|
|
sta ZPPTR1
|
2016-03-29 06:29:48 +00:00
|
|
|
|
bcc .5
|
2019-10-06 12:50:43 +00:00
|
|
|
|
|
2015-03-14 21:47:37 +00:00
|
|
|
|
inc ZPPTR1+1
|
2019-10-06 12:50:43 +00:00
|
|
|
|
|
|
|
|
|
.5 dec EntryCount
|
2016-03-16 07:19:54 +00:00
|
|
|
|
bne .1
|
2019-10-06 12:50:43 +00:00
|
|
|
|
|
2015-03-14 21:47:37 +00:00
|
|
|
|
.8 lda #0 tell TSKMGR that all done ok, but
|
|
|
|
|
sec we do not want to stay in memory
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2015-06-03 18:30:57 +00:00
|
|
|
|
CS.DOEVENT lda (pEvent)
|
2017-01-29 21:47:19 +00:00
|
|
|
|
bpl .9 is it a TIMER event?
|
2015-03-14 21:47:37 +00:00
|
|
|
|
|
2016-03-16 07:19:54 +00:00
|
|
|
|
ldy #TimeOut
|
|
|
|
|
lda (pData),y
|
2015-03-14 21:47:37 +00:00
|
|
|
|
beq .9
|
2022-11-02 06:54:30 +00:00
|
|
|
|
|
2016-03-16 07:19:54 +00:00
|
|
|
|
dec
|
|
|
|
|
sta (pData),y
|
2022-11-02 06:54:30 +00:00
|
|
|
|
|
2016-03-16 07:19:54 +00:00
|
|
|
|
.9 sec do not discard TIMER event
|
|
|
|
|
rts
|
2015-03-14 21:47:37 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.QUIT lda hLIBTCPIP
|
2018-11-12 09:22:06 +00:00
|
|
|
|
beq .8
|
2019-10-06 12:50:43 +00:00
|
|
|
|
|
2018-07-20 14:10:10 +00:00
|
|
|
|
>SYSCALL UnloadLib
|
2022-11-02 06:54:30 +00:00
|
|
|
|
|
2018-11-12 09:22:06 +00:00
|
|
|
|
.8 clc
|
2015-03-14 21:47:37 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2016-03-16 07:19:54 +00:00
|
|
|
|
Init.Timeout ldy #TimeOut
|
|
|
|
|
lda #TIMEOUT.MAX
|
|
|
|
|
sta (pData),y
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
Wait.TimeOut sec
|
|
|
|
|
ldy #TimeOut
|
|
|
|
|
lda (pData),y
|
|
|
|
|
beq .9
|
2022-11-02 06:54:30 +00:00
|
|
|
|
|
2016-03-16 07:19:54 +00:00
|
|
|
|
clc
|
2022-11-02 06:54:30 +00:00
|
|
|
|
|
2016-03-16 07:19:54 +00:00
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
2015-03-14 21:47:37 +00:00
|
|
|
|
CS.END
|
2019-12-10 16:06:51 +00:00
|
|
|
|
LIBTCPIP .AZ "libtcpip"
|
2022-11-02 06:54:30 +00:00
|
|
|
|
hLIBTCPIP .BS 1
|
2018-04-11 15:35:51 +00:00
|
|
|
|
SSCANF.IP .AZ "%d.%d.%d.%d"
|
2018-05-25 15:09:14 +00:00
|
|
|
|
SSCANF.MAC .AZ "%h:%h:%h:%h:%h:%h"
|
2022-11-02 06:54:30 +00:00
|
|
|
|
MSG.Usage .CS "Usage : ARP display ARP cache\r\n"
|
|
|
|
|
.CS " ARP ip.ip.ip.ip query cache or network\r\n"
|
|
|
|
|
.CZ " ARP ip.ip.ip.ip HH:HH:HH:HH:HH:HH add a static ARP record in cache\r\n"
|
|
|
|
|
MSG0 .CZ "STS TTL MAC Address IP Address"
|
|
|
|
|
MSG1 .CZ "$%h %5D %h:%h:%h:%h:%h:%h %d.%d.%d.%d\r\n"
|
|
|
|
|
MSG2 .CZ "%d.%d.%d.%d is at %h:%h:%h:%h:%h:%h\r\n"
|
2015-03-14 21:47:37 +00:00
|
|
|
|
*--------------------------------------
|
2020-08-12 19:31:36 +00:00
|
|
|
|
.DUMMY
|
|
|
|
|
.OR 0
|
2015-03-14 21:47:37 +00:00
|
|
|
|
DS.START
|
|
|
|
|
DST.IP .BS 4
|
|
|
|
|
DST.MAC .BS 6
|
|
|
|
|
TimeOut .BS 1
|
2020-08-12 19:31:36 +00:00
|
|
|
|
DS.END .ED
|
2015-03-14 21:47:37 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
2020-08-12 19:31:36 +00:00
|
|
|
|
SAVE usr/src/bin/arp.s
|
2015-03-14 21:47:37 +00:00
|
|
|
|
ASM
|