A2osX/BIN/DNSINFO.S.txt

210 lines
4.1 KiB
Plaintext
Raw Permalink 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
AUTO 3,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
*--------------------------------------
.DUMMY
.OR ZPBIN
ZS.START
ZPPTR1 .BS 2
EntryCount .BS 1
ZS.END .ED
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
CS.START cld
jmp (.1,x)
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
.DA #0 S.PS.F.EVENT
.DA #0
.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
.DA 0
*--------------------------------------
* Relocation Table
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.EVENT
.DA CS.QUIT
L.LIBTCPIP .DA LIBTCPIP
L.MSG.IPKO .DA MSG.IPKO
L.SSCANF.IP .DA SSCANF.IP
L.MSG0 .DA MSG0
L.MSG1 .DA MSG1
L.MSG1.Status .DA MSG1.S
.DA MSG1.P
.DA MSG1.D
L.MSG.USAGE .DA MSG.USAGE
.DA 0
*--------------------------------------
CS.INIT >LDYA L.LIBTCPIP
>SYSCALL LoadLib
bcs .9
sta hLIBTCPIP
.9 rts
*--------------------------------------
CS.RUN >LIBCALL hLIBTCPIP,LIBTCPIP.GETCFG is TCPIP loaded ?
>STYA ZPPTR1
lda (ZPPTR1) Configured ?
bmi CS.RUN.IPOK
>LDYA L.MSG.IPKO
>SYSCALL PutS
lda #E.SYN
sec
rts
CS.RUN.IPOK ldy #S.PS.ARGC
lda (pPS),y
bne .1
jmp CS.RUN.DUMP
.1 cmp #2
beq CS.RUN.ADD
>LDYA L.MSG.USAGE
>SYSCALL PutS
lda #E.SYN
sec
rts
*--------------------------------------
CS.RUN.ADD lda #2
>SYSCALL ArgV
>PUSHYA
>PUSHW L.SSCANF.IP
>PUSHEA.G DST.IP
>PUSHEA.G DST.IP+1
>PUSHEA.G DST.IP+2
>PUSHEA.G DST.IP+3
>PUSHBI 8 4 PTRs
>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 EntryCount
.1 lda (ZPPTR1)
beq .6
>PUSHW L.MSG1
ldx #0
lda (ZPPTR1) Entry Status
bmi .5
asl
tax
.5 >PUSHW L.MSG1.Status,x
ldy #S.DNSCACHE.ID
>PUSHB (ZPPTR1),y
iny
>PUSHB (ZPPTR1),y
ldy #S.DNSCACHE.hNAME
lda (ZPPTR1),y
>SYSCALL GetMemPtr
>PUSHYA
ldy #S.DNSCACHE.IP
.3 lda (ZPPTR1),y
>PUSHA
iny
cpy #S.DNSCACHE.IP+4
bne .3
ldy #S.DNSCACHE.TTL+4
.2 dey
lda (ZPPTR1),y
>PUSHA
cpy #S.DNSCACHE.TTL
bne .2
>PUSHBI 14
>SYSCALL PrintF
.6 lda ZPPTR1
clc
adc #S.DNSCACHE
sta ZPPTR1
bcc .7
inc ZPPTR1+1
.7 dec EntryCount
bne .1
lda #0
sec
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"
*--------------------------------------
MSG.IPKO .CZ "TCP/IP Not Loaded/Configured."
MSG0 .CZ "Status TR.ID Hostname IP Address TTL"
MSG1 .CZ "%7s $%H %32s %03d.%03d.%03d.%03d %u\r\n"
MSG1.S .CZ "Static"
MSG1.P .CZ "Pending"
MSG1.D .CZ "Dynamic"
MSG.USAGE .CS "Usage : Add a static entry, DNSINFO <host> <IP>\r\n"
.CZ " Dump DNS Cache, DNSINFO\r\n"
*--------------------------------------
.DUMMY
.OR 0
DS.START
DST.IP .BS 4
DS.END .ED
*--------------------------------------
MAN
SAVE usr/src/bin/dnsinfo.s
ASM