mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-30 08:51:06 +00:00
212 lines
4.3 KiB
Plaintext
212 lines
4.3 KiB
Plaintext
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
|
||
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 CS
|
||
.DA DS.END-DS.START DS
|
||
.DA #64 SS
|
||
.DA #4 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
|
||
L.MSG1.T .DA MSG1.T.RAW
|
||
.DA MSG1.T.DGRAM
|
||
.DA MSG1.T.SEQPKT
|
||
.DA MSG1.T.STREAM
|
||
.DA MSG1.T.INV
|
||
L.MSG1.P .DA MSG1.P.ICMP
|
||
.DA MSG1.P.TCP
|
||
.DA MSG1.P.UDP
|
||
.DA MSG1.P.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 MSG1.S.INV
|
||
.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.GetTable
|
||
>STYA ZPPTR1
|
||
|
||
>STZ.G SocketCount
|
||
|
||
.1 tay
|
||
lda (ZPPTR1),y
|
||
beq .7
|
||
|
||
>SYSCALL GetMemPtr
|
||
>STYA ZPPTR2
|
||
|
||
lda (ZPPTR2)
|
||
cmp #AF.INET
|
||
* bne .7
|
||
|
||
jsr CS.RUN.S
|
||
|
||
ldy #S.SOCKET.O
|
||
>PUSHB (ZPPTR2),y
|
||
|
||
ldy #S.SOCKET.REM.PORT+1
|
||
|
||
.2 >PUSHB (ZPPTR2),y
|
||
dey
|
||
cpy #S.SOCKET.LOC.ADDR-1
|
||
bne .2
|
||
|
||
jsr CS.RUN.P
|
||
jsr CS.RUN.T
|
||
|
||
>PUSHBI 19
|
||
>LDYA L.MSG1
|
||
>SYSCALL printf
|
||
|
||
.7 >INC.G SocketCount
|
||
cmp #K.SKTTABLE.SIZE
|
||
bne .1
|
||
|
||
lda #0 tell TSKMGR that all done ok, but
|
||
sec we do not want to stay in memory
|
||
rts
|
||
*--------------------------------------
|
||
CS.RUN.S ldy #S.SOCKET.TCP.S
|
||
lda (ZPPTR2),y
|
||
|
||
cmp #S.SOCKET.TCP.S.TIMEWT+1
|
||
bcc .1
|
||
|
||
lda #S.SOCKET.TCP.S.TIMEWT+1
|
||
|
||
.1 asl
|
||
tax
|
||
>PUSHB L.MSG1.S+1,x
|
||
>PUSHB L.MSG1.S,x
|
||
rts
|
||
*--------------------------------------
|
||
CS.RUN.P ldy #S.SOCKET.PROTO
|
||
lda (ZPPTR2),y
|
||
|
||
ldx #0
|
||
|
||
.3 cmp PROTO,x
|
||
beq .4
|
||
inx
|
||
cpx #PROTO.Cnt
|
||
bne .3
|
||
|
||
.4 txa
|
||
asl
|
||
tax
|
||
|
||
>PUSHB L.MSG1.P+1,x
|
||
>PUSHB L.MSG1.P,x
|
||
|
||
rts
|
||
*--------------------------------------
|
||
CS.RUN.T ldy #S.SOCKET.T
|
||
lda (ZPPTR2),y
|
||
tax
|
||
cpx #S.SOCKET.T.STREAM+1
|
||
bcc .5
|
||
|
||
ldx #S.SOCKET.T.STREAM+1
|
||
|
||
.5 >PUSHB L.MSG1.T+1,x
|
||
>PUSHB L.MSG1.T,x
|
||
|
||
rts
|
||
*--------------------------------------
|
||
CS.DOEVENT sec
|
||
rts
|
||
*--------------------------------------
|
||
CS.QUIT lda hLIBTCPIP
|
||
beq .8
|
||
>SYSCALL UnloadLib
|
||
|
||
.8 clc
|
||
rts
|
||
*--------------------------------------
|
||
CS.END
|
||
LIBTCPIP .AZ "libtcpip"
|
||
MSG0 .AZ "Type Prot Local Remote Options Status"
|
||
MSG1 .AZ "%s %s %03d.%03d.%03d.%03d:%05D %03d.%03d.%03d.%03d:%05D %b %s\r\n"
|
||
MSG1.T.RAW .AZ "RAW "
|
||
MSG1.T.DGRAM .AZ "DGRAM "
|
||
MSG1.T.SEQPKT .AZ "SEQPKT"
|
||
MSG1.T.STREAM .AZ "STREAM"
|
||
MSG1.T.INV .AZ "??? "
|
||
PROTO .DA #S.IP.PROTOCOL.ICMP,#S.IP.PROTOCOL.TCP,#S.IP.PROTOCOL.UDP
|
||
PROTO.Cnt .EQ *-PROTO
|
||
MSG1.P.ICMP .AZ "ICMP"
|
||
MSG1.P.TCP .AZ "TCP "
|
||
MSG1.P.UDP .AZ "UDP "
|
||
MSG1.P.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"
|
||
MSG1.S.INV .AZ "???"
|
||
hLIBTCPIP .BS 1
|
||
*--------------------------------------
|
||
.DUMMY
|
||
.OR 0
|
||
DS.START
|
||
SocketCount .BS 1
|
||
DS.END
|
||
.ED
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE /A2OSX.SRC/BIN/NETSTAT.S
|
||
ASM
|