A2osX/LIB/LIBTCPIP.S.CFG.txt

531 lines
8.8 KiB
Plaintext
Raw Normal View History

2017-12-22 21:24:30 +00:00
NEW
2018-11-17 17:17:13 +00:00
PREFIX
2017-12-22 21:24:30 +00:00
AUTO 4,1
.LIST OFF
*--------------------------------------
* PULLW = PTR to S.IPCFG
*--------------------------------------
2018-08-08 15:13:37 +00:00
CFG.Init >PUSHBI 0
>LDYA L.DEVNAME
>SYSCALL open
2018-07-26 15:26:39 +00:00
bcc .1
2018-08-08 15:13:37 +00:00
inc DEVNAME+8
lda DEVNAME+8
2018-07-26 15:26:39 +00:00
cmp #'8'
bne CFG.Init
2018-07-23 15:28:42 +00:00
2018-07-26 15:26:39 +00:00
>LDYA L.MSG.DEV.KO
2018-08-23 15:16:20 +00:00
>SYSCALL puts
2018-07-26 15:26:39 +00:00
lda #MLI.E.NODEV
.9 sec
rts
2018-08-08 15:13:37 +00:00
.1 sta IPCFG+S.IPCFG.hFD
2018-07-26 15:26:39 +00:00
>PUSHW L.DEVNAME
2018-08-23 15:16:20 +00:00
>PUSHBI 2
2018-07-26 15:26:39 +00:00
>LDYA L.MSG.DEV.OK
>SYSCALL printf
2018-08-08 15:13:37 +00:00
CFG.EtcFiles >LDYAI 256
>SYSCALL GetMem
2018-09-10 15:07:26 +00:00
bcs .9
>STYA ZPTmpPtr1
stx CFG.hBuf1
2018-07-23 06:28:47 +00:00
2018-09-10 15:07:26 +00:00
>LDYA L.HOSTNAME
jsr CFG.Read.PrintF
2018-07-26 15:26:39 +00:00
jsr CFG.Read.HOSTNAME
lda IPCFG+S.IPCFG.HOSTNAME
bne .4
ldy #$ff
.2 iny
2018-08-08 15:13:37 +00:00
lda CFG.DefaultHost,y
2018-07-26 15:26:39 +00:00
sta IPCFG+S.IPCFG.HOSTNAME,y
bne .2
.3 lda A2osX.TIMER16
jsr CFG.A2CharAX
sta IPCFG+S.IPCFG.HOSTNAME+6
stx IPCFG+S.IPCFG.HOSTNAME+7
lda A2osX.TIMER16+1
jsr CFG.A2CharAX
sta IPCFG+S.IPCFG.HOSTNAME+8
stx IPCFG+S.IPCFG.HOSTNAME+9
2018-10-09 15:47:06 +00:00
2018-09-10 15:07:26 +00:00
.4 >LDYA L.TCPIP.CONF
jsr CFG.Read.PrintF
2018-07-26 15:26:39 +00:00
jsr CFG.Read.TCPIP.CONF
2018-10-09 15:47:06 +00:00
2018-08-08 15:13:37 +00:00
lda IPCFG+S.IPCFG.IP
beq .5
lda #S.IPCFG.STATUS.OK
sta IPCFG+S.IPCFG.STATUS
2018-09-10 15:07:26 +00:00
.5 >LDYA L.HOSTS
jsr CFG.Read.PrintF
2018-07-26 15:26:39 +00:00
jsr CFG.Read.HOSTS
2018-08-08 15:13:37 +00:00
jsr SET.IPCFG.I
2018-09-10 15:07:26 +00:00
lda CFG.hBuf1
2018-08-08 15:13:37 +00:00
>SYSCALL freemem
.9 rts
2018-07-26 15:26:39 +00:00
*--------------------------------------
2018-09-10 15:07:26 +00:00
CFG.Read.PrintF >PUSHYA
>PUSHBI 2
>LDYA L.MSG.CFG
>SYSCALL printf
rts
*--------------------------------------
2018-07-26 15:26:39 +00:00
CFG.Read.HOSTNAME
>LDYA L.HOSTNAME
2018-08-08 15:13:37 +00:00
jsr CFG.Read.Open
jsr CFG.Read.Result
2018-07-26 15:26:39 +00:00
bcs .9
2018-08-08 15:13:37 +00:00
.1 jsr CFG.Read.GetS
bcs .8
2018-07-26 15:26:39 +00:00
2018-08-08 15:13:37 +00:00
lda (ZPTmpPtr1)
beq .1 empty line...
cmp #'#
beq .1 comment...
2018-07-26 15:26:39 +00:00
2018-08-08 15:13:37 +00:00
ldy #0
2018-07-26 15:26:39 +00:00
.2 lda (ZPTmpPtr1),y
sta IPCFG+S.IPCFG.HOSTNAME,y
2018-08-08 15:13:37 +00:00
beq .8 end of name
2018-07-26 15:26:39 +00:00
iny
2018-08-08 15:13:37 +00:00
cpy #15
2018-07-26 15:26:39 +00:00
bne .2
2018-08-08 15:13:37 +00:00
.8 clc
.HS B0 BCS
.9 sec
jmp CFG.Read.Close
2018-07-26 15:26:39 +00:00
*--------------------------------------
CFG.Read.TCPIP.CONF
>LDYA L.TCPIP.CONF
2018-08-08 15:13:37 +00:00
jsr CFG.Read.Open
jsr CFG.Read.Result
2018-07-26 15:26:39 +00:00
bcs .9
2018-08-08 15:13:37 +00:00
.1 jsr CFG.Read.GetS
2018-07-26 15:26:39 +00:00
bcs .8
2018-08-08 15:13:37 +00:00
lda (ZPTmpPtr1)
beq .1 empty line...
cmp #'#
beq .1 comment...
2018-07-26 15:26:39 +00:00
2018-08-08 15:13:37 +00:00
ldy #$ff
2018-07-26 15:26:39 +00:00
2018-08-08 15:13:37 +00:00
.2 iny
lda (ZPTmpPtr1),y
beq .3
cmp #' '
bne .2
.3 lda L.CFG.Keywords
sta ZPTmpPtr2
lda L.CFG.Keywords+1
sta ZPTmpPtr2+1
2018-07-26 15:26:39 +00:00
ldx #0
2018-08-08 15:13:37 +00:00
.4 phy save keyword len
tya
cmp (ZPTmpPtr2)
bne .6
.5 lda (ZPTmpPtr2),y
dey
cmp (ZPTmpPtr1),y
bne .6
tya
bne .5
ply discard keyword len
jsr .80
bra .1
2018-07-26 15:26:39 +00:00
2018-08-08 15:13:37 +00:00
.6 lda (ZPTmpPtr2)
sec
adc ZPTmpPtr2
sta ZPTmpPtr2
bcc .7
inc ZPTmpPtr2+1
.7 inx
2018-07-26 15:26:39 +00:00
inx
2018-08-08 15:13:37 +00:00
ply reset keyword len
lda (ZPTmpPtr2)
bne .4
2018-07-26 15:26:39 +00:00
bra .1
2018-08-08 15:13:37 +00:00
.8 clc
.HS B0 BCS
.9 sec
jmp CFG.Read.Close
.80 jmp (J.CFG.Keywords,x)
*--------------------------------------
CFG.Read.address
ldx #S.IPCFG.IP+3
bra CFG.Read.IP
CFG.Read.netmask
ldx #S.IPCFG.MASK+3
bra CFG.Read.IP
CFG.Read.gateway
ldx #S.IPCFG.GW+3
bra CFG.Read.IP
CFG.Read.nameserver
ldx #S.IPCFG.DNS1+3
lda IPCFG,x
beq CFG.Read.IP
ldx #S.IPCFG.DNS2+3
CFG.Read.IP ldy #3
.1 txa
clc
adc L.IPCFG
pha
lda L.IPCFG+1
adc #0
>PUSHA @IP[3][2][1][0]
pla
>PUSHA
dex
dey
bpl .1
>PUSHBI 8 4 PTRs on stack
>PUSHW L.HST.SScanF
lda (ZPTmpPtr2)
2018-07-26 15:26:39 +00:00
sec
2018-08-08 15:13:37 +00:00
adc ZPTmpPtr1
tay
lda ZPTmpPtr1+1
adc #0
>SYSCALL SScanF
2018-07-26 15:26:39 +00:00
rts
2018-08-08 15:13:37 +00:00
CFG.Read.dnsdomain
lda (ZPTmpPtr2)
sec
adc ZPTmpPtr1
sta ZPTmpPtr1
bcc .1
inc ZPTmpPtr1+1
.1 ldy #$ff
.2 iny
lda (ZPTmpPtr1),y
sta IPCFG+S.IPCFG.DOMAIN,y
beq .8
cpy #K.DNS.MAXLEN
bne .2
lda #0
sta IPCFG+S.IPCFG.DOMAIN,y
.8 rts
*--------------------------------------
2018-09-10 15:07:26 +00:00
CFG.Read.HOSTS stz CFG.hBuf2
stz CFG.hBuf3
>LDYA L.HOSTS
2018-08-08 15:13:37 +00:00
jsr CFG.Read.Open
jsr CFG.Read.Result
bcs .9
2018-09-10 15:07:26 +00:00
>LDYAI 256
>SYSCALL GetMem
bcs .9
>STYA ZPTmpPtr2
stx CFG.hBuf2
2018-08-08 15:13:37 +00:00
2018-09-10 15:07:26 +00:00
>LDYAI 256
>SYSCALL GetMem
bcs .9
>STYA ZPTmpPtr3
stx CFG.hBuf3
2018-08-08 15:13:37 +00:00
.1 jsr CFG.Read.GetS
bcs .8
lda (ZPTmpPtr1)
beq .1 empty line...
cmp #'#
beq .1 comment...
jsr CFG.Read.HOSTS.Scan
2018-07-26 15:26:39 +00:00
bcs .1
2018-08-08 15:13:37 +00:00
cmp #5
bcc .1 less than 5 parameters, ignore
beq .2 no alias
2018-09-10 15:07:26 +00:00
>LDYA ZPTmpPtr3
2018-08-08 15:13:37 +00:00
jsr CFG.DNS.Add
2018-09-10 15:07:26 +00:00
.2 >LDYA ZPTmpPtr2
2018-08-08 15:13:37 +00:00
jsr CFG.DNS.Add
2018-07-26 15:26:39 +00:00
bra .1
2018-08-08 15:13:37 +00:00
.8 clc
.HS B0 BCS
.9 sec
2018-09-10 15:07:26 +00:00
php
pha
lda CFG.hBuf3
beq .90
>SYSCALL freemem
.90 lda CFG.hBuf2
beq .91
>SYSCALL freemem
.91 jmp CFG.Read.Close2
2018-08-08 15:13:37 +00:00
*--------------------------------------
CFG.Read.HOSTS.Scan
2018-09-10 15:07:26 +00:00
>PUSHW ZPTmpPtr3
>PUSHW ZPTmpPtr2
2018-07-26 15:26:39 +00:00
2018-08-08 15:13:37 +00:00
ldx #3
.2 txa
2018-07-26 15:26:39 +00:00
clc
2018-08-08 15:13:37 +00:00
adc L.CFG.IP
tay
lda L.CFG.IP+1
adc #0
>PUSHYA @IP[3][2][1][0]
dex
bpl .2
>PUSHBI 12 6 PTRs on stack
>PUSHW L.CFG.HOSTS.SScanF
>LDYA ZPTmpPtr1
>SYSCALL SScanF
2018-07-26 15:26:39 +00:00
rts
*--------------------------------------
2018-08-08 15:13:37 +00:00
CFG.DNS.ADD >STYA ZPTmpPtr1
>PUSHW ZPTmpPtr1
2018-07-26 15:26:39 +00:00
2018-08-08 15:13:37 +00:00
ldy #3
2018-09-10 15:07:26 +00:00
.1 lda CFG.IP,y
2018-08-08 15:13:37 +00:00
>PUSHA
dey
bpl .1
2018-09-10 15:07:26 +00:00
>PUSHBI 6
2018-08-08 15:13:37 +00:00
>LDYA L.MSG.DNS.ADD
2018-08-23 15:16:20 +00:00
>SYSCALL printf
2018-09-10 15:07:26 +00:00
>LDYA L.CFG.IP
>PUSHYA
>PUSHW ZPTmpPtr1
jsr DNS.Add
*--------------------------------------
CFG.Read.Result bcc .1
>PUSHA
>PUSHBI 1
>LDYA L.MSG.CFG.KO
>SYSCALL printf
sec
rts
.1 >LDYA L.MSG.CFG.OK
>SYSCALL puts
2018-07-26 15:26:39 +00:00
rts
*--------------------------------------
2018-08-08 15:13:37 +00:00
CFG.Read.Open stz CFG.hCfgFile
2018-07-26 15:26:39 +00:00
stz CFG.hCfgPath
>SYSCALL ExpandStr
bcs .9
stx CFG.hCfgPath
pha
2018-08-08 15:13:37 +00:00
>PUSHWI 0
2018-10-02 15:52:30 +00:00
>PUSHBI S.FI.T.TXT
>PUSHBI O.RDONLY
2018-08-08 15:13:37 +00:00
2018-07-26 15:26:39 +00:00
pla
2018-08-08 15:13:37 +00:00
>SYSCALL fopen
2018-07-26 15:26:39 +00:00
bcs .9
2018-08-08 15:13:37 +00:00
sta CFG.hCfgFile
* clc
.9 rts
2018-07-26 15:26:39 +00:00
*--------------------------------------
2018-08-08 15:13:37 +00:00
CFG.Read.Close php
2018-07-26 15:26:39 +00:00
pha
2018-09-10 15:07:26 +00:00
CFG.Read.Close2
2018-07-26 15:26:39 +00:00
lda CFG.hCfgPath
beq .1
>SYSCALL FreeMem
.1 lda CFG.hCfgFile
beq .8
2018-08-08 15:13:37 +00:00
>SYSCALL fclose
2018-07-26 15:26:39 +00:00
.8 pla
2018-08-08 15:13:37 +00:00
plp
2018-07-26 15:26:39 +00:00
rts
*--------------------------------------
2018-08-08 15:13:37 +00:00
CFG.Read.GetS >PUSHWI 255
>PUSHW ZPTmpPtr1
lda CFG.hCfgFile
>SYSCALL fgets
2018-10-09 15:47:06 +00:00
* bcs .9
* >LDYA ZPTmpPtr1
* >SYSCALL puts
.9 rts
2018-07-26 15:26:39 +00:00
*--------------------------------------
CFG.A2CharAX pha
lsr
lsr
lsr
lsr
ora #$30
cmp #'9'+1
bcc .1
adc #6
.1 tax
pla
and #$0F
ora #$30
cmp #'9'+1
bcc .8
adc #6
.8 rts
*--------------------------------------
SET.IPCFG >PULLW ZPTmpPtr1 IPCFG
ldy #0
.1 lda (ZPTmpPtr1),y
sta IPCFG,y
iny
cpy #S.IPCFG
bne .1
2018-08-08 15:13:37 +00:00
SET.IPCFG.I >LDYA L.DCB.NIC
>STYA IOCTL+S.IOCTL.BUFPTR
lda #S.IOCTL.STATCODE.GETDCB
sta IOCTL+S.IOCTL.STATCODE
>PUSHW L.IOCTL
>PUSHBI IOCTL.STATUS
lda IPCFG+S.IPCFG.hFD
>SYSCALL IOCTL
bcs *
ldx #5
.10 lda DCB.NIC+S.DCB.NIC.MAC,x
sta IPCFG+S.IPCFG.MAC,x
sta ARP.REQ.SRCMAC,x
sta ARP.REQ.SHA,x
sta ARP.REP.SRCMAC,x
sta ARP.REP.SHA,x
dex
bpl .10
ldx #3
.11 lda IPCFG+S.IPCFG.IP,x
2018-10-09 15:47:06 +00:00
sta SA.LOCAL+S.SOCKADDR.ADDR,x
2018-08-08 15:13:37 +00:00
sta ARP.REQ.SPA,x
sta ARP.REP.SPA,x
dex
bpl .11
lda DCB.NIC+S.DCB.NIC.FLAGS
2018-07-26 15:26:39 +00:00
and #S.DCB.NIC.FLAGS.ARPOFFLOAD
beq .2
2018-07-23 06:28:47 +00:00
ldx #11
2018-07-26 15:26:39 +00:00
.1 lda IPCFG+S.IPCFG.IP,x
2018-07-23 06:28:47 +00:00
sta DCB.NIC+S.DCB.NIC.IP,x
dex
2018-07-26 15:26:39 +00:00
bpl .1
2018-07-23 06:28:47 +00:00
2018-07-26 15:26:39 +00:00
lda S.IOCTL.CTRLCODE.SETDCB
sta S.IOCTL.CTRLCODE
2018-07-23 06:28:47 +00:00
2018-07-26 15:26:39 +00:00
>PUSHW L.IOCTL
>PUSHBI IOCTL.CONTROL
2018-08-08 15:13:37 +00:00
lda IPCFG+S.IPCFG.hFD
2018-07-26 15:26:39 +00:00
>SYSCALL IOCTL
bcs .9
2018-10-08 15:41:00 +00:00
.2 lda hDNSSocket
2018-07-26 15:26:39 +00:00
beq .3
2018-10-10 15:39:22 +00:00
jsr SKT.Shutdown
2018-10-08 15:41:00 +00:00
stz hDNSSocket
2018-10-08 15:41:00 +00:00
.3 lda IPCFG+S.IPCFG.DNS1
beq .8
2018-10-09 15:47:06 +00:00
>PUSHBI 0 no protocol
2018-10-08 15:41:00 +00:00
lda #S.SOCKET.T.DGRAM
jsr SKT.Socket
bcs .9
2018-10-08 15:41:00 +00:00
sta hDNSSocket
2018-10-09 15:47:06 +00:00
stz SA.LOCAL+S.SOCKADDR.PORT
stz SA.LOCAL+S.SOCKADDR.PORT+1
>PUSHW L.SA.LOCAL
lda hDNSSocket
jsr SKT.Bind
2018-07-26 06:03:49 +00:00
.8 clc
.9 rts
*--------------------------------------
* grab a copy on the fly for lib function
* OUT :
* Y,A = PTR to S.IPCFG
*--------------------------------------
GET.IPCFG >LDYA L.IPCFG
clc
rts
*--------------------------------------
MAN
2018-11-17 17:17:13 +00:00
SAVE USR/SRC/LIB/LIBTCPIP.S.CFG
LOAD USR/SRC/LIB/LIBTCPIP.S
ASM