A2osX/LIB/LIBTCPIP.S.txt

405 lines
8.9 KiB
Plaintext
Raw Normal View History

2017-12-22 21:24:30 +00:00
NEW
2019-05-05 17:15:37 +00:00
AUTO 3,1
2019-06-20 06:39:28 +00:00
.LIST OFF
2015-03-14 21:48:35 +00:00
.OP 65C02
.OR $2000
2020-04-07 06:01:38 +00:00
.TF lib/libtcpip
2018-11-09 13:29:23 +00:00
*--------------------------------------
2019-06-20 06:39:28 +00:00
AUXPIPE .EQ 1
2018-11-09 13:29:23 +00:00
*--------------------------------------
.MA ADC16
clc
lda ]1
adc ]2
sta ]1
lda ]1+1
adc ]2+1
sta ]1+1
.EM
*--------------------------------------
.MA SBC16
sec
lda ]1
sbc ]2
sta ]1
lda ]1+1
sbc ]2+1
sta ]1+1
.EM
2015-03-14 21:48:35 +00:00
*--------------------------------------
2020-06-07 08:06:51 +00:00
.INB inc/macros.i
2019-06-19 15:56:59 +00:00
.DO AUXPIPE=1
2020-06-07 08:06:51 +00:00
.INB inc/io.i
2019-06-19 15:56:59 +00:00
.FIN
2020-06-07 08:06:51 +00:00
.INB inc/a2osx.i
2023-10-18 05:41:12 +00:00
.INB inc/kernel.i
2020-06-07 08:06:51 +00:00
.INB inc/mli.e.i
.INB inc/nic.i
.INB inc/eth.i
.INB inc/net.tcpip.i
.INB inc/net.dns.i
2020-06-07 08:06:51 +00:00
.INB inc/lib.net.i
.INB inc/libtcpip.i
2015-03-14 21:48:35 +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
2019-06-19 15:56:59 +00:00
ZPTmpPtr1 .EQ ZPLIB+16
ZPPtrSKT .EQ ZPLIB+18
ZPCode .EQ ZPLIB+20 12 bytes
2019-06-19 15:56:59 +00:00
ZPPtrIP .EQ ZPLIB+20
ZPPtrMAC .EQ ZPLIB+22
ZPPtrDNS .EQ ZPLIB+24
ZPCachePtr .EQ ZPLIB+26
2019-06-17 15:40:26 +00:00
2019-06-05 15:34:49 +00:00
IP.CHECKSUM .EQ ZPLIB+28
2019-06-10 08:19:13 +00:00
IP.CHECKSUM.TMP .EQ ZPLIB+30
2019-06-17 15:40:26 +00:00
TmpDWord .EQ ZPLIB+28
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
2019-01-14 07:11:50 +00:00
.DA CFG.SET
.DA CFG.GET
.DA INCOMING
2018-07-23 15:28:42 +00:00
.DA PULSE
2015-03-14 21:48:35 +00:00
.DA ARP.CLEAR
.DA ARP.QUERY
.DA ARP.ADD
.DA ARP.GetCACHE
2015-03-14 21:48:35 +00:00
.DA DNS.CLEAR
.DA DNS.QUERY
.DA DNS.ADD
.DA DNS.GetCACHE
.DA HST.GETBYNAME
.DA HST.GETBYADDR
2018-10-01 05:48:42 +00:00
.DA SKT.Socket
.DA SKT.Bind
.DA SKT.Connect
.DA SKT.Listen
2018-07-23 15:28:42 +00:00
.DA SKT.Accept
2018-10-10 15:39:22 +00:00
.DA SKT.Shutdown
.DA SKT.Read
2018-08-29 15:01:02 +00:00
.DA SKT.Write
2018-10-08 15:41:00 +00:00
.DA SKT.Recv
2018-08-29 15:01:02 +00:00
.DA SKT.Send
2018-10-08 15:41:00 +00:00
.DA SKT.RecvFrom
2018-10-01 05:48:42 +00:00
.DA SKT.SendTo
2018-11-08 14:23:06 +00:00
.DA SKT.getsockopt
2018-11-07 21:48:48 +00:00
.DA SKT.setsockopt
2018-11-08 14:23:06 +00:00
2019-03-01 14:36:20 +00:00
.DA SKT.EOF
2015-03-14 21:48:35 +00:00
*--------------------------------------
L.IPCFG .DA IPCFG
L.ARP.REQ .DA ARP.REQ
L.ARP.REP .DA ARP.REP
2018-10-09 15:47:06 +00:00
L.SA.LOCAL .DA SA.LOCAL
L.SA.REMOTE .DA SA.REMOTE
L.DNS.MSG .DA DNS.MSG
2015-03-14 21:48:35 +00:00
L.DNS.CACHE .DA DNS.CACHE
2018-05-25 19:03:31 +00:00
L.HST.SScanF .DA HST.SScanF
2018-07-23 06:28:47 +00:00
L.IOCTL .DA IOCTL
L.DCB.NIC .DA DCB.NIC
2018-09-27 15:34:38 +00:00
J.TCP.IN .DA TCP.IN.JMP.CLOSED
2019-07-07 20:48:57 +00:00
.DA TCP.IN.JMP.OPENED
.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
2018-09-28 05:58:24 +00:00
J.SKT.Socket .DA SKT.Socket.RAW
.DA SKT.Socket.DGRAM
2020-06-07 08:06:51 +00:00
.DA SKT.Socket.SEQPKT
2018-11-01 08:53:47 +00:00
.DA SKT.Socket.STREAM
2018-09-27 15:34:38 +00:00
J.SKT.connect .DA SKT.connect.RAW
.DA SKT.connect.DGRAM
2020-06-07 08:06:51 +00:00
.DA SKT.connect.SEQPKT
2018-11-01 08:53:47 +00:00
.DA SKT.connect.STREAM
2018-10-01 15:52:58 +00:00
J.SKT.send .DA SKT.send.RAW
.DA SKT.send.DGRAM
2020-06-07 08:06:51 +00:00
.DA SKT.send.SEQPKT
2018-11-01 08:53:47 +00:00
.DA SKT.send.STREAM
2015-03-14 21:48:35 +00:00
.DA 0
*--------------------------------------
LIB.LOAD ldx RefCount
bne .8
2019-01-14 07:11:50 +00:00
2021-05-09 17:04:44 +00:00
sta FD.DSOCK+S.FD.DSOCK.IOH
sta FD.SSOCK+S.FD.SSOCK.IOH
2019-01-14 07:11:50 +00:00
2019-10-25 15:09:13 +00:00
>LDYAI K.ARPCACHE.SIZE*S.ARPCACHE
2020-01-30 14:59:40 +00:00
>SYSCALL2 GetMem
2019-10-25 15:09:13 +00:00
bcs .9
2020-01-30 14:59:40 +00:00
>STYA ZPCachePtr
2019-10-25 15:09:13 +00:00
stx hARPCache
2020-01-30 14:59:40 +00:00
jsr ARP.Clear.I
2021-05-19 12:44:47 +00:00
>PUSHBI S.SOCKET.T.DGRAM
2020-09-05 13:38:04 +00:00
>PUSHBI 0 no protocol
jsr SKT.Socket
bcs .9
sta hDNSSocket
2020-10-29 12:55:55 +00:00
2021-05-19 12:44:47 +00:00
>PUSHA
2020-10-29 12:55:55 +00:00
>PUSHW L.SA.LOCAL IP/PORT=All ZERO
jsr SKT.Bind
2020-09-05 13:38:04 +00:00
>LDYAI UDP.PORT.DNS
>STYA SA.REMOTE+S.SOCKADDR.PORT
2020-10-29 12:55:55 +00:00
2021-05-19 12:44:47 +00:00
>PUSHB hDNSSocket
2020-10-29 12:55:55 +00:00
>PUSHW L.SA.REMOTE IP=All ZERO
2020-09-05 13:38:04 +00:00
jsr SKT.Connect
2015-03-14 21:48:35 +00:00
jsr DNS.CLEAR
2020-09-05 13:38:04 +00:00
.8 inc RefCount
2018-07-26 15:26:39 +00:00
clc
2019-10-25 15:09:13 +00:00
.9 rts
2015-03-14 21:48:35 +00:00
*--------------------------------------
LIB.UNLOAD dec RefCount
2019-10-25 15:09:13 +00:00
bne .8
2020-09-05 13:38:04 +00:00
lda hDNSSocket
beq .1
2020-09-05 13:38:04 +00:00
jsr SKT.Shutdown
.1 lda hARPCache
2019-10-25 15:09:13 +00:00
beq .8
>SYSCALL2 freemem
.8 clc
2015-03-14 21:48:35 +00:00
rts
*--------------------------------------
2019-01-14 07:11:50 +00:00
INCOMING sta hFrameIn
2019-01-14 16:37:56 +00:00
>PULLW ZPTmpPtr1
ldy #S.IOCTL.BUFPTR+3
2019-11-01 20:06:04 +00:00
ldx #3
2019-01-14 16:37:56 +00:00
.1 lda (ZPTmpPtr1),y Get Frame Ptr & Len
2019-11-01 20:06:04 +00:00
sta ZPFrameInPtr,x
2019-01-14 16:37:56 +00:00
dey
2019-11-01 20:06:04 +00:00
dex
2019-01-14 16:37:56 +00:00
bpl .1
2018-11-06 16:31:13 +00:00
ldy #S.ETH.EII.TYPE
lda (ZPFrameInPtr),y
2019-05-21 06:34:39 +00:00
cmp /S.ETH.EII.TYPE.IP
bne .9
2019-11-01 20:06:04 +00:00
2017-01-29 21:47:19 +00:00
iny
lda (ZPFrameInPtr),y
2018-11-06 16:31:13 +00:00
cmp #S.ETH.EII.TYPE.ARP
2021-01-12 21:14:13 +00:00
bne .2
2019-11-01 20:06:04 +00:00
2021-01-12 21:14:13 +00:00
jmp ARP.IN
2019-11-01 20:06:04 +00:00
2021-01-12 21:14:13 +00:00
.2 cmp #S.ETH.EII.TYPE.IP
bne .9
2019-11-01 20:06:04 +00:00
2021-01-12 21:14:13 +00:00
jmp IP.IN
2019-11-01 20:06:04 +00:00
2021-01-12 21:14:13 +00:00
.9 lda #MLI.E.EOF
sec
rts
2017-01-29 21:47:19 +00:00
*--------------------------------------
2019-01-14 16:37:56 +00:00
* A = S.EVT.F
* Expire = every sec
* Retry = every 100 msec
*--------------------------------------
2018-07-23 15:28:42 +00:00
PULSE and #S.EVT.F.T1SEC
beq .1
2018-08-08 15:13:37 +00:00
2019-06-17 06:35:54 +00:00
jsr ARP.EXPIRE every sec
2018-11-01 08:53:47 +00:00
jsr DNS.EXPIRE
2021-01-12 21:14:13 +00:00
2019-06-17 06:35:54 +00:00
.1 jsr FRM.RETRY every 100ms
2019-05-05 17:15:37 +00:00
jsr DNS.POLL
2019-06-17 06:35:54 +00:00
jmp TCP.SENDCLOSE
*--------------------------------------
GetDynPort inc DYNPORT.LAST
bne .1
2021-05-19 12:44:47 +00:00
inc DYNPORT.LAST+1
lda DYNPORT.LAST
cmp #K.DYNPORT.END
lda DYNPORT.LAST+1
sbc /K.DYNPORT.END
bcs .1
2021-05-19 12:44:47 +00:00
2018-07-12 15:20:39 +00:00
lda #K.DYNPORT.START
ldx /K.DYNPORT.START
sta DYNPORT.LAST
stx DYNPORT.LAST+1
rts CC
2021-05-19 12:44:47 +00:00
.1 lda DYNPORT.LAST
ldx DYNPORT.LAST+1
2015-03-14 21:48:35 +00:00
clc
rts
2015-03-14 21:48:35 +00:00
*--------------------------------------
2020-06-07 08:06:51 +00:00
.INB usr/src/lib/libtcpip.s.arp
.INB usr/src/lib/libtcpip.s.cfg
.INB usr/src/lib/libtcpip.s.dns
.INB usr/src/lib/libtcpip.s.frm
.INB usr/src/lib/libtcpip.s.hst
.INB usr/src/lib/libtcpip.s.icmp
.INB usr/src/lib/libtcpip.s.ip
.INB usr/src/lib/libtcpip.s.skt
.INB usr/src/lib/libtcpip.s.tcp
*--------------------------------------
2015-03-14 21:48:35 +00:00
CS.END
2019-06-19 15:56:59 +00:00
*--------------------------------------
.DO AUXPIPE=1
ZP.CODE sta IO.SETREADAUX
2019-06-19 15:56:59 +00:00
lda (ZPTmpPtr1),y
sta IO.CLRREADAUX
2019-06-19 15:56:59 +00:00
rts
ZP.CODE.Len .EQ *-ZP.CODE
.FIN
2015-03-14 21:48:35 +00:00
*--------------------------------------
2018-10-09 15:47:06 +00:00
SA.LOCAL .DA #AF.INET S.SOCKADDR.AF
.BS 1
.BS 4 S.SOCKADDR.ADDR
.BS 2 S.SOCKADDR.PORT
*--------------------------------------
SA.REMOTE .DA #AF.INET S.SOCKADDR.AF
.BS 1
.BS 4 S.SOCKADDR.ADDR
.BS 2 S.SOCKADDR.PORT
*--------------------------------------
2018-10-01 15:52:58 +00:00
FD.DSOCK .DA #S.FD.T.DSOCK
2021-05-19 12:44:47 +00:00
.DA #0 S.FD.PFT
.BS 1 S.FD.DSOCK.IOH
2018-10-01 15:52:58 +00:00
.DA #0 S.FD.DSOCK.OPEN
2019-05-08 19:41:46 +00:00
.DA #LIBTCPIP.shutdown
2018-10-10 15:39:22 +00:00
.DA #LIBTCPIP.Recv
.DA #LIBTCPIP.Send
2021-05-19 12:44:47 +00:00
.DA #0 S.FD.DSOCK.EOF
2018-10-01 15:52:58 +00:00
*--------------------------------------
2018-10-01 05:48:42 +00:00
.DA #AF.INET S.SOCKET.AF
2018-09-28 15:24:44 +00:00
.BS 1 S.SOCKET.T
.BS 1 S.SOCKET.PROTO
2019-10-03 06:25:27 +00:00
FD.DSOCK.SIZE .EQ *-FD.DSOCK
2018-10-01 15:52:58 +00:00
*--------------------------------------
FD.SSOCK .DA #S.FD.T.SSOCK
2021-05-19 12:44:47 +00:00
.DA #0 S.FD.PFT
.BS 1 S.FD.SSOCK.IOH
2018-11-01 08:53:47 +00:00
.DA #0 S.FD.SSOCK.OPEN
2019-05-08 19:41:46 +00:00
.DA #LIBTCPIP.shutdown
2018-10-10 15:39:22 +00:00
.DA #LIBTCPIP.Read
.DA #LIBTCPIP.Write
2019-03-01 14:36:20 +00:00
.DA #LIBTCPIP.EOF
2018-10-01 15:52:58 +00:00
*--------------------------------------
.DA #AF.INET S.SOCKET.AF
.DA #S.SOCKET.T.STREAM
2018-10-08 05:55:28 +00:00
.DA #S.IP.PROTOCOL.TCP
2019-10-03 06:25:27 +00:00
FD.SSOCK.SIZE .EQ *-FD.SSOCK
2018-07-26 15:26:39 +00:00
*--------------------------------------
IOCTL .BS S.IOCTL
DCB.NIC .BS S.DCB.NIC
IPCFG .BS S.IPCFG
DNS.CACHE .BS K.DNSCACHE.SIZE*S.DNSCACHE
*--------------------------------------
2018-09-17 15:42:38 +00:00
ARP.REQ .HS FFFFFFFFFFFF S.ETH.DSTMAC
ARP.REQ.SRCMAC .BS 6
2018-11-06 16:31:13 +00:00
ARP.REQ.ETYPE .DA /S.ETH.EII.TYPE.ARP
.DA #S.ETH.EII.TYPE.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
*--------------------------------------
2018-08-08 15:13:37 +00:00
ARP.REP .EQ *
ARP.REP.DSTMAC .BS 6
ARP.REP.SRCMAC .BS 6
2018-11-06 16:31:13 +00:00
ARP.REP.ETYPE .DA /S.ETH.EII.TYPE.ARP
.DA #S.ETH.EII.TYPE.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
*--------------------------------------
2016-03-15 17:16:14 +00:00
DNS.MSG
DNS.MSG.ID .BS 2
.DA /S.DNS.F.RD Flags=query
.DA #S.DNS.F.RD
.DA $100 QDCOUNT
.BS 6 ANCOUNT,NSCOUNT,ARCOUNT
2016-03-15 17:16:14 +00:00
DNS.MSG.NAME .BS K.DNS.MAXLEN+6
*--------------------------------------
2018-09-10 15:07:26 +00:00
DNS.MSG.LEN .BS 2
*--------------------------------------
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
2018-07-23 15:28:42 +00:00
FRM.QUEUE.LenL .BS K.FRMQUEUE.SIZE
FRM.QUEUE.LenH .BS K.FRMQUEUE.SIZE
*--------------------------------------
RefCount .DA #0
2019-06-20 06:39:28 +00:00
hARPCache .DA #0
2017-02-13 07:26:18 +00:00
DYNPORT.LAST .DA K.DYNPORT.START
2018-10-08 15:41:00 +00:00
hDNSSocket .BS 1
2016-03-15 17:16:14 +00:00
DNS.TmpCache .BS S.DNSCACHE
2019-03-11 07:01:40 +00:00
ARP.TmpCache .BS S.ARPCACHE
2018-11-06 16:31:13 +00:00
*--------------------------------------
2018-10-01 05:48:42 +00:00
SKT.LOC.ADDR .BS S.SOCKADDR
SKT.REM.ADDR .BS S.SOCKADDR
2019-05-13 15:40:37 +00:00
SKT.Cache .EQ *-S.SOCKET.TCP.INTAIL
.BS S.SOCKET.TCP-S.SOCKET.TCP.INTAIL
2017-01-29 21:47:19 +00:00
hFrameIn .BS 1
hFrameOut .BS 1
2018-05-25 19:03:31 +00:00
HST.SScanF .AZ "%d.%d.%d.%d"
2020-09-12 12:09:24 +00:00
IP.ID .DA $A205
2015-03-14 21:48:35 +00:00
*--------------------------------------
MAN
2020-07-25 07:05:25 +00:00
SAVE usr/src/lib/libtcpip.s
2015-03-14 21:48:35 +00:00
ASM