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/LIB/LIBTCPIP.O
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
.INB INC/MACROS.I
|
|
|
|
|
.INB INC/A2OSX.I
|
|
|
|
|
.INB INC/LIBTCPIP.I
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
ZPFrameBase1 .EQ ZPLIB
|
|
|
|
|
ZPFrameLen1 .EQ ZPLIB+2
|
|
|
|
|
ZPFramePtr1 .EQ ZPLIB+4
|
2016-01-16 22:04:22 +00:00
|
|
|
|
ZPFrameBase2 .EQ ZPBIN+6
|
|
|
|
|
ZPFrameLen2 .EQ ZPBIN+8
|
|
|
|
|
ZPFramePtr2 .EQ ZPBIN+10
|
|
|
|
|
ZPPtrIP .EQ ZPLIB+12
|
|
|
|
|
ZPPtrMAC .EQ ZPLIB+14
|
|
|
|
|
ZPPtrDNS .EQ ZPLIB+16
|
|
|
|
|
ZPPtrSKT .EQ ZPLIB+18
|
|
|
|
|
ZPTmpPtr1 .EQ ZPLIB+20
|
|
|
|
|
ZPTmpPtr2 .EQ ZPLIB+22
|
|
|
|
|
ZPDataPtr .EQ ZPLIB+24
|
|
|
|
|
ZPDataLen .EQ ZPLIB+26
|
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
|
|
|
|
|
|
|
|
|
|
.DA NEW.ICMP.FRAME
|
|
|
|
|
.DA NEW.TCP.FRAME
|
|
|
|
|
.DA NEW.UDP.FRAME
|
|
|
|
|
.DA NEW.IP.FRAME
|
|
|
|
|
.DA NEW.ARP.FRAME
|
|
|
|
|
.DA NEW.ETH.FRAME
|
|
|
|
|
|
|
|
|
|
.DA SEND.ICMP.FRAME
|
|
|
|
|
.DA SEND.TCP.FRAME
|
|
|
|
|
.DA SEND.UDP.FRAME
|
|
|
|
|
.DA SEND.IP.FRAME
|
|
|
|
|
.DA SEND.ARP.FRAME
|
|
|
|
|
.DA SEND.ETH.FRAME
|
|
|
|
|
|
|
|
|
|
.DA ARP.CLEAR
|
|
|
|
|
.DA ARP.QUERY
|
|
|
|
|
.DA ARP.ADD
|
|
|
|
|
.DA ARP.GETCACHE
|
|
|
|
|
|
|
|
|
|
.DA DNS.CLEAR
|
|
|
|
|
.DA DNS.QUERY
|
|
|
|
|
.DA DNS.ADD
|
|
|
|
|
.DA DNS.GETCACHE
|
|
|
|
|
|
2016-01-16 22:04:22 +00:00
|
|
|
|
.DA ARP.IN
|
|
|
|
|
.DA IP.IN
|
|
|
|
|
|
|
|
|
|
.DA SKT.NEW
|
|
|
|
|
.DA SKT.LISTEN
|
|
|
|
|
.DA SKT.ACCEPT
|
|
|
|
|
.DA SKT.SENDA
|
|
|
|
|
.DA SKT.SEND
|
|
|
|
|
.DA SKT.RCVDA
|
|
|
|
|
.DA SKT.RCVD
|
|
|
|
|
.DA SKT.CLOSE
|
|
|
|
|
.DA SKT.GETTABLE
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
L.IPCFG .DA IPCFG
|
|
|
|
|
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
|
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-01-16 22:04:22 +00:00
|
|
|
|
>LDYA K.DYNPORT.START
|
|
|
|
|
>STYA DYNPORT.LAST
|
2015-03-14 21:48:35 +00:00
|
|
|
|
inc bFirstLoad
|
|
|
|
|
.8 clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
LIB.UNLOAD clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* PULLW = PTR to S.IPCFG
|
|
|
|
|
*--------------------------------------
|
2016-01-16 22:04:22 +00:00
|
|
|
|
SET.IPCFG >PULLW ZPTmpPtr1
|
|
|
|
|
ldy #0
|
|
|
|
|
.1 lda (ZPTmpPtr1),y
|
2015-03-14 21:48:35 +00:00
|
|
|
|
sta IPCFG,y
|
2016-01-16 22:04:22 +00:00
|
|
|
|
iny
|
|
|
|
|
cpy #S.IPCFG
|
2015-03-14 21:48:35 +00:00
|
|
|
|
bne .1
|
2016-01-16 22:04:22 +00:00
|
|
|
|
|
|
|
|
|
lda IPCFG+S.IPCFG.HDEV
|
|
|
|
|
|
2016-01-09 22:36:24 +00:00
|
|
|
|
>SYSCALL SYS.GetDevByIDA
|
|
|
|
|
>STYA NetDevJmp+1
|
2016-01-10 22:17:49 +00:00
|
|
|
|
|
|
|
|
|
ldx #DEVMGR.GETINFO
|
|
|
|
|
jsr NetDevJmp
|
|
|
|
|
|
|
|
|
|
>STYA ZPTmpPtr2
|
|
|
|
|
ldy #S.DEVINFO.FLAGS
|
|
|
|
|
lda (ZPTmpPtr2),y
|
|
|
|
|
sta DevFlags
|
|
|
|
|
and #S.DEVINFO.FLAGS.ARPOFFLOAD
|
|
|
|
|
beq .2
|
2016-01-09 22:36:24 +00:00
|
|
|
|
|
|
|
|
|
>LDYA ZPTmpPtr1
|
2016-01-10 22:17:49 +00:00
|
|
|
|
ldx #DEVMGR.SETIPCFG
|
|
|
|
|
jsr NetDevJmp
|
|
|
|
|
|
|
|
|
|
.2 >LDYA ZPTmpPtr1
|
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
|
|
|
|
*--------------------------------------
|
2016-01-16 22:04:22 +00:00
|
|
|
|
* grab a copy on the fly for lib function
|
|
|
|
|
* OUT :
|
|
|
|
|
* Y,A = PTR to S.IPCFG
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2016-01-16 22:04:22 +00:00
|
|
|
|
GET.IPCFG >LDYA L.IPCFG
|
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
|
|
|
|
*--------------------------------------
|
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
|
|
|
|
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
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2016-01-16 22:04:22 +00:00
|
|
|
|
* A,X = Frame PTR
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2016-01-16 22:04:22 +00:00
|
|
|
|
SetFramePtr1AX clc
|
|
|
|
|
adc ZPFrameBase1
|
|
|
|
|
sta ZPFramePtr1
|
|
|
|
|
txa
|
|
|
|
|
adc ZPFrameBase1+1
|
|
|
|
|
sta ZPFramePtr1+1
|
|
|
|
|
rts
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2016-01-16 22:04:22 +00:00
|
|
|
|
* A,X = Frame PTR
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2016-01-16 22:04:22 +00:00
|
|
|
|
SetFramePtr2AX clc
|
|
|
|
|
adc ZPFrameBase2
|
|
|
|
|
sta ZPFramePtr2
|
|
|
|
|
txa
|
|
|
|
|
adc ZPFrameBase2+1
|
|
|
|
|
sta ZPFramePtr2+1
|
|
|
|
|
rts
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2016-01-16 22:04:22 +00:00
|
|
|
|
* Y = bytes to copy from ZPFramePtr1 to ZPFramePtr2
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2016-01-16 22:04:22 +00:00
|
|
|
|
CopyFramePtr12 dey
|
|
|
|
|
lda (ZPFramePtr1),y
|
|
|
|
|
sta (ZPFramePtr2),y
|
|
|
|
|
tya
|
|
|
|
|
bne CopyFramePtr12
|
|
|
|
|
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
|
|
|
|
|
lda DYNPORT.LAST
|
|
|
|
|
sec
|
|
|
|
|
sbc #K.DYNPORT.END
|
|
|
|
|
lda DYNPORT.LAST+1
|
|
|
|
|
sbc /K.DYNPORT.END
|
|
|
|
|
bcs .1
|
|
|
|
|
>LDAXI K.DYNPORT.END
|
|
|
|
|
>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
|
|
|
|
*--------------------------------------
|
2016-01-16 22:04:22 +00:00
|
|
|
|
PSTR2DNSHostName >STYA ZPTmpPtr1
|
|
|
|
|
|
|
|
|
|
lda (ZPTmpPtr1)
|
|
|
|
|
beq .9
|
|
|
|
|
|
|
|
|
|
cmp #K.DNS.MAXLEN-1
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
tay
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2016-01-16 22:04:22 +00:00
|
|
|
|
inc
|
|
|
|
|
sta DNSHostNameLen
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2016-01-16 22:04:22 +00:00
|
|
|
|
lda #0 Ending 0
|
|
|
|
|
sta DNSHostName+1,y
|
|
|
|
|
|
|
|
|
|
ldx #0
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2016-01-16 22:04:22 +00:00
|
|
|
|
.1 lda (ZPTmpPtr1),y
|
|
|
|
|
and #$7f
|
|
|
|
|
cmp #'.'
|
|
|
|
|
beq .2
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2016-01-16 22:04:22 +00:00
|
|
|
|
cmp #'A'
|
|
|
|
|
bcc .10
|
|
|
|
|
cmp #'Z'+1
|
|
|
|
|
bcs .10
|
|
|
|
|
adc #$20
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2016-01-16 22:04:22 +00:00
|
|
|
|
.10 inx
|
|
|
|
|
bra .3
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2016-01-16 22:04:22 +00:00
|
|
|
|
.2 txa
|
|
|
|
|
ldx #0
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2016-01-16 22:04:22 +00:00
|
|
|
|
.3 sta DNSHostName,y
|
|
|
|
|
dey
|
2015-03-14 21:48:35 +00:00
|
|
|
|
bne .1
|
2016-01-16 22:04:22 +00:00
|
|
|
|
stx DNSHostName
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
|
|
|
|
clc
|
|
|
|
|
rts
|
2016-01-16 22:04:22 +00:00
|
|
|
|
|
|
|
|
|
.9 sec
|
|
|
|
|
rts
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2016-01-16 22:04:22 +00:00
|
|
|
|
DecDataLen lda ZPDataLen
|
|
|
|
|
bne .1
|
|
|
|
|
lda ZPDataLen+1
|
|
|
|
|
beq .9
|
|
|
|
|
dec ZPDataLen+1
|
|
|
|
|
.1 dec ZPDataLen
|
|
|
|
|
lda #$FF Make NZ
|
|
|
|
|
.9 rts
|
2015-10-19 20:35:00 +00:00
|
|
|
|
*--------------------------------------
|
2016-01-16 22:04:22 +00:00
|
|
|
|
NetDevJmp jmp *
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2016-01-16 22:04:22 +00:00
|
|
|
|
.INB LIB/LIBTCPIP.S.FRM
|
2015-03-14 21:48:35 +00:00
|
|
|
|
.INB LIB/LIBTCPIP.S.ARP
|
2016-01-16 22:04:22 +00:00
|
|
|
|
.INB LIB/LIBTCPIP.S.IP
|
|
|
|
|
.INB LIB/LIBTCPIP.S.ICMP
|
|
|
|
|
.INB LIB/LIBTCPIP.S.UDP
|
|
|
|
|
.INB LIB/LIBTCPIP.S.TCP
|
2015-03-14 21:48:35 +00:00
|
|
|
|
.INB LIB/LIBTCPIP.S.DNS
|
2016-01-16 22:04:22 +00:00
|
|
|
|
.INB LIB/LIBTCPIP.S.SKT
|
2016-01-09 22:36:24 +00:00
|
|
|
|
*--------------------------------------
|
2015-03-14 21:48:35 +00:00
|
|
|
|
CS.END
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
bFirstLoad .DA #0
|
|
|
|
|
Status .BS 1
|
2016-01-10 22:17:49 +00:00
|
|
|
|
DevFlags .BS 1
|
2015-10-19 20:35:00 +00:00
|
|
|
|
DNSMessageID .BS 2
|
|
|
|
|
DNSDynamicPort .BS 2
|
|
|
|
|
DNSHostTTL .BS 4
|
|
|
|
|
DNSHostName .BS K.DNS.MAXLEN+1
|
|
|
|
|
DNSHostNameLen .BS 1
|
2015-03-14 21:48:35 +00:00
|
|
|
|
IP.CHECKSUM .BS 4
|
|
|
|
|
IPCFG .BS S.IPCFG
|
|
|
|
|
ARP.CACHE .BS K.ARPCACHE.SIZE*S.ARPCACHE
|
|
|
|
|
DNS.CACHE .BS K.DNSCACHE.SIZE*S.DNSCACHE
|
2016-01-16 22:04:22 +00:00
|
|
|
|
SKT.TABLE .BS K.SKTTABLE.SIZE*S.SOCKET
|
|
|
|
|
hSocket .BS 1
|
|
|
|
|
bFound .BS 1
|
|
|
|
|
DYNPORT.LAST .BS 2
|
2016-01-09 22:36:24 +00:00
|
|
|
|
*TmpCounter .BS 2
|
|
|
|
|
TmpOffset .BS 2
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
|
|
|
|
SAVE LIB/LIBTCPIP.S
|
|
|
|
|
ASM
|