2015-03-14 21:48:35 +00:00
|
|
|
|
PR#3
|
2015-06-03 18:30:57 +00:00
|
|
|
|
PREFIX /A2OSX.SRC
|
2017-01-28 22:05:20 +00:00
|
|
|
|
LOMEM $A00
|
2015-03-14 21:48:35 +00:00
|
|
|
|
INC 1
|
|
|
|
|
AUTO 6
|
|
|
|
|
.LIST OFF
|
|
|
|
|
.OP 65C02
|
|
|
|
|
.OR $2000
|
2015-06-03 18:30:57 +00:00
|
|
|
|
.TF /A2OSX.BOOT/LIB/LIBTCPIP.O
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2016-10-26 20:51:06 +00:00
|
|
|
|
.INB /A2OSX.DEV/INC/MACROS.I
|
|
|
|
|
.INB /A2OSX.DEV/INC/A2OSX.I
|
|
|
|
|
.INB /A2OSX.DEV/INC/LIBTCPIP.I
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2017-01-31 16:40:37 +00:00
|
|
|
|
ZPFrameInPtr .EQ ZPLIB
|
|
|
|
|
ZPFrameInLen .EQ ZPLIB+2
|
|
|
|
|
|
|
|
|
|
ZPDataInPtr .EQ ZPLIB+4
|
|
|
|
|
ZPDataInLen .EQ ZPLIB+6
|
|
|
|
|
|
|
|
|
|
ZPFrameOutPtr .EQ ZPLIB+8
|
|
|
|
|
ZPFrameOutLen .EQ ZPLIB+10
|
|
|
|
|
|
|
|
|
|
ZPDataOutPtr .EQ ZPLIB+12
|
|
|
|
|
ZPDataOutLen .EQ ZPLIB+14
|
|
|
|
|
|
|
|
|
|
ZPPtrIP .EQ ZPLIB+16
|
|
|
|
|
ZPPtrMAC .EQ ZPLIB+18
|
|
|
|
|
ZPPtrDNS .EQ ZPLIB+20
|
|
|
|
|
ZPPtrSKT .EQ ZPLIB+22
|
|
|
|
|
|
|
|
|
|
ZPCachePtr .EQ ZPLIB+24
|
|
|
|
|
ZPTmpPtr1 .EQ ZPLIB+26
|
|
|
|
|
ZPTmpPtr2 .EQ ZPLIB+28
|
|
|
|
|
ZPTmpPtr3 .EQ ZPLIB+30
|
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
|
|
|
|
|
.DA 0
|
|
|
|
|
.DA 0
|
|
|
|
|
.DA 0
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Relocation Table
|
|
|
|
|
*--------------------------------------
|
2015-03-14 21:48:35 +00:00
|
|
|
|
.1 .DA LIB.LOAD
|
|
|
|
|
.DA LIB.UNLOAD
|
|
|
|
|
|
|
|
|
|
.DA SET.IPCFG
|
|
|
|
|
.DA GET.IPCFG
|
|
|
|
|
|
2017-01-30 16:30:39 +00:00
|
|
|
|
.DA $ffff NEW.ICMP.FRAME
|
2017-01-29 21:47:19 +00:00
|
|
|
|
.DA $ffff NEW.TCP.FRAME
|
|
|
|
|
.DA $ffff NEW.UDP.FRAME
|
|
|
|
|
.DA $ffff NEW.IP.FRAME
|
2016-03-27 21:06:56 +00:00
|
|
|
|
.DA $ffff NEW.ARP.FRAME
|
|
|
|
|
.DA $ffff NEW.ETH.FRAME
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2017-01-30 16:30:39 +00:00
|
|
|
|
.DA $ffff SEND.ICMP.FRAME
|
2017-01-29 21:47:19 +00:00
|
|
|
|
.DA $ffff SEND.TCP.FRAME
|
|
|
|
|
.DA $ffff SEND.UDP.FRAME
|
|
|
|
|
.DA $ffff SEND.IP.FRAME
|
2016-03-20 22:16:01 +00:00
|
|
|
|
.DA $ffff SEND.ARP.FRAME
|
|
|
|
|
.DA $ffff SEND.ETH.FRAME
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
|
|
|
|
.DA ARP.CLEAR
|
|
|
|
|
.DA ARP.QUERY
|
|
|
|
|
.DA ARP.ADD
|
|
|
|
|
.DA ARP.GETCACHE
|
|
|
|
|
|
|
|
|
|
.DA DNS.CLEAR
|
|
|
|
|
.DA DNS.QUERY
|
|
|
|
|
.DA DNS.ADD
|
|
|
|
|
.DA DNS.GETCACHE
|
|
|
|
|
|
2017-01-29 21:47:19 +00:00
|
|
|
|
.DA POLL
|
2016-03-20 22:16:01 +00:00
|
|
|
|
.DA PULSEA
|
2016-01-16 22:04:22 +00:00
|
|
|
|
|
|
|
|
|
.DA SKT.NEW
|
2016-03-13 22:09:00 +00:00
|
|
|
|
.DA $FFFF
|
|
|
|
|
.DA SKT.ACCEPTA
|
2017-01-30 16:30:39 +00:00
|
|
|
|
.DA $FFFF
|
2016-01-16 22:04:22 +00:00
|
|
|
|
.DA SKT.SEND
|
|
|
|
|
.DA SKT.RCVDA
|
2016-03-13 22:09:00 +00:00
|
|
|
|
.DA $FFFF
|
|
|
|
|
.DA SKT.CLOSEA
|
2016-01-16 22:04:22 +00:00
|
|
|
|
.DA SKT.GETTABLE
|
2016-03-13 22:09:00 +00:00
|
|
|
|
.DA SKT.GETA
|
|
|
|
|
|
|
|
|
|
.DA HST.GETBYNAME
|
|
|
|
|
.DA HST.GETBYADDR
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
L.IPCFG .DA IPCFG
|
2016-03-13 22:09:00 +00:00
|
|
|
|
L.ARP.REQ .DA ARP.REQ
|
|
|
|
|
L.ARP.REP .DA ARP.REP
|
|
|
|
|
L.DNS.SOCKET .DA DNS.SOCKET
|
|
|
|
|
L.DNS.MSG .DA DNS.MSG
|
2015-03-14 21:48:35 +00:00
|
|
|
|
L.ARP.CACHE .DA ARP.CACHE
|
|
|
|
|
L.DNS.CACHE .DA DNS.CACHE
|
2016-01-16 22:04:22 +00:00
|
|
|
|
L.SKT.TABLE .DA SKT.TABLE
|
2016-03-13 22:09:00 +00:00
|
|
|
|
L.TmpSocket .DA TmpSocket
|
|
|
|
|
L.TCP.MSG .DA TCP.MSG
|
2017-01-28 22:05:20 +00:00
|
|
|
|
L.TCP.IN.JMP .DA TCP.IN.JMP.CLOSED
|
|
|
|
|
.DA TCP.IN.JMP.LISTEN
|
|
|
|
|
.DA TCP.IN.JMP.SYNSENT
|
|
|
|
|
.DA TCP.IN.JMP.SYNRCVD
|
|
|
|
|
.DA TCP.IN.JMP.ESTBLSH
|
|
|
|
|
.DA TCP.IN.JMP.CLWAIT
|
|
|
|
|
.DA TCP.IN.JMP.LASTACK
|
|
|
|
|
.DA TCP.IN.JMP.FINWT1
|
|
|
|
|
.DA TCP.IN.JMP.FINWT2
|
|
|
|
|
.DA TCP.IN.JMP.CLOSING
|
|
|
|
|
.DA TCP.IN.JMP.TIMEWT
|
2015-03-14 21:48:35 +00:00
|
|
|
|
.DA 0
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
LIB.LOAD lda bFirstLoad
|
2015-09-13 20:35:07 +00:00
|
|
|
|
bne .8
|
2015-03-14 21:48:35 +00:00
|
|
|
|
jsr ARP.CLEAR
|
|
|
|
|
jsr DNS.CLEAR
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
|
|
|
|
>LDYAI K.DYNPORT.START
|
2016-01-16 22:04:22 +00:00
|
|
|
|
>STYA DYNPORT.LAST
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
inc bFirstLoad
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
.8 clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
LIB.UNLOAD clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-01-29 21:47:19 +00:00
|
|
|
|
POLL ldx #DEVMGR.READBLOCK
|
|
|
|
|
jsr NetDevJmp
|
|
|
|
|
bcs .99 No Frame
|
|
|
|
|
|
|
|
|
|
stx hFrameIn
|
2017-01-31 16:40:37 +00:00
|
|
|
|
>STYA ZPFrameInPtr
|
|
|
|
|
|
|
|
|
|
lda (ZPFrameInPtr) Get Frame Len
|
|
|
|
|
sta ZPFrameInLen
|
|
|
|
|
ldy #1
|
|
|
|
|
lda (ZPFrameInPtr),y
|
|
|
|
|
sta ZPFrameInLen+1
|
2017-01-29 21:47:19 +00:00
|
|
|
|
|
|
|
|
|
ldy #S.ETH.ETHERTYPE
|
2017-01-31 16:40:37 +00:00
|
|
|
|
lda (ZPFrameInPtr),y
|
2017-01-29 21:47:19 +00:00
|
|
|
|
tax
|
|
|
|
|
iny
|
2017-01-31 16:40:37 +00:00
|
|
|
|
lda (ZPFrameInPtr),y
|
2017-01-29 21:47:19 +00:00
|
|
|
|
|
|
|
|
|
cmp #S.ETH.ETHERTYPE.ARP
|
|
|
|
|
bne .1
|
|
|
|
|
cpx /S.ETH.ETHERTYPE.ARP
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
jmp ARP.IN
|
|
|
|
|
|
|
|
|
|
.1 cmp #S.ETH.ETHERTYPE.IP
|
|
|
|
|
bne .9
|
|
|
|
|
cpx /S.ETH.ETHERTYPE.IP
|
|
|
|
|
bne .9
|
|
|
|
|
|
|
|
|
|
jmp IP.IN
|
|
|
|
|
|
|
|
|
|
.9 lda hFrameIn
|
|
|
|
|
>SYSCALL FreeMemA
|
|
|
|
|
.99 rts
|
|
|
|
|
*--------------------------------------
|
2016-03-20 22:16:01 +00:00
|
|
|
|
* Expire = every sec
|
|
|
|
|
* Retry = every 100 msec
|
|
|
|
|
*--------------------------------------
|
2017-01-30 21:03:12 +00:00
|
|
|
|
PULSEA and #S.EVT.F.T1SEC
|
|
|
|
|
beq .1
|
2016-03-20 22:16:01 +00:00
|
|
|
|
jsr ARP.EXPIRE
|
2016-03-27 21:06:56 +00:00
|
|
|
|
jsr DNS.EXPIRE
|
2017-01-29 21:47:19 +00:00
|
|
|
|
|
|
|
|
|
.1 jsr DNS.POLL
|
|
|
|
|
jmp FRM.RETRY
|
2016-03-20 22:16:01 +00:00
|
|
|
|
*--------------------------------------
|
2016-01-16 22:04:22 +00:00
|
|
|
|
ToLowerCaseA cmp #'A'
|
|
|
|
|
bcc .1
|
|
|
|
|
cmp #'Z'+1
|
|
|
|
|
bcs .1
|
|
|
|
|
adc #$20
|
|
|
|
|
.1 rts
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2016-01-16 22:04:22 +00:00
|
|
|
|
GetDynPort inc DYNPORT.LAST
|
|
|
|
|
bne .1
|
|
|
|
|
inc DYNPORT.LAST+1
|
2017-01-30 22:23:16 +00:00
|
|
|
|
|
2016-01-16 22:04:22 +00:00
|
|
|
|
lda DYNPORT.LAST
|
2017-01-30 22:23:16 +00:00
|
|
|
|
cmp #K.DYNPORT.END
|
2016-01-16 22:04:22 +00:00
|
|
|
|
lda DYNPORT.LAST+1
|
|
|
|
|
sbc /K.DYNPORT.END
|
2017-01-30 22:23:16 +00:00
|
|
|
|
|
2016-01-16 22:04:22 +00:00
|
|
|
|
bcs .1
|
2017-01-30 22:23:16 +00:00
|
|
|
|
|
2016-03-13 22:09:00 +00:00
|
|
|
|
>LDAXI K.DYNPORT.START
|
2016-01-16 22:04:22 +00:00
|
|
|
|
>STAX DYNPORT.LAST
|
|
|
|
|
rts CC
|
|
|
|
|
|
|
|
|
|
.1 >LDAX DYNPORT.LAST
|
2015-03-14 21:48:35 +00:00
|
|
|
|
clc
|
2016-01-16 22:04:22 +00:00
|
|
|
|
rts
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2017-01-31 16:40:37 +00:00
|
|
|
|
DecDataInLen lda ZPDataInLen
|
2016-01-16 22:04:22 +00:00
|
|
|
|
bne .1
|
2017-01-31 16:40:37 +00:00
|
|
|
|
lda ZPDataInLen+1
|
2016-01-16 22:04:22 +00:00
|
|
|
|
beq .9
|
2017-01-31 16:40:37 +00:00
|
|
|
|
dec ZPDataInLen+1
|
|
|
|
|
.1 dec ZPDataInLen
|
2016-01-16 22:04:22 +00:00
|
|
|
|
lda #$FF Make NZ
|
|
|
|
|
.9 rts
|
2015-10-19 20:35:00 +00:00
|
|
|
|
*--------------------------------------
|
2017-01-26 21:57:35 +00:00
|
|
|
|
NetDevJmp jmp *
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2017-01-31 16:40:37 +00:00
|
|
|
|
.INB LIB/LIBTCPIP.S.ARP
|
2016-10-17 06:21:04 +00:00
|
|
|
|
.INB LIB/LIBTCPIP.S.CFG
|
2017-01-31 16:40:37 +00:00
|
|
|
|
.INB LIB/LIBTCPIP.S.DNS
|
2016-01-16 22:04:22 +00:00
|
|
|
|
.INB LIB/LIBTCPIP.S.FRM
|
2017-01-31 16:40:37 +00:00
|
|
|
|
.INB LIB/LIBTCPIP.S.HST
|
2016-01-16 22:04:22 +00:00
|
|
|
|
.INB LIB/LIBTCPIP.S.ICMP
|
2017-01-31 16:40:37 +00:00
|
|
|
|
.INB LIB/LIBTCPIP.S.IP
|
2016-01-16 22:04:22 +00:00
|
|
|
|
.INB LIB/LIBTCPIP.S.SKT
|
2017-01-31 16:40:37 +00:00
|
|
|
|
.INB LIB/LIBTCPIP.S.TCP
|
|
|
|
|
.INB LIB/LIBTCPIP.S.UDP
|
2016-01-09 22:36:24 +00:00
|
|
|
|
*--------------------------------------
|
2015-03-14 21:48:35 +00:00
|
|
|
|
CS.END
|
|
|
|
|
*--------------------------------------
|
2016-03-13 22:09:00 +00:00
|
|
|
|
ARP.REQ .DA S.ARP-2 Frame size
|
|
|
|
|
ARP.REQ.DSTMAC .HS FFFFFFFFFFFF
|
|
|
|
|
ARP.REQ.SRCMAC .BS 6
|
|
|
|
|
ARP.REQ.ETYPE .DA /S.ETH.ETHERTYPE.ARP
|
|
|
|
|
.DA #S.ETH.ETHERTYPE.ARP
|
|
|
|
|
.HS 0001.0800.06.04
|
|
|
|
|
ARP.REQ.OP .DA /S.ARP.OPERATION.REQ
|
|
|
|
|
.DA #S.ARP.OPERATION.REQ
|
|
|
|
|
ARP.REQ.SHA .BS 6
|
|
|
|
|
ARP.REQ.SPA .BS 4
|
|
|
|
|
ARP.REQ.THA .BS 6
|
|
|
|
|
ARP.REQ.TPA .BS 4
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
ARP.REP .DA S.ARP-2 Frame size
|
|
|
|
|
ARP.REP.DSTMAC .BS 6
|
|
|
|
|
ARP.REP.SRCMAC .BS 6
|
|
|
|
|
ARP.REP.ETYPE .DA /S.ETH.ETHERTYPE.ARP
|
|
|
|
|
.DA #S.ETH.ETHERTYPE.ARP
|
|
|
|
|
.HS 0001.0800.06.04
|
|
|
|
|
ARP.REP.OP .DA /S.ARP.OPERATION.REP
|
|
|
|
|
.DA #S.ARP.OPERATION.REP
|
|
|
|
|
ARP.REP.SHA .BS 6
|
|
|
|
|
ARP.REP.SPA .BS 4
|
|
|
|
|
ARP.REP.THA .BS 6
|
|
|
|
|
ARP.REP.TPA .BS 4
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
TCP.MSG .DA S.TCP-2+4 +4 bytes for MSS option
|
|
|
|
|
.BS 12 ETH:MAC+MAC
|
|
|
|
|
.DA /S.ETH.ETHERTYPE.IP
|
|
|
|
|
.DA #S.ETH.ETHERTYPE.IP
|
|
|
|
|
|
|
|
|
|
.DA $0045 IP:
|
|
|
|
|
.BS 6 LEN+ID+Frag
|
|
|
|
|
.DA #K.IP.TTL
|
|
|
|
|
.DA #S.IP.PROTOCOL.TCP
|
|
|
|
|
.BS 2 Checksum
|
|
|
|
|
.BS 8 IP:DST,SRC
|
|
|
|
|
|
|
|
|
|
.BS 4 TCP:Ports
|
|
|
|
|
.BS 8 SEQ,ACK
|
|
|
|
|
.DA #$60 6 DWORD
|
|
|
|
|
.BS 1 Options
|
|
|
|
|
.DA /K.TCP.WSIZE
|
|
|
|
|
.DA #K.TCP.WSIZE
|
|
|
|
|
.BS 4 CHK,URG
|
|
|
|
|
.HS 0204 MSS option
|
|
|
|
|
.DA /K.TCP.MSS
|
|
|
|
|
.DA #K.TCP.MSS
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
DNS.SOCKET .DA #S.SOCKET.SOCK.DGRAM
|
|
|
|
|
.BS 3
|
|
|
|
|
DNS.SOCKET.SA .BS 4
|
|
|
|
|
DNS.SOCKET.SP .DA 0 Dynamic
|
|
|
|
|
DNS.SOCKET.DA .BS 4
|
|
|
|
|
DNS.SOCKET.DP .DA UDP.PORT.DNS
|
|
|
|
|
.BS 16
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
DNS.MSG.LEN .BS 2
|
2016-03-15 17:16:14 +00:00
|
|
|
|
DNS.MSG
|
|
|
|
|
DNS.MSG.ID .BS 2
|
2016-03-13 22:09:00 +00:00
|
|
|
|
.DA /S.DNS.F.RD Flags=query
|
2016-03-20 22:16:01 +00:00
|
|
|
|
.DA #S.DNS.F.RD
|
2016-03-13 22:09:00 +00:00
|
|
|
|
.DA $100 QDCOUNT
|
|
|
|
|
.BS 6 ANCOUNT,NSCOUNT,ARCOUNT
|
2016-03-15 17:16:14 +00:00
|
|
|
|
DNS.MSG.NAME .BS K.DNS.MAXLEN+6
|
2016-03-13 22:09:00 +00:00
|
|
|
|
*--------------------------------------
|
2016-03-27 21:06:56 +00:00
|
|
|
|
IPCFG .BS S.IPCFG
|
2016-03-13 22:09:00 +00:00
|
|
|
|
ARP.CACHE .BS K.ARPCACHE.SIZE*S.ARPCACHE
|
|
|
|
|
DNS.CACHE .BS K.DNSCACHE.SIZE*S.DNSCACHE
|
|
|
|
|
SKT.TABLE .BS K.SKTTABLE.SIZE*S.SOCKET
|
2016-03-20 22:16:01 +00:00
|
|
|
|
FRM.QUEUE.Tail .BS 1
|
|
|
|
|
FRM.QUEUE.Head .BS 1
|
|
|
|
|
FRM.QUEUE.hMem .BS K.FRMQUEUE.SIZE
|
|
|
|
|
FRM.QUEUE.State .BS K.FRMQUEUE.SIZE
|
|
|
|
|
FRM.QUEUE.Retry .BS K.FRMQUEUE.SIZE
|
2016-03-13 22:09:00 +00:00
|
|
|
|
*--------------------------------------
|
2015-03-14 21:48:35 +00:00
|
|
|
|
bFirstLoad .DA #0
|
2016-01-10 22:17:49 +00:00
|
|
|
|
DevFlags .BS 1
|
2016-03-15 17:16:14 +00:00
|
|
|
|
DYNPORT.LAST .BS 2
|
2016-03-13 22:09:00 +00:00
|
|
|
|
hDNSSocket1 .BS 1
|
|
|
|
|
hDNSSocket2 .BS 1
|
2016-03-15 17:16:14 +00:00
|
|
|
|
DNS.HostNameLen .BS 1
|
|
|
|
|
DNS.HostName .BS K.DNS.MAXLEN+1
|
|
|
|
|
DNS.TmpCache .BS S.DNSCACHE
|
2016-03-16 07:19:54 +00:00
|
|
|
|
ARP.TmpCache .BS S.ARP
|
2016-03-13 22:09:00 +00:00
|
|
|
|
TmpDWord .BS 4
|
|
|
|
|
TmpSocket .BS S.SOCKET
|
2017-01-29 21:47:19 +00:00
|
|
|
|
hFrameIn .BS 1
|
|
|
|
|
hFrameOut .BS 1
|
2016-01-16 22:04:22 +00:00
|
|
|
|
hSocket .BS 1
|
2016-01-09 22:36:24 +00:00
|
|
|
|
TmpOffset .BS 2
|
2016-03-13 22:09:00 +00:00
|
|
|
|
HST.DecStr .BS 4
|
|
|
|
|
HST.IP .BS 5
|
2016-03-15 17:16:14 +00:00
|
|
|
|
IP.CHECKSUM .BS 4
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
|
|
|
|
SAVE LIB/LIBTCPIP.S
|
|
|
|
|
ASM
|