A2osX/BIN/NETSTAT.S.txt

234 lines
4.5 KiB
Plaintext
Raw Normal View History

2016-02-24 20:00:42 +00:00
NEW
2019-05-22 21:02:37 +00:00
AUTO 3,1
2016-02-24 20:00:42 +00:00
.LIST OFF
.OP 65C02
.OR $2000
2019-12-05 15:57:56 +00:00
.TF bin/netstat
2016-02-24 20:00:42 +00:00
*--------------------------------------
2020-08-17 20:47:31 +00:00
.INB inc/macros.i
.INB inc/a2osx.i
2023-10-18 05:41:12 +00:00
.INB inc/kernel.i
2020-08-17 20:47:31 +00:00
.INB inc/eth.i
.INB inc/net.tcpip.i
2020-08-17 20:47:31 +00:00
.INB inc/libtcpip.i
2016-02-24 20:00:42 +00:00
*--------------------------------------
2019-05-18 15:38:31 +00:00
.DUMMY
.OR ZPBIN
ZS.START
ZPPTR1 .BS 2
2023-10-18 05:41:12 +00:00
FDIndex .BS 1
2019-05-18 15:38:31 +00:00
ZS.END .ED
2016-02-24 20:00:42 +00:00
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
CS.START cld
jmp (.1,x)
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
.DA 0
2019-05-18 15:38:31 +00:00
.DA CS.END-CS.START Code Size (without Constants)
.DA DS.END-DS.START Data SegmentSize
2019-05-22 21:02:37 +00:00
.DA #64 Stack Size
2019-05-18 15:38:31 +00:00
.DA #ZS.END-ZS.START Zero Page Size
2016-02-24 20:00:42 +00:00
.DA 0
*--------------------------------------
* Relocation Table
2019-10-03 06:25:27 +00:00
*--------------------------------------
2016-02-24 20:00:42 +00:00
.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
2018-10-10 15:39:22 +00:00
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
2016-02-24 20:00:42 +00:00
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
2019-07-07 20:48:57 +00:00
.DA MSG1.S.11
2018-10-10 15:39:22 +00:00
.DA MSG1.S.INV
2016-02-24 20:00:42 +00:00
.DA 0
*--------------------------------------
CS.INIT >LDYA L.LIBTCPIP
2018-07-19 15:33:55 +00:00
>SYSCALL LoadLib
bcs .9
2016-02-24 20:00:42 +00:00
sta hLIBTCPIP
2018-11-12 09:22:06 +00:00
.9 rts
*--------------------------------------
CS.RUN >LDYA L.MSG0
2020-02-28 07:21:46 +00:00
>SYSCALL PutS
2020-04-07 06:01:38 +00:00
2023-10-18 05:41:12 +00:00
inc FDIndex
ldx FDIndex
2023-10-18 05:41:12 +00:00
.1 lda FDs.pHI-1,x
2016-02-24 20:00:42 +00:00
beq .7
2019-05-22 21:02:37 +00:00
2023-10-18 05:41:12 +00:00
ldy FDs.pLO-1,x
>STYA ZPPTR1
2020-04-07 06:01:38 +00:00
2023-10-18 05:41:12 +00:00
lda (ZPPTR1)
cmp #S.FD.T.DSOCK
beq .2
cmp #S.FD.T.SSOCK
bne .7
.2 ldy #S.SOCKET.AF
lda (ZPPTR1),y
2018-10-10 15:39:22 +00:00
cmp #AF.INET
2019-05-18 15:38:31 +00:00
bne .7
2018-10-10 15:39:22 +00:00
2020-04-07 06:01:38 +00:00
>PUSHW L.MSG1
jsr CS.RUN.TP
ldy #S.SOCKET.LOC.ADDR
jsr CS.RUN.A
ldy #S.SOCKET.REM.ADDR
jsr CS.RUN.A
2018-09-28 15:24:44 +00:00
ldy #S.SOCKET.O
2023-10-18 05:41:12 +00:00
>PUSHB (ZPPTR1),y
2020-04-07 06:01:38 +00:00
jsr CS.RUN.S 2 bytes
2018-10-10 15:39:22 +00:00
>PUSHBI 19
2020-04-07 06:01:38 +00:00
2020-02-28 07:21:46 +00:00
>SYSCALL PrintF
2019-05-18 15:38:31 +00:00
bcs .9
2020-04-07 06:01:38 +00:00
2023-10-18 05:41:12 +00:00
.7 inc FDIndex
ldx FDIndex
cpx #K.FD.MAX+1
bcc .1
2020-09-05 13:38:04 +00:00
2018-10-10 06:24:38 +00:00
lda #0 tell TSKMGR that all done ok, but
2023-10-18 05:41:12 +00:00
* sec we do not want to stay in memory
2019-05-18 15:38:31 +00:00
.9 rts
2016-02-24 20:00:42 +00:00
*--------------------------------------
2020-04-07 06:01:38 +00:00
CS.RUN.TP ldy #S.SOCKET.T
2023-10-18 05:41:12 +00:00
lda (ZPPTR1),y
2018-10-10 15:39:22 +00:00
tax
2020-04-07 06:01:38 +00:00
cpx #S.SOCKET.T.STREAM+1
bcc .1
ldx #S.SOCKET.T.STREAM+1
.1 >PUSHB L.MSG1.T+1,x
>PUSHB L.MSG1.T,x
ldy #S.SOCKET.PROTO
2023-10-18 05:41:12 +00:00
lda (ZPPTR1),y
2018-10-10 15:39:22 +00:00
ldx #0
2020-04-07 06:01:38 +00:00
2018-10-10 15:39:22 +00:00
.3 cmp PROTO,x
beq .4
2018-10-10 15:39:22 +00:00
inx
cpx #PROTO.Cnt
bne .3
2020-04-07 06:01:38 +00:00
2018-10-10 15:39:22 +00:00
.4 txa
asl
tax
>PUSHB L.MSG1.P+1,x
>PUSHB L.MSG1.P,x
rts
*--------------------------------------
2020-04-07 06:01:38 +00:00
CS.RUN.A ldx #4
2023-10-18 05:41:12 +00:00
.2 >PUSHB (ZPPTR1),y
2020-04-07 06:01:38 +00:00
iny
dex
bne .2
iny
2023-10-18 05:41:12 +00:00
>PUSHB (ZPPTR1),y
2020-04-07 06:01:38 +00:00
dey
2023-10-18 05:41:12 +00:00
>PUSHB (ZPPTR1),y
2020-04-07 06:01:38 +00:00
rts
*--------------------------------------
CS.RUN.S ldy #S.SOCKET.TCP.S
2023-10-18 05:41:12 +00:00
lda (ZPPTR1),y
2018-10-10 15:39:22 +00:00
2020-04-07 06:01:38 +00:00
cmp #S.SOCKET.TCP.S.TIMEWT+1
bcc .1
2020-04-07 06:01:38 +00:00
lda #S.SOCKET.TCP.S.TIMEWT+1
.1 asl
tax
>PUSHB L.MSG1.S+1,x
>PUSHB L.MSG1.S,x
2018-10-10 15:39:22 +00:00
rts
*--------------------------------------
CS.DOEVENT sec
2016-02-24 20:00:42 +00:00
rts
*--------------------------------------
CS.QUIT lda hLIBTCPIP
beq .8
2018-07-20 14:10:10 +00:00
>SYSCALL UnloadLib
.8 clc
2016-02-24 20:00:42 +00:00
rts
*--------------------------------------
CS.END
2020-08-17 20:47:31 +00:00
LIBTCPIP .AZ "libtcpip"
2019-01-17 15:05:48 +00:00
hLIBTCPIP .BS 1
2018-10-10 15:39:22 +00:00
MSG0 .AZ "Type Prot Local Remote Options Status"
MSG1 .CZ "%s %s %3d.%3d.%3d.%3d:%5D %3d.%3d.%3d.%3d:%5D %b %s\r\n"
2018-10-10 15:39:22 +00:00
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 "*"
2019-07-07 20:48:57 +00:00
MSG1.S.1 .AZ "OPENED"
MSG1.S.2 .AZ "LISTENING"
MSG1.S.3 .AZ "SYN-SENT"
MSG1.S.4 .AZ "SYN-RECEIVED"
MSG1.S.5 .AZ "ESTABLISHED"
MSG1.S.6 .AZ "CLOSE-WAIT"
MSG1.S.7 .AZ "LAST-ACK"
MSG1.S.8 .AZ "FIN-WAIT-1"
MSG1.S.9 .AZ "FIN-WAIT-2"
MSG1.S.10 .AZ "CLOSING"
MSG1.S.11 .AZ "TIME-WAIT"
2018-10-10 15:39:22 +00:00
MSG1.S.INV .AZ "???"
2018-06-15 15:15:48 +00:00
*--------------------------------------
.DUMMY
.OR 0
DS.START
2020-08-17 20:47:31 +00:00
DS.END .ED
2018-06-15 15:15:48 +00:00
*--------------------------------------
2016-02-24 20:00:42 +00:00
MAN
2020-08-17 20:47:31 +00:00
SAVE usr/src/bin/netstat.s
2016-02-24 20:00:42 +00:00
ASM