2016-03-13 21:54:28 +00:00
|
|
|
|
NEW
|
2018-11-17 17:17:13 +00:00
|
|
|
|
PREFIX
|
2018-04-16 15:25:39 +00:00
|
|
|
|
AUTO 4,1
|
2016-03-13 21:54:28 +00:00
|
|
|
|
.LIST OFF
|
|
|
|
|
.OP 65C02
|
|
|
|
|
.OR $2000
|
2018-07-23 15:28:42 +00:00
|
|
|
|
.TF SBIN/HTTPD
|
2016-03-13 21:54:28 +00:00
|
|
|
|
*--------------------------------------
|
2018-07-23 15:28:42 +00:00
|
|
|
|
.INB INC/MACROS.I
|
|
|
|
|
.INB INC/A2OSX.I
|
2019-03-02 22:18:21 +00:00
|
|
|
|
.INB INC/ETH.I
|
2018-07-23 15:28:42 +00:00
|
|
|
|
.INB INC/LIBTCPIP.I
|
2019-03-02 22:18:21 +00:00
|
|
|
|
.INB INC/NET.HTTP.I
|
2016-03-13 21:54:28 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
TIMEOUT.MAX .EQ 30 30 sec.
|
2017-02-15 16:14:41 +00:00
|
|
|
|
CONN.MAX .EQ 16
|
2016-03-13 21:54:28 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
ZPIPCfgPtr .EQ ZPBIN
|
|
|
|
|
ZPSktPtr .EQ ZPBIN+2
|
2018-04-16 15:25:39 +00:00
|
|
|
|
ZPLinePtr .EQ ZPBIN+4
|
2016-03-13 21:54:28 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
* File Header (16 Bytes)
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.START cld
|
|
|
|
|
jmp (.1,x)
|
|
|
|
|
.DA #$61 6502,Level 1 (65c02)
|
|
|
|
|
.DA #1 BIN Layout Version 1
|
2019-03-02 20:47:58 +00:00
|
|
|
|
.DA #S.PS.F.EVENT
|
|
|
|
|
.DA #0
|
2018-04-16 15:25:39 +00:00
|
|
|
|
.DA CS.END-CS.START CS
|
|
|
|
|
.DA DS.END-DS.START DS
|
|
|
|
|
.DA #64 SS
|
|
|
|
|
.DA #6 ZP
|
2016-03-13 21:54:28 +00:00
|
|
|
|
.DA 0
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Relocation Table
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
.1 .DA CS.INIT
|
|
|
|
|
.DA CS.RUN
|
|
|
|
|
.DA CS.DOEVENT
|
|
|
|
|
.DA CS.QUIT
|
|
|
|
|
L.LIBTCPIP .DA LIBTCPIP
|
2019-03-02 22:18:21 +00:00
|
|
|
|
L.SA.Local .DA SA.Local
|
2016-03-13 21:54:28 +00:00
|
|
|
|
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
|
2019-03-07 20:40:06 +00:00
|
|
|
|
L.MSG.DBG0 .DA MSG.DBG0
|
|
|
|
|
L.MSG.DBG1 .DA MSG.DBG1
|
2017-04-12 06:12:39 +00:00
|
|
|
|
L.HTTP.200OK .DA HTTP.200OK
|
2016-03-13 21:54:28 +00:00
|
|
|
|
.DA 0
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.INIT >LDYA L.LIBTCPIP
|
2018-07-19 15:33:55 +00:00
|
|
|
|
>SYSCALL LoadLib
|
2019-03-04 07:14:31 +00:00
|
|
|
|
bcs .9
|
2016-03-13 21:54:28 +00:00
|
|
|
|
sta hLIBTCPIP
|
|
|
|
|
|
2019-03-04 07:14:31 +00:00
|
|
|
|
.9 rts
|
2016-03-13 21:54:28 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN jsr Init.Timeout
|
|
|
|
|
|
|
|
|
|
>LDYA L.MSG.TCPWAIT
|
2019-03-04 07:14:31 +00:00
|
|
|
|
>SYSCALL puts
|
|
|
|
|
|
|
|
|
|
.1 >SLEEP
|
2016-03-13 21:54:28 +00:00
|
|
|
|
|
2019-03-04 07:14:31 +00:00
|
|
|
|
>LIBCALL hLIBTCPIP,LIBTCPIP.GETCFG is TCPIP loaded ?
|
2016-03-13 21:54:28 +00:00
|
|
|
|
bcs .99
|
|
|
|
|
>STYA ZPIPCfgPtr
|
|
|
|
|
|
|
|
|
|
lda (ZPIPCfgPtr) Configured ?
|
|
|
|
|
bmi CS.RUN.INIT
|
|
|
|
|
|
|
|
|
|
jsr Wait.Timeout
|
2019-03-04 07:14:31 +00:00
|
|
|
|
bcs .99
|
|
|
|
|
|
|
|
|
|
ldy #S.PS.hStdIn
|
|
|
|
|
lda (pPs),y
|
|
|
|
|
>SYSCALL feof
|
|
|
|
|
bcs CS.RUN.RTS I/O err
|
|
|
|
|
tay
|
|
|
|
|
beq .1
|
|
|
|
|
|
2018-04-16 15:25:39 +00:00
|
|
|
|
>SYSCALL GetChar
|
2019-03-04 07:14:31 +00:00
|
|
|
|
bcs CS.RUN.RTS
|
|
|
|
|
|
2017-01-28 22:05:20 +00:00
|
|
|
|
cmp #$03
|
|
|
|
|
bne .1
|
2018-04-16 15:25:39 +00:00
|
|
|
|
|
|
|
|
|
>LDYA L.MSG.ABORT
|
2018-06-21 15:12:10 +00:00
|
|
|
|
>SYSCALL printf
|
2019-03-04 07:14:31 +00:00
|
|
|
|
lda #3
|
2018-04-16 15:25:39 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
2016-03-13 21:54:28 +00:00
|
|
|
|
|
|
|
|
|
.99 >LDYA L.MSG.TCPIPERR
|
2019-03-04 07:14:31 +00:00
|
|
|
|
>SYSCALL puts
|
2018-10-21 20:54:07 +00:00
|
|
|
|
lda #E.SYN
|
2016-03-13 21:54:28 +00:00
|
|
|
|
sec
|
2018-04-16 15:25:39 +00:00
|
|
|
|
CS.RUN.RTS rts
|
2016-03-13 21:54:28 +00:00
|
|
|
|
|
|
|
|
|
CS.RUN.INIT ldx #3
|
|
|
|
|
ldy #S.IPCFG.IP+3
|
2018-04-16 15:25:39 +00:00
|
|
|
|
|
2016-03-13 21:54:28 +00:00
|
|
|
|
.1 lda (ZPIPCfgPtr),y
|
2019-03-02 22:18:21 +00:00
|
|
|
|
sta SA.LOCAL+S.SOCKADDR.ADDR,x
|
2016-03-13 21:54:28 +00:00
|
|
|
|
dey
|
|
|
|
|
dex
|
|
|
|
|
bpl .1
|
|
|
|
|
|
2019-03-02 22:18:21 +00:00
|
|
|
|
>PUSHBI 0 no protocol
|
|
|
|
|
lda #S.SOCKET.T.STREAM
|
|
|
|
|
>LIBCALL hLIBTCPIP,LIBTCPIP.Socket
|
|
|
|
|
bcs CS.RUN.ERR
|
2018-09-17 15:42:38 +00:00
|
|
|
|
|
|
|
|
|
>STA.G hSrvSocket
|
2019-03-02 22:18:21 +00:00
|
|
|
|
pha
|
|
|
|
|
>PUSHW L.SA.LOCAL
|
|
|
|
|
pla
|
|
|
|
|
>LIBCALL hLIBTCPIP,LIBTCPIP.Bind
|
|
|
|
|
bcs CS.RUN.ERR
|
|
|
|
|
|
|
|
|
|
>LDA.G hSrvSocket
|
|
|
|
|
>LIBCALL hLIBTCPIP,LIBTCPIP.Listen
|
|
|
|
|
bcs CS.RUN.ERR
|
2016-03-13 21:54:28 +00:00
|
|
|
|
|
2019-03-07 20:40:06 +00:00
|
|
|
|
>LDYAI 512
|
2018-07-20 11:51:08 +00:00
|
|
|
|
>SYSCALL getmem
|
2018-04-16 15:25:39 +00:00
|
|
|
|
bcs CS.RUN.RTS
|
|
|
|
|
|
|
|
|
|
>STYA ZPLinePtr
|
|
|
|
|
txa
|
|
|
|
|
>STA.G hLineBuf
|
|
|
|
|
|
2016-03-13 21:54:28 +00:00
|
|
|
|
>LDYA L.MSG.INITOK
|
2018-06-21 15:12:10 +00:00
|
|
|
|
>SYSCALL printf
|
2016-03-13 21:54:28 +00:00
|
|
|
|
|
2018-04-16 15:25:39 +00:00
|
|
|
|
CS.RUN.LOOP >SLEEP
|
2017-02-17 07:20:57 +00:00
|
|
|
|
jsr CS.RUN.SERVER
|
|
|
|
|
bcs CS.RUN.ERR
|
2016-03-13 21:54:28 +00:00
|
|
|
|
|
2018-04-16 15:25:39 +00:00
|
|
|
|
bra CS.RUN.LOOP
|
2017-02-17 07:20:57 +00:00
|
|
|
|
|
|
|
|
|
.9 >LDYA L.MSG.SKTERR
|
2018-06-21 15:12:10 +00:00
|
|
|
|
>SYSCALL printf
|
2018-10-21 20:54:07 +00:00
|
|
|
|
lda #E.SYN
|
2017-02-17 07:20:57 +00:00
|
|
|
|
sec
|
|
|
|
|
|
2019-03-02 22:18:21 +00:00
|
|
|
|
CS.RUN.ERR rts
|
2017-02-17 07:20:57 +00:00
|
|
|
|
*--------------------------------------
|
2019-03-02 22:18:21 +00:00
|
|
|
|
CS.RUN.SERVER >LDA.G hSrvSocket
|
|
|
|
|
>LIBCALL hLIBTCPIP,LIBTCPIP.accept
|
2017-02-17 07:20:57 +00:00
|
|
|
|
bcs .8
|
2017-02-15 16:14:41 +00:00
|
|
|
|
|
2019-03-02 22:18:21 +00:00
|
|
|
|
>STA.G hClntSocket
|
|
|
|
|
>SYSCALL GetMemPtr
|
2016-03-13 21:54:28 +00:00
|
|
|
|
>STYA ZPSktPtr
|
2017-02-17 07:20:57 +00:00
|
|
|
|
|
2016-03-13 21:54:28 +00:00
|
|
|
|
ldx #3
|
2019-03-02 22:18:21 +00:00
|
|
|
|
ldy #S.SOCKET.REM.ADDR+3
|
2016-03-13 21:54:28 +00:00
|
|
|
|
|
2017-02-17 07:20:57 +00:00
|
|
|
|
.3 >PUSHB (ZPSktPtr),y
|
2016-03-13 21:54:28 +00:00
|
|
|
|
dey
|
|
|
|
|
dex
|
2017-02-17 07:20:57 +00:00
|
|
|
|
bpl .3
|
2016-03-13 21:54:28 +00:00
|
|
|
|
|
2019-03-02 22:18:21 +00:00
|
|
|
|
>PUSHB.G hClntSocket
|
|
|
|
|
|
|
|
|
|
>PUSHBI 5
|
2016-03-13 21:54:28 +00:00
|
|
|
|
>LDYA L.MSG.INCOMING
|
2018-06-21 15:12:10 +00:00
|
|
|
|
>SYSCALL printf
|
2019-03-02 22:18:21 +00:00
|
|
|
|
|
2019-03-04 07:14:31 +00:00
|
|
|
|
jsr CS.RUN.CLIENT
|
|
|
|
|
|
2017-02-17 07:20:57 +00:00
|
|
|
|
.8 clc
|
|
|
|
|
.9 rts
|
2016-03-13 21:54:28 +00:00
|
|
|
|
*--------------------------------------
|
2019-03-07 20:40:06 +00:00
|
|
|
|
CS.RUN.CLIENT
|
2019-03-04 07:14:31 +00:00
|
|
|
|
.1 >SLEEP
|
|
|
|
|
|
2019-03-07 20:40:06 +00:00
|
|
|
|
>PUSHWI 512
|
|
|
|
|
>PUSHW ZPLinePtr
|
|
|
|
|
>LDA.G hClntSocket
|
2019-03-02 22:18:21 +00:00
|
|
|
|
>LIBCALL hLIBTCPIP,LIBTCPIP.read
|
2019-03-07 20:40:06 +00:00
|
|
|
|
bcc .2
|
|
|
|
|
|
|
|
|
|
>PUSHYA
|
|
|
|
|
>PUSHBI 2
|
|
|
|
|
>LDYA L.MSG.DBG0
|
|
|
|
|
>SYSCALL printf
|
|
|
|
|
bra .8
|
2017-02-15 16:14:41 +00:00
|
|
|
|
|
2019-03-07 20:40:06 +00:00
|
|
|
|
.2 phy
|
2019-03-04 07:14:31 +00:00
|
|
|
|
ply
|
2019-03-07 20:40:06 +00:00
|
|
|
|
bne .3
|
2019-03-04 07:14:31 +00:00
|
|
|
|
|
|
|
|
|
pha
|
|
|
|
|
pla
|
2019-03-07 20:40:06 +00:00
|
|
|
|
beq .1
|
2019-03-04 07:14:31 +00:00
|
|
|
|
|
2019-03-07 20:40:06 +00:00
|
|
|
|
.3 phy
|
|
|
|
|
pha
|
|
|
|
|
>PUSHYA
|
|
|
|
|
>PUSHBI 2
|
|
|
|
|
>LDYA L.MSG.DBG1
|
|
|
|
|
>SYSCALL printf
|
|
|
|
|
pla
|
|
|
|
|
ply
|
2019-03-04 07:14:31 +00:00
|
|
|
|
|
2019-03-07 20:40:06 +00:00
|
|
|
|
|
2019-03-04 07:14:31 +00:00
|
|
|
|
>PUSHYA
|
2018-04-16 15:25:39 +00:00
|
|
|
|
>PUSHW ZPLinePtr
|
2019-03-04 07:14:31 +00:00
|
|
|
|
ldy #S.PS.hStdOut
|
|
|
|
|
lda (pPS),y
|
2019-03-07 20:40:06 +00:00
|
|
|
|
|
2019-03-04 07:14:31 +00:00
|
|
|
|
>SYSCALL fwrite
|
|
|
|
|
|
|
|
|
|
.7 >PUSHWI HTTP.200OK.len
|
2017-04-12 06:12:39 +00:00
|
|
|
|
>PUSHW L.HTTP.200OK
|
2019-03-02 22:18:21 +00:00
|
|
|
|
>LDA.G hClntSocket
|
2019-03-04 07:14:31 +00:00
|
|
|
|
|
2019-03-02 22:18:21 +00:00
|
|
|
|
>LIBCALL hLIBTCPIP,LIBTCPIP.write
|
2017-04-12 06:12:39 +00:00
|
|
|
|
|
2019-03-04 07:14:31 +00:00
|
|
|
|
.8 >LDA.G hClntSocket
|
|
|
|
|
>LIBCALL hLIBTCPIP,LIBTCPIP.Shutdown
|
|
|
|
|
|
|
|
|
|
clc
|
2016-03-13 21:54:28 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2019-03-04 07:14:31 +00:00
|
|
|
|
CS.DOEVENT lda (pEvent)
|
|
|
|
|
bpl .9 is it a TIMER event?
|
2017-02-15 16:14:41 +00:00
|
|
|
|
|
2019-03-04 07:14:31 +00:00
|
|
|
|
>LDA.G TimeOut
|
|
|
|
|
beq .9
|
2017-02-15 16:14:41 +00:00
|
|
|
|
|
2019-03-04 07:14:31 +00:00
|
|
|
|
dec
|
|
|
|
|
sta (pData),y
|
2017-02-15 16:14:41 +00:00
|
|
|
|
|
2019-03-04 07:14:31 +00:00
|
|
|
|
.9 sec do not discard TIMER event
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.QUIT ldy #hSrvSocket
|
2016-03-13 21:54:28 +00:00
|
|
|
|
lda (pData),y
|
2019-03-04 07:14:31 +00:00
|
|
|
|
beq .3
|
2019-03-02 22:18:21 +00:00
|
|
|
|
>LIBCALL hLIBTCPIP,LIBTCPIP.Shutdown
|
2016-03-13 21:54:28 +00:00
|
|
|
|
|
2019-03-04 07:14:31 +00:00
|
|
|
|
.3 >LDA.G hLineBuf
|
|
|
|
|
beq .4
|
2018-04-16 15:25:39 +00:00
|
|
|
|
|
2018-07-18 15:30:42 +00:00
|
|
|
|
>SYSCALL FreeMem
|
2018-04-16 15:25:39 +00:00
|
|
|
|
|
2019-03-04 07:14:31 +00:00
|
|
|
|
.4 lda hLIBTCPIP
|
2018-11-12 09:22:06 +00:00
|
|
|
|
beq .8
|
2018-07-20 14:10:10 +00:00
|
|
|
|
>SYSCALL UnloadLib
|
2018-11-12 09:22:06 +00:00
|
|
|
|
|
|
|
|
|
.8 clc
|
2016-03-13 21:54:28 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
Init.Timeout ldy #TimeOut
|
|
|
|
|
lda #TIMEOUT.MAX
|
|
|
|
|
sta (pData),y
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
Wait.TimeOut sec
|
|
|
|
|
ldy #TimeOut
|
|
|
|
|
lda (pData),y
|
|
|
|
|
beq .9
|
|
|
|
|
clc
|
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.END
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
hLIBTCPIP .BS 1
|
2019-03-04 07:14:31 +00:00
|
|
|
|
LIBTCPIP .AZ "libtcpip"
|
|
|
|
|
MSG.TCPWAIT .AZ "HTTPD:Waiting for TCP/IP initializing..."
|
|
|
|
|
MSG.INITOK .AZ "HTTPD:Init Ok, Listening."
|
|
|
|
|
MSG.TCPIPERR .AZ "HTTPD:TCP/IP Not initialized properly."
|
|
|
|
|
MSG.SKTERR .AZ "HTTPD:Listen Error."
|
|
|
|
|
MSG.ABORT .AZ "HTTPD:User Aborted."
|
|
|
|
|
MSG.INCOMING .AZ "HTTPD:Incoming Connection [SKT=%h] From : %d.%d.%d.%d\r\n"
|
2019-03-07 20:40:06 +00:00
|
|
|
|
MSG.DBG0 .AZ "read: ERROR %h\r\n"
|
|
|
|
|
MSG.DBG1 .AZ "read: %D bytes\r\n"
|
2017-04-12 06:12:39 +00:00
|
|
|
|
*--------------------------------------
|
2019-03-04 07:14:31 +00:00
|
|
|
|
HTTP.200OK .AS "HTTP/1.1 200 OK"
|
|
|
|
|
.DA #C.CR,#C.LF
|
|
|
|
|
.AS "Server: A2osX-HTTPD 0.92"
|
|
|
|
|
.DA #C.CR,#C.LF
|
|
|
|
|
.AS "Content-Type: text/html"
|
|
|
|
|
.DA #C.CR,#C.LF
|
|
|
|
|
.AS "Content-Length: 34"
|
|
|
|
|
.DA #C.CR,#C.LF
|
|
|
|
|
.AS "Connection: Close"
|
|
|
|
|
.DA #C.CR,#C.LF
|
|
|
|
|
.DA #C.CR,#C.LF
|
|
|
|
|
.AS "<HTML><BODY>Hello!</BODY></HTML>"
|
|
|
|
|
.DA #C.CR,#C.LF
|
2019-03-02 22:18:21 +00:00
|
|
|
|
HTTP.200OK.len .EQ *-HTTP.200OK
|
2016-03-13 21:54:28 +00:00
|
|
|
|
*--------------------------------------
|
2019-03-02 22:18:21 +00:00
|
|
|
|
SA.LOCAL .DA #AF.INET S.SOCKADDR.AF
|
2016-03-13 21:54:28 +00:00
|
|
|
|
.BS 1
|
2019-03-02 22:18:21 +00:00
|
|
|
|
.BS 4 S.SOCKADDR.ADDR
|
|
|
|
|
.DA TCP.PORT.HTTP
|
2016-03-13 21:54:28 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
.DUMMY
|
|
|
|
|
.OR 0
|
|
|
|
|
DS.START
|
2018-04-16 15:25:39 +00:00
|
|
|
|
hLineBuf .BS 1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
hSrvSocket .BS 1
|
2019-03-02 22:18:21 +00:00
|
|
|
|
hClntSocket .BS 1
|
2016-03-13 21:54:28 +00:00
|
|
|
|
TimeOut .BS 1
|
|
|
|
|
DS.END
|
|
|
|
|
.ED
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
2018-11-17 17:17:13 +00:00
|
|
|
|
SAVE USR/SRC/SBIN/HTTPD.S
|
2016-03-13 21:54:28 +00:00
|
|
|
|
ASM
|