A2osX/BIN/DNSINFO.S.txt

179 lines
3.6 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

NEW
PREFIX
AUTO 4,1
.LIST OFF
.OP 65C02
.OR $2000
.TF BIN/DNSINFO
*--------------------------------------
.INB INC/MACROS.I
.INB INC/A2OSX.I
.INB INC/ETH.I
.INB INC/LIBTCPIP.I
*--------------------------------------
ZPPTR1 .EQ ZPBIN
ZPPTR2 .EQ ZPBIN+2
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
CS.START cld
jmp (.1,x)
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
.DA 0
.DA CS.END-CS.START Code Length To Relocate
.DA 0 No Data Segment to Allocate
.DA #16 SS
.DA #4 ZP
.DA 0
*--------------------------------------
* Relocation Table
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.EVENT
.DA CS.QUIT
L.LIBTCPIP .DA LIBTCPIP
L.SSCANF.IP .DA SSCANF.IP
L.MSG0 .DA MSG0
L.MSG1 .DA MSG1
L.MSG.USAGE .DA MSG.USAGE
.DA 0
*--------------------------------------
CS.INIT >LDYA L.LIBTCPIP
>SYSCALL LoadLib
bcs .9
sta hLIBTCPIP
.9 rts
*--------------------------------------
CS.RUN ldy #S.PS.ARGC
lda (pPs),y
cmp #1
bne .1
jmp CS.RUN.DUMP
.1 cmp #3
beq CS.RUN.ADD
>PUSHBI 0
>LDYA L.MSG.USAGE
>SYSCALL printf
lda #E.SYN
sec
rts
*--------------------------------------
CS.RUN.ADD >PUSHEA.G DST.IP+3
>PUSHEA.G DST.IP+2
>PUSHEA.G DST.IP+1
>PUSHEA.G DST.IP
>PUSHBI 8 4 PTRs
>PUSHW L.SSCANF.IP
lda #2
>SYSCALL ArgV
>SYSCALL sscanf
bcs .9
>PUSHEA.G DST.IP
lda #1
>SYSCALL ArgV
>PUSHYA
>LIBCALL hLIBTCPIP,LIBTCPIP.DNS.ADD
bcs .99
lda #0 tell TSKMGR that all done ok, but
sec we do not want to stay in memory
rts
.9 lda #E.SYN
sec
.99 rts
*--------------------------------------
CS.RUN.DUMP >LIBCALL hLIBTCPIP,LIBTCPIP.DNS.GetCache
>STYA ZPPTR1
>LDYA L.MSG0
>SYSCALL puts
lda #K.DNSCACHE.SIZE
>STA.G EntryCount
.1 lda (ZPPTR1)
beq .2
ldy #S.DNSCACHE.TTL+4
.6 dey
lda (ZPPTR1),y
>PUSHA
cpy #S.DNSCACHE.TTL
bne .6
ldy #S.DNSCACHE.IP+4
.5 dey
lda (ZPPTR1),y
>PUSHA
cpy #S.DNSCACHE.IP
bne .5
ldy #S.DNSCACHE.hNAME
lda (ZPPTR1),y
>SYSCALL GetMemPtr
>PUSHYA
ldy #S.DNSCACHE.ID
>PUSHB (ZPPTR1),y
iny
>PUSHB (ZPPTR1),y
>PUSHB (ZPPTR1) Entry Status
>PUSHBI 13
>LDYA L.MSG1
>SYSCALL printf
.2 lda ZPPTR1
clc
adc #S.DNSCACHE
sta ZPPTR1
bcc .3
inc ZPPTR1+1
.3 >DEC.G EntryCount
bne .1
.8 lda #0 tell TSKMGR that all done ok, but
sec we do not want to stay in memory
rts
*--------------------------------------
CS.EVENT sec
rts
*--------------------------------------
CS.QUIT lda hLIBTCPIP
beq .8
>SYSCALL UnloadLib
.8 clc
rts
*--------------------------------------
CS.END
LIBTCPIP .AZ "libtcpip"
hLIBTCPIP .BS 1
SSCANF.IP .AZ "%d.%d.%d.%d"
MSG0 .AZ "STS TR.ID Hostname IP Address TTL"
MSG1 .AZ "$%h $%H %32s %03d.%03d.%03d.%03d %u\r\n"
MSG.USAGE .AS "Usage : Add a static entry, DNSINFO <host> <IP>\r\n"
.AZ " Dump DNS Cache, DNSINFO\r\n"
*--------------------------------------
DS.START
DST.IP .BS 4
EntryCount .BS 1
DS.END
*--------------------------------------
MAN
SAVE USR/SRC/BIN/BIN/DNSINFO.S
ASM