2015-03-14 21:48:35 +00:00
|
|
|
|
PR#3
|
2017-03-29 15:48:15 +00:00
|
|
|
|
PREFIX /A2OSX.BUILD
|
2015-03-14 21:48:35 +00:00
|
|
|
|
NEW
|
|
|
|
|
INC 1
|
|
|
|
|
AUTO 6
|
|
|
|
|
.LIST OFF
|
|
|
|
|
.OP 65C02
|
|
|
|
|
.OR $2000
|
2017-03-29 15:48:15 +00:00
|
|
|
|
.TF /A2OSX.BUILD/SBIN/TELNETD
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2017-03-29 15:48:15 +00:00
|
|
|
|
.INB /A2OSX.BUILD/INC/MACROS.I
|
|
|
|
|
.INB /A2OSX.BUILD/INC/A2OSX.I
|
|
|
|
|
.INB /A2OSX.BUILD/INC/LIBTCPIP.I
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2017-03-07 16:40:32 +00:00
|
|
|
|
TIMEOUT.MAX .EQ 30 30 sec.
|
|
|
|
|
CONN.MAX .EQ 16
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
ZPIPCfgPtr .EQ ZPBIN
|
|
|
|
|
ZPSktPtr .EQ ZPBIN+2
|
|
|
|
|
*--------------------------------------
|
2015-10-19 20:35:00 +00:00
|
|
|
|
* File Header (16 Bytes)
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.START cld
|
|
|
|
|
jmp (.1,x)
|
2015-10-19 20:35:00 +00:00
|
|
|
|
.DA #$61 6502,Level 1 (65c02)
|
|
|
|
|
.DA #1 BIN Layout Version 1
|
|
|
|
|
.DA 0
|
2018-05-22 06:01:05 +00:00
|
|
|
|
.DA CS.END-CS.START CS
|
|
|
|
|
.DA DS.END-DS.START DS
|
|
|
|
|
.DA #64 SS
|
|
|
|
|
.DA #4 ZP SS
|
2015-10-19 20:35:00 +00:00
|
|
|
|
.DA 0
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Relocation Table
|
|
|
|
|
*--------------------------------------
|
2015-03-14 21:48:35 +00:00
|
|
|
|
.1 .DA CS.INIT
|
|
|
|
|
.DA CS.RUN
|
2015-10-19 20:35:00 +00:00
|
|
|
|
.DA CS.DOEVENT
|
2015-03-14 21:48:35 +00:00
|
|
|
|
.DA CS.QUIT
|
2015-10-19 20:35:00 +00:00
|
|
|
|
L.LIBTCPIP .DA LIBTCPIP
|
2017-03-07 16:40:32 +00:00
|
|
|
|
L.Socket .DA Socket
|
|
|
|
|
L.MSG.TCPWAIT .DA MSG.TCPWAIT
|
|
|
|
|
L.MSG.INITOK .DA MSG.INITOK
|
|
|
|
|
L.MSG.TCPIPERR .DA MSG.TCPIPERR
|
|
|
|
|
L.MSG.SKTERR .DA MSG.SKTERR
|
|
|
|
|
L.MSG.ABORT .DA MSG.ABORT
|
|
|
|
|
L.MSG.INCOMING .DA MSG.INCOMING
|
2017-03-15 06:58:13 +00:00
|
|
|
|
L.MSG.BYTE .DA MSG.BYTE
|
2015-10-19 20:35:00 +00:00
|
|
|
|
.DA 0
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2015-10-19 20:35:00 +00:00
|
|
|
|
CS.INIT >LDYA L.LIBTCPIP
|
2018-05-22 06:01:05 +00:00
|
|
|
|
>SYSCALL LoadLib.YA
|
2015-10-19 20:35:00 +00:00
|
|
|
|
sta hLIBTCPIP
|
|
|
|
|
|
2017-03-07 16:40:32 +00:00
|
|
|
|
lda (pPs)
|
|
|
|
|
ora #S.PS.F.EVENT Now accept events
|
|
|
|
|
sta (pPs)
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN jsr Init.Timeout
|
|
|
|
|
|
|
|
|
|
>LDYA L.MSG.TCPWAIT
|
2018-06-21 15:12:10 +00:00
|
|
|
|
>SYSCALL printf
|
2017-03-07 16:40:32 +00:00
|
|
|
|
|
|
|
|
|
.1 >LIBCALL hLIBTCPIP,LIBTCPIP.GET.IPCFG is TCPIP loaded ?
|
2015-10-19 20:35:00 +00:00
|
|
|
|
bcs .99
|
2017-03-07 16:40:32 +00:00
|
|
|
|
>STYA ZPIPCfgPtr
|
|
|
|
|
|
|
|
|
|
lda (ZPIPCfgPtr) Configured ?
|
|
|
|
|
bmi CS.RUN.INIT
|
|
|
|
|
|
2017-11-17 16:16:05 +00:00
|
|
|
|
>SLEEP
|
2017-03-07 16:40:32 +00:00
|
|
|
|
jsr Wait.Timeout
|
|
|
|
|
bcc .1
|
2018-05-22 06:01:05 +00:00
|
|
|
|
>SYSCALL GetChar
|
2017-03-07 16:40:32 +00:00
|
|
|
|
bcs .1
|
|
|
|
|
cmp #$03
|
|
|
|
|
bne .1
|
|
|
|
|
jmp CS.RUN.ABORT
|
|
|
|
|
|
|
|
|
|
.99 >LDYA L.MSG.TCPIPERR
|
2018-06-21 15:12:10 +00:00
|
|
|
|
>SYSCALL printf
|
2017-10-26 16:01:54 +00:00
|
|
|
|
lda #K.E.SYN
|
2017-03-07 16:40:32 +00:00
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
CS.RUN.INIT ldx #3
|
|
|
|
|
ldy #S.IPCFG.IP+3
|
|
|
|
|
.1 lda (ZPIPCfgPtr),y
|
|
|
|
|
sta Socket.Src.Addr,x
|
|
|
|
|
dey
|
|
|
|
|
dex
|
|
|
|
|
bpl .1
|
|
|
|
|
|
|
|
|
|
>PUSHW L.Socket
|
|
|
|
|
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.New
|
|
|
|
|
bcs .9
|
|
|
|
|
txa
|
|
|
|
|
ldy #hSrvSocket
|
|
|
|
|
sta (pData),y
|
|
|
|
|
|
|
|
|
|
>LDYA L.MSG.INITOK
|
2018-06-21 15:12:10 +00:00
|
|
|
|
>SYSCALL printf
|
2017-03-07 16:40:32 +00:00
|
|
|
|
|
2017-11-17 16:16:05 +00:00
|
|
|
|
.2 >SLEEP
|
2017-03-07 16:40:32 +00:00
|
|
|
|
jsr CS.RUN.SERVER
|
|
|
|
|
bcs CS.RUN.ERR
|
|
|
|
|
|
2017-03-23 07:32:11 +00:00
|
|
|
|
jsr CS.RUN.CLIENT
|
2017-03-07 16:40:32 +00:00
|
|
|
|
bra .2
|
|
|
|
|
|
|
|
|
|
.9 >LDYA L.MSG.SKTERR
|
2018-06-21 15:12:10 +00:00
|
|
|
|
>SYSCALL printf
|
2017-10-26 16:01:54 +00:00
|
|
|
|
lda #K.E.SYN
|
2017-03-07 16:40:32 +00:00
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
CS.RUN.ABORT >LDYA L.MSG.ABORT
|
2018-06-21 15:12:10 +00:00
|
|
|
|
>SYSCALL printf
|
2017-03-07 16:40:32 +00:00
|
|
|
|
lda #0
|
|
|
|
|
|
|
|
|
|
CS.RUN.ERR sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN.SERVER ldy #hSrvSocket
|
|
|
|
|
lda (pData),y
|
|
|
|
|
|
|
|
|
|
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.AcceptA
|
|
|
|
|
bcs .8
|
|
|
|
|
pha
|
|
|
|
|
|
|
|
|
|
ldy #hSockets
|
|
|
|
|
ldx #CONN.MAX
|
|
|
|
|
|
|
|
|
|
.1 lda (pData),y
|
|
|
|
|
beq .2
|
|
|
|
|
iny
|
|
|
|
|
dex
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
pla
|
|
|
|
|
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.CloseA
|
|
|
|
|
bra .8
|
2015-10-19 20:35:00 +00:00
|
|
|
|
|
2017-03-07 16:40:32 +00:00
|
|
|
|
.2 pla
|
|
|
|
|
sta (pData),y
|
2017-03-19 21:47:54 +00:00
|
|
|
|
sta .4+1
|
2017-03-07 16:40:32 +00:00
|
|
|
|
|
|
|
|
|
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.GetA
|
|
|
|
|
>STYA ZPSktPtr
|
|
|
|
|
|
|
|
|
|
ldx #3
|
|
|
|
|
ldy #S.SOCKET.DST.ADDR+3
|
|
|
|
|
|
|
|
|
|
.3 >PUSHB (ZPSktPtr),y
|
|
|
|
|
dey
|
|
|
|
|
dex
|
|
|
|
|
bpl .3
|
|
|
|
|
|
2017-03-19 21:47:54 +00:00
|
|
|
|
.4 lda #$ff
|
|
|
|
|
>PUSHA
|
|
|
|
|
|
2017-03-07 16:40:32 +00:00
|
|
|
|
>LDYA L.MSG.INCOMING
|
2018-06-21 15:12:10 +00:00
|
|
|
|
>SYSCALL printf
|
2017-03-07 16:40:32 +00:00
|
|
|
|
.8 clc
|
|
|
|
|
.9 rts
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2017-03-19 21:47:54 +00:00
|
|
|
|
CS.RUN.CLIENT ldy #SktIndex
|
|
|
|
|
lda (pData),y
|
|
|
|
|
tay
|
|
|
|
|
lda (pData),y hSockets
|
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
|
|
sta .1+1 hSocket
|
2017-04-07 06:31:47 +00:00
|
|
|
|
sta .3+1
|
2017-03-14 07:32:31 +00:00
|
|
|
|
|
2017-08-25 06:37:21 +00:00
|
|
|
|
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.GetC.A
|
2017-03-19 21:47:54 +00:00
|
|
|
|
bcc .10
|
|
|
|
|
|
|
|
|
|
tax
|
|
|
|
|
beq .8 NO DATA
|
2017-03-23 07:32:11 +00:00
|
|
|
|
cmp #ERR.SKT.BAD
|
|
|
|
|
bne .8
|
|
|
|
|
|
|
|
|
|
ldy #SktIndex
|
|
|
|
|
lda (pData),y
|
|
|
|
|
tay
|
|
|
|
|
lda #0
|
|
|
|
|
sta (pData),y
|
|
|
|
|
bra .8
|
|
|
|
|
|
2017-03-19 21:47:54 +00:00
|
|
|
|
.10 sta .2+1
|
2017-03-07 16:40:32 +00:00
|
|
|
|
>PUSHA
|
2017-03-15 06:58:13 +00:00
|
|
|
|
>LDYA L.MSG.BYTE
|
2018-06-21 15:12:10 +00:00
|
|
|
|
>SYSCALL printf
|
2017-03-15 06:58:13 +00:00
|
|
|
|
|
|
|
|
|
.1 lda #$ff hSocket
|
2017-03-23 07:32:11 +00:00
|
|
|
|
>PUSHA
|
2015-10-19 20:35:00 +00:00
|
|
|
|
|
2017-03-14 07:32:31 +00:00
|
|
|
|
.2 lda #$ff data
|
2017-03-24 07:31:30 +00:00
|
|
|
|
and #$7F
|
2017-04-07 06:31:47 +00:00
|
|
|
|
ora #$20
|
|
|
|
|
>PUSHA
|
|
|
|
|
|
|
|
|
|
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.PutC
|
|
|
|
|
|
|
|
|
|
.3 lda #$ff hSocket
|
|
|
|
|
>PUSHA
|
|
|
|
|
|
|
|
|
|
lda #'/'
|
2017-03-23 07:32:11 +00:00
|
|
|
|
>PUSHA
|
2017-03-07 16:40:32 +00:00
|
|
|
|
|
2017-03-23 07:32:11 +00:00
|
|
|
|
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.PutC
|
2017-03-07 16:40:32 +00:00
|
|
|
|
|
2017-03-19 21:47:54 +00:00
|
|
|
|
.8 ldy #SktIndex
|
|
|
|
|
lda (pData),y
|
|
|
|
|
inc
|
|
|
|
|
cmp #CONN.MAX
|
|
|
|
|
bne .81
|
|
|
|
|
lda #0
|
|
|
|
|
|
|
|
|
|
.81 sta (pData),y
|
|
|
|
|
|
|
|
|
|
clc
|
2015-03-14 21:48:35 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-03-07 16:40:32 +00:00
|
|
|
|
CS.DOEVENT sec
|
2015-03-14 21:48:35 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-03-07 16:40:32 +00:00
|
|
|
|
CS.QUIT ldx #CONN.MAX
|
|
|
|
|
ldy #hSockets
|
|
|
|
|
|
|
|
|
|
.1 lda (pData),y
|
|
|
|
|
beq .2
|
|
|
|
|
|
|
|
|
|
phx
|
|
|
|
|
phy
|
|
|
|
|
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.CLOSEA
|
|
|
|
|
ply
|
|
|
|
|
plx
|
|
|
|
|
|
|
|
|
|
.2 iny
|
|
|
|
|
dex
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
ldy #hSrvSocket
|
|
|
|
|
lda (pData),y
|
2017-03-19 21:47:54 +00:00
|
|
|
|
beq .3
|
2017-03-07 16:40:32 +00:00
|
|
|
|
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.CLOSEA
|
2015-10-19 20:35:00 +00:00
|
|
|
|
|
2017-03-19 21:47:54 +00:00
|
|
|
|
.3 lda hLIBTCPIP
|
2018-05-22 06:01:05 +00:00
|
|
|
|
>SYSCALL UnloadLib.A
|
2015-10-19 20:35:00 +00:00
|
|
|
|
clc
|
2015-03-14 21:48:35 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-03-07 16:40:32 +00:00
|
|
|
|
Init.Timeout ldy #TimeOut
|
|
|
|
|
lda #TIMEOUT.MAX
|
|
|
|
|
sta (pData),y
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
Wait.TimeOut sec
|
|
|
|
|
ldy #TimeOut
|
|
|
|
|
lda (pData),y
|
|
|
|
|
beq .9
|
|
|
|
|
clc
|
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
2015-03-14 21:48:35 +00:00
|
|
|
|
CS.END
|
2015-10-19 20:35:00 +00:00
|
|
|
|
*--------------------------------------
|
2018-05-22 06:01:05 +00:00
|
|
|
|
LIBTCPIP .AZ "libtcpip.o"
|
2018-04-11 15:35:51 +00:00
|
|
|
|
MSG.TCPWAIT .AZ "TELNETD:Waiting for TCP/IP initializing...\r\n"
|
|
|
|
|
MSG.INITOK .AZ "TELNETD:Init Ok, Listening.\r\n"
|
|
|
|
|
MSG.TCPIPERR .AZ "TELNETD:TCP/IP Not initialized properly\r\n"
|
|
|
|
|
MSG.SKTERR .AZ "TELNETD:Listen Error\r\n"
|
|
|
|
|
MSG.ABORT .AZ "TELNETD:User Aborted\r\n"
|
|
|
|
|
MSG.INCOMING .AZ "TELNETD:Incoming Connection [SKT=%h] From : %d.%d.%d.%d\r\n"
|
|
|
|
|
MSG.BYTE .AZ "[%h]"
|
2015-10-19 20:35:00 +00:00
|
|
|
|
hLIBTCPIP .BS 1
|
2017-03-07 16:40:32 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
Socket .DA #S.SOCKET.SOCK.STREAM
|
|
|
|
|
.DA #S.SOCKET.SO.ACCEPTCONN
|
|
|
|
|
.DA #S.SOCKET.TCP.STATUS.LISTEN
|
|
|
|
|
.BS 1
|
|
|
|
|
Socket.Src.Addr .BS 4
|
|
|
|
|
Socket.Src.Port .DA 23
|
|
|
|
|
Socket.Dst.Addr .BS 4
|
|
|
|
|
Socket.Dst.Port .BS 2
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
.DUMMY
|
|
|
|
|
.OR 0
|
|
|
|
|
DS.START
|
|
|
|
|
hSockets .BS CONN.MAX pData
|
|
|
|
|
SktIndex .BS 1
|
2015-10-19 20:35:00 +00:00
|
|
|
|
hSrvSocket .BS 1
|
2017-03-07 16:40:32 +00:00
|
|
|
|
TimeOut .BS 1
|
|
|
|
|
DS.END
|
|
|
|
|
.ED
|
2015-10-19 20:35:00 +00:00
|
|
|
|
*--------------------------------------
|
2015-03-14 21:48:35 +00:00
|
|
|
|
MAN
|
2017-03-29 15:48:15 +00:00
|
|
|
|
SAVE /A2OSX.SRC/SBIN/TELNETD.S
|
2015-03-14 21:48:35 +00:00
|
|
|
|
ASM
|