2016-03-13 21:54:28 +00:00
|
|
|
|
NEW
|
2018-04-16 15:25:39 +00:00
|
|
|
|
PREFIX /A2OSX.BUILD
|
|
|
|
|
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
|
|
|
|
|
.INB INC/LIBTCPIP.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
|
|
|
|
|
.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
|
|
|
|
|
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-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
|
2016-03-13 21:54:28 +00:00
|
|
|
|
sta hLIBTCPIP
|
|
|
|
|
|
|
|
|
|
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
|
2016-03-13 21:54:28 +00:00
|
|
|
|
|
|
|
|
|
.1 >LIBCALL hLIBTCPIP,LIBTCPIP.GET.IPCFG is TCPIP loaded ?
|
|
|
|
|
bcs .99
|
|
|
|
|
>STYA ZPIPCfgPtr
|
|
|
|
|
|
|
|
|
|
lda (ZPIPCfgPtr) Configured ?
|
|
|
|
|
bmi CS.RUN.INIT
|
|
|
|
|
|
2017-11-17 16:16:05 +00:00
|
|
|
|
>SLEEP
|
2016-03-13 21:54:28 +00:00
|
|
|
|
jsr Wait.Timeout
|
|
|
|
|
bcc .1
|
2018-04-16 15:25:39 +00:00
|
|
|
|
>SYSCALL GetChar
|
2017-01-28 22:05:20 +00:00
|
|
|
|
bcs .1
|
|
|
|
|
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
|
2018-04-16 15:25:39 +00:00
|
|
|
|
lda #0
|
|
|
|
|
clc
|
|
|
|
|
rts
|
2016-03-13 21:54:28 +00:00
|
|
|
|
|
|
|
|
|
.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
|
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
|
|
|
|
|
sta Socket.Src.Addr,x
|
|
|
|
|
dey
|
|
|
|
|
dex
|
|
|
|
|
bpl .1
|
|
|
|
|
|
2018-09-18 06:28:51 +00:00
|
|
|
|
>PUSHW L.Socket
|
2017-02-15 21:46:21 +00:00
|
|
|
|
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.New
|
2018-04-16 15:25:39 +00:00
|
|
|
|
bcs CS.RUN.RTS
|
2018-09-17 15:42:38 +00:00
|
|
|
|
|
|
|
|
|
>STA.G hSrvSocket
|
2016-03-13 21:54:28 +00:00
|
|
|
|
|
2018-04-16 15:25:39 +00:00
|
|
|
|
>LDYAI 256
|
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
|
|
|
|
|
2017-02-17 07:20:57 +00:00
|
|
|
|
ldy #SktIndex
|
|
|
|
|
lda (pData),y
|
|
|
|
|
tay
|
|
|
|
|
lda (pData),y hSockets
|
|
|
|
|
|
|
|
|
|
beq .3
|
|
|
|
|
|
2017-04-12 06:12:39 +00:00
|
|
|
|
jsr CS.RUN.CLIENT
|
2017-02-17 07:20:57 +00:00
|
|
|
|
|
|
|
|
|
.3 ldy #SktIndex
|
|
|
|
|
lda (pData),y
|
|
|
|
|
inc
|
|
|
|
|
cmp #CONN.MAX
|
|
|
|
|
bne .4
|
|
|
|
|
lda #0
|
|
|
|
|
|
|
|
|
|
.4 sta (pData),y
|
|
|
|
|
|
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
|
2017-10-26 16:01:54 +00:00
|
|
|
|
lda #K.E.SYN
|
2017-02-17 07:20:57 +00:00
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
CS.RUN.ERR sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN.SERVER ldy #hSrvSocket
|
2016-03-13 21:54:28 +00:00
|
|
|
|
lda (pData),y
|
|
|
|
|
|
2017-02-15 21:46:21 +00:00
|
|
|
|
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.AcceptA
|
2017-02-17 07:20:57 +00:00
|
|
|
|
bcs .8
|
2017-02-15 16:14:41 +00:00
|
|
|
|
pha
|
|
|
|
|
|
|
|
|
|
ldy #hSockets
|
|
|
|
|
ldx #CONN.MAX
|
|
|
|
|
|
2017-02-17 07:20:57 +00:00
|
|
|
|
.1 lda (pData),y
|
|
|
|
|
beq .2
|
2017-02-15 16:14:41 +00:00
|
|
|
|
iny
|
|
|
|
|
dex
|
2017-02-17 07:20:57 +00:00
|
|
|
|
bne .1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
|
|
|
|
|
pla
|
2017-02-15 21:46:21 +00:00
|
|
|
|
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.CloseA
|
2017-02-17 07:20:57 +00:00
|
|
|
|
bra .8
|
2017-02-15 16:14:41 +00:00
|
|
|
|
|
2017-02-17 07:20:57 +00:00
|
|
|
|
.2 pla
|
2017-02-15 16:14:41 +00:00
|
|
|
|
sta (pData),y
|
2017-04-12 06:12:39 +00:00
|
|
|
|
sta .4+1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
|
2017-02-15 21:46:21 +00:00
|
|
|
|
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.GetA
|
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
|
|
|
|
|
ldy #S.SOCKET.DST.ADDR+3
|
|
|
|
|
|
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
|
|
|
|
|
2017-04-12 06:12:39 +00:00
|
|
|
|
.4 lda #$ff
|
|
|
|
|
>PUSHA
|
|
|
|
|
|
2016-03-13 21:54:28 +00:00
|
|
|
|
>LDYA L.MSG.INCOMING
|
2018-06-21 15:12:10 +00:00
|
|
|
|
>SYSCALL printf
|
2017-02-17 07:20:57 +00:00
|
|
|
|
.8 clc
|
|
|
|
|
.9 rts
|
2016-03-13 21:54:28 +00:00
|
|
|
|
*--------------------------------------
|
2017-04-12 06:12:39 +00:00
|
|
|
|
CS.RUN.CLIENT sta hClntSocket
|
2018-04-16 15:25:39 +00:00
|
|
|
|
|
2017-04-12 06:12:39 +00:00
|
|
|
|
>PUSHA hSocket
|
2018-04-16 15:25:39 +00:00
|
|
|
|
>PUSHW ZPLinePtr
|
2017-02-15 16:14:41 +00:00
|
|
|
|
>PUSHWI 256
|
|
|
|
|
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.GetS
|
2017-02-17 22:04:53 +00:00
|
|
|
|
bcs .1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
|
2018-04-16 15:25:39 +00:00
|
|
|
|
>PUSHW ZPLinePtr
|
2018-06-21 15:12:10 +00:00
|
|
|
|
>SYSCALL printf
|
2017-02-15 16:14:41 +00:00
|
|
|
|
|
2017-04-12 06:12:39 +00:00
|
|
|
|
>PUSHB hClntSocket
|
|
|
|
|
>PUSHW L.HTTP.200OK
|
|
|
|
|
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.PutS
|
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
.1 clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-01-28 22:05:20 +00:00
|
|
|
|
CS.DOEVENT sec
|
2016-03-13 21:54:28 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-02-15 16:14:41 +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
|
2016-03-13 21:54:28 +00:00
|
|
|
|
lda (pData),y
|
|
|
|
|
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.CLOSEA
|
|
|
|
|
|
2018-04-16 15:25:39 +00:00
|
|
|
|
>LDA.G hLineBuf
|
|
|
|
|
beq .3
|
|
|
|
|
|
2018-07-18 15:30:42 +00:00
|
|
|
|
>SYSCALL FreeMem
|
2018-04-16 15:25:39 +00:00
|
|
|
|
|
|
|
|
|
.3 lda hLIBTCPIP
|
2018-07-20 14:10:10 +00:00
|
|
|
|
>SYSCALL UnloadLib
|
2016-03-13 21:54:28 +00:00
|
|
|
|
clc
|
|
|
|
|
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
|
|
|
|
|
*--------------------------------------
|
2018-04-16 15:25:39 +00:00
|
|
|
|
LIBTCPIP .AZ "libtcpip.o"
|
2018-04-11 15:35:51 +00:00
|
|
|
|
MSG.TCPWAIT .AZ "HTTPD:Waiting for TCP/IP initializing...\r\n"
|
|
|
|
|
MSG.INITOK .AZ "HTTPD:Init Ok, Listening.\r\n"
|
|
|
|
|
MSG.TCPIPERR .AZ "HTTPD:TCP/IP Not initialized properly\r\n"
|
|
|
|
|
MSG.SKTERR .AZ "HTTPD:Listen Error\r\n"
|
|
|
|
|
MSG.ABORT .AZ "HTTPD:User Aborted\r\n"
|
|
|
|
|
MSG.INCOMING .AZ "HTTPD:Incoming Connection [SKT=%h] From : %d.%d.%d.%d\r\n"
|
2016-03-13 21:54:28 +00:00
|
|
|
|
hLIBTCPIP .BS 1
|
2017-04-12 06:12:39 +00:00
|
|
|
|
hClntSocket .BS 1
|
|
|
|
|
*--------------------------------------
|
2018-04-16 15:25:39 +00:00
|
|
|
|
HTTP.200OK .AZ "HTTP/1.1 200 OK\r\n"
|
2016-03-13 21:54:28 +00:00
|
|
|
|
*--------------------------------------
|
2018-09-28 15:24:44 +00:00
|
|
|
|
Socket .DA #S.SOCKET.T.STREAM
|
|
|
|
|
.DA #S.SOCKET.O.ACCEPTCONN
|
|
|
|
|
.DA #S.SOCKET.TCP.S.LISTEN
|
2016-03-13 21:54:28 +00:00
|
|
|
|
.BS 1
|
|
|
|
|
Socket.Src.Addr .BS 4
|
|
|
|
|
Socket.Src.Port .DA 80
|
|
|
|
|
Socket.Dst.Addr .BS 4
|
|
|
|
|
Socket.Dst.Port .BS 2
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
.DUMMY
|
|
|
|
|
.OR 0
|
|
|
|
|
DS.START
|
2017-02-15 16:14:41 +00:00
|
|
|
|
hSockets .BS CONN.MAX pData
|
2018-04-16 15:25:39 +00:00
|
|
|
|
hLineBuf .BS 1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
SktIndex .BS 1
|
|
|
|
|
hSrvSocket .BS 1
|
2016-03-13 21:54:28 +00:00
|
|
|
|
TimeOut .BS 1
|
|
|
|
|
DS.END
|
|
|
|
|
.ED
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
2017-03-29 15:48:15 +00:00
|
|
|
|
SAVE /A2OSX.SRC/SBIN/HTTPD.S
|
2016-03-13 21:54:28 +00:00
|
|
|
|
ASM
|