2015-03-14 21:48:35 +00:00
|
|
|
|
PR#3
|
2017-03-29 15:48:15 +00:00
|
|
|
|
PREFIX /A2OSX.BUILD
|
2017-01-29 21:47:19 +00:00
|
|
|
|
LOMEM $A00
|
2015-03-14 21:48:35 +00:00
|
|
|
|
INC 1
|
|
|
|
|
AUTO 6
|
|
|
|
|
.LIST OFF
|
|
|
|
|
.OP 65C02
|
|
|
|
|
.OR $2000
|
2017-03-29 15:48:15 +00:00
|
|
|
|
.TF /A2OSX.BUILD/SBIN/DHCPCLNT
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2017-03-29 15:48:15 +00:00
|
|
|
|
.INB /A2OSX.BUILD/INC/MACROS.I
|
|
|
|
|
.INB /A2OSX.BUILD/INC/A2OSX.I
|
|
|
|
|
.INB /A2OSX.BUILD/INC/LIBTCPIP.I
|
|
|
|
|
.INB /A2OSX.BUILD/INC/NET.DHCP.I
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2017-03-09 16:38:27 +00:00
|
|
|
|
TIMEOUT.MAX .EQ 200 20 sec.
|
2016-03-13 21:54:28 +00:00
|
|
|
|
*--------------------------------------
|
2016-03-27 21:00:19 +00:00
|
|
|
|
ZPIPCfgPtr .EQ ZPBIN
|
|
|
|
|
ZPFrameBase .EQ ZPBIN+2
|
|
|
|
|
ZPFramePtr .EQ ZPBIN+4
|
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
|
2017-10-06 06:33:21 +00:00
|
|
|
|
.DA CS.END-CS.START CS
|
|
|
|
|
.DA DS.END-DS.START DS
|
|
|
|
|
.DA #16 SS
|
|
|
|
|
.DA #6 ZP
|
2015-06-03 18:30:57 +00:00
|
|
|
|
.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
|
|
|
|
|
L.IPCFG .DA IPCFG
|
2016-03-27 21:00:19 +00:00
|
|
|
|
L.Socket .DA Socket
|
2016-03-13 21:54:28 +00:00
|
|
|
|
L.MSG.CFG1 .DA MSG.CFG1
|
|
|
|
|
L.MSG.CFG2 .DA MSG.CFG2
|
2016-01-09 22:39:10 +00:00
|
|
|
|
L.MSG.CFG.KO .DA MSG.CFG.KO
|
|
|
|
|
L.MSG.CFG.OK .DA MSG.CFG.OK
|
2016-03-13 21:54:28 +00:00
|
|
|
|
L.MSG.CFG.ND .DA MSG.CFG.ND
|
2016-01-09 22:39:10 +00:00
|
|
|
|
L.MSG.CFG.NA .DA MSG.CFG.NA
|
2016-03-27 21:00:19 +00:00
|
|
|
|
L.DHCP.DISC .DA DHCP.DISC
|
|
|
|
|
L.DHCP.REQ .DA DHCP.REQ
|
2015-03-14 21:48:35 +00:00
|
|
|
|
.DA 0
|
|
|
|
|
*--------------------------------------
|
2016-01-09 22:39:10 +00:00
|
|
|
|
CS.INIT >LDYA L.LIBTCPIP
|
2017-10-06 06:33:21 +00:00
|
|
|
|
>SYSCALL LoadLib.YA
|
2015-03-14 21:48:35 +00:00
|
|
|
|
sta hLIBTCPIP
|
|
|
|
|
|
|
|
|
|
>LIBCALL hLIBTCPIP,LIBTCPIP.GET.IPCFG
|
|
|
|
|
bcs .9
|
2016-03-27 21:00:19 +00:00
|
|
|
|
>STYA ZPIPCfgPtr
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2016-03-27 21:00:19 +00:00
|
|
|
|
lda (ZPIPCfgPtr)
|
2016-01-16 22:05:07 +00:00
|
|
|
|
and #S.IPCFG.STATUS.OK
|
|
|
|
|
bne .99 Already Configured, exit
|
2016-01-09 22:39:10 +00:00
|
|
|
|
|
2016-03-13 21:54:28 +00:00
|
|
|
|
ldy #S.IPCFG.HDEV
|
2016-03-27 21:00:19 +00:00
|
|
|
|
lda (ZPIPCfgPtr),y
|
2016-03-13 21:54:28 +00:00
|
|
|
|
beq .98
|
|
|
|
|
|
2016-03-27 21:00:19 +00:00
|
|
|
|
ldy #S.IPCFG-1
|
|
|
|
|
.1 lda (ZPIPCfgPtr),y
|
2015-03-14 21:48:35 +00:00
|
|
|
|
sta IPCFG,y
|
2016-03-27 21:00:19 +00:00
|
|
|
|
dey
|
|
|
|
|
bne .1
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2016-03-27 21:00:19 +00:00
|
|
|
|
stz IPCFG
|
|
|
|
|
|
2017-03-09 07:11:44 +00:00
|
|
|
|
ldx #3
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2017-03-09 07:11:44 +00:00
|
|
|
|
.11 lda A2osX.TIMER16,x
|
|
|
|
|
sta DHCP.DISC.XID,x
|
|
|
|
|
sta DHCP.REQ.XID,x
|
|
|
|
|
dex
|
|
|
|
|
bpl .11
|
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
ldx #5
|
2016-01-16 22:05:07 +00:00
|
|
|
|
.2 lda IPCFG+S.IPCFG.MAC,x
|
2016-03-27 21:00:19 +00:00
|
|
|
|
sta DHCP.DISC.CHADDR,x
|
|
|
|
|
sta DHCP.REQ.CHADDR,x
|
2015-03-14 21:48:35 +00:00
|
|
|
|
dex
|
|
|
|
|
bpl .2
|
|
|
|
|
|
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
|
|
|
|
|
.9 rts
|
2016-01-09 22:39:10 +00:00
|
|
|
|
|
2016-03-13 21:54:28 +00:00
|
|
|
|
.98 >LDYA L.MSG.CFG.ND
|
|
|
|
|
bra .90
|
2016-01-09 22:39:10 +00:00
|
|
|
|
.99 >LDYA L.MSG.CFG.NA
|
2017-08-25 15:02:16 +00:00
|
|
|
|
.90 >SYSCALL PrintF.YA
|
2016-01-09 22:39:10 +00:00
|
|
|
|
lda #0
|
|
|
|
|
sec
|
|
|
|
|
rts
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2016-03-27 21:00:19 +00:00
|
|
|
|
CS.RUN >PUSHW L.Socket
|
2017-01-30 21:03:12 +00:00
|
|
|
|
|
2017-02-15 21:46:21 +00:00
|
|
|
|
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.New
|
2016-03-27 21:00:19 +00:00
|
|
|
|
bcc .1
|
|
|
|
|
jmp CS.RUN.KO
|
|
|
|
|
|
|
|
|
|
.1 txa
|
|
|
|
|
ldy #hSocket
|
|
|
|
|
sta (pData),y
|
|
|
|
|
|
|
|
|
|
>LDYA L.MSG.CFG1
|
2017-08-25 15:02:16 +00:00
|
|
|
|
>SYSCALL PrintF.YA
|
2016-01-09 22:39:10 +00:00
|
|
|
|
|
2016-03-27 21:00:19 +00:00
|
|
|
|
jsr Init.Timeout
|
|
|
|
|
|
2017-02-13 07:26:18 +00:00
|
|
|
|
CS.RUN.SDISC ldy #hSocket
|
|
|
|
|
>PUSHB (pData),y
|
2016-03-27 21:00:19 +00:00
|
|
|
|
>PUSHW L.DHCP.DISC
|
2017-02-13 07:26:18 +00:00
|
|
|
|
>PUSHWI DHCP.DISC.LEN
|
2017-02-15 16:14:41 +00:00
|
|
|
|
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.Write
|
2016-03-27 21:00:19 +00:00
|
|
|
|
bcc .1
|
|
|
|
|
jmp CS.RUN.KO
|
2016-03-13 21:54:28 +00:00
|
|
|
|
|
2016-03-27 21:00:19 +00:00
|
|
|
|
.1 lda #S.IPCFG.STATUS.SDISC
|
2015-03-14 21:48:35 +00:00
|
|
|
|
sta IPCFG
|
2016-03-13 21:54:28 +00:00
|
|
|
|
|
2017-11-17 16:16:05 +00:00
|
|
|
|
CS.RUN.ROFFER >SLEEP
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2016-03-27 21:00:19 +00:00
|
|
|
|
jsr CS.RUN.SKT.RCVD
|
|
|
|
|
bcc .1
|
2016-03-13 21:54:28 +00:00
|
|
|
|
jsr Wait.Timeout
|
2017-03-09 07:11:44 +00:00
|
|
|
|
bne CS.RUN.ROFFER
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2016-03-27 21:00:19 +00:00
|
|
|
|
lda #1
|
|
|
|
|
jmp CS.RUN.KO
|
|
|
|
|
|
|
|
|
|
.1 jsr CheckDHCPOffer
|
|
|
|
|
|
|
|
|
|
bcs CS.RUN.ROFFER
|
|
|
|
|
|
|
|
|
|
lda #S.IPCFG.STATUS.ROFFER
|
|
|
|
|
sta IPCFG
|
|
|
|
|
|
|
|
|
|
CS.RUN.SREQ ldx #3
|
2016-03-13 21:54:28 +00:00
|
|
|
|
|
|
|
|
|
.1 >PUSHB IPCFG+S.IPCFG.DHCPSRVR,x
|
|
|
|
|
dex
|
|
|
|
|
bpl .1
|
|
|
|
|
|
|
|
|
|
>LDYA L.MSG.CFG2
|
2017-08-25 15:02:16 +00:00
|
|
|
|
>SYSCALL PrintF.YA
|
2016-03-13 21:54:28 +00:00
|
|
|
|
|
2017-02-13 07:26:18 +00:00
|
|
|
|
ldy #hSocket
|
|
|
|
|
>PUSHB (pData),y
|
2016-03-27 21:00:19 +00:00
|
|
|
|
>PUSHW L.DHCP.REQ
|
2017-02-13 07:26:18 +00:00
|
|
|
|
>PUSHWI DHCP.REQ.LEN
|
2017-02-15 16:14:41 +00:00
|
|
|
|
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.Write
|
2015-03-14 21:48:35 +00:00
|
|
|
|
bcs CS.RUN.KO
|
|
|
|
|
|
|
|
|
|
lda #S.IPCFG.STATUS.SREQ
|
|
|
|
|
sta IPCFG
|
|
|
|
|
|
2017-11-17 16:16:05 +00:00
|
|
|
|
CS.RUN.RACK >SLEEP
|
2016-03-27 21:00:19 +00:00
|
|
|
|
|
|
|
|
|
jsr CS.RUN.SKT.RCVD
|
|
|
|
|
bcc .1
|
2016-03-13 21:54:28 +00:00
|
|
|
|
jsr Wait.Timeout
|
2017-03-09 07:11:44 +00:00
|
|
|
|
bne CS.RUN.RACK
|
2015-03-14 21:48:35 +00:00
|
|
|
|
lda #2
|
2016-03-27 21:00:19 +00:00
|
|
|
|
bra CS.RUN.KO
|
2016-03-13 21:54:28 +00:00
|
|
|
|
|
2016-03-27 21:00:19 +00:00
|
|
|
|
.1 jsr CheckDHCPAck
|
|
|
|
|
bcs CS.RUN.RACK
|
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
CS.RUN.OK lda #S.IPCFG.STATUS.OK
|
|
|
|
|
sta IPCFG
|
|
|
|
|
|
|
|
|
|
>PUSHW L.IPCFG
|
|
|
|
|
>LIBCALL hLIBTCPIP,LIBTCPIP.SET.IPCFG
|
|
|
|
|
|
2016-01-09 22:39:10 +00:00
|
|
|
|
ldx #3
|
|
|
|
|
.1 lda IPCFG+S.IPCFG.MASK,x
|
|
|
|
|
>PUSHA
|
|
|
|
|
dex
|
|
|
|
|
bpl .1
|
|
|
|
|
|
|
|
|
|
ldx #3
|
|
|
|
|
.2 lda IPCFG+S.IPCFG.IP,x
|
|
|
|
|
>PUSHA
|
|
|
|
|
dex
|
|
|
|
|
bpl .2
|
|
|
|
|
|
|
|
|
|
>LDYA L.MSG.CFG.OK
|
2017-08-25 15:02:16 +00:00
|
|
|
|
>SYSCALL PrintF.YA
|
2015-03-14 21:48:35 +00:00
|
|
|
|
lda #0 Leave with NO ERROR
|
|
|
|
|
sec
|
|
|
|
|
rts
|
2016-03-27 21:00:19 +00:00
|
|
|
|
|
|
|
|
|
CS.RUN.KO pha
|
|
|
|
|
>PUSHA
|
|
|
|
|
>LDYA L.MSG.CFG.KO
|
2017-08-25 15:02:16 +00:00
|
|
|
|
>SYSCALL PrintF.YA
|
2016-03-27 21:00:19 +00:00
|
|
|
|
pla
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN.SKT.RCVD ldy #hSocket
|
|
|
|
|
lda (pData),y
|
2017-02-15 16:14:41 +00:00
|
|
|
|
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.ReadA
|
2016-03-27 21:00:19 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
ldy #hFrame
|
|
|
|
|
sta (pData),y
|
2017-08-25 06:37:21 +00:00
|
|
|
|
>SYSCALL GetMemPtr.A
|
2016-03-27 21:00:19 +00:00
|
|
|
|
>STYA ZPFrameBase
|
|
|
|
|
.9 rts
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2017-01-29 21:47:19 +00:00
|
|
|
|
CS.RUN.DISCARD ldy #hFrame
|
|
|
|
|
lda (pData),y
|
2017-08-25 06:37:21 +00:00
|
|
|
|
>SYSCALL FreeMem.A
|
2017-01-29 21:47:19 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2015-06-03 18:30:57 +00:00
|
|
|
|
CS.DOEVENT lda (pEvent)
|
2017-01-26 21:57:35 +00:00
|
|
|
|
bpl .9 is it a TIMER event?
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2016-03-13 21:54:28 +00:00
|
|
|
|
ldy #TimeOut
|
|
|
|
|
lda (pData),y
|
2015-03-14 21:48:35 +00:00
|
|
|
|
beq .9
|
2017-01-26 21:57:35 +00:00
|
|
|
|
|
2016-03-27 21:00:19 +00:00
|
|
|
|
dec
|
2016-03-13 21:54:28 +00:00
|
|
|
|
sta (pData),y
|
2017-01-26 21:57:35 +00:00
|
|
|
|
|
2016-03-27 21:00:19 +00:00
|
|
|
|
.9 sec do not discard TIMER event
|
2016-03-13 21:54:28 +00:00
|
|
|
|
rts
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2017-03-19 21:47:54 +00:00
|
|
|
|
CS.QUIT ldy #hSocket
|
2016-03-27 21:00:19 +00:00
|
|
|
|
lda (pData),y
|
2017-03-16 07:32:24 +00:00
|
|
|
|
beq .1
|
2017-01-31 22:13:26 +00:00
|
|
|
|
|
2017-03-16 16:59:24 +00:00
|
|
|
|
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.CloseA
|
2016-03-27 21:00:19 +00:00
|
|
|
|
|
2017-03-16 07:32:24 +00:00
|
|
|
|
.1 lda hLIBTCPIP
|
2017-10-06 06:33:21 +00:00
|
|
|
|
>SYSCALL UnloadLib.A
|
2015-03-14 21:48:35 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2016-03-27 21:00:19 +00:00
|
|
|
|
CheckDHCPOffer jsr CheckDHCPXID
|
2015-03-14 21:48:35 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
2017-03-09 07:11:44 +00:00
|
|
|
|
lda ZPFrameBase
|
|
|
|
|
clc
|
|
|
|
|
adc #S.DHCP.OPTIONS
|
|
|
|
|
sta ZPFramePtr
|
|
|
|
|
|
|
|
|
|
lda ZPFrameBase+1
|
|
|
|
|
adc /S.DHCP.OPTIONS
|
|
|
|
|
sta ZPFramePtr+1
|
|
|
|
|
|
|
|
|
|
lda (ZPFramePtr)
|
|
|
|
|
cmp #S.DHCP.OPTIONS.MSGTYPE
|
|
|
|
|
bne .9
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2017-03-09 07:11:44 +00:00
|
|
|
|
ldy #2
|
2016-03-27 21:00:19 +00:00
|
|
|
|
lda (ZPFramePtr),y
|
2015-03-14 21:48:35 +00:00
|
|
|
|
cmp #S.DHCP.OPTIONS.DHCPOffer
|
|
|
|
|
bne .9
|
|
|
|
|
|
2017-03-09 16:38:27 +00:00
|
|
|
|
ldy #S.DHCP.GIADDR+3
|
2015-03-14 21:48:35 +00:00
|
|
|
|
ldx #3
|
2017-03-09 07:11:44 +00:00
|
|
|
|
|
2016-03-27 21:00:19 +00:00
|
|
|
|
.1 lda (ZPFrameBase),y
|
2017-03-09 16:38:27 +00:00
|
|
|
|
sta DHCP.REQ.GIADDR,x
|
|
|
|
|
dey
|
|
|
|
|
dex
|
|
|
|
|
bpl .1
|
|
|
|
|
|
|
|
|
|
ldy #S.DHCP.YIADDR+3
|
|
|
|
|
ldx #3
|
|
|
|
|
|
|
|
|
|
.2 lda (ZPFrameBase),y
|
2016-03-27 21:00:19 +00:00
|
|
|
|
sta DHCP.REQ.OPT.REQIP,x
|
2017-03-09 07:11:44 +00:00
|
|
|
|
sta IPCFG+S.IPCFG.IP,x
|
2015-03-14 21:48:35 +00:00
|
|
|
|
dey
|
|
|
|
|
dex
|
2017-03-09 16:38:27 +00:00
|
|
|
|
bpl .2
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
|
|
|
|
ldy #S.IP.SRC+3
|
|
|
|
|
ldx #3
|
2017-03-09 07:11:44 +00:00
|
|
|
|
|
2016-03-27 21:00:19 +00:00
|
|
|
|
.3 lda (ZPFrameBase),y
|
|
|
|
|
sta DHCP.REQ.OPT.SVRIP,x
|
2017-03-09 07:11:44 +00:00
|
|
|
|
sta IPCFG+S.IPCFG.DHCPSRVR,x
|
2015-03-14 21:48:35 +00:00
|
|
|
|
dey
|
|
|
|
|
dex
|
|
|
|
|
bpl .3
|
|
|
|
|
|
2016-03-27 21:00:19 +00:00
|
|
|
|
.5 inc ZPFramePtr skip Option 53 (DHCPOffer:530102)
|
2015-03-14 21:48:35 +00:00
|
|
|
|
bne .6
|
2016-03-27 21:00:19 +00:00
|
|
|
|
inc ZPFramePtr+1
|
2017-03-09 07:11:44 +00:00
|
|
|
|
|
2016-03-27 21:00:19 +00:00
|
|
|
|
.6 lda (ZPFramePtr)
|
2015-03-14 21:48:35 +00:00
|
|
|
|
sec
|
2016-03-27 21:00:19 +00:00
|
|
|
|
adc ZPFramePtr add option len + 1
|
|
|
|
|
sta ZPFramePtr
|
2015-03-14 21:48:35 +00:00
|
|
|
|
bcc .7
|
2016-03-27 21:00:19 +00:00
|
|
|
|
inc ZPFramePtr+1
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2016-03-27 21:00:19 +00:00
|
|
|
|
.7 lda (ZPFramePtr)
|
2015-03-14 21:48:35 +00:00
|
|
|
|
cmp #S.DHCP.OPTIONS.END
|
|
|
|
|
beq .8
|
|
|
|
|
jsr GetDHCPOption
|
|
|
|
|
bra .5
|
2017-01-29 21:47:19 +00:00
|
|
|
|
|
|
|
|
|
.8 jsr CS.RUN.DISCARD
|
|
|
|
|
clc
|
2015-03-14 21:48:35 +00:00
|
|
|
|
rts
|
|
|
|
|
|
2017-01-29 21:47:19 +00:00
|
|
|
|
.9 jsr CS.RUN.DISCARD
|
|
|
|
|
sec
|
2015-03-14 21:48:35 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
GetDHCPOption cmp #S.DHCP.OPTIONS.MASK
|
|
|
|
|
bne .1
|
2016-11-27 21:59:46 +00:00
|
|
|
|
ldx #S.IPCFG.MASK
|
2015-03-14 21:48:35 +00:00
|
|
|
|
bra GetDHCPOption.CopyIP
|
|
|
|
|
|
|
|
|
|
.1 cmp #S.DHCP.OPTIONS.GW
|
|
|
|
|
bne .2
|
2016-11-27 21:59:46 +00:00
|
|
|
|
|
|
|
|
|
ldx #S.IPCFG.GW
|
2015-03-14 21:48:35 +00:00
|
|
|
|
bra GetDHCPOption.CopyIP
|
|
|
|
|
|
|
|
|
|
.2 cmp #S.DHCP.OPTIONS.DNS
|
|
|
|
|
bne .3
|
2016-11-27 21:59:46 +00:00
|
|
|
|
|
|
|
|
|
ldx #S.IPCFG.DNS1
|
2015-03-14 21:48:35 +00:00
|
|
|
|
bra GetDHCPOption.CopyIP
|
|
|
|
|
|
|
|
|
|
.3 cmp #S.DHCP.OPTIONS.DOMAIN
|
|
|
|
|
bne .9
|
|
|
|
|
|
|
|
|
|
ldy #1
|
|
|
|
|
|
2016-11-27 21:59:46 +00:00
|
|
|
|
lda (ZPFramePtr),y Get String len
|
|
|
|
|
cmp #80
|
|
|
|
|
bcc .4
|
|
|
|
|
lda #79
|
|
|
|
|
|
|
|
|
|
.4 sta IPCFG+S.IPCFG.DOMAIN store len
|
|
|
|
|
tax
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2016-11-27 21:59:46 +00:00
|
|
|
|
.5 iny
|
|
|
|
|
lda (ZPFramePtr),y
|
|
|
|
|
sta IPCFG+S.IPCFG.DOMAIN-1,y
|
|
|
|
|
dex
|
|
|
|
|
bne .5
|
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
.9 rts
|
2016-11-27 21:59:46 +00:00
|
|
|
|
*--------------------------------------
|
2015-03-14 21:48:35 +00:00
|
|
|
|
GetDHCPOption.CopyIP
|
2016-11-27 21:59:46 +00:00
|
|
|
|
ldy #1
|
|
|
|
|
lda (ZPFramePtr),y Get Byte count
|
|
|
|
|
cmp #9
|
|
|
|
|
bcc .1
|
|
|
|
|
lda #8 max 8 bytes (2 DNS)
|
|
|
|
|
|
|
|
|
|
.1 iny
|
|
|
|
|
|
|
|
|
|
.2 pha
|
|
|
|
|
|
|
|
|
|
lda (ZPFramePtr),y
|
|
|
|
|
sta IPCFG,x
|
2015-03-14 21:48:35 +00:00
|
|
|
|
iny
|
|
|
|
|
inx
|
2016-11-27 21:59:46 +00:00
|
|
|
|
|
|
|
|
|
pla
|
|
|
|
|
dec
|
2015-03-14 21:48:35 +00:00
|
|
|
|
bne .2
|
2016-11-27 21:59:46 +00:00
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2016-03-27 21:00:19 +00:00
|
|
|
|
CheckDHCPAck jsr CheckDHCPXID
|
2015-03-14 21:48:35 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
2017-03-09 07:11:44 +00:00
|
|
|
|
lda ZPFrameBase
|
|
|
|
|
clc
|
|
|
|
|
adc #S.DHCP.OPTIONS
|
|
|
|
|
sta ZPFramePtr
|
|
|
|
|
|
|
|
|
|
lda ZPFrameBase+1
|
|
|
|
|
adc /S.DHCP.OPTIONS
|
|
|
|
|
sta ZPFramePtr+1
|
|
|
|
|
|
|
|
|
|
lda (ZPFramePtr)
|
|
|
|
|
cmp #S.DHCP.OPTIONS.MSGTYPE
|
|
|
|
|
bne .9
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2017-03-09 07:11:44 +00:00
|
|
|
|
ldy #2
|
2016-03-27 21:00:19 +00:00
|
|
|
|
lda (ZPFramePtr),y
|
2015-03-14 21:48:35 +00:00
|
|
|
|
cmp #S.DHCP.OPTIONS.DHCPAck
|
|
|
|
|
bne .9
|
|
|
|
|
|
2017-01-29 21:47:19 +00:00
|
|
|
|
jsr CS.RUN.DISCARD
|
2015-03-14 21:48:35 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
2017-01-29 21:47:19 +00:00
|
|
|
|
.9 jsr CS.RUN.DISCARD
|
|
|
|
|
sec
|
2015-03-14 21:48:35 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CheckDHCPXID ldy #S.DHCP.XID+3
|
|
|
|
|
ldx #3
|
2017-03-09 07:11:44 +00:00
|
|
|
|
|
2016-03-27 21:00:19 +00:00
|
|
|
|
.1 lda (ZPFrameBase),y
|
|
|
|
|
cmp DHCP.DISC.XID,x same XID ?
|
2015-03-14 21:48:35 +00:00
|
|
|
|
bne .9
|
|
|
|
|
dey
|
|
|
|
|
dex
|
|
|
|
|
bpl .1
|
2017-01-29 21:47:19 +00:00
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
2017-01-29 21:47:19 +00:00
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
.9 sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2016-03-13 21:54:28 +00:00
|
|
|
|
Init.Timeout ldy #TimeOut
|
|
|
|
|
lda #TIMEOUT.MAX
|
|
|
|
|
sta (pData),y
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-03-09 07:11:44 +00:00
|
|
|
|
Wait.TimeOut ldy #TimeOut
|
2016-03-13 21:54:28 +00:00
|
|
|
|
lda (pData),y
|
2017-03-09 07:11:44 +00:00
|
|
|
|
rts
|
2016-03-13 21:54:28 +00:00
|
|
|
|
*--------------------------------------
|
2015-03-14 21:48:35 +00:00
|
|
|
|
CS.END
|
2017-10-06 06:33:21 +00:00
|
|
|
|
LIBTCPIP >CSTR "libtcpip.o"
|
2017-02-28 16:58:36 +00:00
|
|
|
|
MSG.CFG1 >CSTR "DHCPCLNT:Searching for DHCP servers...\r\n"
|
|
|
|
|
MSG.CFG2 >CSTR "DHCPCLNT:Reply from DHCP Server at %d.%d.%d.%d, requesting...\r\n"
|
|
|
|
|
MSG.CFG.KO >CSTR "DHCPCLNT:Time Out [%h].\r\n"
|
|
|
|
|
MSG.CFG.OK >CSTR "DHCPCLNT:Success:[IP=%d.%d.%d.%d/%d.%d.%d.%d]\r\n"
|
|
|
|
|
MSG.CFG.ND >CSTR "DHCPCLNT:No Device, exiting.\r\n"
|
|
|
|
|
MSG.CFG.NA >CSTR "DHCPCLNT:TCPIP Already configured, exiting.\r\n"
|
2016-03-13 21:54:28 +00:00
|
|
|
|
hLIBTCPIP .BS 1
|
|
|
|
|
IPCFG .BS S.IPCFG
|
2016-03-27 21:00:19 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
Socket .DA #S.SOCKET.SOCK.DGRAM
|
|
|
|
|
.BS 3
|
|
|
|
|
.HS 00.00.00.00 Socket.Src.Addr
|
|
|
|
|
.DA UDP.PORT.DHCPC Socket.Src.Port
|
|
|
|
|
.HS FF.FF.FF.FF Socket.Dst.Addr
|
|
|
|
|
.DA UDP.PORT.DHCPS Socket.Dst.Port
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
DHCP.DISC .HS 01010600 OP,HTYPE,HLEN,HOPS
|
|
|
|
|
DHCP.DISC.XID .BS 4
|
2016-03-13 21:54:28 +00:00
|
|
|
|
.HS 0000 SECS
|
2017-03-16 16:59:24 +00:00
|
|
|
|
.DA S.DHCP.FLAGS.BRDCST
|
2016-03-13 21:54:28 +00:00
|
|
|
|
.HS 00000000 CIADDR
|
2016-03-27 21:00:19 +00:00
|
|
|
|
DHCP.DISC.YIADDR .HS 00000000
|
2016-03-13 21:54:28 +00:00
|
|
|
|
.HS 00000000 SIADDR
|
2017-03-09 16:38:27 +00:00
|
|
|
|
DHCP.DISC.GIADDR .HS 00000000
|
2016-03-27 21:00:19 +00:00
|
|
|
|
DHCP.DISC.CHADDR .HS 00000000.00000000.00000000.00000000
|
2016-03-13 21:54:28 +00:00
|
|
|
|
.BS 64 SNAME
|
|
|
|
|
.BS 128 FILE
|
|
|
|
|
.HS 63825363 COOKIE
|
|
|
|
|
.HS 3501 OPT
|
2015-03-14 21:48:35 +00:00
|
|
|
|
.DA #S.DHCP.OPTIONS.DHCPDiscover
|
|
|
|
|
.HS 37040103060FFF
|
2016-03-27 21:00:19 +00:00
|
|
|
|
DHCP.DISC.LEN .EQ *-DHCP.DISC
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
DHCP.REQ .HS 01010600 OP,HTYPE,HLEN,HOPS
|
|
|
|
|
DHCP.REQ.XID .BS 4
|
2016-03-13 21:54:28 +00:00
|
|
|
|
.HS 0000 SECS
|
2017-03-16 16:59:24 +00:00
|
|
|
|
.DA S.DHCP.FLAGS.BRDCST
|
2016-03-13 21:54:28 +00:00
|
|
|
|
.HS 00000000 CIADDR
|
2016-03-27 21:00:19 +00:00
|
|
|
|
DHCP.REQ.YIADDR .HS 00000000
|
2016-03-13 21:54:28 +00:00
|
|
|
|
.HS 00000000 SIADDR
|
2017-03-09 16:38:27 +00:00
|
|
|
|
DHCP.REQ.GIADDR .HS 00000000
|
2016-03-27 21:00:19 +00:00
|
|
|
|
DHCP.REQ.CHADDR .HS 00000000.00000000.00000000.00000000
|
2016-03-13 21:54:28 +00:00
|
|
|
|
.BS 64 SNAME
|
|
|
|
|
.BS 128 FILE
|
|
|
|
|
.HS 63825363 COOKIE
|
|
|
|
|
.HS 3501 OPT
|
2015-03-14 21:48:35 +00:00
|
|
|
|
.DA #S.DHCP.OPTIONS.DHCPRequest
|
|
|
|
|
.HS 3204
|
2016-03-27 21:00:19 +00:00
|
|
|
|
DHCP.REQ.OPT.REQIP .BS 4
|
2015-03-14 21:48:35 +00:00
|
|
|
|
.HS 3604
|
2016-03-27 21:00:19 +00:00
|
|
|
|
DHCP.REQ.OPT.SVRIP .BS 4
|
2015-03-14 21:48:35 +00:00
|
|
|
|
.HS FF
|
2016-03-27 21:00:19 +00:00
|
|
|
|
DHCP.REQ.LEN .EQ *-DHCP.REQ
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2015-06-03 18:30:57 +00:00
|
|
|
|
DS.START
|
2016-03-13 21:54:28 +00:00
|
|
|
|
TimeOut .BS 1
|
2016-03-27 21:00:19 +00:00
|
|
|
|
hSocket .BS 1
|
|
|
|
|
hFrame .BS 1
|
2015-03-14 21:48:35 +00:00
|
|
|
|
DS.END
|
|
|
|
|
MAN
|
2017-03-29 15:48:15 +00:00
|
|
|
|
SAVE /A2OSX.SRC/SBIN/DHCPCLNT.S
|
2015-03-14 21:48:35 +00:00
|
|
|
|
ASM
|