Kernel 0.9.2

This commit is contained in:
Rémy GIBERT 2018-09-17 17:42:38 +02:00
parent 5916df2322
commit 5ddf499055
19 changed files with 227 additions and 291 deletions

View File

@ -53,12 +53,18 @@
Y,A = PTR to DNS.CACHE
# SKT.New
Create a new socket
**In:**
PUSHW = PTR to S.SOCKET template
**Out:**
Y,A = PTR to new S.SOCKET
X = hSocket
Create a new socket
## C
`hSOCKET skt.new(void *template);`
## ASM
**In:**
`>LDYA template`
`>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.New`
**Out:**
CC: A = hSOCKET
CS: A = EC
# SKT.Close
Close socket
@ -87,11 +93,17 @@
A = hSocket
# SKT.MkNod
Create a new file from TCP socket
**In:**
A = hSocket
**Out:**
A = hFile
## C
`hFD skt.mknod(hSOCKET *s);`
## ASM
**In:**
`>LDYA s`
`>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.MkNod`
**Out:**
CC: A = hFD
CS: A = EC
# SKT.Read (STREAM)
@ -103,7 +115,7 @@
`>PUSHWI count`
`>PUSHW buf`
`lda fd`
`>SYSCALL read`
`>LIBCALL hLIBTCPIP,LIBTCPIP.skt.read`
**Out:**
CC: Y,A = bytes read
CS: A = EC
@ -118,7 +130,7 @@ CS: A = EC
`>PUSHWI count`
`>PUSHW buf`
`lda fd`
`>SYSCALL write`
`>LIBCALL hLIBTCPIP,LIBTCPIP.skt.write`
**Out:**
CC: Y,A = bytes written
CS: A = EC
@ -130,7 +142,16 @@ CS: A = EC
A = hFrame
# SKT.Send (DGRAM,RAW)
**In:**
A = hSocket
**Out:**
A = hFrame
## C
`int skt.send(hFD fd, const void *buf, int count);`
## ASM
**In:**
`>PUSHWI count`
`>PUSHW buf`
`lda fd`
`>LIBCALL hLIBTCPIP,LIBTCPIP.skt.send`
**Out:**
CC: Y,A = bytes written
CS: A = EC

Binary file not shown.

Binary file not shown.

View File

@ -161,7 +161,7 @@ CS.RUN.OPENSKT ldx #3
sta Socket.Dst.Port+1
sta (pData),y
>PUSHW L.Socket
>LDYA L.Socket
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.New
bcc .2
@ -171,8 +171,7 @@ CS.RUN.OPENSKT ldx #3
sec
rts
.2 txa
>STA.G hSocket
.2 >STA.G hSocket
CS.RUN.SEND.ECHO
ldy #Identifier
@ -197,10 +196,9 @@ CS.RUN.SEND.ECHO
jsr Init.Timeout
>PUSHB.G hSocket
>PUSHW L.ICMP.Request
>PUSHWI ICMP.RequestLen
>PUSHW L.ICMP.Request
>LDA.G hSocket
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.Send
bcs CS.RUN.ERR

View File

@ -106,9 +106,7 @@ CS.RUN jsr Init.Timeout
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.New
bcs .91
txa
ldy #hSocket
sta (pData),y
>STA.G hSocket
ldx #3
@ -117,10 +115,9 @@ CS.RUN jsr Init.Timeout
dex
bpl .21
.3 ldy #hSocket
>PUSHB (pData),y
.3 >PUSHWI RPC.Request.End-RPC.Request
>PUSHW L.RPC.Request
>PUSHWI RPC.Request.End-RPC.Request
>LDA.G hSocket
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.Send
bcc .4
@ -131,8 +128,7 @@ CS.RUN jsr Init.Timeout
.4 jsr Init.Timeout
.5 ldy #hSocket
lda (pData),y
.5 >LDA.G hSocket
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.Rcvd
bcc .6

View File

@ -154,8 +154,7 @@ CS.RUN.OPENSKT ldx #3
sec
.9 rts
.2 txa
>STA.G hSocket
.2 >STA.G hSocket
>LDYA L.MSG.SKTOK
>SYSCALL puts

View File

@ -218,15 +218,14 @@ S.ICMP.SEQUENCE .EQ S.IP+6
*
S.ICMP .EQ S.IP+8
*--------------------------------------
S.UDP.SRCPORT .EQ S.IP+0
S.UDP.DSTPORT .EQ S.IP+2
S.TCPUDP.SRCPORT .EQ S.IP+0
S.TCPUDP.DSTPORT .EQ S.IP+2
*--------------------------------------
S.UDP.LENGTH .EQ S.IP+4
S.UDP.CHECKSUM .EQ S.IP+6 $0000 = DISABLE
*
S.UDP .EQ S.IP+8
*--------------------------------------
S.TCP.SRCPORT .EQ S.IP+0
S.TCP.DSTPORT .EQ S.IP+2
S.TCP.SEQNUM .EQ S.IP+4
S.TCP.ACKNUM .EQ S.IP+8
S.TCP.DATAOFFSET .EQ S.IP+12

View File

@ -513,7 +513,7 @@ SET.IPCFG.I >LDYA L.DCB.NIC
stz DNS.SOCKET.SP
stz DNS.SOCKET.SP+1
>PUSHW L.DNS.SOCKET
>LDYA L.DNS.SOCKET
jsr SKT.New
bcs .9
@ -532,7 +532,7 @@ SET.IPCFG.I >LDYA L.DCB.NIC
stz DNS.SOCKET.SP
stz DNS.SOCKET.SP+1
>PUSHW L.DNS.SOCKET
>LDYA L.DNS.SOCKET
jsr SKT.New
bcs .9

View File

@ -102,7 +102,6 @@ DNS.REQUEST lda hDNSSocket1
beq .8
jsr DNS.REQUEST.SEND
jsr SKT.Send
bcc .8
.99 lda #ERR.DNS.ERROR
@ -114,9 +113,10 @@ DNS.REQUEST lda hDNSSocket1
rts
*--------------------------------------
DNS.REQUEST.SEND
>PUSHA
>PUSHW L.DNS.MSG
pha
>PUSHW DNS.MSG.LEN
>PUSHW L.DNS.MSG
pla
jmp SKT.Send
*--------------------------------------
DNS.CSTR2DNS lda (ZPPtrDNS)
@ -532,7 +532,7 @@ DNS.DecodeMsg sta hFrameIn
jsr DNS.UPDATE.BY.ID
.9 lda hFrameIn
* >SYSCALL FreeMem
>SYSCALL FreeMem
clc
rts
*--------------------------------------

View File

@ -73,7 +73,7 @@ ICMP.IN.EXIT lda hFrameIn
>SYSCALL FreeMem
.8 rts
*--------------------------------------
ICMP.IN.ECHOREP jsr IP.FillSKT.TemplateSrcDst
ICMP.IN.ECHOREP jsr IP.FillSKT.TemplateSrcDstIP
lda #S.IP.PROTOCOL.ICMP
sta SKT.Template+S.SOCKET.RAW.PROTO

View File

@ -91,7 +91,22 @@ IP.ComputeChecksum
eor #$FF
rts
*--------------------------------------
IP.FillSKT.TemplateSrcDst
IP.FillSKT.TemplateSrcDstIPP
ldy #S.TCPUDP.SRCPORT
lda (ZPFrameInPtr),y
sta SKT.Template+S.SOCKET.DST.PORT+1
iny
lda (ZPFrameInPtr),y
sta SKT.Template+S.SOCKET.DST.PORT
iny #S.TCPUDP.DSTPORT
lda (ZPFrameInPtr),y
sta SKT.Template+S.SOCKET.SRC.PORT+1
iny
lda (ZPFrameInPtr),y
sta SKT.Template+S.SOCKET.SRC.PORT
*--------------------------------------
IP.FillSKT.TemplateSrcDstIP
ldy #S.IP.SRC+3
ldx #3
.1 lda (ZPFrameInPtr),y

View File

@ -4,21 +4,27 @@ AUTO 4,1
.LIST OFF
*/--------------------------------------
* # SKT.New
* Create a new socket
* **In:**
* PUSHW = PTR to S.SOCKET template
* **Out:**
* Y,A = PTR to new S.SOCKET
* X = hSocket
* Create a new socket
* ## C
* `hSOCKET skt.new(void *template);`
* ## ASM
* **In:**
* `>LDYA template`
* `>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.New`
* **Out:**
* CC: A = hSOCKET
* CS: A = EC
*\--------------------------------------
SKT.New >PULLW ZPTmpPtr1
ldy #S.SOCKET.SRC.PORT+1
SKT.New >STYA ZPTmpPtr1
ldy #S.SOCKET.SRC.PORT
lda (ZPTmpPtr1),y
dey
iny
ora (ZPTmpPtr1),y
bne .1
jsr GetDynPort
ldy #S.SOCKET.SRC.PORT
sta (ZPTmpPtr1),y
txa
iny
@ -101,8 +107,7 @@ SKT.New >PULLW ZPTmpPtr1
.8 lda TmpByte
ora #$80
tax
>LDYA ZPPtrSKT
clc
rts
@ -293,33 +298,20 @@ SKT.Accept jsr SKT.Get.I
.9 rts
*/--------------------------------------
* # SKT.MkNod
* Create a new file from TCP socket
* **In:**
* A = hSocket
* **Out:**
* A = hFile
* ## C
* `hFD skt.mknod(hSOCKET *s);`
* ## ASM
* **In:**
* `>LDYA s`
* `>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.MkNod`
* **Out:**
* CC: A = hFD
* CS: A = EC
*\--------------------------------------
SKT.MkNod sta .1+1
SKT.MkNod sta FD.SSOCK+S.FD.SSOCK.HSKT
>LDYAI S.FD.SSOCK
>SYSCALL getmem0
bcs .9
>STYA ZPTmpPtr1
ldy #S.FD.T
lda #S.FD.T.SSOCK
sta (ZPTmpPtr1),y
ldy #S.FD.SSOCK.HSKT
.1 lda #$ff
sta (ZPTmpPtr1),y
>LDYA ZPTmpPtr1
rts
bcs .9
>STYA ZPTmpPtr1
@ -330,6 +322,7 @@ SKT.MkNod sta .1+1
sta (ZPTmpPtr1),y
dey
bpl .2
txa
* clc
@ -343,7 +336,7 @@ SKT.MkNod sta .1+1
* `>PUSHWI count`
* `>PUSHW buf`
* `lda fd`
* `>SYSCALL read`
* `>LIBCALL hLIBTCPIP,LIBTCPIP.skt.read`
* **Out:**
* CC: Y,A = bytes read
* CS: A = EC
@ -393,7 +386,7 @@ SKT.Read.I jsr SKT.Get.I
* `>PUSHWI count`
* `>PUSHW buf`
* `lda fd`
* `>SYSCALL write`
* `>LIBCALL hLIBTCPIP,LIBTCPIP.skt.write`
* **Out:**
* CC: Y,A = bytes written
* CS: A = EC
@ -475,17 +468,25 @@ SKT.Rcvd jsr SKT.Get.I
.9 rts
*/--------------------------------------
* # SKT.Send (DGRAM,RAW)
* **In:**
* A = hSocket
* **Out:**
* A = hFrame
* ## C
* `int skt.send(hFD fd, const void *buf, int count);`
* ## ASM
* **In:**
* `>PUSHWI count`
* `>PUSHW buf`
* `lda fd`
* `>LIBCALL hLIBTCPIP,LIBTCPIP.skt.send`
* **Out:**
* CC: Y,A = bytes written
* CS: A = EC
*\--------------------------------------
SKT.Send >PULLW ZPDataInLen
SKT.Send pha
>PULLW ZPDataInPtr
>PULLA
>PULLW ZPDataInLen
pla
jsr SKT.Get.I
bcs .9
bcs SKT.Send.9
cmp #S.SOCKET.SOCK.DGRAM
beq SKT.Send.UDP
@ -495,7 +496,7 @@ SKT.Send >PULLW ZPDataInLen
lda #ERR.SKT.BAD
sec
.9 rts
SKT.Send.9 rts
*--------------------------------------
SKT.Send.RAW ldy #S.SOCKET.RAW.PROTO
lda (ZPPtrSKT),y
@ -503,50 +504,22 @@ SKT.Send.RAW ldy #S.SOCKET.RAW.PROTO
tax
>LDYA ZPDataInLen
jsr FRM.NewIP
bcs .9
bcs SKT.Send.9
jsr SKT.SetFrameOutDstIP
jsr SKT.CopyDataInToOut
jmp FRM.SendIP
.9 rts
bra SKT.Send.UDP.8
*--------------------------------------
SKT.Send.UDP ldx #S.IP.PROTOCOL.UDP
>LDYA ZPDataInLen
jsr FRM.NewIP
bcs .9
bcs SKT.Send.9
jsr SKT.SetFrameOutDstIP
jsr SKT.SetFrameOutTCPUDPPorts
ldy #S.SOCKET.SRC.PORT
lda (ZPPtrSKT),y
tax
iny
lda (ZPPtrSKT),y
ldy #S.UDP.SRCPORT
sta (ZPFrameOutPtr),y
iny
txa
sta (ZPFrameOutPtr),y
SKT.Send.UDP.8 jsr SKT.SetFrameOutDstIP
ldy #S.SOCKET.DST.PORT
lda (ZPPtrSKT),y
tax
iny
lda (ZPPtrSKT),y
ldy #S.UDP.DSTPORT
sta (ZPFrameOutPtr),y
iny
txa
sta (ZPFrameOutPtr),y
jsr SKT.CopyDataInToOut
jmp FRM.SendIP
.9 rts
*--------------------------------------
* PRIVATE
*--------------------------------------
@ -1185,6 +1158,31 @@ SKT.SetFrameOutDstIP
bne .2
rts
*--------------------------------------
SKT.SetFrameOutTCPUDPPorts
ldy #S.SOCKET.SRC.PORT
lda (ZPPtrSKT),y
tax
iny
lda (ZPPtrSKT),y
ldy #S.TCPUDP.SRCPORT
sta (ZPFrameOutPtr),y
iny
txa
sta (ZPFrameOutPtr),y
ldy #S.SOCKET.DST.PORT
lda (ZPPtrSKT),y
tax
iny
lda (ZPPtrSKT),y
ldy #S.TCPUDP.DSTPORT
sta (ZPFrameOutPtr),y
iny
txa
sta (ZPFrameOutPtr),y
rts
*--------------------------------------
SKT.CopyDataInToOut
lda ZPDataInPtr+1
pha

View File

@ -3,21 +3,7 @@ PREFIX /A2OSX.BUILD
AUTO 4,1
.LIST OFF
*--------------------------------------
TCP.IN jsr IP.FillSKT.TemplateSrcDst
ldy #S.TCP.SRCPORT
lda (ZPFrameInPtr),y
sta SKT.Template+S.SOCKET.DST.PORT+1
iny
lda (ZPFrameInPtr),y
sta SKT.Template+S.SOCKET.DST.PORT
ldy #S.TCP.DSTPORT
lda (ZPFrameInPtr),y
sta SKT.Template+S.SOCKET.SRC.PORT+1
iny
lda (ZPFrameInPtr),y
sta SKT.Template+S.SOCKET.SRC.PORT
TCP.IN jsr IP.FillSKT.TemplateSrcDstIPP
lda hSocketTable
>SYSCALL GetMemPtr
@ -96,7 +82,7 @@ TCP.IN.JMP.LISTEN
stz SKT.Template+S.SOCKET.SO
stz SKT.Template+S.SOCKET.TCP.STATUS
>PUSHW L.SKT.Template
>LDYA L.SKT.Template
jsr SKT.New Assign OUTNEXTSEQ
bcs .99
@ -505,27 +491,7 @@ TCP.NewFrame ldx #S.IP.PROTOCOL.TCP
jsr SKT.SetFrameOutDstIP
ldy #S.SOCKET.SRC.PORT
lda (ZPPtrSKT),y
tax
iny
lda (ZPPtrSKT),y
ldy #S.TCP.SRCPORT
sta (ZPFrameOutPtr),y
iny
txa
sta (ZPFrameOutPtr),y
ldy #S.SOCKET.DST.PORT
lda (ZPPtrSKT),y
tax
iny
lda (ZPPtrSKT),y
ldy #S.TCP.DSTPORT
sta (ZPFrameOutPtr),y
iny
txa
sta (ZPFrameOutPtr),y
jsr SKT.SetFrameOutTCPUDPPorts
ldy #S.TCP.DATAOFFSET
lda #$50 Header size = 5 DWORDS

View File

@ -3,21 +3,7 @@ PREFIX /A2OSX.BUILD
AUTO 4,1
.LIST OFF
*--------------------------------------
UDP.IN jsr IP.FillSKT.TemplateSrcDst
ldy #S.UDP.SRCPORT
lda (ZPFrameInPtr),y
sta SKT.Template+S.SOCKET.DST.PORT+1
iny
lda (ZPFrameInPtr),y
sta SKT.Template+S.SOCKET.DST.PORT
ldy #S.UDP.DSTPORT
lda (ZPFrameInPtr),y
sta SKT.Template+S.SOCKET.SRC.PORT+1
iny
lda (ZPFrameInPtr),y
sta SKT.Template+S.SOCKET.SRC.PORT
UDP.IN jsr IP.FillSKT.TemplateSrcDstIPP
lda hSocketTable
>SYSCALL GetMemPtr

View File

@ -287,9 +287,9 @@ FD.SSOCK .BS 1 S.FD.HANDLER
.BS 1 S.FD.SSOCK.HSKT
.DA #0 S.FD.SSOCK.OPEN
.DA #0 S.FD.SSOCK.CLOSE
.DA #0
.DA #0
.DA #0 S.FD.SSOCK.STATUS
.DA #LIBTCPIP.SKT.Read
.DA #LIBTCPIP.SKT.Write
.DA #0 S.FD.SSOCK.STATUS
*--------------------------------------
IOCTL .BS S.IOCTL
DCB.NIC .BS S.DCB.NIC
@ -297,8 +297,7 @@ IPCFG .BS S.IPCFG
ARP.CACHE .BS K.ARPCACHE.SIZE*S.ARPCACHE
DNS.CACHE .BS K.DNSCACHE.SIZE*S.DNSCACHE
*--------------------------------------
ARP.REQ .EQ *
ARP.REQ.DSTMAC .HS FFFFFFFFFFFF
ARP.REQ .HS FFFFFFFFFFFF S.ETH.DSTMAC
ARP.REQ.SRCMAC .BS 6
ARP.REQ.ETYPE .DA /S.ETH.ETHERTYPE.ARP
.DA #S.ETH.ETHERTYPE.ARP

View File

@ -108,7 +108,7 @@ CS.INIT >LDYA L.LIBTCPIP
sec
rts
*--------------------------------------
CS.RUN >PUSHW L.Socket
CS.RUN >LDYA L.Socket
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.New
bcc .1
@ -122,9 +122,9 @@ CS.RUN >PUSHW L.Socket
jsr Init.Timeout
CS.RUN.SDISC >PUSHB.G hSocket
CS.RUN.SDISC >PUSHWI DHCP.DISC.LEN
>PUSHW L.DHCP.DISC
>PUSHWI DHCP.DISC.LEN
>LDA.G hSocket
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.Send
bcc .1
jmp CS.RUN.KO
@ -159,9 +159,9 @@ CS.RUN.SREQ ldx #3
>LDYA L.MSG.CFG2
>SYSCALL printf
>PUSHB.G hSocket
>PUSHW L.DHCP.REQ
>PUSHWI DHCP.REQ.LEN
>PUSHW L.DHCP.REQ
>LDA.G hSocket
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.Send
bcs CS.RUN.KO

View File

@ -98,12 +98,11 @@ CS.RUN.INIT ldx #3
dex
bpl .1
>PUSHW L.Socket
>LDYA L.Socket
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.New
bcs CS.RUN.RTS
txa
ldy #hSrvSocket
sta (pData),y
>STA.G hSrvSocket
>LDYAI 256
>SYSCALL getmem

View File

@ -85,12 +85,11 @@ CS.RUN.INIT ldx #3
dex
bpl .1
>PUSHW L.Socket
>LDYA L.Socket
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.New
bcs .9
txa
ldy #hSocket
sta (pData),y
>STA.G hSocket
>LDYA L.MSG.INITOK
>SYSCALL printf

View File

@ -11,8 +11,8 @@ AUTO 4,1
.INB INC/ETH.I
.INB INC/LIBTCPIP.I
*--------------------------------------
TIMEOUT.MAX .EQ 30 30 sec.
CONN.MAX .EQ 16
TIMEOUT.MAX .EQ 30 30 sec.
*--------------------------------------
ZPIPCfgPtr .EQ ZPBIN
ZPSktPtr .EQ ZPBIN+2
@ -23,7 +23,8 @@ CS.START cld
jmp (.1,x)
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
.DA 0
.DA #S.PS.F.EVENT S.PS.F
.DA #0
.DA CS.END-CS.START CS
.DA DS.END-DS.START DS
.DA #64 SS
@ -44,7 +45,6 @@ L.MSG.TCPIPERR .DA MSG.TCPIPERR
L.MSG.SKTERR .DA MSG.SKTERR
L.MSG.ABORT .DA MSG.ABORT
L.MSG.INCOMING .DA MSG.INCOMING
L.MSG.BYTE .DA MSG.BYTE
.DA 0
*--------------------------------------
CS.INIT >LDYA L.LIBTCPIP
@ -54,13 +54,14 @@ CS.INIT >LDYA L.LIBTCPIP
lda (pPs)
ora #S.PS.F.EVENT Now accept events
sta (pPs)
clc
rts
*--------------------------------------
CS.RUN jsr Init.Timeout
>LDYA L.MSG.TCPWAIT
>SYSCALL printf
>SYSCALL puts
.1 >LIBCALL hLIBTCPIP,LIBTCPIP.GET.IPCFG is TCPIP loaded ?
bcs .99
@ -78,9 +79,10 @@ CS.RUN jsr Init.Timeout
bne .1
jmp CS.RUN.ABORT
.99 >LDYA L.MSG.TCPIPERR
>SYSCALL printf
lda #K.E.SYN
.99 pha
>LDYA L.MSG.TCPIPERR
>SYSCALL puts
pla
sec
rts
@ -92,42 +94,46 @@ CS.RUN.INIT ldx #3
dex
bpl .1
>PUSHW L.Socket
>LDYA L.Socket
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.New
bcs .9
txa
ldy #hSrvSocket
sta (pData),y
>STA.G hSrvSocket
>LDYA L.MSG.INITOK
>SYSCALL printf
>SYSCALL puts
.2 >SLEEP
jsr CS.RUN.SERVER
bcs CS.RUN.ERR
* >SYSCALL GetChar
* bcs .2
jsr CS.RUN.CLIENT
* cmp #$03
* beq CS.RUN.ABORT
bra .2
.9 >LDYA L.MSG.SKTERR
>SYSCALL printf
lda #K.E.SYN
.9 pha
>LDYA L.MSG.SKTERR
>SYSCALL puts
pla
sec
rts
CS.RUN.ABORT >LDYA L.MSG.ABORT
>SYSCALL printf
lda #0
>SYSCALL puts
lda #3
CS.RUN.ERR sec
rts
*--------------------------------------
CS.RUN.SERVER ldy #hSrvSocket
lda (pData),y
CS.RUN.SERVER >LDA.G hSrvSocket
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.AcceptA
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.Accept
bcs .8
pha
>STA.G hClientSocket
ldy #hSockets
ldx #CONN.MAX
@ -138,15 +144,12 @@ CS.RUN.SERVER ldy #hSrvSocket
dex
bne .1
pla
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.CloseA
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.Close
bra .8
.2 pla
sta (pData),y
sta .4+1
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.GetA
.2 sta (pData),y
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.Get
>STYA ZPSktPtr
ldx #3
@ -157,74 +160,32 @@ CS.RUN.SERVER ldy #hSrvSocket
dex
bpl .3
.4 lda #$ff
>PUSHA
>PUSHB.G hClientSocket
>PUSHBI 5
>LDYA L.MSG.INCOMING
>SYSCALL printf
bcs .9
>LDA.G hClientSocket
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.MkNod
bcs .9
.8 clc
.9 rts
*--------------------------------------
CS.RUN.CLIENT ldy #SktIndex
lda (pData),y
tay
lda (pData),y hSockets
beq .8
CS.DOEVENT lda (pEvent)
bpl .9 is it a TIMER event?
sta .1+1 hSocket
sta .3+1
>LDA.G TimeOut
beq .9
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.GetC
bcc .10
tax
beq .8 NO DATA
cmp #ERR.SKT.BAD
bne .8
ldy #SktIndex
lda (pData),y
tay
lda #0
dec
sta (pData),y
bra .8
.10 sta .2+1
>PUSHA
>LDYA L.MSG.BYTE
>SYSCALL printf
.1 lda #$ff hSocket
>PUSHA
.2 lda #$ff data
and #$7F
ora #$20
>PUSHA
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.PutC
.3 lda #$ff hSocket
>PUSHA
lda #'/'
>PUSHA
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.PutC
.8 ldy #SktIndex
lda (pData),y
inc
cmp #CONN.MAX
bne .81
lda #0
.81 sta (pData),y
clc
rts
*--------------------------------------
CS.DOEVENT sec
.9 sec do not discard TIMER event
rts
*--------------------------------------
CS.QUIT ldx #CONN.MAX
@ -235,7 +196,7 @@ CS.QUIT ldx #CONN.MAX
phx
phy
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.CLOSEA
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.Close
ply
plx
@ -246,7 +207,7 @@ CS.QUIT ldx #CONN.MAX
ldy #hSrvSocket
lda (pData),y
beq .3
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.CLOSEA
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.Close
.3 lda hLIBTCPIP
>SYSCALL UnloadLib
@ -267,15 +228,14 @@ Wait.TimeOut sec
*--------------------------------------
CS.END
*--------------------------------------
LIBTCPIP .AZ "libtcpip.o"
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]"
hLIBTCPIP .BS 1
LIBTCPIP .AZ "libtcpip.o"
MSG.TCPWAIT .AZ "TELNETD:Waiting for TCP/IP initializing..."
MSG.INITOK .AZ "TELNETD:Init Ok, Listening."
MSG.TCPIPERR .AZ "TELNETD:TCP/IP Not initialized properly"
MSG.SKTERR .AZ "TELNETD:Listen Error."
MSG.ABORT .AZ "TELNETD:User Aborted."
MSG.INCOMING .AZ "TELNETD:Incoming Connection [SKT=%h] From : %d.%d.%d.%d\r\n"
*--------------------------------------
Socket .DA #S.SOCKET.SOCK.STREAM
.DA #S.SOCKET.SO.ACCEPTCONN
@ -292,6 +252,7 @@ DS.START
hSockets .BS CONN.MAX pData
SktIndex .BS 1
hSrvSocket .BS 1
hClientSocket .BS 1
TimeOut .BS 1
DS.END
.ED