2015-03-14 21:48:35 +00:00
|
|
|
|
PR#3
|
2015-06-03 18:30:57 +00:00
|
|
|
|
PREFIX /A2OSX.SRC
|
2015-03-14 21:48:35 +00:00
|
|
|
|
NEW
|
|
|
|
|
INC 1
|
|
|
|
|
AUTO 6
|
|
|
|
|
.LIST OFF
|
|
|
|
|
.OP 65C02
|
|
|
|
|
.OR $2000
|
2015-06-03 18:30:57 +00:00
|
|
|
|
.TF /A2OSX.BOOT/SBIN/TCPIP
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
.INB INC/MACROS.I
|
|
|
|
|
.INB INC/A2OSX.I
|
|
|
|
|
.INB INC/LIBTCPIP.I
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
ZPFrameBase1 .EQ ZPBIN
|
|
|
|
|
ZPFrameLen1 .EQ ZPBIN+2
|
|
|
|
|
ZPFramePtr1 .EQ ZPBIN+4
|
|
|
|
|
ZPFrameBase2 .EQ ZPBIN+6
|
|
|
|
|
ZPFrameLen2 .EQ ZPBIN+8
|
|
|
|
|
ZPFramePtr2 .EQ ZPBIN+10
|
2015-11-22 22:30:06 +00:00
|
|
|
|
ZPIPCfgPtr .EQ ZPBIN+12
|
|
|
|
|
ZPIPDevPtr .EQ ZPBIN+14
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2015-06-03 18:30:57 +00:00
|
|
|
|
* File Header (16 Bytes)
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.START cld
|
|
|
|
|
jmp (.1,x)
|
2015-06-03 18:30:57 +00:00
|
|
|
|
.DA #$61 6502,Level 1 (65c02)
|
|
|
|
|
.DA #1 BIN Layout Version 1
|
|
|
|
|
.DA 0
|
|
|
|
|
.DA CS.END-CS.START Code Length To Relocate
|
|
|
|
|
.DA 0
|
|
|
|
|
.DA 0
|
|
|
|
|
.DA 0
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Relocation Table
|
|
|
|
|
*--------------------------------------
|
2015-03-14 21:48:35 +00:00
|
|
|
|
.1 .DA CS.INIT
|
|
|
|
|
.DA CS.RUN
|
|
|
|
|
.DA CS.DOEVENT
|
|
|
|
|
.DA CS.QUIT
|
|
|
|
|
L.LIBTCPIP .DA LIBTCPIP
|
2015-11-22 22:30:06 +00:00
|
|
|
|
L.MSG.HELP .DA MSG.HELP
|
2016-01-09 22:38:03 +00:00
|
|
|
|
L.MSG.CFG .DA MSG.CFG
|
|
|
|
|
L.MSG.CFG.KO .DA MSG.CFG.KO
|
|
|
|
|
L.MSG.CFG.OK .DA MSG.CFG.OK
|
|
|
|
|
L.HOSTNAME .DA HOSTNAME
|
|
|
|
|
L.TCPIP.CONF .DA TCPIP.CONF
|
2015-03-14 21:48:35 +00:00
|
|
|
|
L.IPCFG .DA IPCFG
|
|
|
|
|
.DA 0
|
|
|
|
|
*--------------------------------------
|
2015-06-03 18:30:57 +00:00
|
|
|
|
CS.INIT >LDYA L.LIBTCPIP
|
2015-11-22 22:30:06 +00:00
|
|
|
|
>SYSCALL SYS.LoadLibYA
|
2015-03-14 21:48:35 +00:00
|
|
|
|
bcs .99
|
|
|
|
|
sta hLIBTCPIP
|
2015-11-22 22:30:06 +00:00
|
|
|
|
|
|
|
|
|
ldy #S.PS.hARGS
|
|
|
|
|
lda (pPs),y
|
2016-01-09 22:38:03 +00:00
|
|
|
|
bne .1
|
2015-11-22 22:30:06 +00:00
|
|
|
|
>LDYA L.MSG.HELP
|
|
|
|
|
>SYSCALL SYS.PSTROutYA
|
|
|
|
|
lda #0
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
|
2016-01-09 22:38:03 +00:00
|
|
|
|
.1 jsr CS.INIT.DEV
|
2015-03-14 21:48:35 +00:00
|
|
|
|
bcs .99
|
|
|
|
|
|
2016-01-09 22:38:03 +00:00
|
|
|
|
jsr CFG.Read continue even if error opening CFG file
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
|
|
|
|
ldx #S.IPCFG.HOSTNAME
|
|
|
|
|
lda IPCFG,x
|
|
|
|
|
bne .3
|
|
|
|
|
|
|
|
|
|
ldy #0
|
|
|
|
|
.2 lda DefaultHostName,y
|
|
|
|
|
sta IPCFG,x
|
|
|
|
|
beq .3
|
|
|
|
|
inx
|
|
|
|
|
iny
|
|
|
|
|
bne .2
|
|
|
|
|
|
|
|
|
|
.3 >PUSHW L.IPCFG
|
|
|
|
|
>PUSHBI K.PROTOID.IP
|
|
|
|
|
>SYSCALL SYS.AddNetCfg
|
|
|
|
|
bcs .99
|
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
lda (pPs)
|
2015-03-14 21:48:35 +00:00
|
|
|
|
ora #S.PS.F.EVENT Now accept events
|
2015-06-03 18:30:57 +00:00
|
|
|
|
sta (pPs)
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
|
|
|
|
clc
|
|
|
|
|
.99 rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.INIT.DEV ldy #S.PS.hARGS
|
2015-06-03 18:30:57 +00:00
|
|
|
|
lda (pPs),y
|
2015-03-14 21:48:35 +00:00
|
|
|
|
>PUSHA
|
|
|
|
|
>PUSHBI $20 Push SEP=' '
|
|
|
|
|
>PUSHBI 1 Push 1 for getting DEV
|
|
|
|
|
>SYSCALL SYS.PStrGetTkn
|
|
|
|
|
bcs .99
|
|
|
|
|
sta hDEVNAME save DevName for discard
|
|
|
|
|
>SYSCALL SYS.GetDevByNameA
|
|
|
|
|
bcs .98
|
2016-01-09 22:38:03 +00:00
|
|
|
|
>STYA pNetDevJmp+1
|
2015-06-03 18:30:57 +00:00
|
|
|
|
txa
|
2016-01-09 22:38:03 +00:00
|
|
|
|
sta hNetDev
|
2015-03-14 21:48:35 +00:00
|
|
|
|
ldx #S.IPCFG.HDEV
|
|
|
|
|
sta IPCFG,x
|
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
ldx #DEVMGR.OPEN
|
2016-01-09 22:38:03 +00:00
|
|
|
|
jsr pNetDevJmp
|
2015-11-22 22:30:06 +00:00
|
|
|
|
bcs .98
|
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
ldx #DEVMGR.GETINFO
|
2016-01-09 22:38:03 +00:00
|
|
|
|
jsr pNetDevJmp
|
2015-11-22 22:30:06 +00:00
|
|
|
|
bcs .98
|
|
|
|
|
>STYA ZPIPDevPtr
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
|
|
|
|
ldy #1
|
2016-01-09 22:38:03 +00:00
|
|
|
|
lda (ZPIPDevPtr),y
|
|
|
|
|
sta DEVFLAGS
|
|
|
|
|
|
|
|
|
|
iny
|
2015-03-14 21:48:35 +00:00
|
|
|
|
ldx #S.IPCFG.MAC
|
2016-01-09 22:38:03 +00:00
|
|
|
|
|
2015-11-22 22:30:06 +00:00
|
|
|
|
.1 lda (ZPIPDevPtr),y
|
2015-03-14 21:48:35 +00:00
|
|
|
|
sta IPCFG,x
|
|
|
|
|
iny
|
2015-06-03 18:30:57 +00:00
|
|
|
|
inx
|
|
|
|
|
cpx #S.IPCFG.MAC+6
|
2015-03-14 21:48:35 +00:00
|
|
|
|
bne .1
|
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
jsr .98
|
2015-03-14 21:48:35 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
2015-03-25 16:30:00 +00:00
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
.98 pha
|
|
|
|
|
lda hDEVNAME
|
|
|
|
|
>SYSCALL SYS.FreeMemA
|
|
|
|
|
pla
|
2015-03-25 16:30:00 +00:00
|
|
|
|
.99 sec
|
|
|
|
|
rts
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2015-06-03 18:30:57 +00:00
|
|
|
|
CS.DOEVENT lda (pEvent)
|
2015-03-14 21:48:35 +00:00
|
|
|
|
and #S.EVT.F.NET
|
|
|
|
|
beq .9
|
|
|
|
|
|
|
|
|
|
ldy #S.EVT.hDEV
|
|
|
|
|
lda (pEvent),y
|
2016-01-09 22:38:03 +00:00
|
|
|
|
cmp hNetDev
|
2015-03-14 21:48:35 +00:00
|
|
|
|
beq CS.DOEVENT.NET
|
|
|
|
|
.9 sec
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
CS.DOEVENT.NET ldy #S.EVT.DATALO Get Frame hMem
|
|
|
|
|
lda (pEvent),y
|
|
|
|
|
>SYSCALL SYS.GetMemPtrA
|
|
|
|
|
>STYA ZPFrameBase1
|
|
|
|
|
|
|
|
|
|
ldy #S.EVT.DATAW1 Get Frame Len
|
|
|
|
|
lda (pEvent),y
|
|
|
|
|
sta ZPFrameLen1
|
|
|
|
|
iny
|
|
|
|
|
lda (pEvent),y
|
|
|
|
|
sta ZPFrameLen1+1
|
|
|
|
|
|
|
|
|
|
ldy #S.ETH.ETHERTYPE
|
|
|
|
|
lda (ZPFrameBase1),y
|
|
|
|
|
tax
|
|
|
|
|
iny
|
|
|
|
|
lda (ZPFrameBase1),y
|
|
|
|
|
|
|
|
|
|
cmp #S.ETH.ETHERTYPE.ARP
|
|
|
|
|
bne .1
|
|
|
|
|
cpx /S.ETH.ETHERTYPE.ARP
|
|
|
|
|
bne .1
|
|
|
|
|
jsr ARPListener
|
|
|
|
|
bcc .89
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.1 cmp #S.ETH.ETHERTYPE.IP
|
|
|
|
|
bne .99
|
|
|
|
|
cpx /S.ETH.ETHERTYPE.IP
|
|
|
|
|
bne .99
|
|
|
|
|
|
|
|
|
|
ldy #S.IP.PROTOCOL
|
|
|
|
|
lda (ZPFrameBase1),y
|
|
|
|
|
cmp #S.IP.PROTOCOL.ICMP
|
|
|
|
|
bne .2
|
|
|
|
|
jsr ICMPListener
|
|
|
|
|
bcc .89
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.2 cmp #S.IP.PROTOCOL.UDP
|
2015-09-13 20:35:07 +00:00
|
|
|
|
bne .21
|
|
|
|
|
|
|
|
|
|
ldy #S.UDP.DSTPORT
|
|
|
|
|
lda /UDP.PORT.DNS
|
|
|
|
|
cmp (ZPFrameBase1),y
|
2015-03-14 21:48:35 +00:00
|
|
|
|
bne .3
|
2015-09-13 20:35:07 +00:00
|
|
|
|
iny
|
|
|
|
|
lda #UDP.PORT.DNS
|
|
|
|
|
cmp (ZPFrameBase1),y
|
|
|
|
|
bne .3
|
|
|
|
|
|
|
|
|
|
jsr DNSListener
|
|
|
|
|
bcc .89
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.21 >PUSHW ZPFrameLen1
|
2015-03-14 21:48:35 +00:00
|
|
|
|
>PUSHW ZPFrameBase1
|
|
|
|
|
>LIBCALL hLIBTCPIP,LIBTCPIP.UDP.LISTENER
|
|
|
|
|
bcc .89
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.3 cmp #S.IP.PROTOCOL.TCP
|
|
|
|
|
bne .99
|
|
|
|
|
>PUSHW ZPFrameLen1
|
|
|
|
|
>PUSHW ZPFrameBase1
|
|
|
|
|
>LIBCALL hLIBTCPIP,LIBTCPIP.TCP.LISTENER
|
|
|
|
|
bcc .89
|
|
|
|
|
rts
|
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
.89 clc
|
2015-03-14 21:48:35 +00:00
|
|
|
|
rts
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
.99 sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2016-01-09 22:38:03 +00:00
|
|
|
|
CS.QUIT ldx #DEVMGR.CLOSE
|
|
|
|
|
jsr pNetDevJmp
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
|
|
|
|
lda hLIBTCPIP
|
2015-10-19 20:35:00 +00:00
|
|
|
|
>SYSCALL SYS.UnloadLibA
|
2015-03-14 21:48:35 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
*--------------------------------------
|
2015-09-13 20:35:07 +00:00
|
|
|
|
*--------------------------------------
|
2015-03-14 21:48:35 +00:00
|
|
|
|
GetIPCFG >LIBCALL hLIBTCPIP,LIBTCPIP.GET.IPCFG
|
2015-11-22 22:30:06 +00:00
|
|
|
|
>STYA ZPIPCfgPtr
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
|
|
|
|
ldy #S.IPCFG
|
|
|
|
|
.1 dey
|
2015-11-22 22:30:06 +00:00
|
|
|
|
lda (ZPIPCfgPtr),y
|
2015-03-14 21:48:35 +00:00
|
|
|
|
sta IPCFG,y
|
|
|
|
|
tya
|
|
|
|
|
bne .1
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
MakeIPReply >LDAXI S.IP.SRC
|
|
|
|
|
jsr SetFramePtr1AX
|
|
|
|
|
>LDAXI S.IP.DST
|
|
|
|
|
jsr SetFramePtr2AX
|
|
|
|
|
ldy #4
|
|
|
|
|
jsr CopyFramePtr12
|
|
|
|
|
|
|
|
|
|
>LDAXI S.IP.DST
|
|
|
|
|
jsr SetFramePtr1AX
|
|
|
|
|
>LDAXI S.IP.SRC
|
|
|
|
|
jsr SetFramePtr2AX
|
|
|
|
|
ldy #4
|
|
|
|
|
jsr CopyFramePtr12
|
|
|
|
|
|
|
|
|
|
>LDAXI S.ETH.SRCMAC
|
|
|
|
|
jsr SetFramePtr1AX
|
|
|
|
|
>LDAXI S.ETH.DSTMAC
|
|
|
|
|
jsr SetFramePtr2AX
|
|
|
|
|
ldy #6
|
|
|
|
|
jsr CopyFramePtr12
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* A,X = Frame PTR
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
SetFramePtr1AX clc
|
|
|
|
|
adc ZPFrameBase1
|
|
|
|
|
sta ZPFramePtr1
|
|
|
|
|
txa
|
|
|
|
|
adc ZPFrameBase1+1
|
|
|
|
|
sta ZPFramePtr1+1
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* A,X = Frame PTR
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
SetFramePtr2AX clc
|
|
|
|
|
adc ZPFrameBase2
|
|
|
|
|
sta ZPFramePtr2
|
|
|
|
|
txa
|
|
|
|
|
adc ZPFrameBase2+1
|
|
|
|
|
sta ZPFramePtr2+1
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Y = bytes to copy from ZPFramePtr1 to ZPFramePtr2
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CopyFramePtr12 dey
|
|
|
|
|
lda (ZPFramePtr1),y
|
|
|
|
|
sta (ZPFramePtr2),y
|
|
|
|
|
tya
|
|
|
|
|
bne CopyFramePtr12
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2016-01-09 22:38:03 +00:00
|
|
|
|
pNetDevJmp jmp *
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
.INB SBIN/TCPIP.S.CFG
|
|
|
|
|
.INB SBIN/TCPIP.S.ARP
|
|
|
|
|
.INB SBIN/TCPIP.S.DNS
|
|
|
|
|
.INB SBIN/TCPIP.S.ICMP
|
|
|
|
|
*--------------------------------------
|
2015-03-14 21:48:35 +00:00
|
|
|
|
CS.END
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
LIBTCPIP >PSTRING "libtcpip.o"
|
2015-11-22 22:30:06 +00:00
|
|
|
|
MSG.HELP >PSTRING "Usage: TCPIP ETHx\n"
|
2016-01-10 22:18:12 +00:00
|
|
|
|
MSG.CFG >PSTRING "TCPIP:Reading %S..."
|
2016-01-09 22:38:03 +00:00
|
|
|
|
MSG.CFG.KO >PSTRING "Failed!!! [%h]\n"
|
|
|
|
|
MSG.CFG.OK >PSTRING "OK.\n"
|
|
|
|
|
HOSTNAME >PSTRING "${A2OSX}ETC/HOSTNAME"
|
|
|
|
|
TCPIP.CONF >PSTRING "${A2OSX}ETC/TCPIP.CONF"
|
2015-03-14 21:48:35 +00:00
|
|
|
|
DefaultHostName >CSTRING "a2osx-host"
|
2016-01-09 22:38:03 +00:00
|
|
|
|
CFG.Keywords >PSTRING "DOMAIN"
|
|
|
|
|
>PSTRING "IP"
|
|
|
|
|
>PSTRING "MASK"
|
|
|
|
|
>PSTRING "GW"
|
|
|
|
|
>PSTRING "DNS1"
|
|
|
|
|
>PSTRING "DNS2"
|
|
|
|
|
CFG.Keyword.Map .DA #0 End Of Keyword table and NA Keyword
|
|
|
|
|
.DA #S.IPCFG.IP
|
|
|
|
|
.DA #S.IPCFG.MASK
|
|
|
|
|
.DA #S.IPCFG.GW
|
|
|
|
|
.DA #S.IPCFG.DNS
|
|
|
|
|
.DA #S.IPCFG.DNS+4
|
2015-03-14 21:48:35 +00:00
|
|
|
|
hLIBTCPIP .BS 1
|
|
|
|
|
hDEVNAME .BS 1
|
2016-01-09 22:38:03 +00:00
|
|
|
|
hNetDev .BS 1
|
|
|
|
|
DEVFLAGS .BS 1
|
2015-03-14 21:48:35 +00:00
|
|
|
|
IPCFG .BS S.IPCFG Get in cache for faster access with ,X
|
2016-01-09 22:38:03 +00:00
|
|
|
|
CFG.hCfgFile .BS 1
|
|
|
|
|
CFG.FileLen .BS 2
|
|
|
|
|
CFG.Keyword .BS 1
|
|
|
|
|
CFG.StrBuf .BS 4
|
|
|
|
|
CFG.HexByte .BS 1
|
|
|
|
|
CFG.IP .BS 5
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
|
|
|
|
SAVE SBIN/TCPIP.S
|
|
|
|
|
ASM
|