A2osX/BIN/IPCONFIG.S.DHCP.txt

394 lines
6.1 KiB
Plaintext
Raw Normal View History

2018-12-06 16:39:53 +00:00
NEW
2020-08-09 19:47:42 +00:00
AUTO 3,1
2018-12-06 16:39:53 +00:00
*--------------------------------------
2019-01-17 15:05:48 +00:00
DHCP.INIT lda IPCFG+S.NETCFG.STATUS
2018-12-06 16:39:53 +00:00
and #S.IPCFG.STATUS.OK
bne .99 Already Configured, exit
2020-10-30 09:51:37 +00:00
2019-01-17 15:05:48 +00:00
stz IPCFG+S.NETCFG.STATUS
2018-12-06 16:39:53 +00:00
ldx #3
2021-05-19 12:44:47 +00:00
2020-10-29 07:22:39 +00:00
.1 eor A2osX.TIMER16,x
2018-12-06 16:39:53 +00:00
sta DHCP.DISC.XID,x
sta DHCP.REQ.XID,x
dex
2019-01-15 07:36:21 +00:00
bpl .1
2018-12-06 16:39:53 +00:00
ldx #5
2019-01-17 15:05:48 +00:00
.2 lda IPCFG+S.NETCFG.MAC,x
2018-12-06 16:39:53 +00:00
sta DHCP.DISC.CHADDR,x
sta DHCP.REQ.CHADDR,x
dex
bpl .2
2020-10-30 09:51:37 +00:00
2018-12-06 16:39:53 +00:00
clc
.9 rts
2019-01-05 20:33:08 +00:00
.99 >LDYA L.MSG.DHCP.NA
2018-12-06 16:39:53 +00:00
2020-02-28 07:21:46 +00:00
>SYSCALL PutS
2018-12-06 16:39:53 +00:00
sec
rts
*--------------------------------------
2021-05-19 12:44:47 +00:00
DHCP.RUN >PUSHBI S.SOCKET.T.DGRAM
>PUSHBI 0 no protocol
2018-12-06 16:39:53 +00:00
>LIBCALL hLIBTCPIP,LIBTCPIP.Socket
bcc .1
2020-09-12 12:09:24 +00:00
2019-01-05 20:33:08 +00:00
.9 jmp DHCP.RUN.KO
2020-09-12 12:09:24 +00:00
2020-09-01 10:47:39 +00:00
.1 sta hSocket
2021-05-19 12:44:47 +00:00
>PUSHA
2018-12-06 16:39:53 +00:00
>PUSHW L.SA.LOCAL
>LIBCALL hLIBTCPIP,LIBTCPIP.Bind
bcs .9
2020-09-12 12:09:24 +00:00
2020-10-29 07:22:39 +00:00
>SLEEP
2021-05-19 12:44:47 +00:00
>PUSHB hSocket
>PUSHBI S.SOCKET.O.BROADCAST
2018-12-06 16:39:53 +00:00
>LIBCALL hLIBTCPIP,LIBTCPIP.setsockopt
2021-05-19 12:44:47 +00:00
>PUSHB hSocket
2018-12-06 16:39:53 +00:00
>PUSHW L.SA.REMOTE
>LIBCALL hLIBTCPIP,LIBTCPIP.Connect
bcs .9
2020-09-12 12:09:24 +00:00
2019-01-05 20:33:08 +00:00
>LDYA L.MSG.DHCP.CFG1
2020-02-28 07:21:46 +00:00
>SYSCALL PutS
2021-05-19 12:44:47 +00:00
2020-09-12 12:09:24 +00:00
>SLEEP
lda #3
sta RetryCount
2018-12-06 16:39:53 +00:00
2021-05-19 12:44:47 +00:00
DHCP.RUN.SDISC >PUSHB hSocket
2018-12-06 16:39:53 +00:00
>PUSHW L.DHCP.DISC
2021-05-19 12:44:47 +00:00
>PUSHWI DHCP.DISC.LEN
>PUSHW L.SA.DEST
2018-12-06 16:39:53 +00:00
2019-07-07 20:48:57 +00:00
>LIBCALL hLIBTCPIP,LIBTCPIP.SendTo
2018-12-06 16:39:53 +00:00
bcc .1
2021-05-19 12:44:47 +00:00
2019-01-05 20:33:08 +00:00
jmp DHCP.RUN.KO
2018-12-06 16:39:53 +00:00
.1 lda #S.IPCFG.STATUS.SDISC
sta IPCFG
2020-09-01 10:47:39 +00:00
DHCP.RUN.ROFFER jsr DHCP.RUN.SKT.RECV
2018-12-06 16:39:53 +00:00
bcc .1
2021-05-19 12:44:47 +00:00
dec RetryCount
bne DHCP.RUN.SDISC
2018-12-06 16:39:53 +00:00
lda #1
2019-01-05 20:33:08 +00:00
jmp DHCP.RUN.KO
2021-05-19 12:44:47 +00:00
2018-12-06 16:39:53 +00:00
.1 jsr CheckDHCPOffer
2019-01-05 20:33:08 +00:00
bcs DHCP.RUN.ROFFER
2021-06-30 19:09:07 +00:00
2018-12-06 16:39:53 +00:00
lda #S.IPCFG.STATUS.ROFFER
sta IPCFG
2021-05-19 12:44:47 +00:00
2020-02-14 07:21:56 +00:00
DHCP.RUN.SREQ >PUSHW L.MSG.DHCP.CFG2
ldx #0
2018-12-06 16:39:53 +00:00
.1 >PUSHB IPCFG+S.IPCFG.DHCPSRVR,x
2020-02-14 07:21:56 +00:00
inx
cpx #4
bne .1
2020-10-30 09:51:37 +00:00
2018-12-06 16:39:53 +00:00
>PUSHBI 4
2020-02-28 07:21:46 +00:00
>SYSCALL PrintF
2018-12-06 16:39:53 +00:00
2021-05-19 12:44:47 +00:00
>PUSHB hSocket
2018-12-06 16:39:53 +00:00
>PUSHW L.DHCP.REQ
2021-05-19 12:44:47 +00:00
>PUSHWI DHCP.REQ.LEN
>PUSHW L.SA.DEST
2019-07-07 20:48:57 +00:00
>LIBCALL hLIBTCPIP,LIBTCPIP.SendTo
2019-01-05 20:33:08 +00:00
bcs DHCP.RUN.KO
2018-12-06 16:39:53 +00:00
lda #S.IPCFG.STATUS.SREQ
sta IPCFG
2021-05-19 12:44:47 +00:00
2020-09-01 10:47:39 +00:00
DHCP.RUN.RACK jsr DHCP.RUN.SKT.RECV
2018-12-06 16:39:53 +00:00
bcc .1
2021-05-19 12:44:47 +00:00
2018-12-06 16:39:53 +00:00
lda #2
2019-01-05 20:33:08 +00:00
bra DHCP.RUN.KO
2020-08-09 19:47:42 +00:00
2018-12-06 16:39:53 +00:00
.1 jsr CheckDHCPAck
2019-01-05 20:33:08 +00:00
bcs DHCP.RUN.RACK
2020-02-14 07:21:56 +00:00
DHCP.RUN.OK lda #S.IPCFG.STATUS.OK
2018-12-06 16:39:53 +00:00
sta IPCFG
>PUSHW L.IPCFG
2019-01-14 07:11:50 +00:00
>LIBCALL hLIBTCPIP,LIBTCPIP.SETCFG
2018-12-06 16:39:53 +00:00
2020-02-14 07:21:56 +00:00
>PUSHW L.MSG.DHCP.OK
2021-05-19 12:44:47 +00:00
2020-02-14 07:21:56 +00:00
ldx #0
2019-01-05 20:33:08 +00:00
2020-02-14 07:21:56 +00:00
.1 lda IPCFG+S.IPCFG.IP,x
2018-12-06 16:39:53 +00:00
>PUSHA
2020-02-14 07:21:56 +00:00
inx
cpx #4
bne .1
2021-05-19 12:44:47 +00:00
2020-02-14 07:21:56 +00:00
ldx #0
2019-01-05 20:33:08 +00:00
2021-01-12 21:14:13 +00:00
.2 lda IPCFG+S.IPCFG.MASK,x
2018-12-06 16:39:53 +00:00
>PUSHA
2020-02-14 07:21:56 +00:00
inx
cpx #4
bne .2
2021-05-19 12:44:47 +00:00
2018-12-06 16:39:53 +00:00
>PUSHBI 8
2020-02-28 07:21:46 +00:00
>SYSCALL PrintF
2020-09-12 12:09:24 +00:00
2018-12-06 16:39:53 +00:00
lda #0 Leave with NO ERROR
sec
rts
2020-09-12 12:09:24 +00:00
2019-01-05 20:33:08 +00:00
DHCP.RUN.KO pha
2020-02-14 07:21:56 +00:00
>PUSHW L.MSG.DHCP.KO
pla
pha
2018-12-06 16:39:53 +00:00
>PUSHA
>PUSHBI 1
2020-02-28 07:21:46 +00:00
>SYSCALL PrintF
2018-12-06 16:39:53 +00:00
pla
sec
rts
*--------------------------------------
2020-09-01 10:47:39 +00:00
DHCP.RUN.SKT.RECV
lda #TIMEOUT.MAX
sta TimeOut
.1 >SLEEP
2021-05-19 12:44:47 +00:00
2020-09-01 10:47:39 +00:00
lda hSocket
2018-12-06 16:39:53 +00:00
>LIBCALL hLIBTCPIP,LIBTCPIP.Recv
2020-09-01 10:47:39 +00:00
bcc .8
2021-05-19 12:44:47 +00:00
2020-09-01 10:47:39 +00:00
cmp #E.NODATA
bne .9
2021-05-19 12:44:47 +00:00
2020-09-01 10:47:39 +00:00
lda TimeOut
bne .1
2021-05-19 12:44:47 +00:00
2020-09-01 10:47:39 +00:00
.9 sec
rts
2021-05-19 12:44:47 +00:00
2020-09-01 10:47:39 +00:00
.8 sta hFrame
2018-12-06 16:39:53 +00:00
>SYSCALL GetMemPtr
2019-10-03 06:25:27 +00:00
>STYA ZPFrameBase
2020-09-01 10:47:39 +00:00
rts
2018-12-06 16:39:53 +00:00
*--------------------------------------
2020-09-01 10:47:39 +00:00
DHCP.QUIT lda hSocket
2018-12-06 16:39:53 +00:00
beq .1
2020-10-29 13:50:46 +00:00
>LIBCALL hLIBTCPIP,LIBTCPIP.Shutdown
2020-10-30 09:51:37 +00:00
2019-01-05 20:33:08 +00:00
.1 clc
2018-12-06 16:39:53 +00:00
rts
*--------------------------------------
CheckDHCPOffer jsr CheckDHCPXID
bcs .9
2020-10-30 09:51:37 +00:00
2018-12-06 16:39:53 +00:00
cmp #S.DHCP.OPTIONS.DHCPOffer
bne .9
2020-10-30 09:51:37 +00:00
2019-01-17 15:05:48 +00:00
* ldy #S.DHCP.YIADDR+11 Copy YIADDR,SIADDR+GIADDR
* ldx #11
*.1 lda (ZPFrameBase),y
* sta DHCP.REQ.YIADDR,x
* dey
* dex
* bpl .1
2020-10-30 09:51:37 +00:00
2018-12-06 16:39:53 +00:00
ldy #S.DHCP.YIADDR+3
ldx #3
2020-10-30 09:51:37 +00:00
2018-12-06 16:39:53 +00:00
.2 lda (ZPFrameBase),y
sta DHCP.REQ.OPT.REQIP,x
sta IPCFG+S.IPCFG.IP,x
dey
dex
bpl .2
2020-10-30 09:51:37 +00:00
2019-01-17 15:05:48 +00:00
ldy #S.DHCP.SIADDR+3
lda (ZPFrameBase),y
bne .3
2020-10-30 09:51:37 +00:00
2018-12-06 16:39:53 +00:00
ldy #S.IP.SRC+3
2020-10-30 09:51:37 +00:00
2019-01-17 15:05:48 +00:00
.3 ldx #3
2020-10-30 09:51:37 +00:00
2019-01-17 15:05:48 +00:00
.4 lda (ZPFrameBase),y
2018-12-06 16:39:53 +00:00
sta IPCFG+S.IPCFG.DHCPSRVR,x
2019-01-17 15:05:48 +00:00
sta DHCP.REQ.OPT.SVRIP,x
2018-12-06 16:39:53 +00:00
dey
dex
2019-01-17 15:05:48 +00:00
bpl .4
2018-12-06 16:39:53 +00:00
.5 inc ZPFramePtr skip Option 53 (DHCPOffer:530102)
bne .6
2020-10-30 09:51:37 +00:00
2018-12-06 16:39:53 +00:00
inc ZPFramePtr+1
2020-10-30 09:51:37 +00:00
2018-12-06 16:39:53 +00:00
.6 lda (ZPFramePtr)
sec
2021-06-30 19:09:07 +00:00
adc ZPFramePtr add option len + 1
2018-12-06 16:39:53 +00:00
sta ZPFramePtr
bcc .7
2020-10-30 09:51:37 +00:00
2018-12-06 16:39:53 +00:00
inc ZPFramePtr+1
2020-10-30 09:51:37 +00:00
2018-12-06 16:39:53 +00:00
.7 lda (ZPFramePtr)
cmp #S.DHCP.OPTIONS.END
beq .8
2020-10-30 09:51:37 +00:00
2021-06-30 19:09:07 +00:00
jsr GetDHCPOption May override SVRIP
2018-12-06 16:39:53 +00:00
bra .5
2020-10-30 09:51:37 +00:00
2021-06-30 19:09:07 +00:00
.8 clc
.HS B0 BCS
.9 sec
php
lda hFrame
>SYSCALL FreeMem
plp
2018-12-06 16:39:53 +00:00
rts
*--------------------------------------
GetDHCPOption cmp #S.DHCP.OPTIONS.MASK
bne .1
2020-10-30 09:51:37 +00:00
2018-12-06 16:39:53 +00:00
ldx #S.IPCFG.MASK
bra GetDHCPOption.CopyIP
2020-10-30 09:51:37 +00:00
2018-12-06 16:39:53 +00:00
.1 cmp #S.DHCP.OPTIONS.GW
bne .2
2020-10-30 09:51:37 +00:00
2018-12-06 16:39:53 +00:00
ldx #S.IPCFG.GW
bra GetDHCPOption.CopyIP
2020-10-30 09:51:37 +00:00
2018-12-06 16:39:53 +00:00
.2 cmp #S.DHCP.OPTIONS.DNS
bne .3
2020-10-30 09:51:37 +00:00
2018-12-06 16:39:53 +00:00
ldx #S.IPCFG.DNS1
bra GetDHCPOption.CopyIP
2019-01-17 15:05:48 +00:00
.3 cmp #S.DHCP.OPTIONS.SRVID
bne .4
ldy #5
ldx #3
2020-10-30 09:51:37 +00:00
2019-01-17 15:05:48 +00:00
.31 lda (ZPFramePtr),y
sta DHCP.REQ.OPT.SVRIP,x
dey
dex
bpl .31
2020-10-30 09:51:37 +00:00
2019-01-17 15:05:48 +00:00
rts
2020-10-30 09:51:37 +00:00
2019-01-17 15:05:48 +00:00
.4 cmp #S.DHCP.OPTIONS.DOMAIN
2018-12-06 16:39:53 +00:00
bne .9
2020-10-30 09:51:37 +00:00
2018-12-06 16:39:53 +00:00
ldy #1
lda (ZPFramePtr),y Get String len
2019-01-17 15:05:48 +00:00
cmp #45
bcc .6
2020-10-30 09:51:37 +00:00
2019-01-17 15:05:48 +00:00
lda #44
2020-10-30 09:51:37 +00:00
2019-01-17 15:05:48 +00:00
.6 sta IPCFG+S.IPCFG.DOMAIN store len
2020-10-30 09:51:37 +00:00
2018-12-06 16:39:53 +00:00
tax
2020-10-30 09:51:37 +00:00
2019-01-17 15:05:48 +00:00
.7 iny
2018-12-06 16:39:53 +00:00
lda (ZPFramePtr),y
sta IPCFG+S.IPCFG.DOMAIN-1,y
dex
2019-01-17 15:05:48 +00:00
bne .7
2021-05-19 12:44:47 +00:00
2018-12-06 16:39:53 +00:00
.9 rts
*--------------------------------------
GetDHCPOption.CopyIP
ldy #1
lda (ZPFramePtr),y Get Byte count
cmp #9
bcc .1
2020-10-30 09:51:37 +00:00
2018-12-06 16:39:53 +00:00
lda #8 max 8 bytes (2 DNS)
2020-10-30 09:51:37 +00:00
2018-12-06 16:39:53 +00:00
.1 iny
2020-10-30 09:51:37 +00:00
2018-12-06 16:39:53 +00:00
.2 pha
lda (ZPFramePtr),y
sta IPCFG,x
iny
inx
pla
dec
bne .2
2020-10-30 09:51:37 +00:00
2018-12-06 16:39:53 +00:00
rts
*--------------------------------------
CheckDHCPAck jsr CheckDHCPXID
bcs .9
2020-10-30 09:51:37 +00:00
2018-12-06 16:39:53 +00:00
cmp #S.DHCP.OPTIONS.DHCPAck
bne .9
2020-10-30 09:51:37 +00:00
2021-06-30 19:09:07 +00:00
.8 clc
.HS B0 BCS
.9 sec
php
lda hFrame
2019-01-05 20:33:08 +00:00
>SYSCALL FreeMem
2021-06-30 19:09:07 +00:00
plp
2019-01-05 20:33:08 +00:00
rts
*--------------------------------------
2018-12-06 16:39:53 +00:00
CheckDHCPXID ldy #S.DHCP.XID+3
ldx #3
2020-10-30 09:51:37 +00:00
2018-12-06 16:39:53 +00:00
.1 lda (ZPFrameBase),y
cmp DHCP.DISC.XID,x same XID ?
bne .9
2020-10-30 09:51:37 +00:00
2018-12-06 16:39:53 +00:00
dey
dex
bpl .1
2020-10-30 09:51:37 +00:00
2021-06-30 19:09:07 +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
ldy #2
lda (ZPFramePtr),y
2018-12-06 16:39:53 +00:00
clc
rts
2020-10-30 09:51:37 +00:00
2018-12-06 16:39:53 +00:00
.9 sec
rts
*--------------------------------------
MAN
2020-08-09 19:47:42 +00:00
SAVE usr/src/bin/ipconfig.s.dhcp
LOAD usr/src/bin/ipconfig.s
2018-12-06 16:39:53 +00:00
ASM