A2osX/BIN/NETSTAT.S.txt
2018-08-23 17:16:20 +02:00

163 lines
3.3 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 /A2OSX.BUILD
AUTO 4,1
.LIST OFF
.OP 65C02
.OR $2000
.TF BIN/NETSTAT
*--------------------------------------
.INB INC/MACROS.I
.INB INC/A2OSX.I
.INB INC/ETH.I
.INB INC/LIBTCPIP.I
*--------------------------------------
ZPPTR1 .EQ ZPBIN
*--------------------------------------
* 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 CS
.DA DS.END-DS.START DS
.DA #64 SS
.DA #2 ZP
.DA 0
*--------------------------------------
* Relocation Table
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
L.LIBTCPIP .DA LIBTCPIP
L.MSG0 .DA MSG0
L.MSG1 .DA MSG1
.DA MSG1.UDP
.DA MSG1.TCP
.DA MSG1.RAW
.DA MSG1.INV
L.MSG1.S .DA MSG1.S.0
.DA MSG1.S.1
.DA MSG1.S.2
.DA MSG1.S.3
.DA MSG1.S.4
.DA MSG1.S.5
.DA MSG1.S.6
.DA MSG1.S.7
.DA MSG1.S.8
.DA MSG1.S.9
.DA MSG1.S.10
.DA 0
*--------------------------------------
CS.INIT >LDYA L.LIBTCPIP
>SYSCALL LoadLib
bcs .9
sta hLIBTCPIP
clc
.9 rts
*--------------------------------------
CS.RUN >LDYA L.MSG0
>SYSCALL puts
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.GETTABLE
>STYA ZPPTR1
lda #K.SKTTABLE.SIZE
>STA.G SocketCount
.1 lda (ZPPTR1)
beq .7
ldy #S.SOCKET.TCP.STATUS
lda (ZPPTR1),y
cmp #S.SOCKET.TCP.STATUS.TIMEWT+1
bcs *
asl
tax
>PUSHB L.MSG1.S+1,x
>PUSHB L.MSG1.S,x
ldy #S.SOCKET.SO
>PUSHB (ZPPTR1),y
ldy #S.SOCKET.DST.PORT+1
.2 >PUSHB (ZPPTR1),y
dey
cpy #S.SOCKET.SRC.ADDR-1
bne .2
lda (ZPPTR1)
cmp #S.SOCKET.SOCK.RAW+1
bcc .3
lda #S.SOCKET.SOCK.RAW+1
.3 asl
tax
>PUSHB L.MSG1+1,x
>PUSHB L.MSG1,x
>PUSHBI 17
>LDYA L.MSG1
>SYSCALL printf
.7 lda ZPPTR1
clc
adc #S.SOCKET
sta ZPPTR1
lda ZPPTR1+1
adc /S.SOCKET
sta ZPPTR1+1
>DEC.G SocketCount
bne .1 A=0
* lda #0 tell TSKMGR that all done ok, but
sec we do not want to stay in memory
rts
*--------------------------------------
CS.DOEVENT sec
rts
*--------------------------------------
CS.QUIT lda hLIBTCPIP
beq .8
>SYSCALL UnloadLib
.8 clc
rts
*--------------------------------------
CS.END
LIBTCPIP .AZ "libtcpip.o"
MSG0 .AZ "Proto Local Remote Options Status"
MSG1 .AZ "%s %03d.%03d.%03d.%03d:%05D %03d.%03d.%03d.%03d:%05D %b %s\r\n"
MSG1.UDP .AZ "UDP"
MSG1.TCP .AZ "TCP"
MSG1.RAW .AZ "RAW"
MSG1.INV .AZ "???"
MSG1.S.0 .AZ "*"
MSG1.S.1 .AZ "LISTENING"
MSG1.S.2 .AZ "SYN-SENT"
MSG1.S.3 .AZ "SYN-RECEIVED"
MSG1.S.4 .AZ "ESTABLISHED"
MSG1.S.5 .AZ "CLOSE-WAIT"
MSG1.S.6 .AZ "LAST-ACK"
MSG1.S.7 .AZ "FIN-WAIT-1"
MSG1.S.8 .AZ "FIN-WAIT-2"
MSG1.S.9 .AZ "CLOSING"
MSG1.S.10 .AZ "TIME-WAIT"
hLIBTCPIP .BS 1
*--------------------------------------
.DUMMY
.OR 0
DS.START
SocketCount .BS 1
DS.END
.ED
*--------------------------------------
MAN
SAVE /A2OSX.SRC/BIN/NETSTAT.S
ASM