New commands for new socket API

This commit is contained in:
Rémy GIBERT 2016-02-24 21:00:42 +01:00
parent 889c503c16
commit e40abd2bb4
2 changed files with 223 additions and 80 deletions

View File

@ -13,8 +13,8 @@ AUTO 6
.INB INC/LIBSTR.I
.INB INC/LIBTCPIP.I
*--------------------------------------
ZPPTR1 .EQ ZPBIN
ZPPTR2 .EQ ZPBIN+2
ZPIPCfgPtr .EQ ZPBIN
ZPDevInfoPtr .EQ ZPBIN+2
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
@ -35,13 +35,10 @@ CS.START cld
.DA CS.DOEVENT
.DA CS.QUIT
L.LIBSTR .DA LIBSTR
L.LIBTCPIP .DA LIBTCPIP
L.MSG0 .DA MSG0
L.MSG0.0 .DA MSG0.0
L.MSG0.1 .DA MSG0.1
L.MSG0.2 .DA MSG0.2
L.MSG0.N .DA MSG0.N
L.MSG0.U .DA MSG0.U
L.MSG0.C .DA MSG0.C
L.MSG0.U .DA MSG0.U
L.MSG1.DEV .DA MSG1.DEV
L.MSG1.DHCPSRVR .DA MSG1.DHCPSRVR
L.MSG1.IP .DA MSG1.IP
@ -49,154 +46,142 @@ L.MSG1.GW .DA MSG1.GW
L.MSG1.DNS .DA MSG1.DNS
L.MSG1.HOSTNAME .DA MSG1.HOSTNAME
L.MSG1.DOMAIN .DA MSG1.DOMAIN
L.MSG1.END .DA MSG1.END
.DA 0
*--------------------------------------
CS.INIT >LDYA L.LIBSTR
>SYSCALL SYS.LoadLibYA
sta hLIBSTR
lda #K.PROTOID.IP
>SYSCALL SYS.GetNetCfgA
bcc CS.INIT.LOADED
>PUSHW L.MSG0.N
>PUSHW L.MSG0.2
>PUSHW L.MSG0
>LIBCALL hLIBSTR,LIBSTR.PRINTF
jmp CS.INIT.END
CS.INIT.LOADED >STYA ZPPTR1
>LDYA L.LIBTCPIP
>SYSCALL SYS.LoadLibYA
sta hLIBTCPIP
ldy #S.IPCFG.STATUS
lda (ZPPTR1),y
bmi CS.INIT.CONFOK
>PUSHW L.MSG0.U
>PUSHW L.MSG0.2
>PUSHW L.MSG0
>LIBCALL hLIBSTR,LIBSTR.PRINTF
jsr CS.INIT.DEV.MAC
jmp CS.INIT.END
>LIBCALL hLIBTCPIP,LIBTCPIP.GET.IPCFG
>STYA ZPIPCfgPtr
CS.INIT.CONFOK >PUSHW L.MSG0.C
>PUSHW L.MSG0.2
>PUSHW L.MSG0
>LIBCALL hLIBSTR,LIBSTR.PRINTF
lda (ZPIPCfgPtr)
and #S.IPCFG.STATUS.OK
beq .11
>LDYA L.MSG0.C
bra .10
.11 >LDYA L.MSG0.U
jsr CS.INIT.DEV.MAC
.10 >PUSHYA
>LIBCALL hLIBSTR,LIBSTR.PRINTF
CS.INIT.PRINT ldy #S.IPCFG.MAC+6
.1 dey
>PUSHB (ZPIPCfgPtr),y
cpy #S.IPCFG.MAC
bne .1
ldy #S.IPCFG.hDEV
lda (ZPIPCfgPtr),y
>SYSCALL SYS.GetDevInfoA
>STYA ZPDevInfoPtr
ldy #S.DEVINFO.NET.STATUS
>PUSHB (ZPDevInfoPtr),y
ldy #S.IPCFG.hDEV
>PUSHB (ZPIPCfgPtr),y
>PUSHW L.MSG1.DEV
>LIBCALL hLIBSTR,LIBSTR.PRINTF
ldy #S.IPCFG.DHCPSRVR+3
ldx #4
L1 >PUSHB (ZPPTR1),y
.2 >PUSHB (ZPIPCfgPtr),y
dey
dex
bne L1
bne .2
>PUSHW L.MSG1.DHCPSRVR
>LIBCALL hLIBSTR,LIBSTR.PRINTF
ldy #S.IPCFG.IP+7 IP/MASK
ldx #8
L2 >PUSHB (ZPPTR1),y
.3 >PUSHB (ZPIPCfgPtr),y
dey
dex
bne L2
bne .3
>PUSHW L.MSG1.IP
>LIBCALL hLIBSTR,LIBSTR.PRINTF
ldy #S.IPCFG.GW+3
ldx #4
L4 >PUSHB (ZPPTR1),y
.4 >PUSHB (ZPIPCfgPtr),y
dey
dex
bne L4
bne .4
>PUSHW L.MSG1.GW
>LIBCALL hLIBSTR,LIBSTR.PRINTF
ldy #S.IPCFG.DNS+7
ldy #S.IPCFG.DNS1+7
ldx #8
L5 >PUSHB (ZPPTR1),y
.5 >PUSHB (ZPIPCfgPtr),y
dey
dex
bne L5
bne .5
>PUSHW L.MSG1.DNS
>LIBCALL hLIBSTR,LIBSTR.PRINTF
lda ZPPTR1
lda ZPIPCfgPtr
clc
adc #S.IPCFG.HOSTNAME
tay
lda ZPPTR1+1
lda ZPIPCfgPtr+1
adc #0
>PUSHYA
>PUSHW L.MSG1.HOSTNAME
>LIBCALL hLIBSTR,LIBSTR.PRINTF
ldy #S.IPCFG.DOMAIN
lda (ZPPTR1),y
beq L6
lda (ZPIPCfgPtr),y
beq CS.INIT.DONE
lda ZPPTR1
lda ZPIPCfgPtr
clc
adc #S.IPCFG.DOMAIN
tay
lda ZPPTR1+1
lda ZPIPCfgPtr+1
adc #0
>PUSHYA
>PUSHW L.MSG1.DOMAIN
>LIBCALL hLIBSTR,LIBSTR.PRINTF
L6 >PUSHW L.MSG1.END
>LIBCALL hLIBSTR,LIBSTR.PRINTF
CS.INIT.END lda #0 tell TSKMGR that all done ok, but
CS.INIT.DONE lda #0 tell TSKMGR that all done ok, but
sec we do not want to stay in memory
rts
*--------------------------------------
CS.INIT.DEV.MAC ldy #S.IPCFG.MAC+6
.1 dey
>PUSHB (ZPPTR1),y
cpy #S.IPCFG.MAC
bne .1
ldy #S.IPCFG.hDEV
>PUSHB (ZPPTR1),y
>PUSHW L.MSG1.DEV
>LIBCALL hLIBSTR,LIBSTR.PRINTF
rts
*--------------------------------------
CS.RUN clc
rts
*--------------------------------------
CS.RUN
CS.DOEVENT clc
rts
*--------------------------------------
CS.QUIT lda hLIBSTR
CS.QUIT lda hLIBTCPIP
>SYSCALL SYS.FreeMemA
lda hLIBSTR
>SYSCALL SYS.FreeMemA
clc
rts
*--------------------------------------
CS.END
LIBSTR >PSTRING "libstr.o"
MSG0 >CSTRING "Protocol:%s (%s)\n"
MSG0.0 >CSTRING "AppleTalk"
MSG0.1 >CSTRING "EtherTalk"
MSG0.2 >CSTRING "TCP/IP"
MSG0.N >CSTRING "Not Loaded"
MSG0.U >CSTRING "Unconfigured"
MSG0.C >CSTRING "Configured"
MSG1.DEV >CSTRING " DeviceID : %h,MAC=%02h:%02h:%02h:%02h:%02h:%02h\n"
LIBTCPIP >PSTRING "libtcpip.o"
MSG0 >CSTRING "TCP/IP Status: "
MSG0.C >CSTRING "Configured.\n"
MSG0.U >CSTRING "Not Configured.\n"
MSG1.DEV >CSTRING " DeviceID : %h,%b,MAC=%02h:%02h:%02h:%02h:%02h:%02h\n"
MSG1.DHCPSRVR >CSTRING " DHCP Server : %d.%d.%d.%d\n"
MSG1.IP >CSTRING " IP/Mask : %d.%d.%d.%d/%d.%d.%d.%d\n"
MSG1.GW >CSTRING " Gateway : %d.%d.%d.%d\n"
MSG1.DNS >CSTRING " DNS : %d.%d.%d.%d,%d.%d.%d.%d\n"
MSG1.HOSTNAME >CSTRING " Hostname : %s"
MSG1.DOMAIN >CSTRING ".%s"
MSG1.END >CSTRING "\nEnd of network configuration.\n"
MSG1.DOMAIN >CSTRING ".%s\n"
hLIBSTR .BS 1
hLIBTCPIP .BS 1
MAN
SAVE BIN/NETINFO.S
ASM

158
BIN/NETSTAT.S.txt Normal file
View File

@ -0,0 +1,158 @@
PR#3
PREFIX /A2OSX.SRC
NEW
INC 1
AUTO 6
.LIST OFF
.OP 65C02
.OR $2000
.TF /A2OSX.BOOT/BIN/NETSTAT
*--------------------------------------
.INB INC/MACROS.I
.INB INC/A2OSX.I
.INB INC/LIBSTR.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 Code Length To Relocate
.DA 0 Data Segment to Allocate
.DA 0
.DA 0
*--------------------------------------
* Relocation Table
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
L.LIBSTR .DA LIBSTR
L.LIBTCPIP .DA LIBTCPIP
L.MSG0 .DA MSG0
L.MSG1 .DA MSG1
.DA MSG1.UDP
.DA MSG1.TCP
.DA MSG1.RAW
.DA MSG1.RDM
.DA MSG1.SEQ
.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.LIBSTR
>SYSCALL SYS.LoadLibYA
sta hLIBSTR
>LDYA L.LIBTCPIP
>SYSCALL SYS.LoadLibYA
sta hLIBTCPIP
>PUSHW L.MSG0
>LIBCALL hLIBSTR,LIBSTR.PRINTF
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.GETTABLE
>STYA ZPPTR1
lda #K.SKTTABLE.SIZE
sta SocketCount
.1 lda (ZPPTR1)
beq .7
ldy #S.SOCKET.STATUS
lda (ZPPTR1),y
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.SEQPACKET
bcc .3
lda #S.SOCKET.SOCK.SEQPACKET+1
.3 asl
tax
>PUSHB L.MSG1+1,x
>PUSHB L.MSG1,x
>PUSHW L.MSG1
>LIBCALL hLIBSTR,LIBSTR.PRINTF
.7 clc
lda ZPPTR1
adc #S.SOCKET
sta ZPPTR1
lda ZPPTR1+1
adc /S.SOCKET
sta ZPPTR1+1
dec SocketCount
bne .1
CS.INIT.DONE lda #0 tell TSKMGR that all done ok, but
sec we do not want to stay in memory
rts
*--------------------------------------
CS.RUN
CS.DOEVENT clc
rts
*--------------------------------------
CS.QUIT lda hLIBTCPIP
>SYSCALL SYS.FreeMemA
lda hLIBSTR
>SYSCALL SYS.FreeMemA
clc
rts
*--------------------------------------
CS.END
LIBSTR >PSTRING "libstr.o"
LIBTCPIP >PSTRING "libtcpip.o"
MSG0 >CSTRING "Proto Local Remote Options Status\n"
MSG1 >CSTRING "%s %03d.%03d.%03d.%03d:%05D %03d.%03d.%03d.%03d:%05D %b %s\n"
MSG1.UDP >CSTRING "UDP"
MSG1.TCP >CSTRING "TCP"
MSG1.RAW >CSTRING "RAW"
MSG1.RDM >CSTRING "RDM"
MSG1.SEQ >CSTRING "SEQ"
MSG1.INV >CSTRING "???"
MSG1.S.0 >CSTRING "*"
MSG1.S.1 >CSTRING "LISTENING"
MSG1.S.2 >CSTRING "SYN-SENT"
MSG1.S.3 >CSTRING "SYN-RECEIVED"
MSG1.S.4 >CSTRING "ESTABLISHED"
MSG1.S.5 >CSTRING "CLOSE-WAIT"
MSG1.S.6 >CSTRING "LAST-ACK"
MSG1.S.7 >CSTRING "FIN-WAIT-1"
MSG1.S.8 >CSTRING "FIN-WAIT-2"
MSG1.S.9 >CSTRING "CLOSING"
MSG1.S.10 >CSTRING "TIME-WAIT"
hLIBSTR .BS 1
hLIBTCPIP .BS 1
SocketCount .BS 1
MAN
SAVE BIN/NETSTAT.S
ASM