NEW
  AUTO 3,1
*--------------------------------------
CFG.GET			>LDYA L.IPCFG
				clc
CFG.GET.RTS		rts
*--------------------------------------
CFG.SET			>PULLW ZPTmpPtr1		IPCFG

				ldy #S.IPCFG-1

.1				lda (ZPTmpPtr1),y
				sta IPCFG,y
				dey
				bpl .1

				>LDYA L.DCB.NIC
				>STYA IOCTL+S.IOCTL.BUFPTR

				lda #S.IOCTL.S.GETDCB
				sta IOCTL+S.IOCTL.S

				ldx #IOCTL.STATUS
				jsr CFG.IOCTL
				bcs CFG.GET.RTS
				
				ldx #11					IP/MASK/GW

				lda IPCFG+S.IPCFG.IP
				bne .3
				
				lda DCB.NIC+S.DCB.NIC.IP
				beq .6
	
.2				lda DCB.NIC+S.DCB.NIC.IP,x
				sta IPCFG+S.IPCFG.IP,x
				dex
				bpl .2
				
				lda #S.IPCFG.STATUS.OK
				sta IPCFG
				
				bra .6
				
.3				lda IPCFG+S.IPCFG.IP,x
				sta DCB.NIC+S.DCB.NIC.IP,x
				dex
				bpl .3

.6				lda #S.IOCTL.C.SETDCB
				sta IOCTL+S.IOCTL.C

				ldx #IOCTL.CONTROL				NIC driver may wants IP config....
				jsr CFG.IOCTL
*				bcs CFG.GET.RTS					.....or not

				ldx #5

.7				lda IPCFG+S.NETCFG.MAC,x
				sta ARP.REQ.SRCMAC,x
				sta ARP.REQ.SHA,x
				sta ARP.REP.SRCMAC,x
				sta ARP.REP.SHA,x
				dex
				bpl .7

				ldx #3

.8				lda IPCFG+S.IPCFG.IP,x
				sta SA.LOCAL+S.SOCKADDR.ADDR,x
				sta ARP.REQ.SPA,x
				sta ARP.REP.SPA,x
				dex
				bpl .8

				stz SA.LOCAL+S.SOCKADDR.PORT
				stz SA.LOCAL+S.SOCKADDR.PORT+1

				>PUSHB hDNSSocket
				>PUSHW L.SA.LOCAL
				jmp SKT.Bind
*--------------------------------------
CFG.IOCTL		>PUSHB IPCFG+S.NETCFG.DevID
				txa
				>PUSHA
				>PUSHW L.IOCTL
				>SYSCALL2 IOCTL
				rts
*--------------------------------------
MAN
SAVE usr/src/lib/libtcpip.s.cfg
LOAD usr/src/lib/libtcpip.s
ASM
